akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import math

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))

    A = set()
    over = 0
    for b in a:
        val = b // 400
        if val >= 8:
            over += 1
        else:
            A.add(val)

    num = len(A)
    min = num
    if min == 0 and over >= 1:
        min = 1

    if over >= 1:
        num += over
        #if num >= 8:
            #num = 8

    print(min, num)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(void){
    string S;
    cin >> S;
    string day[8];
    day[7]="SUN";
    day[6]="MON";
    day[5]="TUE";
    day[4]="WED";
    day[3]="THU";
    day[2]="FRI";
    day[1]="SAT";
    for(int i=1;i<8;i++){
        if(S==day[i]){
            cout<<i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

typedef vector<char> vc;
typedef vector<vc> vvc;

int main()
{
	for(int w,h;cin>>w>>h,w|h;){
		vvc grid(h,vc(w));
		rep(i,h) rep(j,w)
			cin>>grid[i][j];
		int n; cin>>n;
		vi gs(n),ds(n),ss(n),es(n);
		rep(i,n)
			cin>>gs[i]>>ds[i]>>ss[i]>>es[i];
		
		rep(i,h) rep(j,w){
			if(!isdigit(grid[i][j]))
				continue;
			grid[i][j]=find(all(gs),grid[i][j]-'0')-gs.begin()+'0';
		}
		
		static bool dp[101][20][20][1<<10]; // [t][i][j][bit]
		memset(dp,0,sizeof dp);
		
		rep(i,h) rep(j,w)
			if(grid[i][j]=='P'){
				dp[0][i][j][0]=1;
				grid[i][j]='.';
			}
		
		rep(t,100) rep(i,h) rep(j,w) rep(k,1<<n){
			if(dp[t][i][j][k]==0)
				continue;
			rep(_,4){
				int ni=i+"\xff\x1\0\0"[_],nj=j+"\0\0\xff\x1"[_];
				if(ni<0 || h<=ni || nj<0 || w<=nj)
					continue;
				if(isdigit(grid[ni][nj])){
					int item=grid[ni][nj]-'0';
					if(ss[item]<=t && t<es[item])
						dp[t][i][j][k|1<<grid[ni][nj]-'0']=1;
				}
				if(grid[ni][nj]=='.')
					dp[t+1][ni][nj][k]=1;
			}
		}
		
		vi ps(1<<n);
		rep(i,1<<n) rep(j,n)
			if(i&1<<j)
				ps[i]+=ds[j];
		
		int res=0;
		rep(i,h) rep(j,w) rep(k,1<<n){
			if(dp[100][i][j][k])
				res=max(res,ps[k]);
		}
		cout<<res<<endl;
	}	
	
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int s=S.size();
    ll ans=0;
    int cnt=0;
    rep (i,s){
        if (S[i]=='W'){
            ans+=i-cnt;
            cnt++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n, m;
    string s[109], t[109];
    int a[109]={};
    int ans=0;
    
    cin >> n;
    
    for(int i=1; i<=n; i++){
        
        cin >> s[i];
        
    }
    
    cin >> m;
    
    for(int i=1; i<=m; i++){
        
        cin >> t[i];
        
    }
    
    for(int i=1; i<=n; i++){
        
        a[i] = 1;
        
    }
    
    for(int i=1; i<=n; i++){
        
        if(i<=n-1){
        
        for(int j=i+1; j<=n; j++){
            
            if(a[j]<=0){
                
                continue;
                
            }
            
            if(s[i]==s[j]){
                
                a[i] += 1;
                a[j] -= 1;
                
            }
            
        }
        
        }
        
        for(int k=1; k<=m; k++){
            
            if(s[i]==t[k]){
                
                a[i] -= 1;
                
            }
            
        }
        
        ans = max(ans, a[i]);
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  cin >> N;
  int A[N];
  int P[N],rank=1;
  string S[N];
  
  for(int i=0; i<N; i++){
    cin >> S[i] >> P[i];
  }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
  			if(S[i] > S[j])
              rank++;
          	else if (S[i] == S[j]){
              if(P[i] < P[j])
                rank++;
            }
        }
      A[rank]=i+1;
      rank=1;
    }
  for(int i=1; i<=N; i++){
    cout << A[i] <<endl;
  }
}


Measured memory_bytes: 384
while True:
    a, b = map(int, input().split())
    if a == b and a == 0:
        break
 
    for i in range(a):
        for j in range(b):
            if i == 0 or i == a - 1 or j == 0 or j == b - 1:
                print("#", end = "")
            else:
                print(".", end = "")
        print()
    print()


Measured memory_bytes: 7000
#include <iostream>


using namespace std;
 string ss, st;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> ss >> st;
  for (int k = 0; k < ss.size(); ++k) 
  {
            if (ss[k] != st[k]) {
     cout << "No" << "\n";
    return 0;
    
    
    } }
 
 
  cout << "Yes" << "\n";
    
  return 0;
}

Measured memory_bytes: 3640
fun main(arr:Array<String>) {
    val posList = readLine()!!.toInt()
    val totalList = Proc((1..posList).map { readLine()!!.split(" ").map { it.toInt() }.let { Pos(it[0], it[1]) } } ).getAns(null, 0, 0.toDouble())
    val ans = totalList.sum() / totalList.size
    println(ans)
}

class Pos(val x:Int, val y:Int)
class Proc(val pointList:List<Pos>) {
    fun getAns(prev:Pos?, flag:Int, subTotal:Double):List<Double> {
        if(flag == (1 shl pointList.size) - 1) {
            return listOf(subTotal)
        }
        val ret = mutableListOf<Double>()
        if(prev == null) {
            for(i in pointList.indices) {
                ret.addAll(getAns(pointList[i], 1 shl i, 0.toDouble()))
            }
        } else {
            for(i in pointList.indices) {
                val key = 1 shl i
                if((flag and key) != 0) {
                    continue
                }
                val dist = Math.sqrt(Math.pow((prev.x - pointList[i].x).toDouble(), 2.toDouble()) + Math.pow((prev.y - pointList[i].y).toDouble(), 2.toDouble()))
                ret.addAll(getAns(pointList[i], flag + key, subTotal + dist))
            }
        }
        return ret
    }
}

Measured memory_bytes: 41680
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if(a>=13) {
			System.out.println(b);
		}
		else if(a<13&&a>=6) {
			System.out.println(b/2);
		}
		else if(a<6) {
			System.out.println(0);
		}
	}
}


Measured memory_bytes: 20820
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

int n,m,k,s;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    s=0;
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
        {
            if((n*j+m*i-2*i*j) == k)
            {
                s=1;
            }
        }
    if(s == 0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}


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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	long long x , y ;
	cin>>x>>y ;
	long long now = x ;
	for(long long i = 1 ; ; ++i)
	{
		now *= 2ll ;
		if(now > y)
			return cout<<i<<"\n" , 0 ;
	}
}

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

