akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define F first
#define S second
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  map<string, ll>mp;
  ll n = 0;
  cin >> n;
  for (ll i = 0; i < n; ++i) {
    string s;
    cin >> s;
    ++mp[s];
  }
  ll maxm = 0;
  for (auto i : mp) {
    maxm = max(i.S, maxm);
  }
  for (auto i : mp) {
    if (i.S == maxm)
      cout << i.F << "\n";
  }
}


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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const long double pi = acosl(-1);

int main() {
	int n = nxt(), L = nxt();
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		a[i] = nxt();
	}

	long long total = 1ll * n * (n - 1) * (n - 2) / 6;
	long double ix = 0, iy = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i + 1; j < n; ++j) {
			long double x = cosl(pi * (a[i] + a[j]) / L);
			long double y = sinl(pi * (a[i] + a[j]) / L);
			int c = i - (j - i - 1) + (n - j - 1);
			ix += x * c / total;
			iy += y * c / total;
		}
	}

	cout << setprecision(12) << fixed;
	cout << ix << " " << iy << "\n";

	return 0;
}


Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = S()
    n1 = n[::-1]
    for i in range(len(n)):
        if n1[i] != n[i]:
            print("No")
            return
    print("Yes")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 40560
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vector<string> s(N);
    REP(i,N) cin>>s[i];

    string ans;
    for(char c='a';c<='z';c++){
        int Min=100;
        REP(i,N) Min=min(Min,(int)count(ALL(s[i]),c));
        REP(i,Min) ans+=c;
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt(), q = scanner.nextInt();
			// 町と町の間の移動最短距離
			int[][] d = new int[n][n];
			IntStream.range(0, n).forEach(i -> {
				Arrays.fill(d[i], Integer.MAX_VALUE >> 1);
				d[i][i] = 0;
			});
			int[] r = new int[q];
			IntStream.range(0, q).forEach(i -> r[i] = scanner.nextInt() - 1);
			IntStream.range(0, m).forEach(i -> {
				int a = scanner.nextInt() - 1, b = scanner.nextInt() - 1, c = scanner.nextInt();
				d[a][b] = d[b][a] = c;
			});
			warshallFloyd(d, n);
			System.out.println(getResult(d, r, -1, new boolean[q], 1));
		}
	}

	/**
	 * 町と町の間の移動最短距離をワーシャル–フロイド法で計算する
	 * 
	 * @param d 町と町の間の移動最短距離の配列
	 * @param n 町の数
	 */
	private static void warshallFloyd(int[][] d, int n) {
		IntStream.range(0, n).forEach(k -> IntStream.range(0, n)
				.forEach(j -> IntStream.range(0, n).forEach(i -> d[i][j] = Math.min(d[i][j], d[i][k] + d[k][j]))));
	}

	/**
	 * 解説通りに実装したメソッド
	 * 
	 * @param d       町と町の最短距離の配列
	 * @param r       訪ねる町の配列
	 * @param prev    直前に訪ねた町（存在しないときは-1）
	 * @param visited 町が訪ねたかどうかの配列
	 * @param depth   訪ねた町の数
	 * @return 訪ねる町をすべて訪ねたときの移動距離
	 */
	private static int getResult(final int[][] d, final int[] r, int prev, boolean[] visited, int depth) {
		if (depth > r.length) {
			return 0;
		}
		int result = Integer.MAX_VALUE >> 1;
		for (int i = 0; i < r.length; i++) {
			if (!visited[i]) {
				visited[i] = true;
				if (-1 == prev) {
					result = Math.min(result, getResult(d, r, i, visited, depth + 1));
				} else {
					result = Math.min(result, getResult(d, r, i, visited, depth + 1) + d[r[prev]][r[i]]);
				}
				visited[i] = false;
			}
		}
		return result;
	}
}


Measured memory_bytes: 58772
n,w = map(int,input().split())

items = [list(map(int,input().split())) for i in range(n)]

dp = [[0]*(w+1) for i in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j >= items[i][0]:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-items[i][0]] + items[i][1])
            
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])

print(dp[n][w])

Measured memory_bytes: 121068
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=3e5+5;
const int MOD=1e9+7;
template <class T>
bool sf(T &ret){ //Faster Input
    char c; int sgn; T bit=0.1;
    if(c=getchar(),c==EOF) return 0;
    while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
    sgn=(c=='-')?-1:1;
    ret=(c=='-')?0:(c-'0');
    while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
    if(c==' '||c=='\n'){ ret*=sgn; return 1; }
    while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
    ret*=sgn;
    return 1;
}
int sign(int x){
    return abs(x)<1e-7?0:x<0?-1:1;
}

int main(void){
    ll n,k;
    cin >>n>>k;
    cout <<n+1-k<<endl;
}


Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
void yes(bool cond) { cond ? puts("Yes") : puts("No"); }


