akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int main(){
    ll n; cin >> n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));

    vector<int> zero,pos,neg;
    for(int i=0;i<n-1;i++){
        if(a[i] > 0) pos.push_back(a[i]);
        else if(a[i] < 0) neg.push_back(a[i]);
        else if(a[i] == 0) zero.push_back(a[i]);
    }

    vector<pii> ans;
    if(a[0] >= 0){
        int now = a[0];
        for(int i=1;i<n-1;i++){
            ans.emplace_back(now,a[i]);
            now -= a[i];
        }
        ans.emplace_back(a[n-1],now);
        cout << a[n-1] - now << endl;
        for(auto& p : ans){
            cout << p.first << " " << p.second << endl;
        }
        return 0;
    }else{
        for(int i=n-2;i>=0;i--){
            if(a[i] < 0) break;
            ans.emplace_back(a[0],a[i]);
            a[0] -= a[i];
        }

        for(int i=0;i<n-1;i++){
            if(a[i] >= 0) break;
            ans.emplace_back(a[n-1],a[i]);
            a[n-1] -= a[i];
        }
        cout << a[n-1] << endl;
        for(auto& p : ans){
            cout << p.first << " " << p.second << endl;
        }
    }
}


Measured memory_bytes: 3828
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

const int INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL b){
    if(b==0)return a;

    return gcd(b,a%b);
}

int main(){
    LL n,k;
    cin>>n>>k; 
    int v[100100]={0};
    int a,b;
    int ma=-11111;
    for(int i=0;i<n;++i){
        cin>>a>>b;
        if(ma<=a)ma=a;
        v[a]+=b;
    }
    int ans;
    for(int i=0;i<ma;++i){
        k-=v[i];
        if(k<=0){
        ans=i;
        break;
        }
    }
    cout<<ans<<endl;
}

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

int main()
{
  string S,T,U;
  cin>>S>>T;
  int r_number,b_number;
  cin>>r_number>>b_number;
  cin>>U;
  if(U==S)
    r_number-=1;
  else
    b_number-=1;
  
  cout<<r_number<<" "<<b_number;
    return 0;
}

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

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

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

    double even = n / 2;
    double odd = n / 2;

    if (n % 2 == 1) {
        odd++;
    }

    double ans = odd / (even + odd);

    cout << printf("%.10f",  ans ) << endl;


}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //// 提出時にはコメントアウトする
            //var exStdIn = new System.IO.StreamReader("stdin.txt");
            //System.Console.SetIn(exStdIn);

            // 解答
            int ret = 0;

            // 読み込み
            string line = Console.ReadLine();
            // 半角スペースでsplit
            string[] lineSplit = line.Split(' ');
            // intに変換
            int a = int.Parse(lineSplit[0]);
            int b = int.Parse(lineSplit[1]);

            // 2回繰り返す
            for (int i = 0; i < 2; i++ )
            {
                if ( a > b)
                {
                    ret += a;
                    a--;
                }
                else
                {
                    ret += b;
                    b--;
                }
            }

            Console.WriteLine(ret);
        }
    }
}


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

