akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).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;}
const ll INF = 1LL << 60;

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

struct edge{
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main() {
    ll h,w,cx,cy,dx,dy;
    cin >> h >> w >> cx >> cy >> dx >> dy;
    cx--;
    cy--;
    dx--;
    dy--;
    string s[h];
    for (ll i=0;i<h;i++)cin >> s[i];
    deque<P> que;

    que.push_back(P(cx,cy));
    bool visited[h][w];
    ll d[h][w];
    for (ll i=0;i<h;i++){
        fill(visited[i],visited[i]+w,false);
        fill(d[i],d[i]+w,INF);
    }
    d[cx][cy]=0;
    visited[cx][cy]=true;

    while(!que.empty()){
        P p=que.front();
        ll X=p.first,Y=p.second;
        if (X==dx and Y==dy){
            cout << d[X][Y] << endl;
            return 0;
        }
        visited[X][Y]=true;
        que.pop_front();
        for (ll i=-2;i<3;i++){
            for (ll j=-2;j<3;j++){
                ll x=X+i,y=Y+j;
                if (x<h and x>=0 and y<w and y>=0 and s[x][y]=='.'){
                    if (visited[x][y])continue;
                    if (abs(i)+abs(j)<2){
                        que.push_front(P(x,y));
                        d[x][y]=d[X][Y];
                        visited[i][j]=true;
                    }else{
                        if (d[X][Y]+1<d[x][y]){
                            d[x][y]=d[X][Y]+1;
                            que.push_back(P(x,y));
                        }
                    }
                }
            }
        }

    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 14472
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    X, Y = map(int,input().split())
    a = Y - 2 * X
    if a >= 0 and a % 2 == 0 and a / 2 <= X:
        print('Yes')
    else:
        print('No')

    
if __name__ == "__main__":
    main()

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

vector<int> par(100000);

void init(int n){
  for(int i=0; i<n; i++){
    par.at(i) = i;
  }
}
int root(int x){
  if(par.at(x) == x){
    return x;
  }
  else{
    return par.at(x) = root(par.at(x));
  }
}
bool same(int x, int y){
  return root(x) == root(y);
}
void unite(int x, int y){
  x = root(x);
  y = root(y);
  if(x == y){
    return;
  }
  par.at(x) = y;
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
    vec.at(i)--;
  }
  
  vector<pair<int,int>> shift(M);
  pair<int,int> P;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    P = make_pair(min(a,b),max(a,b));
    shift.at(i) = P;
  }
  sort(shift.begin(),shift.end());
  
  init(N);
  for(int i=0; i<M; i++){
    P = shift.at(i);
    unite(P.first,P.second);
  }
  
  /*for(int i=0; i<N; i++){
    par.at(i) = root(i);
  }*/
  
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(same(vec.at(i),i)){
      cnt++;
    }
  }
  
  cout << cnt << endl;
  
}    

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

n,a,b,c = LI()
l = [I() for _ in range(n)]

s = a+b+c
ans = inf
for i in range(1<<n):
    lst = []
    t = 0
    for j in range(n):
        if i >> j & 1:
            t += 1
            lst.append(l[j])
    if t < 3:
        continue
    for j in range(3**t):
        tmp = '0'*t + Base_10_to_n(j,3)
        tmp = tmp[-t:]
        B = [0]*t
        for k in range(t):
            if str(tmp[k]) == '1':
                B[k] = 1
            elif str(tmp[k]) == '2':
                B[k] = 2
        X = [[],[],[]]
        for k in range(t):
            X[B[k]].append(lst[k])
        if len(X[0]) == 0:
            continue
        if len(X[1]) == 0:
            continue
        if len(X[2]) == 0:
            continue
        cost = abs(sum(X[0])-a)
        cost += abs(sum(X[1])-b)
        cost += abs(sum(X[2])-c)
        cost += 10*(len(X[0])-1)
        cost += 10*(len(X[1])-1)
        cost += 10*(len(X[2])-1)
        ans = min(ans,cost)
print(ans)

Measured memory_bytes: 112728
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#define MAX 2000000
using namespace std;

const int INF = 1<<29;
bool isPrime[MAX+5],dp[MAX+5];

