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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int sol(string s){
  int vs=0;
  for(int i=0;i<s.length();i++){
    if(s[i]=='m'){
      if(i==0) vs+=1000;
      else if('0'<=s[i-1]&&s[i-1]<='9') vs+=(s[i-1]-'0')*1000;
      else vs+=1000;
    }
    if(s[i]=='c'){
      if(i==0) vs+=100;
      else if('0'<=s[i-1]&&s[i-1]<='9') vs+=(s[i-1]-'0')*100;
      else vs+=100;
    }
    if(s[i]=='x'){
      if(i==0) vs+=10;
      else if('0'<=s[i-1]&&s[i-1]<='9') vs+=(s[i-1]-'0')*10;
      else vs+=10;
    }
    if(s[i]=='i'){
      if(i==0) vs+=1;
      else if('0'<=s[i-1]&&s[i-1]<='9') vs+=(s[i-1]-'0');
      else vs+=1;
    }
  }
  return vs;
}

int main(){
  int q;
  cin >> q;
  string s,tt;
  string ans;
  int vs,vt;
  for(int t=0;t<q;t++){
    cin >> s >> tt;
    vs=sol(s);
    vt=sol(tt);
    // cout << vs SP vt << endl;
    vs+=vt;
    ans="";
    // cout << vs << endl;
    if(vs/1000>0){
      if(vs/1000>1){
        ans+=string(1,(vs/1000)+'0');
      }
      ans+="m";
    }
    vs%=1000;
    if(vs/100>0){
      if(vs/100>1){
        ans+=string(1,(vs/100)+'0');
      }
      ans+="c";
    }
    vs%=100;
    if(vs/10>0){
      if(vs/10>1){
        ans+=string(1,(vs/10)+'0');
      }
      ans+="x";
    }
    vs%=10;
    if(vs>0){
      if(vs>1){
        ans+=string(1,(vs)+'0');
      }
      ans+="i";
    }
    cout << ans << endl;
  }
  return 0;
}



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

using ll=long long;
using int64=int64_t;
const int inf=100000000;

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

int fib(int x){
  if (x <= 2) return x;
  int a[x];
  a[0]=1;
  a[1]=2;
  for (int i=2;i<x;i++){
    a[i]=a[i-1]+a[i-2];
  }
  return a[x-1];
}//(x) フィボナッチ数列のx番目

