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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N;
    ll mini = numeric_limits<ll>::max();
    cin >> N;
    vector<ll> W(N + 1);
    rep(i, N) {
        ll temp;
        cin >> temp;
        W[i + 1] += W[i] + temp;
    }
    rep(i, N) mini = min(mini, abs(W.back() - 2 * W[i]));
    cout << mini << endl;
    return 0;
}


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

int main() {
    int n; cin >> n;
    int d, x;
    cin >> d >> x;
    vector<int> a(n);
    rep(i, a.size())
        cin >> a.at(i);
    int sum = 0;
    rep(i,n){
        for (int j = 1; j <= d; j += a.at(i)) {
            sum++;
        }
    }
    cout << sum + x << endl;
    return 0;
}

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

void soma (int i) {
  _sum += i;
}

void ans (int i) {
  _sum += (p - i)*(p - i);
}

int main() {
  int n;
  vector<int> x;
  cin >> n;
  int input;
  while (cin >> input) x.push_back(input);
  _sum = 0;
  for_each(x.begin(), x.end(), &soma);
  p = (int)((0.0 + _sum)/n + 0.5);
  //printf("sum: %d\n", _sum);
  //printf("p: %d\n", p);
  _sum = 0;
  for_each(x.begin(), x.end(), &ans);
  printf("%d\n", _sum);
  return 0;}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	if (N == 1) {
		cout << "Hello World" << endl;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

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

int(a)
int(b)

if a == b:
    print("Draw")
else:
    if 1 in [a, b]:
        if a == 13:
            print("Bob")
        else:
            print("Alice")
    else:
        if (b-a) > 0:
            print("Bob")
        else:
            print("Alice")

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
int main(void){
    int n,i;
    double x;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        x=pow(2,i);
        if(n==x) {
            i++;
            break;
        }
        if(n<x) break;
    }
    printf("%.0f\n",pow(2,i-1));
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

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

#define MAX 1000


int main(void) {
  ll a, b, k, c;
  cin >> a >> b >> k;

  FOR(i, a, a+k) {
	if (i > b) break;
	cout << i << endl;
  }

  if (a + k - 1 >= b - k + 1) {
	c = a + k;
  }
  else {
	c = b - k + 1;
  }

  FOR(i, c, b + 1) {
	cout << i << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct STR{
	int num[30];
};
int n,q,cnt[500010];
STR val[500010*4],tmpstr[20010];
string s;
char c[500010];
void push_up(int pos) {
	for(char i=1;i<=26;++i) val[pos].num[i]=val[pos*2].num[i]+val[pos*2+1].num[i];
}
void build(int pos,int l,int r) {
//	printf("%d %d %d\n",pos,l,r);
	if(l==r) {
		val[pos].num[cnt[l]]=1;
		return;
	}
	int mid=(l+r)/2;
	build(pos*2,l,mid);
	build(pos*2+1,mid+1,r);
	push_up(pos);
}
void update(int pos,int l,int r,int u,int x) {
	if(u>r||u<l) return;
	if(l==r) {
		val[pos].num[cnt[l]]--;
		val[pos].num[x]++;
		cnt[l]=x;
		return;
	}
	int mid=(l+r)/2;
	update(pos*2,l,mid,u,x);
	update(pos*2+1,mid+1,r,u,x);
	push_up(pos);
}
void query(int t,int pos,int l,int r,int ql,int qr) {
	if(ql>r||qr<l) return;
	if(l>=ql&&r<=qr) {
		for(char i=1;i<=26;++i) tmpstr[t].num[i]+=val[pos].num[i];
		return;
	}
	int mid=(l+r)/2;
	query(t,pos*2,l,mid,ql,qr);
	query(t,pos*2+1,mid+1,r,ql,qr);
}
int main()
{
	memset(val,0,sizeof(val));
	memset(tmpstr,0,sizeof(tmpstr));
	scanf("%d%s%d",&n,c,&q);
//	cout<<1;
	s=c;
	for(int i=1;i<=n;++i) cnt[i]=s[i-1]-'a'+1;
	build(1,1,n);
	for(int i=1,flag;i<=q;++i) {
		scanf("%d",&flag);
		if(flag==1) {
			char x;
			int u;
			scanf("%d%s",&u,&x);
			int t=x-'a'+1;
			update(1,1,n,u,t);
		}
		else {
			int l,r,ans=0;
			scanf("%d%d",&l,&r);
			query(i,1,1,n,l,r);
			for(int j=1;j<=26;++j) ans+=(tmpstr[i].num[j]!=0);
			printf("%d\n",ans);
		}
	}
	return 0;
}

Measured memory_bytes: 240000
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#define int long long
#define mod 998244353
using namespace std;
inline int read(){
    int f=1,ans=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){ans=ans*10+c-'0';c=getchar();}
    return f*ans;
}
const int MAXN=301;
const int MAXNS=90001;
int n,a[MAXN],S,f[2][MAXNS],g[2][MAXNS];
int cur;
int ksm(int a,int b){
	int ans=1;
	while(b){
		if(b&1) ans*=a,ans%=mod;
		a*=a,a%=mod;
		b>>=1;
	}return ans;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++) a[i]=read(),S+=a[i];
	f[0][0]=1,g[0][0]=2;
	for(int i=1;i<=n;i++){
		cur^=1;
		for(int j=0;j<=S;j++){
			f[cur][j]=f[cur^1][j]*2;f[cur][j]%=mod;
			if(j>=a[i]) f[cur][j]+=f[cur^1][j-a[i]];f[cur][j]%=mod;
			g[cur][j]=g[cur^1][j];g[cur][j]%=mod;
			if(j>=a[i]) g[cur][j]+=g[cur^1][j-a[i]];g[cur][j]%=mod;
		}
	}
	int res=0;
	for(int i=(S+1)>>1;i<S;i++) res+=f[cur][i]-g[cur][i];res*=3;res%=mod;
	int cnt=(((ksm(3,n)-3*ksm(2,n)+3)%mod)+mod)%mod;
	printf("%lld\n",(((cnt-res)%mod)+mod)%mod);
	return 0;
}

Measured memory_bytes: 3072
from collections import defaultdict
from string import ascii_uppercase
import sys, bisect, math
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N = read_int()[0]
V = read_int()
C = read_int()
diff = [V[i] - C[i] for i in range(N)]
diff.sort(reverse=True)

def solve():
    ans = 0
    for i in range(N):
        if diff[i] >= 0:
            ans += diff[i]
        else: break
    return ans

if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3820
R,G,B,N=(int(i) for i in input().split())
import math
answer=0
for r in range(0,math.floor(N/R)+1):
    for g in range(math.floor(N/G)+1):
        if R*r+G*g>N:
            break
        if (N-R*r-G*g)%B==0:
            answer+=1

print(answer)




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

int main(){
    int a;
    cin >> a;
    int h = a/3600;
    int h1 = a%3600;
    int m = h1/60;
    int s = h1%60;
    cout << h << ":" << m << ":" << s <<  endl;
    return 0;
}


Measured memory_bytes: 3092
<?php
/*
    http://agc005.contest.atcoder.jp/tasks/agc005_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%s", $X);
//echo $X . PHP_EOL;

$str1 = str_repeat("S", 1) . str_repeat("T", 1);
$str2 = str_repeat("S", 10) . str_repeat("T", 10);
$str3 = str_repeat("S", 100) . str_repeat("T", 100);
$str4 = str_repeat("S", 1000) . str_repeat("T", 1000);
$str5 = str_repeat("S", 10000) . str_repeat("T", 10000);
$str6 = str_repeat("S", 100000) . str_repeat("T", 100000);

while (preg_match("/ST/", $X)) {
	$X = str_replace($str6, "", $X);
	$X = str_replace($str5, "", $X);
	$X = str_replace($str4, "", $X);
	$X = str_replace($str3, "", $X);
	$X = str_replace($str2, "", $X);
	$X = str_replace($str1, "", $X);
}

echo strlen($X) . PHP_EOL;


Measured memory_bytes: 4768
#include<iostream>
#include<cmath>
#define PI 3.141592
using namespace std;

int main(){
  double a,b,c,d;
  double seta;

  while(1){
    cin >> a >> b >> c >> d;
    if(a==-1 && b==-1 && c==-1 && d==-1)break;

    a *= PI / 180;
    b *= PI / 180;
    c *= PI / 180;
    d *= PI / 180;
    seta = acos( cos(a)*cos(c)*cos(b-d)+sin(a)*sin(c) );
    cout << (int)(6378.1 * seta + 0.5) << endl;

  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
struct lzq
{
    int x,y;
} a[200000+10];
vector<int>v[200000+10];
bool solve(int n)
{
    int i,j;
    for(i=0; i<v[1].size(); i++)
    {
        int to=v[1][i];
        for(j=0; j<v[to].size(); j++)
            if(v[to][j]==n)
                return 1;
    }
    return 0;
}
int main()
{
    int n,m,x,y;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=m; i++)
        scanf("%d%d",&x,&y),v[x].push_back(y),v[y].push_back(x);
    printf(solve(n)?"POSSIBLE\n":"IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 13424
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

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

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  ll P = 0;
  ll Q = 0;
  vll V;
  REP(i, 0, N) {
    ll p;
    cin >> p;
    P += p * pow(10, N - i - 1);
    V.emplace_back(i + 1);
  }
  REP(i, 0, N) {
    ll q;
    cin >> q;
    Q += q * pow(10, N - i - 1);
  }

  vll R;
  do {
    ll x = 0;
    REP(i, 0, N) {
      x += V[i] * pow(10, N - i - 1);
    }
    R.emplace_back(x);
  } while (next_permutation(V.begin(), V.end()));

  ll p_rank = 0;
  REP(i, 0, R.size()) {
    if (R[i] < P) { continue; }
    p_rank = i;
    break;
  }
  ll q_rank = 0;
  REP(i, 0, R.size()) {
    if (R[i] < Q) { continue; }
    q_rank = i;
    break;
  }

  cout << abs(p_rank - q_rank) << endl;

  return 0;
}


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

using namespace std;

typedef long long  ll;

const int INF = 1e9;

void WarshallFloyd(vector<vector<int>> &d) {
    int n = d.size();

    for (int k = 0; k < n; ++k)
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main()
{
    int n, k, t, s, d, v;

    cin >> n;
    vector<vector<int>> g(n, vector<int>(n, INF));

    for (int i = 0; i < n; ++i)
        g[i][i] = 0;

    for (int i = 0; i < n; ++i) {
        cin >> s >> k;
        --s;
        while (k--) {
            cin >> t;
            g[s][t - 1] = 1;
        }
    }

    WarshallFloyd(g);

    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s >> d >> v;
        --s, --d;
        if (g[s][d] + 1 > v)
            cout << "NA\n";
        else
            cout << g[s][d] + 1 << '\n';
    }

    return 0;
}

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

#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))


int main(void)
{
	//変数の宣言
	int n;
	llong m;
	llong a[50];
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	llong int ans=0;
	int count=0;
	llong int temp,temp1,temp2;
	int max,min;
	int len;
	//データの読み込み
	
	scanf("%lld",&m);
	
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	for(i=0;i<50;i++){
		a[i]=49-i;
		if(i<m%50) a[i]++;
		a[i]=a[i]+m/50;
	}
	
	
//	printf("計算部分終了\n");
	//出力
	
	printf("50\n");
	
	for(i=0;i<50;i++){
		if(i!=0)printf(" ");
		printf("%lld",a[i]);
	}
	
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
module Main where

import Data.Functor

main :: IO ()
main = do
  { [x, y] <- getInts
  ; if x == 0 && y == 0 then done
    else do
      { case compare x y of
        LT -> putInts [x,y]
        GT -> putInts [y,x]
        EQ -> putInts [x,y]
      ; main
      }
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 4016
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    vector<int> x(n);
    for(int i=0;i<n;i++)cin>>x[i];
    int res=0;
    for(int i=1;i<n;i++){
        res+=min(b,(x[i]-x[i-1])*a);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1024
use strict;
use warnings;

my ($h1, $m1, $h2, $m2, $d) = split /\s/, <STDIN>;

my $hour_min = ($h2 - $h1) * 60;
my $min = $m2 - $m1;
my $total_min = $hour_min + $min;
my $valid_time_len = $total_min - $d;
print $valid_time_len, "\n";


Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int n, w;
    cin >> n >> w;
    int *we =  new int[n+1];
    int *val =  new int[n+1];
    we[0]=0;
    val[0]=0;
    for(int i = 1;i <= n;i++)
    cin >> we[i] >> val[i];
    ll ans[2][w+1];
    for(int i=0;i<=1;i++)
    {
        ans[i][0] = 0;
    }

    for(int i=0;i<=w;i++)
    {
        ans[0][i] = 0;
    }

    for(int i=1;i<=n;i++)
    {
        int t= i%2;
        if(t==1)
        {
            for(int j=1;j<=w;j++)
            {
                if(j-we[i]>=0)
                ans[t][j] =  max(ans[t-1][j], val[i] + ans[t-1][j-we[i]]);
                else
                ans[t][j]= ans[t-1][j];
            }
        }
        else
        {
            for(int j=1;j<=w;j++)
            {
                if(j-we[i]>=0)
                ans[t][j] =  max(ans[t+1][j], val[i] + ans[t+1][j-we[i]]);
                else
                ans[t][j]= ans[t+1][j];
            }
        }
    }

    if(n%2)
    cout << ans[1][w];
    else
    cout << ans[0][w];
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

void find_leaves(int c_node, vector<vector<int>> &G, vector<int> &V, vector<int> &leaves){
    if(G[c_node].size()==1){
        leaves.push_back(c_node);
    }
    for(auto node : G[c_node]){
        if(V[node]==-1){
            V[node] = 1;
            find_leaves(node, G, V, leaves);
        }
    }
}

ll cnt=0LL;
void dfs(int c_node, vector<vector<int>> &G, vector<int> &V, vector<int> &Checked){
    for(auto n_node : G[c_node]){
        if(Checked[n_node]==-1){
            cnt+=min(V[c_node], V[n_node]);
            Checked[n_node] = 1;
            dfs(n_node, G, V, Checked);
        }
    }
}


int main(){
    int n;
    cin >> n;
    vector<vector<int>> G(n, vector<int>(0));
    vector<ll> C(n);
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i,n) cin >> C[i];
    sort(ALL(C));
    reverse(ALL(C));
    // rep(i,n){
    //     cout << "node " << i << " ";
    //     for(auto x : G[i]) cout << x << ' ';
    //     cout << endl;
    // }
    vector<int> V(n,-1);
    vector<int> leaves;
    V[0] = 1;
    find_leaves(0, G, V, leaves);    
    fill(ALL(V), -1);

    queue<int> que;
    // for(auto leaf:leaves) que.push(leaf);
    que.push(leaves[0]);
    
    int max_i=0;
    while(que.size()!=0){
        int c_node = que.front();que.pop();
        // cout << c_node << endl;
        // cout << "c_node " <<c_node << " minC " << C[min_i]<< endl;
        V[c_node] = C[max_i];
        max_i++;
        for(auto n_node:G[c_node]){
            if(V[n_node]==-1){
                V[n_node] = 0;
                que.push(n_node);
                // cout << "pushed " << n_node << endl;
            }
        }
    }

    
    vector<int> Checked(n,-1);
    Checked[0]=1;
    dfs(0, G, V,Checked);

    cout << cnt << endl;
    for(auto v: V)cout << v << " ";
    return 0;
}

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

using namespace std;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//debug
#define dump(x)  cerr << #x << " = " << (x) << "\n";
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";

//not typedef but using
using VI = vector<int>;
using VC = vector<char>;
using VVI = vector<VI>;
using VS = vector<string>;
using PII = pair<int, int>;
using LL = long long;

//stdin methods
int I(){ int a; scanf("%d", &a); return a; }
char R(){ char c; scanf("%c", &c); return c; }
string S(){ string s; cin >> s; return s; }
VI LI(int n){ VI v; REP(i,n){v.PB(I());} return v; } 
VC LR(int n){ VC v; REP(i,n){v.PB(R());} return v; }
VS LS(int n){ VS v; REP(i,n){v.PB(S());} return v; }

    
int main(){
  string s=S();
  int x=I(), y=I();
  VI v;
  v.PB(0);
  EACH(c,s) {
    if (*c=='F') v[v.size()-1]+=1;
    else v.PB(0);
  }
  VI vx;
  vx.PB(v[0]);
  for (int i=2; i<v.size(); i+=2) {
    VI tx;
    if (v[i]==0) continue;
    EACH (t,vx) {
      tx.PB(*t+v[i]);
      tx.PB(*t-v[i]);
    }
    vx=tx;
    sort(ALL(vx));
    vx.erase(unique(ALL(vx)),vx.end());
  }
  int flag=0;
  EACH(i,vx) {
    if (*i==x) {
      flag=1;
    }
  }
  if (flag!=1) {
    printf("No\n");
    return 0;
  }
  VI vy;
  vy.PB(0);
  for (int i=1; i<v.size(); i+=2) {
    VI ty;
    if (v[i]==0) continue;
    EACH (t,vy) {
      ty.PB(*t+v[i]);
      ty.PB(*t-v[i]);
    }
    vy=ty;
    sort(ALL(vy));
    vy.erase(unique(ALL(vy)),vy.end());
  }
  EACH(i,vy) {
    if (*i==y) {
      printf("Yes\n");
      return 0;
    }
  }

  printf("No\n");
}


Measured memory_bytes: 508
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int R = sc.nextInt();
      if(N >= 10){
        System.out.println(R);
      }else{
        System.out.println(100*(10-N)+R);
      }
    }
}
      

Measured memory_bytes: 35764
#include<stdio.h>
#include<string.h>
int main(void){
  unsigned long long i,ans=0,w=0;
  char s[200001];
  scanf("%s",s);
  for(i=0;i<strlen(s);i++){
    if(s[i]=='W'){
      ans+=i-w;
      w++;
    }
  }
  printf("%llu",ans);
  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define mem(dp,a) memset(dp,a,sizeof(dp))
#define pb(x) push_back(x)
#define m_p(x,y) make_pair(x,y)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repush_back(i,a,b) for(ll i=a;i>=b;i--)
#define f(n) for(ll i=0;i<n;i++)
#define r(n) for(ll j=0;j<n;j++)
#define F first
#define S second
#define pi 3.14159265359
#define hs ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;
ll HRX=1e18;
ll INF=1e9+7;

const ll N=2*100007;
vector<ll>adj[N];
bool vis[N];
ll n,k;
ll ways[N];

void dfs(ll u,ll level)
{
  vis[u]=1;
  if(level==0)
    ways[u]=k;
  ll j=(level==0) ? 1:2;
  for(ll i=0;i<adj[u].size();i++)
  {
    ll v=adj[u][i];
    if(!vis[v])
    {
     ways[v]=k-j;
     j++;
     dfs(v,1);
    }
  }
}

int main()
{
  hs;

    cin>>n>>k;
    f(n-1)
    {
     ll x,y;
     cin>>x>>y;
     adj[x].pb(y);
     adj[y].pb(x);
    }

    dfs(1,0);
    ll way=1;
    for(ll i=1;i<=n;i++)
    {
      way=(way*ways[i])%INF;
    }
    cout<<way<<endl;


  return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a;
  cin >> a;
  if(a%10 == 9 || a/10 == 9) cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
    int a, b, c, t;
    scanf("%d %d %d",&a,&b,&c);
    if (a == b && a == c)
    {
        printf("%d\n",a + b);
    }
    else
    {
        if (a>b)
        {
            t = a;
            a = b;
            b = t;
        }
        if (b>c)
        {
            t = b;
            b = c;
            c = t;
        }
        if (a>b)
        {
            t = a;
            a = b;
            b = t;
        }
        printf("%d\n",a + b);
    }
    return 0;
}


Measured memory_bytes: 128
N = int(input())
a = list(map(int,input().split()))
color = [False]*8
over_human = 0
for i in a:
    if(i<=399):
        color[0]=True
    elif(i<=799):
        color[1]=True
    elif(i<=1199):
        color[2]=True
    elif(i<=1599):
        color[3]=True
    elif(i<=1999):
        color[4]=True
    elif(i<=2399):
        color[5]=True
    elif(i<=2799):
        color[6]=True
    elif(i<=3199):
        color[7]=True
    elif(i>=3200):
        over_human += 1
if(color.count(True)==0):
    print(1,color.count(True)+over_human)
else:
    print(color.count(True),color.count(True)+over_human)


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

int main()
{
    ll n,x;
    cin >>n >>x;

    ll ans=x;

    ll len=n;
    ll y=len-x;

    while(1)
    {
        //printf("len=%lld y=%lld\n",len,y);
        ll num=len/y;

        if(len%y==0)
        {
            ans+=(num-1)*2*y;
            break;
        }
        else
        {
            ans+=(1+(num-1)*2)*y;
            ll tlen=len;
            len=y;
            y=tlen-y*num;

            ans+=y;
        }
    }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define deb(x) cout << #x << "=" << x << endl
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
int M=1e9+7,N=205001;

int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M



void solve() {
	int n,x,y;
	cin>>n;
	int a[n],b[n];
	rep(i,0,n){
		cin>>x>>y;
		a[i]=x+y;
		b[i]=x-y;
	}
	sort(a,a+n);
	sort(b,b+n);
	cout<<max(a[n-1]-a[0],b[n-1]-b[0]);
}


signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}





Measured memory_bytes: 6780
#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;

const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

int n;
vector<vector<int>> G;
vector<int> d;
vector<int> colors;

int mst(){
    int left = n;
    int res = 0;
    d[0] = 0;
    //int u = 0;
    while(left--){
        int min_id = -1;
        int cur_min = INT_MAX;
        for(int i = 0;i<n;i++){
            if(colors[i] !=BLACK && d[i] < cur_min){
                min_id = i;
                cur_min = d[i];
            }
        }
        if(min_id==-1) break;
        int u = min_id;
        //printf("%d\n",min_id);
        res += d[u];
        colors[u] = BLACK;
        for(int v =0;v<n;v++){
            if(colors[v]!=BLACK && G[u][v] < d[v]){
                d[v] = G[u][v];
            }
        }
    }
    return res;
}

int main()
{
    //freopen("data.txt","r",stdin);
    cin >> n;
    G.resize(n,vector<int>(n,INT_MAX));
    d.resize(n,INT_MAX);
    colors.resize(n,WHITE);
    int tmp;
    for(int i =0;i<n;i++){
        for(int j=0;j<n;j++){
            cin >> tmp;
            if(tmp!=-1) G[i][j] = tmp;
        }
    }
    cout << mst() <<endl;
    return 0;
}



Measured memory_bytes: 3160
#include <stdio.h>
#include <string.h>

int main(void)
{
	static char prime[1000001];
	static char ok[1000001];
	int i, j;
	int n, t;
	int a[30];
	int max;

	for (i = 3; i <= 1000000; i += 2) {
		prime[i] = 1;
	}
	prime[2] = 1;

	for (i = 3; i <= 1000; i += 2) {
		if (prime[i] == 1) {
			for (j = 3; j <= 1000000 / i; j += 2) {
				prime[i * j] = 0;
			}
		}
	}

	while (1) {
		scanf("%d%d", &t, &n);

		if (t + n == 0) {
			break;
		}

		for (i = 0; i < t; i++) {
			scanf("%d", &a[i]);
		}

		memset(ok, 0, sizeof(ok));
		ok[0] = 1;
		max = -100;
		for (i = 0; i < t; i++) {
			for (j = 0; j + a[i] <= n; j++) {
				if (ok[j] != 0) {
					ok[j + a[i]] = ok[j];
					if (j + a[i] > max && prime[j + a[i]]) {
						max = j + a[i];
					}
				}
			}
		}

		if (max != -100) {
			printf("%d\n", max);
		}
		else {
			printf("NA\n");
		}
	}

	return (0);
}

Measured memory_bytes: 4456
#include<iostream>
#include<cmath>
#include<algorithm>
 
using namespace std;
 
long long v;
int main(){
bool flag=0;
cin>>v;
if(v%10==7)flag=1;
else if((v/10)%10==7)flag=1;
else if((v/100)%10==7)flag=1;
if(flag==1)cout<<"Yes";
else cout<<"No";
return 0;
} 

Measured memory_bytes: 3636
#include <stdio.h>
#define NUMBER 100
int main(void)
{
    int a,b;
    char x[NUMBER];
    char y[NUMBER];
    char z[NUMBER];
    int i;
    
    scanf("%s %s",x,y);
    scanf("%d %d",&a,&b);
    scanf("%s",z);
    
    for (i = 0;z[i] != EOF;i++){
        if (z[i] != x[i]){
            b = b - 1;
            break;
        }
        else if (z[i] != y[i]){
            a = a - 1;
            break;
        }
    }
    
    printf("%d %d\n",a,b);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	int n;
	int a[100];
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	
	for(int j=n-1;j>0;j--)
		cout<<a[j]<<" ";
	cout<<a[0]<<endl;
	
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, k, ans = 0;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n) cin >> a[i], a[i]--;

  int logk = ceil(log2(k));
  vector<vector<ll>> doubling(logk, vector<ll>(n));
  rep(i, n) doubling[0][i] = a[i];

  rep(i, logk - 1) rep(j, n) doubling[i + 1][j] = doubling[i][doubling[i][j]];

  int now = 0;
  for (int i = 0; i < logk; ++i)
    if ((k >> i) & 1) now = doubling[i][now];

  cout << now + 1 << endl;
  return 0;
}


Measured memory_bytes: 100384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
        cin >> A[i];
    ll ans = 0;
    for (int i = 0; i < N-1; i++) {
        if (A[i]%2 == 1 && A[i+1] > 0) {
            ans++;
            A[i]--;
            A[i+1]--;
        }
    }
    for (int i = 0; i < N; i++) {
        ans += A[i]/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,ans;
  cin >> A >> B;
  ans = max(A,B);
  if (A == B) ans += A;
  else  ans += max(A,B)-1;
  cout << ans;
  

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k,ans;
struct Matrix{
    int m[55][55];
    Matrix(int n){
        rep(i,n){
            rep(j,n){
                m[i][j]=0;
            }
        }
    }
    Matrix operator*(Matrix a){
        Matrix res(n);
        rep(i,n){
            rep(j,n){
                rep(k,n){
                    res.m[i][j]+=m[i][k]*a.m[k][j];
                    res.m[i][j]%=mod;
                }
            }
        }
        return res;
    }
    Matrix pow(Matrix a,int b){
        if(b==1)return a;
        if(b%2){
            Matrix c=pow(a,b-1);
            return c*a;
        }
        else{
            Matrix c=pow(a,b/2);
            return c*c;
        }
    }
};
signed main(){
    cin>>n>>k;
    Matrix mat(n);
    rep(i,n){
        rep(j,n){
            cin>>mat.m[i][j];
        }
    }
    mat=mat.pow(mat,k);
    rep(i,n){
        rep(j,n){
            ans+=mat.m[i][j];
            ans%=mod;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif
 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const int EPS = 1e-9;



int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k,x,y;
  while(cin >> n >> k >> x >> y){
    TSTART();
    int ans;
    if(n <= k)ans = n*x;
    else ans = k*x + (n-k)*y;
    cout << ans << endl;
    TSTOP();
  }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf (1LL<<57)
#define PII pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define endl "\n"
const long long mod = 1e9 + 7;
typedef unsigned long long ull;
using namespace std;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
#define DBG cerr << "debug here" << endl;
#define DBGV(vari) cerr << #vari<< " = "<< (vari) <<endl;
/*============================================================================
rk
Deependra Chourasia
IIT(ISM) DHANBAD
16je001916

============================================================================
*/


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll k,x;
    cin>>k>>x;
    
    if(k*500LL >= x)cout<<"Yes\n";
    else cout<<"No\n";
    
}