int main() {
  int sum;
  sum=0;
  vector<int>iroha(3);
  for(int i=0;i<3;i++){
    cin>>iroha.at(i);
    sum+=iroha.at(i);
  }
  if(sum!=17){
    cout<<"NO"<<endl;
  }
  else{
    sort(iroha.begin(),iroha.end());
    if(iroha.at(2)==7){
      if(iroha.at(0)==iroha.at(1)){
        cout<<"YES"<<endl;
      }
      else{
         cout<<"NO"<<endl;
      }
    }
    else{
      cout<<"NO"<<endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static int mod = 1000000007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		long [][][][]dp = new long [n+1][5][5][5];
		
		//左から現在の桁数、n-2,n-1,n,番目の文字がいくつか
		//0 -> null,1 -> A, 2 -> G,3 -> C, 4 -> T のようにした
		
		// 
		dp[0][0][0][0] = 1L;
		
		for(int i = 1 ; i <= n ;i++) {
			for(int j = 0 ; j < 5 ; j++) {
				for(int k = 0 ; k < 5 ; k++) {
					for(int l = 0 ; l < 5 ; l++) {
						for(int m = 1 ; m < 5 ; m++) {
							if(j == 1 && l == 2 && m == 3) {continue;}
							if(j == 1 && k == 2 && m == 3) {continue;}
							if(k == 1 && l == 2 && m == 3) {continue;}
							if(k == 1 && l == 3 && m == 2) {continue;}
							if(k == 2 && l == 1 && m == 3) {continue;}
							
							dp[i][k][l][m] = (dp[i][k][l][m] + dp[i-1][j][k][l])% mod;
						
						}
					}
				}
			}
		}
		
		
		long ans = 0;
		
		for(int i = 1 ; i < 5 ;i++) {
			for(int j = 1 ; j < 5 ; j++) {
				for(int k = 1 ; k < 5 ; k++) {
					ans = (ans + dp[n][i][j][k])%mod;
				}
			}
		}
	
		System.out.println(ans);
		
	}	
		
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M = 302;
const ll mod = 998244353;
int a[M];
ll dp[(M*M)][2][2],tp[(M*M)][2][2],ncr[M][M],val[M][3];
void pre()
{
	ncr[0][0] = 1;
	for(int i=1;i<M;i++)
	{
		ncr[i][0] = 1;
		for(int j=1;j<=i;j++)
		{
			ncr[i][j] = (ncr[i-1][j]+ncr[i-1][j-1])%mod;
		}
	}
}
ll solve(int x,int y)
{
	if(val[x][y] != -1)
		return val[x][y];
	if(x==0)
		return 0;
	if(y==1)
		return 1;
	ll res = 0;
	for(int j=1;j<x;j++)
	{
		res += (ncr[x][j]*solve(x-j,y-1))%mod;
	}
	return val[x][y] = res%mod;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	dp[0][0][0] = 1;
	int s = 0;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=s;j++)
		{
			for(int p=0;p<2;p++)
			{
				for(int q=0;q<2;q++)
				{
					tp[j+a[i]][p][q] += dp[j][p][q];
					tp[j][p][1] += dp[j][p][q];
					tp[j][1][q] += dp[j][p][q];
				}
			}
		}
		s += a[i];
		for(int j=0;j<=s;j++)
		{
			for(int p=0;p<2;p++)
			{
				for(int q=0;q<2;q++)
				{
					dp[j][p][q] = tp[j][p][q]%mod;
					tp[j][p][q] = 0;
				}
			}
		}
	}
	ll res = 0;
	for(int i=(s+1)/2;i<=s;i++)
	{
		res += dp[i][1][1];
		res %= mod;

	}
	memset(val,-1,sizeof(val));
	pre();
	res = (3*res)%mod;
	res = (solve(n,3)-res+mod)%mod;
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 9808
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
	int q,c,a,n,res;
	cin >> q;
	for(int i = 0;i < q;i++){
		int m;
		res = 0;
		cin >> c >> a >> n;
		m = min(c,min(a,n));
		res += m;
		c -= m;
		a -= m;
		n -= m;
		m = min(c / 2,a);
		res += m;
		c -= 2 * m;
		a -= m;
		res += c / 3;
		cout << res << endl;
	}
	return 0;
}

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

#define loop(x) for(int knzk=0;knzk<x;++knzk)
int in(){int x;scanf("%d",&x);return x;}

template<class T>
ostream& operator<<(ostream& os,set<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}


signed main(){

  int n,m;
  set<int> s;
  cin>>n;
  loop(n)s.insert(in());
  cin>>m;
  loop(m)s.erase(in());

  for(auto x:s)cout<<x<<endl;

}


Measured memory_bytes: 12520
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x[3],op,y;

    for(int i=0;i<3;i++)cin>>x[i];

    sort(x,x+3);

    op=x[2]-x[1];

    x[0]+=op;

    y=x[2]-x[0];
    op+=y/2;
    if(y%2) op+=2;


    /*cout<<"***"<<op<<endl;*/

    cout<<op<<endl;

    return 0;
}


Measured memory_bytes: 256
def recursion(s, mx, n):
    if len(s) == n:
        print(s)
        return
 
    c = 'a'
    while c <= mx:
        nmx = mx
        if c == mx:
            nmx = chr(ord(c) + 1)
        recursion(s + c, nmx, n)
        c = chr(ord(c) + 1)


n = int(input())
recursion("", 'a', n)

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll INF = 1LL << 60;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > 2*b){
        cout << a - 2*b << endl;
    }
    else cout << 0 << endl;
}

Measured memory_bytes: 3604
# cook your dish here
n,m = map(int,input().split())
a = []

for i in range(m):
    l = list(map(int,input().split()))
    if l[0] == 1:
        a.append(l[1])
    elif l[1] == n:
        a.append(l[0])

b = list(set(a))
if len(a)==len(b):
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

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

using pint=pair<int,int>;