//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<bool> cs;
    rep(i, N)
    {
        char c;
        cin >> c;
        bool b = c == 'R';
        cs.push_back(b);
    }
    // 方法1 swapを繰り返す。両端から攻める
    ll L = 0;
    ll R = N - 1;
    ll cnt1 = 0;
    for(;;)
    {
        while((L < N) && cs[L] )
        {
            ++L;
        }
        while ((R >= 0) && !cs[R])
        {
            --R;
        }
        if (L >= R)
        {
            break;
        }
        ++cnt1;
        ++L;
        --R;
    }

    // 方法2  色を変える。最後のRより左にあるWの総数
    ll lastRed = 0;
    for(ll i=cs.size()-1;i>=0;--i)
    {
        if (cs[i] == true)
        {
            lastRed = i;
            break;
        }
    }
    int cnt2 = 0;
    rep(i,lastRed)
    {
        cnt2 += !cs[i] ? 1 : 0;
    }
    ll m2 = cnt2;
    cout << min(cnt1, m2);
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    cout << setprecision(20);
    double n;
    cin >> n;
    double c = 2* acos(-1) * n;
    cout << c << '\n'; 
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        sort(all(s));
        mp[s]++;
    }
    ll res = 0;
    for (auto v : mp) {
        res += (ll)v.second * (ll)(v.second - 1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 11400
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define EPS 10e-8
#define MAX_H 100
#define MAX_W 8
#define MOD 1000000007

using namespace std;
typedef pair<int, int> ipair;
llong modulo(llong left, llong right) { return (left % right + right) % right; }

int N, M;
int main(int argc, char **argv) {
    cin >> N >> M;
    
    vector<int> yakusu;
    for(int i = 1; i * i <= M; ++i) {
        if(M % i == 0) {
            yakusu.push_back(i);
        }
    }

    int res = 1;
    for(int i = 0; i < yakusu.size(); ++i) {
        if(yakusu[i] >= N)
            res = max(res, M / yakusu[i]);
        if(M / yakusu[i] >= N)
            res = max(res, yakusu[i]);
    }

    cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace EDPC
{
    class S
    {
        static void Main(string[] args)
        {
            string N = Console.ReadLine();
            int D = int.Parse(Console.ReadLine());
            int mod = 1000000007;

            long[,,] dp = new long[N.Length + 1, D, 2];
            dp[0, 0, 0] = 1;

            for (int i = 0; i < N.Length; i++)
            {
                int nd = N[i] - '0';
                for (int j = 0; j < D; j++)
                {
                    for (int k = 0; k < 2; k++)
                    {
                        for (int d = 0; d < 10; d++)
                        {
                            int ni = i + 1;
                            int nj = (j + d) % D;
                            int nk = k;

                            if (k == 0)
                            {
                                if (d > nd) continue;
                                if (d < nd) nk = 1;
                            }
                            dp[ni, nj, nk] += dp[i, j, k] % mod;
                        }
                    }
                }
            }
            Console.WriteLine((dp[N.Length, 0, 0] + dp[N.Length, 0, 1] - 1) % mod);
        }
    }
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

constexpr int INF = 1e9;

int main() {
    int n;
    while(cin >> n, n) {
        string s; cin >> s;
        vector<int> dp(1 << 10);
        vector<bool> used(1 << 10);
        int state = 0;
        for(int i = 0; i + 1 < n; ++i) {
            if(s[i] == 'u') {
                state = 0;
            } else {
                state |= (1 << (s[i] - '0'));
            }
            if(s[i + 1] != 'u') {
                int d = s[i + 1] - '0';
                dp[state] |= (1 << d);
                used[state] = true;
            }
        }

        for(int S = 0; S < (1 << 10); ++S) {
            for(int T = S + 1; T < (1 << 10); ++T) {
                if(used[S] && used[T] && (S & T) == 0) {
                    dp[S | T] |= dp[S] | dp[T];
                    used[S | T] = true;
                }
            }
        }

        bool ng = false;
        for(int S = 1; S < (1 << 10); ++S) {
            if(used[S]) {
                ng |= (dp[S] & S) == dp[S];
            }
        }
        if(ng) {
            cout << "UNSAFE" << endl;
        } else {
            cout << "SAFE" << endl;
        }
    }
}


Measured memory_bytes: 3208
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)

const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;



int main() {
  string s;
  cin >> s;

  int year = stoi(s.substr(0, 4));
  int month = stoi(s.substr(5, 2));
  int day = stoi(s.substr(8, 2));

  if (year < 2019) {
    cout << "Heisei" << endl;
    return 0;
  } else if (year > 2019) {
    cout << "TBD" << endl;
    return 0;
  }

  if (month <= 4) {
    cout << "Heisei" << endl;
    return 0;
  }
  cout << "TBD" << endl;
}


Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  var m = sc.nextLong()
  val shops = Array.fill(n)(sc.nextLong() -> sc.nextLong()).sortBy(_._1)
  var ans = 0L
  for(t <- shops) {
    if (t._2 < m) {
      m -= t._2
      ans += t._1 * t._2
    } else if (m != 0 && t._2 >= m) {
      ans += t._1 * m
      m = 0L
    }
  }
  println(ans)
}


Measured memory_bytes: 68480
# 写経しましたが、何もわかっていません。

def floor_sum(n, m, a, b):
    "Return sum( floor( (A * i + B) / M ) for i in range(N) )"
    ret = 0
    while True:
        if a >= m:
            ret += ((n - 1) * n) // 2 * (a // m)
            a %= m
        if b >= m:
            ret += n * (b // m)
            b %= m
        y_max = (a * n + b) // m
        x_max = y_max * m - b
        if y_max == 0:
            return ret
        ret += (n - (x_max + a - 1) // a) * y_max
        n = y_max
        b = -x_max % a
        m, a = a, m

def main():
    import sys
    input = sys.stdin.buffer.readline

    ans = []
    T = int(input())
    for _ in range(T):
        N, M, A, B = map(int, input().split())
        ans.append(floor_sum(N, M, A, B))

    print('\n'.join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 79328
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <set>
using namespace std;

vector<vector<int> > h_edges, c_edges;

void dfs1(set<int> &ss,int start) {
    queue<int> q; q.push(start); ss.insert(start);
    while(!q.empty()) {
        int ns = q.front(); q.pop();
        for(int i=0; i<c_edges[ns].size(); ++i)
            if(ss.find(c_edges[ns][i]) == ss.end()) {
                q.push(c_edges[ns][i]);
                ss.insert(c_edges[ns][i]);
            }
    }
}

void bfs(queue<int> &q,vector<int> &dist) {
    while(!q.empty()) {
        int ns = q.front(); q.pop();
        for(int i=0; i<h_edges[ns].size(); ++i) {
            if(dist[h_edges[ns][i]] > dist[ns]+1) {
                dist[h_edges[ns][i]] = dist[ns]+1;
                q.push(h_edges[ns][i]);
            }
        }
    }
}

int main() {
    int n,m,tc,a,b,h_start,c_start;
    string s;
    cin>>tc;

    while(tc--) {
        cin>>n>>m;
        cin>>h_start>>c_start;
        h_edges.clear(); c_edges.clear();
        h_edges.resize(n+1); c_edges.resize(n+1);

        for(int i=0; i<m; ++i) {
            cin>>a>>b>>s;
            if(s == "N") {
                h_edges[a].push_back(b);
                h_edges[b].push_back(a);
            }else{
                c_edges[a].push_back(b);
                c_edges[b].push_back(a);
            }
        }

        set<int> canReach,fromGoal;
        // dfs1
        dfs1(canReach, c_start);
        dfs1(fromGoal, 0);

        if(canReach.find(0) != canReach.end()) {
            cout<<0<<endl;
            continue;
        }

        queue<int> q;
        vector<int> d1(n+1,1<<29), d2(n+1, 1<<29), d3(n+1, 1<<29);
        d1[h_start] = 0; q.push(h_start);
        bfs(q,d1);

//        cout<<canReach.size()<<endl;
        for(set<int>::iterator it = canReach.begin();
            it != canReach.end(); ++it) {
            q.push(*it); d2[*it] = 0;
        }
        bfs(q,d2);

        for(set<int>::iterator it = fromGoal.begin();
            it != fromGoal.end(); ++it) {
            q.push(*it); d3[*it] = 0;
        }
        bfs(q,d3);

        int ans = 1<<29;
        for(int i=0; i<=n; ++i) {
//            cout<<i<<" -> "<<d1[i]<<","<<d2[i]<<","<<d3[i]<<endl;
            ans = min(ans, d1[i]+d2[i]+d3[i]);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 7440
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

const int mod = 998244353;
struct mint{ //modint
    int x;
    mint(int x = 0): x(x % mod) {}
    friend istream& operator >> (istream &s, mint& m){ return s >> m.x; }
    friend ostream& operator << (ostream &s, mint m){ return s << m.x; }
    inline mint& operator += (mint a){ if((x += a.x) >= mod)x -= mod; return *this; }
    inline mint& operator -= (mint a){ if((x += mod - a.x) >= mod)x -= mod; return *this; }
    inline mint& operator *= (mint a){ (x *= a.x) %= mod; return *this; }
    inline mint& operator /= (mint a){ return(*this) *= a.inv(); }
    inline mint operator + (mint a){ mint res(*this); return res += a; }
    inline mint operator - (mint a){ mint res(*this); return res -= a; }
    inline mint operator * (mint a){ mint res(*this); return res *= a; }
    inline mint operator / (mint a){ mint res(*this); return res /= a; }
    inline bool operator == (mint a){ return x == a.x; }
    inline bool operator != (mint a){ return x != a.x; }
    inline bool operator < (mint a){ return x < a.x; }
    inline bool operator > (mint a){ return x > a.x; }
    inline bool operator <= (mint a){ return x <= a.x; }
    inline bool operator >= (mint a){ return x >= a.x; }
    inline void takemod(){ x = ((x % mod) + mod) % mod; }
    mint inv(){ return pow(mod - 2); }
    mint pow(int p){
        mint res(1), tmp(x);
        for(; p; p >>= 1){ if(p & 1)res *= tmp; tmp *= tmp; }
        return res;
    }
};

const int max_n = 310;
const int max_ai = 310;
int N;
int sum;
mint dp1[max_n][max_n * max_ai];
mint dp2[max_n][max_n * max_ai];


signed main(void){

    cin >> N;
    dp1[0][0] = dp2[0][0] = mint(1);

    rep(loop, N){
        
        int a; cin >> a;
        sum += a;

        rep(i, max_n * max_ai){
            dp1[loop + 1][i + a] += dp1[loop][i];
            dp1[loop + 1][i] += dp1[loop][i] * 2;
            dp2[loop + 1][i + a] += dp2[loop][i];
            dp2[loop + 1][i] += dp2[loop][i]; 
        }   

    }

    mint res1 = 0, res2 = 0;
    rep(i, max_n * max_ai){
        if(i * 2 >= sum)res1 += dp1[N][i];
        if(i * 2 == sum)res2 += dp2[N][i];
    }

    cout << mint(3).pow(N) - (res1 * 3 - res2 * 3) << endl;
    return 0;

}

Measured memory_bytes: 465792
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double W = sc.nextInt();
		double H = sc.nextInt();
		double x = sc.nextInt();
		double y = sc.nextInt();
		System.out.print(W*H/2 + " ");
		if(x == W/2 && y == H/2)
			System.out.println(1);
		else
			System.out.println(0);

	}

}

Measured memory_bytes: 22100
H,W=gets.split.map(&:to_i)
S=[]
white=0
H.times{
	S << gets.chomp
	white+=S[-1].chars.count(".")
}
warn white
q=[[0,0,1]]
visited=Array.new(H){Array.new(W){false}}
dist=nil
until q.empty?
	x,y,d=q.shift
	if x==W-1 && y==H-1
		dist=d
		break
	end
	next if visited[y][x]
	next if S[y][x]=="#"
	visited[y][x]=true
	d+=1
	if x>0
		q << [x-1,y,d]
	end
	if x<W-1
		q << [x+1,y,d]
	end
	if y>0
		q << [x,y-1,d]
	end
	if y<H-1
		q << [x,y+1,d]
	end
end
warn dist
puts dist ? white-dist : -1


Measured memory_bytes: 14304
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define PI acos(-1)

int main() {
    int N;
    cin >> N;
    vector<vector<ll>> dp(N + 1, vector<ll>(3));
    for (int i = 1; i <= N; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        dp[i][0] += max(dp[i - 1][1], dp[i - 1][2]) + a;
        dp[i][1] += max(dp[i - 1][0], dp[i - 1][2]) + b;
        dp[i][2] += max(dp[i - 1][0], dp[i - 1][1]) + c;
    }
    cout << max({ dp[N][0], dp[N][1], dp[N][2] }) << endl;
    return 0;
}

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

int main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    int cnt=0;
    for(int i=0;i<n;i++)
	{
        cin>>a[i];
        if(a[i]!=i+1)
            cnt++;
    }
    if(cnt>2)
    	cout<<"NO";
    else
		cout<<"YES";

	return 0;
}

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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for(int i=0;i<K;i++){
	if(A%2==1){
	  A--;
	}
	B+=A/2;
	A/=2;
	int t=A;
	A=B;
	B=t;
  }

  if(K%2==1){
	int t=A;
	A=B;
	B=t;	
  }

  cout << A << " " << B << endl;
  return 0;
  
}

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

using namespace std;

map<int,int> mm;

int main(){

    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(mm.find(x)!=mm.end()){
            mm.erase(x);
        }else{
            mm[x]=1;
        }
    }
    printf("%d\n",mm.size());
    return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#define BIG 2000000000
#define white 0
#define black 1

int n,c[100][100];

int prim() {
    int i, d[100], p[100], color[100], sum, minconst, u;
    for (i = 0; i < n; ++i) {
        color[i] = white;
        d[i] = BIG;
    }
    
    d[0] = 0;
    
    while(1){
        minconst = BIG;
        for (i = 0; i < n; ++i){
            if (color[i] != black && d[i] < minconst){
                minconst = d[i];
                u = i;
            }
        }
        
        if (minconst == BIG) break;
        
        color[u] = black;
        
        for (i = 0; i < n; ++i) {
            if (color[i] != black && c[u][i] != BIG) {
                if (c[u][i] < d[i]){
                    d[i] = c[u][i];
                    p[i] = u;
                }
            }
        }
    }
    
    sum = 0;
    for (i = 1; i < n ; ++i) {
        sum += c[i][p[i]];
    }
    return sum;
}

int main() {
    int i, j;
    scanf("%d", &n);
    
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; ++j) {
            scanf("%d", &c[i][j]);
            if (c[i][j] == -1) c[i][j] = BIG;
        }
    }
    
    printf("%d\n", prim());
    return 0;
}

Measured memory_bytes: 1764
def main():
    a = int(input())


    if a > 100:
        a = a % 100

    if a > 10:
        a = a % 10

    if a in [2, 4, 5, 7, 9]:
        print('hon')
    elif a in [0, 1, 6, 8]:
        print('pon')
    else:
        print('bon')



if __name__ == "__main__":
    main()

Measured memory_bytes: 9128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

var h int
var w int
var field [][]string
var dp [1100][1100]int

var dx = []int{1, 0}
var dy = []int{0, 1}

const mod = 1000000007

// func rec(x, y int) int {
// 	if dp[x][y] != -1 {
// 		return int(dp[x][y])
// 	}

// 	res := 0
// 	for i := 0; i < len(dx); i++ {
// 		sx := x + dx[i]
// 		sy := y + dy[i]

// 		if (0 <= sx && sx < h) && (0 <= sy && sy < w) && field[sx][sy] == "." {
// 			res = rec(sx, sy)
// 			dp[x][y] = res%mod + 1
// 		}
// 	}

// 	return int(dp[x][y])
// }

func main() {
	sc.Split(bufio.ScanWords)

	h, w = nextInt(), nextInt()

	field = make([][]string, h)
	for i := 0; i < h; i++ {
		field[i] = make([]string, w)
	}

	for i := 0; i < h; i++ {
		s := strings.Split(nextLine(), "")
		for j := 0; j < w; j++ {
			field[i][j] = s[j]
		}
	}
	// rec(0, 0)
	// fmt.Println(rec(0, 0))

	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if i+1 < h && field[i+1][j] == "." {
				dp[i+1][j] += (dp[i][j])
				dp[i+1][j] %= mod
			}

			if j+1 < w && field[i][j+1] == "." {
				dp[i][j+1] += dp[i][j]
				dp[i][j+1] %= mod
			}

		}
	}

	fmt.Println(dp[h-1][w-1])
}