using namespace std;

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

int judge(int a){
  int answer=0;
  int count=0;
  for(int i=1; i<=100; i++){
    answer+=i;
    if(a<answer){
      count=i-1;
      break;
    }
  }
  return count;
}

int main() {
    long long N;
    cin >> N;
    const auto &res = prime_factorize(N);
    vector<int> a;
    for (auto p : res) {
        for (int i = 0; i < p.second; ++i){
          a.push_back(p.first);
        }
    }
    int answer= 0;
    for(int i=0; i<50; i++) {
      if(!a.empty()){
        size_t count_up = count(a.begin(), a.end(), a[0]);
        int count_int=(int)count_up;
        answer=answer+judge(count_int); 
        a.erase(a.begin(),a.begin()+count_int);
      } else {
        break;
      }
    }
    cout<<answer<<endl;
}


Measured memory_bytes: 3632
def main():
    n, x = [int(s) for s in input().split()]
    a = [int(s) for s in input().split()]
    a.sort()

    cnt = 0
    for i, y in enumerate(a):
        if x < y:
            break
        x -= y
        cnt += 1
    else:
        # distribute to all child
        if x != 0:
            cnt -= 1
    print(cnt)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
   map<string,int>m;
   m["SUN"]=1;
   m["MON"] =2;
   m["TUE"]=3;
   m["WED"]=4;
   m["THU"]=5;
   m["FRI"]=6;
   m["SAT"]=7;
   string s;
   cin>>s;
   cout<<7-m[s]+1<<endl;


}
return 0;
}

Measured memory_bytes: 256
s=input()
while 'eraser' in s :
        s = s.replace('eraser', '')
while 'erase' in s :
        s = s.replace('erase', '')
while 'dreamer' in s :
        s = s.replace('dreamer', '')
while 'dream' in s :
        s = s.replace('dream', '')
if len(s) == 0:
        print('YES')
else:
        print('NO')

Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll i;
    vector<ll> v;
    vector<ll> ans;
    ll e;
    for(i=0;i<N;i++){
      cin >> e;
      v.push_back(e);
    }
    while(!v.empty()){
      i=v.size()-1;
      while(true){
          if(v[i]>i+1){
              cout << -1 <<endl;
              return 0;
          }
          if(v[i]==i+1){
            ans.push_back(i+1);
            v.erase(v.begin()+i);
            i=v.size()-1;
            break;
          }
          i--;
        }
      }
    for(auto it=ans.rbegin();it!=ans.rend();++it){
      cout << *it <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#43 ABC134D
n=int(input())
a=list(map(int,input().split()))
x=[0 for _ in range(n)]
for i in range(n,0,-1):
	x[i-1]=1 if a[i-1]!=sum([x[j] for j in range(i-1,n,i)])%2 else 0
#print(x)
j=True
for i in range(n):
	if a[i]!=sum([x[j] for j in range(i,n,i+1)])%2:
		j=False
if j:
	print(sum(x))
	if sum(x)!=0:
		res=[]
		for i,t in enumerate(x):
			if t==1:
				res.append(str(i+1))
		print(" ".join(res))
else:
	print(-1)

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

using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, n) for (int i = 1; i < (int)(n+1); i++)
#define rep4(i, s, n) for (int i = (s); i < (int)(n+1); i++)
#define repr(i,n) for (int i = (n-1); i>=0;i--)
#define repr2(i,s,n) for (int i = (n-1); i>=(int)(s);i--)
#define repr3(i,n) for(int i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
const ll INF = 1001001000100010;
const ld PI = 3.14159265358979323846;



