akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
int main() {
	double a;
	cin >> a;
	double b = a / 3;
	cout << fixed << setprecision(16);
	cout << pow(b, 3) << endl;
}

Measured memory_bytes: 4232
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private final static int ARRAY_LENGTH = 50;
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long k = scanner.nextLong();
        long[] ans = new long[ARRAY_LENGTH];
        Arrays.fill(ans, k / ARRAY_LENGTH + ARRAY_LENGTH - 1);
        int left = (int)(k % ARRAY_LENGTH);
        for (int i = 1; i <= left; i++) {
            long min = Long.MAX_VALUE;
            int minId = -1;
            for (int j = 0; j < ARRAY_LENGTH; j++) if (ans[j] < min) {
                min = ans[j];
                minId = j;
            }
            ans[minId] += ARRAY_LENGTH;
            for (int j = 0; j < ARRAY_LENGTH; j++) if (j != minId)
                ans[j]--;
        }
        System.out.println(ARRAY_LENGTH);
        System.out.print(ans[0]);
        for (int i = 1; i < ARRAY_LENGTH; i++)
            System.out.printf(" %d", ans[i]);
        System.out.println();
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(void){
	int k; cin>>k;
	cout<<a[k-1]<<endl;
	
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <iostream>
#include <numeric>
#include <math.h>
#define ll  long long
#define ull unsigned long
#define mpa make_pair
#define pb push_back
#define ff first
#define pii pair<ll,ll>
#define dd double
#define trace(x) cerr << #x << " : " << x << endl
#define ss second
#define boost ios_base::sync_with_stdio(0)
#define forp(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n)    for(ll i=0;i<n;++i)
#define ren(i,n)    for(ll i=n-1;i>=0;i--)
#define forn(i,a,b) for(ll i=a;i>=b;i--)
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin()) i = (c).begin(); i != (c).end();
#define sc(x) scanf("%lld",&x)
#define clr(x,val) memset(x,val,sizeof(x))
#define pr(x) printf("%lld\n",x) 
#define gc getchar
#define pdd pair<dd,dd>
#define prec(x) cout<<fixed<<setprecision(x)
using namespace std;
ll a[100005];
ll b[100005];
int main(){
   ll n;
   cin>>n;
   ll f=0;
   while(n){
   	if(n%10==7)f=1;
   	n/=10ll;
   }
   if(f)cout<<"Yes";
   else cout<<"No";
   
   
   
}

Measured memory_bytes: 3640
#include <cstdio>

int freind[111111], block[111111], group[111111];

int Find(int x)
{
    if (freind[x] == x)
		return x;
	else
		return freind[x] = Find(freind[x]);
}

int main(void)
{
	int n, m, k, i;

	scanf("%d %d %d" ,&n, &m, &k);

	for (i = 1; i <= n; i++)
		freind[i] = i, group[i] = 1;

	while (m--)
	{
        int a, b;

        scanf("%d %d" ,&a, &b);

        block[a]++;
        block[b]++;

        a = Find(a);
        b = Find(b);

        if (a != b)
		{
			if (a < b)
			{
				freind[b] = a;
				group[a] += group[b];
			}
			else
			{
				freind[a] = b;
				group[b] += group[a];
			}
		}
	}

    while (k--)
	{
		int c, d;

		scanf("%d %d" ,&c, &d);

		if (Find(c) == Find(d))
		{
			block[c]++;
			block[d]++;
		}
	}

    for (i = 1; i <= n; i++)
		printf("%d " ,group[Find(i)] - block[i] - 1);
	return 0;
}

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

using namespace std;

int main()
{
    char a[4];
    scanf("%s",a);
    int b=0,c=0;
    for(int i=0;i<4;i++)
        if(a[i]=='+')
        b++;
    else c++;
    printf("%d\n",b-c);
    return 0;
}


