akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <stdio.h>


using namespace std;

int main(int argc, char *argv[]){
  int Amax, Bmin;
  int tmpA, tmpB;

  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> tmpA >> tmpB;
    if(tmpA > Amax){
      Amax = tmpA;
      Bmin = tmpB;
    }
  }

  cout << Amax + Bmin << endl;;


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int main(){
    string s;cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
}


Measured memory_bytes: 3576
# -*- coding: utf-8 -*-
import collections

#
N = int(input())
edges = []
graph = [[] for _ in range(N)]
color = [{} for _ in range(N)]
for _ in range(N-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    graph[a].append(b)
    graph[b].append(a)

    color[a][b] = -1
    color[b][a] = -1

    edges.append((a, b))

#
buf = collections.deque()
buf.append(0)

while buf:
    src = buf.popleft()
    used = [color[src][dst] for dst in graph[src]
                if color[src][dst] != -1]
    dst_color = 1
    while dst_color in used:
        dst_color += 1

    for dst in graph[src]:
        if color[src][dst] == -1:
            color[src][dst] = dst_color
            color[dst][src] = dst_color
            buf.append(dst)

            used.append(dst_color)
            while dst_color in used:
                dst_color += 1



#
print(max([max(c.values()) for c in color]))
for a,b in edges:
    print(color[a][b])




Measured memory_bytes: 128364
nn = int(input())
aa = list(map(int, input().split()))
bb = [0]*(nn-1)
mysum = sum(aa) % (10**9 + 7)
mydiff = 0

for i in range(1,nn):
    mydiff += aa[i - 1]
    tete = mysum - mydiff
    if tete >= 0:
        bb[i-1] = tete
    else:
        bb[i-1] = tete + 10**9+7

finalsum = 0
for i in range(nn-1):
        finalsum += aa[i]*bb[i]
        finalsum = finalsum % (10**9 + 7)

print(finalsum)

Measured memory_bytes: 93912
#include <iostream>
#include <string>
using namespace std;
int N,check[330000],Sum,Min=999999,arr;
string ar;
int main()
{
	cin>>N>>ar;
	for(int x=0; x<N; x++)
	{
		check[x]+=Sum;
		if(ar[x]=='W')Sum++;
	}
	Sum=0;
	for(int x=N-1; x>-1; x--)
	{
		check[x]+=Sum;
		if(ar[x]=='E') Sum++;
	}
	for(int x=N-1; x>-1; x--)
	{
		if(Min>check[x])
		{
			Min=check[x];
		}
	}
	cout<<Min;
	
}

Measured memory_bytes: 1796
#include<stdio.h>
int main (){
	char str[19];
	scanf("%s", str);
	for(int i = 0; i < 19 ; i++){
		if(str[i] == ','){
			printf(" ");
		}
		else{
			printf("%c", str[i]);	
		}
	}

	return 0;
}

Measured memory_bytes: 1640
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [-1] * N
for x in range(N):
    if x == 0:
        dp[0] = 0
    elif x == 1:
        dp[1] = abs(h[1] - h[0])
    else:
        sub = min(K, x)
        MinDP = 10**9
        for y in range(1, sub + 1, 1):
            tmpDP = abs(h[x] - h[x - y]) + dp[x - y]
            if MinDP > tmpDP:
                MinDP = tmpDP
        dp[x] = MinDP
print(dp[N - 1])


Measured memory_bytes: 52448
H, W = map(int, input().split())

if H%3 == 0 or W%3 == 0:
    print(0)
    exit()
    
def solve(a, b):
    ans = 10**15
    for i in range(1, a+1):
        s1 = i * b
        s2 = (a-i) * (b//2)
        s3 = a*b - s1 - s2
        s4 = ((a-i)//2) * b
        s5 = a*b - s1 - s4
        list1 = sorted([s1, s2, s3])
        list2 = sorted([s1, s4, s5])
        s = min((list1[-1] - list1[0]), (list2[-1] - list2[0]))
        if ans > s:
            ans = s
    return ans

print(min(solve(H, W), solve(W, H)))


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
const int MAX = 1000000;

int main(){
	bool b[MAX] = {true};
	static int a[MAX] = {0,0};
	int n;
	for(int i = 2;i < MAX;i++){
		if(!b[i]){
			for(int j = 2;i*j < MAX;j++){
				b[i*j] = true;
			}
		}
		a[i] = a[i-1] + !b[i];
	}
	while(cin >> n){
		cout << a[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 7976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll INF = 1e9;
    double start_temp = 3000, end_temp = 0;
    ll turn = 900000;
    for (i = 0; i < turn; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        double temp = start_temp + (end_temp - start_temp) * i / turn;
        double prob = exp(ma / temp);
        if (prob > (rand() % INF) / (double)INF){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N,K;
  cin >> N >> K;
  if(K==1) {
    cout << 0 << endl;
  } else {
    cout << N-K <<endl;
  }
  return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	while (cin >> n) {
		vector<int> a(n * 3);
		for (int &x : a) {
			cin >> x;
			x--;
		}
		vector<vector<int>> dp(n, vector<int>(n, -1e9));
		vector<int> mid(n, -1e9);
		dp[a[0]][a[1]] = dp[a[1]][a[0]] = 0;
		mid[a[0]] = mid[a[1]] = 0;
		int ans = 0, add = 0;
		for (int i = 2; i + 2 < n * 3; i += 3) {
			vector<int> b = {a[i], a[i + 1], a[i + 2]};
			sort(b.begin(), b.end());
			if (b[0] == b[2]) {
				add++;
				continue;
			}
			vector<tuple<int, int, int>> v;
			if (b[0] == b[1]) {
				for (int j = 0; j < n; j++) {
					v.emplace_back(j, b[2], dp[b[0]][j] + 1);
				}
			} else if (b[1] == b[2]) {
				for (int j = 0; j < n; j++) {
					v.emplace_back(j, b[0], dp[b[2]][j] + 1);
				}
			}
			v.emplace_back(b[0], b[1], max(ans, dp[b[2]][b[2]] + 1));
			v.emplace_back(b[0], b[2], max(ans, dp[b[1]][b[1]] + 1));
			v.emplace_back(b[1], b[2], max(ans, dp[b[0]][b[0]] + 1));
			for (int j = 0; j < n; j++) {
				for (int k = 0; k < 3; k++) {
					v.emplace_back(j, b[k], mid[j]);
				}
			}
			for (auto &[x, y, z] : v) {
				dp[x][y] = max(dp[x][y], z);
				dp[y][x] = max(dp[y][x], z);
				mid[x] = max(mid[x], z);
				mid[y] = max(mid[y], z);
				ans = max(ans, z);
			}
		}
		ans = max(ans, dp[a.back()][a.back()] + 1);
		cout << ans + add << '\n';
	}
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    
    if (s[0] == 'R' && s[1] ==  'R' && s[2] == 'R') {
        cout << 3 << endl;
        return 0;
    }
    rep(i,s.size()-1) {
        if (s[i] == 'R' && s[i+1] == 'R') {
            cout << 2 << endl;
            return 0;
        }
    }
    rep(i,s.size()) 
    if (s[i] == 'R') {
        cout << 1 << endl;
        return 0;
    }
    cout << 0 << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong N, K;
	cin >> N >> K;
	vector<P> ans;
	llong sum = (N-1)*(N-2)/2;
	cerr << sum << endl;
	for (int i = 1; i < N; ++i)
		ans.push_back(P(i, N));

	for (int i = 1; i < N; ++i) {
		for (int j = i+1; j < N; ++j) {
			if (sum == K) {
				i = j = N;
				break;
			}
			ans.push_back(P(i, j));
			--sum;
		}
	}

	cerr << sum << endl;
	if (sum == K) {
		cout << ans.size() << endl;
		for (auto ret : ans)
			cout << ret.first << " " << ret.second << endl;
	} else {
		cout << -1 << endl;
	}

	return 0;
}


Measured memory_bytes: 512
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "x", long, "y");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    long a, b, c;
    scan(a, b, c);
    long l = 4 * a * b;
    long r = (c - (a + b)) ^^ 2;
    if(l < r && (a + b) < c)
        writeln("Yes");
    else
        writeln("No"); 
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << (X - Z) / (Y + Z) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int maxn = 2e5 + 7;

int ans = 0;
map<int, int> cnt;
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    string s;
    cin >> s;
    int val = 0, cc = 1;
    cnt[0] = 1;
    for(int i = s.length() - 1; i >= 0; i--)
    {
        cc = cc * 10 % 2019;
        val = (val + cc * (s[i] - '0')) % 2019;
        ans += cnt[val];
        cnt[val]++;
    }
    cout << ans;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, k, a, s = 0;
    cin >> n >> k;
    map<int, int> cnt;
    map<int, int> used;
    vector<int> s1(n);
    vector<int> s2(n);
    for (int i = 0; i < n; i++){
        cin >> a;
        s1[i] = a;
        cnt[a]++;
    }
    for (int i = 0; i < n; i++){
        if (used[s1[i]] < 1){
            s2[i] = cnt[s1[i]];
            used[s1[i]]++;
        }
    }
    sort(s2.begin(), s2.end());
    for (int i = 0; i < s2.size() - k; i++){
        s = s + s2[i];
    }
    cout << s << endl;
}

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

signed main(){
    constexpr int mod=1e9+7;
    int N;cin>>N;
    char c[4]={'A','G','C','T'};
    vector<map<string,int>> memo(N+1);
    auto dfs=[&](auto &&f,int i,string last4)->int{
        if(last4.substr(0,2)=="AG"&&last4[3]=='C') return 0LL;
        if(last4.substr(2,2)=="GC"&&last4[0]=='A') return 0LL;
        string t=last4.substr(1,3);
        if(t=="AGC"||t=="ACG"||t=="GAC") return 0LL;
        if(i==N) return 1LL;
        if(memo[i][last4]>0) return memo[i][last4];
        int res=0;
        REP(j,4){
            res+=f(f,i+1,t+c[j]);
        }
        return memo[i][last4]=res%mod;
    };
    cout<<dfs(dfs,0,"DDDD")<<endl;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using ll=long long;
using namespace std;
const auto mod=1e9+7;

template <typename T>
using GPQ=priority_queue<T,vector<T>,greater<T>>;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int n,k,ans=0;
  cin >> n >> k;
  int h[n];
  rep(i,0,n){
  	cin >> h[i];
  	if(h[i]>=k) ans++;
  } 
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X = MAP()
L = LIST()

cnt = 1
D = 0
for i in range(N):
	D += L[i]
	if D <= X:
		cnt += 1
	else:
		print(cnt)
		break
else:
	print(cnt)


Measured memory_bytes: 5148
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
/*
int main() {
    // 前処理
    COMinit();

    // 計算例
    cout << COM(100000, 50000) << endl;
}*/

//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
    */
int main(){
    string S;
    cin >> S;
    ll s = S.size();
    rep(i,s){
        if(S[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
using namespace std;
using ll = long long;

const long double PI = acos(-1.0);
const int MOD = 1e9 + 7;

int main() {
    string t;
    cin >> t;
    int n = t.size();

    string ans = "";
    for(int i = 0; i < n; i++) {
        if(t[i] == '?') ans += 'D';
        else ans += t[i];
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3924
program abc37
 implicit none
 character(len=2*10**5)::T,S
 integer::c=0,L,i
 read(*,*)S
 read(*,*)T
 L=len_trim(S)
 do i=1,L
  if(S(i:i)/=T(i:i))then
   c=c+1
  end if
 end do
 print'(i0)',c
end program abc37

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

int main()
{
    ll N;
    cin >> N;
    map<ll,ll> mp;

    for(int i = 0; i < N; i++)
    {
        ll tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    for(auto e:mp)
    {
        if(e.second > 1)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 12800
#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(digit) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K;
  cin >> N;
  cin >> K;
  vi A(N);
  rep(i, N) {
    cin >> A[i];
    A[i]--;
  }

  vi seen(N);
  vi step(N, -1);
  step[0] = 0;
  seen[0] = 1;
  ll loop_num = 0;
  ll loop_start_pos = 0;
  ll until_loop = 0;

  rep(i, N + 10) {
    int next_pos = A[step[i]];
    if (seen[next_pos] == 1) {
      loop_start_pos = next_pos;
      break;
    } else {
      seen[next_pos] = 1;
      step[i + 1] = next_pos;
    }
  }

  int current_pos = loop_start_pos;
  rep(i, N + 10) {
    int next_pos = A[current_pos];
    if (next_pos == loop_start_pos) {
      loop_num = i + 1;
      break;
    }
    current_pos = next_pos;
  }

  current_pos = 0;
  rep(i, N + 10) {
    int next_pos = A[current_pos];
    if (next_pos == loop_start_pos) {
      until_loop = i + 1;
      break;
    }
    current_pos = next_pos;
  }

  // dump(step);
  // dump(seen);
  // dump(loop_start_pos);
  // dump(loop_num);
  // dump(until_loop);

  ll num=0;

  if(K<until_loop){
    num=K;
  }else{
    num = until_loop + (K - until_loop) % loop_num;
  }

  current_pos = 0;
  rep(i, num) { current_pos = A[current_pos]; }
  out(current_pos + 1);
  return 0;
}

Measured memory_bytes: 5580
//package Dynamic;
import java.io.*;
import java.util.*;
class Main
{
    static public void main(String[] args) throws IOException 
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int ar[]=new int[n];
      StringTokenizer st=new StringTokenizer(br.readLine());
//        int a=Integer.parseInt(st.nextToken());
//        int b=Integer.parseInt(st.nextToken());
//        int c=Integer.parseInt(st.nextToken());
        //int d=Integer.parseInt(st.nextToken());
       int i=0;
        while(st.hasMoreTokens())
        {
        	ar[i++]=Integer.parseInt(st.nextToken());
        }
        int c=0;
        for(int x=1;x<n-1;x++)
        {
        	int arr[]=new int[3];
        	arr[0]=ar[x];
        	arr[1]=ar[x-1];
        	arr[2]=ar[x+1];
        	Arrays.sort(arr);
        	if(arr[1]==ar[x])
        		c++;
        }
        System.out.println(c);
//        for(int x=0;x<n;x++)
//        {
//        	
//        }
        
        
    }
}


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

int N;
long long int D, A, X[200005], H[200005];

vector<pair<long long int, long long int> > V;

//set<pair<long long int, long long int> >S;
long long int INF = 9999999999999;

long long int S[200005];

vector<long long int> VEC;

int main(void) {

	cin >> N >> D >> A;

	for (int i = 1; i <= N; i++) {
		cin >> X[i] >> H[i];
		V.push_back(make_pair(X[i], H[i]));
		VEC.push_back(X[i]);
	}


	V.push_back(make_pair(-1, 987)); //dummy
	VEC.push_back(-1); //dummy

	sort(V.begin(), V.end());
	sort(VEC.begin(), VEC.end());

	long long int ans = 0;

	pair<long long int, long long int> P;
	for (int i = 1; i <= N; i++) {
		P = V[i];
		S[i] += S[i - 1];

		//cout << "i= " << i << " S[" << i << "]= " << S[i] << endl;
		P.second -= S[i]*A;

		if (P.second <= 0) { continue; }
		
		S[i] += (P.second + A - 1) / A;
		ans += (P.second + A - 1) / A;
		//cout << "ans= " << ans << endl;

		int I = upper_bound(VEC.begin(), VEC.end(), P.first + D * 2) - VEC.begin();

		S[I] -= (P.second + A - 1) / A;

	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12524
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
 
int main () {
	ll x;
	cin >> x;
	ll sum = 100;
	int count = 0;
	while(1) {
		sum = sum * 1.01;
		count++;
		if (sum >= x) {
			cout << count << endl;
			return 0;
		}
	}

}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    int i=1;
    int flag=0,ans=0;
    while(i<n){
        if(a[i-1]==a[i]){i++;}
        if(a[i-1]<a[i]){
            if(flag==0){flag=1;i++;}//増加
            else if(flag==1){i++;}
            else{ans++;i++;flag=0;}     
        }
        else if(a[i-1]>a[i]){
            if(flag==0){flag=-1;i++;}
            else if(flag==-1){i++;}
            else{ans++;i++;flag=0;}
        }
    }
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using pb = pair<double,double>;

signed main(){
	ll a,b; cin>>a>>b;
	ll c=(a+1)/2;
	if(c>=b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;

	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int ans = 0;
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				for(int k=j+1;k<N;k++){
					long a = A[i];
					long b = A[j];
					long c = A[k];
					if(a + b > c && b + c > a && c + a > b){
						if(a != b && b != c && c != a) ans++;
					}
				}
			}
		}
		Console.WriteLine(ans);
	}
	int N;
	long[] A;
	public Sol(){
		N = ri();
		A = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 27544
<?php
$n = trim(fgets(STDIN));
$A = explode(" ",trim(fgets(STDIN)));
echo implode(" ",$A)."\n";
for($i = 1; $i < $n; ++$i){
    $v = $A[$i];
    $j = $i - 1;
    while($j > -1 && $A[$j] > $v){
        $A[$j + 1] = $A[$j];
        $j--;
    }
    $A[$j + 1] = $v;
    echo implode(" ",$A)."\n";
}

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

int main(){
	int n,po;
	int score[10];
	string name[10];
	int d[]={3,0,1};
	int cou=0;
	while(1){
		cin >> n;
		if(n==0) break;
		if(cou != 0) cout << endl;
		for(int i=0;i<n;i++){
			cin >> name[i];
			score[i] = 0;
			for(int j=0;j<3;j++){
				cin >> po;
				score[i] += po * d[j];
			}
		}
		int top;
		for(int i=0;i<n;i++){
			top = 0;
			for(int j=1;j<n;j++){
				if(score[top]<score[j]){
					top = j;
				}
			}
			cout << name[top] << "," << score[top] << endl;
			score[top] = -1;
		}
		cou++;
	}
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll X, Y;
    cin >> X >> Y;

    if (X%Y == 0) {
        cout << -1 << endl;
    } else {
        cout << X << endl;
    }
    return 0;
}


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

K = int(input())

amari = set()
count = 1

r = 7%K

while r>0 and r not in amari:
  amari.add(r)
  r = (10*r+7)%K
  count += 1

if r==0:
  print(count)
else:
  print(-1)

Measured memory_bytes: 77884
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a * b, c);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a * b > c * d) {
		cout << a * b << endl;
	}
	else {
		cout << c * d << endl;

	}

	
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.*;
class Main
{ 
    public static void main(String[] args)throws IOException
    {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] s = br.readLine().split(" ");	
        int a = Integer.parseInt(s[0]);
        int b = Integer.parseInt(s[1]);
        if(a<=8 && b<=8)
            out.println("Yay!");
        else
            out.println(":(");
        out.flush();
    }
}

Measured memory_bytes: 21332
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <stack>
#include <vector>
#define ls (node << 1)
#define rs ((node << 1) | 1)
typedef long long ll;
using namespace std;
const int MAX = 2e5 + 20;
vector<int> pic[MAX];
int colo[MAX], tot_cal;
int n, m;
int p[MAX],val[MAX];
map<int,int> temm;
int findd(int x)
{
    return p[x] == x ? x : p[x] = findd(p[x]);
}
int read()
{
    int x = 0, flag = 1;
    char c = getchar();
    while ((c > '9' || c < '0') && c != '-')
        c = getchar();
    if (c == '-')
        flag = 0, c = getchar();
    while (c <= '9' && c >= '0')
    {
        x = (x << 3) + (x << 1) + c - '0';
        c = getchar();
    }
    return flag ? x : -x;
}
// void dfs(int u)
// {
//     if (tot_cal == 4)
//         return;
//     int tem[5] = {0, 0, 0, 0, 0};
//     for (auto v : pic[u])
//         tem[colo[v]]++;
//     for (int i = 1; i <= 4; i++)
//     {
//         if (tem[i] == 0)
//         {
//             colo[u] = i;
//             tot_cal = max(i, tot_cal);
//             break;
//         }
//     }
//     if (colo[u] == 0)
//         return;
//     for (auto v : pic[u])
//     {
//         if (colo[v] == 0)
//             dfs(v);
//     }
// }
int main()
{
    n = read();
    m = read();
    for (int i = 1; i <= n; i++)
        p[i] = i,val[i] = 1;
    for (int i = 1; i <= m; i++)
    {
        int x = read(), y = read();
        int xx = findd(x);
        int yy = findd(y);
        if (xx == yy)
            continue;
        p[xx] = yy;
        val[yy] += val[xx];
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = max(ans, val[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9356
n = gets.strip.to_i
as = gets.strip.split.map(&:to_i)

l = r = 0
xor = sum = as[0]
result=0

while r<n

  if xor==sum
    result += (r-l+1)
    break if r==n-1
    r += 1
    xor = xor^as[r]
    sum += as[r]
  else
    xor = xor^as[l]
    sum -= as[l]
    l += 1
  end
end

p result

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

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

    ll n; cin >> n;

    int i;
    for (i=1; i<=10; i++) {
        if (1000*i - n >= 0) break;
    }

    cout << 1000*i - n << endl;
       

    return 0;
}


Measured memory_bytes: 3636
s = list(input())

lens = len(s)
if lens == 1:
  print(1)
  exit()
  
li = [0] * (len(s) + 1)
for itr, val in enumerate(s):
  if itr == 0:
    if val == "<":
      li[0] = 0
  else:
    if (s[itr - 1] == "<" and s[itr] == "<"):
      li[itr] = li[itr - 1] + 1
#    elif s[itr - 1] == ">" and s[itr] == "<":
#      li[itr] = 0
    if s[itr] == "<" and itr == lens - 1:
      li[itr + 1] = li[itr] + 1

for itr, val in enumerate(reversed(s)):
  if itr == 0:
    if val == ">":
      li[lens] = 0
  else:
    if s[lens - itr - 1] == ">" and s[lens - itr] == ">":
      li[lens - itr] = li[lens - itr + 1] + 1
    if s[0] == ">":
      li[0] = li[1] + 1
      
for itr, val in enumerate(s):
  if itr > 0:
    if s[itr - 1] == "<" and s[itr] == ">":
      li[itr] = max(li[itr - 1],li[itr + 1]) + 1 

print(sum(li))

Measured memory_bytes: 94824
#include <iostream>
#include <cmath>
#include <vector>
#include <map>

using namespace std;

int main() {
    string a, b;
    cin >> a >> b;
    int l = b.size();

    //cout << a.size();

    int i = 0;

    while (true)
    {
        if (a[i] != b[i]) {
            cout << "No";
            return 0;
        }
        if (i == a.size() - 1)break;
        i++;
    }
    //cout << "same";
    if (b.size() > i + 2)cout << "No";
    else {
        cout << "Yes";
    }


    return 0;
}

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


int main() {
	int n;
	cin >>n;
	int last=n%10;
	if(last==2 || last ==4 || last == 5 || last == 7 || last == 9) {
		cout << "hon";
	}else if(last==0 || last ==1 || last ==6 || last ==8) {
		cout << "pon";
	}else{
		cout << "bon";
	}
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  string ans="No";
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(i*j==N){
        ans = "Yes";
        cout << ans << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
	
/*
	for(int i=0; i<7; i++){
		int a,b;
		cin >> a >> b;
		cout << a - b <<endl;
		*/


	for(int i=0; i<4; i++){
		int T, K;
		cin >> T >> K;
		if(T == 1){
			cout << K*6000 << endl;
		}
		else if(T == 2){
			cout << K*4000 << endl;
		}
		else if(T == 3){
			cout << K*3000 << endl;
		}
		else{
			cout << K*2000 << endl;
		}

	}

	

}



Measured memory_bytes: 3116
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
int n;

signed main(){

    cin >> n;
  if(n==1){
    cout << "Yes" << endl;
    cout << 2 << endl;
    cout << "1 1" << endl;
    cout << "1 1" << endl;

    
    return 0;
  }

    int k = -1;
    rep(i,n+1){
        if(i*(i-1)/2 == n){
            k = i;
            break;
        }
        if(i == n){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    cout << k << endl;

    rep(i,k){
        cout << k-1 << " " ;
        int cnt = 0;
        int now1 = 0;
        int now2 = 0;
        while(cnt != k-1){
            if(now1 == i){
                rep(j,k-1-now1){
                    cout << j+1+now2 << " ";
                    cnt = k-1;
                }
            }else{
                cout << (now2 +k-1 -now1) - (k-1-i) << " ";
                now2 += k-1-now1;
                now1++;
                cnt++;
            }
        }

        cout << endl;
    }
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define MOD 1000000007
using namespace std;
ll power(ll x,ll n){
	ll ans=1LL;
	while(n){
		if(n%2)
			ans=(ans%MOD*x%MOD)%MOD;

		x=(x%MOD*x%MOD)%MOD;
		n>>=1;
	}
	return ans%MOD;
}
void solve()
{
	ll n;cin>>n;
	ll p1=power(10,n)%MOD;
	ll p2=power(9,n)%MOD;
	ll p3=power(8,n)%MOD;
	ll ans=(p1%MOD-2*p2%MOD+p3%MOD+MOD)%MOD;
	cout<<ans<<'\n';
	
}
int main()

{	Fast;
//	int t;cin>>t;
//	while(t--)
	solve();
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  int ans = 0;
  
  for (int i = 1; i <= n; i++) {
    int l, r; cin >> l >> r;
    ans += r - l + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

void dfs(const vector<vector<int>>& graph, vector<int>& groups, int node, int group) {
    groups[node] = group;
    for (auto& nxt_node : graph[node]) {
        if (groups[nxt_node] < 0) {
            dfs(graph, groups, nxt_node, group);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    int u, v;
    vector<vector<int>> graph(N);
    rep(i, 0, M) {
        cin >> u >> v;
        --u, --v;
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    vector<int> groups(N, -1);
    int group = 0;
    rep(i, 0, N) {
        if (groups[i] < 0) {
            dfs(graph, groups, i, group);
            ++group;
        }
    }
    cout << group - 1 << endl;
    return 0;
}

Measured memory_bytes: 10040
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()
    val A = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    A.sortBy { it * -1}
    var replaced = false

    var former = A[0]
    var formerGcd = A[0]

    val candidate1 = A.reduce { acc, a ->
        var result = gcd(acc, a)
        if (result == 1L && !replaced) {
            result = listOf(gcd(acc, former),
                    gcd(formerGcd, a)
                    ).max()!!
            replaced = true
        }
        former = a
        formerGcd = acc
        result
    }

    val store = A[1]
    A [1] = A[0]
    val candidate2 = A.reduce { acc, a -> gcd(acc, a)}
    A [1] = store
    A[0] = store
    val candidate3 = A.reduce { acc, a -> gcd(acc, a)}

    println(listOf(candidate1, candidate2, candidate3).max()!!)
}

fun gcd(a: Long, b: Long): Long {
    return if (b == 0L) a else gcd(b, a % b)
}

Measured memory_bytes: 65664
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  int par[200009],sz[200009];
int p(int x)
{
if(x==par[x])return x;

return par[x]=p(par[x]);

}
void unite(int x,int y)
{
	x=p(x);
	y=p(y);
	if(x==y)return ;
	if(sz[x]>sz[y])swap(x,y);
	sz[y]+=sz[x];
	par[x]=y;
}
  void solve()
  {
  	int n,m;
  	cin>>n>>m;
  	for(int i=1;i<=n;i++)par[i]=i,sz[i]=1;
  	forn(i,m)
  	{
int x,y;
cin>>x>>y;
unite(x,y);

 }
 int ans=0;
 for(int i=1;i<=n;i++)
 {
ans=max(ans,sz[p(i)]);
 }
 cout<<ans;


  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


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

using namespace std;

int N;

int main() {
	int X, Y;
	cin >> N >> X >> Y;
	vector<int> count(N);
	for (int i = 1; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			int dist = min(abs(i - j), 
			min(abs(X - i) + abs(Y - j) + 1, abs(Y - i) + abs(X - j) + 1));
			count[dist]++;
		}
	}
	for (int i = 1; i < N; i++) {
		cout << count[i] << endl;
	}
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll N;
    cin >> N;
    vec W(N);
    REP(i,0,N) cin >> W[i];

    ll S1 = 0, S2 = 0;
    REP(i,0,N) S2 += W[i];
    ll m = INF;
    REP(i,0,N-1) {
        S1 += W[i]; S2 -=W[i];
        m = MIN(m,abs(S1-S2));
    }
    _PR(m);

    return 0;
}

/*



*/

Measured memory_bytes: 256
#include <iostream>

int main() {
  using namespace std;

  long N, K;
  cin >> N >> K;

  N %= K;

  long prevN = N + 1;
  do {
    prevN = N;
    N = abs(N - K);
  } while (N < prevN);

  cout << prevN << endl;

  return 0;
}


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

using namespace std;

void solve()
{
	int n;
	cin >> n;
	if(n == 1)
	{
		cout << 1 << endl;
		return;
	}
	vector<int> a(1000);
	for(int i = 1; i < 1000; ++i)
	{
		a[i] = 0;	
	}
	a[0] = 1;

	for(int i = 2; i <= n; ++i)
	{
		int buf = 0;
		for(int j = 0; j < a.size() - 1; ++j)
		{
			int temp = 0;
			temp = a[j] * i + buf;
			buf = temp / 10;
			a[j] = temp % 10;
		}
	}
	reverse(a.begin(), a.end());
	bool flag = false;
	for(int b = 0; b < a.size(); ++b)
	{
		if(a[b] != 0)
		{
			flag = true;
		}
		if(flag)
		{
			cout << a[b];
		}
	}
	cout << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll; ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);
ll fac(ll x){if(x==0) return 1;  return x*fac(x-1);}

int main(){
    string s; cin>>s;
    sort(all(s));
    if(s=="abc") cout<<"Yes";
    else cout<<"No";
}

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

int main(){
    string s;
    cin >> s;
    int g, h;
    for (int i = 0; i < s.size(); i += 2){
        if((s[i] == 'R') || (s[i] == 'U') || (s[i] == 'D'))
            g = 0;
        else{
            g = 1;
            break;
        }
    }
    for (int i = 1; i < s.size(); i += 2){
        if((s[i] == 'L') || (s[i] == 'U') || (s[i] == 'D'))
            h = 0;
        else{
            h = 1;
            break;
        }
    }
    if((g == 0) && (h == 0))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,tmp=0;
    scanf("%d",&n);
    tmp += n / 25;
    n = n % 25;
    tmp += n / 10;
    n = n % 10;
    tmp += n / 5;
    n = n % 5;
    tmp += n / 1;
    printf("%d\n",tmp);
    return 0;
}


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

int main(){
    map<string,ll> rec;
    ll n; 
    cin >> n;
    string it;
    cin >> it;
    char next = it[it.size()-1];
    rec[it]++;
    rep(i, 0, n-1){
        string t;
        cin >> t;
        if(next != t[0] || rec.count(t) > 0){
            cout << "No" << endl;
            return 0;
        }else{
            next = t[t.size()-1];
            rec[t]++;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(snip_i, h) cin >> s.at(snip_i);
	int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
	rep(i, h){
		rep(j, w){
			if(s.at(i)[j] == '#'){
				int flag = false;
				rep(k, 4){
					int ti = i + dx[k];
					int tj = j + dy[k];
					if(ti < 0 || ti >= h || tj < 0 || tj >= w) continue;
					if(s.at(ti)[tj] == '#'){
						flag = true;
						break;
					}
				}
				if(flag == true) continue;
				else{
					cout << "No" << endl;
					return 0;
				}
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256