int main()
{
   int N; cin>>N;
   vector<vector<pint>> a(N);
   for(int i=0;i<N;i++){
      int sz; cin>>sz;
      while(sz--){
         int x,y; cin>>x>>y;
         x--;
         a[i].push_back({x,y});
      }
   }

   int ans=0;
   for(int S=0;S<(1<<N);S++){
      bool ok=true;
      for(int i=0;i<N;i++) if(S>>i&1){
         for(auto p:a[i]){
            if(p.second!=(S>>p.first&1)) ok=false;
         }
      }
      if(ok) ans=max(ans,__builtin_popcount(S));
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#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: 4504
import math
# def resolve():
# 	n, k = map(int, input().split())
# 	a = list(map(int, input().split()))
# 	i = a.index(min(a)) + 1
# 	if k - 1 > i:
# 		v = max(0, math.ceil((n - k - 2) / (k - 1))) + 1
# 	else:
# 		v = math.ceil(i / (k - 1)) + math.ceil((n - i - 1) / (k - 1))
# 	print(v)

def resolve():
	n, k = map(int, input().split())
	a = list(map(int, input().split()))
	v = math.ceil((n - k) / (k-1) + 1)
	print(v)
resolve()

Measured memory_bytes: 52780
#include<iostream>

int dp[5005][5005];

int main(void){
    int n;
    std::string s;
    std::cin >> n >> s;
    for(int i = n-1; i >= 0; i--){
        for(int j = n-1; j >= 0; j--){
            if(s[i] != s[j]) continue;
            dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int cur = std::min(dp[i][j], j-i);
            ans = std::max(ans, cur);
        }
    }
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 101316
#include<bits/stdc++.h>
using namespace std;
map<string,int> mymap;
int ds[4]={1,-1,4,-4};
void bfs()
{
    mymap["01234567"]=0;
    queue<string> q;
    q.push("01234567");
    while(!q.empty())
    {
        int zero;
        string x=q.front();
        q.pop();
        for(int i=0;i<8;++i)
        {
            if(x[i]=='0')
                zero=i;
        }
        for(int i=0;i<4;++i)
        {
            int t=zero+ds[i];
            if(t>=0&&t<8&&!(zero==3&&i==0)&&!(zero==4&&i==1))
            {
                string now=x;
                swap(now[zero],now[t]);
                if(mymap.find(now)==mymap.end())
                {
                    mymap[now]+=mymap[x]+1;
                    q.push(now);
                }
            }
        }

    }
}
int main()
{
    bfs();
    string s;
    while(getline(cin,s))
    {
        s.erase(remove(s.begin(),s.end(),' '),s.end());
        cout<<mymap[s]<<endl;
    }
}



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


typedef tuple<int, int> mytuple;

// タプルの最初の要素から順番に比較　もしその要素が同じなら次の要素で比較
bool mycompare( const mytuple &lhs, const mytuple &rhs )
{
    if (get<0>(lhs) != get<0>(rhs)) return get<0>(lhs) < get<0>(rhs);
    return get<1>(lhs) > get<1>(rhs);
}

void print_vector( vector<mytuple>& vec )
{
    for( auto& element : vec ) {
        cout << std::get<0>(element) << ", " << std::get<1>(element) <<  std::endl;
    }
    cout << std::endl;
}


int main(){
	vector<tuple<int, int>> vc;

	int N;
	cin >> N;

	int tmpA, tmpB;
	for (int i = 0 ; i < N; i++){
		cin >> tmpA >> tmpB;
		vc.emplace_back(tmpB, tmpA);	 
	}

	sort(vc.begin(), vc.end(), mycompare);
	//print_vector(vc);
	int s = 0;
	for( auto x : vc )
	{
    	s += get<1> (x);
		if (get<0> (x) < s){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;


	return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	string S;
	cin>>S;
	bool FF=true;
	FOR(i,1,S.size()){
		if(S[i-1]!=S[i]){
			FF=false;
			break;
		}
	}
	if(FF){
		cout<<0<<endl;
		return 0;
	}
	string AL="abcdefghijklmnopqrstuvwxyz";
	int rd=INF;
	REP(i,26){	
		int c=0,d=0;
			FOR(j,0,S.size()){
				c++;
				if(S[j]==AL[i] || j==S.size()-1){
					c--;
					if(j==S.size()-1)c++;
					d=max(d,c);
					c=0;
				}
			}
		rd=min(rd,d);
	}
	cout<<rd<<endl;
	//REP(i,26)cout<<co[i];
	
	return 0;
}

Measured memory_bytes: 256
import java.io.*;
public class Main {
   public static void main(String[] args) throws IOException{
	   int[] prime = new int[1000005];
	   for(int i=2;i<=500000;i++){
		   for(int j=2;i*j<=1000000;j++){
			   prime[i*j] = 1;
		   }
	   }
	   BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	   String s;
	   int n;
	   int cnt;
	   while((s = buf.readLine()) != null){
		   cnt = 0;
		   n = Integer.parseInt(s);
		   for(int i=2;i<=n;i++){
			   if(prime[i] == 0) cnt++;
		   }
		   System.out.println(cnt);
	   }
   }
}

Measured memory_bytes: 23400
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x = I()
print('Yes' if x >= 30 else 'No')


Measured memory_bytes: 10412
/* ＵＴＦ－８ */
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int N;
	std::vector<int> A;
	std::cin >> N;
	A.resize(N);
	for (auto& a : A) {
		std::cin >> a;
	}
	
	if (std::find(A.begin(), A.end(), 1) == A.end()) {
		std::cout << "-1\n";
		return 0;
	}
	
	int k = 1;
	auto it = A.begin();
	while (true) {
		auto jt = std::find(it, A.end(), k);
		if (jt == A.end())
			break;
		it = jt;
		++k;
	}

	std::cout << (N - k + 1) << "\n";
}


Measured memory_bytes: 1024
class Team
  attr_accessor :name, :w, :l, :i
  def initialize(name, w, l, i)
    @name = name; @w = w; @l = l; @i =i;
  end
  def <=>(other)
    return other.w <=> @w if @w != other.w
    return @l <=> other.l if @l != other.l
    return @i <=> other.i if @i != other.i
  end
end

while n = gets.chomp.to_i and n != 0
  teams = []

  n.times do |i|
    inputs = gets.split
    name = inputs[0]
    w = inputs[1..n].count('0')
    l = inputs[1..n].count('1')

    teams << Team.new(name, w, l, i)
  end

  teams.sort.each{ |team| puts team.name }
end

  
    

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

using namespace std;

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

int main(){
    int n;cin>>n;
    vector<int> p(n),q(n);
    int i;
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];

    bool change=false;
    rep(i,n){
        if(p[i]==q[i]) continue;
        else if(p[i]<q[i]) change=true;
        else break;
    }

    if(change){
        rep(i,n) swap(p[i],q[i]);
    }

    int count=0;
    do{ 
        bool same=true;
        rep(i,n)if(p[i]>q[i]){
            count++;
            same=false;
            break;
        }

        if(same) break;
    }while(next_permutation(q.begin(),q.end()));

    cout<<count<<endl;
}

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

#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, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
// constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int H, W, N;
  cin >> H >> W >> N;
  int sr, sc;
  cin >> sr >> sc;
  string S, T;
  cin >> S >> T;
  int l = 1, r = W, u = 1, d = H;
  bool ans = true;
  REPR(i, N-1){
    switch(T[i]){
      case 'L': r = min(W, r+1); break;
      case 'R': l = max(1, l-1); break;
      case 'U': d = min(H, d+1); break;
      case 'D': u = max(1, u-1); break;
    }
    switch(S[i]){
      case 'L': l+=1; break;
      case 'R': r-=1; break;
      case 'U': u+=1; break;
      case 'D': d-=1; break;
    }
    if(l > r || u > d) ans = false;
  }
  if(!(u <= sr && sr <= d && l <= sc && sc <= r)){
    ans = false;
  }
  if(ans){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 776
S = input()
s_1 = S[:2]
s_2 = S[2:]

def mm_checker(s):
  if int(s) <= 12 and int(s) > 0:
    return True
  return False

if mm_checker(s_1) and mm_checker(s_2):
  print('AMBIGUOUS')

elif mm_checker(s_1) and not mm_checker(s_2):
  print('MMYY')
elif not mm_checker(s_1) and mm_checker(s_2):
  print('YYMM')
else:
  print('NA')
  

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int a,b,c,i = 0;
  scanf("%d\n %d\n %d\n",&a,&b,&c);
  if(1 <= a&&c <= 10000&&a <= b){
    for(int k = a;k <= b;k++){
      if(c % k == 0){
        i++;
      }
    } 
  }
  printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 1820
from collections import Counter
N, *A = map(int, open(0).read().split())
A.sort(reverse=True)
C = Counter(A)
ans = 0
for a in A:
    if C[a] == 0:
        continue
    C[a] -= 1
    partner = (2 ** (a.bit_length())) - a
    if C[partner] > 0:
        ans += 1
        C[partner] -= 1
print(ans)

Measured memory_bytes: 33888
#include <stdio.h>
    
int main(){
    int i,n,tmp;
    long min,max,sum;
    
    min=1000000000;
    max=-1000000000;
    sum=0;
    
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d",&tmp);
        if(tmp<min){
            min=tmp;
        }
        if(tmp>max){
            max=tmp;
        }
        sum+=tmp;
    }
    
    printf("%ld %ld %ld\n",min,max,sum);
    
    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  
  vll a(n), b(n);
  
  rep(i,n){
    ll x, y; cin>>x>>y;
    a[i]=x+y;
    b[i]=x-y;
  }
  
  vsort(a); vsort(b);
  
  ll ans=a[n-1]-a[0];
  chmax(ans,b[n-1]-b[0]);
  cout<<ans<<endl;
}

Measured memory_bytes: 6336
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        mut n: usize,
        k: usize
    }
    let mut d = 0;
    while n > 0 {
        d += 1;
        n /= k;
    }
    println!("{}", d);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


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

    if ( x == 3 | x == 5 | x == 7 ) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

from collections import Counter
c = Counter(a)
if n % 2 == 1:
    ans = 1
    for i in range(n // 2 + 1):
        ii = 2 * i
        if i == 0 and c[ii] == 1:
            ans *= 1
        elif i != 0 and c[ii] == 2:
            ans *= 2
        else:
            ans *= 0
        ans %= (10 ** 9 + 7)
else:
    ans = 1
    for i in range(n // 2):
        ii = 2 * i + 1
        if c[ii] == 2:
            ans *= 2
        else:
            ans *= 0
        ans %= (10 ** 9 + 7)
print(ans)


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

int main() {
	int N, K;
	scanf("%d%d", &N, &K);
	long long ans = 0;
	for(int i=K+1; i<=N; ++i)
	{
		int div = N/i;
		int rem = N%i;
		ans += 1LL*div*(i-K) + max(rem-K+1, 0);
	}
	if(K==0) ans = 1LL*N*N;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include<iostream>
#define MAX 100000

int n;

struct q{
	char c;
	int s;
};
struct q A[MAX], B[MAX], tmp;
/*
int partition(int p, int r){
	int x = A[r - 1].s, j = 0;
	for (int i = 0; i < n; i++){
		if (A[i].s <= x) {
			tmp = A[j];
			A[j++] = A[i];
			A[i] = tmp;
		}
	}
	return j - 1;
}
*/
int partition(int p, int r){
	int x = A[r].s, j = p-1;
	for (int i = p; i < r; i++){
		if (A[i].s <= x) {
			j++;
			tmp = A[j];
			A[j] = A[i];
			A[i] = tmp;
		}
	}
	std::swap(A[j+1], A[r]);
	return j+1;
}

int quicksort(int p, int r){
	if (p < r){
		int qq = partition(p, r);
		quicksort(p, qq-1);
		quicksort(qq+1, r);
	}

	return 0;
}

int merge(int left, int mid, int right){
	struct q L[MAX / 2 + 1], R[MAX / 2 + 1];
	int n1 = mid - left, n2 = right - mid;
	int l = 0, r = 0;
	for (int i = 0; i < n1; ++i)L[i] = B[left + i];
	for (int i = 0; i < n2; ++i)R[i] = B[mid + i];
	L[n1].s = R[n2].s = 2000000000;
	for (int i = left; i < right; i++){
		if (L[l].s <= R[r].s){
			B[i] = L[l++];
		}
		else {
			B[i] = R[r++];
		}
	}
	return 0;
}

int mergesort(int left, int right){
	if (left + 1 < right){
		int mid = (right + left) / 2;
		mergesort(left, mid);
		mergesort(mid, right);
		merge(left, mid, right);
	}
	return 0;
}

int main(){
	scanf("%d", &n);
	char cc[2]; int ss;
	for (int i = 0; i < n; i++){
		scanf("%s %d", cc, &ss);
		B[i].c = A[i].c = cc[0];
		B[i].s = A[i].s = ss;
	}
	
	quicksort(0, n-1);
	mergesort(0, n);
	int dif = 1;
	for(int i = 0;i < n;i++)if(A[i].c != B[i].c)dif = 0;
	if(dif == 1) printf("Stable\n");
	if(dif == 0)printf("Not stable\n");
	for(int i = 0;i < n;i++){
		printf("%c %d\n", A[i].c, A[i].s);
	}
	//printf("%c %d\n", A[n - 1].c, A[n - 1].s);
	return 0;
}

/*
6
D 3
H 2
D 1
S 3
D 2
C 1
*/

/*
5
H 1
D 1
S 1
C 1
H 2
*/

Measured memory_bytes: 5540
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x,i,m,n,t=0;
  string s;
  cin>>x>>s;
  if(x%2!=0) cout<<"No"<<endl;
  else
  {
    m=(x/2)-1;
    n=x/2;
    for(i=0;i<=m;i++)
    {
      if(s[i]!=s[n]) t++;
      n++;
    }
  if(t==true) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  }

}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>

using namespace std;

typedef pair<string, int> P;

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

	set<string> s;
	vector<string> ans;
	for (int i = 0; i < n; i++) {
		string s1, s2;
		cin >> s1 >> s2;
		if (s1 == "insert") {
			s.insert(s2);
		}
		else if (s1 == "find") {
			auto itr=s.find(s2);
			if (itr != s.end()) {
				ans.push_back("yes");
			}
			else ans.push_back("no");
		}
	}
	
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 55380
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG



int main() {
  char S;
  cin >> S;
  if ((int)S <=90)cout << "A" << endl;
  else cout << "a" << endl;

  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
const int inf = INT_MAX;
const ll INF = 1LL >> 60;
const ll mod = 1e9+7;

int main() {
    int x;
    cin >> x;
    if(x==3 or x==5 or x==7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input().rstrip())
red = []
for i in range(N):
    a, b = input().rstrip().split()
    red.append((int(a), int(b)))
red.sort(key=lambda y: y[1], reverse=True)
blue = []
for i in range(N):
    a, b = input().rstrip().split()
    blue.append((int(a), int(b)))
blue.sort(key=lambda x: x[0])

# print(red, blue)

i = 0
while len(blue) > i:
    for j in red:
        if j[0] < blue[i][0] and j[1] < blue[i][1]:
            del blue[i]
            red.remove(j)
            break
    else:
        i += 1
    # print(red, blue)

print(N - len(red))

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

int main(){
        stack<int> S;
        string str;
        while(cin >> str){
                if(str == "+"){
                        int b = S.top();
                        S.pop();
                        int a = S.top();
                        S.pop();
                        S.push(a + b);
                }
                else if(str == "-"){
                        int b = S.top();
                        S.pop();
                        int a = S.top();
                        S.pop();
                        S.push(a - b);
                }else if(str == "*"){
                        int b = S.top();
                        S.pop();
                        int a = S.top();
                        S.pop();
                        S.push(a * b);
                }
                else{
                        S.push(stoi(str));
                }
        }
        cout << S.top() << endl;
}

Measured memory_bytes: 3164
function Main(input) {
	var day = parseInt(input, 10);
    if (day === 22) {
      console.log('Christmas Eve Eve Eve');
    } else if (day === 23) {
      console.log('Christmas Eve Eve');
    } else if (day === 24) {
      console.log('Christmas Eve');
    } else if (day === 25) {
      console.log('Christmas');
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
#include<string>
#include<cmath>
#include<stack>
#include <vector>
#include<queue>
#include <random>
using namespace std;



int main() {

	int n, m, ans = 0;
	string s[100], t[100];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}

	for (int i = 0; i < n; i++) {
		int yen = 0;
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j]) {
				yen++;
			}
		}
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) {
				yen--;
			}


		}

		ans = max(ans, yen);

	}
	cout << max(ans, 0);


	return 0;
}

Measured memory_bytes: 256
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

b_time = Array.new

b.each.with_index do |x, i|
    b_time.push(b_time[i-1].to_i + x)
end

j = m
t = b_time[-1]
ans = 0

(n+1).times do |x|
    while j > 0 && t > k do
        j -= 1
        t -= b[j]
    end
    break if t > k
    ans = [ans, x+j].max
    break if x == n
    t += a[x]
end

puts ans


Measured memory_bytes: 43544
#include <bits/stdc++.h>
using namespace std;
int main() {
  char A;
  cin >> A;
  int c = 0;
  string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(int i = 0; i < 26; i++) {
    if(A == ALP.at(i)) {
      cout << "A" << endl;
      c++;
    }
  }
  if(c == 0) {
    cout << "a" << endl;
  }
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    string s; int k;
    cin>>s>>k;
    int n=s.size();
    ll ans=0,cnt=1;
    set<char>se;
    rep(i,n)se.insert(s[i]);
    if(se.size()==1){cout<<(ll)n*k/2<<endl; return 0;}
    rep(i,n-1){
        if(s[i]==s[i+1])cnt++;
        else{ans+=cnt/2; cnt=1;}
    }
    ans+=cnt/2;
    ll cnt2=1,ans2=0;
    s+=s;
    n=s.size();
    rep(i,n-1){
        if(s[i]==s[i+1])cnt2++;
        else{ans2+=cnt2/2; cnt2=1;}
    }
    ans2+=cnt2/2;
    ll x=ans2-ans;
    cout<<ans+x*(k-1)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
  map<string, int> mp;

  int n;
  cin >> n;

  int mx = 0;
  for (int i = 0; i < n; ++i) {
    string k;
    cin >> k;
    mp[k]++;

    mx = max(mx, mp[k]);
  }

  for (auto &p : mp) {
    if (p.second == mx) {
      cout << p.first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25216
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int weeks;
    scanf("%d", &weeks);

    int debt = 100000;
    for (int i = 0; i < weeks; i++) {
        debt = debt * 1.05;
        int p = debt / 1000;
        int q = debt % 1000;
        if (q > 0) {
            p += 1;
        }
        debt = p * 1000;
    }
    printf("%d\n", debt);
}

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

#define BUF_SIZE 100002
int main(void) {
  FILE *fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  char *tmp;
  int hist[26] = {0};
  for(tmp = line; *tmp != '\n'; tmp++) {
    hist[*tmp - 'a']++;
  }

  char res = 0; int i;
  for(i = 0; i < 26; i++) {
    if(hist[i] == 0) {
      res = i+'a'; break;
    }
  }
  if(res == 0) {
    printf("None\n");
  } else {
    printf("%c\n", res);
  }
  return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,m = LI()
    a = LI()
    r = 0
    d = collections.defaultdict(int)
    d[0] = 1
    t = 0
    for c in a:
        t = (t+c) % m
        r += d[t]
        d[t] += 1
    return r




print(main())


Measured memory_bytes: 16784
#!/usr/bin/env python
import collections


n = int(input())
v = list(map(int, input().split()))
odd = v[0::2]
even = v[1::2]

odd_c = collections.Counter(odd).most_common()
even_c = collections.Counter(even).most_common()

if odd_c[0][0] != even_c[0][0]:
    ans = len(v) - odd_c[0][1] - even_c[0][1]
elif len(odd_c) == 1 and len(even_c) == 1:
    ans = odd_c[0][1]
elif len(odd_c) == 1:
    ans = len(v)//2 - even_c[1][1]
elif len(even_c) == 1:
    ans = len(v)//2 - odd_c[1][1]
else:
    e = len(v) - odd_c[0][1] - even_c[1][1]
    o = len(v) - even_c[0][1] - odd_c[1][1]
    ans = e if e < o else o
print(ans)


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    int N, K;
    cin >> N >> K;
    int R, S, P;
    cin >> R >> S >> P;
    string T;
    cin >> T;
    vector<char> rsp;
    for(int i = 0;i < T.length();i++){
        if(i >= K)if(T[i] == T[i-K] && rsp[i-K] != 'v'){rsp.push_back('v');continue;}
        if(T[i] == 'r')rsp.push_back('p');
        else if(T[i] == 's')rsp.push_back('r');
        if(T[i] == 'p')rsp.push_back('s');
    }
    int ans = 0;
    for(int i = 0;i < rsp.size();i++){
        if(rsp[i] == 'r')ans+=R;
        if(rsp[i] == 's')ans+=S;
        if(rsp[i] == 'p')ans+=P;
    }
    cout << ans;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    if(x == 1 || x == 2*n-1)
    {
        cout << "No" << endl;
        return 0;
    }
    if(n == 2)
    {
        cout << "Yes" << endl;
        cout << 1 << endl << 2 << endl << 3 << endl;
        return 0;
    }
    set<int> s;
    for(int i = 1; i <= 2*n-1; i++)
    {
        s.insert(i);
    }
    s.erase(x);
    s.erase(x-1);
    s.erase(x+1);
    if(x != 2*n-2)
    {
        s.erase(x+2);
    }
    else
    {
        s.erase(x-2);
    }
    cout << "Yes" << endl;
    auto itr = s.begin();
    for(int i = 1; i <= n-2; i++)
    {
        cout << *itr << endl;
        itr++;
    }
    if(x != 2*n-2)
    {
        cout << x+2 << endl;
        cout << x << endl;
        cout << x-1 << endl;
        cout << x+1 << endl;
    }
    else
    {
        cout << x-1 << endl;
        cout << x << endl;
        cout << x+1 << endl;
        cout << x-2 << endl;
    }
    while(itr != s.end())
    {
        cout << *itr << endl;
        itr++;
    }
}


Measured memory_bytes: 10880
n = gets.to_i

c = [0]
s = [0]
f = [0]
(n-1).times do 
    x,y,z = gets.split.map(&:to_i)
    c << x
    s << y
    f << z
end

ans = []
n.downto(1) do |i|
    now = i
    t = 0

    while now < n
        if t < s[now]
            t = s[now]
        else
            t = (t.to_f / f[now]).ceil * f[now]
        end
        t += c[now]
        now += 1
    end

    ans << t
end

puts ans.reverse

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

int main(){
    vector<int> a(9);
    vector<int> flg(9, 0);

    rep(i, 9) cin >> a.at(i);

    int n, b;
    cin >> n;
    rep(i, n){
        cin >> b;
        rep(j, 9){
            if(a.at(j)==b) flg.at(j)=1;
        }
    }

    rep(i, 3){
        if(flg.at(i)==1 and flg.at(i+3)==1 and flg.at(i+6)==1){
            // height
            cout << "Yes" << endl;
            return 0;
        }
        if(flg.at(3*i)==1 and flg.at(3*i+1)==1 and flg.at(3*i+2)==1){
            // weight
            cout << "Yes" << endl;
            return 0;
        }
    }
    // diagonal
    if(flg.at(0)==1 and flg.at(4)==1 and flg.at(8)==1){
        cout << "Yes" << endl;
        return 0;
    }
    if(flg.at(2)==1 and flg.at(4)==1 and flg.at(6)==1){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    if(S == "ABC")
        cout << "ARC";
    else
        cout << "ABC";
    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

using namespace std;

void dfs(int n, map<pair<int, int>, int>& id, vector<vector<int>>& graph, vector<int>& result, int prev, int cur) {
    for (int i = 0, j = 1; i < static_cast<int>(graph[cur].size()); i++) {
        if (graph[cur][i] != prev) {
            if (j == result[id[make_pair(prev, cur)]]) {
                j++;
            }

            result[id[make_pair(cur, graph[cur][i])]] = j;
            result[id[make_pair(graph[cur][i], cur)]] = j;
            j++;

            dfs(n, id, graph, result, cur, graph[cur][i]);
        }
    }
}

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

    map<pair<int, int>, int> id;
    vector<vector<int>> graph(n, vector<int>(0));
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;

        id[make_pair(a - 1, b - 1)] = i;
        id[make_pair(b - 1, a - 1)] = i;

        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    vector<int> result(n - 1, 0);
    for (int i = 0, j = 1; i < static_cast<int>(graph[0].size()); i++) {
        result[id[make_pair(0, graph[0][i])]] = j;
        result[id[make_pair(graph[0][i], 0)]] = j;
        j++;

        dfs(n, id, graph, result, 0, graph[0][i]);
    }

    int k = 0;
    for (int i = 0; i < n - 1; i++) {
        k = max(k, result[i]);
    }

    cout << k << endl;
    for (int i = 0; i < n - 1; i++) {
        cout << result[i] << endl;
    }
}


Measured memory_bytes: 21120
#include <stdio.h>
#include <stdlib.h>
int main()
{
    long long int a, b, k;
    scanf("%lld %lld %lld", &a, &b, &k);
    printf("%lld %lld", (a > k) ? a - k : 0, (a > k) ? b : ((a + b > k) ? a + b - k : 0));
    return 0;
}

Measured memory_bytes: 128
import sys
from bisect import bisect_left as bi_l

n, *a = map(int, sys.stdin.read().split())

def main():
    a.sort()
    b = a[-1]
    c = (b + 1) // 2

    i = bi_l(a, c)
    if i == 0:
        return b, a[0]
    elif i == n - 1:
        return b, a[-2]
    else:
        res = a[i] if a[i] - c <= c - a[i-1] else a[i-1]
        return b, res

if __name__ == '__main__':
    ans = main()
    print(*ans, sep=' ')

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int main2() {
  string s; cin >> s;
  int N = (int)s.size();
  int ans = N;
  for (int i = 0; i + 1 < N; i++) {
    if (s[i] != s[i+1]) {
      chmin(ans, max(i+1, N-i-1));
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define int llint
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N, M;
int fact[100010];


void makeFact(){
	int n = max(N, M);
	fact[0] = 1;
	repe(i, 1, n) fact[i] = MUL(i, fact[i-1]);
}


int solve(){
	if(abs(N-M) >= 2) return 0;
	if(abs(N-M) == 1) return MUL(fact[N], fact[M]);
	if(abs(N-M) == 0) return MUL(2, MUL(fact[N], fact[M]));
	return -1;
}


signed main(){
	cin >> N >> M;

	makeFact();

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std;
int D,N;
int main(){
    cin>>D>>N;
    if (N<100){
        cout<<N;
        for (int i=0;i<D;i++) cout<<"00";
        cout<<endl;
    }else{
        cout<<"101";
        for (int i=0;i<D;i++) cout<<"00";
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int a[101010];
int main()
{
	int n,k,ans=1010101010;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=k;i<=n;i++)
	{
		if(a[i-k+1]<0&&a[i]>0)
			ans=min(ans,min(a[i],-a[i-k+1])+a[i]-a[i-k+1]);
		else
			ans=min(ans,max(a[i],-a[i-k+1]));
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 640