akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

int main(){
  // int N; cin >> N ;
  ll x,a; cin >> x >> a ;
  if(x<a) cout << "0" << endl;
  else cout << "10" << endl;
  return 0;
}


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

class DisjointSet {
  public:
    int size;
    vector<int> p, rank;

  DisjointSet(){}
  DisjointSet(int size){
    p.resize(size, 0);
    rank.resize(size, 0);
    for ( int i = 0; i < size; i++){
      makeSet(i);
    }
  }

  void makeSet(int x){
    p[x] = x;
    rank[x] = 1;
  }

  int findSet(int x){
    if ( p[x] != x){
      p[x] = findSet(p[x]);
    }
    return p[x];
  }

  bool same(int x, int y){
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y){
    link(findSet(x), findSet(y));
  }

  void link(int x, int y){
    if ( rank[x] > rank[y]){
      p[y] = x;
    } else {
      p[x] = y;
      if ( rank[x] == rank[y]){
        rank[y]++;
      }
    }
  }
};

int main(){
  int n, q, com, x, y;
  cin >> n >> q;
  DisjointSet ds = DisjointSet(n+1);
  for ( int i = 0; i < q; i++){
    cin >> com >> x >> y;
    if ( com == 1){
      if ( ds.same(x, y) ) { cout << 1 << endl;}
      else { cout << 0 << endl;}
    } else {
      ds.unite(x, y);
    }
  }

  return 0;
}


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

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

    int h, w;
    cin >> h >> w;
    char a[h][w];

    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
        }
    }

    rep(i, h+2){
        cout << '#';
        rep(j, w){
            if(i == 0 || i == h+1) cout << '#';
            else cout << a[i-1][j];
        }
        cout << '#' << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
int color[N],d[N],f[N],M[N][N],n,time;
void dfs();
void visit(int);
int main()
{
  int u,v,k,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j] = 0;
    }
  }

  for(i=0;i<n;i++)
    {
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  v--;
	  M[u][v] = 1;
	}
    }

  dfs();

  return 0;
}


void dfs()
{
  int u;
  for(u=0;u<n;u++)
    {
      color[u] = WHITE;
    }
  time = 0;
  for(u=0;u<n;u++)
    {
      if(color[u] == WHITE)
	  visit(u); 
    }
  for(u=0;u<n;u++)
    {
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}




void visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++time;
  for(v=0;v<n;v++)
    {
      if(M[u][v] == 0)continue;
      if(color[v] == WHITE)
	{
	  visit(v);
	}
    }
  color[u] = BLACK;
  f[u] = ++time;
}



Measured memory_bytes: 2132
using System;

class AtCoder
{
    static void Main(string[] args)
    {
        var x = Console.ReadLine().Split(' ');     
      	var a = int.Parse(x[0]);
      	var b = int.Parse(x[1]);
      
      	if( (a & 0x000001) == 0 || (b & 0x0000001) == 0 ) {
          Console.WriteLine("Even");
        }
      else{
        Console.WriteLine("Odd");
      }
    }
}

Measured memory_bytes: 11092
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
using namespace std;

