akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <stdio.h>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i] << std::endl;
		else std::cout << da[i] << ' ';
	}
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

const int m = 100010;
const ll mod = 1000000007;
vector<ll> dp(m);

int main() {
	int n, x;cin >> n >> x;
	vector<int> da(n);
	rip(i, n, 0) cin >> da[i];
	sort(all(da));
	reverse(all(da));
	dp[x]= 1;
	rip(i, n, 0) {
		rip(j, m, 0) {
			ll now = dp[j];
			dp[j%da[i]] += now;
			dp[j] += now * (n - i - 2);
			if(dp[j] >= mod) dp[j] %= mod;
			if(dp[j%da[i]] >= mod) dp[j%da[i]] %= mod;
		}
	}
	ll ans = 0;
	rip(i, m, 0){
		ans += (ll)dp[i] * i;
		if(ans >= mod) ans %= mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

N = int(input())
S = list(input())

ans = 0
for i in range(1000):
    pw = list("{0:03d}".format(i))

    if pw[0] in S:
        w1 = S.index(pw[0])
        if pw[1] in S[w1+1:]:
            w2 = w1+1 + S[w1+1:].index(pw[1])
            if pw[2] in S[w2+1:]:
                ans += 1

print(ans)


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

int main() {
  int N, D;
  cin >> N >> D;
  
  if (N % (2 * D + 1) != 0) {
  	cout << N / (2 * D + 1) + 1 << endl;
  }
  
  else {
  	cout << N / (2 * D + 1) << endl;
  }
}

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

#define MaxN 100005
#define INF 2140000000

using namespace std;

int N,Max=INF;

int sum(int x)
{
    int a=0;
    while(x)
        a+=x%10,x/=10;
    return a;
}

int main()
{
    cin>>N;
    for(int i=1;i<N;i++)
    {
        Max=min(Max,sum(N-i)+sum(i));
    }

    cout<<Max;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

// n^r%modを出力
long long mod_pow(long long n, long long r, long long mod){
  long long ret = 1;
  while(r > 0){
    if(r & 1)
      ret = (ret*n)%mod;
    r >>= 1;
    n = n*n%mod;
  }
  return ret;
}


int main(){
  long long N;
  cin >> N;
  pair<long long, long long> p[N];
  long long tmp;
  rep(i, N){
    cin >> tmp;
    p[i] = make_pair(tmp, i);
  }
  // 入力終了

 // 距離0の頂点は絶対ある(頂点1)                                               
  if(p[0].first != 0){
    cout << 0 << endl;
    return 0;
  }
  
  // 距離が短い順にソート
  sort(p, p+N);

  // 距離0の頂点はただ1つ(頂点1のみ)
  if(p[0].first == 0 && p[1].first == 0){
    cout << 0 << endl;
    return 0;
  }

  long long ans = 1;
  long long MOD = 998244353;
  
  // 距離が小さい頂点から順に見ていく
  // number of current vertex, number of previous vertex
  long long curr_vnum = 0, prev_vnum = 1;

  long long i = 1;
  while(i<N){
    curr_vnum = 1;
    // 距離がいきなり2以上飛ぶことはない
    if(p[i-1].first+1 != p[i].first){
      cout << 0 << endl;
      return 0;
    }
    
    // 頂点1からの距離が同じものをまとめて見る
    while(p[i].first == p[i+1].first){
      i++;
      curr_vnum++;
    }

    // 今見ている頂点を，1つ前に見ていた頂点のどれかにつけるため
    // prev^currだけ増えていく
    ans = ans*mod_pow(prev_vnum, curr_vnum, MOD);
    ans = ans % MOD;
    
    // prevの更新
    prev_vnum = curr_vnum;
    
    i++;
  }
  
  // 解答
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 5128
def f(n):
    return n/2 if n %2 == 0 else 3 * n + 1

s = int(input())

an = set()
an.add(s)

c = 1
ai = s
while True:
    c += 1
    ai = f(ai)
    let = an.isdisjoint({ai})
    if let:
        an.add(ai)
    else:
        break
print(c)


Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)
	var ans int
	var bCount int
	for i := len(s) - 1; i >= 0; i-- {
		if s[i] == 'B' {
			ans += len(s) - 1 - i - bCount
			bCount++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
# D

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect

# 再起回数上限変更
# sys.setrecursionlimit(1000000)
PI = math.pi

a, b, x = map(int, input().split())
x /= a

if x >= a * b / 2:
    x = a * b - x
    # print(x)
    # print(2*x/a**2)
    print(math.atan(2*x/a**2) * 180 / PI)
    sys.exit()
else:
    print(90 - math.atan(2 * x / b ** 2) * 180 / PI)
    sys.exit()




Measured memory_bytes: 38768
# salsa=0, rumba=1
# [0 1 0 1] 1より上の位に帯する操作

# 繰り上がりを考慮しつつ、3（より上）の位に対する操作を考える
# [1]       1の位が0である数字の、3の位に対する操作
# [0 1 0]   1の位が1である数字の、3の位に対する操作
# []        1の位が2である数字の、3の位に対する操作
# ある数字が"2"の時にルンバが来れば繰り上がる（上の位にルンバが波及）
# それ以外の状態では、上の位にとってルンバは無いのと同じことになる
# サルサは常に影響するが、連続した2つのサルサは打ち消し合い、無いのと同じことになる

# 再帰的に上の位を決める
# []        3,1の位が00,10である数字の、9の位に対する操作
# [1]       3,1の位が20である数字の、9の位に対する操作
# []        3,1の位が01,21である数字の、9の位に対する操作
# [0 1 0]   3,1の位が11である数字の、9の位に対する操作
# []        3,1の位が02,12,22である数字の、9の位に対する操作

# 一度繰り上がったら、例えば100.. と0がd個続くとして、
# 更にその上の位に波及させるには 2^d オーダーの操作が必要となるので、各操作列は徐々に減っていく

n = int(input())
t = input()
op = [[int(c == 'R') for c in t]]
ans = [0]

for d in range(n):
    k = 3 ** d
    nop = []
    nans = [0] * (k * 3)
    for g in range(3):  # d桁目の数
        for i in range(k):  # d桁目未満の数
            opg = op[i]
            opn = []
            h = g
            for o in opg:
                if o == 0:
                    if len(opn) > 0 and opn[-1] == 0:
                        opn.pop()
                    else:
                        opn.append(0)
                    if h == 1:
                        h = 2
                    elif h == 2:
                        h = 1
                else:
                    if h == 2:
                        h = 0
                        opn.append(1)
                    else:
                        h += 1
            nop.append(opn)
            nans[g * k + i] = h * k + ans[i]

    op = nop
    ans = nans

print(*ans)


Measured memory_bytes: 202804
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	int x;
	cin >> x;
	if (x < 600)
		cout << "8\n";
	else if (x < 800)
		cout << "7\n";
	else if (x < 1000)
		cout << "6\n";
	else if (x < 1200)
		cout << "5\n";
	else if (x < 1400)
		cout << "4\n";
	else if (x < 1600)
		cout << "3\n";
	else if (x < 1800)
		cout << "2\n";
	else
		cout << "1\n";
	return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

vector<ll> dv;
void divisor(ll n)
{
    for (ll i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            dv.push_back(i);
            if (i * i != n)
                dv.push_back(n / i);
        }
    }
    sort(ALL(dv));
}

ll digits(ll n)
{
    ll d = 0;
    while (n > 0)
    {
        n /= 10;
        d++;
    }
    return d;
}

int main()
{
    ll n;
    cin >> n;
    divisor(n);
    ll minv = 12;
    for (auto x : dv)
        minv = min(minv, max(digits(x), digits(n / x)));

    OP(minv);
    return 0;
}

/*int main()
{
    ll n;
    cin >> n;

    double minv = 12;

    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            minv = min(minv, log10(n / i) + 1);
        }
    }
    OP((int)minv);
    return 0;
}*/

Measured memory_bytes: 256
from collections import deque

# 頂点数n、辺の本数m
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    G[a-1].append(b)
    G[b-1].append(a)

# FIFO(取り出しの順番を決める)
q = deque([])
# 0で初期化
q.append(0)
# 頂点が訪問済かどうかを格納(距離情報を保存)
dist = [-1] * n
dist[0] = 0
# 深さ-1の部屋番号を保存
pre = [-1] * n

while q:
    v = q.popleft()
    for nv in G[v]:
        nv -= 1
        if dist[nv] != -1:
            continue
        dist[nv] = dist[v] + 1
        pre[nv] = v + 1
        q.append(nv)

if -1 in pre[1:]:
    print('No')
else:
    print('Yes')
    for i in range(1, n):
        print(pre[i])


Measured memory_bytes: 38824
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void) {
  int n, k;
  vector<int> v;
  cin>>n;
  cin>>k;
  for(int i=0; i<n; i++) {
    int x;
    cin>>x;
    v.push_back(x);
  }
  sort(v.begin(), v.end());
  std::cout << v.end()-lower_bound(v.begin(), v.end(), k) << std::endl;
  
  return 0;
}



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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    ll x, k, d;
    cin >> x >> k >> d;

    x = abs(x);
    ll amari = x % d;

    ll count = (x - amari) / d;

    if(count > k){
        x = x - k * d;
    }else if(count == k){
        x = amari;
    }else{
        if((k - count) % 2 == 0){
            x = amari;
        }else{
            x = abs(amari - d);
        }
    }

    cout << x << endl;

    return 0;
}

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

using namespace std;
int a,b,c,k,s;
int main()
{
    cin>>a>>b>>c>>k;
    s=0;
    s+=min(a,k);
    if(k>=a)
    {
        k-=a;
        if(k>=b)
        {
            k-=b;
            s-=k;
        }
    }
    cout<<s;


    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    ll n, m, k, a, b, left, right;
    ll sum_a[200005], sum_b[200005];
    sum_a[0] = 0, sum_b[0] = 0;
    cin >> n >> m >> k;

    for(ll i = 0; i < n; i++) {
        cin >> a;
        sum_a[i + 1] = sum_a[i] + a;
    }
    for(ll i = 0; i < m; i++) {
        cin >> b;
        sum_b[i + 1] = sum_b[i] + b;
    }

    left = 0, right = n + m;
    while(left < right) {
        ll mid = (left + right) / 2 + 1;
        bool flag = false;
        for(int i = 0; i <= mid; i++) {
            if(i <= n && mid - i <= m && sum_a[i] + sum_b[mid - i] <= k) {
                flag = true;
                break;
            }
        }
        if(flag) {
            left = mid;
        } else {
            right = mid - 1;
        }
    }

    cout << left << endl;

    return 0;
}

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

int main(){
  ll a,b; cin >> a>>b;
  ll g; g = __gcd(a,b);
  ll ans = 1;
  for(ll i = 2; i*i<=g; i++){
    if(g%i == 0){ ans++;
      while(g%i == 0){
        g = g/i;
      }
    }

  }if(g>1){ans++;}
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = (int)1.01e9;

ll f(string s) {
    stringstream ss;
    ss << s;
    ll x;
    ss >> x;
    ll y = 0;
    while (x) {
        y += x % 10;
        x /= 10;
    }
    return y;
}

int main() {
#ifdef HOME
    freopen("in", "r", stdin);
#endif

    string s = "";
    while (cin >> s) {
        ll ans = 0;
        ans = f(s);

        for (int i = (int)s.length() - 1; i >= 0; i--) {
            if (s[i] >= '1') {
                s[i]--;
                for (int j = i + 1; j < (int)s.length(); j++) s[j] = '9';
                ans = max(ans, f(s));
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 764
#include <iostream>
using namespace std;
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b && a!=c){
    cout<<"Yes";
    return 0;
  }
  if(a==c && a!=b){
    cout<<"Yes";
    return 0;
  }
  if(b==c && b!=a){
    cout<<"Yes";
    return 0;
  }
  cout<<"No";
}

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

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 K = 0;
	SINT32 ANS = 0;
	SINT32 Gcount0 = 0;
	SINT32 Gcount1 = 0;
	SINT32 Kcount0 = 0;
	SINT32 Kcount1 = 0;

	SINT8 S[1000000];
	for (SINT32 i = 0; i < 1000000; i++) {
		S[i] = 'A';
	}

	cin >> S;

	for (SINT32 i = 0; i < 1000000; i++) {

		if (S[i] == '0') {

		} else if (S[i] == '1') {

		} else {
			break;
		}

		if ((i % 2) == 0) {
			if ((S[i]) == '1') {
				Gcount1++;
			} else {
				Gcount0++;
			}

		} else {
		if ((S[i]) == '1') {
			Kcount1++;
		} else {
			Kcount0++;
		}
		}

	}

	ANS = MIN(Kcount1+Gcount0,Kcount0+Gcount1);




	cout << ANS << endl;
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

Measured memory_bytes: 1280
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
int a,b;
int main()
{
	scanf("%d%d",&a,&b);
	if(a<b)
		printf("0\n");
	else
		printf("10\n");
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int t1,t2;
int main(){
	cin>>s;
	int ls=s.size();
	for(int i=0;i<ls;i++)
	{
		if(s[i]=='g')t1++;
		if(s[i]=='p')t2++;
	}
	int b=ls/2;
	if(b>=t2)
	{
		cout<<b-t2;
	}
	else
	{
		cout<<t2-b;
	}
	return 0;
} 

Measured memory_bytes: 512
from functools import reduce

N = int(input())
A = [int(s) for s in input().split()]

def calc(a, b):
    while True:
        if a > b:
            b, a = a, b
        b = b % a
        if b == 0:
            return a

def main():
    ans = reduce(calc, A)    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14596
#include <stdio.h>

int main() {
	int a, b;

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

	if( (a + b) % 2 == 1 ) {
		printf("IMPOSSIBLE\n");
	} else {
		printf("%d\n", (a + b) / 2);
	}

	return 0;
}

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

int main() {
	int N = 0;
	cin >> N;
	vector<int> a(N);
	rep(i, N) {
		cin >> a.at(i);
	}
	int M = 0;
	cin >> M;
	vector<vector<int>> m(2, vector<int>(M));
	rep(i, M) {
		rep(j, 2) {
			cin >> m.at(j).at(i);
		}
	}
	int re = 0;
	rep(i, M) {
		rep(j, N) {
			re = re + a.at(j);
		}
		cout << re - a.at(m.at(0).at(i)-1) + m.at(1).at(i) << endl;
		re = 0;
	}
	return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[101][101];
bool yoko[101],tate[101];
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>h>>w;
      rep(i,h){
        rep(j,w){
          cin>>s[i][j];
          if(s[i][j]=='#'){
            yoko[i]=true;
            tate[j]=true;
          }
        }
      }
      rep(i,h){
        if(!yoko[i])continue;
        rep(j,w){
          if(tate[j])cout<<s[i][j];
        }
        cout<<"\n";
      }
     

       
return 0;
}


Measured memory_bytes: 256
#ifndef bhartiya
    // #pragma GCC optimize("Ofast")
    // #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

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

typedef long long ll;
typedef pair<ll, ll> pll;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#ifdef bhartiya
#define endl '\n'
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define pb push_back
#define bitc  __builtin_popcountl
#define mp make_pair
#define ff first
#define ss second

#define swap(a,b) {a=a^b;b=a^b;a=a^b;}
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define inf 200000000000000ll
// #define inf 10000000000ll
#define mod 1000000007ll
// #define mod 998244353ll
#define eps 1e-7

ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 100005;
ll dp[105][maxn];
bool vis[105][maxn];
ll v[maxn];
ll we[maxn];


void recur(ll i, ll w){
    if(i<0) return;
    else if(w == 0) return;
    if(vis[i][w]) return;
    vis[i][w] = true;
    ll a=0,b=0;
    recur(i-1,w);
    b = i>0?dp[i-1][w]:0;
    if(we[i] <= w){
        recur(i-1,w-we[i]);
        a = i>0?dp[i-1][w-we[i]] + v[i]:v[i];
    }
    dp[i][w] = max(a,b);
}

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.precision(10);
    // cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t = 1;
    // cin>>t;
    while(t--){
        ll n,w;
        cin>>n>>w;
        rep(i,n){
            cin>>we[i]>>v[i];
        }
        recur(n-1,w);
        cout<<dp[n-1][w];
    }
}

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

void work()
{
    int n, m;
    cin >>n >> m;
    int X, Y;
    cin >>X >>Y;
    for(int i = 0; i < n; i++)
    {
        int t; cin >> t;
        X = max(X, t);
    }
    for(int i = 0; i < m; i++)
    {
        int t; cin >> t;
        Y = min(Y, t);
    }

    if(X < Y)
    {
        cout <<"No ";
    }
    cout <<"War" <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
    work();
    return 0;
}


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

using namespace std;
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(vr) vr.begin(),vr.end()
const int N=3e5+10;

int n,m,ans[N],bit[N],ps[N];
vector<pii> Q[N];
vector<int> inter[N];

void add(int v,int x)
{
    for (int i=v;i<=m;i+=(i&-i)) bit[i]+=x;
}

int get(int v)
{
    int res=0;
    for (int i=v;i;i-=(i&-i)) res+=bit[i];
    return res;
}

void read()
{
    cin>>n>>m;
    for (int i=1,l,r;i<=n;i++) cin>>l>>r,inter[l].pb(r),add(r,1);
}

void process()
{
    for (int i=m;i;i--) ps[i]=ps[i+1]+inter[i].size();
    for (int i=1;i<=m;i++)
        for (int j=i;j<=m;j+=i) Q[j-i+1].pb(mp(j,i));
    for (int i=1;i<=m;i++)
    {
        for (pii x : Q[i])
            ans[x.se]+=get(m)-get(x.fi-1)-ps[x.fi+1];
        for (int x : inter[i]) add(x,-1);
    }
    for (int i=1;i<=m;i++) cout<<ans[i]<<"\n";
}

int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    read();
    process();
    return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            // 1行はコスト1だから先に
            if (N == 1)
            {
                Console.WriteLine(1);
                return;
            }

            var a = new int[N];
            var b = new int[N];
            var x = new string[N];
            for (var i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine().Split().Select(int.Parse).ToArray();
                a[i] = tmp[0];
                b[i] = tmp[1];
                x[i] = ($"{a[i]} {b[i]}");
            }

            var pred = new Dictionary<string, int>();
            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    if (i != j)
                    {
                        if (pred.ContainsKey($"{a[i] - a[j]} {b[i] - b[j]}"))
                            pred[$"{a[i] - a[j]} {b[i] - b[j]}"]++;
                        else
                            pred[$"{a[i] - a[j]} {b[i] - b[j]}"] = 1;
                    }
                }
            }

            var predict = "";
            var max = 0;
            foreach (var d in pred)
            {
                if (d.Value > max)
                {
                    max = d.Value;
                    predict = d.Key;
                }
            }

            var tmp2 = predict.Split();
            var A = int.Parse(tmp2[0]);
            var B = int.Parse(tmp2[1]);

            var min = int.MaxValue;
            var count = 0;
            for (var i = 0; i < N; i++)
            {
                if (!x.Contains($"{a[i] - A} {b[i] - B}"))
                {
                    count++;
                }
            }

            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 13536
#include <algorithm>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <vector>
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  int sum = 0;
  double p = 0;
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
    p += v.at(i);
    sum += v.at(i) * v.at(i);
  }

  int p1 = round(p / n);
  p /= 1;

  sum += n * p1 * p1;
  sum += -2 * p1 * p;

  cout << sum;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        int idx = -1;
        for (int i = 0; i < ss.length(); i++) {
            int c = 0;
            for (int j = 0; j < t.length(); j++) {
                if (i + j < ss.length() && (ss.charAt(i + j) == '?' || ss.charAt(i + j) == t.charAt(j))) {
                    c++;
                }
            }
            if (c == t.length()) idx = i;
        }
        if (idx == -1) {
            System.out.println("UNRESTORABLE");
            return;
        }
        char[] s = ss.toCharArray();
        for (int i = idx, j = 0; i < ss.length() && j < t.length(); i++, j++) {
            s[i] = t.charAt(j);
        }
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '?') s[i] = 'a';
        }
        System.out.println(new String(s));
    }
}


