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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int a[3];
  cin>>a[0]>>a[1]>>a[2];
  sort(a, a+3);
  if(a[0]+a[1] == a[2])
  {
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 12160
#include <iostream>
using namespace std;
long int n ;
int digit(int m){
     
     int ret = 1 ;
     while(m / 10 != 0){
          m /= 10 ;
          ret++ ;
     }
     
     return ret ;
}

int main(void){
     
     
     cin >> n ;
     
     int t ;
     
     for(long int i = 1 ; i * i <= n ; i++){
          
          if(n % i == 0){
               t = i ;
          }
          
          
     }

     cout << digit(n / t) << endl ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int n;
cin >> n;
int x,y,z;
while(1) {
  x=n/100;
  y=(n/10)%10;
  z=n%10;
  if(x==y&&y==z) break;
  n++;
}
cout << n << endl;
return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N, A;

int main() {

	cin >> N >> A;



	cout << N / A + !!(N % A) << endl;

	return 0;
}


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

void dfs(vector<vector<ll>> &g, ll v, ll parent, vector<ll> &ans, ll value) {
	ans[v]+=value;
	for(ll nextv:g[v]){
		if(nextv==parent)continue;
		dfs(g, nextv, v, ans, ans[v]);
	}
}

signed main() {
	ll N, Q;
	cin>>N>>Q;
	vector<ll> a(N-1,0);
	vector<ll> b(N-1,0);
	vector<ll> q(Q,0);
	vector<ll> x(Q,0);
	rep(i, N-1) cin>>a[i]>>b[i];
	rep(i, Q) cin>>q[i]>>x[i];

	vector<vector<ll>> g(N,vector<ll>());
	for (ll i=0; i<N-1; i++) {
		ll from,to;
		from=a[i];to=b[i];
		from--;to--;
		g[from].push_back(to);
		g[to].push_back(from);
	}

	vector<ll> ans(N,0);
	rep(i,Q){
		ans[q[i]-1]+=x[i];
	}

	vector<ll> trail;
	dfs(g, 0, -1, ans, 0);

	rep(i,N){
		cout<<ans[i]<<' ';
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 36736
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	vector<string> S(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> S[i];
	}
	vector<map<char, int> > cnt(n);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < 26; ++j)
		{
			cnt[i]['a' + j] = 0;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < S[i].size(); ++j)
		{
			cnt[i][S[i][j]]++;
		}
	}
	string ans = "";
	for (int i = 0; i < 26; ++i)
	{
		int minUse = 1e9;
		for (int j = 0; j < n; ++j)
		{
			minUse = min(minUse, cnt[j]['a' + i]);
		}
		for (int j = 0; j < minUse; ++j)
		{
			ans += 'a' + i;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int a[214514],b[214514];
map<int,int> mpa,mpb;
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i];
	ic(m)
	rep(0,i,m)cin>>b[i];
	rep(0,i,n)mpa[a[i]]++;
	rep(0,i,m)mpb[b[i]]++;
	rep(0,i,m){
		if(mpa[b[i]]<mpb[b[i]]){
			c("NO")
			return 0;
		}
	}
	c("YES")	
}	

Measured memory_bytes: 28416
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  ll s[N];
  ll sumB = 0;
  rep(i,N){
    ll a, b; cin >> a >> b;
    s[i] = a+b;
    sumB += b;
  }
  sort(s,s+N);
  reverse(s,s+N);
  ll ans = -sumB;
  rep(i,N) if (i%2==0) ans += s[i];
  cout << ans << endl;



  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 4348
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 char s[100010];
 sc(s);
 ll cnt=0;
 bool ch=false;
 if(s[0]=='W')ch=true;
 ll len=strlen(s);
 rep(i,0,len){
  if((ch&&s[i]=='B')||(!ch&&s[i]=='W')){
   cnt++;
  }
  if(s[i]=='B')ch=false;
  if(s[i]=='W')ch=true;
 }
 pr(cnt);
return 0;}

Measured memory_bytes: 3752
#14:31-
N = int(input())
s = []
for i in range(N):
    s.append(int(input()))
sum_s = sum(s)
s.sort()
if sum_s % 10 != 0:
    ans = sum_s
else:
    for i in range(N):
        if s[i] % 10 != 0:
            ans = sum_s - s[i]
            break
    else:
        ans = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, mod, a;
	string s, ans="";
	vector<char> v;
	cin>>n>>s;
	
	for(int i=0; i<s.length(); ++i)	v.push_back(s[i]);
	for(int i=0; i<v.size();++i){
		a = v[i]-'A';
		a += n;
		a %= 26;
		cout<<char('A'+a);
	}
	return 0;
}

