akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)

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

constexpr int MAXN = 2e3 + 5;
vi graph[MAXN];
int dist[MAXN];
int ans[MAXN];

void bfs(int src) {
    memset(dist, 0x3f, sizeof(dist));
    queue<int> q;
    q.push(src);
    dist[src] = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v : graph[u]) {
            if (dist[u] + 1 < dist[v]) {
                dist[v] = dist[u] + 1;
                q.push(v);
            }
        }
    }
}

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

    int n, x, y;
    cin >> n >> x >> y;
    --x; --y;

    for (int i = 0; i + 1 < n; ++i) {
        graph[i].push_back(i + 1);
        graph[i + 1].push_back(i);
    }

    graph[x].push_back(y);
    graph[y].push_back(x);

    for (int src = 0; src < n; ++src) {
        bfs(src);
        for (int snk = 0; snk < src; ++snk) {
            ans[dist[snk]]++;
        }
    }

    for (int i = 1; i < n; ++i) {
        cout << ans[i] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 384
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            int val = 700;

            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'o') {
                    val += 100;
                }
            }

            System.out.println(val);
        }
    }
}


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

using namespace std;
typedef long long int lld;
#define INF 1000000000000000000
#define MOD 1000000007
int DP[1000][1000];
char table[1000][1000];
int n,m;
lld compute(int a,int b){//cout<<a<<" "<<b<<endl;
	if(a==-1 || b==-1 || table[a][b]=='#')return 0;
	if(DP[a][b]!=-1)return DP[a][b];
	DP[a][b]=compute(a-1,b)+compute(a,b-1);
	DP[a][b]%=MOD;
	return DP[a][b];
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){DP[i][j]=-1;
			cin>>table[i][j];
		}
	}DP[0][0]=1;
	cout<<compute(n-1,m-1)<<endl;
	
	return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k;
  int a,b;
  cin >> k >> a >> b;
  int i, f=0;
  for(i=a;i<=b;i++){
    if(i%k==0){
      cout << "OK\n";
      f=1;
      break;
    }
  }
  if(!f)	cout << "NG\n";
  return 0;}

Measured memory_bytes: 3560
N = int(input())
B = list(map(int, input().split()))
ans = 0
INF=2*10**5
old_B=INF
for i in range(N):
	if i==N-1:ans+=old_B
	else:
		ans+=min(old_B, B[i])
		old_B=B[i]
print(ans)

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

/*
 * @title NBase
 */
class NBase{
public:
	inline static vector<long long> translate(long long X,long long N) {
		assert(abs(N)>1);
		vector<long long> res;
		while(1) {
			long long b = (X%abs(N)+abs(N)) % abs(N);
			res.push_back(b);
			(X -= b) /= N;
			if(X==0) break;
		}
		return res;
	}
	//Digit Sum
	inline static constexpr long long digit_sum(long long N, long long K) {
		long long sum = 0;
		for (; N > 0; N /= K) sum += N % K;
		return sum;
	}
};


int main() {
    ll N; cin >> N; N--;
    vector<ll> A(13);
    A[0]=26;
    for(int i = 1; i < 13; ++i) A[i] = 26*A[i-1];
    int idx = -1;
    for(int i = 0; i < 13; ++i) if(A[i]<=N) {
        N -= A[i];
        idx = i;
    }
    corner(idx==-1,char('a'+N));
    auto t = NBase::translate(N,26);
    string S = string(idx+2,'a');
    // print(N,idx);
    // print(t);
    // print(S);
    for(int i = 0; i < t.size(); ++i) {
        S[i] = char(t[i]+'a');
    }
    reverse(ALL(S));
    cout << S << endl;
    
    return 0;
}


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

typedef long long ll;
ll n, ans = 3;
ll M = 1e9 + 7;
string a[2];
int main()
{
	ll i;
	cin >> n >> a[0] >> a[1];
	if (a[0][0] == a[0][1]) i = 2, ans = 6;
	else i = 1, ans = 3;
	for (; i < n; i++) {
		if (a[0][i] == a[1][i]) {
			if (a[0][i - 1] == a[1][i - 1]) ans *= 2;
		} else {
			if (a[0][i - 1] != a[1][i - 1]) ans *= 3;
			else ans *= 2;
			i++;
		}
		ans %= M;
	}
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const long long INF = 1LL << 60;
const ll C = 1000000000+7;

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

    ll min_cost = INF;
    for(int k=0; k<=100000; k++) {
        ll cost = 2*C*k + max(0, X-k) * A + max(0, Y-k) * B;
        min_cost = min(min_cost, cost);
    }
    cout << min_cost << endl;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var s = Console.ReadLine();
        var t = Console.ReadLine().ToCharArray().ToList();
        t.RemoveAt(t.Count - 1);

        Console.WriteLine((s == new string(t.ToArray())) ? "Yes" : "No");
    }
}