Measured memory_bytes: 23124
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
int n,Fa[1005],Limit[1005],dp[1005];
bool pack[5005],tmp[5005];
vector<int> vec[1005];
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		scanf("%d",&Fa[i]);
		vec[Fa[i]].push_back(i);
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&Limit[i]);
	}
	for(int i=n;i>=1;i--)
	{
		memset(pack,false,sizeof(pack));
		pack[0]=true;
		int sum=0;
		for(auto x : vec[i])
		{
			sum+=Limit[x]+dp[x];
			for(int j=0;j<=Limit[i];j++)
			{
				tmp[j]=pack[j];
			}
			for(int j=Limit[i];j>=0;j--)
			{
				pack[j]=false;
				if(j>=Limit[x]) pack[j]|=tmp[j-Limit[x]];
				if(j>=dp[x]) pack[j]|=tmp[j-dp[x]];
			}
		}
		bool possible=false;
		for(int j=Limit[i];j>=0;j--)
		{
			if(pack[j])
			{
				possible=true;
				dp[i]=sum-j;
				break;
			}
		}
		if(!possible)
		{
			printf("IMPOSSIBLE\n");
			return 0;
		}
	}
	printf("POSSIBLE\n");
}

Measured memory_bytes: 3180
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _List{
	struct _List *prev,*next;
	long x;
}List;