Measured memory_bytes: 256
#yandy
N = int(input())
 
paths = []
 
for _ in range(N):
    x, y = map(int, input().split())
    paths.append((x, y))
 
all_path_len = 0
 
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        xa, ya = paths[i]
        xb, yb = paths[j]
        all_path_len += ((xa - xb) ** 2 + (ya - yb) ** 2) ** 0.5
 
ans = all_path_len / N
 
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define ld long double
#define mod 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,i,j,x,y,ansx=0,ansy=0,a[100006],b[100006];
	cin>>n>>m;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(j=0;j<m;j++)
	{
		cin>>b[j];
	}
	sort(a,a+n);
	sort(b,b+m);
	for(i=0;i<n;i++)
	{
		x=i*a[i];
		y=(n-1-i)*a[i];
		x-=y;
		while(x<0)
		{
			x+=mod;
		}
		x%=mod;
		ansx+=x;
		ansx%=mod;
	}
	
	for(i=0;i<m;i++)
	{
		x=i*b[i];
		y=(m-1-i)*b[i];
		x-=y;
		while(x<0)
		{
			x+=mod;
		}
		x%=mod;
		ansy+=x;
		ansy%=mod;
        //cout<<ansy<<endl;
	}
    //cout<<ansx<<" "<<ansy<<" ";
	cout<<(ansx*ansy)%mod;
	return 0;
}	

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