func chmin(a *float64, b float64) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

func chmax(a *float64, b float64) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}


Measured memory_bytes: 38656
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input
        .split_whitespace()
        .map(|x| x.parse::<i64>().unwrap())
        .collect::<Vec<_>>();
    let a = list[0];
    let b = list[1];
    let mut count = 0;
    for i in a..b + 1 {
        let x = i.to_string().chars().collect::<Vec<_>>();
        let mut y = x.clone();
        y.reverse();
        if (x == y) {
            count += 1;
        }
    }
    count.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "11009 11332" => "4",
    test2: "31415 92653" => "612",
}


Measured memory_bytes: 4352
S = input()

equations_str = [S[0]]

def add_str(s:str, op:str):
    return s+op

for i in S[1:]:
    tmp_plus = list(map(lambda x: x+'+'+i, equations_str))
    tmp_minus = list(map(lambda x: x+'-'+i, equations_str))
    equations_str = tmp_plus
    equations_str.extend(tmp_minus)

for eq in equations_str:
    if eval(eq) == 7:
        print(eq+'=7')
        break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1000000007
#define int long long

signed main(){
    int h,w,k;cin>>h>>w>>k;
    char s[h][w];
    int ans[h][w];
    rep(i,h)rep(j,w)cin>>s[i][j];
    int c=1;
    bool al[h];
    fill(al,al+h,false);
    for(int i=0;i<h;i++){
        bool e=false;
        for(int j=0;j<w;j++){
            if(s[i][j]=='.')ans[i][j]=c;
            else {
                if(e&&c<k)c++;
                ans[i][j]=c;
                e=true;
            }
        }
        if(!e)al[i]=true;
        if(e&&c<k)c++;
    }
    if(al[0]){
        int i=1;
        while(al[i])i++;
        rep(j,w)ans[0][j]=ans[i][j];
    }
    rep(i,h-1){
        if(al[i+1])rep(j,w)ans[i+1][j]=ans[i][j];
    }
    rep(i,h)rep(j,w)printf("%lld%s",ans[i][j],(j==w-1?"\n":" "));
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
ll gcd(ll a, ll b)
{
    if(a*b==0) return a+b;
    if (a < b)
        gcd(b, a);
    ll r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> A(n+2,0);
    vector<int> L(n + 2, 0);
    vector<int> R(n + 2, 0);
    FOR(i,1,n+1)
    {
        cin >> A[i];
    }
    L[0] = 0;
    R[n + 1] = 0;
    REP(i, n+1)
    {   
        L[i+1]= gcd(L[i], A[i]);
    }
    for(int i= n; i>=0; i--)
    {   
        R[i]= gcd(R[i+1], A[i]);
        
    }
    int mm= -1;
    FOR(i,1,n+1){
        if(mm<gcd(L[i],R[i+1])) mm= gcd(L[i],R[i+1]);
    }
    cout << mm << endl;
}

Measured memory_bytes: 1408
/*
                                                  __          __
      /\   |   |     /\   |  | |  |     /\   | / |  )   /\   |  )
     /__\  |   |    /__\  |--| |  |    /__\  |<  |-<   /__\  |-<
    /    \ |__ |__ /    \ |  | \__/   /    \ | \ |__) /    \ |  \

*/

#import<bits/stdc++.h>
typedef long long ll;
#define forl(n) for(int i=0; i<n; i++)
#define forll(i,a,b,c) for(int i=a; i<b; i+=c)
#define pb(n) push_back(n)

using namespace std;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){




for(; ;){

int h, w, i, j;

scanf("%d%d", &h, &w);


if(h == 0 & w == 0){return 0;}

for(i = 0; i < h; i++){

for(j = 0; j < w; j++)
{printf("#");}

printf("\n");

}
printf("\n");

}

}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
  int n,m;
  cin>>n>>m;
  map<int,string> mp;
  vector<int> pena(n);
  int ans=0;
  int pans=0;
  rep(i,m){
    int p;
    string s;
    cin>>p>>s;
    if(mp[p]=="AC") continue;
    if(s=="AC"){
      mp[p]="AC";
      ans++;
    }
    if(s=="WA"){
      pena[p-1]++;
    }
  }
  rep(i,n){
    if(mp[i+1]=="AC"){
      pans+=pena[i];
    }
  }
  cout<<ans<<" "<<pans<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string c1, c2;
  cin >> c1 >> c2;

  if (c1.at(0) == c2.at(2) && c1.at(1) == c2.at(1) && c1.at(2) == c2.at(0)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int animal, leg;
    
    scanf("%d", &animal);
    scanf("%d", &leg);
    
    if (leg % 2 == 1){
        printf("No");
    }else if (animal * 2 > leg){
    	printf("No");
    }else if (animal * 4 < leg){
        printf("No");
    }else{
        printf("Yes");
    }
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
vector<vl> Adj;
ll dp[100005][2];

void dfs(ll node,ll par)
{
	if((Adj[node].size() == 1) and (node != 1))//Meaning leaf
	{
		dp[node][0] = 1;
		dp[node][1] = 1;
	}
	else
	{
		dp[node][0] = dp[node][1] = 1;
		for(auto child : Adj[node])
		{
			if(child == par) continue;
			else
			{
				dfs(child,node);
				dp[node][0] = ((dp[node][0] % mod) * (((dp[child][0]%mod) + (dp[child][1]%mod))%mod))%mod;
				dp[node][1] = ((dp[node][1]%mod) * (dp[child][0] % mod))%mod;
			}
			
		}
	}
	
}
void Compute(ll n)
{
	KAKA
	Adj.resize(n + 1);
	memset(dp,1,sizeof(dp));
    pragi(0,n - 1)
	{
		ll u,v;
		cin>>u>>v;
		Adj[u].eb(v);
		Adj[v].eb(u);
	}
	dfs(1,0);
	/*pragi(1,n + 1)
	{
		cout<<dp[i][0] + dp[i][1]<<"\n";
	}*/
	cout<<(dp[1][0] + dp[1][1])%mod<<"\n";
}
int main()
{
	KAKA
	ll n;
	cin>>n;
	Compute(n);
}

Measured memory_bytes: 17080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int X = stdIn.nextInt();
		int Y = stdIn.nextInt();
		int[] a = new int[N - 1];
		for(int i = 0; i < a.length; i ++) {
			a[i] = 0;
		}
		
		for(int i = 1; i < N; i ++) {
			for(int j = i + 1; j <= N; j ++) {
				int normal = j - i;
				int warp = Math.abs(i - X) + 1 + Math.abs(j- Y);
				a[Math.min(normal, warp) - 1] ++;
			}
		}
		
		for(int num: a) {
			System.out.println(num);
		}
	}
}

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