Measured memory_bytes: 26460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
string x[100100];
int main() {
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {cin>>x[i];sort(x[i].begin(),x[i].end());}
    sort(x,x+n);ll sum=0;
    for(int i=0;i<n;i++)
    {
        int y=i+1;
        ll u=0;
        while(x[i]==x[y]&&y<n)
        {
            y++;
            u++;
        }
        i=y-1;
        sum+=u*(u+1)/2;
    }
    cout<<sum;
    return 0;
    }


Measured memory_bytes: 7296
#include <algorithm>
#include <bitset>
#include <climits>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <utility>
#include <valarray>
#include <vector>

#define rep(i, a, n) for(int i = (a);i < (n);i++)
#define REP(i, n)    rep(i, 0, n)
#define all(e)       (e).begin(), (e).end()

#ifdef LOCAL
#define show(x) cerr<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#else
#define show() true
#endif

using namespace std;
using ll=long long;
template<class T> using V=vector<T>;

template<class T, class U>
void chmin(T &t, const U u) { if (t > u) t = u; }

template<class T, class U>
void chmax(T &t, const U u) { if (t < u) t = u; }

const int INF = (1 << 30) - 1;
const ll INFL = (ll) 5e15;
const int MOD = 1000000007;

class Solver {
public:
    bool solve() {
        cin >> N >> M >> A;
        if (N == 0) return false;
        G.resize(N+1, V<int>(1010));
        REP(i, M) {
            int h, p, q;
            cin >> h >> p >> q;
            G[p][h] = q;
            G[q][h] = p;
        }

        for (int i = 1005; i >= 0; --i) {
            if (G[A][i] != 0) {
                A = G[A][i];
            }
        }

        cout << A << endl;

        return true;
    }

private:
    int N, M, A;
    V<V<int>> G;
};

int main() {

    while (Solver().solve());

    return 0;
}



Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
#define int           long long
#define pb            push_back
#define all(a)        (a).begin(),(a).end()
#define sz(x)         (int)x.size()
#define F             first
#define S             second
#define endl          "\n"
#define inf           (long long)1000000007
#define FOR(i, a, b)  for(int i=a; i<b; i++)
#define bigint        1e18
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count()); 
#define SHUF(v) shuffle(aint(v), RNG);
// Use mt19937_64 for 64 bit random numbers. 

template <typename T>
T ceil(T a, T b){ return (a+b-1)/b; }


template<typename T>
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
set<int> fact(int n){
    set<int> ans;
    while (n % 2 == 0)  {  
        ans.insert(2);
        n = n/2;  
    }  
 
    for (int i = 3; i <= sqrt(n); i = i + 2)  {  
        while (n % i == 0)  {  
            ans.insert(i);
            n = n/i;  
        }  
    }  
    if (n > 2) {
        ans.insert(n);
    }
    return ans;
}
void solve(){
    int n; cin>>n;
    int a[n];
    FOR(i, 0, n) {
        cin>>a[i];
    }
    int g=a[0];
    bool F=1;
    vector<int> m(1000002);
    FOR(i, 0, n) {
        set<int> s = fact(a[i]);
        for(int x:s) {
            m[x]++;
            if(m[x]>1) {
                F=0;
            }
        }
        if(i>0) {
            g = __gcd(g, a[i]);
        }
    }
    bool st = 1;
    if(g > 1){
        st = false;
    }
    if(F){
        cout<<"pairwise coprime";
    }
    else if(st){
        cout<<"setwise coprime";
    }
    else{
        cout<<"not coprime";
    }
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);     
    int t=1;
    //cin>>t;
    FOR(i, 1, t+1){ 
        //cout<<"Case #"<<i<<": ";
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
 
}

Measured memory_bytes: 18756
#include<stdio.h>
#define maxn 201111
int m,n;
int a[maxn];
int b[maxn];
int flag = 1;
int ans = 0;
int p[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)
    {
        scanf("%d",a+i);
    }
    for(int i=n;i>=1;--i)
    {
        int now = i;
        int acc = 0;
        do
        {
            acc += b[now];
            now += i;
        }while(now <= n);
        if(acc % 2 != a[i])
        {
            b[i] = 1;
            ans++;
            p[ans] = i;
        }
    }

    printf("%d\n",ans);
    for(int i=1;i<=ans;++i)
        printf("%d ",p[i]);
}

