akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
string a,b,c[4]={"esare","maerd","remaerd","resare"};
bool q=true;

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(18);
	cin>>a;
	//reverse(a.begin(),a.end());
	for (;!a.empty();){
		for (int j=0;j<5;j++){
			b+=a.back();
			a.pop_back();
		}
		if (b==c[0]||b==c[1]){
			b.clear();
			continue;
		}
		b+=a.back();
		a.pop_back();
		if (b==c[3]){
			b.clear();
			continue;
		}
		b+=a.back();
		a.pop_back();
		if (b==c[2]){
			b.clear();
			continue;
		}
		else {
			q=false;
			break;
		}
	}
	cout<<(q?"YES":"NO");
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int ans;
	int i;
	int k = 10;					
	int keta = 1;				
	
	while(scanf("%d %d",&a,&b) != EOF){
		ans = a + b;				
		
		while(1){
			if(i == 1) break;
				if((ans / k) < 1){		
					printf("%d\n",keta);
					i = 1;
				}
				keta++;
				k = k *10;
		}
		keta = 1;
		k = 10;
		i = 0;
	}
	
	return 0;
}

Measured memory_bytes: 596
# coding:utf-8

import sys
import math
INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n, m = LI()
    A = LI()
    A.sort()
    A.reverse()

    match = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    # dp[i]: ちょうどマッチをi本使ったときに作れる整数の最大の桁数（-1: 作れない）
    dp = [-1] * (n + 1)
    dp[0] = 0
    res = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in A:
            # 最上位桁の数字を決める
            # k: 最上位桁をjにしたときの残りのマッチの数
            k = i - match[j - 1]
            if k < 0 or dp[k] == -1:
                continue

            if dp[i] < dp[k] + 1:
                dp[i] = dp[k] + 1
                res[i] = max(j * 10 ** dp[k] + res[k], res[k] * 10 + j)

    return res[n]


print(main())


