akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

int i;
int a[7];
int t;

void input()
{
    //配列にさいころの数字を割り当てる
    for (i = 1; i <= 6; i++){
        scanf("%d", &a[i]);
    }
}

int main(void)
{
    input();
    int n, u, w;

    scanf("%d", &n);
    for (i = 0;i < n; i++){
        scanf("%d %d", &u, &w);

        if (u == a[1]){
            if (w == a[2]){
                printf("%d\n", a[3]);
            }else if (w == a[3]){
                printf("%d\n", a[5]);
            }else if (w == a[5]){
                printf("%d\n", a[4]);
            }else if(w == a[4]){
                printf("%d\n", a[2]);
            }
        }else if (u == a[2]){
            if (w == a[6]){
                printf("%d\n", a[3]); 
            }else if (w == a[3]){
                printf("%d\n", a[1]);
            }else if (w == a[1]){
                printf("%d\n", a[4]);
            }else if(w == a[4]){
                printf("%d\n", a[6]);
            }
        }else if (u == a[3]){
            if (w == a[1]){
                printf("%d\n", a[2]); 
            }else if (w == a[2]){
                printf("%d\n", a[6]);
            }else if (w == a[6]){
                printf("%d\n", a[5]);
            }else if(w == a[5]){
                printf("%d\n", a[1]);
            }
        }else if (u == a[4]){
            if (w == a[1]){
                printf("%d\n", a[5]); 
            }else if (w == a[5]){
                printf("%d\n", a[6]);
            }else if (w == a[6]){
                printf("%d\n", a[2]);
            }else if(w == a[2]){
                printf("%d\n", a[1]);
            }
        }else if (u == a[5]){
            if (w == a[1]){
                printf("%d\n", a[3]); 
            }else if (w == a[3]){
                printf("%d\n", a[6]);
            }else if (w == a[6]){
                printf("%d\n", a[4]);
            }else if(w == a[4]){
                printf("%d\n", a[1]);
            }
        }else if (u == a[6]){
            if (w == a[2]){
                printf("%d\n", a[4]); 
            }else if (w == a[4]){
                printf("%d\n", a[5]);
            }else if (w == a[5]){
                printf("%d\n", a[3]);
            }else if(w == a[3]){
                printf("%d\n", a[2]);
            }
        }
    }

    return (0);
}




Measured memory_bytes: 2032
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
const int maxn = 100 + 5;
int a[maxn][maxn];
int n, m;
const int N = maxn * 2;
int g[N][N];
int mat[N];
void ad_e(int x,int y){
	y += n;
	g[x][y] = 1;
	g[y][x] = 1;
}
bool mark[N];
bool dfs(int v){ // can find aug path
	if(mark[v])
		return false;
	mark[v] = 1;
	for(int i=0; i<N; i++){
		if(g[v][i] == 0)
			continue;
		if(mat[i] == -1 || dfs(mat[i])){
			mat[i] = v;
			mat[v] = i;
			return true;
		}
	}
	return false;
}
int32_t main(){
	IOS;
	cin >> n >> m;
	for(int i=0; i<n; i++)
		for(int j=0; j<m; j++){
			cin >> a[i][j];
			a[i][j]--;
		}
	for(int col=0; col<m; col++){
		memset(mat, -1, sizeof mat);
		memset(g, 0, sizeof g);
		for(int i=0; i<n; i++){
			for(int j=col; j<m; j++){
				ad_e(i, a[i][j]/m);		
			}
		}
		int sz = 0;
		for(int i=0; i<n; i++){
			memset(mark, 0, sizeof mark);
			sz += dfs(i);
		}
		//cout << col << " " << sz << endl;
		for(int i=0; i<n; i++){
			int u = mat[i] - n;
			for(int j=col; j<m; j++){
				if(a[i][j]/m == u){
					swap(a[i][j], a[i][col]);
					break;
				}
			}
		}/*
		for(int i=0; i<n; i++){
			for(int j=0; j<m; j++){
				cout << a[i][j]/m << " ";
			}
			cout << endl;
		}*/
	}	
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cout << a[i][j] + 1 << " ";
		}
		cout << endl;
	}
	for(int i=0; i<m; i++){
		vi v;
		for(int j=0; j<n; j++)
			v.push_back(a[j][i]);
		sort(all(v));
		for(int j=0; j<n; j++)
			a[j][i] = v[j];
	}
	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cout << a[i][j] + 1 << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;