Measured memory_bytes: 2688
#include <stdio.h>

int main(void){
    int N, A[20], B[20], x[20][20], y[20][20], i, j, k, p, t, n, X, M;
    scanf("%d", &N);
    for (i=1; i<=N; i++) {
        scanf("%d", &A[i]);
        for (j=1; j<=A[i]; j++) scanf("%d%d", &x[i][j], &y[i][j]);
    }
    p=1;
    for (i=1; i<=N; i++) p*=2;
    n=p;
    M=0;
    for (i=0; i<=n-1; i++) {
        for (j=0; j<=N-1; j++) {
            p=1;
            for (k=1; k<=j; k++) p*=2;
            B[N-j]=i/p%2;
        }
        
        /*
        printf("%d: ", i);
        for (j=1; j<=N; j++) printf("%d ", B[j]);
        printf("\n");
        */
        
        t=1;
        for (j=1; j<=N; j++) {
            if (B[j]==0) continue;
            for (k=1; k<=A[j]; k++) {
                // printf("(%d %d)\n", B[x[j][k]], y[j][k]);
                if ((B[x[j][k]] != y[j][k])) {
                    t=0;
                    break;
                }
            }
            if (t==0) break;
        }
        
        if (t==1) {
            X=0;
            for (j=1; j<=N; j++) X+=B[j];
            // printf("!%d: %d\n", i, X);
            if (X>M) M=X;
        }
    }
    printf("%d", M);
    return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

typedef pair<int, int> P;

int h, w;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};
string field[1000];

int bfs(int& x, int& y, char goal) {
	queue<P> que;
	que.push(P(x, y));

	vector<vector<int> > d(h, vector<int>(w, -1));
	d[y][x] = 0;

	for(;;) {
		P s = que.front();
		que.pop();

		if(field[s.second][s.first] == goal) {
			x = s.first;
			y = s.second;
			return d[y][x];
		}

		for(int i = 0; i < 4; ++i) {
			int nx = s.first + dx[i], ny = s.second + dy[i];

			if(nx < 0 || ny < 0 || nx >= w || ny >= h)
				continue;

			if(field[ny][nx] == 'X' || d[ny][nx] != -1)
				continue;

			d[ny][nx] = d[s.second][s.first] + 1;
			que.push(P(nx, ny));
		}
	}
}

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

	int n;
	cin >> h >> w >> n;

	for(int i = 0; i < h; ++i)
		cin >> field[i];

	int x, y;
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == 'S') {
				x = j;
				y = i;
				break;
			}
		}
	}

	int ans = 0;
	for(int i = 1; i <= n; ++i)
		ans += bfs(x, y, '0' + i);

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 6072
local D=io.read"*n"

local c={}
for i=1,26 do c[i]=io.read"*n"end
local s={}
for i=1,D do s[i]={}for j=1,26 do s[i][j]=io.read"*n"end end

local function copy(t)local ret={}for i,v in ipairs(t)do ret[i]=v end return ret end

local function calc(d,t,l)
	local a=0
	l[t]=d
	for j=1,26 do
		a=a-c[j]*(d-l[j])
	end
	return a+s[d][t]
end

local t={}
for i=1,D do t[i]=io.read"*n"end

local last={}
for i=1,26 do
last[i]=0
end

local ret={}
local a=0
--score,contestid,last
local beam={{0,{},last}}
for i=1,D do
	local newbeam={}
	for k,b in ipairs(beam) do
		local lastt={}
		for j=1,26 do
			lastt[j]=copy(b[3])
		end
		for j=1,26 do
			local t=copy(b[2])
			table.insert(t,j)
			table.insert(newbeam,{b[1]+calc(i,j,lastt[j]),t,lastt[j]})
		end
	end
	table.sort(newbeam,function(a,b)return a[1]>b[1]end)
	newbeam[52]=nil
	beam=newbeam
end

for i,v in ipairs(beam[1][2])do
print(v)
end

Measured memory_bytes: 35088
x1,y1,x2,y2=map(int,input().split())

a=(x2-x1)
b=(y2-y1)

x3=x2-b
y3=y2+a

x4=x3-a
y4=y3-b
        