List *head,*tail;
int flag=0;

void set();
void output();
List *generate(long);
void insertFirst(long);
void insertLast(long);
void delete(long);
void deleteFirst();
void deleteLast();
void deleteAll();

int main(void){
	int i,j=0;
	int n;
	long x;
	char op[15];

	set();
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s",op);
		if(strcmp(op,"insert")==0){
			scanf("%ld",&x);
			insertFirst(x);
		}else if(strcmp(op,"delete")==0){
			scanf("%ld",&x);
			delete(x);
		}else if(strcmp(op,"deleteFirst")==0) deleteFirst();
		else if(strcmp(op,"deleteLast")==0) deleteLast();
	}

	output();
return 0;
}
void set(){
List *l;
l = generate(-1);
head = l;
tail = l;
return;
}
void output(){
	List *tmp;
	//List tmp = (List *)malloc(sizeof(List));
	if(flag == 0){
		return;
	}
	tmp = head;
	while(tmp != NULL){
		printf("%ld",tmp->x);
		if(tmp->next == NULL/*|| tmp->next->next == NULL*/) break;
		printf(" ");
		tmp = tmp->next;
	}
	printf("\n");
return;
}

List *generate(long x){
	List *p;
	p = (List *)malloc(sizeof(List));
	p->prev = NULL;
	p->next = NULL;
	p->x = x;
	return p;
}