int main() {
int N;
cin>>N;
vector<ll> A(N),B(N),C(N),BtoC(N),Bsum(N);
rep(i,N){
    cin>>A[i];
}
rep(i,N){
    cin>>B[i];
}
rep(i,N){
    cin>>C[i];
}
sort(all(B));
sort(all(C));
ll key,left,right,mid,countnum=0,left2,right2,mid2;
rep(i,N){
    key=B[i];
    left=-1;right=N;
    while(true){
        mid=(left+right)/2;
        if(C[mid]==key){
            left2=mid;right2=N;
            while(true){
                mid2=(left2+right2)/2;
                if(C[mid2]==key){
                    left2=mid2;
                }
                else{
                    right2=mid2;
                }
                if(right2-left2==1){
                    BtoC[i]=N-right2;
                    break;
                    
                }


            }
            
            break;
        }
        else if(C[mid]<key){
            left=mid;
        }
        else{
            right=mid;
        }
        if(right-left==1){
            BtoC[i]=N-right;
            break;

        }
    }
}
Bsum[N-1]=BtoC[N-1];
repr(i,N-1){
    Bsum[i]=Bsum[i+1]+BtoC[i];
}
rep(i,N){
    key=A[i];
    left=-1;right=N;
    while(true){
        mid=(left+right)/2;
        if(B[mid]==key){
            left2=mid;right2=N;
            while(true){
                mid2=(left2+right2)/2;
                if(B[mid2]==key){
                    left2=mid2;
                }
                else{
                    right2=mid2;
                }
                if(right2-left2==1){
                    if(right2!=N){
                    countnum+=Bsum[right2];
                    }
            break;
                }
            }
            break;
        }
        else if(B[mid]<key){
            left=mid;
        }
        else{
            right=mid;
        }
        if(right-left==1){
            countnum+=Bsum[right];
            break;
        }
    }
}
cout<<countnum<<endl;

return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int a[130];
    memset(a,0,sizeof(a));
    for(int i=0;i<s.length();i++)
    {
        a[s[i]]++;
        if(a[s[i]]>1)
        {
            cout<<"no"<<endl;
            return 0;
        }
    }
    cout<<"yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;

int main()
{
	int n, a, b;
	ll x[100000], y[100000];
	scanf("%d %d %d", &n, &a, &b);
	a--; b--;
	map<P, int> mp1, mp2;
	vector<P> v1, v2;
	for(int i=0; i<n; i++){
		scanf("%lld %lld", &x[i], &y[i]);
		mp1[P(x[i]+y[i], x[i]-y[i])]=i;
		mp2[P(x[i]-y[i], x[i]+y[i])]=i;
		v1.push_back(P(x[i]+y[i], x[i]-y[i]));
		v2.push_back(P(x[i]-y[i], x[i]+y[i]));
	}
	ll d=abs(x[a]-x[b])+abs(y[a]-y[b]);
	ll count=0;
	vector<int> v;
	vector<int> comp;
	v.push_back(a);
	mp1.erase(P(x[a]+y[a], x[a]-y[a]));
	mp2.erase(P(x[a]-y[a], x[a]+y[a]));
	while(!v.empty()){
		int p=v.back();
		v.pop_back();
		comp.push_back(p);
      vector<int> er;
		for(auto itr=mp1.lower_bound(P(x[p]+y[p]+d, x[p]-y[p]-d)); itr!=mp1.lower_bound(P(x[p]+y[p]+d, x[p]-y[p]+d)); itr++){
			int q=itr->second;
			v.push_back(q);
          er.push_back(q);
		}
		for(auto itr=mp2.lower_bound(P(x[p]-y[p]-d, x[p]+y[p]-d)); itr!=mp2.lower_bound(P(x[p]-y[p]-d, x[p]+y[p]+d)); itr++){
			int q=itr->second;
			v.push_back(q);
          er.push_back(q);
		}
		for(auto itr=mp1.upper_bound(P(x[p]+y[p]-d, x[p]-y[p]-d)); itr!=mp1.upper_bound(P(x[p]+y[p]-d, x[p]-y[p]+d)); itr++){
			int q=itr->second;
			v.push_back(q);
          er.push_back(q);
		}
		for(auto itr=mp2.upper_bound(P(x[p]-y[p]+d, x[p]+y[p]-d)); itr!=mp2.upper_bound(P(x[p]-y[p]+d, x[p]+y[p]+d)); itr++){
			int q=itr->second;
			v.push_back(q);
          er.push_back(q);
		}
      for(int j=0; j<er.size(); j++){
        int q=er[j];
        mp1.erase(P(x[q]+y[q], x[q]-y[q]));
		mp2.erase(P(x[q]-y[q], x[q]+y[q]));
      }
	}
	sort(v1.begin(), v1.end());
	sort(v2.begin(), v2.end());
	ll ans=0;
	for(int i=0; i<comp.size(); i++){
		int p=comp[i];
     
		ans=ans+(ll)(lower_bound(v1.begin(), v1.end(), P(x[p]+y[p]+d, x[p]-y[p]+d))-lower_bound(v1.begin(), v1.end(), P(x[p]+y[p]+d, x[p]-y[p]-d)));
		ans=ans+(ll)(lower_bound(v2.begin(), v2.end(), P(x[p]-y[p]-d, x[p]+y[p]+d))-lower_bound(v2.begin(), v2.end(), P(x[p]-y[p]-d, x[p]+y[p]-d)));
		ans=ans+(ll)(upper_bound(v1.begin(), v1.end(), P(x[p]+y[p]-d, x[p]-y[p]+d))-upper_bound(v1.begin(), v1.end(), P(x[p]+y[p]-d, x[p]-y[p]-d)));
		ans=ans+(ll)(upper_bound(v2.begin(), v2.end(), P(x[p]-y[p]+d, x[p]+y[p]+d))-upper_bound(v2.begin(), v2.end(), P(x[p]-y[p]+d, x[p]+y[p]-d)));
	}
	printf("%lld\n", ans/2);
	return 0;
}

Measured memory_bytes: 18656
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    #print(ans)
    if ans > pow(10, 18):
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 21808
#include <stdio.h>

int main(void) {
  int a;
  int b;
  int x;
  int needs;
  scanf("%d %d %d", &a, &b, &x);
  needs = x - a;
  if (needs > b || needs < 0) printf("NO\n");
  else printf("YES\n");
  return 0;
}



Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int N=0;
long long dp[100100],Hi[100100];
int main(void){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>Hi[i];
	}
	dp[0]=0;
	dp[1]=abs(Hi[0]-Hi[1]);
	for(int i=2;i<N;i++){
		dp[i]=min(dp[i-1]+abs(Hi[i-1]-Hi[i]),dp[i-2]+abs(Hi[i-2]-Hi[i]));
	}
	cout<<dp[N-1];
	return 0;
}

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

