akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long
map<int, int> mp;
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[200010];
    rep(i, n) cin >> a[i];
    sort(a, a + n, greater<int>());
    rep(i, n) mp[a[i]]++;
    int ans = 0;
    rep(i, n) {
        int k1 = a[i];
        if(mp[k1] == 0) continue;
        mp[k1]--;
        int times = (1LL << 30);
        while(times >= 1) {
            int k2 = times - a[i];
            if(k2 >= 0)
            //cout << k1 << " " << k2 << " " << k1 + k2 << " " << times << endl;
            if(mp[k2] > 0) {
                ans++;
                mp[k2]--;
                //cout << "*" << k1 << " " << k2 << " " << k1 + k2 << " " << times << endl;
                break;
                
            }
            times >>= 1;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 40192
# coding: utf-8
# Your code here!

def nextrun(x):
    sx = list(str(x))
    for i in reversed(range(len(sx))):
        isInc = True
        if i > 0:
            if int(sx[i]) == 9:
                continue
            if abs(int(sx[i])+1-int(sx[i-1])) <= 1:
                sx[i] = str(int(sx[i])+1)
                for j in range(len(sx)-i-1):
                    sx[i+j+1] = str(max(0,int(sx[i])-j-1))
                return int(''.join(sx))
    if sx[0] == '9':
        ret = ['0']*(len(sx)+1)
        ret[0] = '1'
        return int(''.join(ret))
    else:
        sx[0] = str(int(sx[0])+1)
        for i in range(len(sx)-1):
            sx[i+1] = str(max(0,int(sx[0])-i-1))
        return int(''.join(sx))
        

n = int(input())
a = 0
for i in range(n):
    a = nextrun(a)
print(a)

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

int Q;
vector<int> v(100010);
vector<int> prime;
int l[100010],r[100010];
void erast(){
	for(int i=0;i<100003;i++){
		v[i] = 1;
	}
	for(int i=2;i*i<=100003;i++){
		if(v[i]){
			for(int j=0;i*(j+2)<100003;j++){
				v[i*(j+2)]=0;
			}
		}
	}
	/*for(int i=2;i<100001;i++){
		if(v[i]){
			prime.push_back(i);
		}
	}*/
}

int main(){
	erast();
	int check[100010] = {0};
	for(int i=3;i<100010;i++){
		int b = 0;
		if(v[i] == 1 && v[(i+1)/2]==1) b = 1;
		check[i] += check[i-1] + b;//3からiまでの似た数の数
	}
	while(cin >> Q){
		int ans[Q+10] = {0};
		for(int i=0;i<Q;i++){
			cin >> l[i] >> r[i];
		}
		for(int i=0;i<Q;i++){
			
			//if(l[i] == 1) ans[i] -= 2;
			//if(l[i] == 2) ans[i] -= 1;
			cout << check[r[i]] - check[l[i]-1] << endl;
		}
	}
}

Measured memory_bytes: 2560
(defun app ()
    (let* ((s (read-line))
        (n (length s))
        (ans "Yes"))
        (dotimes (i (floor (/ n 2)))
            (if (not (equal (subseq s i (+ i 1)) (subseq s (- n i 1) (- n i))))
                (setq ans "No")
            )
        )
        (if (equal ans "Yes")
            (dotimes (i (floor (/ (- n 1) 2)))
                (if (not (equal (subseq s i (+ i 1)) (subseq s (- (floor (/ (- n 1) 2)) i 1) (- (floor (/ (- n 1) 2)) i))))
                (setq ans "No")
                )
            )
        )
        (if (equal ans "Yes")
            (let ((num (floor (/ (+ n 3) 2))))
            (loop for i from 0 to (floor (/ (- n num) 2)) do
                (if (not (equal (subseq s (- (+ num i) 1) (+ num i)) (subseq s (- n i 1) (- n i))))
                (setq ans "No")
                )
            )
            )
        )

        (format t "~A~%" ans)
    )
)
(app)

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(v) v.begin(),v.end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end())
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
const ll inf = 1000000001;
const ll INF = 2e18;
//const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair

int main() {
	ll n, m, d;
	cin >> n >> m >> d;
	ll ans = (m - 1) * 2 * (n - d);
	if (d == 0) {
		ans /= 2;
	}
	Sp(double(ans) / pow(n, 2));
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

int n;
ll MOD = 1e9+7;
ll num[1000100];
ll fac[1000100];
ll fnv[1000100];

ll power(ll a, ll n) {
    if (!n) return 1;
    ll t = power(a,n/2);
    return t*t%MOD*((n%2)?a:1)%MOD;
}

ll comb(ll n, ll k) {
    if (k<0||k>n) return 0;
    return fac[n]*fnv[k]%MOD*fnv[n-k]%MOD;
}

int main() {
    int i;

    scanf("%d",&n);
    fac[0] = 1;
    for (i=1;i<=n;i++) fac[i]=fac[i-1]*i%MOD;
    for (i=0;i<=n;i++) fnv[i]=power(fac[i],MOD-2);
    for (i=0;i<n;i++) num[i] = comb(i-1,2*i-n)*fac[n-1-i]%MOD*fac[i]%MOD;
    for (i=n-1;i>0;i--) num[i] = (num[i]+MOD-num[i-1])%MOD;
   // for (i=0;i<n;i++) printf("%d : %lld\n",i,num[i]);
    ll ans = 0;
    for (i=0;i<n;i++) ans = (ans+num[i]*i)%MOD;
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 23680
import sys
from collections import Counter
input = lambda : sys.stdin.readline().rstrip()

h, w, m = map(int, input().split(" "))

xs = []
ys = []
for i in range(m):
    x, y = map(int, input().split(" "))
    xs.append(x)
    ys.append(y)

xcounter = Counter(xs)
ycounter = Counter(ys)

x_most, x_most_num = xcounter.most_common(1)[0]
#y_most, y_most_num = ycounter.most_common(1)[0]

#if x_most_num < y_most_num:
#    x_most_num = y_most_num
#    tmp = ys
#    ys = xs
#    xs = tmp
#
out1 = x_most_num

if x_most_num < m:
    y2s = [] 
    for i in range(m):
        if xs[i] == x_most:
            continue
        else:  
            y2s.append(ys[i])
        
    y2counter = Counter(y2s)
    y2_most, y2_most_num = y2counter.most_common(1)[0]
    out1 += y2_most_num


y_most, y_most_num = ycounter.most_common(1)[0]

out2 = y_most_num

if y_most_num < m:
    x2s = [] 
    for i in range(m):
        if ys[i] == y_most:
            continue
        else:  
            x2s.append(xs[i])
        
    x2counter = Counter(x2s)
    x2_most, x2_most_num = x2counter.most_common(1)[0]
    out2 += x2_most_num

out = max(out1, out2)

print(out)

Measured memory_bytes: 194528
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(std::string S, long long w){
  string ans ="";
  int i = 0;
  while(i < S.length()){
    ans += S[i];
    i += w;
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    long long w;
    scanf("%lld",&w);
    solve(S, w);
}


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


int flag1,flag2,flag3;
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<=2;i++)
	{
		if(s[i]=='a') flag1=1;
		if(s[i]=='b') flag2=1;
		if(s[i]=='c') flag3=1;
	}
	if(flag1&&flag2&&flag3)
		puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
a,b,c,r,K;gcd(n,m){return m?gcd(m,n%m):n;}main(){scanf("%d",&K);for(;a++<K;)for(b=0;b++<K;)for(c=0;c++<K;)r+=gcd(a,gcd(b,c));printf("%d",r);}

Measured memory_bytes: 1724
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示
#include <map>
#include<set>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

#define MAX_N 50005//ここにNの最大値を入れる
#define MAX_K 100005


double max(double a, double b) {
    if (a > b) return a;
    return b;
}

int main() {
    int N,Y;
    cin >> N >> Y;

    //int check = Y - 1000 * N;

    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N; y++) {
            int z = N - x - y;
            if (z >= 0) {
                if (1000*x + 5000 * y + 10000 * z == Y) {
                    cout << z << " " << y << " " << x << endl;
                    return 0;
                }
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        
        long min = Long.MAX_VALUE;
        long x = 0;
        long y = 0;
        for(long i = 1; i*i <= N; i++){
            if(i + (N / i) < min && N % i == 0){
                min = i + (N / i);
                x = i;
                y = N / i;
            }
        }

        System.out.println(x - 1 + y - 1);        
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int H,W;
    cin >> H >> W;
    rep(i,0,H){
        string S;
        cin >> S;
        cout << S << endl;
        cout << S << endl;
    }
}

Measured memory_bytes: 384
// ABC135 A
//20190908
using System;
using System.Linq;
using static System.Math;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            // Console.WriteLine("Hello World!");
            var INPUT = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int A = INPUT[0];
            int B = INPUT[1];

            int ansA = Abs(A - B) - 1;
            int ansB = Abs(B - A) - 1;

            if (ansA % 2 == 0 && ansB % 2 == 0)
            {
                Console.WriteLine("IMPOSSIBLE");
            }
            else
            {
                int K = Min(A,B) + (ansA / 2) + 1;
                Console.WriteLine(K);
            }

        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 100001

int par[MAX_N];
int siz[MAX_N];

struct edge{
	int start;
	int to;
};

void init(){
	rep(i,MAX_N){
		par[i] = i;
		siz[i] = 1;
	}
}

int root(int i){
	if(par[i] == i) return i;
	par[i] = root(par[i]);
	return par[i];
}

bool isSame(int i,int j){
	i = root(par[i]);
	j = root(par[j]);
	return i == j;
}

void unite(int i, int j){
	i = root(i);
	j = root(j);
	if(i == j) return;
	if(siz[i] > siz[j]){
		int temp = i;
		i = j;
		j = temp;
	}
	par[i] = j;
	siz[j] += siz[i];
}

ll howLong(int i){
	return siz[root(i)];
}

int main()
{
	ll N,M;
	cin>>N>>M;
	vector<edge> edgeList;
	vector<ll> ans(M+1);
	rep(i,M){
		ll x,y;
		cin>>x>>y;
		x--;
		y--;
		struct edge e;
		e.start = x;
		e.to = y;
		edgeList.push_back(e);
	}
	init();
	ans[M] = N*(N-1)/2;
	for(ll i = M-1; i >= 0; i--){
		if( isSame(edgeList[i].start,edgeList[i].to) == true){
			ans[i] = ans[i+1];
			unite(edgeList[i].start,edgeList[i].to);
		}else{
			ans[i] = ans[i+1] - howLong(edgeList[i].start)*howLong(edgeList[i].to);
			unite(edgeList[i].start,edgeList[i].to);
		}
	}
	rep(i,M){
		cout<<ans[i+1]<<endl;
	}
	return 0;
}


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

int main(){
  int A,B,C,D,E,K;

  cin >>A>>B>>C>>D>>E>>K;

  if(E-A > K)cout <<":("<<endl;
  else cout <<"Yay!"<<endl;

  return 0;
  }

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   char s[3];
   int i, a[2];

   scanf("%s", s);
   for(i=0;i<3;i++){
      if(s[i] == 'a')
         a[i] = 1;
      else if(s[i] == 'b')
         a[i] = 2;
      else if(s[i] == 'c')
         a[i] = 3;
      else a[i] = 0;
}
      if (a[0] * a[1] * a[2] == 6){
           printf("Yes\n");
}
      else printf("No\n");

   return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int n, k;
	int s[100];
	int i;
	int sum = 0;

	scanf("%d", &n);
	scanf("%d", &k);
	for (i = 0; i < n; i++) {
		scanf("%d", &s[i]);
	}
	for (i = 0; i < n; i++) {
		if (s[i] > k / 2) {
			sum += (k - s[i]) * 2;
		}
		else {
			sum += s[i] * 2;
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pop_b pop_back
#define pf push_front
#define pop_f pop_front
#define mt make_tuple
#define eb emplace_back
#define sf(x) sizeof(x)
#define len(x) x.length()
#define sz(x) x.size()
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef long double ld; 
typedef vector<int> vi;
typedef vector<set<ll>> vset;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef deque<ll> dql;
typedef deque<int> dqi;
typedef unsigned long long ull;
typedef tuple<int,int,int> State;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << ", ";
	err(++it, args...);
	cout<<"\n";
}

#define vmax(type)   std::numeric_limits<type>::max()
#define vmin(type)   std::numeric_limits<type>::min()
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;
#define resize_vec(a) a.resize(unique(a.begin(), a.end()) - a.begin());
#define ms(dp, x) memset(dp, x, sf(dp))
#define endl '\n'

ll powm(ll a, ll b, ll mod) {
	ll res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const ll mod = 1e9 + 7;
const ll N = 1000005;
const ll inf = 1e9;

void solve()
{
	string s;
	cin>>s;
	if(s[s.length()-1] == 's')
		s += 'e';
	s += 's';
	cout<<s<<endl;
}

// #define _DEBUG 
// #define testCases
signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cout << fixed << setprecision(15);
	
	int tc = 1;
#ifdef testCases
	cin>>tc;
#endif
	while(tc--)
	{
#ifdef _DEBUG
	int tt = clock();
#endif
		solve();
		
#ifdef _DEBUG
		cerr << "TIME = " << clock() - tt << endl;
		tt = clock();
#endif
	}
	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

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

# define ll long long

const ll INF= 10000000000001;

const int N = 100001;
ll dp[N];

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);

	int n, tot;
	cin >> n >> tot;
	for (int i = 0; i <= N;i++) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++)
	{
		ll x, y;
		cin >> x >> y;
		for (int j = N - y; j >= 0; j--) {
			dp[j + y] = min(dp[j + y], dp[j] + x);
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if(dp[i]<=tot){
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4380
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   vector<int> a(3);
   cin >> a[0] >> a[1] >> a[2];

   sort(a.begin(), a.end());

   cout << a[0] + a[1] << endl;


   return 0;
}

Measured memory_bytes: 256
//coded by not_surrender

#pragma GCC optimize( "Ofast" )

#include <bits/stdc++.h>

#define MAXN 100010
#define oo (1<<30)
#define MOD 1000000007
#define mid ((a+b)/2)
#define L (nod*2)
#define R (nod*2+1)
#define pb push_back

using namespace std;

typedef long long ll;
typedef vector <int> vi;

ll N, dp[MAXN][2];

vi G[MAXN];

void dfs( int nod, int last, int color ){
	dp[nod][color] = 1;
	for ( int nxt:G[nod] )
		if ( nxt != last ){
			if ( !color && !dp[nxt][color] )
				dfs( nxt, nod, color );
			if ( !dp[nxt][color^1] )
				dfs( nxt, nod, color^1 );
			if ( color )
				dp[nod][color] = (dp[nod][color]*dp[nxt][color^1])%MOD;
			else
				dp[nod][color] = (dp[nod][color]*(dp[nxt][color^1]+dp[nxt][color]))%MOD;
		}
}

int main(){

    #ifndef ONLINE_JUDGE
        //~ freopen( "a.txt", "r", stdin );
    #endif // ONLINE_JUDGE

    ios_base::sync_with_stdio( false );
    cin.tie( NULL ), cout.tie( NULL );
    
    cin >> N;
    
    for ( int i = 1, a, b; i < N; ++i )
		cin >> a >> b, G[a].pb( b ), G[b].pb( a );
	
	dfs( 1, 1, 0 );
	dfs( 1, 1, 1 );
	
	cout << (dp[1][0]+dp[1][1])%MOD << '\n';
      
return 0;
}


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

int main()
{
    int a1,a2,a3;scanf("%d %d %d",&a1,&a2,&a3);
    if(a1+a2+a3>=22){printf("bust");}
    else printf("win");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

ll mod = 1000000007;

int main() {
  ll N;
  cin >> N;

  ll ans = 0;
  FOR(i, 1, N + 1) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }

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

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

int main(){
  int n;
  string s;

  cin >> n >> s;

  if(n%2==1) cout << "No" << endl;
  else{
    bool flg = true;
    for (int i = 0; i < n/2; i++)
    {
      if(s[i]!=s[n/2+i]) flg = false;
    }

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    
  }
}

Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-22 07:16:51
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

template<class T> T mod_pow(T x, int n, T mod) {
  T res = 1;
  while (n > 0) {
    if (n & 1) (res *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return res;
}

constexpr int64 MOD = 1e9 + 7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

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

  vector<int> cnt(101010, 0);
  for (int i = 0; i < n; ++i) ++cnt[a[i]];

  if (n & 1) {
    for (int i = 0; i < n; i += 2) {
      if (i == 0) {
        if (cnt[i] != 1) {
          cout << 0 << endl; return 0;
        }
      } else {
        if (cnt[i] != 2) {
          cout << 0 << endl; return 0;
        }
      }
    }
  } else {
    for (int i = 1; i < n; i += 2) {
      if (cnt[i] != 2) {
        cout << 0 << endl; return 0;
      }
    }
  }

  cout << mod_pow(2LL, n / 2, MOD) << endl;

  return 0;
}

Measured memory_bytes: 1024
n = int(input())
*a, = map(int,input().split())
M = 10**5+1
g = [0] * M
s = 0
for A in a:
    g[A] += 1
    s += A

q = int(input())
for loop in range(q):
    b,c = map(int,input().split())
    if g[b] == 0:
        print(s)
        continue
    s += g[b] * (c - b)
    g[c] += g[b]
    g[b] = 0
    print(s)


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

typedef long long ll;
ll mod = 1000000007;

ll mod_expo(ll a, ll b){
	if(b == 0)
		return 1;

	ll x = mod_expo(a , b / 2) % mod;
	x = (x * x) % mod;

	if( b % 2 == 0)
		return x;
	else
		return (a * x) % mod;
}


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

	ll a,b;
	cin>>a>>b;

	a = min(a, n - a);
	b = min(b, n - b);
	ll ans = mod_expo(2,n);
	ans = (ans - 1 + mod) % mod;

	ll x = 1;
	ll y = 1;

	for(ll i = 0; i < a; i++){
		x = (x * (n - i)) % mod;
		y = (y * (i + 1)) % mod;
	}

	ll not_a = (x  * (mod_expo(y,mod -2)))%mod;


	x = 1;
	y = 1;

	for(ll i = 0; i < b; i++){
		x = (x * (n - i)) % mod;
		y = (y * (i + 1)) % mod;
	}

	ll not_b = (x  * (mod_expo(y,mod -2)))%mod;

	ans = (ans - not_a + mod)%mod;
	ans = (ans - not_b + mod)%mod;

	cout<<ans<<"\n";

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
//stack<int> st;
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    ll x,y,d=0,n,m,h,k,max=-100000,min=10000000,ans=0,count=1,sum=0;
    string s;
    cin >> n;
    VI a(n);
    VI f(3);
    rep(i,n){
        cin >> a[i];
        if(a[i]%4==0)
            f[2]++;
        else if  (a[i]%2==0 && a[i]%4!=0)
            f[1]++;
        else f[0]++;
	}
    //operator << (cout,f);
    if(f[2]+1 > f[0])   
        cout << "Yes" << endl;
    else if (f[2]+1==f[0] && f[1]==0)
        cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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 long long INF = 1LL << 60;

int N;

long long dp[200000];

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

  rep(i, 200000) dp[i] = INF;

  dp[0] = 0;
  rep(i, N){
    chmin(dp[i+1], dp[i]+1);
    int index = 1;
    rep(j, 6){
      index *= 6;
      chmin(dp[i+index], dp[i]+1);
    }
    index = 1;
    rep(j, 5){
      index *= 9;
      chmin(dp[i+index], dp[i]+1);
    }
  }

  cout << dp[N] << endl;

  return 0;
}


Measured memory_bytes: 1792
N = int(input())

reply = [[-1] * N for _ in range(N)]

for i in range(N):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        x -= 1
        reply[i][x] = y

ans = 0

for i in range(1<<N):
    flag = True
    for j in range(N):
        if i>>j&1 == 1:
            for k in range(N):
                if reply[j][k] == 1:
                    if i>>k&1 == 0:
                        flag = False
                        break
                elif reply[j][k] == 0:
                    if i>>k&1 == 1:
                        flag = False
                        break
            if not flag:
                break
    if flag:
        count = 0
        for j in range(N):
            if i>>j&1:
                count += 1
        ans = max(ans, count)

print(ans)

Measured memory_bytes: 3064
N = int(input())
X = [int(x) for x in input().split()]
X_ = sorted(X, reverse=True)
mid1 = X_[N // 2 - 1]
mid2 = X_[N // 2]
for x in X:
  if x >= mid1:
    print(mid2)
  else:
    print(mid1)

Measured memory_bytes: 26772
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define ARRAY_MAX 100005


int main(){

    int h,w;
    cin >> h >> w;
    string s[h];
    REP(i,h){
        cin >> s[i];
    }
    int cnt = 0;
    REP(i,h){
        REP(j,w){
            if(s[i][j] == '#'){
                cnt++;
            }
        }
    }
    if(cnt == h+w-1){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
   
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = True
if n%2 == 1:
  for i in range(n):
    if a[i] != i+i%2:
      flag = False
else:
  for i in range(n):
    if a[i] != i+1-i%2:
      flag = False
if not flag:
  print(0)
else:
  s = 1
  for _ in range(n//2):
    s = s*2%1000000007
  print(s)

Measured memory_bytes: 14008
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define fop(i,m,n) for (int i=(m);i<(n);++i)
#define test(x) cout << #x << ' ' << x << endl;
#define eb emplace_back
#define pb push_back
#define mp make_pair 
int a[100000],dp[100000],n;

int dpp (int k) {
	if (dp[k]>-1) return dp[k];
	if (k==n-1) return 0;
	if (k+2<n) dp[k]=min(abs(a[k+1]-a[k])+dpp(k+1),abs(a[k+2]-a[k])+dpp(k+2));
	else if (k+2==n) dp[k]=abs(a[k+1]-a[k]);
	else return 0;
	return dp[k];
}



int main () {
	cin >> n;
	fop (i,0,n)  {
      cin >> a[i];
      dp[i]=-1;
     }
	cout << dpp(0) << endl;
}


Measured memory_bytes: 2560
#map(int, input().split())
#list(map(int, input().split()))
h = int(input())
w = int(input())
n = int(input())
if h<w:
    a = n/w
    if a%1 == 0:
        print(int(a))
    else:
        print(int(a)+1)
else:
    a = n/h
    if a %1 == 0:
        print(int(a))
    else:
        print(int(a)+1)


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

//#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 3e2 + 1e2;

const int M = 54;

vector<int> g;

bool bit(int num, int i){
    return (num >> i) & 1;
}

void add_row(int row){

    g.push_back(row);


    for (int i = 20; i >= 0; --i){
        if (bit(row, i)){

        }
    }


    sort(all(g));
    while (g.back() == 0)
        g.pop_back();
}

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> v;
    for (int i = 0; i < n; ++ i){
        int curr;
        cin >> curr;
        v.push_back(curr);
    }

}

#else

const int MAXN = 2e5 + 60;

vector<int> g[MAXN];

void solve(){
    int n;
    cin >> n;

    for (int i = 2; i <= n; ++i){
        int curr;
        cin >> curr;
        g[curr].push_back(i);
        g[i].push_back(curr);
    }

    for (int i = 1; i <= n; ++ i){
        if (i == 1)
            cout << g[i].size() << "\n";
        else
            cout << g[i].size() - 1 <<"\n";
    }

}

#endif

void multisolve() {
    int t;
    cin >> t;

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++) << ": ";
        solve();
        cout << endl;
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif

}

Measured memory_bytes: 15216
import sys
sys.setrecursionlimit(1000000)

def input():
    return sys.stdin.readline()[:-1]
n = int(input())
l = list(map(int, input().split(" ")))
output = 1

if 0 in l:
    print(0)
    sys.exit()

for i in range(n):
    output = output * l[i]
    if output > 10 ** 18:
        output = -1
        break
print(output)


Measured memory_bytes: 82432
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double d;
typedef long long ll;

const int N=2e5+5;
const int mod=1e9+7;

int n;
ll dp[10][10],ans;
void solve(int i){
    string a=to_string(i);
    string b=a;
    reverse(all(b));
    int B=0;
    for(char c:b) B=B*10+(c-'0');
    int s=a[0]-'0',e=a[a.size()-1]-'0';
    dp[s][e]++;
}
signed main(){
    FastIO;
    cin>>n;
    rep(i,1,n){
        solve(i);
    }
    rep(i,1,9){
        rep(j,1,9){
            ans+=dp[i][j]*dp[j][i];
        }
    }
    cout<<ans<<'\n';
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;


public class Main {
    static boolean isBase(char b){
        return b=='A' || b=='C' || b=='G' || b=='T';
    }
    static boolean isACGT(String s){
        int N = s.length();
        for(int n=0; n<N; n++) if(!isBase(s.charAt(n))) return false;
        return true;
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int N = S.length();

        int ans = 0;
        for(int i=0; i<N; i++) for(int j=i+1; j<=N; j++){
            if(isACGT(S.substring(i,j))) ans = Math.max(ans, j-i);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
N,M = map(int,input().split())
edges=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
S,T = map(lambda x:int(x)-1,input().split())

N3=N*3
adj=[set() for _ in range(N3)]

for a,b in edges:
    for i in range(3):
        start = a+N*i
        dst = b+N*(i+1)
        adj[start%N3].add(dst%N3)


Q=[S]
visited={S}
dist=[-1]*N3
dist[S]=0

while Q:
    tmp=[]
    for q in Q:
        for i in adj[q]:
            if i in visited:
                continue
            else:
                dist[i]=dist[q]+1
                visited.add(i)
                tmp.append(i)
    Q = tmp
print(dist[T] if dist[T]==-1 else dist[T]//3)



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

using namespace std;

typedef long double ld;

bool m1[100001] = {0};
ld m2[100001];

#define EPS 1e-12

ld dp(int N) {
	if (N == 0) return 0;
	if (m1[N]) return m2[N];

	ld res = 0, p = 1, np = 1;
	for (int i = 1; i < N; ++i) {
		np /= 2;
		ld dr = p * (1-np) * (i + dp(N-i-1));
		res += dr;
		if (dr < EPS) break;
		p *= np;
	}
	res += p * N;
	return m1[N] = true, m2[N] = res;
}

ld solve(int N) {
	return dp(N);
}

int main() {
	int N;
	cout.precision(10);
	while ( cin >> N, N ) {
		cout << solve(N) << endl;
	}
}

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

/*
 * 0-1????????????????????????
 * ????????????AOJ DPL_1B
 */

int N,W;
vector<int> v,w;

int main(){
    cin >> N >> W;
    v.resize(N);
    w.resize(N);
    for(int i=0;i<N;i++) cin >> v[i] >> w[i];

    vector<vector<int>> dp(N+1,vector<int>(W+1,0));
    //dp[i][j] : v[i-1],w[i-1]?????§??§?????????????????§???

    for(int i=0;i<N;i++){
        for(int j=0;j<=W;j++){
            if(j-w[i]>=0){
                dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
            }else{
                dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

Measured memory_bytes: 6788
#include <iostream>

using namespace std;

int a, b;

void solve()
{
    int k;
    if ((a + b) % 2 == 0)
    {
        k = abs((a + b) / 2);
        cout << k << endl;
    }
    else
        cout << "IMPOSSIBLE" << endl;
}

int main()
{
    cin >> a;
    cin >> b;

    solve();
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};

int main() {
	for (;;) {
		int T, P, R; cin >> T >> P >> R;
		if (T == 0) break;
		vector<int> a(T), b(T);
		vector< vector<int> > c(T, vector<int>(P));
		while (R--) {
			int t, p, time; cin >> t >> p >> time;
			t--; p--;
			string s; cin >> s;
			if (s == "CORRECT") {
				a[t]++;
				b[t] += time + c[t][p] * 1200;
			}
			else if (s == "WRONG")
				c[t][p]++;
		}
		vector< pair<i_i, int> > v(T);
		for (int t = 0; t < T; t++)
			v[t] = make_pair(i_i(-a[t], b[t]), t);
		sort(v.begin(), v.end());
		for (int t = 0; t < T; t++)
			cout << v[t].second + 1 << ' ' << -v[t].first.first << ' ' << v[t].first.second << endl;
	}
}

Measured memory_bytes: 1248
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char const *argv[]) {
  int a,b,c;

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

  if( (a<1 || a>100) || (b<1 || b>100) || (c<1 || c>100) ){
    fprintf(stderr, "INPUT ERROR!\n");
    return -1;
  }

  if( (a+b==c) || (a+c==b) || (b+c==a) ){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
import sys
from bisect import bisect_left

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    MAX = max(A)
    A = A[:-1]
    target = MAX / 2
    idx = bisect_left(A, target)

    if idx == 0:
        print(MAX, A[0])
    elif idx == N - 1:
        print(MAX, A[-1])
    else:
        if abs(target - A[idx]) < abs(target - A[idx - 1]):
            print(MAX, A[idx])
        else:
            print(MAX, A[idx - 1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 14160
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p2;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,res=pow(10,10);
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
    cin>>arr[i];
    for(ll x=1;x<=100;x++){
        ll sum=0;
        for(ll i=0;i<n;i++)
        sum+=pow(arr[i]-x,2);
        res=min(res,sum);
    }
    cout<<res;
}


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

int main(){
int a,b,c,d;
cin >> a>>b>>c>>d;
int s=0,t=0,u=0,v=0;
if(a == 1) s=1;
else if(a==9) t=1;
else if(a==7) u=1;
else if(a==4) v=1;
if(b == 1) s=1;
else if(b==9) t=1;
else if(b==7) u=1;
else if(b==4) v=1;
if(c == 1) s=1;
else if(c==9) t=1;
else if(c==7) u=1;
else if(c==4) v=1;
if(d == 1) s=1;
else if(d==9) t=1;
else if(d==7) u=1;
else if(d==4) v=1;
if(s*t*u*v) cout <<"YES" << endl;
else cout << "NO" << endl;
}


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

int flag=1,letter[27]={0};

int main()
{
	string s;
	cin>>s;	
	for (int i=0;i<=s.size()-1;i++)  letter[s[i]-'a'+1]++;
	
	for (int i=1;i<=26;i++)
	{
		if (letter[i]%2==1)
		{
			flag=0;
			break;
		}
	}
	if (flag==1)  cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(int argc, char const *argv[])
{
  double a,b,a1,a2,b1,b2;
  scanf("%lf%lf",&a,&b);
  a1=ceil(a/0.08);
  b1=ceil(b/0.1);
  a2=(a+1)/0.08;
  if(ceil(a2)!=floor(a2)) a2=floor(a2);
  else a2--;
  b2=(b+1)/0.1;
  if(ceil(b2)!=floor(b2)) b2=floor(b2);
  else b2--;
  if(a1>b2 || b1>a2) printf("-1");
  else if(a1>b1) printf("%d",(int)a1);
  else printf("%d",(int)b1);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int MAX=100;
int INFTY=(1<<21);
int W=0,G=1,B=2;

main(){
  int n,i,j,k,c,u,v,minv,M[MAX][MAX];
  int d[MAX],color[MAX];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      M[u][v] = c;
    }
  }
  for(i=0;i<n;i++){
    d[i] = INFTY;
    color[i] = W;
  }
  d[0] = 0;
  while(1){
    minv = INFTY;
    u = -1;
    for(i=0;i<n;i++){
      if(minv > d[i] && color[i] != B){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1)break;
    color[u] = B;
    for(v=0;v<n;v++){
      if(color[v] != B && M[u][v] != INFTY){
        if(d[v] > d[u] + M[u][v]){
          d[v] = d[u] + M[u][v];
          color[v] = G;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INFTY?-1:d[i]));
  }

  return 0;
}




Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <utility>
#include <set>
using namespace std;

pair<int, int> dfs(int nowpoint, int nowcost, vector<vector<pair<int, int> > >& adjlist, vector<bool>& used){
  used[nowpoint] = true;

  pair<int, int> ans(nowcost, nowpoint);
  for(size_t i = 0; i < adjlist[nowpoint].size(); i++)
    if(!used[adjlist[nowpoint][i].second])
      ans = max(ans, dfs(adjlist[nowpoint][i].second, nowcost + adjlist[nowpoint][i].first, adjlist, used));
  
  return ans;
}


int main(void){
  while(true){
    int n;
    cin >> n;
    if(n == 0){ break; }

    int input, sum = 0;
    vector<int> p(n, 0);
    vector<int> d(n, 0);
    for(int i = 1; i < n; i++){
      cin >> input;
      p[i] = input - 1;
    }
    for(int i = 1; i < n; i++){
      cin >> d[i];
      sum += d[i];
    }
    
    vector<vector<pair<int, int> > > adjlist(n);
    for(int i = 1; i < n; i++){
      adjlist[i].push_back(make_pair(d[i], p[i]));
      adjlist[p[i]].push_back(make_pair(d[i], i));
    }

    int leafedge = 0;
    set<int> leaflist;
    for(int i = 0; i < n; i++){
      if(adjlist[i].size() == 1){
        leaflist.insert(i);
        leafedge += adjlist[i][0].first;
      }
    }

    vector<vector<pair<int, int> > > inner = adjlist;
    for(int i = 0; i < n; i++){
      if(leaflist.count(i) == 1){ inner[i].resize(0); }
      else{
        for(size_t j = 0; j < inner[i].size(); j++){
          if(leaflist.count(inner[i][j].second) == 1){
            inner[i].erase(inner[i].begin() + j);
            --j;
          }
        }
      }
    }

    vector<bool> used(n, false), used2(n, false);;
    int start, diam;
    for(start = 0; start < n && inner[start].size() == 0; start++);
    if(start == n){ diam = 0; }
    else {
      start = dfs(start, 0, inner, used).second;
      diam = dfs(start, 0, inner, used2).first;
    }
    
    int ans = sum + (sum - leafedge) * 2 - diam;
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3284
#include <bits/stdc++.h>
#define lambda(res, ...) (function<res(__VA_ARGS__)>)[&](__VA_ARGS__)->res
#define method(name, res, ...)                                                 \
  function<res(__VA_ARGS__)> name = lambda(res, __VA_ARGS__)
#define foreach(i,n) for(auto&i:(n))

using namespace std;

int main(){
  int table[10][10];
  foreach(i,table)
    foreach(j,i)
    cin >> j;

  method(f,int,int x,int y){
    return table[x][y];
  };
  method(g,int,vector<int> xs){
    int res = 0;
    foreach(i,xs){
      res = f(res,i);
    }
    return res;
  };
  method(digits,vector<int>,int x,int n){
    vector<int> res;
    for(int i=0;i<n;++i){
      res.emplace_back(x%10);
      x/=10;
    }
    reverse(res.begin(),res.end());
    return res;
  };

  method(func,bool,int x){
    int y = x * 10 + g(digits(x,4));
    vector<int> ys = digits(y,5);
    foreach(i,ys){
      for(int j=0;j<10;++j){
        if(i==j)continue;
        swap(i, j);
        if(g(ys)==0)return true;
        swap(i, j);
      }
    }
    for(int i=0;i<4;++i){
      if(ys[i]==ys[i+1])continue;
      swap(ys[i],ys[i+1]);
      if(g(ys)==0)return true;
      swap(ys[i],ys[i+1]);
    }
    return false;
  };

  int ans = 0;

  for(int i=0;i<10000;++i){
    ans += func(i);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3160