Measured memory_bytes: 256
$N=<>;
++$_[$_]for glob<>;
if($_[0]||$_[12]>=2){exit!print 0}
for(1..12){
	$_[$_]==1?
		push@d,$_
	:$_[$_]==2?
		push@D,$_,24-$_
	:$_[$_]>=3?
		exit!print 0
	:0;
}
$y=0;
for$b(0..2**@d-1){
	@c=();
	for$i(0..@d-1){
		push@c,$b>>$i&1?$d[$i]:24-$d[$i]
	}
	@_=sort{$a-$b}0,@D,@c;
	$x=12;
	("@_ ".($_[0]+24))=~s/\d+ /$x-=$-=$x-($'-$&)/ger;
	$x>$y&&($y=$x)
}
print$y


Measured memory_bytes: 768
n, y = map(int, input().split())

# 10000
for i in range(n+1):
    # 5000
    for j in range(n+1-i):
        k = (n-i-j)
        if i * 10000 + j * 5000 + k * 1000 == y:
            print(" ".join([str(i), str(j), str(k)]))
            exit(0)
print('-1 -1 -1')

Measured memory_bytes: 3060
#include"bits/stdc++.h"
using namespace std;

long long f(long long b, long long n) {
    if (n < b) {
        return n;
    } else {
        return f(b, n / b) + n % b;
    }
}

int main() {
    long long n, s;
    cin >> n >> s;

    if (n == s) {
        cout << n + 1 << endl;
        return 0;
    }

    for (long long b = 2; b * b <= n; b++) {
        if (b * b <= n) {
            if (f(b, n) == s) {
                cout << b << endl;
                return 0;
            }
        }
    }

    long long start = 1;
    while (start * start <= n) {
        start++;
    }

    for (long long a = start - 1; a >= 1; a--) {
        //n = a * b + c
        //a + c = s
        long long b = (n - s + a) / a;
        if (b <= 1) {
            continue;
        }
        if (f(b, n) == s) {
            cout << b << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

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

int main() {
	int N, X;
	cin >> N >> X;
	int C = 1, D = 0;
	for (int i = 0; i < N; i++) {
		int L;
		cin >> L;
		D += L;
		if (D <= X) C++;
	}
	cout << C << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <ctime>
#include <list>
using namespace std;
static const double EPS = 1e-8;
typedef long long ll;
typedef pair<int,int> PI;
#ifndef M_PI
const double M_PI=acos(-1);
#endif
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int((a).size()))
#define F first
#define S second
int dx[]={0,1,0,-1,0,0},dy[]={1,0,-1,0,0,0};
int dz[]={0,0,0,0,1,-1};

int vis[110000];
int p[110000];

main(){
  int n;
  cin>>n;
  rep(i,n)cin>>p[i];

  priority_queue<PI>q;
  q.push(mp(0,0));

  while(!q.empty()){
    int cv=q.top().S;
    int cc=-q.top().F;
    q.pop();
    if(cv>=n-1){
      cout<<cc<<endl;
      return 0;
    }

    if(vis[cv])continue;
    vis[cv]=true;
    if(p[cv]){
      q.push(mp(-cc,cv+p[cv]));
      continue;
    }

    rep(i,6)
      q.push(mp(-cc-1,cv+i+1));
  }
}

Measured memory_bytes: 1660
# AOJ 0217 Walking in the Hospital
# Python3 2018.6.23 bal4u

while 1:
	n = int(input())
	if n == 0: break
	dmax = 0
	for i in range(n):
		p, d1, d2 = map(int, input().split())
		if d1+d2 > dmax: id, dmax = p, d1+d2
	print(id, dmax)


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

using namespace std;

int main() {
    long long n;
    cin >> n;
    vector<int> x(n);
    for (auto &i : x) {
        cin >> i;
    }
    long long res = 1e9;
    for (int i = 0; i < 100; i++) {
        long long sum = 0;
        for (auto j : x) {
            sum += (i - j) * (i - j);
        }
        res = min(res, sum);
    }
    cout << res;
    return 0;
}

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

int main(){
    int n ;
    cin >> n ;
    vector<double> v(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> v.at(i) ;
    }
    sort(v.begin(), v.end()) ;
    for (size_t i = 0; i < n-1; i++)
    {
        v.at(i+1) = (v.at(i) + v.at(i+1)) / 2.0 ;
    }
    cout << v.at(n-1) << endl ;
    
}

Measured memory_bytes: 256
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<f64> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn read_int_tuple() -> (f64, f64, f64, f64) {
    let v = read_vec();
    (v[0], v[1], v[2], v[3])
}

fn main() {
    let (W, H, x, y) = read_int_tuple();
    let area = W*H/2.0;
    let multiple = if x == W/2.0 && y == H/2.0 {
        1
    } else {
        0
    };
    println!("{} {}", area, multiple);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

int n,a,s,g;

struct edge{
  int from;
  int to;
  string cost;

  edge(int f = 0,int t = 0,const string& c = "") : from(f) , to(t) , cost(c){

  }
};

void solve(){
  vector<edge> edges;

  for(int i = 0;i < a;i++){
    int f,t;
    string c;
    cin >> f >> t >> c;
    edges.emplace_back(t,f,c);
  }

  vector<string> dist(n + 1,"");
  vector<int> bit(n + 1,1);
  bit[g] = 0;
  dist[g] = "";
  for(int i = 0;i <= 7 * n;i++){
    for(auto & e : edges){
      if(bit[e.from]) continue;
      string A = e.cost + dist[e.from];

      if(bit[e.to] || dist[e.to] > A){
        bit[e.to] = 0;
        dist[e.to] = A;
      }
    }
  }

  vector<int> neg(n + 1,0);

  for(int i = 0;i <= 7 * n;i++){
    for(auto & e : edges){
      if(bit[e.from]) continue;
      string A = e.cost + dist[e.from];

      if(bit[e.to] || dist[e.to] > A){
        neg[e.to] = neg[e.from] = 1;
        bit[e.to] = 0;
        dist[e.to] = A;
      }
    }
  }

  if(bit[s] || neg[s]){
    cout << "NO" << endl;
    return;
  }
  cout << dist[s] << endl;
}

int main(){
  while(cin >> n >> a >> s >> g,n){
    solve();
  }
}



Measured memory_bytes: 4264
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
vector<vector<LL> > dp(2005, vector<LL>(2005, -1));
LL C(int i, int j) {
    if (i < 0 || j < 0 || i < j) return 0;
    if (~dp[i][j]) return dp[i][j];
    if (i == j || j == 0) return dp[i][j] = 1;
    return dp[i][j] = (C(i - 1, j) + C(i - 1, j - 1)) % MOD;
}
int main() {
    int n, k; cin >> n >> k;
    int a = k, b = n - k;
    for (int i = 1 ; i <= k ; i++) {
        cout << C(a - 1, i - 1) * C(b + 1, i) % MOD << '\n';
    }
}


Measured memory_bytes: 31872
=begin
－－－－－－－－－－－－－－ 
A = 100*A 水
B = 100*B 水
C,D = １回の投入可能砂糖量
E = 100(g)あたりに溶かすことのできる砂糖量
F = ビーカー許容量(水 + 砂糖 = 総質量)
sugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙)
water = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙)
sum = water[i]とsugar[j]の総質量
pos = water[i] に溶かせる砂糖量
con = sugar[j]*100 / (sugar[j] + water[i])  の砂糖濃度(%)
ans = 答え
－－－－－－－－－－－－－－
=end

A,B,C,D,E,F = gets.split.map(&:to_i);

water = [];
(0..30).each do |i|
  (0..30).each do |j|
    x = (100*A*i) + (100*B*j);
    water << x if x <= F;
  end
end
water.sort!.uniq!;

sugar = []
(0..100).each do |i|
  (0..100).each do |j|
    y = C * i + D * j;
    sugar << y if y <= F;
  end
end
sugar.sort!.uniq!;

sum_ans = 0;
sugar_ans = 0;
dif = -1;
con = 0.0;

water.each do |w|
  pos = w / 100 * E;
  sugar.each do |s|
    sum = w + s;
    next if pos < s || F < sum
    con = (s*100) / (s + w).to_f;
    if dif < con
      sum_ans = sum;
      sugar_ans = s;
      dif = con;
    end
  end
end

puts "#{sum_ans} #{sugar_ans}"

Measured memory_bytes: 2040
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <iostream>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
const double pi = 3.141592653589793238;

// 最大公約数を求める
long long GCD(long long x, long long y) {
    return y ? GCD(y, x%y) : x;
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) {a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) {a = b; return true; } return false; }


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

  int sum = 0;
  for(int i = 1; i <=K; i++) {
    for( int j = 1; j <=K; j++) {
      for(int k = 1; k <=K; k++) {
        sum += GCD(i, GCD(j, k));
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var stdInScanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	stdInScanner.Scan()
	i, _ := strconv.Atoi(stdInScanner.Text())
	return i
}

func main() {
	stdInScanner.Split(bufio.ScanWords)

	N := nextInt()
	M := nextInt()

	var A, B int
	E := make([][]int, N)
	for i := 0; i < N; i++ {
		E[i] = make([]int, 0)
	}
	for i := 0; i < M; i++ {
		A = nextInt()
		B = nextInt()
		E[A-1] = append(E[A-1], B)
		E[B-1] = append(E[B-1], A)
	}

	prevRooms := make([]int, N)
	for i := 0; i < N; i++ {
		prevRooms[i] = -1
	}

	nowRooms := []int{1}
	for {
		nextRooms := []int{}
		for _, nowRoom := range nowRooms {
			for _, nextRoom := range E[nowRoom-1] {
				if prevRooms[nextRoom-1] > 0 {
					continue
				}
				prevRooms[nextRoom-1] = nowRoom
				nextRooms = append(nextRooms, nextRoom)
			}
		}
		if len(nextRooms) == 0 {
			break
		}
		nowRooms = nextRooms
	}
	if len(prevRooms) > 0 {
		fmt.Println("Yes")
		for index, prevRoom := range prevRooms {
			if index == 0 {
				continue
			}
			fmt.Println(prevRoom)
		}
	}
}


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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}

#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>







int main()
{
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n=Int;
    string s;
    cin>>s;
    int cnt =0;
    for(int i=0;i<n;i++)
    {
    	int j=i+1;
    	cnt++;
    	while(s[i]==s[j])
    	{
    		j++;
    		if(j>=n) break;
    	}
    	i=j-1;

    }

    cout<<cnt<<endl;
    
    return 0;
}




Measured memory_bytes: 512
N = int(input())
Da = [0 for i in range(N+1)]
Db = [0 for i in range(N+1)]
Dc = [0 for i in range(N+1)]
for i in range(1, N+1):
  a, b, c = map(int, input().split())
  Da[i] = max(Db[i-1], Dc[i-1]) + a
  Db[i] = max(Da[i-1], Dc[i-1]) + b
  Dc[i] = max(Da[i-1], Db[i-1]) + c
print(max(Da[N], Db[N], Dc[N]))

Measured memory_bytes: 90808
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=2000010;
const ll mod=1e9+7;


int main(){
  ll x,y;
  cin >> x >> y;
  ll ans=0;
  while(x<=y){x*=2; ans++;}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		long N = scn.nextLong();
		for(long i = (long)Math.sqrt(N);i>0;i--) {
			if(N%i==0) {
				long j = N/i;
				System.out.println(j + i - 2);
				return;
			}
		}
	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,x; cin >> N >> x;
    VI ans(2*N-1);
    REP(i,2*N-1){
        ans[i] = i+1;
    }
    if(x  == 1 || x == 2*N-1){
        cout << "No" << endl;
        return 0;
    }
    if(N == 2){
        cout << "Yes" << endl;
        cout << 1 << endl << 2 << endl << 3 << endl;
        return 0;
    }

    if(x == 2){
        cout << "Yes" << endl;
        ans.erase(ans.begin(), ans.begin()+4);
        VI tmpins = {4,1,2,3};
        //cout << printVector(ans) << endl;
        auto it = ans.begin() + N -3;
        dump(*it)
        for(int p : tmpins){
            //it = ans.insert(it,p);
            ans.insert(it,p);
            it++;
        }

    }
    else{
        cout << "Yes" << endl;
        ans.erase(ans.begin()+(x-2-1), ans.begin()+(x+2-1));
        VI tmpins = {x-2,x-1,x,x+1};
        auto it = ans.begin()+N-3;
        for(int p : tmpins){
            ans.insert(it,p);
            it++;
        }
    }
    for(int p : ans){
        cout << p << endl;
    }

}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e18+9
#define N 2000006

using namespace std;

int n, m, k, d[30], t, f, p;
char a[1005][1005];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> a[i][j], d[a[i][j] - 97]++;
    for (int i = 0; i < 26; i++)
        if (d[i] % 2) t++, p = d[i];
        else f += d[i] / 4;
    f += (p - 1) / 4;
    if ((n * m) % 2 && t != 1)
        cout << "No" << endl;
    else if ((n * m) % 2 == 0 && t)
        cout << "No" << endl;
    else if ((n / 2) * (m / 2) > f)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;

	return 0;
}


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

string S;
ll n,ans;

void dfs(ll i, ll a, ll b){
  if(i==n){
    ans += a+b;
  }
  
  else{
    dfs(i+1, a+b, S[i+1]-48);
    dfs(i+1, a, 10*b+S[i+1]-48);
  }
}

int main(){
  cin >> S;
  n = S.size()-1;
  ans = 0;
  dfs(0,0,S[0]-48);
  cout << ans << endl;
  return 0;
}

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

int main(){
    int x, y, ans=0;
    std::cin>>x>>y;

    if(abs(x) < abs(y)){
		if(x<0) ans++;
		ans += abs(y)-abs(x);
		if(y<0) ans++;
    }
    else if(abs(x) == abs(y)){
        if(x!=y) ans++;
    }
    else{
		if(x>0) ans++;
		ans += abs(x)-abs(y);
		if(y>0) ans++;
    }
    std::cout<<ans;
	return 0;
}


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

int main(){

  int x, t[10], cnt=0;

  while(cin>>x){
    if(x==0){
      cnt--;
      cout<<t[cnt]<<endl;
    }else{
      t[cnt]=x;
      cnt++;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

template <std::uint_fast64_t Modulus> class mint {
public:
  ll a;
  constexpr mint(const ll x = 0) noexcept : a(x % Modulus) {}
  constexpr ll &value() noexcept { return a; }
  constexpr const ll &value() const noexcept { return a; }
  constexpr mint operator+(const mint rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator-(const mint rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator*(const mint rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator/(const mint rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint &operator+=(const mint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr mint &operator-=(const mint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr mint &operator*=(const mint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr mint &operator/=(mint rhs) noexcept {
    ll exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
constexpr ll MOD=1000000007;

void solve(){
  string k; cin>>k;
  ll n=k.size();
  ll D; cin>>D;
  auto dp=make_v(D,2,mint<MOD>(0)); // dp[r][lt] 桁の和がr mod D, b=1は<=kが確定
  dp[0][0]=1;
  rep(i,n){ // 上からi桁目まで見た
    ll a=k[i]-'0';
    auto newdp=make_v(D,2,mint<MOD>(0));
    rep(r,D)rep(d,10){
      newdp[(r+d)%D][1]+=dp[r][1]; // ltが確定していれば好きに遷移できる
      if(d<a) newdp[(r+d)%D][1]+=dp[r][0];
      else if(d==a) newdp[(r+d)%D][0]+=dp[r][0];
    }
    dp=newdp;
  }
  cout<<(dp[0][0]+dp[0][1]-1).a<<"\n";
}

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;

	cin >> n;

	cout << n * 800 - (int)(n / 15) * 200 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int num=0;
    int ans=0;
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1]){
            num++;
        }
        else{
            num=0;
        }
        ans=max(ans,num);

    }
    cout << ans<<endl;
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <stdint.h>

int main(void) {
  int64_t N;
  scanf("%ld", &N);

  int MIN = 10;
  for(int64_t i = 1; i * i <= N; i++) {
    if(N % i == 0) {
      int64_t B = N / i;
      int M = 0;
      while(B > 0) {
	B /= 10;
	M++;
      }
      MIN = M;
    }
  }
  printf("%d\n", MIN);
  
  return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

#define int ll

const int MAXN = 2e5 + 10;
int n, k;
int a[MAXN];

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

int used[MAXN];
int ans;

void run() {
	fill(used, used + n, -1);
	int now = 0;
	int t = 0;
	while (k > 0 && used[now] == -1) {
		used[now] = t++;
		now = a[now];
		k--;
	}
	if (!k) {
		ans = now;
		return;
	}
	int len = t - used[now];
	k %= len;
	while (k > 0) {
		now = a[now];
		k--;
	}
	ans = now;
}

void write() {
	cout << ans + 1 << endl;
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	read();
	run();
	write();
	return 0;
}

Measured memory_bytes: 6776
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))

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


int main()
{
    int n;cin>>n;
    double ans=0;
    double a[n];for(int i=0;i<n;i++)cin>>a[i];
    a[0]=2*a[0];
    ans=a[0];
    for(int i=0;i<n;i++)
    {
        ans=(ans*a[i])/(ans+a[i]);
    }
    cout<<fixed<<setprecision(15)<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,c,cnt=0;
string s;
signed main()
{
	cin>>s;
	rep(i,s.size()/2){
		if(s[i]!=s[s.size()-i-1]){
			cnt++;
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = do
  n <- readLn :: IO Int
  -- ss <- replicateM n getLine :: IO [String]
  ss <- map (sort . B.unpack) <$> replicateM n B.getLine :: IO [String]
  print $ solve n ss

-- solve :: Int -> [String] -> Int
solve n ss = sum . map fac2 . Map.elems . toCountMap $ ss
  where
    fac2 x = x * (x-1) `div` 2 :: Integer

toCountMap :: (Ord k, Integral a) => [k] -> Map.Map k a
toCountMap xs = Map.fromListWith (+) $ zip xs (repeat 1)


Measured memory_bytes: 84988
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

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

  int n;
  cin >> n;
  vector<int> v(n), l(n), r(n);
  for (int &x : v) cin >> x;
  for (int i = 0; i < n; i++) {
    l[i] = v[i];
    if (i > 0) l[i] = gcd(v[i], l[i - 1]);
  }

  for (int i = n - 1; i >= 0; i--) {
    r[i] = v[i];
    if (i < n - 1) r[i] = gcd(v[i], r[i + 1]);
  }

  int mx = 0;
  for (int i = 0; i < n; i++) {
    int g = 0;
    if (i > 0) g = gcd(g, l[i - 1]);
    if (i < n - 1) g = gcd(g, r[i + 1]);
    mx = max(mx, g);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 1408
n = int(input())
A = list(map(int, input().split()))
l = A.pop(0)
idxl = 0
r = A.pop(-1)
idxr = -1

for i in range(n-2):
  if r<l:
    r+=A[idxr]
    idxr -= 1
  else:
    l+=A[idxl]
    idxl += 1
  
print(abs(r-l))

Measured memory_bytes: 87888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            var dic = new Dictionary<string, long>();

            for (int i = 0; i < N; i++)
            {
                var line = new string(Console.ReadLine().ToCharArray().OrderBy(x => x).ToArray());
                if (dic.ContainsKey(line))
                {
                    dic[line]++;
                }
                else
                {
                    dic.Add(line, 1);
                }
            }

            long ans = 0;
            foreach (var d in dic)
            {
                if (d.Value <= 1) continue;
                ans += d.Value * (d.Value - 1) / 2;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 29084
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int mod=1e9+7;
inline int qpow(int a,int b) { int c=1;
    for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) c=1ll*c*a%mod;
    return c;
}

const int N=400+10;

int n,c,a[N],b[N];
int sum[N][N],dp[N][N];

int main() {
    n=read(),c=read(); int mx=0;
    for (re int i=1;i<=n;++i) a[i]=read(),mx=max(mx,a[i]);
    for (re int i=1;i<=n;++i) b[i]=read(),mx=max(mx,b[i]);
    for (re int i=0;i<=c;++i)
        for (re int j=1;j<=mx;++j)
            sum[i][j]=(sum[i][j-1]+qpow(j,i))%mod;
    dp[0][0]=1;
    for (re int i=1;i<=n;++i)
        for (re int j=0;j<=c;++j)
            for (re int k=0;k<=j;++k)
                dp[i][j]=(dp[i][j]+1ll*dp[i-1][j-k]*(sum[k][b[i]]-sum[k][a[i]-1]+mod)%mod)%mod;
    printf("%d\n",dp[n][c]);
    return 0;
}
//qwq

Measured memory_bytes: 1536
n,t = gets.chomp.split.map(&:to_i)
costs = []
n.times do |i|
  c, cur_t = gets.chomp.split.map(&:to_i)
  if cur_t <= t
    costs.push [c,cur_t]
  end
end
puts (costs.map{|c| c[0]}.min || "TLE")

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

typedef pair<int,int> P;

int main() {
  ios::sync_with_stdio(false);cin.tie(nullptr);
  int n;
  cin >> n;
  int ans = 0;
  vector<P> astr;
  priority_queue<int> mq;
  priority_queue<int,vector<int>,greater<int>> pq;

  if (n == 2) {
    int a,b;
    cin >> a >> b;
    if (a>b) swap(a,b);
    cout << b-a << endl;
    cout << b << " " << a << endl;
    return 0;
  }

  for (int i=0; i<n; i++) {
    int a;
    cin >> a;
    if (a < 0) mq.push(a);
    else pq.push(a);
  }

  if (mq.empty()) {
    int a,b;
    a = pq.top(); pq.pop();
    b = pq.top(); pq.pop();
    astr.push_back(P(a,b));
    mq.push(a-b);
  }

  if (pq.empty()) {
    int a,b;
    a = mq.top(); mq.pop();
    b = mq.top(); mq.pop();
    astr.push_back(P(a,b));
    pq.push(a-b);
  }

  ans = mq.top(); mq.pop();
  int last = pq.top(); pq.pop();
  while (!pq.empty()) {
    astr.push_back(P(ans,pq.top()));
    ans -= pq.top(); pq.pop();
  }
  astr.push_back(P(last, ans));
  ans = last - ans;
  while (!mq.empty()) {
    astr.push_back(P(ans,mq.top()));
    ans -= mq.top(); mq.pop();
  }


  cout << ans << '\n';
  for(auto a : astr)
    cout << a.first << " " << a.second << '\n';

}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  string SA, SB, SC; cin >> SA >> SB >> SC;
  
  reverse(all(SA));
  reverse(all(SB));
  reverse(all(SC));
  
  char next = 'a';
  rep(i,300) {
    if (next == 'a') {
      if (SA == "") {
        cout << "A" << endl;
        return 0;
      }
      next = SA.at(SA.size()-1);
      SA.pop_back();
    }
    else if (next == 'b') {
      if (SB == "") {
        cout << "B" << endl;
        return 0;
      }
      next = SB.at(SB.size()-1);
      SB.pop_back();
    }
    else {
      if (SC == "") {
        cout << "C" << endl;
        return 0;
      }
      next = SC.at(SC.size()-1);
      SC.pop_back();
    }
  }
}

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

using namespace std;

int main(){
    string s;
    
    cin >> s;
    string S = s + s;
    long K;
    cin >> K;
    int n = s.size();

    long cnt1 = 0;
    long cnt = 0;
    int same = 0;
    for(int i = 0; i<n; i++){
        if(s[i] == s[0]) same++;
    }
    for(int i=0; i< 2 * n -1; i++){
        
        if(i < n-1){
            if(S[i] == S[i+1]){
                cnt1++;
                S[i+1] = '*';
            }
        }
        else{
            if(S[i] == S[i+1]){
                cnt++;
                S[i+1] = '*';
            }
        }
    }

    long ans = cnt * (K-1) + cnt1;

    if(same == n) cout << n * K /2 << endl;
    
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	int N;
	cin >> N;
	int k = sqrt(N * 2);
	if (k*(k + 1) / 2 != N) {
		cout << "No" << endl;
		return 0;
	}
	k++;
	vector<vector<int>> s(k);
	int cnt = 0;
	rep(r, k)rep(l, r) {
		s[l].push_back(cnt);
		s[r].push_back(cnt);
		cnt++;
	}
	cout << "Yes" << endl << s.size() << endl;
	for (const auto& row : s) {
		cout << row.size();
		for (const auto& col : row) {
			cout << " " << col + 1;
		}
		cout << endl;
	}

	return 0;
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main()
{
    string a;
    cin >> a;
    if(a=="T") cout << "A" << endl;
    else if(a=="A") cout << "T" << endl;
    else if(a=="C") cout << "G" << endl;
    else if(a=="G") cout << "C" << endl;
}


Measured memory_bytes: 256
package main
import(
    "fmt"
)
func main(){
    var a, b  int
    fmt.Scan(&a,&b)
    if a >= 13 {
        fmt.Println(b)
    } else if  6<= a && a <= 12{
        fmt.Println(b/2)
    } else {
        fmt.Println(0)
    }
}

Measured memory_bytes: 512
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int d, g;
    cin >> d >> g;
    vector<int> p(d), c(d);
    rep(i, d){
        cin >> p[i] >> c[i];
    }
    int ans = 100000;
    for(int bit = 1; bit < (1 << d); bit++){
        int score = 0;
        int prob = 0;
        rep(i, d){
            if(((bit >> i) & 1) == 0)
                continue;
            score += c[i] + (i + 1) * 100 * p[i];
            prob += p[i];
        }
        int origin_score = score;
        int origin_prob = prob;
        rep(i, d){
            if(((bit >> i) & 1) == 0)
                continue;
            if(origin_score - c[i] < g)
                continue;
            int removable = min((origin_score - c[i] - g) / ((i + 1) * 100), p[i]);
            prob = min(prob, origin_prob - removable);
        }
        if(g <= score){
            ans = min(ans, prob);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
s=input()
n=len(s)
ans=[0 for _ in range(n)]
r=ans[:]
p=''
c=0
for i in range(n):
  x=s[i]
  if x=='R':
    if p=='R':
      c+=1
    else:
      c=1
  else:
    if p=='R':
      r[i-1]=c
      c=0
  p=x
r=r[::-1]
s=s[::-1]
for i in range(n):
  x=s[i]
  if x=='L':
    if p=='L':
      c+=1
    else:
      c=1
  else:
    if p=='L':
      r[i-1]=c
      c=0
  p=x
r=r[::-1]
s=s[::-1]
o=ans[:]
e=ans[:]
for i in range(n):
  y=r[i]
  if y!=0:
    x=s[i]
    if x=='R':
      ans[i]+=(y+1)//2
      ans[i+1]+=y//2
    else:
      ans[i-1]+=y//2
      ans[i]+=(y+1)//2
print(*ans)

Measured memory_bytes: 8804
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int INF=1e9;

int main(){
    int a,b,t;
    cin >> a >> b >> t;
    int c=t/a;
    cout << c*b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n,k;
set<int>s;
int main() {
  ios::sync_with_stdio(false);
  cin>>n>>k;
  for(int i=1;i<=n;i++)s.insert(i);
  for(int i=1;i<=k;i++){
    int d;
    cin>>d;
    for(int j=1;j<=d;j++){
      int q;
      cin>>q;
      s.erase(q);
    }
  }
  cout<<s.size();
  return 0;
}

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

#define make_it_fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define imn INT_MIN
#define imx INT_MAX

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}

template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}

void _print() {cerr << "]\n";}

template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) 20
#endif

ll power(ll a,ll b)
{
    if(b==1)
    return a;
    if(b==0)
    return 1;
    ll ret=power(a,b/2);
    ret=(ret*ret);
    if(b&1)
    ret=(ret*a);
    return ret;
}

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

void solve()
{
    ll n,k,i,j;
    cin>>n>>k;
    ll a[n];
    vector<ll> dp(k+1,2);
    for(i=0;i<n;i++)
    cin>>a[i];
    ll flag=0;
    for(i=1;i<=k;i++)
    {
        flag=0;
        for(j=0;j<n;j++)
        {
            if(i-a[j]>=0)
            {
                if(dp[i-a[j]]==2)
                {
                    dp[i]=1;
                    flag=1;
                    break;
                }
            }
        }
        if(flag)
        continue;
    }
    if(dp[k]==1)
    cout<<"First"<<endl;
    else
    cout<<"Second"<<endl;
}
int main()
{
    int TEST_CASES=1;
    // cin>>TEST_CASES;
    while(TEST_CASES--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 4052