int main(void){
	int i;
	int len;
	char str[20],rts[20] = {};

	scanf("%s",str);
	len = strlen(str);
	for(i = 0;i < len;i++){
		rts[i] = str[len - (i+1)];
	}
	rts[len] = '\0';
	printf("%s\n",rts);
	return 0;
}

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

char rot(char c, int n) {
    return (c-'A'+n)%26 + 'A';
}

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

    string res = "";
    for (int i=0; i<(int)S.size(); ++i) {
        res += rot(S[i], N);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
// Power Socket.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//

#include <iostream>

using namespace std;

int a, b;

int main() {
	cin >> a >> b;
	cout << (b + a - 3) / (a - 1) << endl;
	return 0;
}

// 运行程序: Ctrl + F5 或调试 >“开始执行(不调试)”菜单
// 调试程序: F5 或调试 >“开始调试”菜单

// 入门使用技巧: 
//   1. 使用解决方案资源管理器窗口添加/管理文件
//   2. 使用团队资源管理器窗口连接到源代码管理
//   3. 使用输出窗口查看生成输出和其他消息
//   4. 使用错误列表窗口查看错误
//   5. 转到“项目”>“添加新项”以创建新的代码文件，或转到“项目”>“添加现有项”以将现有代码文件添加到项目
//   6. 将来，若要再次打开此项目，请转到“文件”>“打开”>“项目”并选择 .sln 文件


Measured memory_bytes: 256
#include<stdio.h>

#define I 2000001
#define N 10000

void countingSort(int);

int A[I];
int B[I];
int C[N];

int main() {
  int i,x;

  scanf("%d",&x);
  for(i = 1; i < x + 1; i++) {
    scanf("%d",&A[i]);
  }

  countingSort(x);

   for(i = 1; i < x; i++) {
     printf("%d ",B[i]);
   }
     printf("%d\n",B[i]);

   return 0;
}

void countingSort(int a) {
  int i;

  for(i = 0; i <= N; i++) {
    C[i] = 0;
  }

  for(i = 1; i <= a; i++) {
    C[A[i]]++;
  }

  for(i = 1; i <= N; i++) {
    C[i] = C[i] + C[i - 1];
  }
  
  for(i = a; i > 0; i--) {
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}
  
   
  



Measured memory_bytes: 17408
n, m = map(int, input().split())
dic = {}
flag = True
for _ in range(m):
  digit, num = map(int, input().split())
  if dic.get(digit, None):
    if dic[digit] != num:
      flag = False
      break
  if digit == 1 and num == 0 and n != 1:
    flag = False
    break
  if not dic.get(digit, None):
    dic[digit] = num
if flag:
  lst = [0] * n
  for digit, num in dic.items():
    lst[digit - 1] = num
  s = ''
  if lst[0] == 0 and n != 1:
    lst[0] = 1
  for ele in lst:
    s += str(ele)
  print(int(s))
else:
  print(-1)

Measured memory_bytes: 9220
#include<stdio.h>
#include<string.h>
char t1[10] = "dream";
char t2[10] = "dreamer";
char t3[10] = "erase";
char t4[10] = "eraser";

int main()
{
	char s[100000];
	gets(s);
	int i;
	int number = 0;
	int flag = 0;
	int m = strlen(s);
	for(i = 0;i < m;i++)
	{
		if(s[i] == 'e' && s[i+2] == 'a'||s[i] == 'd')
		{
		 number = 0;
		}
		if(s[i] == t1[number] || s[i] == t2[number] || s[i] == t3[number] || s[i] == t4[number] )
		{
			flag = 0;		
			number++;
		}
		else
		{
			flag = 1;
			break;
		}

	}
	if(flag == 0) printf("YES\n");
	if(flag == 1) printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    print(max(A+B,A-B,A*B))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdio>

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

using namespace std;

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

	int ans=1001;
	rep(i,n){
		int c,t; scanf("%d%d",&c,&t);
		if(t<=T) ans=min(ans,c);
	}

	if(ans<=1000) printf("%d\n",ans); else puts("TLE");

	return 0;
}


Measured memory_bytes: 128
n = int(input())

#1行ずつ読んでやる方がスマートだけど、とりあえず見た目わかりやすい方で

t = [0] * (n+1)
x = [0] * (n+1)
y = [0] * (n+1)

t[0] = 0
x[0] = 0
y[0] = 0

for i in range(n):
    t[i+1],x[i+1],y[i+1] = map(int,input().split())

aFlg = True #ダメとなるまでは見なしOK

for i,tm in enumerate(t):
  xm = 0
  ym = 0
  if i > 0:
    if x[i] > x[i-1]:
      xm = x[i] - x[i-1]
    else:
      xm = x[i-1] - x[i]

    if y[i] > y[i-1]:
      ym = y[i] - y[i-1]
    else:
      ym = y[i-1] - y[i]

    if xm + ym > (t[i] - t[i-1]):  #動きすぎ
      aFlg = False
      break
    elif ((t[i] - t[i-1]) - (xm+ym))%2 == 1:  #そこには止まれない
      aFlg = False
      break

if aFlg:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 11636
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	cin >> n;
	V ans(n);
	ans[0]=0LL;
	V a(n);
	rep(i,n){
		cin>>a[i];
		if(i%2==0){
			ans[0]+=a[i];
		}else{
			ans[0]-=a[i];
		}
	}
	rep(i,n){
	
		if(i!=0){
			ans[i]=(a[i-1]-ans[i-1]/2)*2;
		}
		cout << ans[i] ;
		if(i!=n-1){
			cout<<" ";
		}else
		{
			cout<<endl;
		}
		
	}
	
}

Measured memory_bytes: 2944
#include<iostream>
#include<string>
using namespace std;
int main(){
	string a;
	cin>>a;
	int n=a.size(),res;
	for(int i=0;i<n;i++){
		if(a[i]=='A'){
//			cout<<i;
			res=i;
			break;
		}
	}
	for(int i=n-1;i>=0;i--){
		if(a[i]=='Z'){
//			cout<<i;
			res=i-res;
			res++;
			break;
		}
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;


int main(){
    int N;
    vector<int> A{};
    
    cin >> N;
    for (int i=0;i<N;i++) {
        int temp;
        cin >> temp;
        A.push_back(temp);
    }
    
    int result = 100000;
    int S1 = 0;
    int S2 = 0;
    for (int i=0;i<N;i++) {
        S2 += A[i];
    }
    for (int i=0;i<N-1;i++) {
        S1 += A[i];
        S2 -= A[i];
        result = min(result, abs(S1-S2));
    }
    
    cout << result << endl;
    
    
    return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int x = (j < a) ^ (i < b);
      cout << x;
    }
    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
int main()
{
  int n, a, b;
  scanf("%d", &n);
  if (n == 1) {
  printf("Hello World\n");
  }

  if (n == 2) {
      scanf("%d", &a);
      scanf("%d", &b);
      printf("%d", a+b);
  }

  return 0;

}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#define MAX_N 1000001
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll n,k,sum=0,cnt=0,tav,s=0,e,h;
  cin >> n >> k;
  ll a[n],f[n];
  vector<ll> v0,v1;
  ll ans=1000000000000;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    cin >> f[i];
  }
  sort(a,a+n);
  sort(f,f+n,greater<ll>());
  e = a[n-1]*f[0];
  while(s<e){
    h = (s+e)/2;
    cnt=0;
    for(int i=0;i<n;i++){
      cnt += a[i] - min(a[i],h/f[i]);
    }
    if(cnt<=k){
      e = h;
    }else if(cnt>k){
      s = h+1;
    }
  }
  cout << s << endl;
}

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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N,M;
int T[50010];
int S[50010];
int lis[]={9,11,0,2,4,5,7};

char t[3];
inline int in(){
    scanf("%s",t);
    return lis[t[0]-'A']+(t[1]=='#');
}

void solve(){
    scanf("%lld%lld",&N,&M);
    rep(i,N)T[i]=in();
    rep(i,M)S[i]=in();
    for(int fin=N-2;fin<N;fin++){
        bool ok=true;
        int pos=fin;
        for(int i=M-1;i>=0;i--){
            if(pos<0||pos==N){
                ok=false;
                break;
            }
            if(T[pos]==S[i])pos--;
            else if((T[pos]+1)%12==S[i])pos-=2;
            else if((T[pos]+11)%12==S[i])pos++;
            else{
                ok=false;
                break;
            }
        }
        if(ok&&pos==-1){
            puts("Yes");
            return;
        }
    }
    puts("No");
}

signed main(){
    int T;scanf("%lld",&T);
    while(T--)solve();
    return 0;
}

Measured memory_bytes: 1952
def main():
    n = int(input().strip())
    a = [[int(i) for i in input().split()] for _ in range(2)]

    rs = []
    for i in range(n):
        c = sum(a[0][0:i+1])
        c += sum(a[1][i:])
        rs.append(c)

    print(max(rs))


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
<?php
    while (true) {
        $num = trim(fgets(STDIN));
        if (strlen($num <= 3)){
                break;
        }
        $hit = 0;
        $brow = 0;
        $brow2 = 0;
        $num = str_split($num);
        // var_dump($num);
        for($i = 0; $i < 4; $i++){
            if($num[$i] == $num[5]){
                $brow++;
            }if($num[$i] == $num[6]){
                $brow++;
            }if($num[$i] == $num[7]){
                $brow++;
            }if($num[$i] == $num[8]){
                $brow++;
            }
        }
                if ($num[0] == $num[5]) {
                    $hit++;
                    $brow--;
                }if ($num[1] == $num[6]) {
                    $hit++;
                    $brow--;
                }if ($num[2] == $num[7]) {
                    $hit++;
                    $brow--;
                }if ($num[3] == $num[8]) {
                    $hit++;
                    $brow--;
                }
            echo $hit . " " . $brow . "\n";
    }


Measured memory_bytes: 9240
using System;
using System.Diagnostics;
using System.Linq;
using System.IO;

namespace ConsoleApp1
{
    class Program
    {
        static void print(string s)
        {
            Console.WriteLine(s);
        }

        static string scan()
        {
            return Console.ReadLine();
        }

        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var arr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var max = arr.Max();
            var count = new int[max + 1];
            for (int i = 0; i < n; i++)
            {
                count[arr[i]]++;
            }
            var isMultiples = Enumerable.Repeat(true, max + 1).ToArray();
            foreach (var value in arr.Distinct())
            {
                for (int i = value * 2; i <= max; i += value)
                    isMultiples[i] = false;
            }
            var answer = 0;
            for (int i = 0; i < n; i++)
            {
                if (isMultiples[arr[i]] && count[arr[i]] == 1) answer++;
            }
            var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(writer);
            Console.WriteLine(answer);
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 53092
#include<stdio.h>
int main(void){
int n,k,q;
  scanf("%d%d%d",&n,&k,&q);
  int a[q];
  for(int i=0;i<q;i++){
	scanf("%d",&a[i]);
  }
int count[n];
  for(int i=0;i<n;i++){
	count[i]=0;
  }
  for(int i=0;i<q;i++){
	count[a[i]-1]++;
  }
  for(int i=0;i<n;i++){
    if(k-q+count[i]>0)printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1280
//abc145_d.cpp
//Sat Nov 16 20:53:14 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

//nCk を1000000007で割った余りの計算。
const ll MAX = 1000000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(ll n, ll k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
	ll x,y;
	cin >> x >> y;

	if ((x+y)%3!=0){
		cout << 0 << endl;
		return 0;
	}

	ll dan = (x+y)/3+1;
	ll hashi = (dan-1)*2;

	if (x>hashi || y>hashi){
		cout << 0 << endl;
		return 0;
	}

	ll ban = hashi-x+1;
	COMinit();
	ll ans = COM(dan-1,ban-1);
	cout << ans << endl;
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
typedef long long int ll;
#define iceil(x,y) (x+y-1)/y

using namespace std;
typedef pair<int, int> P;

int main() {
	FAST;

	int n,x;
	int cnt=0;
	cin >> n >> x;
	int m[n];
	int d=1000000;
	rep(i,n) {
		cin >> m[i];
		x -= m[i];
		cnt++;
		if (m[i] < d) d = m[i];
	}
	
	while (x > 0) {
		if (x>=d) {
			x-=d;
			cnt++;
		}
		else break;
	}

	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 256
# 入力
D, G = map(int, input().split())
ps = [0] * D
cs = [0] * D

for i in range(D):
    ps[i], cs[i] = map(int, input().split())

# 再帰的に問題数を求める
def dfs(n, d, g):
    """
    d以下の問題でg点以上取るために必要な最小の問題数を返す

    Parameters
    ----------
    n : int
        dより大きいレベルを解いた数
    d : int
        レベル
    g : int
        点数
    m : int
        dレベルを解く場合の問題数
    p : int
        p問解いた場合に得られる点数

    Returns
    -------
    g点取るための問題数
    """
    # d < 1でgに満たない場合
    if d < 1:
        return float('inf')

    # 解くべき問題数(piまたはg点取るのに必要な最小の問題数)
    m = min(-(-g // (100 * d)), ps[d-1])

    # m問解いた時に得られる点数
    p = 100 * m * d + cs[d-1] if m == ps[d-1] else 100 * m * d

    
    if p >= g:  # g点以上取れる
        return min(n+m, dfs(n, d-1, g))
    else:       #g点に満たない
        return min(dfs(n + m, d - 1, g - p), dfs(n, d -1, g))

print(dfs(0, D, G))


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


int main() {

string s;
long K;
cin>>s>>K;
set<string> d;
int n=s.size();

for(int i=1;i<=K;i++){
  for(int j=0;j<n-i+1;j++){
    d.insert(s.substr(j,i));
  }
}

auto itr = d.begin();
for(int i=0;i<K-1;i++) itr++;
cout<<*itr<<endl;

}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <cmath>

int main() {
    std::string a, b, joined;
    std::cin >> a >> b;
    
    joined += a + b;
    int num = std::stoi(joined);
    
    bool ans = false;
    for (int i=0; i<num; ++i) {
        if (std::pow(i, 2)==num) {
            ans = true;
            break;
        }
    }
    
    std::cout << (ans ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int sum,n,m,p;
  int t[100]={};
  int s[100]={};

  std::cin >> n;

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

  std::cin >> m;

  for(int i=0;i<m;i++){
    sum = 0;
    p = 0;
    for(int k=0;k<n;k++){
      s[k] = t[k];
    }
    
    std::cin >> p;
    std::cin >> s[p-1];

    for(int j=0;j<n;j++){
      sum += s[j];
    }
    std::cout << sum << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    string s, t; cin >> s >> t;
    int n_s = s.size(), n_t = t.size();
    int ans = inf;
    for (int i = 0; i <= n_s - n_t; i++) {
        int sum = 0;
        string tmp = s.substr(i,n_t);
        rep(i,n_t) {
            if (tmp[i] != t[i]) sum++;
        }
        ans = min(ans,sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include<cstdio>
#include<iostream>
using namespace std;
string str[10]={" ","SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(){
	
	string t;
	cin>>t;
	int i=1,ans=1;
	while(t!=str[i]){
		i++;
	}
	for(;ans<=7;ans++){
		if(str[(i+ans)%7]=="SUN")break;
	}
	cout<<ans;
	
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}
int n,m;
int ans[1001][1001];
string s[1001];
queue<pair<int,int> > q;
void solve(int a,int b){
    if(a){
        if(ans[a][b]+1<ans[a-1][b]){
            ans[a-1][b]=ans[a][b]+1;
            q.push(make_pair(a-1,b));
        }
    }
    if(b){
        if(ans[a][b]+1<ans[a][b-1]){
            ans[a][b-1]=ans[a][b]+1;
            q.push(make_pair(a,b-1));
        }
    }
    if(a!=n-1){
        if(ans[a][b]+1<ans[a+1][b]){
            ans[a+1][b]=ans[a][b]+1;
            q.push(make_pair(a+1,b));
        }
    }
    if(b!=m-1){
        if(ans[a][b]+1<ans[a][b+1]){
            ans[a][b+1]=ans[a][b]+1;
            q.push(make_pair(a,b+1));
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>s[i];
        for(int j=0;j<m;j++){
            if(s[i][j]=='#'){
                ans[i][j]=0;
            }
            else{
                ans[i][j]=1e9;
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(ans[i][j]==0){
                q.push(make_pair(i,j));
            }
        }
    }
    while(!q.empty()){
        solve(q.front().first,q.front().second);
        q.pop();
    }
    int ma=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            ma=max(ma,ans[i][j]);
        }
    }
    cout <<ma<<endl;

    return 0;
}


Measured memory_bytes: 13456
import sys
input = sys.stdin.readline

N = int(input())

A = [input().strip() for i in range(N)]

B = []
for a in A:
    NOW=[0]*26

    for k in a:
        NOW[ord(k)-97]+=1

    B.append(NOW)
B.sort()
NOW=1
ANS=0
for i in range(1,N):
    if B[i]==B[i-1]:
        NOW+=1
    else:
        ANS+=NOW*(NOW-1)//2
        NOW=1

ANS+=NOW*(NOW-1)//2

print(ANS)
    

Measured memory_bytes: 82536
n,k=gets.split.map &:to_i
if  k==2
p n-1
exit
end

if  n==k
p 1
exit
end

a=gets.split.map &:to_i
i=a.index(1)

if  i+1<k
p ((n-k)/(k-1.0)).ceil+1
exit
end

if  n-i>k
p ((n-k)/(k-1.0)).ceil+1
exit
end

p (i/(k-1.0)).ceil+((n-i-1)/(k-1.0)).ceil

Measured memory_bytes: 8068
#include<bits/stdc++.h>
using namespace std;
#define ll unsigned long long
const ll mx=1e18;
map<ll,ll>mp;
ll a,b,c,d;
ll solve(ll n){
    if(n==1) return d;
    if(n==0) return 0;
    ll l1,l2,l3,r1,r2,r3;
    if(mp.count(n)) return mp[n];
    l1=n/2;
    r1=(n+1)/2;
    l2=n/3;
    r2=(n+2)/3;
    l3=n/5;
    r3=(n+4)/5;
    ll res=1e18;
    if(n<=mx/d) res=n*d;
    res=min(res,solve(l1)+(n-l1*2)*d+a);
    res=min(res,solve(r1)+(r1*2-n)*d+a);
    res=min(res,solve(l2)+(n-l2*3)*d+b);
    res=min(res,solve(r2)+(r2*3-n)*d+b);
    res=min(res,solve(l3)+(n-l3*5)*d+c);
    res=min(res,solve(r3)+(r3*5-n)*d+c);
    return mp[n]=res;
}
int main(){
    int t;
    cin>>t;
    while(t--){
       ll n;
       mp.clear();
       cin>>n>>a>>b>>c>>d;
       cout<<solve(n)<<'\n';
    }
}

Measured memory_bytes: 4288
#include <stdio.h>
int main()
{
  int N,p,cnt = 0;
  
  scanf("%d",&N);
 
  for(int i=1;i<=N;i++){
    scanf("%d" ,&p);
    if( p != i )
      cnt++;
  }
 
  if( cnt == 0 || cnt == 2)
    printf("YES\n");
  else
    printf("NO\n");
  
  return 0;
}

Measured memory_bytes: 1612
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n,m;
	cin>>n>>m;
	int suf=0;
	for(int i=0;i<m;++i){
		int t; cin>>t;
		suf += t;
	}
	if(suf>n) cout<<-1<<endl;
	else cout<<n-suf<<endl;
	return 0;
}

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

int main() {
	// your code goes here
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 ll t,n,i,j;
	     cin>>n;
	     string s;
	     unordered_map<string,ll> um;
	     while(n--)
	     {
	         cin>>s;
	         um[s]++;
	     }
	     cout<<"AC x "<<um["AC"]<<"\n";
	     cout<<"WA x "<<um["WA"]<<"\n";
	     cout<<"TLE x "<<um["TLE"]<<"\n";
	     cout<<"RE x "<<um["RE"]<<"\n";
	
	return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
vector<ll> now;
vector<ll> goal;
vector<ll> diff;

//解法
void solve() {

	ll sum = 0;
	ll shortage = 0;
	ll ans = 0;

	diff.resize(N);
	rep(i, N) {
		diff[i] = now[i] - goal[i];
		sum += diff[i];
		if (diff[i] < 0) {
			shortage -= diff[i];
			ans++;
		}
	}

	if (sum < 0) {
		cout << "-1";
		return;
	}

	SORTL2S(ll, diff);

	rep(i, N) {
		if (shortage <= 0) break;
		shortage -= diff[i];
		ans++;
	}

	cout << ans;

	return;
}

int main() {
	//入力

	cin >> N;
	now.resize(N);
	goal.resize(N);
	rep(i, N) cin >> now[i];
	rep(i, N) cin >> goal[i];

	solve();
	cout << endl;
	return 0;
}

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

using namespace std;

char s[600005];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    cin>>s+200000;
    int n=strlen(s+200000);
    int l=199999,r=200000+n;
    int cnt=0;

    int q;cin>>q;
    while(q--){
        int op;cin>>op;
        if(op==1){
            cnt^=1;
        }else{
            int opop;
            cin>>opop;
            char t;cin>>t;
            if(opop==1){
                if(!cnt)s[l--]=t;
                else s[r++]=t;
            }else{
                if(!cnt)s[r++]=t;
                else s[l--]=t;
            }
        }
    }

    if(!cnt){
        for(int i=l+1;i<r;++i)cout<<s[i];
    }
    else{
        for(int i=r-1;i>=l+1;--i)cout<<s[i];
    }

    return 0;
}


Measured memory_bytes: 896
#include <stdio.h>

int main(void){
	int a[10];
	int i;
	int x;
	for (;;)
	{
	
		for (i=0;i<=9;i++)
		{
			scanf("%d",&a[i]);
			if (a[0]==0)
			{
				break;
			}
		}
		if (a[0]==0)
		{
			break;
		}
		x=a[0];
		for(i=1;i<=9;i++){
			x=x-a[i];
		}
			
		printf("%d\n",x);
	}		
	return 0;
}

Measured memory_bytes: 596
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val X = scanner.nextLong()
    val Y = scanner.nextLong()

    var ret = 0
    var tmp = X
    while (tmp <= Y) {
        ret++
        tmp = tmp shl 1
    }

    println(ret)
}

Measured memory_bytes: 31268
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

int main() {
  int n;
  cin >> n;
  long double x[n];
  string u[n];

  long double res=0;
  for(int i = 0; i < n; ++i){
    cin >> x[i] >> u[i];
    if(u[i]=="BTC"){
      x[i] *= 380000.0;
    }
    res+=x[i];
  }
  
  cout << res << endl;
}



Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll x=n%(a+b);
  ll y=n/(a+b);
  ll ans=a*y;
  if(a>x){
    ans+=x;
  }
  else{
    ans+=a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<vector>
#include<algorithm>
#define MAXN 200006
using namespace std;
int d[MAXN],n,a,b;
vector<int> road[MAXN];
void DFS(int x,int fa)
{
	int ok=0;
	for(int i=0;i<(int)road[x].size();i++)
	{
		int nex=road[x][i];
		if(nex==fa) continue;
		DFS(nex,x);
		if(d[nex]==0)
		{
			if(ok==0) ok=1;
			else d[x]++;
		}
		else d[x]+=d[nex];
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&a,&b);
		a++;
		b++;
		road[a].push_back(b);
		road[b].push_back(a);
	}
	int st=0;
	for(int i=1;i<=n;i++)
	{
		if(road[i].size()>=3)
		{
			st=i;
			break;
		}
	}
	if(st==0) printf("1");
	else 
	{
		DFS(st,0);
		printf("%d",d[st]);
	}
}

Measured memory_bytes: 12672
#!/usr/bin/env python3
import math
import sys


def solve(H: int, A: int):
    ans = math.ceil(H / A)
    print(ans)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(H, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060