void Init(){
  for(int i=0;i<=MAX;i++)isPrime[i] = false;
  for(int i=3;i<=MAX;i+=2)isPrime[i] = true;
  isPrime[2] = true;
  int limit = (int)sqrt((double)MAX)+1;
  for(int i=3;i<=limit;i+=2){
    if(!isPrime[i])continue;
    for(int j=i+i;j<=MAX;j+=i)isPrime[j] = false;
  }
}


int main(){
  int n,x,val;
  vector<int> The_rock;
  Init();
  while(cin >> n >> x && n && x){
    The_rock.clear();
    for(int i=0;i<n;i++){
      cin >> val;
      The_rock.push_back(val);
    }
    //int dp[x+10];
  
    for(int i=0;i<=MAX;i++)dp[i] = false;
    
    for(int i=0;i<The_rock.size();i++)dp[The_rock[i]] = true;
    dp[0] = true;
    for(int i=0;i<The_rock.size();i++){
      for(int j=The_rock[i];j<=MAX;j++){
	if(dp[j-The_rock[i]])dp[j] = true;
      }
    }

    bool fin = false;
    for(int i=x;i>=2;i--){
      if(isPrime[i] && dp[i]){
	cout << i << endl;
	fin = true;
	break;
      }
    }
    if(!fin)cout << "NA" << endl;


  }
  return 0;
}

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

typedef long long ll;