Measured memory_bytes: 256
//AtCoder ABC045 C - たくさんの数式 / Many Formulas
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
#if LOCAL&01
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    string s;
    cin>>s;
    int N=s.size()-1;
    lli max=1ull<<N;
	lli sum = 0;
	for(lli bs=0;bs<max;++bs){
        int pt=0;
        for(int i=0;i<N;++i){
            if (bs&(1ull<<i)) {
                sum += std::stol(string(&s[pt],i-pt+1));
                pt = i+1;
            }
        }
        sum += std::stol(string(&s[pt]));//終端
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
class Main{
	public static void main(String[] args)throws NumberFormatException, IOException{
//		System.out.println(" ");
		Scanner scan = new Scanner(System.in);
		int times = scan.nextInt();
		int num[] =new int[times];
		int temp = 0; 
		int finir = -1;
		int irekae = 0;
		int i = 0;
		for(i=0;i<times;i++){
			num[i] = scan.nextInt();
		}
		i = 0;
		int bot = num.length-1;
		int pre = bot-1;
		while (times != 1){
			if(num[pre - i] > num[bot -i]){//???????°?2????????????????°?????????\????????????
//				System.out.println("irekae"+num[pre-i]+" "+num[bot-i]);
				temp = num[bot-i];
				num[bot-i] = num[pre-i];
				num[pre-i] = temp;
				irekae += 1;
			}
			
			i += 1;
			
			if(finir == pre-i){//???-1????????????????????\?????????????°??????????
				finir += 1;
//				System.out.println("finir "+finir);
				if(finir == num.length-2){
					break;
				}
				i = 0;
			}
		}
		for(i=0;i<times;i++){
			System.out.print(num[i]);
			if(i == times-1){
				System.out.println("");
				System.out.println(irekae);
			}
			else{
				System.out.print(" ");
			}
			
		}
	}
}

Measured memory_bytes: 26384
A,B,K = map(int,input().split(" "))
def f(A,B,n):
  i = 1
  while i <= n:
    if i%2 == 1:
      if A%2 == 1:
        A = A - 1
      A = A/2
      B = B + A
    else:
      if B%2 == 1:
        B = B - 1
      B = B/2
      A = B + A
    i = i + 1 
  list = [int(A),int(B)]
  return (list)
print(' '.join(map(str,f(A,B,K))))

Measured memory_bytes: 3064
N = int(input())
A = []
B = []
C = []
for i in range(N):
    tmp_a,tmp_b,tmp_c = map(int,input().split())
    A.append(tmp_a)
    B.append(tmp_b)
    C.append(tmp_c)

dp = [[0 for j in range(3)] for i in range(N)]
dp[0][0] = A[0]
dp[0][1] = B[0]
dp[0][2] = C[0]

for i in range(1,N):
    dp[i][0] = max(dp[i-1][1],dp[i-1][2])+A[i]
    dp[i][1] = max(dp[i-1][0],dp[i-1][2])+B[i]
    dp[i][2] = max(dp[i-1][0],dp[i-1][1])+C[i]

    

print(max(dp[-1][0],dp[-1][1],dp[-1][2]))

Measured memory_bytes: 36208
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
string a;
int p,pp;
int main()
{
    cin>>a;
    int n=a.size();
    for(int i=0;i<n;i++)
        if(a[i]=='A')
        {
            p=i;
            break;
        }
    for(int i=n-1;i>=0;i--)
        if(a[i]=='Z')
        {
            pp=i;
            break;
        }
    cout<<pp-p+1;
    return 0;
}


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

int main(){
    string s;
    getline(cin,s);
    int n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]>='A' && s[i]<='Z'){
            s[i]+='a'-'A';
        }else if(s[i]>='a' && s[i]<='z'){
            s[i]+='A'-'a';
        }
    }
    cout<<s<<endl;
    return 0;
}



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

const int N = 3003, S = 3003, mod = 998244353;
int n, s, a, f[S], fp;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> s;
	for(int i = 1; i <= n; ++i) {
		cin >> a;
		if(a > s) continue;
		f[0] = i;
		(fp += (long long)f[s - a] * (n - i + 1) % mod) %= mod;
		for(int j = s - 1; j >= a; --j) {
			(f[j] += f[j - a]) %= mod;
		}
	}
	cout << fp << endl;
	return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	map<int, int> m;
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int A;
		cin >> A;
		m[A]++;
	}

	vector<int> n;
	for (auto v : m) {
		n.push_back(v.second);
	}
	sort(n.begin(), n.end());
	int sum = 0;
	if (n.size() > K) {
		for (int i = 0; i < n.size() - K; i++) {
			sum += n[i];
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 10744
import java.util.Comparator;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/* static int java.util.Arrays.binarySearch(int[] a, int key); */


public class Main {
    Scanner sc = new Scanner(System.in);
    int n, m;
    public void run(){
        n = sc.nextInt();
        m = sc.nextInt();
        solve();
    }
    public void solve(){
        ArrayList<Pair> ab = new ArrayList<Pair>();
        for(int i = 0; i < m; i++){
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            ab.add(new Pair(a, b));
        }

        Collections.sort(ab, new MyComparator());

        int[] flag = new int[n];

        for(int i = 0; i < m; i++){
            Pair npair = ab.get(i);
            int a = npair.first;
            int b = npair.second;

            if(flag[a] == flag[b]){
                for(int j = b; j < n; j++){
                    flag[j] = flag[a] + 1;
                }
            }
        }

        System.out.println(flag[n-1]);
    }

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

    static class Pair {
        int first,second;
        public Pair(int a,int b) {
            this.first = a;
            this.second = b;
        }
    }
    static class Edge{
        int to, cost;
        public Edge(int a, int b){
            this.to = a;
            this.cost = b;
        }
    }
    class MyComparator implements Comparator {
        @Override
        public int compare (Object arg0, Object arg1) {
            int x = ((Pair)arg0).first;
            int y = ((Pair)arg1).first;

            if (x < y) {
                return -1;
            } else if (x > y) {
                return 1;
            } else{
                return 0;
            }
        }
    }
    static class UnionFind{
        int par[];
        int rank[];

        //n要素で初期化
        public UnionFind(int maxn){
            par = new int[maxn];
            rank = new int[maxn];

            for(int i = 0; i < maxn; i++){
                par[i] = i;
                rank[i] = 0;
            }
        }

        //木の根を求める
        int find(int x){
            if(par[x] == x){
                return x;
            }
            else {
                return par[x] = find(par[x]);
            }
        }

        // xとyの属する集合を併合
        void unite (int x, int y){
            x = find(x);
            y = find(y);
            if(x == y){
                return;
            }

            if(rank[x] < rank[y]){
                par[x] = y;
            }
            else{
                par[y] = x;
                if(rank[x] == rank[y]) rank[x]++;
            }
        }

        // xとyが同じ集合に属するか否か
        boolean same(int x, int y){
            return find(x) == find(y);
        }
    }

}

Measured memory_bytes: 87572
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] h = new int[n];
        int[] d = new int[n];
        for (int i = 0 ; i < n ; i++) {
            h[i] = sc.nextInt();
        }
        if (n == 1) {
            System.out.println("Yes");
            return;
        }
        h[0] -= 1;
        for (int i = 0 ; i < n - 1 ; i++) {
            if (h[i] - h[i + 1] >= 1) {
                System.out.println("No");
                return;
            }
            if (h[i] < h[i + 1]) {
                h[i + 1] -= 1;
            }
        }

        System.out.println("Yes");

    }

}