void insertFirst(long x){
	List *p;
	p = generate(x);
	//first contents
	if(flag==0){
		tail = p;
		flag = 1;
	}else{
		head->prev = p;
		p->next = head;
	}
	head = p;
	return;
}
void insertLast(long x){
	List *p,*tmp;
	p = generate(x);
	//first contents
	if(flag==0){
		head = p;
		flag = 1;
	}else{
		p->prev = tail;
		tail->next = p;
	}
	tail = p;
	return;
}
void delete(long x){
	List *p;
	//List tmp = (List *)malloc(sizeof(List));
	if(flag == 0){
		return;
	}
	if(head->x ==x){
		deleteFirst(x);
		return;
	}
	p = head;
	while(p->x != x){
		if(p->next == NULL){
			return;
		}
		p = p->next;
	}
	if(p->next == NULL){
		deleteLast(x);
		return;
	}
	List *prev;
	prev = p->prev;
	List *next;
	next = p->next;
	free(p);
	prev->next = next;
	next->prev = prev;
return;
}
void deleteFirst(){
	if(flag==0) return;
	List *next = head->next;
	if(next == NULL){
		flag = 0;
		set();
	}else{
	next->prev = NULL;
	free(head);
	head = next;
	}
return;
}
void deleteLast(){
	if(flag==0) return;
	List *prev = tail->prev;
	if(prev == NULL){
		flag = 0;
		set();	
	}else{
		prev->next=NULL;
		free(tail);
		tail = prev;
	}
return;
}
void deleteAll(){
	List *tmp,*next;
	//List tmp = (List *)malloc(sizeof(List));
	if(flag == 0){
		return;
	}
	tmp = head;
	next = tmp->next;
	while(next != NULL){
		free(tmp);
		next = next->next;
		tmp = next;
	}
	set();
	flag = 0;
return;
}