using namespace std;

using ll = long long;

const ll INF = 1e18;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll a, b;
    cin >> n >> a >> b;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
    }

    vector<ll> dp(n, 0);
    for (int i = 0; i < n; i++) {
        vector<ll> ndp(n, INF);
        ndp[p[i]] = dp[p[i]];
        for (int j = 0; j < n; j++) {
            if (dp[j] == INF || j == p[i]) continue;
            if (j < p[i]) ndp[p[i]] = min(ndp[p[i]], dp[j]);
            ndp[j] = dp[j];
            if (j > p[i]) ndp[j] += b;
            else ndp[j] += a;
        }
        dp = ndp;
    }

    ll ans = INF;
    for (int i = 0; i < n; i++) {
        ans = min(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  int sum[1001];

  sum[0] = 0;
  for(int i=1;i<=1000;i++)sum[i] = sum[i-1]+i;
    
  while(cin >> n && n){

    int ans = 0;
    for(int i=0;i<=n;i++){
      for(int j=0;j<i-1;j++){
	if(sum[i]-sum[j] == n)ans++;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int INF = (1<<30);
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() {
    string s;
    cin >> s;
    string ans = "";
    ans += s[0];
    ans += to_string(s.size()-2);
    ans += s[s.size()-1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    char n, h, w;
    cin >> n >> h >> w;
    if (n == h && n == w && n == 'R')
    {
        cout << 3 << endl;
    }
    else if (n != h && h != w)
    {
        cout << 1 << endl;
    }
    else if (n == h && n == w && n == 'S')
    {
        cout << 0 << endl;
    }
    else if ((n == h && n == 'S') || (h == w && h == 'S'))
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 2 << endl;
    }
}

Measured memory_bytes: 3636
import math
flag = 0
a,b = map(int,input().split())

for i in range(1,10000):
    if int(i*0.08) == a and int(i*0.1) == b:
        print(i)
        break
    elif i*0.08 > a and i*0.1 > b:
        print(-1)
        break

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <bits/stdint-intn.h>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
  int64_t n;
  std::cin >> n;

  std::cout << n * (n - 1) / 2 << std::endl;

  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    map<map<char,int>,int> m;
    ll ans = 0;
    rep(i,n) {
        string s;
        cin >> s;
        map<char,int> nm;
        for(char c : s) nm[c]++;
        m[nm]++;
        ans += m[nm]-1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 49152
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
using namespace std;

 
int main(){
    int n; cin >> n;
    vector<int> a(n);
    int num;
    int mi=INF;
    ll sum=0;
    rep(i,n){
        cin >> a[i];
        if(a[i]<0) num++;
        mi=min(mi,abs(a[i]));
        sum+=abs(a[i]);
    }
    if(num%2==0) cout << sum << endl;
    else cout << sum-mi*2 << endl;
return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int n,i,j,cost=0,min=5000000;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=-100;i<101;i++){
        cost = 0;
        for(j=0;j<n;j++){
            cost += (a[j]-i)*(a[j]-i);
        }if(cost<min){
            min=cost;
        }
    }printf("%d\n",min);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
const double eps=1e-5;
int a[maxn],n,k;
bool check(double mval)
{
	int cnt=0;
	for(int i=1;i<=n;i++)
		cnt+=floor(a[i]/mval);
	return cnt<=k;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	double l=0,r=1e9;
	while(r-l>eps)
	{
		double mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid;
	}
	printf("%d\n",(int)round(l+0.5));
}

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

int main(void)
{
    vector<int> v;
    
    for (int i = 0; i < 3; ++i) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    
    cout << v[0] << " " << v[1] << " " << v[2] << endl;
    
    return 0;
}


Measured memory_bytes: 3164
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	a := scanInts(m)

	sum := 0
	for i := 0; i < m; i++ {
		sum += a[i]
	}

	if sum > n {
		fmt.Fprintln(wr, -1)
	} else {
		fmt.Fprintln(wr, n-sum)
	}
}


Measured memory_bytes: 1884
#include <iostream>

int main()
{
    int n = 0;

    // input
    std::cin >> n;

    if (n < 0)
    {
        std::cout << "Error : out of range!" << std::endl;
    }

    int resident[4][3][10];

    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 10; ++k)
            {
                resident[i][j][k] = 0;
            }
        }
    }

    int b = 0;
    int f = 0;
    int r = 0;
    int v = 0;

    for (int i = 0; i < n; ++i)
    {
        std::cin >> b;
        std::cin >> f;
        std::cin >> r;
        std::cin >> v;

        resident[b - 1][f - 1][r - 1] += v;
    }

    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 10; ++k)
            {
                std::cout << " " << resident[i][j][k];
            }
            std::cout << std::endl;
        }
        if (3 != i)
        {
            for (int l = 0; l < 20; ++l)
            {
                std::cout << "#";
            }
            std::cout << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3096
import numpy as np
if __name__ == "__main__":
    N = int(input())
    A = [None]*N
    A = list(map(int, input().split()))
    flag_p = True
    max_a = max(A)
    max_idx = A.index(max_a)
    min_a = min(A)
    min_idx = A.index(min_a)
    if max_a < -min_a:
        flag_p = False
    
    print(N+N-1)
    
    if flag_p:
        #A = [a + max_a for a in A]
        for i in range(N):
            print(max_idx+1, i+1)
        
    else:
        #A = [a + min_a for a in A]
        for i in range(N):
            print(min_idx+1, i+1)

    if flag_p:
        for i in range(N-1):
            #A[i+1] += A[i]
            print(i+1, i+2)
    
    else:
        for i in range(N-1, 0, -1):
            #A[i-1] += A[i]
            print(i+1, i)

Measured memory_bytes: 12504
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <algorithm>
#include <cstdio>

#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; i++)
#define DOW(i, a, b) for(int i = (a), _b = (b); i >= _b; i--)

using namespace std;

const int MAXN = 200;
long long w[MAXN], v[MAXN], f[MAXN * 3][MAXN];

int main() {
  ios::sync_with_stdio(false);
  int n;
  long long S;
  while (cin >> n >> S) {
    FOR(i, 1, n) cin >> w[i] >> v[i];
    long long W1 = w[1];
    DOW(i, n, 1) w[i] -= w[1];
    long long res = 0;
    FOR(m, 0, n) {
      long long s = min(S - m * W1, (long long) m * 3);
      if (s < 0) continue;
      memset(f, 0, sizeof(f));
      FOR(i, 1, n) {
        // f[k][j]: max value of j bag, w = k
        DOW(k, s, 0) DOW(j, m, 1) {
          if (k >= w[i]) f[k][j] = max(f[k][j], f[k-w[i]][j-1] + v[i]);
        }
      }
      FOR(k, 0, s) FOR(j, 0, m) res = max(res, f[k][j]);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n, m;
		String before[] = new String[100];
		String after[] = new String[100];
		String a;
		
		n = scanner.nextInt();
		while (n != 0) {
			for (int i = 0; i < n; i++) {
				before[i] = scanner.next();
				after[i] = scanner.next();
			}
			m = scanner.nextInt();
			for (int i = 0; i < m; i++) {
				a = scanner.next();
				for (int j = 0; j < n; j++) {
					if (a.equals(before[j])) {
						a = after[j];
						break;
					}
				}
				System.out.print(a);
			}
			System.out.println();
			n = scanner.nextInt();
		}
	}
}

Measured memory_bytes: 13000
// 1827
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    string sa, sb, sc, current; cin >> sa >> sb >> sc;
    reverse(sa.begin(), sa.end());
    reverse(sb.begin(), sb.end());
    reverse(sc.begin(), sc.end());

    char c = 'a';
    char ans;

    while(true) {
        if(c == 'a') {
            if(sa.empty()) {
                ans = 'A';
                break;
            }
            c = sa[sa.size() - 1];
            sa.pop_back();
        }

        else if(c == 'b') {
            if(sb.empty()) {
                ans = 'B';
                break;
            }
            c = sb[sb.size() - 1];
            sb.pop_back();
        }

        else {
            if(sc.empty()) {
                ans = 'C';
                break;
            }
            c = sc[sc.size() - 1];
            sc.pop_back();
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3572