akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner scan=new Scanner(System.in);

		int n=scan.nextInt();

		int a=0;
		int sum=100000;
		int[][] m=new int[2][5];

		for(a=1;a<=n/2;a++) {
			int a1=a;
			int b1=n-a;
			for(int j=4;j>=0;j--) {
				if(a1/Math.pow(10, j)<1) {
					m[0][j]=0;
				}else {
					m[0][j]=(int)Math.floor(a1/Math.pow(10, j));
					a1-=(int)Math.floor(a1/Math.pow(10, j))*Math.pow(10, j);
				}
				if(b1/Math.pow(10, j)<1) {
					m[1][j]=0;
				}else {
					m[1][j]=(int)Math.floor(b1/Math.pow(10, j));
					b1-=(int)Math.floor(b1/Math.pow(10, j))*Math.pow(10, j);
				}
			}

			int sum1=0;

			for(int k=0;k<5;k++) {
				sum1+=(m[0][k]+m[1][k]);
			}
			if(sum1<sum) {
				sum=sum1;
			}
		}

		System.out.println(sum);
	}

}


Measured memory_bytes: 23136
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n)
	if(n%2)
	{
		ld ans=(n/2+1);
		cout<<fixed<<setprecision(10)<<ans/n<<'\n';
	}
	else
	{
		cout<<0.5<<'\n';
	}
	printclock;
}

Measured memory_bytes: 256
s=str(input())
t=str(input())
n=len(s)-len(t)
cl=[]
for i in range(n+1):
    cnt=0
    for j in range(len(t)):
        if s[j+i]==t[j]:
            cnt+=1
    cl.append(cnt)
print(len(t)-max(cl))

Measured memory_bytes: 67724
N = int(input())
As = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
for a in As:
    d[a] += 1
cnt = 0
for k in d.keys():
    if d[k]-k >= 0:
        cnt += d[k] - k
    else:
        cnt += d[k]
print(cnt)

Measured memory_bytes: 18164
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
 