Measured memory_bytes: 63104
N = int(input())
SP = []

for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    SP.append((s, p, i))

SP.sort(key=lambda x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])

for sp in SP:
    print(sp[2])


Measured memory_bytes: 3060
l = [int(input()) for i in range(5)]
l2 = []
cnt = 0
cnt2 = 0
for i in range(5):
    res = l[i] - (l[i]//10)*10
    if res == 0:
        cnt += l[i]
        flag = True
    else:
        cnt += (l[i]//10)*10
        l2.append(res)
        cnt2 += 1

if l2 == []:
    l2.append(0)
if cnt2 >= 1:
    cnt2-= 1

print(cnt+min(l2)+cnt2*10)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int64_t A, B, C;
    cin >> A >> B >> C;
    if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
        cout << 0 << endl;
        return 0;
    }
    if (A == max({A, B, C})){
        cout << B * C << endl;
    }
    else if (B == max({A, B, C})){
        cout << A * C << endl;
    }
    else if (C == max({A, B, C})){
        cout << B * A << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

ll floor2(ll num){
    ll ret = 1LL;
    while(ret <= num){
        ret *= 2;
    }
    ret /= 2;

    return ret;
}

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

    ll a, b; cin >> a >> b;
    if(a == b){
        cout << 1 << endl;
        return 0;
    }

    ll floorb = floor2(b);
    ll floora = floor2(a);
    while(floorb == floora){
        b &= ~floorb;
        a &= ~floora;
        floorb = floor2(b);
        floora = floor2(a);
    }

    if(floorb != b){
        bool f = false;
        for(ll i = floorb / 2; i >= 1LL; i /= 2){
            if(b & i){
                f = true;
            }
            if(f){
                b |= i;
            }
        }
    }

    ll res = b - a + 1;
    if(floorb <= a){
        cout << res << endl;
        return 0;
    }

    ll unum = b - floorb + 1;
    ll lnum = floorb - a;
    ll diff = lnum;

    if(unum + lnum > floorb){
        diff = diff - (unum + lnum - floorb);
    }
    res += diff;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
 
 
public class Main 
{
 
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		HashSet<Integer> A = new HashSet<Integer>();
 
		for(int i=0;i<N;i++)
		{
			int a_i=sc.nextInt();					
			if(!A.contains(a_i))
			{
				A.add(a_i);
			}
			else
			{
				A.remove(a_i);
			}
		}
		sc.close();
		
		System.out.println(A.size());

	}
}

Measured memory_bytes: 61344
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>


using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll, ll> pll;
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };

#define ARRAY_MAX 100005

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

bool dp[ARRAY_MAX];

int main() {

	int n, k;
	cin >> n >> k;
	vector<int> a(n);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	dp[0] = false;

	for (int i = 0; i <= k; i++)
	{
		//石の個数がi個の時
		for (int j = 0; j < n; j++)
		{
			//遷移できるマスについては論理和を取る
			//どこかのtrueから遷移できるならtrueにできる
			if (i + a[j] <= k) {
				dp[i + a[j]] |= !dp[i];
			}
		}
	}
	if (dp[k] == true)
	{
		cout << "First" << endl;
	}
	else {
		cout << "Second" << endl;
	}

	return 0;
}

Measured memory_bytes: 384
n,m = map(int,input().split())                                                  
a = list(map(int,input().split()))
s = sum(a)
flag = 1 
 
a.sort(reverse=True)
 
for i in range(0,m):
    if a[i] < s/(4*m):
        flag = 0 
        break
 
if flag == 1:
    print("Yes")
else:
    print("No")
 

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

using namespace std;

int main(){
  string b;
  string pair("initial");
    
  cin >> b;
  
  if (b == "A"){
  	pair = "T";
  }else if (b == "T"){
  	pair = "A";
  }else if (b == "C"){
  	pair = "G";
  }else if (b == "G"){
  	pair = "C";
  }
  cout << pair << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    
    if(A != 1 && B != 1) cout << 1 << endl;
    else if (A != 2 && B != 2) cout << 2 << endl;
    else cout << 3 << endl;
}


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

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	if(n < x){
		cout << t;
		return 0;
	}
	int c = (int)((n * 1.0)/x + 0.5);
	cout << t * c;
	return 0;
};


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b, c;
  while (cin >> a >> b >> c) {
    bool used[10] = {};
    used[a - 1] = used[b - 1] = used[c - 1] = true;
    int cnt = 0;
    for (int i = 0; i < 10; i++) {
      cnt += (!used[i] && a + b + i + 1 <= 20);
    }
    cout << (cnt * 2 >= 7 ? "YES" : "NO") << endl;
  }

  return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int r;
    scanInt(r);
    printInt(r*r); 
    return 0;
}

Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