print(str(x3)+" "+str(y3)+" "+str(x4)+" "+str(y4))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define intarr(arr, n)  ll arr[n];  for (ll i = 0; i < n; i++)  cin >> arr[i]
#define inpvec(vec,n) for(ll i=0;i<n;i++){ll var;cin>>var;vec.push_back(var);}
#define ff first
#define ss second
#define pb push_back
#define mkp make_pair
#define vec vector<ll>
#define pi pair<ll,ll>
#define changeline cout<<endl
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define mod2 998244353
#define NO cout << "NO" <<endl
#define YES cout << "YES" <<endl
#define mem(arr,val) memset(arr,val,sizeof(arr));
const ll mod=1e9+7;
#define piii 3.14159265358979323846264338327950


bool prime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
bool subsequence_checker(string str1, string str2, ll m, ll n) 
{ 
    if (m == 0) return true; 
    if (n == 0) return false; 
    if (str1[m-1] == str2[n-1]) 
        return subsequence_checker(str1, str2, m-1, n-1); 
    return subsequence_checker(str1, str2, m, n-1); 
}

//////////////////////////////////////////////////// Lets Do It ////////////////////////////////////////////////////////
bool cmp(const pair<int,int> &a,  const pair<int,int> &b) 
{ 
    if(a.ff == b.ff)
        return a.ss>b.ss;
    return (a.ff < b.ff); 
} 
void solve(){

    ll n;
    cin>>n;
    vec a;
    inpvec(a,n);

    ll j =0;
    loop(i,0,n){
         j = j^a[i];
    }

    loop(i,0,n)
    {
        ll x=j^a[i];
        cout<<x<<" ";
    }


    return;    
} 
 
int main()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
    IOS;
    ll t;
    //cin>>t;
    t=1;

    while(t--){
        solve();
        cout<<endl;
    }

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 5308
import java.util.Scanner;

public class Main {
	void run(){
		Scanner s = new Scanner(System.in);
		String W = s.next();
		int count = 0;
		while(true){
			String T = s.next();
			if(T.equals ("END_OF_TEXT")) break;
			if(W.compareToIgnoreCase(T) == 0){
				count++;
			}
		}
			System.out.println(count);
		}

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

Measured memory_bytes: 26176
import sys


class Node(object):
    def __init__(self, key=None, parent=None):
        self.key = key
        self.parent = parent
        self.left = None
        self.right = None

    def __str__(self):
        return "Not implemented yet."

    def __repr__(self):
        return self.__str__()


def insert(key, node):
    if key < node.key:
        if node.left is None:
            left_node = Node(key, node)
            node.left = left_node
        else:
            insert(key, node.left)
    else:
        if node.right is None:
            right_node = Node(key, node)
            node.right = right_node
        else:
            insert(key, node.right)


def print_preorder(node):
    print(" %d" % node.key, end="")
    if node.left is not None:
        print_preorder(node.left)
    if node.right is not None:
        print_preorder(node.right)


def print_inorder(node):
    if node.left is not None:
        print_inorder(node.left)
    print(" %d" % node.key, end="")
    if node.right is not None:
        print_inorder(node.right)


def main():
    lines = sys.stdin.readlines()
    root = Node()

    for order in lines[1:]:
        if order.startswith("insert"):
            command, key = order.strip().split(" ")
            key = int(key)
            if root.key is None:
                root.key = key
            else:
                insert(key, root)
        elif order.startswith("print"):
            print_inorder(root)
            print("")
            print_preorder(root)
            print("")

if __name__ == "__main__":
    main()

Measured memory_bytes: 193328
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N, K;
set<int> S;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N >> K;
    FOR (K) {
        int d;
        cin >> d;
        FOR (j, d) {
            int a;
            cin >> a;
            S.insert(a);
        }
    }
    cout << N - S.size() << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3656
import java.util.Scanner;

public class Main {