Measured memory_bytes: 56720
#include <iostream>

bool is_Rtriangle(int a, int b, int c){
	if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b)	return true;
	else return false;
}

int main(){
	int num_d;
	std::cin >> num_d;
	
	for(int i = 0; i < num_d; ++i){
		int a, b, c;
		std::cin >> a >> b >> c;
		
		if(is_Rtriangle(a, b, c)){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		String ans = "No";

		if(A == B && B != C)
			ans = "Yes";
		if(A == C && A != B)
			ans = "Yes";
		if(B == C && A != B)
			ans = "Yes";

		System.out.println(ans);
	}

}


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

typedef long long LL;

int main()
{
    long long n;
    cin>>n;
    LL u=100;
    LL i;
    for(i=1;;i++)
    {
        u+=u/100;
        if(u>=n) break;
    }
    cout<<i<<endl;
}


Measured memory_bytes: 3636
function main(lines) {
  const N = n();
  const as = na();
  
  let max = as[0];
  let ans = 0;
  for (let i = 0; i < N; i++) {
    ans += Math.max(max-as[i], 0);
    max = Math.max(max, as[i]);
  }
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 50868
#include <stdio.h>

int main() {
	int y, m, d;

	scanf("%d/%d/%d", &y, &m, &d);


	if (y <= 2018) printf("Heisei\n");
	else if (y == 2019 && m <= 4) printf("Heisei\n");
	else printf("TBD\n");

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
int main(){
  long long n, min = 2000000000000;
  std::cin >> n;
  for(long long i=1;i*i <= n; i++){
    if(n%i == 0)
      if(i + n/i -2 < min) min = i + n/i -2;
  }
  std::cout << min << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i]; a[i]--;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i + 1 < n; i++) {
    cin >> c[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += b[a[i]];
    if (i > 0 && a[i - 1] == a[i] - 1) {
      ans += c[a[i - 1]];
    }
  }
  cout << ans << endl;
  return 0;
}


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

int N;
int main(){
	cin >> N;
	vector<long long> v(N);
	for(int i=0;i<N;i++){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	long long max1 = 0,max2 = 0;
	int i=0;
	while((max1 == 0 || max2 ==0) && i<=N){
		if(v[i+1] == v[i] && max1==0){
			max1 = v[i];
			i += 2;
		}else if(v[i+1] == v[i] && max2==0){
			max2 = v[i];
			i += 2;
		}else i++;
	}
	cout << max1*max2 << endl;
}

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

int main(){
    ll n; cin >> n;
    ll num[n];
    map<ll, ll> a;
    for(ll i = 0; i < n; i++){
        ll number; cin >> number;
        num[i] = number;
        (a.find(number) == a.end()) ? a[number] = 1 : a[number]++;
    }

    map<ll, ll> p1;
    map<ll, ll> p2;
    ll sum = 0;
    for(ll i = 0; i < n; i++){
        if((p1.find(num[i]) == p1.end())){
            if(a[num[i]]>0){
                ll tmp = a[num[i]]*(a[num[i]] - 1)/2;
                sum += tmp;
                p1[num[i]] = tmp;
                if(a[num[i]] - 1 > 0) p2[num[i]] = (a[num[i]] - 1)*(a[num[i]] - 2)/2;
                else p2[num[i]] = 0;
            }
        }
    }

    for(ll i = 0; i < n; i++) cout << sum - p1[num[i]] + p2[num[i]] << endl;

    return 0;
}


Measured memory_bytes: 28824
import numpy as np
import math
n = input()
t,a = input().split()
H = input().split()

n = int(n)
t = int(t)
a = int(a)
H = [int(h) for h in H]

ans = []
for h in H:
	ans.append(np.abs((t - h*0.006) - a))

print(np.argmin(ans)+1)

Measured memory_bytes: 12388
a,b,c,d = map(int,input().split())
import numpy as np
one =[a,b]
two =[c,d]
A = np.array(one)
B = np.array(two)
vec = B-A
C = B+np.array([-vec[1],vec[0]])
D = C+np.array([-vec[0],-vec[1]])
print(C[0],C[1],D[0],D[1])

Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll fun(ll x){
    return x*(x+1)/2;
}
int gcd(int x,int y ,int z){
    int gc = __gcd(x,y);
    return __gcd(gc,z);
}
int main (){
    ll n;cin >> n;

    ll sum = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                sum+=gcd(i,j,k);
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3632
s = input()
MOD = 2019
a =[0]*MOD
a[0] = 1
c_ = 0
ans = 0
t = 1
for i in reversed(s):
  c = (c_+int(i)*t)%MOD
  a[c] += 1
  t *= 10
  t %= MOD
  c_ = c
for i in a:
  ans += i*(i-1)//2
print(ans)

Measured memory_bytes: 9184
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef pair<int,int> P;
int n;
int S[10001],E[10001];
int f[216005];
int main(){
  while(scanf("%d",&n),n){
    memset(f,0,sizeof(f));
    for(int i=0;i<n;i++){
      int s1,h1,m1,s2,h2,m2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);
      S[i]=h1*3600+m1*60+s1;
      E[i]=h2*3600+m2*60+s2;
      for(int j=S[i];j<E[i];j++) f[j]++;
    }
    int res=0;
    for(int i=0;i<216000;i++){
      res = max(res,f[i]);
    }
    printf("%d\n",res);
  }
}

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

int main() {
  int N,M;
  cin >> N >>M;
  vector<int> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  
  int sum = 0;
  
  for (int i = 0; i < M; i++) {
    sum += vec.at(i);
  }
  
  int x = 0;
  x = N - sum;
  
  if (x >= 0) {
    cout << x << endl;
  }
  else {
    cout << -1 << endl;
  }
}
    
  
  


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)



int main() {
	ll N;
  	cin>>N;
  	char c[N];
  	ll w=0;
  	ll r=0;
    ll count=0;
  	rep(i,N){
     	 cin>>c[i];
      	 if(c[i]=='W') w++;
      	 else r++;
    }
  
  	rep(i,r){
     	if(c[i]=='W'){
         	count++; 
        }
    }
  
  	cout<<min(min(w,r),count)<<endl;
  	
}

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

int main() {
     long long n;
    cin >> n;
    
    vector<int> a;
    
    while(n / 26 > 0) {
        if(n % 26 != 0){
          a.push_back(n % 26);
        n = n / 26;
                       }
      else {a.push_back(n % 26);
            n = n /26 - 1;
      }
                              
  }
    if(n != 0){
      a.push_back(n);
    }
    reverse(a.begin(), a.end());
    
    rep(i,a.size()) {
    if(a.at(i) == 1){
        cout << 'a';
    }
        else if(a.at(i) == 2) {
        cout << 'b';
        }
         if(a.at(i) == 3){
        cout << 'c';
    }
        else if(a.at(i) == 4){
        cout << 'd';
    }
         else if(a.at(i) == 5){
        cout << 'e';
    }  else if(a.at(i) == 6){
        cout << 'f';
    } else if(a.at(i) == 7){
        cout << 'g';
    } else if(a.at(i) == 8){
        cout << 'h';
    } else if(a.at(i) == 9){
        cout << 'i';
    } else if(a.at(i) == 10){
        cout << 'j';
    } else if(a.at(i) == 11){
        cout << 'k';
    } else if(a.at(i) == 12){
        cout << 'l';
    } else if(a.at(i) == 13){
        cout << 'm';
    } else if(a.at(i) == 14){
        cout << 'n';
    } else if(a.at(i) == 15){
        cout << 'o';
    } else if(a.at(i) == 16){
        cout << 'p';
    } else if(a.at(i) == 17){
        cout << 'q';
    } else if(a.at(i) == 18){
        cout << 'r';
    } else if(a.at(i) == 19){
        cout << 's';
    } else if(a.at(i) == 20){
        cout << 't';
    } else if(a.at(i) == 21){
        cout << 'u';
    } else if(a.at(i) == 22){
        cout << 'v';
    } else if(a.at(i) == 23){
        cout << 'w';
    } else if(a.at(i) == 24){
        cout << 'x';
    } else if(a.at(i) == 25){
        cout << 'y';
    } else if(a.at(i) == 0){
        cout << 'z';
    }
        
    }
    
    
    
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> p(m);
    vector<string> s(m);
    rep(i, m) cin >> p.at(i) >> s.at(i);

    map<int, int> ac, wa;
    rep(i, m)
    {
        if (s.at(i) == "AC")
        {
            ac[p.at(i)]++;
        }
        else if (s.at(i) == "WA")
        {
            // 過去にACしていないとき
            if (ac.count(p.at(i)) == 0)
            {
                wa[p.at(i)]++;
            }
        }
    }

    int ac_count = 0, wa_count = 0;
    for (auto itr = ac.begin(); itr != ac.end(); itr++)
    {
        ac_count++;
    }
    for (auto itr = wa.begin(); itr != wa.end(); itr++)
    {
        if (ac.count(itr->first) > 0)
        {
            wa_count += itr->second;
        }
    }

    cout << ac_count << " " << wa_count << endl;
}

Measured memory_bytes: 10752
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int N, K;
  cin >> N >> K;
  vec<int> A(N, 0);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  vec<int> Points_K(K, 0);
  for(int i = 0; i < K; i++){
    Points_K[i] = A[i];
  }
  for(int i = K; i < N; i++){
    if(Points_K[i%K] >= A[i]){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
    Points_K[i%K] = A[i];
  }

  return 0;
}


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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1000000007
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int dp[100001];
    vector<int> wd;
    fill_n(dp, 100001, 1e9);

    dp[0] = 0;
    wd.push_back(1);
    
    for(int i = 6; i <= n; i *= 6){
        wd.push_back(i);
    }
    for(int i = 9; i <= n; i *= 9){
        wd.push_back(i);
    }

    for(int i = 0; i <= n; ++i){
        for(auto w : wd){
            if(i >= w){
                dp[i] = min(dp[i], dp[i-w]+1);
            }
        }
    }


    ppp(dp[n]);

    return 0;
}


Measured memory_bytes: 640
# 2020/03/14
# パナソニックプログラミングコンテスト2020 - A

# Input
nl = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

# Calc

# Output
print(nl[k-1])


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll,null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<ll,ll>,null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pi; 
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define PRECISE cout.precision(18);
#define F first
#define S second




int main(){
 

    FAST
	//PRECISE


ll n,m;
cin>>n>>m;
ll ans=0;
ans+=(n*(n-1))/2;
ans+=(m*(m-1))/2;
cout<<ans;


return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
using ll = long long;
template <typename T>
T sq(T x){
  return x * x;
}
const int AMAX = 100000;
ll cnt[AMAX + 1];
int main(void) {
  int N;
  ll K;
  cin >> N >> K;
  for (int i = 0; i < N; ++i) {
    int A, B;
    cin >> A >> B;
    cnt[A] += B; }
  for (int ans = 1; ans <= AMAX; ++ans){
    if (K <= cnt[ans]) {
      cout << ans << endl;
      break; }
    K -= cnt[ans]; }
  return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

const ll N_MAX = 100005;

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];
void make(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        fac[i]=fac[i-1]*(ll) i%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}

ll combination(ll C, ll D){
    if(C<D||C<0||D<0) return 0;
    return fac[C]*(finv[D]*finv[C-D]%mod)%mod;
}

ll dp[1010][25] = {};

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

    ll N, K;
    cin >> N >> K;
    vector<ll> a(K);
    REP(i, K) cin >> a[i];

    dp[0][0] = 1;
    REP(k, K){
      REP(n, N+1){
        ll res = 0;
        REP(i, N+1){
          ll tmp = (dp[i][k] * combination(N-(n-i), a[k]-(n-i)))%mod;
          tmp *= combination(n, i);
          tmp %= mod;
          res += tmp;
          res %= mod;
        }
        dp[n][k+1] = res;
      }
    }

    /*
    REP(i, N+1){
      REP(k, K+1){
        cout << dp[i][k] << " ";
      }
      cout << endl;
    }
    */

    cout << dp[N][K] << endl;
    return 0;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const int maxn=112345;
int a,b,m,A[maxn],B[maxn];
int main()
{
    scanf("%d%d%d",&a,&b,&m);
    for (int i=0;i<a;++i) scanf("%d",&A[i]);
    for (int i=0;i<b;++i) scanf("%d",&B[i]);
    int res=1e9;
    for (int i=0;i<m;++i) {
        int x,y,c;scanf("%d%d%d",&x,&y,&c);
        --x;
        --y;
        res=min(res,A[x]+B[y]-c);
    }
    sort(A,A+a);
    sort(B,B+b);
    res=min(res,A[0]+B[0]);
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 1024
#include <assert.h>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 105;
const int INF = 0x3f3f3f3f;

int X[N], Y[N];

int Count(int x1, int x2, int y1, int y2) {
    if(y1 < x1) {
        if(y2 < x1) return 0;
        else if(y2 <= x2) 
            return y2 - x1 + 1;
        else return x2 - x1 + 1;
    } else if(y1 <= x2) {
        if(y2 <= x2) 
            return y2 - y1 + 1;
        else return x2 - y1 + 1;
    } else 
        return 0;
}
int main() {
    int n, m, x, y;
    while(~scanf("%d %d %d %d", &n, &m, &x, &y)) {
        for(int i = 1; i <= n; ++i) {
            scanf("%d", &X[i]);
        }
        for(int i = 1; i <= m; ++i) {
            scanf("%d", &Y[i]);
        }

        sort(X+1, X + n + 1);
        sort(Y+1, Y + m + 1);
        
        bool flag = false;
        for(int i = x + 1; i < y && !flag; ++i) {
            if(i > X[n] && i <= Y[1]) {
                flag = true;
            }
        }
        printf("%s\n", flag ? "No War" : "War");
    }
    return 0;
}


Measured memory_bytes: 384
"use strict";
function main(input) {
    const line = input.split("\n");
    let a = parseInt(line[0]);
    let str = line[1];
    let str1 = [];
    var l = str.length;
    if(l<=a) console.log(str);
    else{
        for(let i=0; i<a; ++i) str1[i] = str[i];
        console.log(str1.join('')+"...");
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29976
import sys
input = sys.stdin.readline

N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())
V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
dp[0][0] = 0
for i in range(N):
	for j in range(V + 1):
		if j - v[i] >= 0:
			dp[i + 1][j] = dp[i][j - v[i]] + w[i]
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j
print(ans)


Measured memory_bytes: 312536
N = int(input())
b = input().split()
a = [int(n) for n in b]

c = 0
flag = 1
while flag:
    flag = 0
    for j in range(1,N):
        if a[j] < a[j-1]:
            v = a[j]
            a[j] = a[j-1]
            a[j-1] = v
            c +=1
            flag =1
print(" ".join([str(n) for n in a]))
print(c)


Measured memory_bytes: 5604
n = int(input())
l = []
add = 0
for i in range(1,n+1):
    if i%3 == 0 and i%5 == 0:
        l.append("fizzBuzz")
    elif i%3 == 0:
        l.append("Fizz")
    elif i%5 == 0:
        l.append("Buzz")
    else:
        l.append(i)
        add = add + i
print(add)



Measured memory_bytes: 33824
import sys

s = list(input())
n = len(s)
for i in range(n):
    if (i+1)%2 ==0:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()
    else:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()

print('Yes')

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

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

using namespace std;

using ll = long long;

int n, m;
ll a[5000];
int b[200][5000];
int d[200][5000][13];
ll s[5002][5002];

void init(){
  rep(i, m){
    rep(j, n){
      d[i][j][0] = j;
    }
    for(int k = 1; k <= 12; ++k){
      rep(j, n){
        int p = d[i][j][k - 1];
        if(j + (1 << k - 1) >= n){
          d[i][j][k] = p;
        }
        else{
          int q = d[i][j + (1 << k - 1)][k - 1];
          d[i][j][k] = b[i][p] >= b[i][q] ? p : q;
        }
      }   
    }
  }
}
int query(int i, int u, int v){
  int p = u;
  for(int k = 12; k >= 0; --k){
    if(u + (1 << k) <= v){
      int q = d[i][u][k];
      p = b[i][p] >= b[i][q] ? p : q;
      u += 1 << k;
    }
  }
  return p;
}

void add(int a, int b, int c, int d, int x){
  s[a][b] += x;
  s[a][d] -= x;
  s[c][b] -= x;
  s[c][d] += x;
}
void sum(){
  rep(i, n + 1){
    rep(j, n + 1){
      s[i][j + 1] += s[i][j];
    }
  }
  rep(i, n + 1){
    rep(j, n + 1){
      s[i + 1][j] += s[i][j];
    }
  }
}

void calc(int i, int u, int v){
  if(u == v){
    return;
  }
  int p = query(i, u, v);
  add(u, p + 1, p + 1, v + 1, b[i][p]);
  calc(i, u, p);
  calc(i, p + 1, v);
}

int main(){
  cin >> n >> m;
  rep(i, n - 1){
    cin >> a[i + 1];
    a[i + 1] += a[i];
  }
  rep(j, n){
    rep(i, m){
      cin >> b[i][j];
    }
  }

  init();
  rep(i, m){
    calc(i, 0, n);
  }
  sum();

  ll ans = 0;
  rep(i, n){
    for(int j = i + 1; j <= n; ++j){
      ans = max(s[i][j] - (a[j - 1] - a[i]), ans);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 250496
def f1():
    t = 0
    for y, line in enumerate(M):
        for x, cell in enumerate(line):
            if M[y][x] == '1':
                f2(x, y)
                t += 1
    return t


def f2(x, y):
    if x < 0 or len(M[0]) == x or y < 0 or len(M) == y:
        return
    if M[y][x] == '1':
        M[y][x] = '0'
        f2(x, y-1)
        f2(x, y+1)
        f2(x+1, y)
        f2(x-1, y)


def get_input():
    while True:
        try:
            yield input()
        except EOFError:
            break


M = []
for line in list(get_input()):
    if line == '':
        print(f1())
        M = []
    else:
        M.append(list(line))
print(f1())

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector< unsigned long long > num;
    int n,k,x;
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> x;
        num.push_back(x);
    }
    sort(num.begin(),num.end());
    int m = n - k;
    unsigned long long sum = 0;
    for(int i = 0;i < m;i++)  sum += num[i];
    cout << sum << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <set>

using namespace std;

#define pb push_back
#define mp make_pair
#define x first
#define y second

typedef long long ll;

const ll INF = 1e9+5;
const ll MOD = 1e9+7;
const int off = 200002;

set <int> u[200005];
set <int> d[200005];
set <int> l[200005];
set <int> r[200005];

pair <int, int> a[200005];
char D[200005];

set <int> suml[400005];
set <int> difr[400005];

int main() {
	int n;
	scanf("%d", &n);
	for (int i=0 ; i<n ; i++) {
		scanf("%d%d", &a[i].x, &a[i].y);
		scanf(" %c", D+i);
		if (D[i] == 'U') {
			u[a[i].x].insert(a[i].y);
		}
		if (D[i] == 'D') {
		//	cout <<"yoz\n";
			d[a[i].x].insert(a[i].y);
		}
		if (D[i] == 'L') {
			l[a[i].y].insert(a[i].x);
		}
		if (D[i] == 'R') {
			r[a[i].y].insert(a[i].x);
		}
	}
	int minn = INF;
	for (int i=0 ; i<n ; i++) {
		if (D[i] == 'U') {
		//	cout <<"arr\n";
		//	cout <<a[i].x<<"  "<<a[i].y<<endl;
			set <int> :: iterator it = d[a[i].x].upper_bound(a[i].y);
		//	cout <<d[a[i].x].size()<<endl;
			if (it != d[a[i].x].end()) {
		//		cout <<"...\n";
				minn = min(minn, (*it-a[i].y)*5);
			}
		}
		if (D[i] == 'R') {
			set <int> :: iterator it = l[a[i].y].upper_bound(a[i].x);
			if (it != l[a[i].y].end()) {
				minn = min(minn, (*it-a[i].x)*5);
			}
		}
	}
//	cout <<"minn = "<<minn<<endl;
	for (int f=0 ; f<4 ; f++) {
		/*cout <<"----"<<endl;
		for (int i=0 ; i<n ; i++) {
			cout <<a[i].x<<" "<<a[i].y<<" "<<D[i]<<endl;
		}
		cout <<"----"<<endl;*/
		for (int i=0 ; i<n ; i++) {
			if (D[i] == 'R') {
				suml[a[i].x+a[i].y].insert(a[i].y);
			}
			if (D[i] == 'L') {
				difr[a[i].x-a[i].y+off].insert(a[i].y);
			}
		}
		for (int i=0 ; i<n ; i++) {
			if (D[i] == 'U') {
				set <int> :: iterator it = suml[a[i].x+a[i].y].upper_bound(a[i].y);
				if (it != suml[a[i].x+a[i].y].end()) minn = min(minn, (*it-a[i].y)*10);
				it = difr[a[i].x-a[i].y+off].upper_bound(a[i].y);
				if (it != difr[a[i].x-a[i].y+off].end()) minn = min(minn, (*it-a[i].y)*10);
			}
		}
		for (int i=0 ; i<n ; i++) {
			swap(a[i].x, a[i].y);
			if (D[i] == 'U') {
				D[i] = 'R';
			} else if (D[i] == 'R') {
				D[i] = 'U';
			} else if (D[i] == 'D') {
				D[i] = 'L';
			} else {
				D[i] = 'D';
			}
		}
		if (f == 1) {
			for (int i=0 ; i<n ; i++) {
				a[i].x = 200000-a[i].x;
				a[i].y = 200000-a[i].y;
				if (D[i] == 'U') D[i] = 'D';
				else if (D[i] == 'D') D[i] = 'U';
				else if (D[i] == 'L') D[i] = 'R';
				else D[i] = 'L';
			}
		}
		for (int i=0 ; i<400005 ; i++) {
			suml[i].clear();
			difr[i].clear();
		}
	//	cout <<"minn = "<<minn<<endl;
	}
	if (minn == INF) {
		printf("SAFE\n");
	} else {
		printf("%d\n", minn);
	}
	return 0;
}

Measured memory_bytes: 99028
#include <bits/stdc++.h>
using namespace std;
         
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
#define vll vector<ll>
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define F first
#define S second
#define pll pair<ll,ll> 
#define G(a,b) get<a>(b)
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define MT make_tuple
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)    
#define endl "\n"
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define sz(x) (ll)x.size() 
#define ara cout<<"ara-ara\n"; 
 


void func()
{
   ll n;
   cin>>n;
   char s[n+5];
   f(i,1,n+1) cin>>s[i];
   ll cnt1=0;
   f(i,1,n+1) if(s[i]=='1') cnt1++;

   if(cnt1==1)
   {
     ll idx=-1,tt=0,zz=0;
     fi(i,1,n+1) 
     {
       if(s[i]=='1')
       {
        idx=i;
        zz=tt;
        break;
       }
       tt++;
     }

     ll ans[n+1];
     ll curr=0;

     fi(i,1,n+1)
     {
       if(i==idx) 
       {
         ans[i]=0;
         curr++;
         continue;
       }
       
       ll pp=zz,qq=curr;
       if(pp==0 || qq==0) ans[i]=2;
       else ans[i]=1;
       curr++;
     }
     
     f(i,1,n+1) cout<<ans[i]<<endl;
     return;

   }



   ll x=cnt1+1,y=cnt1-1;
   
   ll totx=0,toty=0,curr1=1%x,curr2=1%y;
   fi(i,1,n+1)
   {
     if(s[i]=='1') 
     {
       totx=(totx+curr1)%x;
       toty=(toty+curr2)%y;
     }
     curr1=(curr1*2)%x;
     curr2=(curr2*2)%y;
   }

   ll g[n+1];
   g[0]=0;
   f(i,1,n+1) 
   {
     ll xx=__builtin_popcountll(i);
     g[i]=1+g[i%xx];
   }

   ll ans[n+1];
   curr1=1%x,curr2=1%y;
   fi(i,1,n+1)
   {
     if(s[i]=='1')
     {
       ll z=(toty-curr2+y)%y;
       ans[i]=1+g[z];
     }
     else
     {
       ll z=(totx+curr1)%x;
       ans[i]=1+g[z];
     }

     curr1=(curr1*2)%x;
     curr2=(curr2*2)%y;
   }
   
   f(i,1,n+1) cout<<ans[i]<<"\n";
}   
     
     
     
int main() 
{
    fast
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //#endif // ONLINE_JUDGE
        
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
       func();
    }
     
    return 0;
}

Measured memory_bytes: 6980
// C.

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[])
{
	LL n, a, sum[2] = {}, ans[2] = {};
	cin >> n;
	for (LL i = 0; i < n; ++i) {
		cin >> a;
		for (LL j = 0; j < 2; ++j) {
			sum[j] += a;
			if ((i + j) % 2) {
				if (sum[j] <= 0) {
					ans[j] += (1 - sum[j]);
					sum[j] = 1;
				}
			} else {
				if (sum[j] >= 0) {
					ans[j] += 1 + sum[j];
					sum[j] = -1;
				}
			}
		}
	}
	cout << min(ans[0], ans[1]) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int h,w;
char s[50][50];
int d[50][50];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int bfs(){
    queue<P> p;
    p.push(P(0,0));
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)d[i][j]=INF;
    d[0][0]=0;
    while(p.size()){
        P u=p.front();
        p.pop();
        for(int i=0;i<4;i++){
            int nx=u.first+dx[i];
            int ny=u.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&s[nx][ny]=='.'&&d[nx][ny]==INF){
                p.push(P(nx,ny));
                d[nx][ny]=d[u.first][u.second]+1;
            }
        }
    }
    if(d[h-1][w-1]==INF)return -1;
    return d[h-1][w-1];
}
int main(){
    cin>>h>>w;
    int count=0;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++){
            cin>>s[i][j];
            if(s[i][j]=='#')count++;
        }
    if(bfs()==-1)cout<<-1<<endl;
    else cout<<h*w-bfs()-count-1<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        long N = in.l();
        int X = in.i();
        int M = in.i();

        long ans = -1;
        long a = X;

        long[] sum = new long[M + 2];
        sum[1] = a;

        int[] r = new int[M];
        Arrays.fill(r, -1);
        r[X] = 0;

        for (int i = 1; i < N; i++) {
            int b = (int)(a * a % M);
            sum[i + 1] = sum[i] + b;

            if (r[b] > -1) {
                ans = sum[r[b]] + (N - r[b]) / (i - r[b]) * (sum[i] - sum[r[b]]);
                int j = (int)((N - r[b]) % (i - r[b]));
                ans += sum[r[b] + j] - sum[r[b]];
                break;
            }

            r[b] = i;
            a = b;
        }
        if (ans == -1) ans = sum[(int)N];

        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 34000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x, x0; cin >> n >> x >> x0;
    int ans = abs(x - x0);
    rep (i, n - 1) {
        int a; cin >> a;
        ans = gcd(ans, abs(a - x));
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
n=int(input())
data = []
for i in range(n):
    data.append(list(map(int,input().split())))
data.sort(key=lambda x:x[2],reverse=True)
ansflg = False
for xpos in range(101):
    for ypos in range(101):
        high = data[0][2] + abs(data[0][0]-xpos) + abs(data[0][1]-ypos)
        check = True
        for k in range(1,n):
            if data[k][2] != max(0,high - abs(data[k][0]-xpos) - abs(data[k][1]-ypos)):
                check = False
                break
        if check:
            print('{} {} {}'.format(xpos,ypos,high))
            ansflg = True
            break
    if ansflg:
        break

Measured memory_bytes: 3064