bool C(string a,string b,string ans,int x){
	bool f=false;
	string aa,bb,ss;
	for(int i=0;i<a.size();i++){
		if(a[i]>='1' && a[i]<='9')f=true,aa+=a[i];
		if(a[i]=='0' && f)aa+=a[i];
		if(a[i]=='X'){
			if(f ||(x>0))aa+=x+'0',f=true;
		}
	}
	f=false;
	for(int i=0;i<b.size();i++){
		if(b[i]>='1' && b[i]<='9')f=true,bb+=b[i];
		if(b[i]=='0' && f)bb+=b[i];
		if(b[i]=='X'){
			if(f ||(x>0))bb+=x+'0',f=true;
		}
	}
	f=false;
	for(int i=0;i<ans.size();i++){
		if(ans[i]>='1' && ans[i]<='9')f=true,ss+=ans[i];
		if(ans[i]=='0' && f)ss+=ans[i];
		if(ans[i]=='X'){
			if(f ||(x>0))ss+=x+'0',f=true;
		}
	}
	if(aa.size()==0)aa+='0';
	if(bb.size()==0)bb+='0';
	if(ss.size()==0)ss+='0';
	if(a.size()!=aa.size())return false;
	if(b.size()!=bb.size())return false;
	if(ans.size()!=ss.size())return false;
	reverse(aa.begin(),aa.end());
	reverse(bb.begin(),bb.end());
	string res;
        int c=0;
        for(int j=0;j<max(aa.size(),bb.size());j++){
            string d;
            int e;
            e=c;
            if(aa.size()>j)e+=aa[j]-'0';
            if(bb.size()>j)e+=bb[j]-'0';
            c=0;
            if(e>=10)c=1,e-=10;
            d=e+'0';
            res+=d;
        }
        if(c==1)res+=c+'0';
	if(res.size()==0)res+='0';
	if(ss.size()==0)ss+='0';
	reverse(res.begin(),res.end());
	//cout << res << " " << ss << endl;
	if(res==ss)return true;
	return false;
}