int main(){
	int t,p,r;
	while(cin>>t>>p>>r,t){
		vector<pair<int,pair<int,int> > > inf_team(t,make_pair(0,make_pair(0,0)));//problem,time,number
		REP(i,t)inf_team[i].second.second = -i;
		vector<vector<int> > penalty(t,vector<int>(p,0));
		REP(i,r){
			int t_id,p_id,time;
			string mes;
			cin >> t_id >> p_id >> time >> mes;
			t_id--;p_id--;
			if(mes=="WRONG"){
				penalty[t_id][p_id]++;
			}else{
				inf_team[t_id].second.first -= time + 1200*penalty[t_id][p_id];
				inf_team[t_id].first++;
			}
		}
		sort(inf_team.begin(),inf_team.end(),greater<pair<int,pair<int,int> > >());
		REP(i,t){
			cout << -inf_team[i].second.second + 1 << " " << inf_team[i].first << " " << -inf_team[i].second.first << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3216
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

count_dict = defaultdict(int)
for cal in A:
  count_dict[cal] += 1
    
from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

count_result = defaultdict(list)
for k,v in count_dict.items():
  if v > 2:
    count_result[k] = [combinations_count(v,2), combinations_count(v-1,2)]
  elif v == 2:
    count_result[k] = [1,0]    
  else:
    count_result[k] = [0,0]

all_ans = 0
for v in count_result.values():
  all_ans += v[0]


for _ in A:
  ans = all_ans - count_result[_][0] + count_result[_][1]
  print(ans)



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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int a[maxn];

void solve() {
    int n;
    cin >> n;
    int mi, cnt = 1;
    for (int i = 1; i <= n; i++) cin >> a[i];
    mi = a[1];
    for (int i = 2; i <= n; i++) {
        if (a[i] <= mi) mi = a[i], cnt++;
    }
    cout << cnt << endl;
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(0,c-(a-b))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define max 100005
#define nil -1

constexpr int inf = 1000000;
vector<vector<int>> g;
vector<int> d;

void bfs(int s){
    d.resize(max);
   fill(d.begin(),d.end(),inf);
   d[s]=0;
   queue<int> q;
   q.push(s);
   while(!q.empty()){
       int now=q.front();
       q.pop();
       for(auto &e:g[now]){
           if(d[e]==inf){
               d[e]=d[now]+1;
               q.push(e);
           }
       }
   }
}

int main() {
  int  n,u,k,v;
  cin>>n;
    g.resize(n);
    d.resize(n);
  rep(i,n){
      cin>>u>>k;
      u--;
      for(int j=0;j<k;j++){
          cin>>v;
          v--;
          g[u].push_back(v);
        }
    }
    bfs(0);
    rep(i,n){
        if(d[i]<inf){
            cout<<i+1<<" "<<d[i]<<endl;
        }else{
            cout<<i+1<<" "<<-1<<endl;
        }
    }
  return 0;
}



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

int main(void)
{
    int a, b; cin >> a >> b;
    if (b == 1) {
        cout << 0 << "\n";
    }
    else if (b <= a-1) {
        cout << 1 << "\n";
    }
    else {
        int count = 0;
        while (b > a)
        {
            count++;
            b -= a - 1;
        }
        count++;
        cout << count << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    double d=sc.nextDouble();
    double x=0,y=0;
    int count=0;
    for(int i=0;i<n;i++)
    {
      x=sc.nextDouble();
      y=sc.nextDouble();
      double val=(x*x)+(y*y);
      double ans=Math.sqrt(val);
      if(ans<=d)
        count++;
    }
    System.out.println(count);
  }
}


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

class P
{
  static void Main()
  {
    var a = Console.ReadLine()
            .Split(' ')
            .Select(x => int.Parse(x))
            .ToArray();
    Array.Sort(a);
    Console.WriteLine("{0} {1} {2}", a[0], a[1], a[2]);
  }
}

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

int main()
{
    int n;
    int i, judge, count = 0;
    
    cin >> n;
    
    judge = n % 10;
    count++;
    n = n /10;
    
    for(i = 0; (i < 3) && (count < 3); i++) {
        if((n % 10) == judge) {
            count++;
        } else {
            count = 1;
            judge = n % 10;
        }
        
        n = n / 10;
    }
    
    if(count == 3) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

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

using namespace std;

#define MAX 51

struct Point{
  int x,y;
  double dist(const Point &p){
    return abs(x-p.x)+abs(y-p.y);
  }
};

int N,m[MAX];
vector<Point> lines[MAX];

int getDir(Point &p1,Point &p2){
  if(p1.x == p2.x){
    return (p1.y < p2.y ? 0 : 2);
  }
  return (p1.x < p2.x ? 3 : 1);
}

bool equals(vector<Point> &l1,vector<Point> &l2){
  int s1 = l1.size(), s2 = l2.size();
  if(s1 != s2) return false;
  bool flg = false;
  int d1,d2,diff;
  for(int i = 0 ; i < s1-1 ; i++){
    if(l1[i].dist(l1[i+1]) != l2[i].dist(l2[i+1])){
      flg = true; break;
    }
    d1 = getDir(l1[i],l1[i+1]);
    d2 = getDir(l2[i],l2[i+1]);
    if(i > 0){
      if(diff != (d1-d2+4)%4){
        flg = true; break;
      }
    }else{
      diff = (d1-d2+4)%4;
    }
  }
  if(!flg) return true;
  flg = false;
  for(int i = s1-1 ; i > 0 ; i--){
    if(l1[s1-i-1].dist(l1[s1-i]) != l2[i].dist(l2[i-1])){
      flg = true; break;
    }
    d1 = getDir(l1[s1-i-1],l1[s1-i]);
    d2 = getDir(l2[i],l2[i-1]);
    if(i != s1-1){
      if(diff != (d1-d2+4)%4){
        flg = true;
        break;
      }
    }else{
      diff = (d1-d2+4)%4;
    }
  }
  return !flg;
}

int main(){
  while(cin >> N,N){
    for(int i = 0 ; i <= N ; i++){
      cin >> m[i]; lines[i].clear();
      for(int j = 0 ; j < m[i] ; j++){
        int x,y;
        cin >> x >> y;
        lines[i].push_back((Point){x,y});
      }
    }
    for(int i = 1 ; i <= N ; i++){
      if(equals(lines[0],lines[i])){
        cout << i << endl;
      }
    }
    cout << "+++++" << endl;
  }
  return 0;
}

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

int main()
{
	unsigned n, money = 100000;
	for (cin >> n; n; n--) {
		money *= 1.05;
		if (money % 1000) {
			money = money - money % 1000 + 1000;
		}
	}
	cout << money << endl;
	return 0;
}

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

int main()
{
    int n,h,w;
    cin>>n>>h>>w;
    int cp=0;
    while(n--){
        int a,b;
        cin>>a>>b;
        if(a>=h && b>=w)
        cp++;
    }
    cout<<cp;
    return 0;
}


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

using namespace std;

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

    int n;
    cin>>n;

    vector<int> arr(n);
    for(int i=0;i<n;i++) cin>>arr[i];

    int q;
    cin>>q;

    while(q--)
    {
        int key;
        cin>>key;

        cout<<(lower_bound(arr.begin(),arr.end(),key)-arr.begin())<<endl;
    }

    return 0;
}



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

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

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

void formalize(char s[2052]){
	int i,j,k;
	int flg = 0, diff;
	int len = strlen(s);
	char tmp[2052];

	for(i=len;!flg && i>=4;i-=2){
		if(len % i == 0){
			for(j=0;!flg && j<len;j+=i){
				for(k=j+2;k<j+i;k+=2){
					if(s[k] != '0' || s[k+1] != '0') break;
				}
				if(k != j+i) break;
			}
			if(j == len){
				flg = 1;
				break;
			}
		}
	}

	if(!flg){return;}

	diff = i;
	strcpy(tmp,s);
	for(i=0;i<2052;i++) s[i] = '0';
	for(i=0;i<len;i+=diff){
		s[2*i/diff] = tmp[i];
		s[2*i/diff+1] = tmp[i+1];
	}
	s[2*i/diff] = 0;
}

void wideForm(char s[2052],int mult){
	int i;
	int len = strlen(s);
	char tmp[2052];

	strcpy(tmp,s);
	for(i=0;i<2052;i++) s[i] = '0';
	for(i=0;i<len;i+=2){
		s[i*mult] = tmp[i];
		s[i*mult+1] = tmp[i+1];
	}
	s[len*mult] = 0;
}

int main(void){
	int i,j;
	int n,m;
	int l;
	int ans[2052];
	char s[8][2052];

	scanf("%d",&n);
	while(n--){
		scanf("%d",&m);
		l = 1;
		for(i=0;i<m;i++){
			scanf("%s",s[i]);
			formalize(s[i]);
			if(l <= 2048) l = lcm(l,strlen(s[i]));
		}

		if(l > 2048){
			printf("Too complex.\n");
			continue;
		}

		for(i=0;i<2052;i++) ans[i] = 0;
		for(i=0;i<m;i++){
			wideForm(s[i],l/strlen(s[i]));
			for(j=0;j<l;j++) ans[j] += s[i][j] - '0';
		}

		for(i=0;i<l;i++){
			if(ans[i] >= 10) putchar(ans[i]-10+'A');
			else printf("%d",ans[i]);
		}
		printf("\n");
	}

	return 0;
}

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

int main( void ) 
{
	double a,b,C;
	double S,L,h;
	double A,a2,b2,c,h2;
	double radian;
	
    scanf( "%lf%lf%lf", &a, &b, &C );
    
    if( 90 ==C ) {
    	h=b;
		a2=pow( a, 2 );
		b2=pow( b, 2 );
		c=sqrt( a2+b2 );
    } else if( C < 90 ) {
    	radian=C* M_PI/ 180.0;
	 	C=sin( radian );			
		h=C*b;
		h2=pow( h, 2 );
		b2=pow( b, 2 );
		A=sqrt( b2-h2 );
		if( a==A ) {
			c=h;
		} else if( a < A ) {
			c=sqrt( pow( (A-a), 2 )+h2 );
		} else {
			c=sqrt( pow( (a-A), 2 )+h2 );
		}		
    } else {
    	C=180-C;
    	radian=C* M_PI/ 180.0;
	 	C=sin( radian );
    	h=C*b;
		h2=pow( h, 2 );
		b2=pow( b, 2 );
		A=sqrt( b2-h2 );
		a2=pow( A+a, 2 );		
		c=sqrt( a2+h2 );    	
    }
	S=a*h*0.5;
	L=a+b+c;
	


	printf( "%.4lf\n", S );
	printf( "%.4lf\n", L );
	printf( "%.4lf\n", h );
		
	return 0;
}

Measured memory_bytes: 676
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
#include<cstring>
#include<vector>
#include<stack>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<iomanip>
#include<functional>
#include<unordered_map>
#define io ios::sync_with_stdio(false),cin.tie(0)
#define inf 0x3f3f3f3f
#define ll long long
#define P pair<int,int>
#define lc rt*2
#define rc rt*2+1
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const double PI = 3.1415926536;

using namespace std;

int a[maxn], b[maxn], m[maxn][3];


int main()
{
	int x, y, k;
	cin >> x >> y >> k;
	for (int i = 1; i <= x; ++i)
		cin >> a[i];
	for (int i = 1; i <= y; ++i)
		cin >> b[i];
	for (int i = 1; i <= k; ++i)
		cin >> m[i][0] >> m[i][1] >> m[i][2];
	int mi = inf;
	for (int i = 1; i <= k; ++i)
	{
		mi = min(mi, a[m[i][0]] + b[m[i][1]] - m[i][2]);
	}
	int mia = inf, mib = inf;
	for (int i = 1; i <= x; ++i)
		mia = min(mia, a[i]);
	for (int i = 1; i <= y; ++i)
		mib = min(mib, b[i]);
	cout << min(mi, mia + mib);
	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll N, M, K;

ll binary_search(ll l, ll r, vector<ll> A, vector<ll> B, vector<ll> A_sum, vector<ll> B_sum){
    map<ll, bool> tried;
    tried[l] = true;
    tried[r] = false;

    while (true){
        ll mid = (r + l) / 2;

        bool flag = false;
        rep(i, mid + 1){
            if (i > N || mid - i > M || mid - i < 0){continue;}
            if (A_sum.at(i) + B_sum.at(mid - i) <= K){flag = true; break;}
        }
        // cout << mid << " " << flag << endl;

        if (flag){
            l = mid;
            tried[mid] = true;
        } else {
            r = mid;
            tried[mid] = false;
        }

        // // 一つ前ではだめで，ここではokという変曲点があるはず
        if (tried.find(mid+1) != tried.end() && !tried[mid + 1] && tried[mid]){
            return mid;
        }
        if (tried.find(mid-1) != tried.end() && tried[mid - 1] && !tried[mid]){
            return mid - 1;
        }
    }
}

void Main() {
    cin >> N >> M >> K;
    vector<ll> A, B, A_sum, B_sum;
    A_sum.push_back(0);
    B_sum.push_back(0);

    ll a_sum = 0, b_sum = 0;
    rep(i, N){ll a; cin >> a; a_sum += a; A.push_back(a); A_sum.push_back(a_sum);}
    rep(i, M){ll b; cin >> b; b_sum += b; B.push_back(b); B_sum.push_back(b_sum);}

    cout << binary_search(0, N + M + 1, A, B, A_sum, B_sum) << endl;
}

    // ll a_ind = 0, b_ind = 0, cnt = 0, time = 0;
    // while (true){
    //     if (A.at(a_ind) < B.at(b_ind)){ // Aを読む
    //         if (time + A.at(a_ind) <= K){
    //             time += A.at(a_ind);
    //             a_ind++;
    //             cnt++;
    //         } else {
    //             break;
    //         }
    //     } else {
    //         if (time + B.at(b_ind) <= K){
    //             time += B.at(b_ind);
    //             b_ind++;
    //             cnt++;
    //         } else {
    //             break;
    //         }
    //     }
    // }

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 17476
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>

using namespace std;

#define sz			size()
#define lgt			length()
#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()
#define pb			push_back
#define SORT(a)		sort(ALL(a));
#define RSORT(a)	sort(RALL(a));
#define mp			make_pair
#define dump(x)		cerr<<#x<<" = "<<(x)<<endl;
#define fir			first
#define sec			second

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<string> vs;

int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
vs form(string a,char s){vs v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(b);b="";}else b+=a[i];}v.pb(b);return v;}
vi formint(string a,char s){vi v;string b;rep(i,a.lgt){if(a[i]==s){v.pb(toInt(b));b="";}else b+=a[i];}v.pb(toInt(b));return v;}

const double EPS=1e-10,PI=acos(-1.0);
const int INF=2100000000;

int main(void)
{
	int n, m, tmp;
	while (cin >> n >> m, n && m){
		int res = 0;
		vi v, v1, v2;
		
		v.pb(0);
		for (int i = 0; i < n; i++){
			cin >> tmp;
			v.pb(tmp);
		}
		for (int i = 0; i < v.sz; i++){
			for (int j = 0; j < v.sz; j++){
				v1.pb(v[i] + v[j]);
				v2.pb(v[i] + v[j]);
			}
		}
		SORT(v1);
		RSORT(v2);
		
		for (int i = 0, j = 0; i < v1.sz && j < v2.sz;){
			if (m < v1[i] + v2[j]) j++;
			else {
				res = max(res, v1[i] + v2[j]);
				i++;
			}
		}
		
		cout << res << endl;
		v.clear();
	}
	
	return 0;
}

Measured memory_bytes: 9140
///   ***   ---   |||		 In the name of ALLAH		|||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {			cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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


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

int main()
{
	optimize();

	int t;
	cin >> t;

	if ( t >= 30 ) cout << "Yes\n";
	else cout << "No";

	return 0;
}


















Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int a, b; cin >> a >> b;
	int num = 10;
	while (num <= b) num *= 10;
	int c = a * num + b;
	bool flag = false;
	for (int i = 0; i * i <= c; i++) {
		if (i * i == c) flag = true;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=list(S())

  c1=c2=0
  f=True
  for x in s:
    if f:
      if x=='0':
        c1+=1
      f=False
    else:
      if x=='1':
        c1+=1
      f=True

  f=False
  for x in s:
    if f:
      if x=='0':
        c2+=1
      f=False
    else:
      if x=='1':
        c2+=1
      f=True

  # print(c1,c2)
  return min(c1,c2)

print(main())


Measured memory_bytes: 6316
#include <bits/stdc++.h>
#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 ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int h, a;
    cin >> h >> a;
    if(h % a == 0) cout << h / a << endl;
    else cout << h / a + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  char a,b;
  cin >> a >> b;
  if((a=='H')^(b=='H')) {
    cout << "D" << endl;
  } else {
    cout << "H" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(){
    int N, K, i=1, count=0;
    cin >> N >> K;
    while (true){
        count ++;
        i = i * K;
        if (N / i* K==0) {
            cout << count << endl;
            break;
        }
    }
    return 0;
}


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

int main() {
    int N; cin >> N;
    int* d = new int[N];
    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++){
            sum += d[i] * d[j];
        }
    }
    cout << sum << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long


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

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

int32_t main() {
IOS;
int n;
cin>>n;
int above=0;
vector<int> cnt(13,0);
    for (int i = 0; i < n; ++i) {
        int a;
        cin>>a;
        if(a>=1 and a<=399)cnt[1]=1;
        else if(a>=400 and a<=799)cnt[8]=1;
        else if(a>=800 and a<=1199)cnt[2]=1;
        else if(a>=1200 and a<=1599)cnt[3]=1;
        else if(a>=1600 and a<=1999)cnt[4]=1;
        else if(a>=2000 and a<=2399)cnt[5]=1;
        else if(a>=2400 and a<=2799)cnt[6]=1;
        else if(a>=2800 and a<=3199)cnt[7]=1;
        else above++;
    }
    int ans=0;
    for (int i = 1; i <=8; ++i) {
        ans+=cnt[i];
    }
    cout<<max(1ll,ans)<<" "<<ans+above<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  vi A(3*N);
  rep(i,3*N) {
    cin >> A[i];
  }
  priority_queue<int,vi,greater<int>> fir;
  ll f = 0;
  rep(i,N) {
    fir.push(A[i]);
    f += A[i];
  }
  vl ma(N+1,0);
  ma[0] = f;
  srep(i,N,2*N) {
    fir.push(A[i]);
    f += A[i];
    f -= fir.top();
    fir.pop();
    ma[i-N+1] = f;
  }
  priority_queue<int> sec;
  ll s = 0;
  rep(i,N) {
    sec.push(A[i+2*N]);
    s += A[i+2*N];
  }
  vl mi(N+1,0);
  mi[N] = s;
  for(int i = 2*N-1;i >= N;i--) {
    sec.push(A[i]);
    s += A[i];
    s -= sec.top();
    sec.pop();
    mi[i-N] = s;
  }
  ll ans = -LINF;
  rep(i,N+1) {
    ans = max(ans,ma[i]-mi[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
    while (1)
    {

        int n;
        cin >> n;
        if (n == 0)
            return 0;
        vector<int> b(10000010, 0);
        for (int i = 0; i < n; i++)
        {
            cin >> b[i];
        }

        bool valid = true;
        for (int i = 0; i < n; i++)
        {
            if ((i + 1) != b[i])
            {
                valid = false;
            }
        }

        if (valid)
        {
            cout << 0 << endl;
            goto END;
        }

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

            /*
        for (int j = 0; j < 10; j++)
        {
            cout << b[j] << " ";
        }*/
            //cout << endl;
            int cnt = 0;
            for (int j = 0;; j++)
            {
                if (b[j] == 0)
                {
                    break;
                }
                b[j]--;
                cnt++;
            }

            b[cnt] = cnt;

            int id = 0;
            for (int j = 0; j <= cnt; j++)
            {
                if (b[j] != 0)
                {
                    b[id++] = b[j];
                }
            }

            for (int j = id; j <= 1000; j++)
            {
                b[j] = 0;
            }

            bool valid = true;
            for (ll j = 0; j < id; j++)
            {
                if ((j + 1) != b[j])
                {
                    valid = false;
                }
            }

            if (valid)
            {
                cout << i + 1 << endl;
                goto END;
            }
        }

        cout << -1 << endl;
    END:;
    }
}


Measured memory_bytes: 41876
n = int(input())
if n==0:
    print(0)
if n%2==0:
    print(-1)
elif n%5==0:
    print(-1)
else:
    k=7
    l=1
    k%=n
    while k!=0:
        l+=1
        k*=10
        k+=7
        k%=n
        #print(k)
    print(l)
        
    

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const int MD = 1e9+7; typedef vector<ll> VL;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	VI a={0} , b={0};
	rep(i, n){
		int p; cin >>p;
		if(p < 0) b.push_back(-p);
		else a.push_back(p);
	}
	sort(all(b));
	int na =sz(a), nb =sz(b);
	ll ans = 1LL<<60;
	rep(i, min(sz(a),k+1)){
		ll wb = 1LL<<60;
		if(k - i < sz(b)) wb = b[k-i];
		dbg("c",i, a[i], wb );
		ans = min(ans, a[i] + wb + min<ll>(a[i], wb));
	}
	
	cout << ans <<"\n";
	
	
	
	
	return 0;
}


Measured memory_bytes: 1020
M, N = map(int,input().split())
A = list(map(int,input().split()))
if M >= 3:
    now = A[0]
    ans = 0
    for k in range(1,N):
        if A[k] == now:
            now = -1
            ans += 1
        else:
            now = A[k]
    print(ans)
else:
    now = A[0]
    ans1 = 0
    for k in range(1,N):
        if A[k] == now:
            now = 3-now
            ans1 += 1
        else:
            now = A[k]

    ans2 = 1
    now = 3-A[0]
    for k in range(1,N):
        if A[k] == now:
            now = 3-now
            ans2 += 1
        else:
            now = A[k]

    print(min(ans1,ans2))



Measured memory_bytes: 16660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

vector<vector<int>> g;

struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n, -1){}

    int find(int x){
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){
        return (find(x) == find(y));
    }
    int size(int x){return -d[find(x)];}
};


bool f(int n, int m, int a, int b){
    UnionFind uf(n);
    rep(i,n){
        for(auto v : g[i]){
            if (i == a && v == b) continue;
            if (i == b && v == a) continue;
            uf.unite(i, v);
        }
    }
    return uf.size(a) != n;
}

int main(){
    int n, m;
    cin >> n >> m;
    g.resize(n);
    vector<pair<int, int>> e(m);
    rep(i,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        e[i] = (make_pair(a, b));
    }

    int ans = 0;
    rep(i,m){
        int a, b;
        a = e[i].first;
        b = e[i].second;
        if (f(n, m, a, b)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,s,q;
    cin>>a>>s;
    q=((a+s)/2);
    if((a+s)%2==1)
        cout<<"IMPOSSIBLE";
    else
    {
        cout<<q;
        return 0;
    }
}


Measured memory_bytes: 256
// コード長484Byte, 実行時間290ms, メモリ896KB
#include <stdio.h>

int main()
{
  int i, j, k, d, n;
  scanf("%d %d", &n, &k);
  
  int h[n+k];
  int cost[n+k];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  for (; i<n+k; i++) {
    h[i] = h[n-1];
    cost[i] = 0;
  }

  for (i=n-1; i>=0; i--) {
    cost[i] = h[i]-h[i+k];
    if (cost[i]<0) cost[i]=-cost[i];
    cost[i] += cost[i+k];
    for (j=k-1; j>0; j--) {
      d = h[i]-h[i+j];
      if (d<0) d=-d;
      if (j==k || cost[i] > d + cost[i+j])
	cost[i] = d + cost[i+j];
    }
  }
  
  printf("%d\n", cost[0]);

  return 0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
 
int main() {
  int n ; cin>>n;
  map<string,int>mp;
  rep(i,n){
    string s; cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;    
  } 
  ll num=0;
  for(auto p:mp){
    num+=p.second*(ll)(p.second-1)/2;
  }    
  cout<<num<<endl; 
}


Measured memory_bytes: 11136
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;
ll INF=1e10;

int main(){
    ll n,m; cin>>n>>m;
    vector<vector<ll>>a(m,vector<ll>(3));
    rep(i,m){
        cin>>a[i][0]>>a[i][1];
        a[i][2]=i+1;
    }
    sort(a.begin(),a.end());
    vector<vector<ll>>na(m,vector<ll>(3));
    ll cnt=1;
    rep(i,m){
        na[i][0]=a[i][2];
        na[i][1]=a[i][0];
        na[i][2]=cnt;
        if(i<=m-2&&a[i+1][0]==a[i][0])cnt++;
        else cnt=1;
    }
    sort(na.begin(),na.end());
    rep(i,m){
        string s=to_string(na[i][1]);
        string t=to_string(na[i][2]);
        rep(j,6-s.size())cout<<'0';
        cout<<s;
        rep(j,6-t.size())cout<<'0';
        cout<<t<<endl;
    }
}



























































































Measured memory_bytes: 14352
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define REPS(i,n) for(int i=1;i<=(n);i++)
#define RREPS(i,n) for(int i=(n);i>0;i--)
#define mp make_pair
#define pb(a) push_back(a)
typedef long long ll;

#define MAX_N 100000
vector<int> G[MAX_N];
int dis1[MAX_N];
int disN[MAX_N];
int N;
void dfs1(int n,int d = 0){
    dis1[n] = d;
    REP(i,G[n].size()){
      if(dis1[G[n][i]] == 0 && G[n][i] != 0) dfs1(G[n][i],d+1);
    }
}
void dfsN(int n,int d = 0){
    disN[n] = d;
    REP(i,G[n].size()){
      if(disN[G[n][i]] == 0 && G[n][i] != N-1) dfsN(G[n][i],d+1);
    }
}
int main(){

  cin >> N;
  REP(i,N-1){
    int a,b;
    cin >> a >> b;
    G[a-1].pb(b-1);
    G[b-1].pb(a-1);
  }
  dfs1(0);
  dfsN(N-1);
  int b = 0;
  int w = 0;
  REP(i,N){
    if(dis1[i] <= disN[i]) b++;
    else w++;
  }
  if(b > w) cout << "Fennec" << endl;
  else cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 11136
import java.util.*;

public class Main {
    static long ans = 1001001001001001018L;;
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        divisorList(n);
        System.out.println(ans);
    }
        
    public static List<Long> divisorList(long n) {
        List<Long> res = new ArrayList<Long>();
        for (long i = 1; i * i <= n; i++) {
            if (n % i == 0) {
                res.add(i);
                
                long j = n / i;
                if (j != i) {
                    res.add(j);
                    
                    String s = String.valueOf(i);
                    String t = String.valueOf(j);
                    ans = Math.min(ans, Math.max(s.length(), t.length()));
                } else {
                    String u = String.valueOf(i);
                    ans = Math.min(ans, u.length());
                }
            }
        }
        res.sort(Comparator.naturalOrder());
        
        return res;
    }
}


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


int main() {
    int a[3];
    int ans = 0;
    for(int i = 0; i < 3;i++) {
        cin >> a[i];
        ans += a[i];
    }

    if(ans >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    
    return 0;
}



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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    set<int>se;
    se.insert(a);
    se.insert(b);
    se.insert(c);
    cout<<se.size()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    bool jud = false;

    rep(i,n){
        char c; cin >> c;
        if(c == 'Y') jud = true;
    }

    if(jud) cout << "Four" << endl;
    else cout << "Three" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String ans = (N == 0)? "0" : "";

    while(N != 0){
      if(N % 2 != 0){
        N--;
        ans = "1" + ans;
      }else{
        ans = "0" + ans;
      }
      N /= -2;
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include<stdio.h>
#define N 100000

typedef struct Card{
  char mark;
  int numver;
  int order;
}Card;

int Partition(Card A[], int p, int r){
  int x,i,j;
  Card k;
  
  x = A[r].numver;
  i = p-1;
  for(j = p; j <= r-1; j ++){
    if (A[j].numver <= x){
      i = i+1;
      k = A[i]; 
      A[i] = A[j] ;
      A[j] = k;
    }
  }
  k = A[i+1];
  A[i + 1] = A[r];
  A[r] = k;

  return i+1;
}

void Quicksort(Card A[], int p, int r){
  int q;
  if(p < r){
    q = Partition(A, p, r);
    Quicksort(A, p, q-1);
    Quicksort(A, q+1, r);
  }
}

int main(){
  Card A[N];
  int n, i,judge=0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i ++){
    scanf(" %c %d", &A[i].mark, &A[i].numver);
    A[i].order = i;
  }
  Quicksort(A, 0, n-1);
  
  for(i = 0; i < n-1; i ++){
    if(A[i].numver == A[i+1].numver){
      if(A[i].order > A[i+1].order){
	judge = 1;
	break;
      }
    }
  }
  if(judge == 0){
    printf("Stable\n");
  }
  else 
    printf("Not stable\n");
  
  for(i = 0; i < n; i ++){
    printf("%c %d\n",A[i].mark, A[i].numver);
  }
  return 0;   
}

Measured memory_bytes: 1780
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main()
{
	char str[16];

	cin >> str;

	sort(str, str + 4);

	if (str[0] == str[1] && str[2] == str[3] && str[0] != str[2])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


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

int main(void){
	stack<int> st;
	string s;
	while(cin >> s){
		char c = s[0];
		if(isdigit(c)){
			st.push(stoi(s));
		}else{
			int b = st.top();st.pop();
			int a = st.top();st.pop();
			int ret = 0;
			if(c == '+') ret = a + b;
			else if(c == '-') ret = a - b;
			else if(c == '*') ret = a * b;
			st.push(ret);
		}
		cin.ignore();
	}	
	cout << st.top() << endl;
	return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int K;
	string S;

	cin >> K >> S;

	if (S.length() > K) cout << S.substr(0, K) << "..." << endl;
	else cout << S << endl;

	return 0;
}


Measured memory_bytes: 3560
import java.util.*;
public class Main{
    public static void main(String[] args){
        try{
            Scanner sn = new Scanner(System.in);
            String str = sn.nextLine();
            int r = Integer.parseInt(str);
            sn.close();
           
            if(1 <= r || r <=100){
                System.out.println(r*r*3);
            }else{
                return;
            }
        }catch(Exception e){
            //do nothing
            return;
        }
    }
}

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

int main(){
  int m,d;
  cin >> m >> d;
  int c=0;
   for (int i = 1; i <= m; i++)
  {
    for (int j = 1; j <= d; j++)
    {
      int d10 = j/10;
      int d1 = j%10;
      if(i == d10*d1 && d10>=2 && d1 >=2){
          c++;
      }
    }
      
  }
   
  cout << c;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) {
        cout << (a + b) / 2 << endl;
    }
    else cout << (a + b) / 2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import chain
n=int(input())
c=list(range(1,1+2*n))
for _ in[0]*int(input()):
    k=int(input())
    c=c[k:]+c[:k]if k else list(chain.from_iterable(x for x in zip(c[:n],c[n:])))
for x in c:print(x)


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

/* 比較関数(小->大) */
/*
int compar(const char *val1, const char *val2) {
    if ( *val1 < *val2 ) {
        return -1;
    } else if ( *val1 == * val2 ) {
        return 0;
    } else {
        return 1;
    }
}
//*/

int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;
 
    return strcmp( left_char, right_char );
}

int main(){
    int N, count;
    char buf;
    char S[300000][20] = {};
    scanf("%d", &N);
    for(int i=0; i<N; i++){
        //ぶち込む
        scanf("%s", S[i]);
    }

    //ソートする
    qsort(S, N, sizeof(char)*20,compare_char);

    //ひとつ前と違ったらカウント増やす
    count = 1;
    for(int i=1; i<N; i++){
        if(strcmp(S[i-1], S[i]))count++;
    }

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

    return 0;
}

Measured memory_bytes: 11240
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;
vector<vector<int>> edges(1e5L+5);
int in_degree[(int)1e5+5];
int visited[(int)1e5+5];
int ans=0;
int dist[(int)1e5+5];
void dfs(int st){
    visited[st]=1;
    
    for(int i:edges[st]){
        dist[i]=max(dist[i],dist[st]+1);
        in_degree[i]--;
        if(in_degree[i]==0){
            dfs(i);
        }
    }
}

int32_t main(){
    vaibhavv06;
	int n,m; cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y; cin>>x>>y;
        edges[x].push_back(y);
        in_degree[y]++;
    }
    for(int i=1;i<=n;i++){
        if(!visited[i] && in_degree[i]==0){
            dfs(i);
        }
    }
    for(int i=0;i<=n;i++)ans=max(ans,dist[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 11136