int div1(ll x){
  return x%1000000007;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/arc081_a.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }

  sort(c.begin(), c.end(), greater<ll>());
  vector<ll> a(2, 0);
  int j = 0;
  rep(i, N - 1) {
    if (c[i] == c[i + 1]) {
      a[j++] = c[i];
      i++;
    }
    if (j > 1) break;
  }

  cout << a[0] * a[1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define MAXN	524288
#define P	924844033
#define G	5
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
struct number {long long x; };
number operator + (number a, number b) {return (number) {(a.x + b.x) % P}; }
number operator - (number a, number b) {return (number) {(a.x - b.x + P) % P}; }
number operator * (number a, number b) {return (number) {(a.x * b.x) % P}; }
number power(number x, long long y) {
	if (y == 0) return (number) {1};
	number tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp;
	else return tmp * tmp * x;
}
vector <int> a[MAXN];
int b[MAXN], size[MAXN], N, Log, n, home[MAXN];
number c[MAXN], d[MAXN], res[MAXN];
long long fac[MAXN], inv[MAXN];
void PREBRC() {
	for (int i = 0; i < N; i++) {
		int res = 0, tmp = i;
		for (int j = 1; j <= Log; j++) {
			res = (res << 1) + (tmp & 1);
			tmp >>= 1;
		}
		home[i] = res;
	}
}
void NTT(number *a, int type) {
	for (int i = 0; i < N; i++)
		if (home[i] > i) swap(a[i], a[home[i]]);
	for (int len = 2; len <= N; len <<= 1) {
		number eps = power((number) {G}, (P - 1) / len);
		if (type == -1) eps = power(eps, P - 2);
		for (int i = 0; i < N; i += len) {
			number now = (number) {1};
			for (int j = i, k = i + len / 2; k < i + len; j++, k++) {
				number tmp = a[j];
				number tnp = a[k] * now;
				a[j] = tmp + tnp;
				a[k] = tmp - tnp;
				now = now * eps;
			}
		}
	}
	if (type == -1) {
		number INV = power((number) {N}, P - 2);
		for (int i = 0; i < N; i++)
			a[i] = a[i] * INV;
	}
}
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
void work(int pos, int fa) {
	size[pos] = 1;
	for (unsigned i = 0; i < a[pos].size(); i++)
		if (a[pos][i] != fa) {
			work(a[pos][i], pos);
			size[pos] += size[a[pos][i]];
		}
	if (fa != 0) {
		b[size[pos]]--;
		b[n - size[pos]]--;
	}
}
long long getc(int x, int y) {
	if (x < y) return 0;
	else return fac[x] * inv[y] % P * inv[x - y] % P;
}
int main() {
	read(n);
	for (int i = 1; i < n; i++) {
		int x, y;
		read(x), read(y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	work(1, 0);
	for (int i = 0; i < n; i++)
		b[i] = (b[i] + P) % P;
	b[n] = n;
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
	for (int i = 0; i <= n; i++) {
		c[i] = (number) {fac[n - i] * b[n - i] % P};
		d[i] = (number) {inv[i]};
	}
	N = 1, Log = 0;
	while (N <= 2 * n + 2) {
		N <<= 1;
		Log++;
	}
	PREBRC();
	NTT(c, 1);
	NTT(d, 1);
	for (int i = 0; i < N; i++)
		res[i] = c[i] * d[i];
	NTT(res, -1);
	for (int i = 1; i <= n; i++)
		printf("%lld\n", inv[i] * res[n - i].x % P);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

const int MOD = 1000000007;

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> x(N);
    rep(i, N) cin >> x[i];

    long long ans = 1000100010001000;
    rep(i, N) {
        if (i + K - 1 == N) break;
        long long minusLen = 0;
        long long plusLen = 0;
        if (x[i] < 0) {
            minusLen = -1 * x[i];
        }

        if (x[i + K - 1] > 0) {
            plusLen = x[i + K - 1];
        }

        long long len = min(minusLen * 2 + plusLen, minusLen + plusLen * 2);
        chmin(ans, len);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    bool x = true;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }
    if(a[0]) x = false;

    ll ans = 0;
    rep(i, n-1) {
        if(a[i]+1 < a[i+1]) x = false;
        if(a[i] >= a[i+1]) {
            ans += a[i+1];
        } else {
            ans++;
        }
    }

    cout << (x ? ans:-1) << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int x = n;
	vi v;
	int ans = 1e9;
	rep(i, 1, sqrt(n))
	{
		if (n % i == 0)
		{
			string s1, s2;
			s1 = to_string(i);
			s2 = to_string(n / i);
			int var = max(s1.size(), s2.size());
			ans = min(ans, var);
		}
	}
	cout << ans << en;
	//sarasr galat approch its very easy maha gadha i am:)
	// while (x % 2 == 0)
	// {
	// 	x /= 2;
	// 	v.pb(2);
	// }
	// for (int i = 3; i <= sqrt(x); i += 2)
	// {
	// 	while (x % i == 0)
	// 	{
	// 		x /= i;
	// 		v.pb(i);
	// 	}
	// }
	// if (x > 2)
	// 	v.pb(x);
	// int var = 1;
	// int y = sqrt(n);
	// zip(i, 0, v.size())cout << v[i] << " "; cout << en;
	// // if (y * y == n)
	// // {
	// // 	string s = to_string(y);
	// // 	cout << s.size() << en;
	// // 	return 0;
	// // }
	// zip(i, 0, v.size())
	// {
	// 	if (n / v[i] >= y)
	// 	{
	// 		n = n / v[i];
	// 		var = var * v[i];
	// 	}
	// 	else
	// 	{
	// 		break;
	// 	}
	// }
	// cout << n << en << var << en;
	// string s1, s2;
	// s1 = to_string(n);
	// s2 = to_string(var);
	// cout << max(s1.size(), s2.size()) << en;


	return 0;
}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef pair<int64, int64> pii;
int64 dp[2002][2002];
int main(){
	int n; cin >> n;
    vector<pii> A(n + 1);
    for(int64 i = 1; i <= n; i++){
    	cin >> A[i].first;
        A[i].second = i;
    }
    sort(A.begin() + 1, A.end());

    int64 ans = 0;
    memset(dp, 0, sizeof(dp));
  	for(int64 l = n; l >= 1; l--){
    	for(int64 i = 1; i <= n - l + 1; i++){
          int64 j = i + l - 1;
          if(l == 1){
          	  ans = max(ans, dp[i][j] + (int64)A[l].first * abs(A[l].second - i));
          }
          else{
          	  dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + A[l].first * abs(A[l].second - i));
              dp[i][j - 1] = max(dp[i][j - 1], dp[i][j] + A[l].first * abs(A[l].second - j));
          }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}

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

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

using namespace std;

int main(){
	int a,b,c; cin>>a>>b>>c;
	cout<<max({10*a+b+c,10*b+c+a,10*c+a+b})<<endl;

	return 0;
}


Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toLong() }
    val total = a.sum()
    var subTotal = a.first()
    var ans = Math.abs(total - subTotal * 2)
    for(i in (1..a.lastIndex-1)) {
        subTotal += a[i]
        ans = Math.min(ans, Math.abs(total - subTotal*2))
    }
    println(ans)
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int ans = int.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                int temp = 0;
                foreach (int x in a)
                {
                    temp += (int)Math.Pow(x - i, 2);
                }
                ans = Math.Min(ans, temp);
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> color(3,0);
    ll ans = 1;
    rep(i,n){
        int cnt = 0;
        rep(j,3){
            if(a[i] == color[j]) cnt ++;
        }
        ans *= cnt;
        rep(j,3){
            if(a[i] == color[j]){
                color[j] ++;
                break;
            }
        }
        
        if(ans >= MOD) ans %= MOD;
    }
    cout << ans << endl;

    return 0;  
}

Measured memory_bytes: 640
def gcd(A, B):
    while B != 0:
        A, B = B, A%B
    return A
N, X = map(int, input().split())
x = [abs(int(i) - X) for i in input().split()] 
y = x[0]
for i in range(N):
    if x[i] % y == 0:
        continue
    y = gcd(y, x[i])
print(y)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
using namespace std;
#define MOD (int)(1e9 + 7)
#define ll long long

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	vector<int> v(3);
	for(int i = 0; i < 3; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	cout << v[0] * v[1] / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

//ただの辺
struct edge {
    int to;
    lint cost;
    //引数一つの時は距離1
    edge(int t, lint c = 1) : to(t), cost(c) {
    }
};

// dijkstra
// depend:edge
vector<long long int> dijkstra(vector<vector<edge>>& g, int start) {
    vector<lint> res(g.size(), LLONG_MAX);
    res[start] = 0;
    // first:距離、second:行き先
    priority_queue<pair<lint, lint>, vector<pair<lint, lint>>,
                   greater<pair<lint, lint>>>
        pq;
    pq.push({0, start});
    while (!pq.empty()) {
        lint dist = pq.top().first, now = pq.top().second;
        pq.pop();
        if (res[now] < dist) continue;
        for (int i = 0; i < (int)g[now].size(); i++) {
            edge e = g[now][i];
            if (res[e.to] > res[now] + e.cost) {
                res[e.to] = res[now] + e.cost;
                pq.push(make_pair(res[e.to], e.to));
            }
        }
    }
    return res;
}

int main() {
    int n, m, r;
    cin >> n >> m >> r;
    vector<vector<edge>> g(n);
    for (int i = 0; i < m; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        g[s].push_back(edge(t, d));
    }
    vector<lint> dist = dijkstra(g, r);
    for (int i = 0; i < n; i++) {
        if (dist[i] == LLONG_MAX) {
            cout << "INF" << endl;
        } else {
            cout << dist[i] << endl;
        }
    }
}


Measured memory_bytes: 19360
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int pre = min(x,y);
    ll sum = pre*min(a+b,2*c);
    x -= pre;
    y -= pre;
    if(x>0){
        sum += x*min(a,2*c);
    }else if(y>0){
        sum += y*min(b,2*c);
    }
    cout << sum << endl;
    return 0;
}



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

namespace AtcoderTemplateForCSharp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var s = Console.ReadLine();

            Console.WriteLine("2018/01/" + s.Substring(8));
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		String op = sc.next();
		int B = sc.nextInt();

		if ("+".equals(op)) {
			System.out.println(A + B);
		} else {
			System.out.println(A - B);
		}
	}
}