int main(void){
	string str;
	while(cin >> str){
		string a,b,ans;
		int i=0;
		while(str[i]!='+'){
			a+=str[i];
			i++;
		}
		i++;
		while(str[i]!='='){
			b+=str[i];
			i++;
		}
		i++;
		while(i!=str.size()){
			ans+=str[i];
			i++;
		}
		bool f=false;
		for(i=0;i<10;i++){
			if(C(a,b,ans,i)){
				cout << i << endl;
				f=true;
				break;
			}
		}
		if(!f)cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1200
N,Y=map(int,input().split())
#10000:i 5000:j 1000:k
i2 = -1
j2 = -1
k2 = -1
for i in range(N+1):
    for j in range(N+1-i):
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k == Y:
            i2 = i
            j2 = j
            k2 = k
            break
print(i2,j2,k2)

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

using namespace std;

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

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N; cin >> N;
    string X; cin >> X;
    int D; cin >> D;
    vector<bool> changed(N, false);
    REP(i, N) {
        if (X[i] == '0' && D > 0) {
            changed[i] = true;
            X[i] = '1';
            --D;
        }
    }
    RREP(i, N) {
        if (!changed[i] && D > 0) {
            changed[i] = true;
            X[i] = X[i] == '0' ? '1' : '0';
            --D;
        }
    }
    cout << X << endl;
}

Measured memory_bytes: 3228
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[a[i]-1]-1 == i) ans++;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/python
# -*- Coding: utf-8 -*-
n,m = map(int,input().split())

H = [[0 for _ in range(n)] for _ in range(n) ]

edge_list = []

for _ in range(m):
    a, b = map(int,input().split())
    edge_list.append([a-1,b-1])
    H[a-1][b-1] = 1
    H[b-1][a-1] = 1
    
l = [0 for _ in range(n)]
ans = 0
l[0] = 1

def dfs(node,x):
    global ans
    if x.count(0) == 0:
        ans += 1 
        return 0


    else:
        visited = x
        visited[node] = 1
        for node_,edge_ in enumerate(H[node]):
            if edge_ == 1 and visited[node_] != 1:
                visited[node_] = 1
                visited[node] = 1
                dfs(node_,visited)
                visited[node_] = 0
                #頂点iをここで未訪問にすることが一番重要！！！！！



dfs(0,l)
print(ans)


Measured memory_bytes: 3064
# import numpy as np
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))


def binary_search(A, key):
    n = len(A)
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            return True
        elif key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return False


count = 0
for i in range(q):
    key = T[i]
    # binary search
    if binary_search(S, key):
        count += 1
print(count)






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

using namespace std;

int main()
{
    int X,Y;
    cin>>X>>Y;
    if(2*X>Y){
        cout<<"No"<<endl;
        exit(0);
    }
    string ans="No";
    for(int i=0;i<=X;i++){
        for(int j=0;j<=X-i;j++){
            if(2*i+4*j==Y){
                ans="Yes";
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    final long x = sc.nextLong();
    long l = 100;
    for(int i=0;;i++){
      if(l >= x){
        System.out.println(i);
        break;
      }
      l += l / 100;
    }
  }
}

Measured memory_bytes: 27044
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Globalization;
using static System.Console;
using static System.Math;

namespace abc84_c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[,] dis = new int[n,3];
            for(int i=0; i<n-1; i++){
                int[] input = ReadLine().Split().Select(int.Parse).ToArray();
                dis[i,0] = input[0];
                dis[i,1] = input[1];
                dis[i,2] = input[2];
            }

            for(int i=0; i<n-1; i++){
                int time=0;
                time += dis[i,0] + dis[i,1];

                for(int j=i+1; j<n-1; j++){
                    if(time < dis[j,1]) time = dis[j,1];
                    else if (time % dis[j,2] == 0);
                    else time += dis[j,2]-(time%dis[j,2]);
                    time += dis[j,0];
                }
                WriteLine(time);
            }
            //n番目の駅
            WriteLine(0);


            //Write();
            //WriteLine();
            //WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);
            //WriteLine($"答えは{input[0]+input[1]}");
        }

        /// 値のスワップ
        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }


    }
}

Measured memory_bytes: 13396
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            if (S.Length <= K)Console.WriteLine(S);
            else Console.WriteLine(S.Substring(0,K)+"...");
        }
    }
}


Measured memory_bytes: 27396
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf.trim().to_string()
}

fn main() {
    read();
    let w: Vec<i32> = read()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();

    let mut s = 0;
    let mut t = w.iter().sum();
    let mut r = t;

    for &e in w.iter() {
        s += e;
        t -= e;
        let d = ((s - t) as i32).abs();
        if d <= r {
            r = d;
        } else {
            break;
        }
    }

    println!("{}", r);
}


Measured memory_bytes: 4352
#include<iostream>

int main(){

    int a, b, c;
    std::cin >> a >> b >> c;

    int cnt = 0;
    for(int i = a; i <= b; ++i){
        if(c % i == 0){
            cnt++;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 3100