using namespace std; 

int n; 
int a[4020], c[4020]; 
int pw[2020], pb[2020]; 
int cw[2020][2020], cb[2020][2020], dp[2020][2020]; 

int main() {
    scanf("%d", &n); 
    for (int i = 1; i <= 2 * n; i++) {
        char s[2];
        scanf("%s %d", s, &a[i]); 
        if (s[0] == 'W') c[i] = 0, pw[a[i]] = i; 
        else c[i] = 1, pb[a[i]] = i; 
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            if (pw[i] < pw[j]) {
                cw[i][0]++; 
            }
        }
        for (int j = 1; j <= n; j++) {
            cw[i][j] = cw[i][j - 1]; 
            if (pw[i] < pb[j]) {
                cw[i][j]++; 
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < i; j++) {
            if (pb[i] < pb[j]) {
                cb[0][i]++;
            }
        }
        for (int j = 1; j <= n; j++) {
            cb[j][i] = cb[j - 1][i]; 
            if (pb[i] < pw[j]) {
                cb[j][i]++; 
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        dp[i][0] = dp[i - 1][0] + cw[i][0]; 
        dp[0][i] = dp[0][i - 1] + cb[0][i]; 
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = min(dp[i - 1][j] + cw[i][j], dp[i][j - 1] + cb[i][j]); 
        }
    }
    printf("%d\n", dp[n][n]); 
    return 0; 
}

Measured memory_bytes: 48000
a = [[0]*3]*3
for i in range(3):
  a[i] = list(map(int,input().split()))
  
def isInList(b,a):
  for i in range(len(a)):
    for j in range(len(a[i])):
      if a[i][j] == b:
        return i,j
      
  return -1,-1
  
N = int(input())
for i in range(N):
  b = int(input())
  I,J = isInList(b,a)
  if I != -1:
    a[I][J] = -1
    

def judge(a):
  for i in range(3):
    if a[i][0] == -1 and a[i][1] == -1 and a[i][2] == -1:
      return True
  for i in range(3):
    if a[0][i] == -1 and a[1][i] == -1 and a[2][i] == -1:
      return True
  tmp = [a[i][i] for i in range(3)]
  if tmp == [-1,-1,-1]:
    return True
  tmp = [a[i][2-i] for i in range(3)]
  if tmp == [-1,-1,-1]:
    return True
  return False


ans = "Yes" if judge(a) else "No"
print(ans)

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

int main() {
  vector<char> vec(6);
  
  for(int i = 0 ; i < 6 ; i++) {
    cin >> vec.at(i);
  }
  
  if(vec.at(2) == vec.at(3) && vec.at(4) == vec.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 
 
 
const int N=2e5+100;
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;
vector<ll>edge[200000];
int visted[100][100][999];
vector<pair<ll,ll>>vv;

int main()
{
  ll n,k;cin>>n>>k;/*
  for(int i=0;i<n;i++){cin>>a[i]>>b[i];}
  dp[0][a[0]]=b[0];
   for(int i=1;i<n;i++){
      for(int s=0;s<t-1;s++){
          dp[i][t+b[i]]=max( dp[i][t+a[i]], dp[i-1][t]+b[i]);
      }
       
   }*/
   if(k>=n){cout<<"unsafe";}else{cout<<"safe";}
 
}

Measured memory_bytes: 8312
#include <bits/stdc++.h>
#define max(a, b) (a>b)?a:b
using namespace std;
long double pre[200005], maxi, cur;
int n, k, arr[200005];
int main()
{
    cin>>n>>k;
    for(int i = 0; i<n; ++i)
        cin>>arr[i];
    
    cur = 0;//add
    for(int i = 0; i<k; ++i)
        cur+=(arr[i]+1)/2.0;
    maxi = cur;

    for(int i = k; i<n; ++i)
    {
        cur = cur-((arr[i-k]+1)/2.0)+((arr[i]+1)/2.0);
        maxi = max(maxi, cur);
    }
    cout<<setprecision(20)<<fixed<<maxi<<"\n";
}

Measured memory_bytes: 1024
/*                    ___          |\    /|           ____   ____   ____  ____
   |     |    /\    /    \ |     | | \  / |    /\    |    \ |    \ |     |    \
   |_____|   /__\   \____  |_____| |  \/  |   /__\   |____/ |____/ |__   |____/
   |     |  /    \       \ |     | |      |  /    \  |      |      |     |   \
   |     | /      \ \____/ |     | |      | /      \ |      |      |____ |    \
*/
#include<bits/stdc++.h>
using namespace std;
#define isko_lga_dala_to_life_jhinga_la_la ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define lb lower_bound
#define ub upper_bound
#define pf push_front
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define pld pair<long double,long double>
#define endl '\n'
#define loop(i,n) for(ll i=0;i<n;i++)
#define mod ((ll)(1e9+7))
#define in(x) scanf("%lld",&x)
#define in2(x,y) scanf("%lld %lld",&x,&y)
#define in3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define inv(v) for(auto&i:v) in(i)
#define vl vector<ll>
#define ml unordered_map<ll,ll> 
#define vpl vector<pair<ll,ll>>
#define INF 0x3f3f3f3f

template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<t.first<<" "<<t.second; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }

int main() {
    ll a,b;
    in2(a,b);
    if(a+b == 3) cout<<3<<endl;
    else if(a+b == 4) cout<<2<<endl;
    else if(a+b == 5) cout<<1<<endl;
    return 0;
}

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

int main(){
  int N,Y;
  cin >> N >> Y;
  
  for(int i=0;i<=N;i++){
    for(int j=0;j<=N-i;j++){
      if(10000*i+5000*j+1000*(N-i-j)==Y){
        cout << i << " " << j  << " " << N-i-j << "\n";
        return 0;
      }
    }
  }
  cout << -1 << " " << -1 << " " << -1 << "\n";
}
    
  

Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
r = [[] for i in range(n + 1)]
ans = 0
for i in range(m):
    r[l[i][0]].append(l[i][1])
    r[l[i][1]].append(l[i][0])
p = []
for i in range(n):
    p.append(i + 1)
p = list(itertools.permutations(p))
for i in range(len(p)):
    check = True
    t = list(p[i])
    if t[0] != 1:
        check = False
    for j in range(len(t)-1):
        if not t[j + 1] in r[t[j]]:
            check = False
    if check:
        ans += 1
print(ans)

Measured memory_bytes: 8052
import java.util.*;
import java.io.*;

public class Main {
	public void solve() throws IOException {
		int n = nextInt();
		int s = nextInt();
		long[][][] dp2 = new long[10][1001][101];
		for(int i = 0; i <= 100; i++){
			dp2[1][i][i] = 1;
		}
		for(int i = 2; i <= 9; i++){
			for(int j = 0; j <= 1000; j++){
				for(int k = 0; k <= 100; k++){
					if( dp2[i-1][j][k] > 0 ){
						for(int l = k+1; l <= 100 && j+l <= 1000; l++){
							dp2[i][j+l][l] += dp2[i-1][j][k];
						}
					}
				}
			}
		}
		long[][] ans = new long[10][1001];
		for(int i = 1; i <= 9; i++){
			for(int j = 0; j <= 1000; j++){
				for(int k = 0; k <= 100; k++){
					ans[i][j] += dp2[i][j][k];
				}
			}
		}
	/*	long[][][] dp = new long[10][10][1010];
		for(int i = 1; i <= 9; i++){
			dp[i][0][0] = 1;
			for(int j = 1; j <= i; j++){
				for(int k = 0; k < dp[i][j].length; k++){
					if( dp[i][j-1][k] > 0 ){
						for(int l = 1; l <= 100 && k+l < dp[i][j].length; l++){
							int idx = (i-j+1)*l+k;
							if( idx >= dp[i][j].length ){
								break;
							}
							dp[i][j][idx] += dp[i][j-1][k];
						}
					}
				}
			}
		}*/
		while( n != 0 || s != 0 ){
			writer.println(ans[n][s]);
			writer.flush();
			n = nextInt();
			s = nextInt();
		}
		writer.flush();
	/*	for(int i = 1; i < 10; i++){
			for(int j = 0; j < 20; j++){
				writer.println("i = " + i + ", j = " + j + ", " + dp[i][i][j+i]);
			}
		}*/
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter writer;

	public void run() throws IOException {
		try {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			writer = new PrintWriter(System.out);
			solve();
			reader.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
}

Measured memory_bytes: 32748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll n,m; cin >> n >> m;
    vector<ll> a(n),b(m),c(m);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    rep(i,m) cin >> b[i] >> c[i];
    vector<pair<ll,ll>> cb(m);
    rep(i,m){
        cb[i].first = c[i];
        cb[i].second = b[i];
    }
    sort(cb.rbegin(),cb.rend());
    ll sum=0,post=0;
    rep(i,m){
        ll index = lower_bound(a.begin(),a.end(),cb[i].first) - a.begin();
        
        if(index>=post){
            ll difference = index - post;
            difference = min(difference,cb[i].second);
            sum+=cb[i].first*difference;
            post+=difference;
        }
        
    }
    rep(i,post,n) sum+=a[i];
    cout << sum << endl;
}

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

int main() {
  
  int N,S,K;
  cin >> N;
  K=N;
  S=0;
  
  if(N>10000000){
    S+=N/10000000;
    N=N%10000000;
  }
  if(N>1000000){
    S+=N/1000000;
    N=N%1000000;
  }
  if(N>100000){
    S+=N/100000;
    N=N%100000;
  }
  if(N>10000){
    S+=N/10000;
    N=N%10000;
  }
  if(N>1000){
    S+=N/1000;
    N=N%1000;
  }
  if(N>100){
    S+=N/100;
    N=N%100;
  }
  if(N>10){
    S+=N/10;
    N=N%10;
  }
  S+=N;
  if(K%S==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
X,N = map(int,input().split())
if N == 0:
  print(X)
  
else:
  p = list(map(int,input().split()))
  
  if X not in p:
    print(X)
    
  else:
    n = [x for x in range(102)]

    for i in p:
      n.remove(i)
    ans = 0  
    a = 101
    b = -1
    for j in n:
      b += 1
    
      if abs(j-X) < a:
        a=abs(j-X)
        ans = n[b]
  
    print(ans)
  


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100000+5;
ll a[maxn],b[maxn];
ll n;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i],&b[i]);
	ll res=0,now=0,del=0;
	for(int i=n;i>=1;i--)
	{
		now=a[i]+res;
		del=b[i]-now%b[i];
		if(del==b[i]) del=0;
		res+=del;
	}
	printf("%lld\n",res);
	return 0;
}


Measured memory_bytes: 1792
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 100000;
int n, k, r, s, p;
string t;
bool done[MAX_N];

int main() {
    fastio();

    cin >> n >> k >> r >> s >> p >> t;

    int ans = 0;
    forn(i, n) {
        if (i >= k) {
            if (t[i - k] == t[i] && done[i - k]) continue;
        }

        if (t[i] == 'r') {
            ans += p;
        } else if (t[i] == 's') {
            ans += r;
        } else {
            ans += s;
        }

        done[i] = true;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 592
var i,j,a,n,m,c,sum,ac:integer;
    b : array[1..20] of integer;
begin
  ac := 0;
  readln(n,m,c);
  for i := 1 to m do read(b[i]);
	for i := 1 to n do begin
    sum := 0;
    for j := 1 to m do begin
      read(a);
      sum := sum + a * b[j]
	  end;
    if sum > -c then ac := ac + 1
  end;
  writeln(ac);
end.

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
bool so(int a,int b){
	return a > b;
}

int main(){
	int k,n,l[50];
	cin >> n >> k;
	for(int i=0;i<n;i++)
		cin >> l[i];
	sort(&l[0],&l[n],so);
n = 0;
	for(int i=0;i<k;i++)
		n += l[i];
	cout << n << endl;
}

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

 int main() {
   int N;
   int A,B;
   cin >> N;
   cin >> A >> B;

   if(N == 1){
     cout << "Hello World" << endl;
   }else if(N == 2){
     cout << A + B << endl;
   }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<vector<int> > a(n,vector<int>(n-1));
  rep(i,n)rep(j,n-1){
    cin >> a[i][j];
    a[i][j]--;
  }
  rep(i,n){
    reverse(all(a[i]));
  }
  set<i_i> st1;
  set<i_i> st2;
  int day=0;
  while(1){
    set<i_i> st1; // 初期化
    if(st2.empty()){
      rep(i,n){ //初回のみループ回す
        if(a[i].empty()) continue;
        if(a[a[i].back()].empty()) continue;
        if(a[a[i].back()].back()==i){
          int mn=min(i,a[i].back());
          int mx=max(i,a[i].back());
          st1.insert(i_i(mn,mx));
        }
      }
    }
    else{
      for(auto c:st2){
        int i=c.first;
        if(a[i].size()&&a[a[i].back()].size()&&a[a[i].back()].back()==i){
          int mn=min(i,a[i].back());
          int mx=max(i,a[i].back());
          st1.insert(i_i(mn,mx));
        }
        i=c.second;
        if(a[i].size()&&a[a[i].back()].size()&&a[a[i].back()].back()==i){
          int mn=min(i,a[i].back());
          int mx=max(i,a[i].back());
          st1.insert(i_i(mn,mx));
        }
      }
    }
    if(st1.empty()){
      bool f=1;
      rep(i,n){
        if(a[i].size()) f=0;
      }
      if(f) break;
      else{
        cout << -1 << endl;
        return 0;
      }
    }
    st2=st1; //次の周期ではst1は空である必要があるので2にコピー
    for(auto c:st1){
      a[c.first].pop_back();
      a[c.second].pop_back();
    }
    day++;
  }
  cout << day << endl;
}

Measured memory_bytes: 4224
n=int(input())
W=[]
count=0
for i in range(n):
  w=input()
  if i==0:
    W.append(w)
    count+=1
  else:
    if w not in W and w[0]==W[i-1][-1]:
      W.append(w)
      count+=1
    else:
      break
print("Yes" if count==n else "No")

Measured memory_bytes: 3060