int main(){
   int N, C, K;
   cin >> N >> C >> K;
   vector<int> T(N);
   REP(i, N){
      cin >> T[i];
   }
   sort(T.begin(), T.end());
   int cnt = 0, pre=T[0], ans=0;
   REP(i, N){
      if(T[i] <= pre+ K){
         cnt++;
      }
      else{
         ans++;
         cnt = 1;
         pre = T[i];
      }
      if(cnt >= C ){
         ans++;
         cnt = 0;
         pre = T[i+1];
      }
      //cout << i << " " << ans << endl;
   }
   if(cnt){
      ans++;
   }
   if(C == 1){
      ans = N;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

int main() {
	int N = in();
	int K = in();
	map<int, int> indata;
	rep(i,N) indata[in()]++;
	
	vint data;
	for (auto &&i : indata) data.pb(i.second);
	sort(data.begin(), data.end());
	pra(data);
	int kind = data.size();
	// rep(i,N) if (i == 0 || data[i] != data[i-1]) kind++;
	int ans = 0;
	int todo = kind - K;
	rep(i,data.size()) {
		if (todo <= 0) break;
		ans+=data[i];
		todo--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s;
	cin>>s;
	rep(i,3)cout<<s[i]; 
	return 0;
}



Measured memory_bytes: 3616
import math
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

n, = read_line(int)

weights = []
for i in range(5):
    w, = read_line(int)
    weights.append(w)

if n == 0:
    print(0)
elif n <= min(weights):
    print(5)
else:
    print(5 + int(math.ceil(n / min(weights))) - 1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const long long M=1000000007;//can be changed
const int m=3282;
long long dp[101][m];

int main(){
	long long n,k;
	cin>>n>>k;
	long long ans=(n*(k*(k+1)/2))%M;
	for(int i=0;i<n-1;++i){
		ans*=(k+1);
		ans%=M;
	}
	fill(dp[n],dp[n]+m,0);
	dp[n][0]=1;
	for(int i=n;i>0;--i) for(int j=0;j<m;++j) for(int a=0;a<=k;++a){
		if(a<=i){
			dp[i-1][j+(a+j)/i]+=dp[i][j];
			dp[i-1][j+(a+j)/i]%=M;
		}
		else{
			dp[i-1][j]+=dp[i][j];
			dp[i-1][j]%=M;
		}
	}
	for(int j=0;j<m;++j) ans=(ans+M-(j*dp[0][j])%M)%M;
	cout<<ans<<endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll=long long;
using Graph=vector<vector<ll>>;
int main(){
  int n;cin>>n;
  map<ll,ll> a;
  for(int i=0;i<n;++i){
    ll x;cin>>x;
    a[x]++;
  }
  ll c=0;
  for(auto it=a.begin();it!=a.end();++it){
    int t=it->second;
    if(t&1)c++;
  }
  cout<<c;
}

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

bool solve() {
    string S; cin >> S;
    if(S.front() == S.back()) {
        if(S.size() % 2) return false;
        else return true;
    } else {
        if(S.size() % 2) return true;
        else return false;
    }
}

int main() {
    cout << (solve() ? "First" : "Second") << '\n';
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vl = vector<ll>;
using vi = vector<int>;
using Graph = vector<vi>;

vi C(26), Last(26, -1), T(365);
vector<vi> S(365, vi(26));
vector<vi> table(365, vi(26));
ll ans = 0;
int D, M;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(15); //"for float-base
  // problem"
  int cmax = 0, smax;
  cin >> D;
  REP(i, 26) {
    cin >> C.at(i);
    if (C.at(cmax) < C.at(i)) cmax = i;
  }
  REP(i, D) {
    int smax = 0;
    REP(j, 26) {
      cin >> S.at(i).at(j);
      if (S.at(i).at(smax) < S.at(i).at(j)) smax = j;
    }
    T.at(i) = (C.at(cmax) < S.at(i).at(smax)) ? smax + 1 : cmax + 1;
  }

  REP(i, D) { cout << T.at(i) << endl; }
}

Measured memory_bytes: 3716
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<string>
using namespace std;
 
struct Edge{
    int a,b,d;
    bool operator<(const Edge a)const{
        return d<a.d;
    }
};
 
int par[100],rank_[100];
 
void init(int n){
    for(int i=0;i<n;i++) par[i] = i, rank_[i] = 1;
}
 
int find(int x){
    if(par[x]==x) return x;
    return par[x] = find(par[x]);
}
 
bool unite(int _a,int _b){
    int a = find(_a), b = find(_b);
    if(a==b) return false;
    if(rank_[a]>rank_[b]) par[b] = a;
    else{
        par[a] = b;
        if(rank_[a]==rank_[b]) rank_[b]++;
    }
    return true;
}
 
int main(){
    int N,M;
    while(cin>>N,N){
        init(N);
        cin>>M;
        Edge e[10000];
        for(int i=0;i<M;i++) scanf("%d,%d,%d",&e[i].a,&e[i].b,&e[i].d);
        sort(e,e+M);
        int ans = 0;
        for(int i=0;i<M;i++){
            if(unite(e[i].a,e[i].b)){
                ans += e[i].d/100-1;
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
char a[20],mb[20]={"CODEFESTIVAL2016"};
int main() 
{
	int ans=0;
	scanf("%s",a);
	for (int i=0;i<16;i++)
	  if (a[i]!=mb[i]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main(){

    long int h;
    scanf("%ld", &h);
    long int count = 0;
    long int num = 1;
    while (h > 0){
        h /= 2;
        count += num;
        num *= 2;
        // printf("%ld\n", count);
    }
    printf("%ld\n", count);
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	string a,b,c; cin>>a>>b>>c;
	int ret=0;
	for (int i=0; i<n; i++) {
		set<char> st={a[i],b[i],c[i]};
		ret+=st.size()-1;
	}
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

    long a, b, c, d;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    // ユークリッドの互除法
    // num2に最小公倍数が入る
    long num1, num2;
    if(c < d){
        num1 = d;
        num2 = c;
    }else{
        num1 = c;
        num2 = d;
    }
    long r = num1 % num2;
    while(r != 0){
        num1 = num2;
        num2 = r;
        r = num1 % num2;
    }
    
    long LCM = c * d / num2;
    long result = (b - a + 1) - (b / c - (a - 1) / c) - (b / d - (a - 1) / d) + (b / LCM - (a - 1) / LCM);

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
N=int(sys.stdin.readline().strip())
X=sys.stdin.readline().strip()

cnt_of_one=0
for x in X:
    if x=="1": cnt_of_one+=1

cnt_of_one_plus_one=cnt_of_one+1
cnt_of_one_minus_one=cnt_of_one-1

amari_cnt_of_one_plus_one=0
amari_cnt_of_one_minus_one=0
for i,x in enumerate(X[::-1]):
    if x=="1":    #その桁の値が1の時だけ数を足す
        amari_cnt_of_one_plus_one+=pow(2,i,cnt_of_one_plus_one)
        amari_cnt_of_one_plus_one%=cnt_of_one_plus_one
        if cnt_of_one_minus_one==0: #2進数の全ての桁が0の場合は、0で除算はできないので場合分け
            amari_cnt_of_one_minus_one=0
        else:
            amari_cnt_of_one_minus_one+=pow(2,i,cnt_of_one_minus_one)
            amari_cnt_of_one_minus_one%=cnt_of_one_minus_one

def popcount(n):
    ret=0
    while 0<n:
        ret+=n%2
        n/=2
    return ret

def f(n):
    ret=0   #余りが0になるまでの割った回数
    while 0<n:
        n%=popcount(n)
        ret+=1
    return ret

for i,x in enumerate(X):
    keta=N-i-1
    if x=="0":
        syoki_amari=(amari_cnt_of_one_plus_one+pow(2,keta,cnt_of_one_plus_one))%cnt_of_one_plus_one
        if syoki_amari==0:
            print 1
        else:
            print 1+f(syoki_amari)
    elif x=="1":
        if cnt_of_one_minus_one==0: #2進数の全ての桁が0という意味だから
            print 0 #値が0になるまでの操作回数は0回
        else:
            syoki_amari=(amari_cnt_of_one_minus_one-pow(2,keta,cnt_of_one_minus_one))%cnt_of_one_minus_one
            if syoki_amari==0:
                print 1
            else:
                print 1+f(syoki_amari)
            

Measured memory_bytes: 87548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n,a,b;
  cin >> n >> a >> b;
  int ans;
  ans = min(b,a*n);
  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
import math

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

N, M = map(int, input().split())

E = np.zeros((N, N), dtype=int)

for m in range(M):
    s, t = map(int, input().split())
    s = s-1
    t = t-1
    E[s][t] = 1
    E[t][s] = 1

# print(E)
    
bridges = set()
TIME = 0
    
def bridgeN(n, visited, parent, low, dis):
    global TIME
    visited[n] = 1
    dis[n] = TIME
    low[n] = TIME
    TIME += 1

    # print('time', TIME)

    # print('n=', n)
    # print('visited=', visited)
    
    for v in range(N):
        if E[n][v] == 0:
            continue
        if visited[v] == 1:
            if v != parent[n]:
                low[n] = min(low[n], dis[v])
            continue

        # print('visited[', v, ']=', visited[v])
        
        parent[v] = n
        bridgeN(v, visited, parent, low, dis)

        low[n] = min(low[n], low[v])

        if low[v] > dis[n]:
            if v <= n:
                bridges.add((v, n))
            else:
                bridges.add((n, v))
                

def bridge(E):
    visited = np.zeros(N, dtype=int)
    dis = np.full_like(visited, N*N*10)
    low = np.full_like(visited, N*N*10)
    parent = np.full_like(visited, -1)

    for n in range(N):
        if visited[n] == 0:
            bridgeN(n, visited, parent, low, dis)

bridge(E)
nBridges = len(bridges)
# print(bridges)

print(nBridges)



Measured memory_bytes: 12512
/*
  AOJ #2920
  title:
  @kankichi573
*/
#include <stdio.h>
#include <float.h>
#include <limits.h>
#define min(x,y) (((x)<(y))?(x):(y))

int main()
{
  int i,ret,sum,n,b,oddmin;

  oddmin=INT_MAX;
  sum =0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
       scanf("%d",&b);
       if(b & 1)
          oddmin =min(oddmin,b);
       sum += b;
    }
  if(sum & 1)
  {
     if(oddmin == INT_MAX)
          ret=0;
     else
          ret = (sum-oddmin)/2;
  }
  else
     ret=sum/2;
  //printf("sum=%d\n",sum);
  printf("%d\n",ret);
  return(0);
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H,W;
	cin >> H >> W;
	vector<int> a(H*W);
	for(int i =0; i< H*W;i++) {
		cin >> a[i];
	}
	int mc=0;//movecount
	vector<int> x(H*W);
	vector<int> y(H*W);
	vector<int> xa(H*W);
	vector<int> ya(H*W);
	
	for(int i =0; i< H*W-1;i++) {
		if(!(a[i] & 1))
			continue;
		if((i+1) % W != 0) {
			a[i]--;
			a[i+1]++;
			
			x[mc] = (i+1)%W;
			ya[mc] = y[mc] = i/W + 1;
			xa[mc] = x[mc] + 1;
			mc++;
		} else {
			a[i]--;
			a[i+W]++;
			
			xa[mc] = x[mc] = W;
			y[mc] = (i+1)/W;
			ya[mc] = y[mc]+1;
			mc++;
		}
	}	
	cout << mc << endl;
	for(int i =0; i< mc; i++)
	{
		cout << y[i] << " "<< x[i] << " "<< ya[i] << " "<< xa[i] << endl;
	}
}

Measured memory_bytes: 7040
from itertools import permutations
n,m=map(int,input().split())
graph=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

    
ans=0

for i in permutations(range(1,n+1)):
    if i[0]!=1:
        continue
    for j in range(n-1):
        if i[j+1] not in graph[i[j]]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,s,d;
    cin >> a >> s >> d;
    if( (s*10+d) % 4 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
using namespace std;
int main()
{ int n;
 cin>>n;
 int a[9],s[9];
 FOR(n) cin>>a[i];
 FOR(n) cin>>s[i];
 int cnt =1;
 int f=1,b=1;
 int g[9];
 FOR(n) g[i]=i+1;
 while (next_permutation(g,g+n))
        { cnt++;
          int ok=0;
          FOR(n) 
          {if(g[i]==s[i])
              ok++;
          } 
          if(ok==n)
          {f=cnt;
           ok =0;
          }
          ok =0;
          FOR(n) 
          {if(g[i]==a[i])
              ok++;
          } 
          if(ok==n)
          {b=cnt;
           ok =0;
          }
          ok =0;
         }
cout<<abs(f-b);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>



int main(void)
{
	//変数の宣言
	int n,t;
	int cost[110];
	int time[110];
	int i;
	int ans;
	
	//データの読み込み
	scanf("%d %d",&n,&t);
	
	for(i=0;i<n;i++){
		scanf("%d %d",&cost[i],&time[i]);
	}
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	ans=1001;
	
	for(i=0;i<n;i++){
		if(time[i]<t+1){
			if(cost[i]<ans){
				ans=cost[i];
			}
		}
	}
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	if(ans==1001){
		printf("TLE");
	}else{
		printf("%d",ans);
	}
	
//	printf("結果の出力終了\n");
	
	return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main(){
	long long int N;
	scanf("%lld",&N);
	long long int i;
	int count;
	count=0;
	long long int a[2000000];
	for(i=1;i*i<=N;i++){
		if(N%i==0){
			a[count]=i;
			count=count+1;
			if(i*i!=N){
				a[count]=N/i;
				count=count+1;
			}
		}
	}
	int j;
	long long int ans;
	ans=0;
	long long int m;
	for(j=1;j<count;j++){
		m=a[j]-1;
		if(N%m==N/m){
			ans=ans+m;
		}
	}
	printf("%lld",ans);
}

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

using namespace std;

int main(){
    int h, w;
    string s, n;

    cin >> h >> w;

    for(int i = 0; i < w + 2; i++) s.push_back('#');
    cout << s << endl;

    for(int i = 0; i < h; i++){
        cin >> n;
        cout << "#" << n << "#" << endl;
    }
    cout << s << endl;
}

Measured memory_bytes: 3572
S = input()
s = list(S)
n = len(s)
ans = [[0 for i in range(13)]for i in range(n)]
mod = 10**9+7
if s[0] == '?':
    for i in range(10):
        ans[0][i] += 1
else:
    ans[0][int(s[0])] += 1
for i in range(n-1):
    if s[i+1] == '?':
        for j in range(10):
            for k in range(13):
                ans[i+1][(10*k+j)%13] += ans[i][k]%mod
    else:
        for k in range(13):
            ans[i+1][(10*k+int(s[i+1]))%13] += ans[i][k]%mod
print((ans[n-1][5])%(10**9+7))

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	map<ll, ll> m;
	ll ans = 0;

	cin >> n;

	REP(i, 100003) {
		m[i - 1] = 0;
	}

	REP(i, n) {
		ll a;
		cin >> a;
		m[a]++;
		m[a - 1]++;
		m[a + 1]++;
	}

	REP(i, m.size()) {
		if (m[i - 1] > ans) {
			ans = m[i - 1];
		}
	}

	cout << ans << endl;
}

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

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

  vector<char> als;
  for (char c = 'a'; c <= 'z'; c++)
  {
    als.push_back(c);
  }

  string ans = "";
  n--;
  while(n>=0){
    char an = als[n%26];
    ans.push_back(an);
    if(n<26) break;
    n/=26;
    n--;
  }
  reverse(ans.begin(),ans.end());
  cout << ans << endl;
  
}

Measured memory_bytes: 3612
def mod(x):
    return int(x % (1e+9 + 7))


def combination_dp(s):
    if s < 3:
        return 0
    dp = []
    dp.append(1)
    for i in range(1, s + 1):
        if i < 3:
            dp.append(0)
        else:
            start = 0
            end = i - 3 + 1
            dp.append(mod(sum(dp[start: end])))
    return dp[-1]


if __name__ == '__main__':
    S = int(input())
    print(combination_dp(S))


Measured memory_bytes: 8772
#include <stdio.h>
int main() {
	int x, sum = 0;
	scanf("%d", &x);
	for (int i = 1; i < 5e4; i++) {
		sum += i;
		if (sum >= x) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
//0011 DrawingLots}

public class Main {
	private static Scanner sc;

	public static void main(String args[]) {
		sc = new Scanner(System.in);
		int w, n;

		// w???n???????????????
		w = sc.nextInt();
		n = sc.nextInt();

		// ??´??°???????????????????????????????????????????????????????£??????????????????????????????¨??????????£????
		int number[] = new int[w];
		// ?????????????¨????
		for (int k = 0; k < w; k++) {
			number[k] = k + 1;
		}

		// ?¨??£???????????????????????????????????¬¬????????¨?¬¬???????????°????????????
		int hbar[][] = new int[n][2];

		// ???????????¨???n?????????string????????????????????????????????¨??????int???????????????HorizontalBar???????´???????
		// ?????¨??????????£??????¢??????????¨??£??????????????´???´????????§?????????????????????????????°????????????
		// ????????????????????????????????????????????????
		String buff;

		for (int k = 0; k < n; k++) {
			// System.out.printf("aa1\n");

			buff = sc.next();

			// // System.out.printf("aa2\n");
			// System.out.printf("%s\n", buff);
			// System.out.printf("1's : %d\n",
			// Integer.parseInt(buff.substring(0, buff.indexOf(","))));
			// System.out.printf("%d\n", buff.indexOf(","));
			// System.out.printf("2's : %d\n",
			// Integer.parseInt(buff.substring(2)));

			// ??????????????????????????¨??????????????????????????°????????????????´?
			hbar[k][0] = Integer.parseInt(buff.substring(0, buff.indexOf(",")));
			hbar[k][1] = Integer.parseInt(buff.substring(buff.indexOf(",") + 1));

			// System.out.printf("[%d][%d] : (%d, %d)\n", k, 01, hbar[k][0],
			// hbar[k][1]);
		}

		// ????£????????????§?????????????????????
		for (int i = 0; i < w; i++) {
			// ?¨??£???§???????????????????£?????????????a1???b1????????£???????????????????????????????´¢???????????????
			// ???????????????????¨??£?????????????????????????????????????????£???????????????????
			for (int k = 0; k < n; k++) {
				if (hbar[k][0] == number[i]) {
					// System.out.printf("HITleft!! tate[%d](=%d) excahged {%d}
					// at yoko[%d]\n", i + 1, number[i],
					// hbar[k][1], k + 1);
					number[i] = hbar[k][1];
				} else if (hbar[k][1] == number[i]) {
					// System.out.printf("HITright!! tate[%d](=%d) excahged {%d}
					// at yoko[%d]\n", i + 1, number[i],
					// hbar[k][0], k + 1);
					number[i] = hbar[k][0];
				}
			}
		}

		for (int k = 0; k < w; k++) {
			for (int i = 0; i < w; i++) {
				if (number[i] == k + 1) {
					// System.out.printf("number[%d](=%d) == %d\n", i + 1,
					// number[i], k + 1);
					System.out.printf("%d\n", i + 1);
				}
			}
		}

	}

}

Measured memory_bytes: 25984
// 2020-07-27 02:21:11
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
const int mod = 1000000007;
struct mint {
  ll val;
  constexpr mint(ll v = 0) noexcept : val(v % mod) {
    if (val < 0) val += mod;
  }
  constexpr mint operator + (const mint& rhs) const noexcept {
    return mint(*this) += rhs;
  }
  constexpr mint operator - (const mint& rhs) const noexcept {
    return mint(*this) -= rhs;
  }
  constexpr mint operator * (const mint& rhs) const noexcept {
    return mint(*this) *= rhs;
  }
  constexpr mint operator / (const mint& rhs) const noexcept {
    return mint(*this) /= rhs;
  }
  constexpr mint operator ~ () const noexcept {
    ll a = this->val, b = mod, u = 1, v = 0;
    while (b > 0) {
      ll t = a / b;
      a -= t * b;
      u -= t * v;
      ll c = a; a = b; b = c;
      ll w = u; u = v; v = w;
    }
    if (u < 0) u += mod;
    u %= mod;
    return u;
  }
  constexpr mint& operator += (const mint& rhs) noexcept {
    val += rhs.val;
    if (val >= mod) val -= mod;
    return *this;
  }
  constexpr mint& operator -= (const mint& rhs) noexcept {
    if (val < rhs.val) val += mod;
    val -= rhs.val;
    return *this;
  }
  constexpr mint& operator *= (const mint& rhs) noexcept {
    val = val * rhs.val % mod;
    return *this;
  }
  constexpr mint& operator /= (const mint& rhs) noexcept {
    val = val * (~(mint(rhs))).val % mod;
    return *this;
  }
  friend mint modpow (mint a, ll n) noexcept {
    auto res = mint(1);
    while(n > 0) {
      if(n&1) res *= a;
      a *= a;
      n >>= 1;
    }
    return res;
  }
  friend std::ostream& operator << (std::ostream& os, const mint& a) noexcept {
    return os << a.val;
  }
  friend std::string debug_s (mint a) noexcept {
    return std::to_string(a.val);
  }
};

mint dp[13], p[13];
void answer() {
  string s;
  cin >> s;
  reverse(ALL(s));
  int sz = s.size();
  dp[0] = 1;
  int d = 1;
  auto add = [&](int ci) {
    int n = d * ci % 13;
    rep(m, 13) dp[(n+m)%13] += p[m];
  };
  rep(i, sz) {
    memset(p, 0, sizeof p);
    swap(p, dp);
    char c = s[i];
    if(c == '?') {
      rep(ci, 10) add(ci);
    } else {
      add(c - '0');
    }
    d = d * 10 % 13;
  }
  cout << dp[5] << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3784
import bisect

n = int(input())
a = [int(input()) for _ in range(n)]
# LIS
# 前から順番に埋めていく
# 順番に入る箇所を二分探索する bisect_right
# 1,3,3,4 3 -> 3 , 4-> 4
INF = 10 ** 9 + 1
dp = [INF] * n
ans = 0
for i in range(n):
    idx = bisect.bisect_left(dp, a[i])
    """
    if dp[idx - 1] == a[i]:  # 同じ数が並んできるケース
        continue
    """
    ans = max(idx + 1, ans)
    dp[idx] = a[i]
print(ans)



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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

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

int main(int argc, char *argv[])
{
    map<int, int> m;
    ll sum = 0;

    int N;
    cin >> N;
    vi A(N);
    rep(i, N) {
        cin >> A[i];

        m[A[i]]++;
        sum+= A[i];
    }
    int Q;
    cin >> Q;

    rep(i, Q) {
        int B, C;
        cin >> B >> C;

        if (C > B) {
            sum += (C-B) * m[B];
        } else {
            sum -= (B-C) * m[B];
        }
        m[C] += m[B];
        m[B] = 0;

        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 8048
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
   sort(begin(v),end(v),f);
   v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=1e5+5;
int indeg[N];
VI G[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
   
  int n,m;
  cin >> n >> m;
  REP(i,n+m-1) {
    int a,b;
    cin >> a >> b;
    indeg[b]++;
    G[a].PB(b);
  }
  vector<int> ans(n+1);
  vector<int> q;
  REP1(i,1,n) {
    if ( indeg[i]==0 ) {
      ans[i]=0;
      q.PB(i);
      break;
    }
  }
  while ( q.size() ) {
    VI nq;
    for ( int u:q ) {
      for ( int v:G[u]) {
        indeg[v]--;
        if ( indeg[v]==0 ) {
          ans[v]=u;
          nq.PB(v);
        }
      }
    }
    q=nq;
  }
  REP1(i,1,n) {
    cout << ans[i] << '\n';
  }
  return 0;
}

Measured memory_bytes: 9512
#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()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

struct edge{
    int to;
    ll cost;
};

const ll INF = LLONG_MAX/3;

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

    vector<int> x;
    x.pb(0);
    x.pb(L);

    vector<int> p(n),d(n),t(n);
    rep(i,n){
        scanf(" %d %d %d", &p[i], &d[i], &t[i]);
        x.pb(p[i]);
        x.pb(p[i]+d[i]);
    }

    sort(all(x));
    x.erase(unique(all(x)), x.end());

    int X = x.size();
    vector<vector<edge>> G(X);

    auto ADD = [&](int u, int v, ll w){
        G[u].pb({v,w});
    };

    rep(i,X-1) ADD(i, i+1, x[i+1]-x[i]);
    rep(i,n){
        int u = lower_bound(all(x), p[i]) - x.begin();
        int v = lower_bound(all(x), p[i]+d[i]) - x.begin();
        ADD(u, v, t[i]);
    }

    vector<ll> dp(X,INF);
    dp[0] = 0;
    rep(i,X)for(const auto &e:G[i]) dp[e.to] = min(dp[e.to], dp[i]+e.cost);

    printf("%lld\n", dp[X-1]);
    return 0;
}



Measured memory_bytes: 3464
#include <algorithm>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>

long solve(long k)
{
  auto q = std::priority_queue<long, std::deque<long>, std::greater<long>>{};
  for (long i = 1; i <= 9; ++i) {
    q.push(i);
  }

  for (int i = 0; i < k - 1; ++i) {
    long v = q.top();
    q.pop();
    auto x = v % 10;
    if (x >= 1) q.push(v * 10 + x - 1);
    q.push(v * 10 + x);
    if (x <= 8) q.push(v * 10 + x + 1);
  }

  return q.top();
}

int main()
{
  long k;
  std::cin >> k;

  std::cout << std::setprecision(20);
  std::cout << solve(k) << std::endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int n, m, q;
vector<int> a, b, c, d;
int ans;
 
void dfs(vector<int> A) {
  if (A.size() == n+1) {
    int now = 0;
    rep(i,q) {
      if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
    }
    ans = max(ans, now);
    return;
  }
 
  A.push_back(A.back());
  while (A.back() <= m) {
    dfs(A);
    A.back()++;
  }
}
 
int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  dfs(vector<int>(1,1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i = a; i <= b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

const int mxn = 1e5 + 10;
int dp[mxn];
bool c[mxn];
int n,m;
vector<int> g[mxn];

int f(int i)
{
	if(c[i])
		return dp[i];
	if(g[i].empty())
		dp[i] = 0;
	else
	{
		dp[i] = 0;
		for(int v : g[i])
			dp[i] = max(dp[i], 1 + f(v));
	}
	c[i] = 1;
	return dp[i];
}

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;
	FOR(i,1,m)
	{
		int u,v;	cin >> u >> v;
		g[u].pb(v);
	}

	memset(c,0,sizeof(c));

	int ans = -2e18;
	FOR(i,1,n)
		ans = max(ans, f(i));
	cout << ans;

	return 0;
}

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

int main() {
  long long N;
  cin >> N;
  string S;
  cin >> S;
  bool b = false;
  for(int i = 0; i < N-1; i++) {
    if(S.at(i) == 'W' && S.at(i+1) == 'R') {
      b = true;
      break;
    }
  }
  long long r = 0;
  long long w = 0;
  for(int i = 0; i < N; i++) {
    if(S.at(i) == 'R') {
      r++;
    }
    else {
      w++;
    }
  }
  string SS;
  for(int i = 0; i < r; i++) {
    SS += 'R';
  }
  for(int i = 0; i < w; i++) {
    SS += 'W';
  }
  long long cnt = 0;
  for(int i = 0; i < N; i++) {
    if(S.at(i) != SS.at(i)) {
      cnt++;
    }
  }
  if(b) {
    cout << min(cnt/2,min(r,w)) << endl;
  }
  else {
    cout << "0" << endl;
  }
}


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



int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<pii> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i].first;
		a[i].second = i;
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n; ++i) {
		cout << a[i].second+1 << ' ';
	}
}

Measured memory_bytes: 1664
#095_D
n, c = map(int, input().split())
x, v = [0], [0]
for _ in range(n):
    a, b = map(int, input().split())
    x.append(a)
    v.append(b)
x.append(c)
v.append(0)

fr1, fr2 = [0 for _ in range(n+1)], [0 for _ in range(n+1)]
fl1, fl2 = [0 for _ in range(n+2)], [0 for _ in range(n+2)]

tmp1, tmp2 = 0, 0
for i in range(0, n):
    tmp1 += v[i+1] - (x[i+1] - x[i])
    tmp2 += v[i+1] - 2 * (x[i+1] - x[i])
    fr1[i+1] = max(tmp1, fr1[i])
    fr2[i+1] = max(tmp2, fr2[i])
    
tmp1, tmp2 = 0, 0
for i in range(n, 0, -1):
    tmp1 += v[i] - abs(x[i+1] - x[i])
    tmp2 += v[i] - 2 * abs(x[i+1] - x[i])
    fl1[i] = max(tmp1, fl1[i+1])
    fl2[i] = max(tmp2, fl2[i+1])

ans = 0
for i in range(n+1):
    ans = max(ans, fr1[i] + fl2[i+1], fr2[i] + fl1[i+1])
print(ans)

Measured memory_bytes: 25884
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i <(int)(n); i++)
 
int main(){
  int N;
  cin >> N;
  vector<int> vec(N,0);
  rep (i,N){
    int a;
    cin >> a;
    vec[i]=a;
  }
  vector<int> vec1;
  rep(i,N){
    if (vec[i]%2==0){
      vec1.push_back(vec[i]);
    }
  }
  if (vec1.size() == 0){
    cout <<"APPROVED" << endl;
  }
  else{
    int count =0;
    rep(i,vec1.size()){
      if (vec1[i]%3==0 || vec1[i]%5==0){
        count ++;
      }
      else{
        break;
      }
    }
    if ( count == vec1.size()){
      cout <<"APPROVED" << endl;
    }
    else{
      cout << "DENIED" << endl;
    }
  }
}

Measured memory_bytes: 256
x, y = map(int, input().split())

if x == y:
	res = 0
elif x < y:
	if (0 <= x and 0 <= y) or (x <= 0 and y <= 0):
		res = y - x
	else:
		if abs(x) >= y:
			res = abs(x) - y + 1
		else:
			res = y - abs(x) + 1
else:
	if 0 < x and 0 < y:
		res = x - y + 2
	elif x < 0 and y < 0:
		res = abs(y) - abs(x) + 2
	else:
		if x >= abs(y):
			res = x - abs(y) + 1
		else:
			res = abs(y) - x + 1
		
print(res)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int n = sc.nextInt();

    int total = 0;
    for (int i = 0; i < n; i++) {
      int a = sc.nextInt();
      total += a;
    }

    if (h <= total) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  } 
}


Measured memory_bytes: 48888
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

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

   int max = *max_element(a.begin(),a.end());
   int min = *min_element(a.begin(),a.end());
   print(max - min);
}

Measured memory_bytes: 256
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int n;
	cin >> n;
	VI v(n),c(n);
	rep(i, n) cin >> v[i];
	rep(i, n)cin >> c[i];
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] > c[i]) {
			ans += (v[i] - c[i]);
		}
	}
	cout << ans << endl;
}

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

bool dp[88][88][13000];
int a[88][88];
int b[88][88];
int table[88][88];
int main() {
  int h,w;
  cin >> h >> w;
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      cin >> a[i][j];
    }
  }
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      cin >> b[i][j];
    }
  }
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      table[i][j] = abs(a[i][j] - b[i][j]);
    }
  }
  
  dp[0][1][0] = dp[1][0][0] = true;
  
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      for(int k = 0; k < 13000; k++) {
	if(dp[i-1][j][k] || dp[i][j-1][k]) {
	  dp[i][j][k+table[i][j]] = true;
	  dp[i][j][abs(k-table[i][j])] = true;
	}
      }
    }
  }

  for(int k = 0; k < 13000; k++) {
    if(dp[h][w][k]) {
      cout << k <<endl;
      return 0;
    }
  }
}
	  
	


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

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

    int d = K;
    int c = 1;

    while(1) {
        if(d > N) {
            break;
        } else {
            d *= K;
            c++;
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

int main(void){
	int N;
	cin >> N;
	int a[N];
	int ans2 = 0;
	int ans4 = 0;
	for(int i=0; i<N; i++){
		cin >> a[i];
		if(a[i]%4==0){
			ans4++;
		}else if(a[i]%2==0){
			ans2++;
		}
	}
	if((max(0, ans2-1)+(ans4*2))>=N-1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int a,b;
    cin>>a>>b;
    bool ok=true;
    if(b%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    if(a*2<=b && b<=a*4){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3600
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        for k in range(n):
            if a[i][j] == b[k]:
                a[i][j] = 0

ans = "No"
for i in range(3):
    if a[i][0] + a[i][1] + a[i][2] == 0:
        ans = "Yes"
    if a[0][i] + a[1][i] + a[2][i] == 0:
        ans = "Yes"
if a[0][0] + a[1][1] + a[2][2] == 0:
    ans = "Yes"
if a[0][2] + a[1][1] + a[2][0] == 0:
    ans = "Yes"
print(ans)

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

int main() {
    int n; cin >>n;
    vector<int> rate(8,0);
    int r, over3200 = 0;
    for (int i = 0; i < n; i++) {
        cin >> r;
        if(r>=3200) {over3200++;continue;}
        rate[(int)(r/400)]++;
    }
    int ret_min = 0;
    for (int i = 0; i < 8; i++) ret_min += (rate[i]>0) ? 1 : 0;
    if (ret_min==0) {ret_min = 1; over3200--;} // Ohh, I totally forgot.. All person are crazy in AtCoder, in this case.(in1.txt)

    int ret_max = ret_min + over3200; // ??? min(ret_min+over3200, 8); -> See https://atcoder.jp/contests/abc064/clarifications

    cout << ret_min << " " << ret_max << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
int main(int argc, char **argv)
{
	ll a, b, c; cin >> a >> b >> c;
	bool ok{false};
	if (a + b == c) ok = true;
	if (a + c == b) ok = true;
	if (a == (b + c)) ok = true;
	std::cout << (ok ? "Yes" : "No")<< std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

#define INF (1e9)

using namespace std;

int main(){
 int N, T;
 cin >> N >> T;
 vector<int> c(N), t(N);
 for(int i = 0; i < N; i++){
  cin >> c.at(i) >> t.at(i);
 }
 int cost = INF;
 if(t.at(0) <= T){
  cost = c.at(0);
 }
 for(int i = 1; i< N; i++){
  if(t.at(i) <= T){
    if(cost > c.at(i)){
      cost = c.at(i);
    }
  }
 }
 if(cost == INF){
  cout << "TLE" <<endl;
 }else{
  cout << cost << endl;
 }
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean approved = true;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if ((x & 1) == 0 && (x % 3 != 0 && x % 5 != 0)) 
				approved = false;
		}
		if (approved) System.out.println("APPROVED");
		else System.out.println("DENIED");
	}
}


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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;

	char buf[bufl],*s=buf,*t=buf;

	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}

	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const double eps = 1e-9;

inline int dcmp(double x){if(-eps<x && x<eps)return 0;return x>0?1:-1;}

struct points
{
	double x,y;
	points(double _x=0,double _y=0){x=_x,y=_y;}

	inline friend points operator + (points a,points b){return points(a.x+b.x,a.y+b.y);}
	inline friend points operator - (points a,points b){return points(a.x-b.x,a.y-b.y);}
	inline friend points operator * (points a,double b){return points(a.x*b,a.y*b);}
	inline friend points operator / (points a,double b){return points(a.x/b,a.y/b);}

	void takein(){x=ty(),y=ty();}
	void print(char ends='\n'){printf("%.12lf %.12lf",x,y),putchar(ends);}
};

inline double dox(points a,points b){return a.x*b.x+a.y*b.y;}
inline double cox(points a,points b){return a.x*b.y-a.y*b.x;}
inline double length(points a){return sqrt(dox(a,a));}

points p1,p2,pd;

void finder()
{
	points p;
	p.takein();

	double dis=dox(p-p1,pd-p1);
	points tar=p1+(pd-p1)*dis;
	points mir=p+(tar-p)*2;
	mir.print();
}

int main()
{
	p1.takein(),p2.takein();
	pd=p1+(p2-p1)/(length(p2-p1));
	
	int q=ty();
	while(q--)finder();

	return 0;
}



Measured memory_bytes: 3240
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<algorithm>
#include<vector>
using namespace std;
#define fr first
#define sc second
typedef pair<string,int> P;
struct edge{
  int to;
  string cost;
  edge(){}
  edge(int to,string cost):to(to),cost(cost){};
};
vector< vector<edge> > info;
int n,a,s,g;
string d[40][400];
string Dijkstra(){
  priority_queue< P,vector<P>,greater<P> > que;
  for(int i=0;i<n;i++) for(int j=0;j<400;j++) d[i][j] = "";
  que.push(P("",s));
  while(!que.empty()){
    P p = que.top();
    int now = p.sc;
    string nowstr = p.fr;
    que.pop();
    if( now == g ) return (nowstr.size() >= 300 ? "NO" : p.fr);
    if( nowstr.size() >= 400) continue;
    if( d[now][nowstr.size()] != "" && d[now][nowstr.size()] < nowstr ) continue;
    d[now][nowstr.size()] = nowstr;
    for(int i = 0 ; i < info[now].size() ; i++ ){
      edge e = info[now][i];
      string next_str = nowstr + e.cost;
      if( next_str.size() >= 400 ) continue;
      if( d[e.to][next_str.size()] == "" || next_str < d[e.to][next_str.size()] ){
        d[e.to][next_str.size()] = next_str;
        que.push(P(next_str , e.to ));
      }
    }
  }
  return "NO";
}
int main(){
  while(cin >> n >> a >> s >> g , n){
    info.resize(n);
    for(int i = 0 , x , y ; i < a ; i++ ){
      string s;
      cin >> x >> y >> s;
      info[x].push_back(edge(y,s));
    }
    cout << Dijkstra() << endl;
    info.clear();
  }
}

Measured memory_bytes: 15520
s = str(input())
if s[0]=='R' and s[1]=='R' and s[2]=='R':
    print(3)
elif (s[0]=='R' and s[1]=='R') or (s[1]=='R' and s[2]=='R'):
    print(2)
elif s[0]=='S' and s[1]=='S' and s[2]=='S':
    print(0)
else:
    print(1)

Measured memory_bytes: 9116