	public static int gcd(int x, int y) {
		if (y == 0) { 
			return x + y; }
		else {
			return gcd(y, x % y); } 			
	}
		
	
	public static void main(String[] args) {
		Scanner scnr = new Scanner(System.in);
		int x = scnr.nextInt();
		int y = scnr.nextInt();
		System.out.println(gcd(x, y));
	}
}



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

const int N = 1e5 + 10;

int a[N];

int main(){
	int n, pos;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) scanf("%d",&a[i]);
	sort(a + 1, a + n + 1);
	if (a[1] + 2 <= a[n]) printf("No\n");
	else if (a[1] == a[n]){
		if (a[1] == n - 1 || n % a[1] == 0) printf("Yes\n");
		else printf("No\n");
	}
	else{
		for (int i = 1; i < n; i++){
			if (a[i] < a[i + 1]){
				pos = i;
				break;
			}
		}
		if (a[n] > pos && (n - pos) % (a[n] - pos) == 0) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(int i = (m); i <= (n); i++)
#define zep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, m; cin >> n >> m;
	ll sm = 0;
	zep(i, 0, m){
		ll a; cin >> a;
		sm += a;
	}
	print((sm > n)? -1 : n-sm)
	return 0;
}

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

int main() {
    double n;
    cin >> n;
    double sum = 0;
    vector<double> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    double avg = round(sum / n);
    long long ans = 0;
    for (auto x : a) {
        long long q = avg - x;
        ans += q * q;
    }
    cout << ans;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;

int main(){
	ll n; cin >>n;
	if(n==0)cout << 0 << endl;
	string ans="";
	while(n!=0){
		ll r=n%2;
		if(r<0)r+=2;
        n=(n-r)/(-2);
		ans+= (char)('0'+r);
	}
	reverse(ans.begin(),ans.end());
	cout << ans << endl;
} 

Measured memory_bytes: 256
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
#include<cstdio>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    #ifndef ONLINE_JUDGE
        clock_t tStart = clock();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin>>n;
    if(n==0)
    	cout<<"1"<<endl;
    else
    	cout<<"0"<<endl;
    
    #ifndef ONLINE_JUDGE
        fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
    #endif
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
    int x;
    cin >> x;
    if (1 <= x && x <= 3000)
    {
        if (x <= 1199)
            cout << "ABC";
        else if (x >= 1200)
            cout << "ARC";
    }
    return 0;
}


Measured memory_bytes: 504
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define INF 2147483647
#define MOD 10000007
#define REP(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;

}


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

#define MAX 1000000001
#define SIZE 500001

int S[SIZE];
int count = 0;
int n;

void print(){
    for(int i = 0; i < n; i++){
        if(i != 0)  cout << " ";
        cout << S[i];
    }
    cout << endl;
    cout << count << endl;
}

void merge(int A[], int left, int mid, int right){
    int n1 = mid-left;
    int n2 = right-mid;
    int L[n1+1];
    int R[n2+1];
    for(int i = 0; i < n1; i++) L[i] = A[left+i];
    for(int i = 0; i < n2; i++) R[i] = A[mid+i];
    L[n1] = MAX;
    R[n2] = MAX;

    int li = 0;
    int ri = 0;

    for(int i = left; i < right; i++){
        if(L[li] <= R[ri]){
            A[i] = L[li];
            li++;
        }else{
            A[i] = R[ri];
            ri++;
        }
        count++;
    }
}