Measured memory_bytes: 9680
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9+5;
const int mod = 1e9+7;
using ll = long long;

signed main(){
    int n;
    cin >> n;
    vector<string> a(n);
    map<char,int> m;
    rep(i,n) {
        cin >> a[i];
        m[a[i][0]]++;
    }
    vector<int> c;
    c.push_back(m['M']);
    c.push_back(m['A']);
    c.push_back(m['R']);
    c.push_back(m['C']);
    c.push_back(m['H']);
    
    int ans = 0;
    rep(i,5) {
        FOR(j,i,5) {
            FOR(k,j,5) {
                if(i==j || j==k || k==i)continue;
                ans += c[i]*c[j]*c[k];
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6408
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a, b, c;
const int maxn = 1e5 + 1000;
int dp[maxn][3];
int f(int at, int prev)
{
	if(at == n)
		return 0;
	if(dp[at][prev] != -1)
		return dp[at][prev];
		
	if(prev == 0)
	{
		int type1 = f(at + 1, 1) + b[at];
		int type2 = f(at + 1, 2) + c[at];
		return dp[at][prev] = max(type1,type2);
	}
	else if(prev == 1)
	{
		int type0 = f(at+1,0) + a[at];
		int type2 = f(at+1,2) + c[at];
		return dp[at][prev] =  max(type0,type2);
	}
	else
	{
		int type1 = f(at + 1, 1) + b[at];
		int type0 = f(at+1,0) + a[at];
		return dp[at][prev] = max(type0,type1);
	}
}
int main()
{
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i =0;i<n;i++)
	{
		int q,w,e;
		cin>>q>>w>>e;
		a.push_back(q);
		b.push_back(w);
		c.push_back(e);
	}
	int fir = f(0,0);
	int sec = f(0,1);
	int thir = f(0,2);
	cout<<max(fir,max(sec,thir));
	return 0;
}

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

int main() {
  int N,M,A,X;
  cin >> N;
  vector<string> B(N);
  for (int i=0;i<N;i++){
    cin >> B.at(i);
  }
  cin >> M;
  vector<string> R(M);
  for (int i=0;i<M;i++){
    cin >> R.at(i);
  }

  X=0;
  for (int i=0;i<N;i++){
    A=1;
    for (int j=i+1;j<N;j++){
      if(B.at(i)==B.at(j)){
        A++;
      }
    }
    for (int j=0;j<M;j++){
      if(B.at(i)==R.at(j)){
        A--;
      }
    }
    if(A>X){
      X=A;
    }
  }
  cout << X << endl;
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void printVec(vector<int>& vec) {
    for (auto& e : vec) {
        cout << e << " ";
    }
    cout << endl;
}

int func(long long a, long long b) {
    // cout << fixed << setprecision(8);
    if (a > b * 2) {
        cout << a - b * 2 << endl;

    } else {
        cout << 0 << endl;
    }

    return 0;
}

int main() {
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);

    func(A, B);

    return 0;
}


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

using ll = long long;
constexpr ll inf = static_cast<ll>(1e15);
constexpr ll mod = static_cast<ll>(1e9 + 7);

int in[6];
int pre[5] = { 0,1,2,3,4 };
int main()
{
	for (int i = 0; i < 5; ++i)
		std::cin >> in[i];

	int ans = 1000000000;
	do {
		int res = 0;
		for (int i = 0; i < 5; ++i) {
			res += in[pre[i]];

			if (res % 10 != 0 && i != 4)
				res = (res / 10 + 1) * 10;
		}

		ans = std::min(ans, res);
	} while (std::next_permutation(pre, pre + 5));

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double[] v = new double[n];
    for(int i = 0; i < n; i++) {
      v[i] = sc.nextDouble();
    }
    Arrays.sort(v);
    double ans = (v[0] + v[1]) / (double)2;
    for(int i = 2; i < n; i++) {
      ans = (ans + v[i]) / (double)2;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 37556
using System;
using System.Collections.Generic;

namespace test
{

    class Program
    {
        static int[] primeArray = new int[50022];

        static void Main(string[] args)
        {
            SetPrime();

            List<int[]> list = new List<int[]>();
            string input;
            while ((input = Console.ReadLine()) != null)
            {
                int n = int.Parse(input);
                int small = n - 1;
                int big = n + 1;

                while (true)
                {
                    if (primeArray[small] != 0)
                    {
                        break;
                    }
                    small--;
                }

                while (true)
                {
                    if (primeArray[big] != 0)
                    {
                        break;
                    }
                    big++;
                }

                int[] ans = { small, big };
                list.Add(ans);                
            }

            foreach (int[] a in list)
            {
                Console.WriteLine("{0} {1}",a[0],a[1]);
            }

        }


        static void SetPrime()
        {
            primeArray[2] = 1;
            int primeNum = 2;

            List<int> serchList = new List<int>();
            for (int i = 3; i <= 50022; i += 2)
            {
                serchList.Add(i);
            }

            List<int> tmpList = new List<int>();
            while (true)
            {
                int prime = serchList[0];
                primeArray[prime] = primeNum;
                primeNum++;

                if (prime > Math.Sqrt(serchList[serchList.Count - 1]))
                {
                    break;
                }

                for (int k = 0; k < serchList.Count; k++)
                {
                    if (serchList[k] % prime != 0)
                    {
                        tmpList.Add(serchList[k]);
                    }
                }

                serchList = new List<int>(tmpList);
                tmpList.Clear();
            }

            for (int j = 1; j < serchList.Count; j++)
            {
                primeArray[serchList[j]] = primeNum;
                primeNum++;
            }

        }

    }

}

Measured memory_bytes: 6528
use std::io::prelude::*;
use std::str::FromStr;
pub struct Scanner<R: Read>(R);
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Self {
        Self(reader)
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| (b as char).is_whitespace())
            .take_while(|&b| !(b as char).is_whitespace())
            .collect::<Vec<u8>>();
        unsafe { std::str::from_utf8_unchecked(token.as_slice()) }
            .parse()
            .ok()
            .expect("Can't parse it.")
    }
    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let mut sc = Scanner::new(stdin.lock());
    let mut out = std::io::BufWriter::new(stdout.lock());
    solve(&mut sc, &mut out);
    out.flush().ok().unwrap();
}
fn solve(sc: &mut Scanner<std::io::StdinLock>, out: &mut std::io::BufWriter<std::io::StdoutLock>) {
    let mut s: String = sc.read();

    let pat = ["dream", "dreamer", "erase", "eraser"];
    while s.len() > 0 {
        let found = pat.iter().find(|&&p| s.ends_with(p));

        if let Some(&p) = found {
            s.truncate(s.len() - p.len());
        } else {
            break;
        }
    }

    println!("{}", if s.len() == 0 { "YES" } else { "NO" });
}


Measured memory_bytes: 2272
N, M, Q = map(int, input().split())

a,b,c,d = [], [], [], []
for i in range(Q):
    tmp_a, tmp_b, tmp_c, tmp_d = map(int, input().split())
    a.append(tmp_a)
    b.append(tmp_b)
    c.append(tmp_c)
    d.append(tmp_d)

import itertools

ans = {}

for j in itertools.combinations_with_replacement(range(1,M+1), N):
    ans[j] = 0
    for i in range(Q):
        if j[b[i]-1]-j[a[i]-1] == c[i]:
            ans[j] += d[i]
print(max(ans.values()))

Measured memory_bytes: 30616
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [u32; n],
    }
    let mut x: u32 = 0;
    for e in a.iter() {
        x ^= e;
    }
    for e in a.iter() {
        print!("{} ", x ^ e);
    }
    println!("");
}


Measured memory_bytes: 5544
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <deque>

using namespace std;

typedef long long ll;

int main()
{
	string s;
	cin >> s;
	int q;
	cin >> q;
	
	std::deque<char> chars(s.begin(), s.end());
	bool reversed = false;

	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			reversed = !reversed;
		}
		else
		{
			int f; char c;
			cin >> f;
			cin >> c;

			if ( f== 1)
			{
				if (reversed)
				{
					chars.push_back(c);
				}
				else
				{
					chars.push_front(c);
				}
			}
			else {
				if (reversed)
				{
					chars.push_front(c);
				}
				else {
					chars.push_back(c);
				}
			}
		}
	}

	if (reversed) {
		for (auto itr = chars.rbegin(); itr != chars.rend(); ++itr) {
			std::cout << *itr;
		}
	}
	else {
		for (auto itr = chars.begin(); itr != chars.end(); ++itr) {
			std::cout << *itr;
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define mp(x,y) make_pair(x,y)
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int W, H;
char s[100][100];
bool used[100][100];
bool f = 1;

tuple<int, int, int> bfs(pair<int, int> now, set<pair<int, int>> &nxt){
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
    queue<pair<int, int>> que;
    que.push(now);
    int g = 0;
    set<pair<int, int>> nowp, nowp_under;

    while(!que.empty()) {
        pair<int, int> p = que.front();
        used[p.first][p.second] = 1;
        que.pop();
        nowp.insert(p);
        if(p.first == H-1 || (s[p.first][p.second] != s[p.first+1][p.second] && s[p.first+1][p.second] != '.')) nowp_under.insert(p);
        for(int i = 0; i < 4; i++) {
            char nowc = s[now.first][now.second];
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
            if(used[ny][nx]) continue;

            if(s[ny][nx] == nowc) que.push(mp(ny, nx));
            // nowの真上のブロックが異なるブロック
            if(i == 2 && s[ny][nx] != '.' && s[ny][nx] != nowc) nxt.insert(mp(ny, nx));
        }
    }
    int l = INF, r = -INF;
    repe(i, nowp_under){
        chmin(l, i.second);
        chmax(r, i.second);
    }
    repe(i, nowp) g += i.second;
    // 自分の重心と, 自分の下端
    return tie(g, l, r);
}

pair<int, int> rec(pair<int, int> now){
    set<pair<int, int>> nxt;
    int g, l, r;
    tie(g, l, r) = bfs(now, nxt);
    int tmp = 1;
    repe(i, nxt){
        if(!used[i.first][i.second]){
            auto j = rec(i);
            g += j.first;
            tmp += j.second;
        }
    }
    // cout << now.first << ":" << now.second << "=" << 1.*g/4/tmp << "/" << 0.+l-0.5 << "," << 0.+r+0.5 << " " << tmp << endl;
    if(!((4*l-2)*tmp < g && g < (4*r+2)*tmp)){
        f = 0;
    }
    return mp(g, tmp);
}

int main(){
    cin >> W >> H;
    while(W > 0){
        rep(i, H)rep(j, W){
            cin >> s[i][j];
        }
        memset(used, 0, sizeof(used));
        f = 1;

        rep(i, W){
            if(s[H-1][i] != '.'){
                rec(mp(H-1, i));
                break;
            }
        }
        cout << (f ? "STABLE" : "UNSTABLE") << endl;
        cin >> W >> H;
    }
}


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

typedef long long ll;

#define sz(v) (int)v.size()

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
}

int main() {
	PLAY();

	string s, t;
	cin >> s >> t;
	
	int res = INT_MAX;

	for (int i = 0; i <= sz(s) - sz(t); i++) {
		int cnt = 0, T = 0;
		for (int j = i, tY = 0; tY < sz(t); j++, tY++) {
			if (s[j] != t[tY])
				cnt++;
		}
		res = min(res, cnt);
	}
	cout << res << endl;

	return 0;
}


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

bool square(int x)
{
	int sq = (int)sqrt(x);

	return sq * sq == x;
}

int main(void)
{
	int n, t, i, j, in, ans;

	scanf("%d", &n);

	for (t = 1; t <= n; t++)
	{
		ans = 0;
		in = t * 2;

		for (i = 2; i * i <= in; i++)
		{
			int v1 = in - i * i;

			for (j = 2; j * j <= v1; j++)
			{
				int v2 = v1 - j * j;

				if (square(v2))
				{
					int p1 = i;
					int p2 = j;
					int p3 = (int)sqrt(v2);

					int all = (p1 + p2 + p3) / 2;

					if (all - p1 > 0 && all - p2 > 0 && all - p3 > 0)
						ans++;
				}
			}
		}

		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 2124
#include <iostream>
using namespace std;
int main(void)
{
	for (;;)
	{
		int a,b;
		char d,e;
		int f;
		char g;
		int h;
		char c[2][100000]={0};
		char C[2][100000]={0};
		cin>>a;
		if (a==0)
		{
			break;
		}
		for (b=0;b<a;b++)
		{
			cin>>d>>e;
			c[0][b]=d;
			c[1][b]=e;
		}
		cin>>f;
		for (h=0;h<f;h++)
		{
			cin>>g;
			C[0][h]=g;
			for (b=0;b<a;b++)
			{
				if (C[0][h]==c[0][b])
				{
					C[1][h]=c[1][b];
					break;
				
				}
				else if (C[0][h]!=c[0][b])
				{
					C[1][h]=C[0][h];
				}
			}
		}
		for (h=0;h<f;h++)
		{
			cout<<C[1][h];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3452
#include<iostream>
#include<cstring>
#include<cstdio>
#include<unordered_map>
#include<string>
#include<algorithm>
#include<set>
using namespace std;
const int N = 200 + 5;
const int INF = 0x3f3f3f3f;

int ans;
bool visit[10];
int mat[N][N];

void Init(){
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++) mat[i][j] = (i!=j?INF : 0);
}
void Solve(int n){
    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= n; j++){
        for(int k = 1; k <= n; k++)
            mat[j][k] = min(mat[j][i] + mat[i][k], mat[j][k]);
    }
}
int a[N];
int main(){
    int n, m, r, x, y, c;
    Init();
    cin >> n >> m >> r;
    for(int i = 0; i < r; i++){
        cin >> a[i];
    }
    for(int i = 1; i <=m; i++){
        cin >> x >> y >> c;
        if(c < mat[x][y] || c < mat[y][x]) mat[x][y] = mat[y][x] = c;
    }
    Solve(n);
    sort(a, a + r);
    int ans = INF;
    do{
        int tmp = 0;
        for(int i = 0; i < r - 1; i++)
         tmp += mat[a[i]][a[i+1]];
        ans = min(ans, tmp);
    }while(next_permutation(a, a+r));
    cout << ans << endl;
}


Measured memory_bytes: 384
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  bool ans = abs(A - B) <= (V - W) * T;
  cout << (ans ? "YES" : "NO") << endl;
}


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

int main()
{
    int n,q;
    cin>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    cin>>q;
    REP(i,q)
    {
        int k;
        cin>>k;
        cout<<lower_bound(a.begin(),a.end(),k)-a.begin()<<endl;
    }
}


Measured memory_bytes: 3104
nums = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(nums[k-1])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int n, a[20];
bool table[40005];

void init() {
    for (int bit = 0; bit < (1 << n); bit++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            if (bit & (1 << j)) sum += a[j];
        }
        table[sum] = true;
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    init();
    int q;
    cin >> q;
    for (int i = 0, m; i < q; i++) {
        cin >> m;
        if (table[m]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

bool is_sq(int a) {
    int sq = (int) sqrt(a);
    return sq * sq == a;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    int x[n][d];
    rep(i, n) rep(j, d) cin >> x[i][j];
    int cnt = 0;

    rep(i, n) REP(j, i + 1, n) {
        int sum = 0;
        rep(k, d) sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
        if (is_sq(sum)) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T>
T mod_pow(T a,long long n,T mod){
  using ll = long long;
  T res(1);
  while(n){
    if(n&1) res=(ll)res*a%mod;
    a=(ll)a*a%mod;
    n>>=1;
  }
  return res;
}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,p;
  cin>>n>>p;
  string s;
  cin>>s;

  if(p==2 or p==5){
    Int ans=0;
    for(Int i=0;i<n;i++){
      Int k=s[i]-'0';
      if(k%p==0) ans+=i+1;
    }
    cout<<ans<<newl;
    return 0;
  }

  Int ans=0,sum=0,cof=1;
  vector<Int> cnt(p,0);
  cnt[0]++;
  for(Int i=0;i<n;i++){
    cof*=mod_pow(10LL,p-2,p);
    cof%=p;
    sum+=(s[i]-'0')*cof;
    sum%=p;
    ans+=cnt[sum];
    cnt[sum]++;
  }

  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=200050;
char s[N];
int Solve(char p, int l, int r)
{
	if(l>r) return 0;
	if(l==r){ return p==s[l]?0:1;}
	if(s[l]==p) return 1+Solve('0',l+2,r);
	return 1+Solve(s[l],l+1,r);
}
int main()
{
	int n;
	scanf("%s",s+1);
	n=strlen(s+1);
	printf("%i\n",Solve('0',1,n));
	return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[200000];
    int b[200000];
    int i;
    for(int j=2;j<=n;j++)
    b[j]=0;
    
    for(i=2;i<=n;i++){
    cin>>a[i];
    b[a[i]]++;
    }
    // int k=n-m.size();
    // while(n--)
    // {
    //     for(auto &it:m)
    //     cout<<it.second<<endl;
    //     while(k--)
    //     cout<<"0"<<endl;
    // }
    for(i=1;i<=n;i++)
    cout<<b[i]<<endl;
}


Measured memory_bytes: 5192
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    mod = 10**9 + 7

    s = input().rstrip()
    n = len(s)
    dp = [[0]*13 for _ in range(n)]

    if s[-1]=='?':
        for i in range(10):
            dp[0][i] = 1
    else:
        a = int(s[-1])
        dp[0][a] = 1

    a = 1
    for i in range(1, n):
        a = 10 * a % 13
        if s[-(i+1)] == '?':
            for j in range(10):
                for k in range(13):
                    dp[i][(a*j+k)%13] += dp[i-1][k] % mod
        else:
            j = int(s[-(i+1)])
            for k in range(13):
                dp[i][(a*j+k)%13] += dp[i-1][k] % mod
    print(dp[-1][5]%mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61868
#include<iostream>
int main(){
	int N;
	int a, b, c;
	std::cin >> N;
	for(int i = 0; i < N; i++){
		std::cin >> a >> b >> c;
		if (a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
def f(x, y):
  c = 6
  for a, b in zip(A, B)[::-1]:
    if x > a or y > b: break
    c -= 1
  return c

A = range(60, 180, 20)
B = [2] + range(5, 30, 5)
C = range(600, 1800, 200)

while 1:
  n = input()
  if n==0: break
  s = 0
  for _ in [0]*n:
    x, y, h, w = map(int, raw_input().split())
    r = f(x+y+h, w)
    if r<6: s += C[r]
  print s

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  int tans=0,hans=0;
  for(int i=0;i<n;i++){
    string a,b;cin >> a >> b;
    if(a>b) tans +=3;
    else if(b>a) hans +=3;
    else{
      hans++;
      tans++;
    }
  }
  cout << tans << " " << hans << endl;
}



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

int main(){
  int count=0;
  int N;
  cin>>N;
  vector<pair<pair<string,int>,int>>rest(N);
  rep(i,N){
    cin>>rest[i].first.first>>rest[i].first.second;
    rest[i].second=i+1;
    rest[i].first.second=rest[i].first.second*-1;
  }
  sort(rest.begin(), rest.end());
  rep(i,N){
    cout<<rest[i].second<<endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

class node{
public:
  ll val=0;
  ll parent;
  vector<ll> child_ids;
};

void maketree(ll id, vector<vector<ll>>& edges, vector<node>& nodes){
  ll i;
  ll child;
  ll N = edges[id].size();
  for(i=0;i<N;i++){
    child = edges[id][i];
    if(child != nodes[id].parent){
      nodes[id].child_ids.push_back(child);
      nodes[child].parent = id;
      maketree(child,edges,nodes);
    }
  }
}

void add(ll id, vector<node>& nodes){
  ll i;
  ll child_id;
  ll N = nodes[id].child_ids.size();
  for(i=0;i<N;i++){
    child_id = nodes[id].child_ids[i];
    nodes[child_id].val += nodes[id].val;
    add(child_id,nodes);
  }
}

int main(int argc, const char * argv[]) {
  ll i,j;
  ll a,b;
  ll N, Q;
  cin >> N >> Q;
  vector<vector<ll>> edges(N);
  for(i=0;i<N-1;i++){
    cin >> a >> b;
    a-=1;b-=1;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  vector<node> nodes(N);
  nodes[0].parent = -1;
  maketree(0,edges,nodes);
  
  ll p,x;
  for(i=0;i<Q;i++){
    cin >> p >> x;
    p -= 1;
    nodes[p].val += x;
  }
  add(0,nodes);
  for(i=0;i<N;i++){
    cout << nodes[i].val << ' ';
  }
}


Measured memory_bytes: 46080
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  string a, b;
  cin >> a >> b;
  if(a.size() > b.size())cout << "GREATER" << endl;
  else if(a.size() < b.size())cout << "LESS" << endl;
  else if(a < b)cout << "LESS" << endl;
  else if(a > b)cout << "GREATER" << endl;
  else cout << "EQUAL" << endl;
	return 0;
}


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

ll n,k;

double ex(ll p)
{
  return (p+1)/2.0;
}

int main()
{
  cin >> n >> k;
  vector<double> v(n);
  rep(n)
  {
    ll p;
    cin >> p;
    v[i] = ex(p);
  }

  double tmp = 0;
  ll cur = 0;
  while( cur < k )
  {
    tmp += v[cur];
    cur++;
  }

  double M = tmp;

  while( cur < n )
  {
    tmp += v[cur] - v[cur-k];
    if ( M < tmp ) M = tmp;
    cur++;
  }

  printf("%.16lf",M);
  
  
  return 0;
}

Measured memory_bytes: 1920
class UnionFind{
  int n;
  int[] root;
  this(int n){
    root.length=n;
    foreach(i; 0..n) root[i]=i;
  }
  int find(int i){
    if(root[i]==i) return root[i];
    else return root[i]=find(root[i]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;
    root[x]=y;
  }
  bool same(int x, int y){
    return find(x)==find(y);
  }
}

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  
  int n, m; rd(n, m);
  auto p=readln.split.to!(int[]);
  auto uf=new UnionFind(n);
  foreach(_; 0..m){
    int a, b; rd(a, b);
    uf.unite(a-1, b-1);
  }

  int cnt=0;
  foreach(i; 0..n){
    if(uf.same(i, p[i]-1)) cnt++;
  }
  writeln(cnt);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}

Measured memory_bytes: 4924
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,K=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    F=list(map(int,input().split()))
    F.sort(reverse=True)
    
    def nibutan(ok,ng):
        while abs(ok-ng) > 1:
            mid = (ok + ng) // 2
            if solve(mid):
                ok = mid
            else:
                ng = mid
        return ok
    
    def solve(mid):
        k=0
        for i in range(N):
            k+=max(0,-(-(A[i]*F[i]-mid)//F[i]))
        if k<=K:
            return True
        else:
            return False
    
    print(nibutan(10**18,-1))
        
    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 113280
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<int> topological(vector<vector<int>> E)
{
    int n = (int)E.size();
    
    vector<int> C(n);
    for (int i=0; i<n; i++)
        for (int e: E[i])
            C[e]++;

    vector<int> V;
    vector<int> S;
    for (int i=0; i<n; i++)
        if (C[i]==0)
            S.push_back(i);

    while (!S.empty())
    {
        int v = S.back();
        S.pop_back();
        V.push_back(v);
        for (int e: E[v])
            if (--C[e]==0)
                S.push_back(e);
    }

    return (int)V.size()==n ? V : vector<int>();
}

int main()
{
    int N, M;
    cin>>N>>M;
    string s;
    cin>>s;
    vector<vector<int>> E(N);
    for (int i=0; i<M; i++)
    {
        int a, b;
        cin>>a>>b;
        E[a-1].push_back(b-1);
        E[b-1].push_back(a-1);
    }

    vector<vector<int>> E2(2*N);
    for (int i=0; i<N; i++)
    for (int e: E[i])
    {
        if (s[i]==s[e])
            E2[2*i].push_back(2*e+1);
        else
            E2[2*i+1].push_back(2*e);
    }

    cout<<(topological(E2).empty() ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 47224
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

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

        int N = sc.nextInt();
        int[] C = new int[N - 1];
        int[] S = new int[N - 1];
        int[] F = new int[N - 1];
        for (int i = 0; i < N - 1; ++i) {
            C[i] = sc.nextInt();
            S[i] = sc.nextInt();
            F[i] = sc.nextInt();
        }

        System.out.println(solve(C, S, F));

        sc.close();
    }

    static String solve(int[] C, int[] S, int[] F) {
        int N = C.length + 1;

        int[] result = new int[N];
        for (int i = 0; i < result.length; ++i) {
            int time = 0;
            for (int j = i; j < N - 1; ++j) {
                time = Math.max((time + F[j] - 1) / F[j] * F[j], S[j]) + C[j];
            }

            result[i] = time;
        }

        return Arrays.stream(result).mapToObj(String::valueOf).collect(Collectors.joining("\n"));
    }
}

Measured memory_bytes: 28528