Measured memory_bytes: 15080
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a) = min((a), (b)))
#define chmax(a, b) ((a) = max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = acos(-1);
const double eps = 1e-10;

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

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

    vector<vector<int>> dp(m+1, vector<int>(n+1, 0));
    for(int j=0; j<n; j++){
        dp[1][j+1] = dp[1][j] + (s[j] == t[0]);
    }

    for(int i=1; i<m; i++){
        for(int j=i; j<n; j++){
            (dp[i+1][j+1] += dp[i+1][j]) %= MOD;

            if(t[i] == s[j]){
                (dp[i+1][j+1] += dp[i][j]) %= MOD;
            }
        }
    }

    cout << dp[m][n] << endl;
}



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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int a[3];
	int k;
	rep(i,3)cin>>a[i];
	cin>>k;
	int cnt=0;
	while(a[0]>=a[1]){
		a[1]*=2;
		cnt++;
	}
	while(a[1]>=a[2]){
		a[2]*=2;
		cnt++;
	}
	cout<<(cnt<=k?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 3628
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto & in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N;
uint32_t mask = 0;

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N;
	for (size_t i = 0; i < N; i++)
	{
		uint32_t v;
		in >> v;
		mask ^= v;
	}
	if (mask == 0) {
		out << "Yes" << endl;
	}
	else {
		out << "No" << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


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

    int k;
    string s;
    cin >> k >> s;

    if(s.size() <= k){
        cout << s << endl;
        return 0;
    }
    cout << s.substr(0,k) << "..." << endl;
}

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

int main() {
  string s,t;
  cin >> s >> t;
  int x=stoi(s+t);
  for(int i=1; i<350; i++) {
    if(i*i==x) {
    cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;


int main() 
{
	int n, k;
	cin >> n >> k;
	vector<long long int >h(n);
	rep(i, 0, n)cin >> h[i];
	long long int ans = 0;
	sort(h.begin(), h.end());
	if (k < n) {
		rep(i, 0, n - k)
			ans += h[i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=305;
int main(){
	int n;
	LL a1,a2,x,sum=0;scanf("%d%lld%lld",&n,&a1,&a2);
	for(int i=2;i<n;i++)scanf("%lld",&x),sum^=x;
	LL w=a1+a2-sum,ans=0;
	if(w<0||w%2||((w>>=1)&sum)||w>a1)return puts("-1"),0;
	ans=w;
	for(int i=63;i>=0;i--){
		if(((1ll<<i)&sum)&&ans+(1ll<<i)<=a1)ans+=(1ll<<i);
	}
	if(ans==0)return puts("-1"),0;
	printf("%lld\n",a1-ans);
	return 0;
} 

Measured memory_bytes: 3828
#include <stdio.h>

int main () {
	int n, a, b;
	scanf ("%d", &n);
	if (n==1) {
		printf ("Hello World\n");
	} else if (n == 2) {
		scanf ("%d\n%d", &a, &b);
		printf ("%d\n", a+b);
	}
	
	return 0;
}


Measured memory_bytes: 128
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(1,n+1):
        for i in range(1,n+1):
            for j in range(1,n+1):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
  
  
n,m,r = map(int,input().split()) 
lists=list(map(int,input().split()))
d = [[float("inf") for i in range(n+1)] for i in range(n+1)] 

for i in range(m):
    x,y,z = map(int,input().split())
    d[x][y] = z
    d[y][x] = z
for i in range(n+1):
    d[i][i] = 0 #自身のところに行くコストは０
dislist=warshall_floyd(d)

import itertools

U=list(itertools.permutations(lists))

mini=10**100
for some in U:
  dd=0
  for j in range(r-1):
    if dislist[some[j]][some[j+1]]!=float("inf"):
      dd+=dislist[some[j]][some[j+1]]
    else:
      break
  mini=min(mini,dd)
print(mini)
   	

Measured memory_bytes: 66008
from operator import mul
from functools import reduce
from collections import Counter

def cmb(n,r):
	if n < r:return 0
	if r == 0 or n-r == 0:return 1
	r = min(n-r,r)
	up = reduce(mul, range(n, n-r, -1))
	down = reduce(mul, range(1,r+1))
	return up//down
    
l = []
for i in range(int(input())):
	l.append("".join(sorted(input())))
c = Counter(l)
ans = 0
for i in c.values():
	ans += cmb(i,2)
print(ans)

Measured memory_bytes: 20028
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
t, ans = sum(B), 0
j = M
for i in range(N+1):
    while j>0 and t>K:
        j -= 1
        t -= B[j]
    if t>K: break
    ans = max(ans, i+j)
    if i==N: break
    t += A[i]

print(ans)

Measured memory_bytes: 40572
n = int(input())
s = int(input())
rtn = -1* int( -1 * (n**0.5))
def f(b,n):
    if n<b:
        return n
    return f(b,n//b) + n % b
if n < s or (n // 2)+1 < s < n :
    print("-1")
elif s == n:
    print(n+1)
elif s == n//2 +1:
    if n % 2 == 1:
        print(n//2 + 1)
    else:
        print("-1")
elif (n//3) + 2 < s <= n//2:
    print(n-s+1)
else:
    for b in range(2,rtn+1):
        if f(b,n) == s:
            print(b)
            exit()
    for p in range(rtn,0,-1):
        if (n-s) % p == 0:
            b = (n-s)//p + 1
            if f(b,n) == s:
                print(b)
                exit()
    print(n-s+1)


Measured memory_bytes: 3064
#include <stdio.h>
#define MAX 50001
int p[MAX];
int prime[10000];
int c;
void hurui(){
  int i,j;
  for(i=0;i<MAX;i++)p[i]=1;
  p[0]=0;p[1]=0;c=0;
  for(i=2;i<MAX;i++){
    //printf("%d\n",i);
    if(p[i]==1){
      prime[c++]=i;
      for(j=2*i;j<MAX;j+=i)p[j]=0;
    }
  }

}
int main(){
  int n;
  int i,j;
  int count;
  hurui();
  while(1){
    count=0;
    scanf("%d",&n);
    if(n==0)break;
    else{
      for(i=0;prime[i]<=n/2 ;i++){
	if(n-prime[i]>1 && p[n-prime[i]]==1){count++;}
	}
      }
    
    printf("%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 812
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, ans = 0, c0, c1;
	string s;

	cin >> s;
	n = s.length();
	stack<char> st;
	for (auto ch : s) {
		if (ch == 'S') st.push(ch);
		else {
			if (!st.empty() && (st.top() == 'S')) st.pop();
			else st.push(ch);
		}
	}
	ans = st.size();
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 832
#include<bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/numeric/interval.hpp>
#include <boost/numeric/interval/io.hpp>
using namespace::std;
namespace mp = boost::multiprecision;
typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat;
typedef mp::cpp_int cint;
typedef long long lint;
typedef long long ll;
typedef long double ldouble;
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<double> dvec;
typedef vector<vector<double>> dmat;
typedef vector<vector<vector<double>>> dmat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef vector<vector<vector<string>>> smat3;
#define rep(i, n) for(lint i = 0; i < (lint)(n); i++)
#define irep(i) for(lint i = 0;; i++)
#define irep1(i) for(lint i = 1;; i++)
#define irep2(i) for(lint i = 2;; i++)
#define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--)
#define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--)
#define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++)
#define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c)
#define all(x) (x).begin(),(x).end()
#define sl(c) (('a')<=(c)&&(c)<=('z'))
#define ll(c) (('A')<=(c)&&(c)<=('Z'))
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define PI 3.141592653589793
#define cout (cout<<fixed<<setprecision(15))
#define makeupper(t) (transform(all(t),t.begin(),::toupper))
#define makelower(t) (transform(all(t),t.begin(),::tolower))
#define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5))
#define NEXT_LINE string junk; getline(cin, junk);
#define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0)
#define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";}
#define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i];
#define INF (1LL<<60)
#define IINF (1<<30)
#define LINF 9223372036854775807
#define MOD 1000000007
vector<lint> dx={-1,1,0,0,1,1,-1,-1};
vector<lint> dy={0,0,-1,1,1,-1,1,-1};
inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;}
inline lint lcm(lint a,lint b){return a*b/gcd(a,b);}
int main(){
    lint n,m,p;
    cin>>n>>m>>p;
    vec a(m),b(m),c(m);
    rep(i,m)cin>>a[i]>>b[i]>>c[i];
    rep(i,m)c[i]-=p;
    rep(i,m)a[i]--;
    rep(i,m)b[i]--;
    vector<lint> diff(n,1e16);
    diff[0]=0;
    rep(k,2*n-1)rep(i,m){
        diff[b[i]]=min(diff[b[i]],diff[a[i]]-c[i]);
    }
    lint ans=-diff[n-1];
    rep(k,2*n-1)rep(i,m){
        diff[b[i]]=min(diff[b[i]],diff[a[i]]-c[i]);
    }
    if(ans!=-diff[n-1])cout<<-1;
    else cout<<max(0LL,ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cmath>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
typedef vector<ll> V;
typedef vector<V> VV;
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 INFLL = 1LL << 60;
const int INF = 1 << 28;
void solve(int a) { cout << (a ? "Yes" : "No") << endl; }
int main()
{
	ll n;
	long long ans = 0LL;
	cin >> n;
	for (int i = 1; i <= sqrt(n) + 3; i++)
	{
		if (n % i == 0)
		{
			if(n/i >1){
			if (i == n % ((n / i) - 1))
			{
				ans += ((n / i) - 1);
			}
			}
			//	cout<<((n/i)-1)<<endl;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;typedef long long ll;typedef pair<ll,ll>pll;
#define fi first
#define se second
#define pb(x) push_back(x)
#define m_p(a,b) make_pair(a,b);
#define sz(a) ((int)(a).size())
#define f(i,a,b) for(int i=a;i<b;++i)
#define ff(i,a,b) for(int i=a;i<=b;++i)
#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";
#define file freopen("in.txt","r",stdin)
#define mem(a,b) memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define jkl ios::sync_with_stdio(false);cin.tie(false);
#define all(x) x.begin(),x.end()
/*********************************************/
int main() {
	vector<int> v;
	v.pb(1);
	for(auto i:v) {};
	int a,b,c;
	cin >> a >> b >> c;
	if(a*b<c) cout << a*b;
	else cout << c;
	cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100010
int f[MAXN];
int a[MAXN];
int n,k;
int main()
{
	cin>>n>>k;
	memset(f,0x3f,sizeof f);
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	f[0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i>=j) f[i]=min(f[i],f[i-j]+abs(a[i]-a[i-j]));
		}
	//	f[i]=min(f[i],f[i-1]+abs(a[i]-a[i-1]));
	//	if(i>1) f[i]=min(f[i],f[i-2]+abs(a[i]-a[i-2]));
	}
	if(n<=2) cout<<abs(a[0]-a[1]);
	else cout<<f[n-1];
//	for(int i=0;i<n;i++) cout<<f[i]<<' ';
	return 0;
}

Measured memory_bytes: 1152
// #include <bits/stdc++.h>
#include <iostream> // cout, endl, cin
#include <iomanip> // setprecision
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath> // pow

#define int long long

// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define all(v) v.begin(), v.end()
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
// union of two containers
template <typename T>
void container_union(T &c1, T &c2, T &c3) {
  std::vector<int> vec;
  std::set_union(c1.begin(), c1.end(),
                 c2.begin(), c2.end(),
                 std::back_inserter(vec));
  T tmp(vec.begin(), vec.end());
  c3 = tmp;
}

// chmax, chmin
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

// grid-search
std::vector<int> dx = {1, -1, 0,  0};
std::vector<int> dy = {0,  0, 1, -1};
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

// yes/no
std::string yes = "Yes";
std::string no = "No";
std::string YES = "YES";
std::string NO = "NO";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout << std::fixed << std::setprecision(10);
  solve();
  return 0;
}

void solve() {
  int a, b;
  std::string alice = "Alice", bob = "Bob", draw = "Draw";
  std::cin >> a >> b;
  if (a != 1 && b != 1) {
    if (a > b) {
      cout(alice);
    } else if (a == b) {
      cout(draw);
    } else {
      cout(bob);
    }
  } else {
    if (a == 1 && b == 1) {
      cout(draw);
    } else if (a == 1) {
      cout(alice);
    } else {
      cout(bob);
    }
  }
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split();
            long[] x = new long[3];
            for (int i = 0; i < 3; i++)
            {
                x[i] = long.Parse(a[i]);
            }
            bool end = false;
            for (int i = 0; i < 3; i++)
            {
                if (x[i] % 2 == 1) end = true;
            }
            if (end) Console.WriteLine(0);
            else if (x.Max() == x.Min())
            {
                Console.WriteLine(-1);
            }
            else
            {
                long ret;
                end = false;
                for (ret = -1; !end; ret++)
                {
                    for (int i = 0; i < 3; i++)
                    {
                        if (x[i] % 2 == 1) end = true;
                    }
                    long[] y = new long[3];
                    for (int i = 0; i < 3; i++)
                    {
                        y[i] += (x.Sum() - x[i]) / 2;
                    }
                    x = y;
                }
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I n,m,v,p;
  cin >> n >> m >> v >> p;
  V a(n);
  VIN(a);
  SORT(a);
  REV(a);
  V asum(n);
  REP(i,n){
    if (i >= p){
      asum.at(i) = asum.at(i-1) + min(m,a.at(p-1)-a.at(i-1));
    }
  }
  I t=0;
  REP(i,n){
    if (i <= p - 1){
      t++;
    }else{
      if (a.at(i) + m >= a.at(p-1)){
        if ((p-1)+(n-1-i) >= (v-1)){
          t++;
        }else{
          I nokori = v - ((p-1)+(n-1-i)+1);
          I tmp = 0;
          tmp = max(a.at(i)+m-a.at(p-1),tmp);
          I sum = asum.at(i) + (i-(p-1))*tmp;
          /*
          for(I j=p-1;j<i;j++){
            sum += min(m,a.at(i)+m-a.at(j));
          }
          */
          if (sum >= nokori * m){
            t++;
          }else{
            break;
          }
        }
      }else{
        break;
      }
    }
  }
  cout << t << endl;
  return 0;
}



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

using namespace std;

char s[20] = "CODEFESTIVAL2016", t[20];

int main ()
{
//    freopen ("in", "r", stdin);
    cin >> t;
    int c = 0;
    for (int i = 0; i < 16; i++) if (s[i] != t[i]) c++;
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, Q; cin >> n >> Q;
    string in; cin >> in;

    vi sum(n+1);
    rep(i, n){
        sum[i+1] = sum[i];
        if(in.substr(i, 2) == "AC"){
            sum[i+1]++;
        }
    }

    rep(_, Q){
        int l, r; cin >> l >> r;
        l--;
        int res = sum[r] - sum[l];
        if(in.substr(r-1, 2) == "AC"){
            res--;
        }
        cout << res << endl;
    }

    return 0;
}


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

int main(){
    long long int n, k;
    cin >> n >> k;
    long long int ans = 0;
    for(long long int b=k+1;b<=n;++b){
        long long int nn = (n+b-1)/b * b;
        ans += (nn / b) * (b-k);
        if(nn > n && (n+1)%b >= k)ans -= (nn - n - (k == 0 ? 0 : 1));
        else if(nn > n + 1 && (nn-1)%b >= k)ans -= (b-k);
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    string s; cin >> s;
    int m = 200000, M = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A') m = min(m, i);
        if (s[i] == 'Z') M = max(M, i);
    }
    int ans = M - m + 1;
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <ccomplex>
#include <vector>
#include <cassert>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
#include <list>
#include <assert.h>
#include <math.h>
#include <valarray>
#include <stdio.h>
#include <algorithm>
#include <set>
#include <complex>
#include <list>
#include <time.h>
#include <stack>
#include <locale>
#include <clocale>
#include <ctype.h>
#include <wchar.h>

using namespace std;
typedef long long int LL;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int xcomp(vector<LL>& a, vector<LL>& b) {
	return a[0] < b[0];
}

#define XSORT(c) sort((c).begin(),(c).end(),xcomp)

#define ALL(x) (x).begin(),(x).end()
LL mod = 1000000007;


int main() {
	LL x;
	cin >> x;
	LL a = x / 11;
	LL b = x % 11;
	if (b == 0) {
		cout << a * 2 << endl;
	}else
		if (b <= 6) {
			cout << a * 2 + 1 << endl;
		}
		else
		{
			cout << a * 2 + 2 << endl;
		}
}


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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  ll a, b, k;
  cin >> a >> b >> k;
  ll ansa = max(0LL, a-k);
  ll ansb = min(b, b-(k-a));
  ansb = max(ansb, 0LL);
  cout << ansa << " " << ansb << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {

  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  int magic = 0;
  for (int i = 1; i < n; i++) {
    if (a[i] == a[i-1]) {
      magic++;
      i++;
    }
  }
  printf("%d\n", magic);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int array[128];

int translateStr(char buf[]){
    int sum = -1,mult = 1;
    for(int i = 0; buf[i] != '\0'; i++){
        sum += array[buf[i]]*mult;
        mult *= 4;
    }
    return sum;
}

int main(){

    array['A']=1,array['C']=2,array['G']=3,array['T']=4;

    int n;
    scanf("%d",&n);
    char order[ORDER_LENGTH],str[STR_LENGTH];

    char* check_table = new char[TABLE_SIZE];

    for(int i = 0; i < n; i++){
        scanf("%s %s",order,str);
        if(order[0] == 'i'){
            check_table[translateStr(str)] = 'Y';
        }else{
            if(check_table[translateStr(str)] == 'Y'){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
}


Measured memory_bytes: 4480
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <set>
#include <string.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REP3(i,st,en) for(ll (i)=(st);(i)<(en);(i)++)

using P = pair<ll, ll>;
const int MOD = 1e9+7;
const ll INF = 1e+14;
const double PI = 3.14159265349;



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

  ll N;
  cin >> N;

  ll r = (ll)sqrt(N);
  while(r>0){
    if (N%r==0) break;
    r--;
  }

  ll ans = r-1+N/r-1;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
main = do
  n <- readLn::IO Int
  xs <- (return . map (read::String->Double) . words) =<< getLine
  ys <- (return . map (read::String->Double) . words) =<< getLine
  print $ d1 xs ys
  print $ d2 xs ys
  print $ d3 xs ys
  print $ d4 xs ys
  
d1 xs ys = sum $ map (\(x,y)-> abs (x-y)) $ zip xs ys
d2 xs ys = (sum $ map (\(x,y)-> ((**2) . abs) (x-y)) $ zip xs ys) ** (1/2)
d3 xs ys = (sum $ map (\(x,y)-> ((**3) . abs) (x-y)) $ zip xs ys) ** (1/3)
d4 xs ys = maximum $ map (\(x,y)-> abs (x-y)) $ zip xs ys


Measured memory_bytes: 4456
from itertools import izip

N, M, C = (int(x) for x in raw_input().split())
B = [int(x) for x in raw_input().split()]
A = [[int(x) for x in raw_input().split()] for i in xrange(N)]
result = 0
for i in xrange(N):
  cur_sum = C
  for a, b in izip(A[i], B):
    cur_sum += a * b
  if cur_sum > 0:
    result += 1
print(result)


Measured memory_bytes: 2692
while 1:
  n=int(input())
  if not n:break
  f=1
  L={}
  for a,b,c in [map(int,input().split()) for i in range(n)]:
    a=str(a)
    d=b*c
    if a in L:
      if L[a]>=1e6:continue
      L[a]+=d
    else:L[a]=d
    if L[a] >= 1e6:
      print(a)
      f=0
  if f:print('NA')

Measured memory_bytes: 8152
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int a[1005];
int b[1005];
int main()
{
    int n,i,minn=1000000;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        a[i]=a[i-1]+x;
    }
    for(i=1;i<=n;i++)
    {
        b[i]=abs(abs(a[n]-a[i])-a[i]);
   /// printf("%d b[i]=%d,a[i-1]=%d,a[i]=%d\n",i,b[i],a[i-1],a[i]);
    }

    sort(b+1,b+n+1);
    printf("%d\n",b[1]);


}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
const long double PI=3.14159265358979;
const ll MAX=0;

int main() {
  ll N;
  cin>>N;
  ll a[N];
  rep(i,N){
    cin>>a[i];
  }
  sort(a,a+N);
  
  ll num[1000001];
  rep(i,1000001){
    num[i]=1;
  }
  num[0]=0;
  ll c=0;
  for(int i=0;i<N;i++){
    ll a1=a[i];
    if(num[a1]==1){
      c++;
      //cout<<a1<<endl;
      ll j=1;
      while(a1*j<=1000000){
        num[a1*j]=0;
        j++;
      }
      num[a1]=2;
    }
  }
  rep(i,N-1){
    if(num[a[i]]==2&&a[i]==a[i+1]){
      c--;//cout<<i<<endl;
    }
    if(i==N-2){
      break;
    }
    if(num[a[i]]==2&&a[i+2]==a[i]){
      c++;//cout<<i<<endl;
    }
  }
  cout<<c;
        

}


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

using ll = long long;

int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	
	bool ok = true;
	for (ll a = 0; a < n; a++) {
		if (a * m % n) {
			continue;
		}
		if (s[a] != t[a * m / n]) {
			ok = false;
		}
	}

	if (ok) {
		cout << lcm(n, m) << endl;
	}
	else {
		cout << -1 << endl;
	
	}

	return 0;
}


Measured memory_bytes: 3696
# ABC097D - Equals (ARC097D)
import sys
input = sys.stdin.readline


class UnionFind:
    def __init__(self, N):  # construct a Union-Find tree (1-idx)
        self.parent = [i for i in range(N + 1)]
        self.rank = [0] * (N + 1)

    def find(self, x):  # find the group (root) of a vertex
        if self.parent[x] == x:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def is_same(self, x, y):  # check two vertices are in the same group
        return self.find(x) == self.find(y)

    def unite(self, x, y):  # unite two groups
        x, y = self.find(x), self.find(y)
        if x == y:  # the same group
            return
        # unite a small one to a bigger one to balance trees
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1


def main():
    # check i and Pi are connected components or not
    N, M = tuple(map(int, input().split()))
    P = tuple(map(int, input().split()))
    E = tuple(tuple(map(int, input().split())) for _ in range(M))
    U = UnionFind(N)  # construct a Union-Find tree (1-idx)
    for v, u in E:  # connected components are in the same group
        U.unite(v, u)
    ans = sum(U.is_same(i, p) for i, p in enumerate(P, 1))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 25560
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		out("ABC" + n());

	}

	/*
	 * 以下メソッド集
	 */

	static int abcount(String str) {
		int count = 0;
		int len = str.length();
		for (int i = 0; i < len - 1; i++) {
			if ("AB".equals(str.substring(i, i + 2))) {
				count++;
			}
		}
		return count;
	}

	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static double nd() {
		return sc.nextDouble();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

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

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

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void out(Object obj) {
		System.out.println(obj.toString());
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static double max(double d, double e) {
		return Math.max(d, e);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static double min(double d, double e) {
		return Math.min(d, e);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}

class XY {
	int h;
	int c;

	XY(int h, int c) {
		this.h = h;
		this.c = c;
	}
}


Measured memory_bytes: 21460
n,m=input().split()
n,m=int(n),int(m)
a=[]
for i in range(n):
    a.append(input())

b=[]
for i in range(m):
    b.append(input())

#貪欲にやれドアホ
for i in range(n-m):
    for j in range(n-m):
        c=0
        for k in range(m):
            if b[k] == a[i+k][j:j+m]:
                c+=1
            else:
                break
        if c==m:
            break
    if c==m:
        break
#cが定義されない時(m==nでは)エラー
if a==b:
    print("Yes")
elif n==m:
    print("No")
elif c==m:
    print("Yes")
else:
    print("No")


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

using namespace std;

#define db(x) cerr << #x << " = " << x << endl;
#define MAXN 112
#define MAXK 112345 
#define ll long long
#define fi first
#define se second
#define pll pair<ll, ll>
#define MOD 1000000007

int N, K;
int vals[MAXN];
ll dp[MAXN][MAXK];
ll prefix[MAXN][MAXK];

ll add(ll a, ll b)
{
	return (a + b) % MOD;
}

ll sub(ll a, ll b)
{
	return (a - b + MOD) % MOD;
}

ll get_prefix(int row, int L, int R)
{
	ll result = prefix[row][R];
	
	if (L - 1 >= 0)
		return sub(result, prefix[row][L - 1]);
	return result;
}

//no candies should be left over.
int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++)
	{
		scanf("%d", &vals[i]);
	}
	
	memset(dp, 0, sizeof(dp));
	dp[N][0] = 1;
	for (int i = 0; i <= K; i++)
	{
		prefix[N][i] = 1;
	}
	
	for (int i = N - 1; i >= 0; i--)
	{
		for (int j = 0; j <= K; j++)
		{
			if (j == 0)
			{
				dp[i][j] = 1;
				prefix[i][j] = 1;
			}
			else
			{
				int c = min(j, vals[i]);
				dp[i][j] = add(dp[i][j], get_prefix(i + 1, j - c, j));
				prefix[i][j] = add(prefix[i][j - 1], dp[i][j]);
			}
		}
	}
	
	//~ for (int i = 0; i < N; i++)
	//~ {
		//~ for (int j = 0; j <= K; j++)
		//~ {
			//~ printf("%d ", prefix[i][j]);
		//~ }
		//~ printf("\n");
	//~ }
	
	//~ printf("\n");
	//~ for (int i = 0; i < N; i++)
	//~ {
		//~ for (int j = 0; j <= K; j++)
		//~ {
			//~ printf("%d ", dp[i][j]);
		//~ }
		//~ printf("\n");
	//~ }
	
	printf("%lld\n", dp[0][K]);
	
	return 0;
}



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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll dp[16][16];
bool NG[16][16];
 int main() {
	 int a, b;
	 while (cin >> a >> b, a) {
		 int n;
		 cin >> n;
		 memset(NG, 0, sizeof(NG));
		 for (int i = 0; i < n; i++) {
			 int x, y;
			 cin >> x >> y;
			 x--; y--;
			 NG[x][y] = 1;
		 }
		 if (NG[0][0] || NG[a - 1][b - 1]) {
			 cout << 0 << endl;
			 continue;
		 }
		 memset(dp, 0, sizeof(dp));
		 dp[0][0] = 1;
		 for (int i = 0; i < a; i++) {
			 for (int j = 0; j < b; j++) {
				 if (i + 1 < a && !NG[i + 1][j]) dp[i + 1][j] += dp[i][j];
				 if (j + 1 < b && !NG[i][j + 1]) dp[i][j + 1] += dp[i][j];
			 }
		 }
		 cout << dp[a - 1][b - 1] << endl;
	 }
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	string s;
	int n, i;
	
	cin>>s;
	n = s.size();
	
	int lo = 1, hi = n + 1, mid = 0;
	bool zero, one;
	
	while (hi - lo > 1)
	{
		mid = (lo + hi ) / 2;
		
		zero = one = false;
		
		for (i = n - mid; i < mid; ++i)
			(s[i] == '0' ? zero : one) = true;
		
		if (zero && one)
			hi = mid;
		else lo = mid;
	}
	
	cout<<lo<<'\n';
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(){

  int n;
  int ans = 0;
  scanf("%d", &n);

  vector<int> v(2*n);
  REP(i, 2*n){
    scanf(" %d", &v[i]);
  }

  sort(v.begin(), v.end(), greater<int>());

  for(int i = 1 ; i < 2*n ; i += 2){
    ans += v[i];
  }

  printf("%d\n", ans);

  return 0;
}

Measured memory_bytes: 256
n = int(input())
 
string = {}
count = 0

for i in range(n):
    base = sorted(input())

    if string.get("".join(base)) != None:
        count += int(string["".join(base)])
        string["".join(base)] += 1
    else:
        string["".join(base)] = 1

print(count)


Measured memory_bytes: 17896
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  vector<int> B(N);
  for(int i=0; i<N; i++){
    cin >> B.at(i);
  }
  vector<int> C(N-1);
  for(int i=0; i<N-1; i++){
    cin >> C.at(i);
  }
  
  int ans = 0;
  for(int i=0; i<N; i++){
    int x = A.at(i);
    ans += B.at(x-1);
    if(i > 0){
      if(A.at(i) == A.at(i-1) + 1){
        ans += C.at(x-2);
      }
    }
  }
  cout << ans << endl;
}

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

int N;

using namespace std;

void dfs(string s, char mx) {
	if (s.length()==N) cout << s << endl;
  	else {
    	for (char i='a'; i<=mx; i++) {
        	if (i==mx) dfs(s+i, mx+1);
          	else dfs(s+i, mx);
        }
    }
}

int main() {
  	cin >> N;
  	dfs("", 'a');
	return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, k;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> k;
  vector<bool> f(n, false);

  REP(i, k) {
    int d;
    cin >> d;
    REP(j, d) {
      int a;
      cin >> a;
      a--;
      f[a] = true;
    }
  }

  int count = 0;
  REP(i, n) {
    if(!f[i]) count++;
  }

  cout << count << endl;
}


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

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

  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  
  int X[M];
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }
  
  sort(X, X+M);

  
  int dist[M-1];
  for (int i = 0; i < M-1; i++) {
    dist[i] = X[i+1]- X[i];
  }
  
  sort(dist, dist+M-1);
  
  int ans = 0;
  
  for (int i = 0; i < M-N; i++) {
    ans += dist[i];
  }
  
  cout << ans << endl;
  
  
}



Measured memory_bytes: 1024
def factor(n):
    a=[]
    suu=n
    for i in range(2,int(n**0.5//1)+1):
        if suu%i==0:
            sosuu=0
            while suu%i==0:
                sosuu+=1
                suu//=i
            for j in range(sosuu):
                a.append(i)
    if suu!=1:
        a.append(suu)
    print(n,end='')
    print(':',*a)
n=int(input())
factor(n)


Measured memory_bytes: 5640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){

	int X,N;
	cin>>X>>N;

	vector<int>table(102,0);
	
	REP(i,N){
		int a;
		cin>>a;
		table[a] = 1;
	}
	if(table[X] == 0){
		cout<<X<<endl;
		return 0;
	}
	table[101] = 0;
	int i = 1;
	while(X - i >= 0 || X + i <= 101){
		
		if(X - i >= 0 && table[X-i] == 0){
			cout<<X-i<<endl;
			return 0;
		}
		if(X + i <= 101 && table[X+i] == 0){
			cout<<X+i<<endl;
			return 0;
		}
		i++;
	}
	if(X + i ==  101){
		cout<<X + i<<endl;
	}
	return 0;
}



Measured memory_bytes: 3596
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var n int
	fmt.Scanln(&n)
	counter := 0
	result := 0

	var sc = bufio.NewScanner(os.Stdin)

	var slice = make([]int, n)
	sc.Split(bufio.ScanWords)
	for idx := range slice {
		if sc.Scan() {
			valueInt, _ := strconv.Atoi(sc.Text())
			slice[idx] = valueInt
		}
	}

	slice = append(slice, 100000000000)

	for index := 0; index < n; index++ {
		now := slice[index]
		next := slice[index+1]
		if now < next {
			if counter > result {
				result = counter
			}
			counter = 0
		} else {
			counter++
		}
	}

	fmt.Println(result)
}


Measured memory_bytes: 4096
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		mut sd: Chars,
		t: Chars,
	}

	if sd.len() < t.len() {
		println!("UNRESTORABLE");
		return;
	}

	let mut p = 99999;
	for i in 0..=sd.len()-t.len() {
		let mut ng = false;
		for j in 0..t.len() {
			if sd[i+j] != '?' && sd[i+j] != t[j] {
				ng = true;
				break;
			}
		}
		if ng == false {
			p = i;
		}
	}
	if p == 99999 {
		println!("UNRESTORABLE");
		return;
	}
	for i in 0..t.len() {
		sd[p+i] = t[i];
	}
	for i in 0..sd.len() {
		if sd[i] == '?' {
			print!("a");
		}
		else {
			print!("{}", sd[i]);
		}
	}
	println!("");
}



Measured memory_bytes: 2128
X = int(input())

if X == 2:
    print(2)
    exit()

prime = [2]
k = 3
while True:
    isPrime = True
    maxK = int(k ** 0.5) + 1
    for p in prime:
        if p >= maxK:
            break
        isPrime &= (k % p != 0)
    if isPrime:
        prime.append(k)
        if k >= X:
            break
    k += 2
print(prime[-1])


Measured memory_bytes: 41708
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep2(i,n) for (int i = 1; i <= (n); i++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
using ll = long long;
template <class T>
using Grid = vector<vector<T>>;

int main(){
    ll l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<double> x(N),y(N);
    for (int i=0;i<N;i++){
        cin >> x[i] >> y[i];
    }
    double sum = 0.0;
    for (int i=0;i<N;i++){
        for (int j=i+1;j<N;j++){
            sum += sqrt((x[i]-x[j])*(x[i]-x[j]) +(y[i]-y[j])*(y[i]-y[j]));
        }
    }
    cout << fixed << setprecision(7) << (double)sum*2.0/N << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>  
#include<algorithm>  
#include<string.h>  
#include<math.h>  
#include<stdio.h>  
#include<queue>  
#define INF 0x3f3f3f3f  
typedef long long ll;  
using namespace std;  
  
#define  N 15  
int n;  
int dis[N],maps[N][N];  
int main()  
{  
    int i,a,b,c,j,k;  
    while(scanf("%d",&n),n)  
    {  
        for(i=0;i<N;i++)  
        {  
            for(j=0;j<N;j++)  
            {  
                maps[i][j]=(i==j)?0:INF;  
            }  
        }  
  
        int m=-1;  
        for( i=0; i<n; i++)  
        {  
            scanf("%d%d%d",&a,&b,&c);  
            m=max(a,m);  
            m=max(b,m);  
            maps[a][b]=maps[b][a]=c;  
        }  
  
        for(k=0;k<=m;k++)  
        {  
            for(i=0;i<=m;i++)  
            {  
                for(j=0;j<=m;j++)  
                {  
                    if(maps[i][j]>maps[i][k]+maps[k][j])  
                        maps[i][j]=maps[i][k]+maps[k][j];  
                }  
            }  
        }  
  
        int  Min=INF;  
        int index=-1;  
        memset(dis,0,sizeof(dis));  
        for(i=0;i<=m;i++)  
        {  
            for(j=0;j<=m;j++)  
            {  
                dis[i]=dis[i]+maps[i][j];  
            }  
            if(Min>dis[i])  
            {  
                index=i;  
                Min=dis[i];  
            }  
        }  
        printf("%d %d\n",index,Min);  
    }  
    return 0;  
}  

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

typedef long long ll;

int main() {
    ll N, K, ans = 1;
    cin >> N >> K;
    if (N == 1) {
        cout << K << endl;
        return 0;
    }

    for (int i = 2; i <= sqrt(K); i++) {
        int cnt = 0;
        ll tmp = i;
        while (K%tmp==0) {
            cnt++;
            K/=tmp;
        }
        cnt /= N;
        for (int j = 0; j < cnt; j++) {
            ans *= tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256