void mergeSort(int A[], int left, int right){
    if(left+1 < right){
        int mid = (left+right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++)  cin >> S[i];
    mergeSort(S,0,n);
    print();
    return 0;
}



Measured memory_bytes: 6920
time = []
for i in range(5):
    time.append(int(input()))

total = 0
n = 0
mod10 = [i%10 for i in time]
mod10_l = []
for i in mod10:
    if i > 0:
        mod10_l.append(i)
for i,j in zip(mod10, time):
    if i == 0:
        total += j
    elif n == 0 and i == min(mod10_l):
        total += j
        n += 1
    else:
        total += j + 10-i
print(total)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int X,tamp=0,sum=0;
    cin>>X;
    if(X/500)
    {
        tamp=X/500;
        sum=sum+tamp*500*2;
        X=X%500;
    }
    if(X/5)
    {
        tamp=X/5;
        sum=sum+tamp*5;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;


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

    vector<string> s(n);
    vector<string> ans(n);

    rep(i,n){
        cin >> s[i];
    }

    sort(s.begin(),s.end());

    int tmp=1;
    int jud=0;
    
    rep(i,n-1){
        if(s[i] == s[i+1]){
            tmp++;
        }
        else{
            jud = max(jud,tmp);
            tmp =1;
        }
    }

    jud = max(jud,tmp);

    tmp =1;
    int ok =0;

    rep(i,n-1){
        if(s[i] == s[i+1]){
            tmp++;
            if(jud == tmp){
                ans[ok] = s[i]; 
                ok++;
            }
        }
        else{
            tmp =1;
        }
    }

    if(jud == 1){
        rep(i,n){
            dunk(s[i]);
        }
    }

    else{
    rep(i,ok+1){
        dunk(ans[i]);
    }
    }
}

Measured memory_bytes: 15872
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   ll h,w;
   string s;   
   cin >> h >> w;
   ll ans=0;
   if (h%2==0) ans=h/2*w;
   else {
      ll tmp = h/2;
      if (w%2==0) ans=h*w/2;
      else {
         ans=h*(w-1)/2+tmp+1;
      }
   }
   if (h==1 || w==1)  ans=1LL;
   cout << ans <<endl;
  
 
   
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=1000000007;
int main(){
int n,m;cin>>n>>m;
vector<vector<int>> s(10,vector<int>(10,0));
rep(i,m){
    int k;cin>>k;
    s[i].resize(k);
    rep(j,k){
        cin>>s[i][j];
        s[i][j]--;
    }
}
int p[m];
rep(i,m)cin>>p[i];
int tmp=0;
rep(bit,1<<n){
    vector<int> ok(n,0);
 rep(i,n){
     if(bit>>i&1)ok[i]=1;
 }
 bool ans=true;
 rep(i,m){
     int cnt=0;
     for(int q:s[i]){
         if(ok[q])cnt++;
     }
    if(cnt%2!=p[i])ans=false;
 }
 if(ans)tmp++;
}
cout<<tmp<<endl;
}

Measured memory_bytes: 256
k, s = map(int, input().split())

if s==3*k:
    print(1)
else:
    ans=0
    for i in range(k+1):
        if i>s:
            break
        for j in range(k+1):
            if i+j+k>=s and s-i-j>=0:
                ans+=1
            elif i+j>s:
                break

    print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int MX = 315;
const int MM = 1000000007;

int N;

int main()
{
	int mn[26] = {};
	for(int i = 0; i < 26; i++) mn[i] = 1e9;
	scanf("%d", &N);
	for(int i = 1; i <= N; i++){
		string A;
		cin >> A;
		int cnt[26] = {};
		for(char c : A) cnt[c-'a']++;
		for(int i = 0; i < 26; i++) mn[i] = min(mn[i], cnt[i]);
	}
	string A;
	for(int i = 0; i < 26; i++){
		for(int t = 0; t < mn[i]; t++) A.push_back('a'+i);
	}
	cout << A << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
    int m;
    int n;
    while (1) {
        cin >> m >> n;
        if (m == 0 && n == 0) {
            break;
        }

        vector<bool> v(7368792, 0);
        int base = m;
        int base_now;
        int count = 0;
        while (1) {
            base_now = 0;
            for (int i = 1; i * base < v.size(); i++) {
                base_now += base;
                v[base_now] = 1;
            }
            count++;

            if (count == n) {
                break; 
            }

            while (1) {
                if (v[base] == 0) {
                    break;
                } else {
                    base++;
                }
            }
        }


        int check = m;
        while (1) {
            if (v[check] == 0) {
                cout << check << endl;
                break;
            }
            check++;
        }
    }
    return 0;
}

Measured memory_bytes: 3996
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;




int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================

	int N, M, K;
	string S;
	cin >> N >> S;

	if (N % 2 != 0) {
		cout << "No";
		return 0;
	}
	else {
		for (int i = 0; i < N/ 2; i++) {
			if (S[i] != S[i + N/2]) {
				cout << "No";
				return 0;
			}


		}


		cout << "Yes";



	}







}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int sim(vector<Int> A){
  Int N = A.size();
  Int k = 0;
  while(1){
    Int idx = 0;
    for(Int i=0;i<N;i++) if(A[idx] < A[i]) idx = i;
    if(A[idx] < N) return k;
    k++;
    for(Int i=0;i<N;i++) A[i]++;
    A[idx] -= (N + 1);
    pr(k, A);
  }
}

vector<Int> sim(vector<Int> A, Int K){
  Int N = A.size();
  for(Int i=0;i<K;i++){
    Int idx = 0;
    for(Int i=0;i<N;i++) if(A[idx] < A[i]) idx = i;
    for(Int i=0;i<N;i++) A[i]++;
    A[idx] -= (N + 1);
  }
  return A;
}
signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  if(0){
    Int N;
    cin>>N;
    vector<Int> A(N);
    cin>>A;

    sim(A);
  }

  Int K;
  cin>>K;

  Int n = 50;
  vector<Int> ans(n, 0);
  for(Int i=0;i<n;i++){
    ans[i] = ((K-1) / n + 1) + n - 1;
  }
  ans = sim(ans, (n - K % n) % n);
  if(K == 0) ans = vector<Int>(n, 0);
  cout<<n<<endl;
  cout<<ans<<endl;
  //assert(sim(ans) == K);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cst() int __t;scanf("%d",&__t);while(__t--)