using namespace std;

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

    vector<int> table(N);
    for(int i = 0; i < Q; ++i){
        table[A[i]-1]++;
    }
    for(int i = 0; i < N; ++i){
        // cout << table[i]+(K-Q) << endl;
        if(table[i]+(K-Q) > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 1408
n, d = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
ans = 0
for i in range(n - 1):
    xi = x[i]
    for j in range(i + 1, n):
        xj = x[j]
        y = 0
        for k in range(d):
            y += (xi[k] - xj[k]) ** 2
        y_sqrt = int(y ** 0.5)
        if y_sqrt ** 2 == y:
            ans += 1
print(ans)


Measured memory_bytes: 3188
import java.util.*;

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

        String str = s.next();
        int count = -1;
        
        String forStr;
        for(int i=str.length(); 0<=i; i--){
            forStr = String.format(".*R{%d}.*", i);
            if(str.matches(forStr)){
                count = i;
                i=-1;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 35788
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1000001
#define MAX_M 100010
const long long mod = 1e9 + 7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,m,n) for(int i=m;i<(int)n;++i)
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 INF 1e+9
#define printx(x); cout<<x<<endl; 
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 1000
#define PI 3.141592653589793
// cout << setprecision(15) << std::fixed;


int main() {
	int n, q;
	cin >> n >> q;
	vecll A(n);
	for (int i = 0;i < n;i++) {
		cin >> A[i];
	}
	for (int i = 0;i < q;i++) {
		ll Q,res=0,sum=0;
		cin >> Q;
		int  right = 0;
		for (int left = 0;left < n;left++) {
			while (right < n && sum + A[right] <= Q) {
				sum += A[right];
				right++;
			}
			res += (right - left);
			if (right == left) right++;
			else sum -= A[left];
		}
		printx(res);
	}
}


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

using namespace std;

using ll = long long;

void calc(const string& a, const string& b, vector<int>& res) {
    int na = a.size(), nb = b.size();

    res.resize(na + 1, true);
    for (int i = 0; i < na; ++i) {
        for (int j = 0; j < nb; ++j) {
            if (i + j >= na) break;
            if (a[i + j] != b[j] && a[i + j] != '?' && b[j] != '?') {
                res[i] = false;
                break;
            }
        }
    }
}

int solve(const string& a, const string& b, const string& c) {
    int na = a.size(), nb = b.size(), nc = c.size();

    vector<int> dp_ab, dp_bc, dp_ac;
    calc(a, b, dp_ab);
    calc(b, c, dp_bc);
    calc(a, c, dp_ac);

    int ans = na + nb + nc;
    for (int i = 0; i <= na; ++i) {
        if (!dp_ab[min(i, na)]) continue;
        for (int j = 0; j <= max(nb, na - i); ++j) {
            if (!dp_bc[min(j, nb)] || !dp_ac[min(i + j, na)]) continue;
            ans = min(ans, max({na, i + nb, i + j + nc}));
        }
    }
    return ans;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    array<string, 3> vs;
    for (int i = 0; i < 3; ++i) {
        cin >> vs[i];
    }

    vector<int> ids = {0,1,2};
    int ans = 10000;
    do {
        ans = min(ans, solve(vs[ids[0]], vs[ids[1]], vs[ids[2]]));
    } while (next_permutation(ids.begin(), ids.end()));
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] u = new int[n];
		int[] v = new int[n];
		for (int i = 0; i < n - 1; i++) {
			u[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		sc.close();

		long ans = 0;
		for (int i = 1; i <= n; i++) {
			ans += (long) i * (i + 1) / 2;
		}

		for (int i = 0; i < n - 1; i++) {
			ans -= (long) Math.min(u[i], v[i]) * (n - Math.max(u[i], v[i]) + 1);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 61784
n = int(input())
x = list(map(int, input().split()))
x.append(90)
y = 1000
k =0
for i in range(len(x)-1):
    if x[i] < x[i+1]:
        k += int(y/x[i])
        y -= x[i]*int(y/x[i])
    elif x[i] > x[i+1]:
        y += x[i]*k
        k = 0
    
print(y)

Measured memory_bytes: 9168
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int x, y;
    cin >> x >> y;

    for (int i = 0; i <= x; i++) {
        if ((i) * 2 + (x - i) * 4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }


    cout << "No" << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <iomanip>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef unordered_map<int,int> m32;
typedef map<ll,ll> m64;
typedef unordered_map<ll,set<ll> > m648;
typedef pair<ll,p64 > pp64;
ll MOD = 1e9 + 7;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX
vv64 g;
v64 vis;
ll c1=0;
v64 p;

void dfs(ll v){
    vis[v]=1;
    forn(i,g[v].size()){
        if(vis[g[v][i]]==0) {dfs(g[v][i]);}
    }
}

void dfs1(ll v){
    vis[v]=0;
    forn(i,g[v].size()){
        if(vis[g[v][i]]==1 && g[v][i]!=p[0] && g[v][i]!=p[1]) {dfs1(g[v][i]);}
    }
}

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll a[n],a1[n];
    ll off[n],al[n];
    ll ans[n];
    forn(i,n) {cin >> a[i];a1[i]=a[i];off[i]=0,al[i]=0;ans[i]=-1;}
    sort(a1,a1+n);
    rforn(j,n-1){
        rforn(i,n-1){
            if(al[i]==0 && a[i]==a1[j]){
                ll t = a[i]-1;
                forsn(k,i+1,n){
                    if(al[k]==0) t++;
                }
                if(t>=n){
                    cout << -1 << ln;
                    return 0;
                }
                if(t>=n){
                        cout << -1 << ln;
                        return 0;
                    }
                ll t1 = t;
                t+=off[t];
                while(true){
                    if(t>=n){
                        cout << -1 << ln;
                        return 0;
                    }
                    ll k = off[t]-off[t1];
                    if(k!=0){
                        t1 = t;
                        t+=k;
                    }  
                    else{
                        break;
                    }
                }
                // t+=off[t];
                // cout << t << ln;
                if(t>=n || ans[t]!=-1){
                    cout << -1 << ln;
                    return 0;
                }
                ans[t]=a[i];
                al[i]=1;
                forsn(k,t,n){
                    off[k]++;
                }
                break;
            }
        }
    }
    forn(i,n) cout << ans[i] << ln;
    return 0;
}

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

int main(){
  int N,M;
  string c = "No";
  cin >> N >> M;
  char a[N][N],b[M][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<M;i++){
    for(int j=0;j<M;j++){
      cin >> b[i][j];
    }
  }
  for(int k=0;k<N-M+1;k++){
    for(int l=0;l<N-M+1;l++){
      int d=0;
      for(int i=0;i<M;i++){
        for(int j=0;j<M;j++){
            if(a[i+k][j+l] == b[i][j])
              d++;
         }
      }
      if(d==M*M){
        c = "Yes";
      }
    }
  }
  cout << c << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);
		// Scanner scan = new Scanner(new
		// File("D:\\UserArea\\J0124567\\Downloads\\ALDS1_3_C-in10.txt"));
		// while (scan.hasNext()) {

		int n = scan.nextInt();

		prev[0] = 1;

		for (int i = 0; i < n; i++) {
			String s = scan.next();

			// for (int k=0;k<20;k++)
			// System.out.println(k+" "+next[k]+" "+prev[k]+" "+x[k]);
			// System.out.println(i + " " + s);

			switch (s) {
			case ("insert"):
				x[use] = scan.nextInt();
				prev[use] = 0;
				prev[next[0]] = use;
				next[use] = next[0];
				next[0] = use;
				use++;
				if (use == M)
					use = 0;
				break;
			case ("delete"):
				int dx = scan.nextInt();
				int p = next[0];
				while (x[p] != dx && p > 0) {
					p = next[p];
				}
				if (p == 0)
					break;
				if (next[p] == 0) {
					next[prev[p]] = 0;
					prev[0] = prev[p];
					break;
				}
				prev[next[p]] = prev[p];
				next[prev[p]] = next[p];
				break;
			case ("deleteFirst"):
				prev[next[next[0]]] = 0;
				next[0] = next[next[0]];
				break;
			case ("deleteLast"):
				next[prev[prev[0]]] = 0;
				prev[0] = prev[prev[0]];
				break;
			}
		}
		// }
		int p = next[0];
		System.out.print(x[p]);
		while ((p = next[p]) > 0)
			System.out.print(" " + x[p]);
		System.out.println();

		scan.close();
		System.exit(0);
	}

	static int M = 2000001;
	static int[] x = new int[M];
	static int[] next = new int[M];
	static int[] prev = new int[M];
	static int use = 1;
}

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

int main() {
    int N;
    int A[21], B[21], C[21];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> B[i];
    }
    for (int i = 0; i < N - 1; i++) {
        cin >> C[i];
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ans += B[i];
        if (i >= 1 && A[i] == A[i-1] + 1) {
            ans += C[A[i-1]-1];
        }
    }
    cout << ans << endl;
}

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

    int a=0,b=0,c=0,i;
    char st[5];

    char st1,st2;

    scanf("%s", &st);
    st1 = st[0];

    for(i=0;i<4;i++){
            if(st[i] == st1){
                a++;
            }else{
                if(b==0){
                    st2=st[i];
                }
                if(st2==st[i]){
                    b++;
                }else{
                    c++;
                }
            }
    }
    if(a==2 && b==2 && c==0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string march = "MARCH";
	vector<ll> mp(5,0);
	for(int i = 0; i < n; i++){
		string a;
		cin >> a;
		for(int j = 0; j < 5; j++){
			if(a[0] == march[j]) mp[j]++;
		}
	}
	ll ans = 0;
	for(int i = 0; i < 5; i++){
		for(int j = i+1; j < 5; j++){
			for(int k = j + 1; k < 5; k++){
				ans += mp[i] * mp[j] * mp[k]; 
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;

struct edge {
  ll from;
  ll to;
  ll color;
};

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

  ll N;
  cin >> N;
  vector<edge> E(N-1); // edges
  vector<vector<ll>> adj(N, vector<ll>(0)); //id of adjescent edge

  REP(i,N-1){
    ll ai, bi;
    cin >> ai >> bi;
    ai--; bi--;
    adj[ai].push_back(i);
    adj[bi].push_back(i);
    E[i] = edge{ai, bi, -1}; // From, To, color
  }


  // BFS
  ll max_color = 0;
  queue<ll> que;
  que.push(0);
  while (!que.empty()){
    ll n = que.front(); que.pop();
    //cout << "n = " << n << " : has " << adj[n].size() << " edges.\n";
    // sort adjescent edge
    sort(adj[n].begin(), adj[n].end(), [&E](ll& ia, ll& ib){
      return E[ia].color < E[ib].color;
    });
    //REP(i, adj[n].size()){ cout << "pre-E[" << adj[n][i] << "]: color->" << E[adj[n][i]].color << "\n"; }
    if (E[adj[n][0]].color != -1) continue;

    vector<ll> used(max_color+1, 0);
    for (ll& i: adj[n]){
      edge e = E[i];
      if (e.color != -1){
        used[e.color] = 1;
      }
    }

    ll c = 0;
    for (ll& i: adj[n]){
      edge e = E[i];
      if (e.color != -1){
        break;
      }
      while (c<used.size() && used[c]!=0){
        //cout << "color " << c << " is used.\n";
        c++;
      }
      E[i].color = c;
      max_color = max(max_color, c);
      //cout << "E[" << i << "]: color become " << c << "\n";
      if (c < used.size()){
        used[c] = 1;
      } else {
        used.push_back(1);
      }

      if (e.from != n){
        que.push(e.from);
      } else {
        que.push(e.to);
      }
    }
  }
  cout << max_color+1 << "\n";
  REP(i,N-1){
    cout << E[i].color+1 << "\n";
  }

  return 0;
}


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

int main()
{
	int n, su, parts[8], max, min;

	cin >> n;

	for (int i = 0; i < n; i++){
		max = min = 0;
		cin >> su;
		for (int j = 0; j < 8; j++){
			parts[j] = su % 10;
			su /= 10;
		}
		sort(parts, parts + 8);
		for(int j = 0; j < 8; j++){
			min *= 10;
			min += parts[j];
		}
		reverse(parts, parts + 8);
		for (int j = 0; j < 8; j++){
			max *= 10;
			max += parts[j];
		}
		cout << max - min << endl;
	}

		return (0);
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n,m;
  cin >> n >> m;
  vi cnt(n);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    cnt[a]++;
    cnt[b]++;
  }
  rep(i,m){
    if(cnt[i]%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <map>
using namespace std;

int main(){
  int h, a; cin >> h >> a;
  if(h % a == 0) cout << h / a << endl;
  else cout << h / a + 1 << endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n,ct=0;
    cin>>n;
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        ct+=(x&1);
    }
    if(ct)
        cout<<"first\n";
    else
        cout<<"second\n";
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    cin >> n;
    vector<int> t(n), a(n);
    int ans = 0, pre = 0;
    rep(i, 0, n){
        cin >> t[i] >> a[i];
    }
    int tt = t[0], aa = a[0];
    pre = t[0] + a[0];
    rep(i, 1, n){
        int sum = t[i] + a[i];
        int q = max((pre + sum - 1) / sum, max((tt + t[i] - 1) / t[i], (aa + a[i] - 1) / a[i]));
        pre = q * sum;
        aa = q * a[i];
        tt = q * t[i];
        // cout << pre << endl;
    }
    cout << pre << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <map>
using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n, n)
    {
        vector<int> cnt(7, 0);
        for(int i = 0; i < n; i++)
        {
            int x; cin >> x;
            bool flag = false;
            for(int age = 10; age <= 60; age += 10)
            {
                if(x < age)
                {
                    cnt[age / 10 - 1]++;
                    flag = true;
                    break;
                }
            }
            if(flag == false) cnt[6]++;
        }
        for(int i = 0; i < 7; i++) cout << cnt[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define M 500005
using namespace std;
int f[M], a[M], n;
int main(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    f[1] = abs(a[0] - a[1]);
    for(int i = 2; i < n; ++i){
        f[i] = min(f[i - 1] + abs(a[i] - a[i - 1]), f[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << f[n - 1];
    return 0;
}


Measured memory_bytes: 1024
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

const int N = 1e5;
int arr[N + 5];

void hora(int tc) {
	int n;
	cin>>n;
	int maxi = 0;
	for(int i = 0;i < n;i++) {
		cin>>arr[i];
		maxi = max(maxi, arr[i]);
	}
	bool bisa = true;
	int independent = 0;
	for(int i = 0;i < n;i++) {
		if(maxi - arr[i] >= 2) bisa = false;
		else if(maxi - arr[i] == 1) independent++;
	}
	if(!bisa) {
		cout<<"No"<<endl;
		return ;
	}
	int sisa = n - independent;
	if(sisa == n) {
		if(maxi>= 1 && maxi <= n / 2 || maxi + 1 == n) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	} else {
		if(sisa == 1 || independent + 1 > maxi || maxi > independent + sisa / 2) cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>

const long double pi = 6.28318530717958623200 / 2;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);

	int n;
	std::cin >> n;
	std::cout << std::fixed << std::setprecision(21) << 2 * pi * n;

	return 0;
}

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

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
    //int t=1 ; cin>>t ; while(t--)
    {
        int a, b;
        cin >> a >> b;
        for(int i=0;i<max(a,b);i++)
            cout << min(a,b);

    }
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define RANGE(i,a,b) for(int i=(a);i<=(b);i++)
#define RANGER(i,a,b) for(int i=(b);i>=(a);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)
using ll=long long int;
using vi=vector<int>;
using vvi=vector<vi>;
using pi=pair<int,int>;
constexpr int INF=1<<30;
constexpr ll INTL=1ll<<60;
int main(){
  double n,d;
  cin>>n>>d;
  cout<<ceil(n/(d*2+1))<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}


int main(){
  int n,m; cin >> n >> m;
  cout <<(n-1)*(m-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

int num[105];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int X, n;
   cin >> X >> n;

   rep(i, 0, n) {
      int p;
      cin >> p;
      num[p]++;
   }
   int ans = -100;
   rep(i, 0, 105) {
      if (num[i] == 0 && abs(ans - X) > abs(i - X)) ans = i;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3640
def a(n):
    n = n % 10

    if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
        return 'hon'
    elif n == 0 or n == 1 or n == 6 or n == 8:
        return 'pon'
    
    return 'bon'

n = int(input())

print(a(n))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int V,cmp[MAX];
vector<int> G[MAX],rG[MAX],vs;
bool used[MAX];

void add_edge(int from,int to){
    G[from].push_back(to);
    rG[to].push_back(from);
}

void DFS(int v){
    used[v]=1;
    for(int i=0;i<G[v].size();i++){
        if(used[G[v][i]]==0) DFS(G[v][i]);
    }
    vs.push_back(v);
}

void rDFS(int v,int k){
    used[v]=1;
    cmp[v]=k;
    for(int i=0;i<rG[v].size();i++){
        if(used[rG[v][i]]==0) rDFS(rG[v][i],k);
    }
}

int scc(){
    memset(used,0,sizeof(used));
    vs.clear();
    for(int v=0;v<V;v++){
        if(used[v]==0) DFS(v);
    }
    
    memset(used,0,sizeof(used));
    int k=0;
    for(int i=vs.size()-1;i>=0;i--){
        if(used[vs[i]]==0) rDFS(vs[i],k++);
    }
    return k;
}

int main(){

    cin>>V;
    int M;cin>>M;
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        add_edge(a,b);
    }
    
    scc();
    
    for(int i=0;i<V;i++){
        bool deta=false;
        for(int j=0;j<V;j++){
            if(cmp[i]==cmp[j]){
                if(deta) cout<<" ";
                cout<<j+1;
                deta=true;
            }
        }
        cout<<endl;
    }
}




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

int main() {
    int n; scanf("%d", &n);
    vector<int> p(n), dg(n);
    vector<vector<int>> g(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &p[i]);
        p[i]--;
        dg[p[i]]++;
        g[p[i]].push_back(i);
    }
    queue<int> q;
    for (int i = 0; i < n; ++i) {
        if (dg[i] == 0) q.push(i); 
    }
    vector<int> used(n + n), sg(n);
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (int u : g[x]) used[sg[u]] = 1;
        while (used[sg[x]]) sg[x]++;
        for (int u : g[x]) used[sg[u]] = 0;
        if (--dg[p[x]] == 0) q.push(p[x]);
    }
    vector<int> nxt(n, -1), prv(n, -1), upd(n, -1);
    vector<int> cycle;
    for (int i = 0; i < n; ++i) {
        if (dg[i] != 0) {
            for (int u : g[i]) if (dg[u] == 0) used[sg[u]] = 1;
            while (used[sg[i]]) sg[i]++;
            upd[i] = sg[i] + 1;
            while (used[upd[i]]) ++upd[i];
            for (int u : g[i]) if (dg[u] == 0) used[sg[u]] = 0;
            for (int u : g[i]) if (dg[u] > 0) { 
                nxt[i] = u;
                prv[u] = i;
            }
            cycle.push_back(i);
        }
    }

    auto Check = [&]() {
        bool res = true;
        for (int i = 0; i < n; ++i) {
            for (int u : g[i]) {
                if (sg[u] == sg[i]) res = false;
                used[sg[u]] = 1;
            }
            for (int j = 0; j < sg[i]; ++j) {
                if (!used[j]) res = false;
            }
            for (int u : g[i]) used[sg[u]] = 0;
        }
        return res;
    };

    if (Check()) {
        puts("POSSIBLE");
        return 0;
    }
    auto saved = sg;
    for (int j = 0; j < 1; ++j) {
        {
            sg = saved;
            int x = cycle[j];
            for (int i = 0; i < cycle.size(); ++i) {
                int r = prv[x];
                for (int k : g[r]) used[sg[k]] = 1;
                sg[r] = 0;
                while (used[sg[r]]) sg[r]++;
                for (int k : g[r]) used[sg[k]] = 0;
                x = r;
            }
            if (Check()) {
                // printf("upd = %d\n", cycle[j]);
                puts("POSSIBLE");
                return 0;
            }
        }
        {
            sg = saved;
            sg[cycle[j]] = upd[cycle[j]];
            int x = cycle[j];
            for (int i = 0; i < cycle.size(); ++i) {
                int r = prv[x];
                for (int k : g[r]) used[sg[k]] = 1;
                sg[r] = 0;
                while (used[sg[r]]) sg[r]++;
                // printf("r = %d to = %d\n", r, sg[r]);
                for (int k : g[r]) used[sg[k]] = 0;
                x = r;
            }
            if (Check()) {
                // printf("upd = %d\n", cycle[j]);
                puts("POSSIBLE");
                return 0;
            }
        }
    }
    puts("IMPOSSIBLE");
}


Measured memory_bytes: 17976
#include<stdio.h>

int main(void)
{
int n,l[101],i,lmax=0,lsum=0;

scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d",&l[i]);

  if(lmax<l[i])
  {
    lmax = l[i];
  }

lsum += l[i];
}

if(lmax<lsum-lmax)
{
printf("Yes");
}
else
{
  printf("No");
}

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define clr(x,y) memset(x,y,sizeof(x))
#define FOR(x,l,r) for(int x=l,x##_=r;x<=x##_;x++)
#define FR(x,l,r) for(int x=l,x##_=r;x<x##_;x++)
#define DOR(x,r,l) for(int x=r,x##_=l;x>=x##_;x--)
using namespace std;
const int N=200005;
int n,m;
int A[N],B[N],C[N];
void Add(int x,int d){
    while(x){
        C[x]=max(C[x],d);
        x&=x-1;
    }
}
int query(int x){
    int res=0;
    while(x<=m){
        res=max(res,C[x]);
        x+=x&-x;
    }return res;
}
int main(){
	cin>>n;
    FOR(i,1,n)scanf("%d",A+i),B[i]=A[i];
    sort(B+1,B+n+1);
    m=unique(B+1,B+n+1)-B-1;
    FOR(i,1,n)A[i]=lower_bound(B+1,B+m+1,A[i])-B;
    int ans=0,c=0;
    FOR(i,1,n){
        Add(A[i],c=query(A[i])+1);
        ans=max(ans,c);
    }cout<<ans;
    return 0;
}


Measured memory_bytes: 1408
S=input()
ACGT=[0]
count=0
for i in range(len(S)):
    if (S[i]=="A")|(S[i]=="C")|(S[i]=="G")|(S[i]=="T"):
        count+=1
    else:
        ACGT.append(count)
        count=0
ACGT.append(count)
print(max(ACGT))

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

// int or ll ?
//0-indexed
template<class T>
struct BIT{
    vector<T> data;
    int size;
    BIT(int sz){
        init(sz);
    }
    void init(int sz){
        size=sz+2;
        data.assign(size,0);
    }
    T sum(int k){
        T ans=0;
        k++;
        while(k>0){
            ans+=data[k];
            k-=k&(-k);
        }
        return ans;
    }
    // data[r:l]の合計
    T sum(int r,int l){
        if(r>l) swap(r,l);
        return sum(l)-sum(r-1);
    }
    void add(int k,T x){
        k++;
        while(k<=size){
            data[k]+=x;
            k+=k&(-k);
        }
    }
};

signed main(){
    int N,Q;
    cin>>N>>Q;
    BIT<ll> b(N);
    while(Q--){
        int com,x,y;
        cin>>com>>x>>y;
        if(com==0){
            x--;
            b.add(x,y);
        }else{
            x--; y--;
            cout<<b.sum(x,y)<<endl;
        }
    }
}


Measured memory_bytes: 3568
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    int n, m;
    cin >> n >> m;
    int p = (n - 1) / 2;
    VI a(p), b(p);
    REP(i,p){
        a[i] = p - i;
        b[i] = p + i + 1;
        if (n % 2 == 0 && 2 * i >= p){
            b[i]++;
        }
    }
    REP(i,m){
        printf("%d %d\n", a[i], b[i]);
    }
    return 0;
}


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

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s;
    if (s[k - 1] == 'A') s[k - 1] = 'a';
    else if (s[k - 1] == 'B') s[k - 1] = 'b';
    else s[k - 1] = 'c';

    cout << s; 
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int a,b;
    cin >> a >> b;
    if(a < b)cout<< 0 << endl;
    else cout << 10 << endl;
    return 0;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
vector<string> G;
vector<vector<int> > dp;
int main(){
    int H, W;
    cin >> H >> W;
    G.resize(H);
    dp.assign(H, vector<int>(W, 0));
    for(int i=0; i<H; ++i){
        string a;
        cin >> a;
        G[i] = a;
    }
    dp[0][0] = 1;
    for(int i=0; i<H; ++i){
        for(int j=0; j<W; ++j){
            if(G[i][j]=='#') continue;
            if(i-1>=0 && G[i-1][j]!='#') dp[i][j] += dp[i-1][j];
            if(j-1>=0 && G[i][j-1]!='#') dp[i][j] += dp[i][j-1];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H-1][W-1] << endl;
    return 0;
}

Measured memory_bytes: 5248
import scala.io.{StdIn => in}

object Main extends App {
  val Array(h, w) = in.readLine.split(" ").map(_.toInt)
  val table = Iterator.continually(in.readLine)
    .take(h)
    .map(_.split(" "))
    .toArray

  val res = for {
    i <- 0 until h
    j <- 0 until w
    if table(i)(j) == "snuke"
  } yield (i, j)

  val ans = "" + (res.head._2 + 'A').toChar + (res.head._1 + 1)
  println(ans)
}

Measured memory_bytes: 25552
#include <stdio.h>

int main(void){
  int N,K;
  scanf("%d%d",&N,&K);

  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d",&A[i]);
  }

  if(N == K){
    printf("1\n");
    return 0;
  }
  printf("%d\n",(N-1+K-2)/(K-1));

  return 0;
}

Measured memory_bytes: 512
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

s = readline().rstrip()
t = readline().rstrip()

ls = len(s)
lt = len(t)
ans = INF
for i in range(ls-lt+1):
    c = 0
    for j in range(lt):
        if s[i+j] != t[j]:
            c += 1
    ans = min(ans,c)
print(ans)


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

int main(){
    int n; cin >> n;
    vector<int> b(n-1); rep(i,n-1) cin >> b[i];
    int ans = b[0];
    rep(i,n-2) ans += min(b[i], b[i+1]);
    ans += b[n-2];
    cout << ans << endl;
}

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

int main(){
  vector<bool> prime(1299709,1);
  prime[1]=0;
  for(int i=2;i<prime.size();i++){
    if(prime[i]==1){
      for(int j=i*2;j<prime.size();j+=i)prime[j]=0;
    }
  }
  //for(int i=0;i<prime.size();i++)if(prime[i]==1)cout<<i<<" ";
  while(1){
    int n;
    cin>>n;
    if(n==0)break;
    int ans=0;
    for(int i=0;i<prime.size();i++){
      if(prime[n+i]==1)break;
      ans++;
    }
    for(int i=0;i<prime.size();i++){
      if(prime[n-i]==1)break;
      ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3080
n1 = [int(i) for i in input().split()]

c1 = 0

for i2 in range(2):
    if n1[i2 + 1] > n1[c1]:
        c1 = i2 + 1

r1 = 0
for i1 in range(3):
    if c1 == i1:
        r1 += n1[i1] * 10
    else:
        r1 += n1[i1]

print(r1)


Measured memory_bytes: 2940
#include<stdio.h>
#include<string.h>
int main(){
  int n;
  char s[10010];
  scanf("%d %s",&n,s);
  int len=strlen(s);
  for(int i=0;i<len;i++){
    int x=s[i]-'A';
    x=(x+n)%26;
    putchar('A'+x);
  }
  putchar('\n');
}

Measured memory_bytes: 1652