const int MAX = 52;
int main() {
	int H, W;
	cin >> H >> W;
	string s[MAX];
	for (int i = 0;i <= W + 1;++ i) {
		s[0] += '.';
		s[H + 1] += '.';
	}
	for (int i = 1;i <= H;++ i) {
		cin >> s[i];
		s[i] = '.' + s[i] + '.';
	}
	for (int i = 1;i <= H;++ i) {
		for (int j = 1;j <= W;++ j) {
			if (s[i][j] == '#' && s[i][j + 1] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.' && s[i - 1][j] == '.') {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、nマスが隣接しているとするよ
2マスが隣接しているなら塗ることは可能
n-1マスが塗れているなら、残った1マスは隣接した黒色と一緒に塗れば塗れるので2≦nなら塗ることは可能
逆に1マスなら塗れないので、要するに'.'で囲まれた'#'があるかどうか判定すれば良い
*/

Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<3; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);

        System.out.println(list.get(2) * 10 + list.get(1) + list.get(0));

    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <deque>
using namespace std;
typedef long long ll;
vector<pair<ll, ll>> v;
ll mod = 998244353;
ll d[200001];
ll dp[200001][2];
ll tree[800001];
ll n;
void Update(int node, int x, int y, int i, int val) {
	if (x > i || y < i)return;
	if (x == y) {
		tree[node] = val;
	}
	else {
		int mid = (x + y) / 2;
		Update(node * 2, x, mid, i, val);
		Update(node * 2 + 1, mid + 1, y, i, val);
		tree[node] = max(tree[node * 2], tree[node * 2 + 1]);
	}
}
int Quary(int node, int x, int y, int i, int j) {
	if (x > j || y < i)return 0;
	if (i <= x && y <= j)return tree[node];
	int mid = (x + y) / 2;
	return max(Quary(node * 2, x, mid, i, j), Quary(node * 2 + 1, mid + 1, y, i, j));
}
ll go(int x, int y) {
	if (x == n) {
		if (y == 1)return 1;
		return 0;
	}
	if (dp[x][y] != -1)return dp[x][y];
	ll &ret = dp[x][y];
	ret = 0;
	if (y == 0) {
		ret += go(x + 1, 0); ret %= mod;
		ret += go(x + 1, 1); ret %= mod;
	}
	else {
		ret += go(d[x] + 1, 0); ret %= mod;
		ret += go(d[x] + 1, 1); ret %= mod;
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		ll x, y; cin >> x >> y;
		v.push_back({ x,y });
	}
	sort(v.begin(), v.end());
	d[n - 1] = n - 1;
	Update(1, 0, n - 1, n - 1, n - 1);
	for (int i = n - 2; i >= 0; i--) {
		auto p = upper_bound(v.begin(), v.end(), pair<ll, ll>(v[i].first + v[i].second - 1, 1e9 + 1)) - v.begin();
		int cnt = Quary(1, 0, n - 1, i, p - 1);
		if (cnt == 0)d[i] = i;
		else d[i] = cnt;
		Update(1, 0, n - 1, i, d[i]);
	}
	
	memset(dp, -1, sizeof(dp));

	cout << ((go(0, 0) + go(0, 1)) % mod) << '\n';



}




Measured memory_bytes: 21484
#define _GLIBCXX_DEBUG

#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#include <cmath>

#define int long long

using namespace std;

signed main() {
  int n;
  cin >> n;

  double t = 0;
  for (int i = 0; i < n; i++) {
    double a;
    cin >> a;

    t += 1 / a;
  }

  printf("%.15f\n", 1 / t);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner scan = new Scanner(System.in);

		int n=scan.nextInt();
		long m=100000;
		for(int i=0;i<n;i++){
			m=(long)(1.05*m);
			if(m%1000>0){
				m+=1000;
				m-=m%1000;
			}
		}
		System.out.println(m);
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans=0,g=0,p=0;
  int S=s.size();
  for(int i=0;i<S;i++){
    if(s[i]=='g'){g++;}
    else{p++;}
  }
  if(S%2==0){ans=S/2-p;}
  else{ans=(S-1)/2-p;}
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll A,B,C,_A,_B,_C;
    cin >> A >> B >> C;
    int ans = 0;
    while(true){
        if(A == B && B == C && C == A && A%2 == 0){
            ans = -1;
            break;
        }
        if(A%2 == 1 || B%2 == 1 || C%2 == 1){
            break;
        }
        _A = A;_B = B;_C = C;
        A = (_B + _C)/2;
        B = (_A + _C)/2;
        C = (_A + _B)/2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll bin_pow(ll x, ll n, ll mod =MD){
	ll res = 1LL;
	for(; n > 0; n >>=1, x = x*x %mod) if(n & 1) res = res * x %mod;
	return res;
}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n, k, ans =0;
	cin >>n >>k;
	VL dp(k+10), ep(k+10);

	rep2(i, 1, k+1) dp[i] = bin_pow(k / i, n);
	repr(i, k, 1){
		ep[i] = dp[i];
		for(int j=2*i; j<=k; j+=i) (ep[i] += MD - ep[j]) %=MD;
		(ans += ep[i] * i) %=MD;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 4784
#include<iostream>
#include<vector>
using namespace std;
int main(){
int a, b, c, d, e;
cin >> a >> b >> c >> d >> e;

if(a==0){
    cout << b-1 << endl;
}else if(b == 0){
    cout << a+1 << endl;
}else if(c == 0){
    cout << b+1 << endl;
}else if(d == 0){
    cout << c+1 << endl;
}else if(e == 0){
    cout << d+1 << endl;
}

    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans;
    if ((a * c >= 0) || (b * d >= 0)) {
        ans = max(a * c, b * d);
    } else {
        if (a < 0) {
            ans = b * c;
        } else {
            ans = a * d;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main()
{
    
    while(1)
    {
      int n, x;
      int cnt = 0;
      cin >> n >> x;
      
      if( n == 0 && x == 0)
      { break; }
      
      for(int i = 1; i <= n; ++i)
      {
          for(int j = i + 1; j <= n; ++j)
          {
              for(int k = j + 1; k <= n; ++k)
              {
                  if( i + j + k == x)
                  { ++cnt; }
                  
              }
              
          }
          
      }
    
      cout << cnt << endl;
    }
    return 0;
    
}


Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int q = vs[1];
			string s = Console.ReadLine();
			int[] ans = new int[n + 1];
			for (int i = 0; i < n - 1; i++) {
				ans[i + 1] = ans[i];
				if (s[i] == 'A' && s[i + 1] == 'C') {
					ans[i + 1]++;
				}
			}
			for (int i = 0; i < q; i++) {
				vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				int l = vs[0] - 1;
				int r = vs[1] - 1;
				Console.WriteLine(ans[r] - ans[l]);
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 18500
/*input
8 5
-9 -7 -4 -3 1 2 3 4
1 1
0
3 2
10 20 30
5 3
-30 -10 10 20 50
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define mp make_pair
#define N
#define bit(x,y) ((x>>y)&1LL)
#define loop(x) for(int xv=1; xv<=x; xv++)

#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &a) {
	return os << '(' << a.first << ", " << a.second << ')';
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &a) {
	os << '[';
	for (unsigned int i = 0; i < a.size(); i++)
		os << a[i] << (i < a.size() - 1 ? ", " : "");
	os << ']';
	return os;
}
template <class T>
ostream &operator<<(ostream &os, const set<T> &a) {
	os << '{';
	for (typename set<T>::iterator it = a.begin(); it != a.end(); it++) {
		typename set<T>::iterator jt = it;
		os << *it << (++jt != a.end() ? ", " : "");
	}
	os << '}';
	return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &a) {
	os << "{\n";
	for (typename map<T1, T2>::iterator it = a.begin(); it != a.end(); it++) {
		typename map<T1, T2>::iterator jt = it;
		os << "  " << it->first << ": " << it->second << (++jt != a.end() ? ",\n" : "\n");
	}
	os << '}';
	return os;
}

int n, k;
vector<int> neg, pos;
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	loop(n) {
		int t; cin >> t;
		if (t < 0)neg.push_back(t);
		else pos.push_back(t);
	}
	int ans = 1e9;
	for (int i = 0; i <= min((int)pos.size(), k); i++) {
		if (i == 0) {
			int p = (int)neg.size() - k;
			if (p < 0) continue;
			ans = min(ans, abs(neg[p]));
		}
		else if (i == k) {
			ans = min(ans, pos[i - 1]);
		}
		else {
			if ((int)neg.size() - (k - i) < 0) continue;
			int left = abs(neg[neg.size() - (k - i)]);
			int right = pos[i - 1];
			ans = min(ans, left + right + min(left, right));
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 1020
#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, t, v, f[N];
ll s;

int main()
{
    scanf("%d", &n);
    while(n--){
        scanf("%d", &t);
        f[t]++;
        s += t;
    }
    scanf("%d", &n);
    while(n--){
        scanf("%d%d", &t, &v);
        s += 1ll * f[t] * (v - t);
        f[v] += f[t];
        f[t] = 0;
        printf("%lld\n", s);
    }

    return 0;
}


Measured memory_bytes: 4180
S = input()

year = int(S[0:4])
month = int(S[5:7])
day = int(S[8:])

if(year<2019): #~2018年
    print("Heisei")
else: #2019~
    if(month==4):
        if(day<=30):
            print("Heisei")
        else:
            print("TBD")
    elif(month<4):
        print("Heisei")
    else: #5月~
        print("TBD")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	if((a==b&&b!=c)||(b==c&&a!=b)||(a==c&&a!=b)){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------

int main(void){
    ll a,b,c;cin>>a>>b>>c;
    if(a<b&&b<c)cout<<"Yes";
    else cout<<"No";
    cout<<"\n";
    return 0;
}



Measured memory_bytes: 3080
#!/usr/bin/env python3

import sys, math
sys.setrecursionlimit(300000)


def solve(N: int):
    n = math.ceil(N ** 0.5)
    ret = [0] * (N + 1)
    for x in range(1, n + 1):
        for y in range(1, n + 1):
            for z in range(1, n + 1):
                s = x * x + y * y + z * z + x * y + y * z + z * x
                if 1 <= s <= N:
                    ret[s] += 1
    for i in range(N):
        print(ret[i + 1])
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69236
#include <iostream>
#include <string>
#include <algorithm>

int main(){
   std::string S;
   std::cin >> S;
   bool fe = (std::find(S.begin(), S.end(), 'E') == S.end())? false : true;
   bool fw = (std::find(S.begin(), S.end(), 'W') == S.end())? false : true;
   bool fs = (std::find(S.begin(), S.end(), 'S') == S.end())? false : true;
   bool fn = (std::find(S.begin(), S.end(), 'N') == S.end())? false : true;
   if ((fe == fw) && (fs == fn)){
      std::cout << "Yes" << std::endl;
   } else{
      std::cout << "No" << std::endl;
   }
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define mp(i,j) make_pair(i,j)
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

typedef long long ll;
typedef pair<int, int> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

ll a[200010];

void Main()
{
	int N; cin >> N;
	rep(i,N) {
		ll _a; cin >> _a;
		_a -= (i + 1);
		a[i] = _a;
	}
	sort(a, a+N);
	ll res = 0;
	rep(i,N/2) {
		res += a[N - 1 - i] - a[i];
	}
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  // x を正の座標にする
  x = abs(x);

  // x 座標から 0 に向かって移動可能な回数を算出する
  //
  // * 移動回数は基本 x/d 回だが、k < x/d の場合は k となる
  // * 0 を超えてマイナスには移動しない
  // * 最大でも座標 0 に着地する
  //   * 例えば x = 8, d = 4, k = 100 の場合
  //   * x/d = 8/4 = 2 で、2回 -4 側に移動し、x=0 に着地する
  //
  ll straight = min(k, x/d);

  // 座標と回数を変化させる
  k = k - straight;
  x = x - (straight * d);

  // 残りの移動回数が偶数回の場合
  //
  // * 移動して戻ってくるを繰り返すことで、現在の座標に留まることが、最小値となる
  // * 0の場合も同様
  //
  if (k % 2 == 0) {
    cout << x << endl;
  // 残りの移動回数が奇数回の場合
  //
  // * k = 0 のケース
  //   * min(k, floor(x/d)) == k だった
  //     * 移動回数の上限が少なく、x が 0 に到達する (あるいは 0 を通り抜ける) 前に、回数上限に達する
  //   * min(k, floor(x/d)) == k ( == floor(x/d))
  //     * 移動回数の上限と、x が 0 に到達する (あるいは 0 を通り抜ける) 回数が一致
  // * k > 0 のケース
  //   * min(k, floor(x/d)) == floor(x/d)
  //   * つまり k 回移動する前に、floor(x/d) 回の移動で、x が 0 付近に到達する
  //   * この際、移動先の座標は d 未満となる
  //     * 逆に座標が d 以上の場合は floor(x/d) で移動回数を算出する時点で、移動回数が +1 される
  //   * そのため、x < d のため、d - x > 0 となり、正の値を出力する
  //
  } else {
    cout << d-x << endl;
  }

  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
    int a, b, sum;
    int i;

    while(scanf("%d %d", &a, &b) != EOF){
        sum = a + b;
        for(i = 0; sum != 0; i++){
            sum /= 10;
        }
        printf("%d\n", i);
    }
    
    return 0;
}

Measured memory_bytes: 600
/**Bismillahir Rahmanir Raheem
    Author:Refatul Fahad**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define pil pair<int,ll>
#define IOS  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
const int N = 1e5 + 5;
const ll M = (ll)1e9 + 7;
const double pi=2*acos(0.0);
const double esp=1e-9;
int Set(int N,int pos) {
    return N=N | (1<<pos);
}
int reset(int N,int pos) {
    return N= N & ~(1<<pos);
}
bool check(int N,int pos) {
    return (bool)(N & (1<<pos));
}

int dx[]= {0,0,1,-1};
int dy[]= {1,-1,0,0};

int main() {

    //IOS;
    /// freopen("input.txt","r",stdin);
    /// freopen("output.txt","w",stdout);

    int test=1;
    //cin>>test;
    for(int cs=1; cs<=test; ++cs) {
        int n,ans=0;
        cin>>n;
        string s;
        cin>>s;
        int cr=0,cw=0;
        for(int i=0; i<n; ++i) {
            if(s[i]=='R')++cr;
            else ++cw;
        }
        if(cr==0||cw==0) {
            cout<<0<<endl;
        } else {
            for(int i=0; i<n&&cr>0; ++i) {
                if(s[i]=='W') {
                    ++ans,--cr;
                } else {
                    --cr;
                }
            }
            cout<<ans<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3732
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define ll long long
using namespace std;
const int maxn = 500010, inf = 1e9 + 233;

template<typename T>
inline void read(T &k)
{
    int f = 1; k = 0; char c = getchar();
    while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar();
    while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar();
    k *= f;
}

int main()
{
    int x, y;
    read(x); read(y);
    printf("%.7lf\n", 1.0 * x / y);
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans;
int A,B,C;
string S;

void solve(){

    if(S[2] == S[3] && S[5] == S[4])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    cin >> S;

    solve();
}


Measured memory_bytes: 256
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = input()

ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)


Measured memory_bytes: 16088
while True:
    inputted_str = input().split()
    x = int(inputted_str[0])
    y = int(inputted_str[1])

    if x == 0 and y == 0:
        break
    elif x < y:
        print("{} {}".format(x, y))
    else:
        print("{} {}".format(y, x))

Measured memory_bytes: 7532
open System

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev s =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

[<EntryPoint>]
let main _ =
    let [|X;Y|] = reada int
    if X % Y = 0 then -1
    else X
    |> printfn "%d"
    0 // return an integer exit code


Measured memory_bytes: 14160
#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  char b;
  cin >> b;
  if (b == 'A') cout << 'T';
  if (b == 'T') cout << 'A';
  if (b == 'C') cout << 'G';
  if (b == 'G') cout << 'C';
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



int N;
int A[1 << 18];
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, 1 << 18) scanf("%d", &A[i]);

	int NN = 1 << N;

	while (1 < NN) {
		rep(i, 0, NN / 2) {
			if (A[i * 2] == A[i * 2 + 1]) {
				A[i] = A[i * 2];
			}
			else{
				A[i] = abs(A[i * 2 + 1] - A[i * 2]);
			}
		}
		NN /= 2;
	}

	cout << A[0] << endl;
}

Measured memory_bytes: 1280
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] ans=new int[n];
		for(int i=0; i<n; i++){
			int a=sc.nextInt();
			ans[a-1]=i+1;
		}
		for(int i=0; i<n; i++){
			System.out.print(ans[i]+" ");
		}
	}
}


Measured memory_bytes: 63272
# UnionFind、0-indexであることに注意
#############################################################


class UnionFind:

    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, v):  # vが属する集合の根を返す
        if self.parents[v] < 0:
            return v
        else:
            self.parents[v] = self.find(self.parents[v])
            return self.parents[v]

    def unite(self, u, v):  # 「uが属する集合」と「vが属する集合」を併合（根同士を結ぶ）
        u = self.find(u)
        v = self.find(v)
        if u == v:
            return
        if self.parents[u] > self.parents[v]:  # u < v に統一する
            u, v = v, u
        self.parents[u] += self.parents[v]
        self.parents[v] = u

    def size(self, v):  # vが属する集合の要素数
        return -self.parents[self.find(v)]

    def same(self, u, v):  # uとvが同じ集合に属するか否か
        return self.find(u) == self.find(v)


#############################################################
N, M = map(int, input().split())

uf = UnionFind(N)

# a+bの偶奇が分かる
# ここで、実際の偶奇や、zの値は必要ない
# 一方が分かれば他方も分かる、ということが本質
for _ in range(M):
    a, b, z = map(int, input().split())
    uf.unite(a - 1, b - 1)

# A_1 + A_2の偶奇, A_2 + A_3の偶奇が分かった時、
# 1つだけ魔法で確定させれば他の値は確定する。

# M個の条件についてUnionFindを生成する。
# 連結成分ごとに1回魔法を使えばあとは芋づる式に求まる。

# (連結成分の個数) = (rootの値が何種類存在するか)

root_list = []

for i in range(N):
    root_list.append(uf.find(i))

root_set = set(root_list)

print(len(root_set))


Measured memory_bytes: 96068
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    int ans = 0;
    if(N>K){
        ans += K*X + (N-K)*Y;
    }
    else ans += N*X;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int tt = c % b == 0 ? c / b : c / b + 1;
  int ta = a % d == 0 ? a / d : a / d + 1;
  string ans;
  if(tt <= ta) {
    ans = "Yes";
  }
  else {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3552
n=int(input())
h=list(map(int,input().split()))
d=[]
a=[]
x=0
k=0
while k<len(h)-1:
  if h[k]==h[k+1]:
    h.pop(k)
    k-=1
  k+=1

for i in range(1,len(h)-1):
  if h[i-1]>h[i]<h[i+1]:
    a.append(h[i])
    x=1
for i in range(1,len(h)-1):
  if h[i-1]<h[i]>h[i+1]:
    d.append(h[i])
    x=1
               
if len(h) >= 2:
  if h[0]>=h[1]:
    d.append(h[0])
  if h[-1]>=h[-2]:
    d.append(h[-1])
  print(sum(d)-sum(a))
else:
  print(h[0])

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main
{

  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    String in_S;

    try
    {

      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");


      in_S = in_str_split[0];

      UtilLog.ans_ln("2018/" + in_S.substring(5));
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }
}

class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 21204
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	string s;

	cin >> s;
	long long sum = 0;
	for (long long i = 0; i < s.length(); ++i) {
		sum = (sum + (s[i] - 0x30)) % 9;
	}

	if (sum == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class DSU {
  private: vector<int> p, rank;
  public:
    DSU(int n) {
      p = vector<int>(n, -1);
      rank = vector<int>(n, 0);
    }
    int root(int x) {
      if (p[x] == -1) {
        return x;
      }
      return (p[x] = root(p[x]));
    }
    bool sameSet(int x, int y) {
      return root(x) == root(y);
    }
    void connect(int x, int y) {
      x = root(x);
      y = root(y);
      if (x != y) {
        if (rank[x] > rank[y]) {
          p[y] = x;
        } else {
          p[x] = y;
          rank[y] += (rank[x] == rank[y]);
        }
      }
    }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> edges;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    edges.push_back({w, {u, v}});
  }
  sort(edges.begin(), edges.end());
  DSU dsu(n);
  int ans = 0;
  for (auto& edge : edges) {
    int u = edge.second.first;
    int v = edge.second.second;
    int w = edge.first;
    if (!dsu.sameSet(u, v)) {
      dsu.connect(u, v);
      ans += w;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 4448
// 2011/01/16 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	string str;
	istringstream is;

	getline(cin, str);
	is.str(str);

	int n;
	is >> n;

	int cst[21][21];
	for(int i=1; i<=n; i++)
		for(int j=1; j<=n; j++)
			if(i==j)
				cst[i][j] = 0;
			else
				cst[i][j] = -1;

	is.clear();

	getline(cin, str);
	is.str(str);

	int m;
	is >> m;

	for(int i=0; i<m; i++){
		is.clear();

		getline(cin, str);
		for(int j=0; j<str.size(); j++)
			if(str[j]==',')
				str[j] = ' ';

		is.str(str);

		int a, b, c, d;
		is >> a >> b >> c >> d;
		cst[a][b] = c;
		cst[b][a] = d;
	}

	for(int k=1; k<=n; k++)
		for(int i=1; i<=n; i++)
			for(int j=1; j<=n; j++)
				if(cst[i][k]!=-1&&cst[k][j]!=-1)
					if(cst[i][j]==-1||cst[i][j]>cst[i][k]+cst[k][j])
						cst[i][j] = cst[i][k]+cst[k][j];

	is.clear();

	getline(cin, str);
	for(int i=0; i<str.size(); i++)
		if(str[i]==',')
			str[i] = ' ';

	is.str(str);

	int x1, x2, y1, y2;
	is >> x1 >> x2 >> y1 >> y2;

	cout << y1-y2-cst[x1][x2]-cst[x2][x1] << endl;

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	int x[5], y[5];
	cin >> x[1] >> y[1] >> x[2] >> y[2];
	x[3] = x[2] + y[1] - y[2];
	y[3] = y[2] + x[2] - x[1];
	x[4] = x[1] + y[1] - y[2];
	y[4] = y[1] + x[2] - x[1];
	cout << x[3] << " " << y[3] << " " << x[4] << " " << y[4] << endl;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int solve(int n){
	for(int i = 0; i < n; i++){
		char s[2]; scanf("%s", s);
		if(s[0] == 'Y') return 1;
	}
	return 0;
}

int main(){
	int n; scanf("%d", &n);
	puts(solve(n) ? "Four" : "Three");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
// z[i] is the length of the longest common prefix between s and the suffix of s starting at i
vector<int> make_z_function(const string& s) {
    vector<int> z(s.length() + 1);
    z[0] = s.length();
    for(int i = 1, L = 0, R = 0; i < s.length(); i++) {
        z[i] = i < R ? min(z[i - L], R - i) : 0;
        while(i + z[i] < s.length() and s[i + z[i]] == s[z[i]]) {
            z[i]++;
        }
        if(R < i + z[i]) {
            L = i, R = i + z[i];
        }
    }
    return z;
}
map<char, vector<int>> make_occ(const string& S) {
    map<char, vector<int>> occ;
    for(char c = 'a'; c <= 'z'; c++) {
        occ[c] = vector<int>(S.size() + 1);
        for(int i = 1; i <= S.size(); i++) {
            occ[c][i] = S[i - 1] == c;
        }
        partial_sum(occ[c].begin(), occ[c].end(), occ[c].begin());
    }
    return occ;
}
void solve(std::string S, long long l, long long r) {
    S = S.substr(0, S.size() / 2);
    auto z = make_z_function(S);
    string T;
    for(int i = 1; i <= S.size() and T.size() == 0; i++) {
        if(z[i] == S.size() - i) {
            T = S.substr(0, i);
        }
    }
    auto occ0 = make_occ(S), occ1 = make_occ(S + T);
    if(S.size() % T.size() == 0) {
        auto C = [&](ll i, char c) {
            return i / S.size() * occ0[c][S.size()] + occ0[c][i % S.size()];
        };
        for(char c = 'a'; c <= 'z'; c++) {
            cout << C(r, c) - C(l - 1, c) << " \n"[c == 'z'];
        }
    } else {
        vector<ll> len = {ll(S.size()), ll(S.size() + T.size())};
        while(len.back() < r) {
            len.push_back(len[len.size() - 1] + len[len.size() - 2]);
        }
        map<tuple<int, ll, char>, ll> memo;
        function<ll(int, ll, char)> C = [&](int level, ll i, char c) -> ll {
            auto p = make_tuple(level, i, c);
            if(not memo.count(p)) {
                ll& ans = memo[p];
                if(level == 0) {
                    ans = occ0[c][i];
                } else if(level == 1) {
                    ans = occ1[c][i];
                } else if(i > len[level - 1]) {
                    ans = C(level - 1, len[level - 1], c) + C(level - 2, i - len[level - 1], c);
                } else {
                    ans = C(level - 1, i, c);
                }
            }
            return memo[p];
        };
        for(char c = 'a'; c <= 'z'; c++) {
            cout << C(len.size() - 1, r, c) - C(len.size() - 1, l - 1, c) << " \n"[c == 'z'];
        }
    }
}
int main() {
    std::string S;
    std::cin >> S;
    long long l;
    scanf("%lld",&l);
    long long r;
    scanf("%lld",&r);
    solve(S, l, r);
    return 0;
}


Measured memory_bytes: 31936
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<(b)?(a=b,1):0)
#define chmin(a,b) (a>(b)?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef pair<int,int> pii;
typedef long long ll;

char a[50][50];
int dp[50][50][4][1<<11];
int bitMap[4][1<<11][4];
bool canGet[4][1<<11][4];
vector<pii> needCells[4];

const int dy[4] = {0,1,0,-1};
const int dx[4] = {1,0,-1,0};

int h,w,K;

int solve(int y, int x, int k, int S){
  int &r = dp[y][x][k][S];
  if (r != -1) return r;
  int res = -INF;
  if (y==h-1&&x==w-1) res = 0;
  REP(d,4) {
    int nk = k+(d>=2);
    if (nk>K) continue;
    int ny = y+dy[d];
    int nx = x+dx[d];
    if (!valid(ny,nx,h,w)) continue;
    if (a[ny][nx] == '#') continue;
    int score = canGet[k][S][d]&&isdigit(a[ny][nx]) ? a[ny][nx]-'0' : 0;
    chmax(res, solve(ny,nx,nk,bitMap[k][S][d]) + score);
  }
  return r = res;
}

int main() {
  REP(k,4) {
    for (int y=-3; y<=3; ++y) {
      for (int x=-3; x<=3; ++x) {
        if ((y||x) && -min(y,0)-min(x,0) <= 3-k && max(0,y)+max(0,x) <= k)
          needCells[k].push_back(pii(y,x));
      }
    }
  }
  REP(k,4) {
    int n = needCells[k].size();
    REP(S,1<<n) {
      REP(d,4) {
        int nk = k+(d>=2);
        if (nk == 4) continue;
        int T = 0;
        REP(i,n) {
          if (S>>i&1) {
            pii p = needCells[k][i];
            p.first -= dy[d];
            p.second -= dx[d];
            REP(j,needCells[nk].size()) {
              if (needCells[nk][j] == p) {
                T |= 1 << j;
              }
            }
          }
        }
        REP(j,needCells[nk].size()) {
          if (needCells[nk][j] == pii(-dy[d],-dx[d])) {
            T |= 1 << j;
          }
        }
        bitMap[k][S][d] = T;

        canGet[k][S][d] = 1;
        REP(i,n)
          if (S>>i&1 && needCells[k][i]==pii(dy[d],dx[d]))
            canGet[k][S][d] = 0;
      }
    }
  }
  scanf("%d%d%d",&h,&w,&K);
  REP(i,h) REP(j,w) scanf(" %c ", a[i]+j);
  memset(dp,-1,sizeof(dp));
  cout << solve(0,0,0,0) << endl;
  
}

Measured memory_bytes: 81348
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <string>
#include <map>
#include <queue>
using namespace std;
int a[222222];
int n, k;
int main() {
  scanf("%d%d", &n, &k);
  int x;
  for (int i = 0; i < n; i++)
  {
    scanf("%d", &x);
    a[x]++;
  }
  sort(a, a + 200001);
  int sum = 0;
  for (int i = 200000; k > 0 && i >= 1; i--)
  {
    sum += a[i]; 
    k--;
  }
  cout << n - sum << endl;
  return 0;

}


Measured memory_bytes: 1024
<?php

while ($line = fgets(STDIN)) {
        $temp[] = trim($line);
};

$a = $temp[0];
$b = $temp[1];
$h = $temp[2];


function calc_trapezoid($a, $b, $h) 
{
    $area = ($a + $b) * $h / 2;
    return $area;
}

$answer = calc_trapezoid($a, $b, $h); 
echo $answer;

?>


Measured memory_bytes: 4728
s = input()
n = len(s)

def judge_palindrome(s):
    if s == s[::-1]:
        return True
    else:
        return False

if judge_palindrome(s) and judge_palindrome(s[:(n - 1) // 2]) and judge_palindrome(s[(n + 3) // 2 - 1:]):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)

Measured memory_bytes: 9076
#include<stdio.h> 
int main(void){ 

  int i; 

  char ch; 

  while(1){
      scanf("%c",&ch);
      
      if (ch == '\n')
      break;
    else if(ch>=97&&ch<=122)
      ch=ch-32; 
    else if(ch>=65&&ch<=90) 
      ch=ch+32;
  

  printf("%c", ch); 
  }
  printf("\n");

  return 0; 


} 



Measured memory_bytes: 2104
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


N = map(int, list(input())[:-1])

res = sum(N)

if res % 9 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 29796
#include<stdio.h>
int main()
{
    int a,b,i,j;
    for(;;)
    {
        scanf("%d %d",&a,&b);
        if(a==0 && b==0){
            break;
        }
        
            for(j=1;j<=a;j++){
            for(i=1;i<b;i++){
            printf("#");
            }
            printf("#\n");
            }
            printf("\n");
        
    }
    return 0;
}

Measured memory_bytes: 588
#include<iostream>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	int left = A + B;
	int right = C + D;

	if (left > right) {
		cout << "Left" << endl;
	}
	else if (left == right) {
		cout << "Balanced" << endl;
	}
	else if (left<right) {
		cout << "Right" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	vector<vector<int>>in(n, vector<int>(3));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> in[i][j];
		}
	}
	vector<vector<int>>dp(n, vector<int>(3));
	dp[0][0] = in[0][0];
	dp[0][1] = in[0][1];
	dp[0][2] = in[0][2];
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < j; k++)dp[i][j] = max(dp[i][j], dp[i - 1][k] + in[i][j]);
			for (int k = j + 1; k < 3; k++)dp[i][j] = max(dp[i][j], dp[i - 1][k] + in[i][j]);
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++)ans = max(ans, dp[n - 1][i]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long r, D, x;
  cin >> r >> D >> x;
  for(int i = 0; i < 10; i++){
    x = r * x - D;
    if(i ==9){
      cout << x;
    }
    else{
      cout << x  << endl;
    } 
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	// 入力
	int A, B, K;
	cin >> A >> B >> K;
	
	int answer = 0;
	int divisionIndex = 0;
	
	for (int i = 100; i >= 1; i--)
	{
		if (A % i == 0 && B % i == 0)
		{
			divisionIndex++;
			
			if (divisionIndex == K)
			{
				answer = i;
			}
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	int n, m;
	cin >> n >> m;
	int start = 0;
	if (n > 1) {
		start = pow(10, n - 1);
	}
	int end = pow(10, n) - 1;
	vector<pair<int, int>> vp;
	for (int i = 0; i < m; i++) {
		int s, c;
		cin >> s >> c;
		vp.push_back(make_pair(s, c));
	}
	for (int i = start; i <= end; i++) {
		int flag = 1;
		string s = to_string(i);
		for (auto p : vp) {
			if (s[p.first - 1] - '0' != p.second) {
				flag = 0;
				break;
			}
		}
		if (flag == 1) {
			cout << s << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}









Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

const int INF = 1e9;

template<class T> inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    vector<vector<int>> dp(505, vector<int>(505, INF));
    dp[0][0] = 0;
    for(int i = 0; i < N; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        for(int j = 404; j >= 0; --j) {
            for(int k = 404; k >= 0; --k) {
                chmin(dp[j + a][k + b], dp[j][k] + c);
            }
        }
    }
    int ans = INF;
    for(int j = 1; j < 505; ++j) {
        for(int k = 1; k < 505; ++k) {
            if(B * j == k * A) {
                chmin(ans, dp[j][k]);
            }
        }
    }
    if(ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
    using namespace std;
    
    typedef double dd;
    typedef long long ll;

    #define all(v) v.begin(),v.end()
    #define rall(v) v.rbegin(),v.rend()
    #define trav(i,a) for(auto i: a)
    #define ff first
    #define ss second
    #define eb emplace_back
    #define tc(t) ll t; cin>>t; while(t--)
    #define prec(n) fixed<<setprecission(n)
    #define mst(arr,value) memset(arr,value,sizeof(arr))
    #define mod %MOD
    #define sz(a) a.size()
    
    const long long inf = (long long)1e18;
    const long long MOD = (long long)1e9+7;
    
    #define f(i,n)     for(ll i=0;   i<n;  i++)
    #define fab(i,a,b) for(ll i=a;   i<b;  i++)
    #define fr(i,n)    for(ll i=n-1; i>=0; i--)
    #define fba(i,b,a) for(ll i=b-1; i>=a; i--)

    ll bpw(ll a, ll b) {
        if(b == 0) return 1;
        if(b % 2 == 1) {
            return bpw(a, b - 1) * a mod;
        } else {
            ll b2 = bpw(a, b / 2) mod;
            return b2 * b2 mod;
        }
    }
    ll ncr(ll n, ll r) { 
        ll p = 1, k = 1, m; 
        if (n - r < r) 
            r = n - r; 
        if (r != 0) { 
            while (r) { 
                p *= n; 
                k *= r; 
                m = __gcd(p, k); 
                p /= m; 
                k /= m; 
                n--; 
                r--; 
            } 
        } 
        else
            p = 1;  
        return p; 
    } 

    int main() {
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);
        cout.tie(NULL);
        ll n, m, c = 0, s = 0;
        cin >> n >> m;
        ll a[n];
        f(i, n) {
            cin >> a[i];
            s += a[i];
        }
        dd x = dd(s) / (4 * m);
        // cout << x;
        f(i, n) if(a[i] >= x) c++;
        if(c >= m) cout << "Yes";
        else cout << "No"; 
        return 0;
    }

Measured memory_bytes: 256
li = input()
n = len(li)
child_li = [0] * n

ruiseki = 0
for i in range(n - 1):
    if li[i] == 'R':
        ruiseki += 1
        if li[i + 1] == 'L':
            child_li[i + 1] = ruiseki // 2
            child_li[i] = (ruiseki + 1) // 2
    else:
        ruiseki = 0
        
ruiseki = 0
for i in range(n - 1, 0, -1):
    if li[i] == 'L':
        ruiseki += 1
        if li[i - 1] == 'R':
            child_li[i - 1] += ruiseki // 2
            child_li[i] += (ruiseki + 1) // 2
    else:
        ruiseki = 0
print(*child_li)

Measured memory_bytes: 6400