#define rep(i,s,e) for(int i=s;i<e;++i)
#define repb(i,s,e) for(int i=s;i<=e;++i)
#define lep(i,s,e) for(int i=s;i>e;--i)
#define lepb(i,s,e) for(int i=s;i>=e;--i)
#define mst(a,b) memset(a,b,sizeof(a))
#define mcpy(des,sor) memcpy(des,sor,sizeof(sor))
#define pow2(x) ((x)*(x))
#define pt(x) cout<<#x<<"="<<x<<endl;
#define maxn 333
#define maxm 5005
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
const double pi = acos(-1.0);
const long long mod = 1e9+7;
typedef long long ll;
typedef pair<int,int> pii;

int cnt[maxn];
bool cmp(int a,int b){return cnt[a]>cnt[b];}

int main()
{
	int n,m,a,rank[maxn],ans;
	queue<int> q[maxn];
	bool out[maxn];
	mst(cnt,0);mst(out,0);
	cin>>n>>m;
	repb(i,1,n)repb(j,1,m){cin>>a;q[i].push(a);}
	repb(i,1,m)rank[i]=i;
	repb(i,1,n)++cnt[q[i].front()];
	sort(rank+1,rank+1+m,cmp);
	ans=cnt[rank[1]];
	repb(i,2,m)
	{
		out[rank[1]]=true;
		cnt[rank[1]]=0;
		repb(i,1,n)if(out[q[i].front()])
		{
			while(out[q[i].front()])q[i].pop();
			++cnt[q[i].front()];
		}
		sort(rank+1,rank+1+m,cmp);
		ans=min(ans,cnt[rank[1]]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication59
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                int a = int.Parse(Console.ReadLine());
                if (a == 0) break;
                int x, y; x = y = 0;
                for (int b = 0; b < a; b++)
                {
                    int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    if (c[0] > c[1])
                    {
                        x += c[0] + c[1];
                    }
                    else if (c[1] > c[0])
                    {
                        y += c[0] + c[1];
                    }
                    else
                    {
                        x += c[0];
                        y += c[1];
                    }
                }
                Console.WriteLine("{0} {1}", x, y);
            }
        }
    }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct SegTree {
  int size;
  vector<ll> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,0); }
  ll operator[](const ll &x) const { return pos[x+size]; }

  void build() { per(i,size) operate(i); }
  void set(ll x, const ll v) { pos[x+size] = v; }
  void update(ll x, const ll v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  ll query(ll a, ll b) {
    ll L = 0, R = 0;
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(pos[b],R); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = pos[i*2] + pos[i*2+1]; }
  ll q(ll x, ll y) { return x + y; }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, Q; cin >> N >> Q;
  ll a[N]; rep(i,N) cin >> a[i];

  SegTree st(N); rep(i,N) st.update(i,a[i]);
  rep(_,Q) {
    ll t, x, y; cin >> t >> x >> y;
    if (t==0) st.update(x,st[x]+y);
    else cout << st.query(x,y) << endl;
  }
  return 0;
}

Measured memory_bytes: 16432
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,c,sum=0;
int main()
{
    scanf("%d %d",&a,&b);
    if(a==1&&b==1)
    {
        printf("A1");
        return 0;
    }
    for(int i=1;i<=a*b;i++)
    {
        cin>>s;sum++;
        if(s=="snuke")break;
    }
    c=sum%b==0?b:sum%b;
    printf("%c%.0lf",64+c,ceil((sum+0.00)/b));
    return 0;
}

Measured memory_bytes: 256
def resolve():
    n=int(input())
    xyh=[[0]*3 for _ in range(n)]
    for i in range(n):
        x,y,h=map(int,input().split())
        xyh[i][0],xyh[i][1],xyh[i][2]=h,x,y
    xyh.sort(reverse=True)
    ans,flg=0,0
    for cx in range(101):
        for cy in range(101):        
            ans,flg=0,0
            for h,x,y in xyh:
                if ans==0:
                    if h==0:
                        continue
                    else:
                        ans=h+abs(x-cx)+abs(y-cy)
                else:
                    if h==0:
                        if ans>abs(x-cx)+abs(y-cy):
                            flg=1
                            break
                        else:
                            continue
                    else:
                        if ans==h+abs(x-cx)+abs(y-cy):
                            continue
                        else:
                            flg=1
                            break
            if flg==0:
                break
        if flg==0:
            break
    print(cx,cy,ans)            

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3064
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=2e3+5,inf=1e18;
ll  n,m=inf,k,x,y,h[maxn],num[2][maxn];
bool mark[maxn];
vector <ll> adj[maxn];
pair <ll,ll> p[maxn];
void dfs(int u,int v){
	mark[u]=1;
	for(int j:adj[u]){
		if(!mark[j]&&j!=v){
			h[j]=h[u]+1;
			num[0][h[u]+1]++;
			dfs(j,v);
		}
	}
}
void dfs2(int u,int v){
	mark[u]=1;
	for(int j:adj[u]){
		if(!mark[j]&&j!=v){
			h[j]=h[u]+1;
			num[1][h[u]+1]++;
			dfs2(j,v);
		}
	}
}
void dfs3(int u){
	mark[u]=1;
	for(int j:adj[u]){
		if(!mark[j]){
			h[j]=h[u]+1;
			num[0][h[j]]++;
			dfs3(j);
		}
	}
}
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		x--;
		y--;
		p[i]={x,y};
		adj[y].push_back(x);
		adj[x].push_back(y);
	}
	if(k%2==1){
		for(int i=1;i<n;i++){
			dfs(p[i].first,p[i].second);
			dfs2(p[i].second,p[i].first);
			x=0;
			for(int j=(k+1)/2;j<=n;j++){
				x+=num[0][j];
				x+=num[1][j];
			}
			m=min(m,x);
			for(int j=0;j<=n;j++){
				h[j]=0;
				num[0][j]=0;
				num[1][j]=0;
				mark[j]=0;
			}
		}
	}
	else{
		for(int i=0;i<n;i++){
			dfs3(i);
			x=0;
			for(int j=(k/2)+1;j<=n;j++){
				x+=num[0][j];
			}
			m=min(m,x);
			for(int j=0;j<=n;j++){
				h[j]=0;
				num[0][j]=0;
				num[1][j]=0;
				mark[j]=0;
			}
		}
	}
	cout<<m;
	
}


Measured memory_bytes: 640
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>

const long long MOD = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

typedef struct _MedicineInfo{
    llong a;
    llong b;
    llong c;
}MedicineInfo;

int main(){
    llong N, Ma, Mb;
    cin >> N >> Ma >> Mb;
    vector<MedicineInfo> Table(N+1);
    for(int i=1; i<=N; i++){
        cin >> Table[i].a >> Table[i].b >> Table[i].c;
    }
    llong MAX_SIZE = 500;
    vector<vector<vector<llong> > > dp(N+1, vector<vector<llong> >(MAX_SIZE+1, vector<llong>(MAX_SIZE+1,MOD)));
    dp[0][0][0] = 0;
    for(int i=1; i<=N; i++){
        for(int j=0; j<=MAX_SIZE; j++){
            for(int k=0; k<=MAX_SIZE; k++){
                if(j-Table[i].a<0){
                    dp[i][j][k] = dp[i-1][j][k];
                    continue;
                }
                if(k-Table[i].b<0){
                    dp[i][j][k] = dp[i-1][j][k];
                    continue;
                }
                dp[i][j][k] = min(dp[i-1][j][k], dp[i-1][j-Table[i].a][k-Table[i].b]+Table[i].c);
            }
        }
    }
    llong ans=MOD;
    for(int i=1; i<=MAX_SIZE; i++){
        for(int j=1; j<=MAX_SIZE; j++){
            if((Ma*j)==(i*Mb)){
                ans = min(ans, dp[N][i][j]);
            }
        }
    }
    if(ans==MOD){
        cout << -1 << endl;
        exit(0);
    }
    cout << ans << endl;
    return 0; 
}


Measured memory_bytes: 86084
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
	private Scanner sc;

	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		while (sc.hasNextLine()) {
			String[] nico = sc.nextLine().split(",");
			double w = Double.parseDouble(nico[1]);
			double h = Double.parseDouble(nico[2]);
			
			if ((w / (h * h)) >= 25.0) System.out.println(nico[0]);
		}
	}
}

Measured memory_bytes: 26088
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    
    int K = scanner.nextInt();
    int N = scanner.nextInt();
    int locations[] = new int[N];
    
    for(int i = 0;i < locations.length;i++){
      locations[i] = scanner.nextInt();
    }
    
    int sumDistance = 0;
    int maxDistance = locations[1] - locations[0];
    sumDistance += maxDistance;
    
    for(int i = 2;i <= locations.length;i++){
        
      int distance;
      if(i == locations.length){
        distance = Math.abs(K - locations[i - 1]) + locations[0];
      }else{
      	distance = Math.abs(locations[i - 1] - locations[i]);
      }
      sumDistance += distance;
      if(distance > maxDistance){
        maxDistance = distance;
      }
      
      
    }
    
    sumDistance -= maxDistance;
    System.out.println(sumDistance);
  }
}

Measured memory_bytes: 82256