akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

template<class T> inline vector<pair<T, T> > primeFactorize(T n) {
    vector<pair<T, T> > res;
    for (T a = 2; a * a <= n; a++) {
        if (n % a != 0) continue ;
        T ex = 0;
        while (n % a == 0) {
            ++ex;
            n /= a;
        }
        res.push_back({a, ex});
    }
    if (n != 1) res.push_back({n, 1});
    return res;
}

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

    ll n;
    cin >> n;
    auto fs = primeFactorize(n);
    int ans = 0;
    for (auto p : fs) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            b++;
            ans++;
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3548
# coding: utf-8
# Your code here!
from collections import deque
h,w = map(int,input().split())
s = []
bcnt = 0
for i in range(h):
    ss = list(input())
    bcnt += ss.count("#")
    s.append(ss)
def next(x,y,h,w):
    global s
    ret = [(x-1,y),(x+1,y),(x,y-1),(x,y+1)]
    ans = []
    for i in ret:
        if i[0] >= 0 and i[0] < w and i[1] >= 0 and i[1] < h:
            if s[i[1]][i[0]] == ".":
                ans.append(i)
    return ans

queue = deque([(0,next(0,0,h,w))])
#print(queue)
visited = {(0,0):0}
while queue != deque([]):
    label = queue.popleft()
    #print(label)
    for i in label[1]:
        if not i in visited:
            visited[i] = label[0]+1
            queue.append((label[0]+1,next(i[0],i[1],h,w)))
if (w-1,h-1) in visited:
    print(h*w-bcnt-visited[(w-1,h-1)]-1)
else:
    print(-1)

Measured memory_bytes: 9724
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}






bool vis[25][25];
int dist[25][25];
int dx[4]={0,0,1,-1};
int dy[4]={-1,1,0,0};
int main()
{
     int h,w;
     cin>>h>>w;
     char name[h+1][w+1];
     for(int i=1;i<=h;i++){
          for(int j=1;j<=w;j++){
               cin>>name[i][j];
          }
     }
     int mx=0;
     for(int i=1;i<=h;i++)
     {
          for(int j=1;j<=w;j++){
               if(name[i][j]=='#')continue;
               queue<pi> q;
               q.push({i,j});
               memset(vis,0,sizeof(vis));memset(dist,0,sizeof(dist));
               dist[i][j]=0;
               vis[i][j]=1;
               while(!q.empty())
               {
                    int x=q.front().fi,y=q.front().se;q.pop();
                    for(int k=0;k<4;k++)
                    {
                         int nx=x+dx[k],ny=y+dy[k];
                         if(nx<1||nx>h||ny<1||ny>w||name[nx][ny]=='#')continue;
                         if(!vis[nx][ny]){
                              dist[nx][ny]=dist[x][y]+1;
                              mx=max(mx,dist[nx][ny]);
                              vis[nx][ny]=1;
                              q.push({nx,ny});
                         }
                    }

               }

          }
     }
     cout<<mx;
}











 














 
 

















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;cin>>n>>k;
    vector<int> A(n);
    rep(i, n) cin>>A[i];
    for(int i=k; i<n; i++){
        int hueru = A[i];
        int heru = A[i-k];
        if(heru<hueru){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3984
#include<cstdio>
#define ll long long
int main()
{
	ll n,m;
	scanf("%lld%lld",&n,&m);
	if(n==1||m==1)
		printf("1");
	else
		printf("%lld",m*(n/2)+((m-1)/2+1)*(n&1));
	return 0; 
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> ac(n,false);
  vector<int> wa(n,0);
  vector<int> question(m);
  vector<string> result(m);
  
  rep(i, m) {
    cin >> question[i] >> result[i];
  }
  
  rep(i, m) {
    int q = question[i]-1;
    if(!ac[q] && result[i] == "WA") ++wa[q];
    else if(!ac[q] && result[i] == "AC") ac[q] = true;
  }
  
  int pena = 0;
  int ans = 0;
  rep(i, n) {
    if(ac[i]) {
      ++ans;
      pena += wa[i];
    }
  }
  
  cout << ans << " " << pena << endl; 
    
  return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String output = "NO";

		Scanner scanner = new Scanner(System.in);

		int r = scanner.nextInt();
		int g = scanner.nextInt();
		int b = scanner.nextInt();


		if((r * 100 + g * 10 + b ) % 4  ==0 )
			output = "YES";

		System.out.println(output);
	}

}


Measured memory_bytes: 21716
N, M, X = (int(x) for x in input().split())
A = [int(x) for x in input().split()]
Z = [0] * N
for a in A:
    Z[a] = 1

lower = 0
higher = 0
for i in range(0, N):
    lower += Z[i] if i < X else 0
    higher += Z[i] if i > X else 0
print(min(lower, higher))

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


vector<vector<int>> edge, b_edge;

vector<vector<int>> scc, scc_e;
vector<int> belong;
vector<int> postorder;
vector<bool> visited;

void dfs_1(int now) {
    visited[now] = true;
    for (int nxt : edge[now]) {
        if (!visited[nxt]) {
            dfs_1(nxt);
        }
    }
    postorder.push_back(now);
    return;
}

void dfs_2(int now, int num) {
    visited[now] = true;
    scc[num].push_back(now);
    belong[now] = num;
    
    for (int nxt : b_edge[now]) {
        if (!visited[nxt]) {
            dfs_2(nxt, num);
        }
    }
    return;
}

int main() {
    int N, M;
    cin >> N >> M;
    edge.resize(N+1);
    b_edge.resize(N+1);
    visited.resize(N+1, false);
    belong.resize(N+1);
    
    for (int i = 0; i < N; i++) {
        edge[N].push_back(i);
        b_edge[i].push_back(N);
    }
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        edge[a].push_back(b);
        b_edge[b].push_back(a);
    }
    
    dfs_1(N);
    visited = vector<bool>(N+1, false);
    int num = 0;
    for (int i = N; i >= 0; i--) {
        if (visited[postorder[i]]) continue;
        scc.push_back({});
        dfs_2(postorder[i], num);
        num++;
    }
    
    scc_e.resize((int)scc.size());
    for (int i = 0; i <= N; i++) {
        for (int j : edge[i]) {
            if (belong[i] == belong[j]) continue;
            scc_e[belong[i]].push_back(belong[j]);
        }
    }
    for (int i = 0; i < (int)scc_e.size(); i++) {
        sort(scc_e[i].begin(), scc_e[i].end());
        scc_e[i].erase(unique(scc_e[i].begin(), scc_e[i].end()), scc_e[i].end());
    }
    
    
    int V = scc.size();
    cout << V-1 << "\n";
    for (int i = 1; i < V; i++) {
        cout << (int)scc[i].size();
        for (int v : scc[i]) cout << " " << v;
        cout << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 113064
#include<bits/stdc++.h>
using namespace std;
long long sol(vector<int>x,vector<int>y,vector<int>z,vector<int>p){
    long long a=0;
    for(int i=0;i<x.size();i++){
        if(x[i]>y[y.size()-1])break;
        for(int j=p[*upper_bound(y.begin(),y.end(),x[i])];j<y.size();j++){
            if(y[j]>z[z.size()-1])break;
            a+=z.size()-p[*upper_bound(z.begin(),z.end(),y[j])];
            if(binary_search(z.begin(),z.end(),2*y[j]-x[i]))a--;
        }
    }
    return a;
}
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int>r;
    vector<int>g;
    vector<int>b;
    vector<int>po(n);
    for(int i=0;i<n;i++){
        if(s[i]=='R'){
            r.push_back(i);
            po[i]=r.size()-1;
        }
        if(s[i]=='G'){
            g.push_back(i);
            po[i]=g.size()-1;
        }
        if(s[i]=='B'){
            b.push_back(i);
            po[i]=b.size()-1;
        }
    }
    if(r.size() && g.size() && b.size()){
        cout<<sol(r,g,b,po)+sol(r,b,g,po)+sol(g,r,b,po)+sol(g,b,r,po)+sol(b,r,g,po)+sol(b,g,r,po)<<endl;
    }
    else cout<<"0"<<endl;
    return 0;
}

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

void input(int *a);
 
int main(int argc, char *argv[]){
  int a, b, c;

  scanf("%d/%d/%d", &a, &b, &c);

  if((a > 2019) || (a == 2019 && b > 4) || (a == 2019 && b == 4 && c > 30)){
    printf("TBD\n");
  }
  else{
    printf("Heisei\n");
  }
 
  return 0;
}

/////////////////////////////////////////////////////////////////////////

void input(int *n){
  scanf("%d", n);
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  rep(i, 0, N) cin >> a[i];
  vector<ll> b;
  rep(i, 0, N) {
    ll tmp = 0;
    rep(j, i, N) {
      tmp += a[j];
      b.push_back(tmp);
    }
  }
  ll ans = 0;
  rem(i, 50, -1) {
    ll mask = (1LL << i) | ans;
    int cnt = 0;
    rep(j, 0, b.size()) if((b[j] & mask) == mask) cnt++;
    if(cnt >= K) ans |= mask;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6260
#include<stdio.h>

int num[10][5];
int H;

int puzzle(int i,int j,int k){
  int p;
  num[i][j]=0;
  if((j+1)<5&&(num[i][j+1]==k)) p=puzzle(i,j+1,k)+k;
  else p=k;
  return p;
}

int main(){
  int ans;
  int i,j,k;
  int flag=0;

  while(scanf("%d",&H),H!=0){
    ans=0;
    for(i=H-1;i>=0;i--){
      for(j=0;j<5;j++){
	scanf("%d",&num[i][j]);
      }
    }
    flag=1;
    while(flag==1){
      flag=0;
      for(i=0;i<H;i++){
	for(j=0;j<3;j++){
	  if(num[i][j]!=0&&((num[i][j]==num[i][j+1])&&(num[i][j+1]==num[i][j+2]))){
	    ans+=puzzle(i,j,num[i][j]);
	    flag=1;
	  }
	}
      }
      for(i=H-1;i>0;i--){
	for(j=0;j<5;j++){
	  if(num[i-1][j]==0){
	    for(k=i-1;k<H-1;k++){
	      num[k][j]=num[k+1][j];
	    }
	    num[H-1][j]=0;
	  }
	}
      }
    }
    printf("%d\n",ans);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, a, b) for(int i=(a); i<(int)(b); i++

typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct Node { int from, to, cost; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}

ll solve(ll num){
	ll count = (num+1) / 2;
	ll ans = count % 2;
	if(num % 2 == 0) ans ^= num;
	return ans;
}

int main(void){
	ll a, b; cin >> a >> b;
	cout << (solve(a-1) ^ solve(b)) << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N,M = list(map(int, input().split()))
dat=[]
for i in range(M):
  dat.append(list(map(int, input().split())))
p = list(map(int, input().split()))

A=np.zeros((M,N))
for i in range(M):
  for j in range(len(dat[i])-1):
    A[i,dat[i][j+1]-1]=1
#print(A)
res=0

v = np.zeros((N,1))
for i in range(2**N):
  for j in range(N):
    v[j,0] = int(i / (2**j)) % 2
  w=(np.dot(A,v) % 2)

  flg=True
  for j in range(len(p)):
    if p[j] != int(w[j]):flg=False
  if flg:
    res=res+1
print(res)


Measured memory_bytes: 21508
#include"bits/stdc++.h"
using namespace std;

int mod = 1'000'000'007;

int modpow(int x, int y){
    if (y==0) return 1;
    if (y%2==0) return (long long)modpow(x, y/2) * modpow(x, y/2) % mod;
    else return (long long)x * modpow(x, y-1) % mod;
}

int main(){
    string s;
    cin >> s;
    //mod
    //答えは非常に大きくなることがある
    long long ans = 0;
    char x;
    //cntは最大10^5
    int cnt = 0;
    vector<long long> dp_A(s.size()+1);
    vector<long long> dp_B(s.size()+1);
    for (int i = 0; i<=s.size(); i++){
        dp_A[i] = 0;
        dp_B[i] = 0;
    }
    for (int i = 1; i<=s.size(); i++){
        x = s[i-1];
        //dp_B[i]はi番目までのA,Bの組の総数
        if (x=='?') dp_B[i] += dp_B[i-1]*3;
        else dp_B[i] += dp_B[i-1];
        dp_B[i] %= mod;
        if (x=='?' || x=='B') dp_B[i] += dp_A[i-1];
        dp_B[i] %= mod;
        if (x=='?') dp_A[i] += dp_A[i-1]*3;
        else dp_A[i] += dp_A[i-1];
        dp_A[i] %= mod;
        if (x=='?' || x=='A') dp_A[i] += (long long)modpow(3,cnt);
        dp_A[i] %= mod;
        if (x=='?') cnt++;
        
    }
    int cnt2 = 0;
    for (int i = 1; i<=s.size(); i++){
        x = s[i-1];
        if (x=='?') cnt2++;
        if (x=='?' || x=='C'){
            ans += dp_B[i-1]*((long long)modpow(3, cnt - cnt2) % mod) % mod;
            ans %= mod;
        }
    }
    cout << ans << endl;
}





Measured memory_bytes: 2048
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int digit[10];
vector<int> v;
vector<ll> num;

void makeDigits(int dd, ll x){
  if(dd==0){
    num.push_back(x);
  }else{
    if(x==0) makeDigits(dd-1, x);
    rep(i,v.size()){
      makeDigits(dd-1, 10*x+v[i]);
    }
  }
}


int main(){
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  rep(i,10) digit[i] = 1;
  rep(i,K){
    int a;
    cin >> a;
    digit[a] = 0;
  }

  rep(i,10){
    if(digit[i]==1) v.push_back(i);
  }

  int n = N;
  int cnt = 0;
  while(n>0){ cnt++; n/=10; }
  cnt++;
  makeDigits(cnt, 0);

  ll ret = 1000000000;
  rep(i,num.size()){
    if(num[i]>=N) ret = min(ret, num[i]);
  }
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 1400
def main():
    n = int(input())
    x = list(map(int, input().split()))
    result = 0
    for x_i in x:
        result += (x_i - 1) ** 2
    for i in range(2, 100):
        tmp_result = 0
        for x_i in x:
            tmp_result += (x_i - i) ** 2
        result = min(result, tmp_result)
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof (a))
#define gcd(a,b) __gcd(a,b)
#define all(a) a.begin(),a.end()
#define in(a) insert(a)
#define sz() size()
#define endl '\n'
#define pb push_back
using namespace std;
typedef unsigned long long ll;
const int maxn=500010;
const ll inf=1e9;
const ll mod=998244353;
const double pi=3.14159265358979;
const double ep=0.0;
int n,a[maxn],tree[4*maxn][26],vis[26];
void build(int L,int R,int nd)
{
    if (L==R)
    {
        tree[nd][a[L]]++;
        return ;
    }
    int mid=(L+R)>>1;
    build (L,mid,nd<<1);
    build (mid+1,R,nd<<1|1);
    for (int i=0;i<26;i++)
        tree[nd][i]=tree[nd<<1][i]+tree[nd<<1|1][i];
}
void update(int L,int R,int nd,int id,int val)
{
    if (L==R)
    {
        tree[nd][a[id]]--;
        a[id]=val;
        tree[nd][a[id]]++;
        return;
    }
    int mid=(L+R)>>1;
    if (L<=id&&id<=mid)
        update(L,mid,nd<<1,id,val);
    else
        update(mid+1,R,nd<<1|1,id,val);
    for (int i=0;i<26;i++)
        tree[nd][i]=tree[nd<<1][i]+tree[nd<<1|1][i];
}
void query(int L,int R,int nd,int l,int r)
{
    if (L>R||R<l||L>r)
        return;
    if (L>=l&&R<=r)
    {
        for (int i=0;i<26;i++)
            vis[i]+=tree[nd][i];
        return ;
    }
    int mid=(L+R)>>1;
    query(L,mid,nd<<1,l,r);
    query(mid+1,R,nd<<1|1,l,r);
}
int main()
{
    string s;
    int q;
    cin>>n>>s>>q;
    for (int i=1;i<=n;i++)
        a[i]=s[i-1]-'a';
    build(1,n,1);
    while (q--)
    {
        int x;
        cin>>x;
        if (x==1)
        {
            int id;
            char c;
            cin>>id>>c;
            int val=c-'a';
            update(1,n,1,id,val);
        }
        else
        {
            int l,r;
            cin>>l>>r;
            mem(vis,0);
            query(1,n,1,l,r);
            int ans=0;
            for (int i=0;i<26;i++)
                if (vis[i]!=0)
                    ans++;
            cout<<ans<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 109432
#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)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  int ans=0;
  for(int i=1;i<=n;i++){
    int x=i;
    int cnt=0;
    while(x){
      x/=10;
      cnt++;
    }
    if(cnt%2==1)ans++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  int n;
  ll ans=1;
  cin>>n;
  repi(i,1,n+1){
    ans=(ans*i)%MOD;
  }
  cout<<ans<<endl;

  return 0;
}






Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for (int i = 0; i < N; i++) {
			L[i] = sc.nextInt();
		}
		sc.close();
		// 配列のソート
		Arrays.sort(L);

		int ans = 0;
		for (int i = 0; i < N - 2; i++) {
			for (int j = i + 1; j < N - 1; j++) {
				for (int k = j + 1; k < N; k++) {
					if (L[i] + L[j] > L[k]) {
						ans++;
					} else {
						break;
					}
				}
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26724
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		HashMap<String,String> map = new HashMap<String,String>();
		while(N!=0){
			for(int i=0;i<N;i++){
				String[] st = br.readLine().split(" ");
				map.put(st[0],st[1]);
			}
			
			N = Integer.parseInt(br.readLine());
			for(int i=0;i<N;i++){
				String st = br.readLine();
				if(map.containsKey(st)){
					System.out.print(map.get(st));
				}else{
					System.out.print(st);
				}
			}
			System.out.println("");
			N = Integer.parseInt(br.readLine());
			map = new HashMap<String,String>();
		}
	}
}

Measured memory_bytes: 43588
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m;
    cin>>n>>m;
    int a[100010];
    string s[100010];
    for(int i=0;i<m;i++){
        cin>>a[i]>>s[i];
    }
    int ans1=0,ans2=0,W[100010]={};
    bool AC[100010]={};
    for(int i=0;i<m;i++){
        if(AC[a[i]]){
            continue;
        }
        if(s[i]=="AC"){
            AC[a[i]]=true;
            ans1++;
            ans2+=W[a[i]];
            W[a[i]]=0;
        }
        else{
            W[a[i]]++;
        }
    }
    cout<<ans1<<" "<<ans2;
}


Measured memory_bytes: 6656
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int n, m;
map<int, int> mp;
int main()
{
	cin >> n >> m;
	int k, tmp;
	for (int i = 1; i <= n; i++)
	{
		cin >> k;
		for (int j = 1; j <= k; j++)
		{
			cin >> tmp;
			mp[tmp]++;
		}
	}
	int ans = 0;
	for (auto i : mp)
	{
		if (i.second == n)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

diff = []
cnt = 0
diff_sum = 0
n.times do |i|
  d = a[i]-b[i]
  diff[i] = d
  if d < 0
    cnt += 1
    diff_sum -= d
  end
end

if cnt == 0
  puts cnt
else
  ans = cnt
  diff.sort!.reverse!
  i = 0
  while diff_sum > 0
    if diff[i] < 0
      puts -1
      exit
    end
    diff_sum -= diff[i]
    ans += 1
    i += 1
  end
  puts ans
end

Measured memory_bytes: 17068
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

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

struct dice {
	int top;
	int bottom;
	int front;
	int back;
	int left;
	int right;
};

void rotate_front(dice* d) {
	int tmp = d->top;
	d->top = d->back;
	d->back = d->bottom;
	d->bottom = d->front;
	d->front = tmp;
}

void rotate_back(dice* d) {
	int tmp = d->top;
	d->top = d->front;
	d->front = d-> bottom;
	d->bottom = d-> back;
	d->back = tmp;
}

void rotate_right(dice* d) {
	int tmp = d->top;
	d->top = d->left;
	d->left = d->bottom;
	d->bottom = d->right;
	d->right = tmp;
}

void rotate_left(dice* d) {
	int tmp = d->top;
	d->top = d->right;
	d->right = d->bottom;
	d->bottom = d->left;
	d->left = tmp;
}

// t=top, f=front
void decide_all_aspects(dice* d, int t, int f) {
	d->top = t;
	d->front = f;
	d->bottom = 7 - t;
	d->back = 7 - f;
	if (t == 1) {
		if (f == 2)d->right = 3;
		if (f == 3)d->right = 5;
		if (f == 5)d->right = 4;
		if (f == 4)d->right = 2;
	}
	if (t == 2) {
		if (f == 1)d->right = 4;
		if (f == 4)d->right = 6;
		if (f == 6)d->right = 3;
		if (f == 3)d->right = 1;
	}
	if (t == 3) {
		if (f == 1)d->right = 2;
		if (f == 2)d->right = 6;
		if (f == 6)d->right = 5;
		if (f == 5)d->right = 1;
	}
	if (t == 4) {
		if (f == 1)d->right = 5;
		if (f == 5)d->right = 6;
		if (f == 6)d->right = 2;
		if (f == 2)d->right = 1;
	}
	if (t == 5) {
		if (f == 1)d->right = 3;
		if (f == 3)d->right = 6;
		if (f == 6)d->right = 4;
		if (f == 4)d->right = 1;
	}
	if (t == 6) {
		if (f == 2)d->right = 4;
		if (f == 4)d->right = 5;
		if (f == 5)d->right = 3;
		if (f == 3)d->right = 2;
	}
	d->left = 7 - d->right;
}

int n;
int t[101],f[101];
int fie[101][101][51];
int siz[101][101];

void roll(dice* d){
	int z=siz[50][50];
	int nx=50,ny=50;
	while(1){
		int move=-1,mob=-1;
		for(int i=0;i<4;i++){
			int nnx=nx+dx[i],nny=ny+dy[i];
			if(i==0 && z>siz[nny][nnx] && d->right>3){
				if(mob<d->right){
					move=0;
					mob=d->right;
				}
			}
			if(i==1 && z>siz[nny][nnx] && d->back>3){
				if(mob<d->back){
					move=1;
					mob=d->back;
				}
			}
			if(i==2 && z>siz[nny][nnx] && d->left>3){
				if(mob<d->left){
					move=2;
					mob=d->left;
				}
			}
			if(i==3 && z>siz[nny][nnx] && d->front>3){
				if(mob<d->front){
					move=3;
					mob=d->front;
				}
			}
		}
		if(move==-1){
			z=siz[ny][nx];
			fie[ny][nx][z]=d->top;
			siz[ny][nx]++;
			break;
		}
		if(move>=0){
			nx+=dx[move];
			ny+=dy[move];
			z=siz[ny][nx];
			if(move==0)rotate_right(d);
			if(move==1)rotate_back(d);
			if(move==2)rotate_left(d);
			if(move==3)rotate_front(d);
		}
	}
}

int res[7];

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(fie,0,sizeof(fie));
		memset(siz,0,sizeof(siz));
		for(int i=0;i<n;i++){
			scanf("%d%d",&t[i],&f[i]);
			dice d;
			decide_all_aspects(&d,t[i],f[i]);
			roll(&d);
		}
		memset(res,0,sizeof(res));
		for(int i=0;i<=100;i++){
			for(int j=0;j<=100;j++){
				if(siz[i][j]>0)res[fie[i][j][siz[i][j]-1]]++;
			}
		}
		for(int i=1;i<=6;i++){
			printf("%d%c",res[i],i==6?'\n':' ');
		}
	}
	return 0;
}

Measured memory_bytes: 5248
def main():
    t = list(map(int, input().split()))
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    circle = a[0] * t[0] + a[1] * t[1] - b[0] * t[0] - b[1] * t[1]
    if circle == 0:
        print('infinity')
        return
    d = [0, 0]
    cd = 0
    ans = -1
    for i in range(2):
        d[i] = cd + a[i] * t[i] - b[i] * t[i]
        if cd * d[i] <= 0:
            ans += 1
        cd = d[i]
    if ans == 0:
        print(0)
        return
    if circle < 0:
        if d[0] > 0:
            ans += d[0] // -circle * 2
            if d[0] % (-circle) == 0:
                ans -= 1
        elif d[1] > 0:
            ans += d[1] // -circle * 2
            if d[1] % (-circle) == 0:
                ans -= 1
    else:
        if d[0] < 0:
            ans += -d[0] // circle * 2
            if -d[0] % (circle) == 0:
                ans -= 1
        elif d[1] < 0:
            ans += -d[1] // circle * 2
            if -d[1] % (circle) == 0:
                ans -= 1
    print(ans)
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;

int main(){
  string S;
  ll K;
  cin >> S >> K;
  FOR(i,0,S.size()){
    if(i == K-1){
      cout << S[i] << endl;
      return 0;
    }
    if(S[i] != '1'){
      cout << S[i] << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
int a[101010];

int main() {
	cin >> n >> k;
	REP(i, n)cin >> a[i];
	if (n <= k) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 1;
	n -= k;
	ans += n / (k-1);
	if (n % (k - 1) != 0)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)
int ans[500],anss[500];

signed main(){
  int h,w;
  cin>>h>>w;
  int now=1;
  int mode=0;
  int s;
  lp(i,(h+1)/2){
    s=i+1;
    now=0;
    mode=0;
    lp(j,h){
      if(now<s&&mode==0) now++;
      if(mode==1) now--;
      ans[j]+=now;
      if(h-s==j) mode=1;
    }
  }
  if(h%2==0){
    s++;
  }
  while(1){
    s--;
    if(s==0) break;
    now=0;
    mode=0;
    lp(j,h){
      if(now<s&&mode==0) now++;
      if(mode==1) now--;
      ans[j]+=now;
      if(h-s==j) mode=1;
    }
  }
  lp(i,(w+1)/2){
    s=i+1;
    now=0;
    mode=0;
    lp(j,w){
      if(now<s&&mode==0) now++;
      if(mode==1) now--;
      anss[j]+=now;
      if(w-s==j) mode=1;
    }
  }
  if(w%2==0){
    s++;
  }
  while(1){
    s--;
    if(s==0) break;
    now=0;
    mode=0;
    lp(j,w){
      if(now<s&&mode==0) now++;
      if(mode==1) now--;
      anss[j]+=now;
      if(w-s==j) mode=1;
    }
  }
  /*lp(i,h){
    cout<<ans[i];
  }
  cout<<endl;
  lp(j,w)cout<<anss[j];
  cout<<endl;*/
  int cn=0;
  lp(i,h){
    lp(j,w){
      int n;
      cin>>n;
      cn+=n*(ans[i]*anss[j]);
    }
  }
  cout<<cn<<endl;
  return 0;
}




Measured memory_bytes: 3112
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 500 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}

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

    int n;
    cin >> n;
    vector < int > a(n+1),v;

    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i != a[i]) v.push_back(i);
    }
    if(v.size() > 2){
        cout << "NO\n";
    }
    else {
        assert(v.size() == 2 or v.size() == 0);
        if(!v.empty())
            swap(a[v[0]],a[v[1]]);
        vector < int > tmp(a);

        for(int i = 1; i <= n; i++){
            if(tmp[i] != a[i]){
                return cout << "NO\n",0;
            }
        }
        cout << "YES\n";
    }
    return 0;

}


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

void func_b(int N, int D) {
	double range = 2 * D + 1;
	cout << (int)ceil(N / range);
}

int main()
{
	int N,D;
	cin >> N>>D;
	func_b(N,D);
}


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

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

	int res = 0;
	while (true)
	{
		if(*max_element(h, h + n) == 0) break;
		int i = 0;
		while (i < n)
		{
			if(h[i] == 0) i++;
			else {
				res++;
				while (i < n && h[i] != 0)
				{
					h[i]--;
					i++;
				}

			}
		}

	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
ll  solve(ll x){
    if(x==1){
        return 1;
    }
    ll ret = 1+2LL*solve(x/2);
    return  ret;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h;
    cin >> h;
    ll ans = solve(h);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a = gets.chomp!.to_i
b = gets.chomp!.to_i
c = gets.chomp!.to_i
d = gets.chomp!.to_i
e = gets.chomp!.to_i
k = gets.chomp!.to_i

comb = [a,b,c,d,e].combination(2)

if comb.all? {|x, y| y - a <= k }
  puts "Yay!"
else
  puts ":("
end

Measured memory_bytes: 1788
s = int(input())
lis = set()
lis.add(s)
jud = True
cnt = 1
while jud:
    if s%2:
        s = 3*s+1
    else:
        s = s//2
    if s in lis:
        jud = False
    lis.add(s)
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		int i = s.nextInt();
		int j = s.nextInt();
		System.out.print(i * j);
		System.out.print(" ");
		System.out.println(i * 2 + j *2);
	}
}

Measured memory_bytes: 26024
import java.util.*;


public class Main {
	public static void main (String[] args){
		Scanner sc =  new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int s[] = new int[M];
		int c[] = new int[M];
		for(int i =0; i < M; i++) {
			s[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}
		int R = 0;
		int R_1 = 0;
		int R_2 = 0;
		int R_3 = 0;
		for(int i = 0; i < M; i++) {
			if(N != 1 && s[i] == 1 && c[i] == 0) {
				R = -1;
				break;
			}
			if(R_1 != 0 && s[i] == 1 && R_1 !=c[i]) {
				R = -1;
				break;
			}
			if(R_2 != 0 && s[i] == 2 && R_2 !=c[i]) {
				R = -1;
				break;
			}
			if(R_3 != 0 && s[i] == 3 && R_3 !=c[i]) {
				R = -1;
				break;
			}
			if(s[i] == 1) {
				R_1 = c[i];
			}
			if(s[i] == 2) {
				R_2 = c[i];
			}
			if(s[i] == 3) {
			R_3 = c[i];	
			}
		}
		if(R != -1) {
			if(N == 3 && R_1 == 0) {
				R = 100 + R_2 * 10 + R_3;
			}
			else if(N == 3) {
				R = R_1 * 100 + R_2 * 10 + R_3;
			}
			else if(N == 2 && R_1 == 0) {
				R = 10 + R_2;
			}
			else if(N == 2) {
				R = R_1 * 10 + R_2;
			}
			if(N == 1) {
					R = R_1;
			}
		}
		System.out.println(R);
	}
}

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

int main() {

	int n, k,ans=0;
	cin >> n >> k;
	
	
	while (1) {
		n = n / k;
		ans++;
		if (n == 0)break;
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,m,n) for(int i = m; i <= n; i++)
#define fod(i,m,n) for(int i = m; i >= n; i--)
using namespace std;
typedef int64_t i64;
i64 n;
typedef pair<int,int> _ii;
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
    cin >> n;
    i64 i=0;
    while(i<n) i+=1000;
    cout << i-n;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;

int main(){
	vector<float> v;
	float input;
	float ans;
	while(cin >> input){
		v.push_back(input);
		sort(v.begin(), v.end());
		vector<float>::iterator ite;
		ite = v.end();
		ans = *(ite-1) - v.at(0);
		
	}
	printf("%.1f\n", ans);
	return 0;
}

Measured memory_bytes: 1256
#include <stdio.h>
#include <stdlib.h>

typedef struct ll{
  int *data;
  int num;
  struct ll *next;
} DL;

DL *createList(int *data, int n){
  DL *new;
  new = (DL *)malloc(sizeof(DL));
  int i;
  new->data = (int *)malloc(sizeof(int) * n);
  for(i=0; i<n; i++){
    new->data[i] = data[i];
  }
  new->num = n;

  return new;
}

void addList(DL **head, DL *add){
  add->next = *head;
  *head = add;
  return;
}

void deleteList(DL **pt){
  DL *del = *pt;
  *pt = del->next;

  free(del->data);
  free(del);
  return;
}

void printList(DL *head){
  int i, n, *data;
  puts("LIST---------------");
  while(head != NULL){
    n = head->num;
    data = head->data;
    for(i=0; i<n; i++) printf("%d ", data[i]);
    putchar('\n');
    head = head->next;
  }
  puts("---------------LIST");
  return;
}

int main()
{
  int M, N;
  int i, j, n, index, flg, find;
  int *ss;
  int data[100000]={0};
  int node[100000];

  DL *head=NULL;
  DL **search = NULL;
  scanf("%d%d", &N, &M);

  // 最初の人が喋れる言語のフラグを立てる。
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &index);
    data[index]++;
  }

  // 2番目以降の人の喋れる言語の入力
  // 同時に、すでにフラグの立ってる言語を喋れる場合、その人の喋れるすべての言語にフラグを立てる。
  // フラグが立ってない言語のみの場合はリストに保存する。
  for(i=1; i<N; i++){
    scanf("%d", &n);
    find=0;
    for(j=0; j<n; j++){
      scanf("%d", node+j);
      if(data[node[j]]) find++;
    }
    if(find){
      for(j=0; j<n; j++){
        data[node[j]]=1;
      }
    }else{
      DL *add = createList(node, n);
      addList(&head, add);
    }
  }

  // リストの探索で、喋れる言語がなくなるまでループする。
  // 新たに喋れる言語が見つからないとき(flg==0)か、リストのデータがなくなった時(head==NULL)にこのループを終了する。
  flg = 1;
  while(flg && head != NULL){
    search = &head;
    flg = 0;
    while(*search != NULL){
      n = (*search)->num;
      ss = (*search)->data;
      find=0;
      for(i=0; i<n; i++){
        if(data[ss[i]]) find++;
      }
      if(find){
        for(i=0; i<n; i++){
          data[ss[i]]=1;
        }
        deleteList(search);
        flg++;
      }else search = &(*search)->next;
    }
  }
  printf("%s\n", head==NULL?"YES":"NO");
  return(0);
}


Measured memory_bytes: 6144
while True:
  m,f,r = map(int, input().split())
  if m==-1 and f==-1 and r==-1:
    break
 
  if m==-1 or f==-1:
    print('F')
  elif m+f>=80:
    print('A')
  elif 65<=m+f:
    print('B')
  elif 50<=m+f:
    print('C')  
  elif 30<=m+f:
    if r>=50:
      print('C')
    else:
      print('D')
  else:
    print('F')


Measured memory_bytes: 5596
a, b, c = gets.chomp.split(" ").map(&:to_i)
a2 = 0
b2 = 0

if a >= c
  a2 = a - c
  print a2
  print " "
  puts b
elsif a < c
  if b <= c - a
  print a2
  print " "
  puts b2
  else
  b2 = b - (c - a)
  print a2
  print " "
  puts b2
  end
end



Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<utility>
using namespace std;
int main()
{
  long long int n=0,m=0;
  long long int i=0,j=0,l=0;

  while(scanf("%d %d",&n,&m) != EOF)
    {
      i = n;
      j = m;

      //koyaku
      if((n >= m) != true)swap(n,m);
      while(1)
	{
	  int amari = n % m;
	  n = m;
	  m = amari;
	  if(amari == 0) break;
	}
      
      //kobai
      l = i*j/n;
      
      cout << n << " " << l << endl;
    }
}

Measured memory_bytes: 1208
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
S = 0
cnt = 0
for i in range(N):
    if a[i] < b[i]:
        S += (b[i] - a[i])
        cnt += 1
if S == 0:
    print(0)
    exit()
T = 0
sumlst = []
for i in range(N):
    if a[i] >= b[i]:
        sumlst.append(a[i] - b[i])

sumlst.sort(reverse=True)
for i in sumlst:
    T += i
    cnt += 1
    if T >= S:
        break
if S > T:
    print(-1)
    exit()
print(cnt)

Measured memory_bytes: 19068
n,m=gets.split.map(&:to_i)
a=gets.split.map(&:to_i).sort
bc=m.times.map{gets.split.map(&:to_i)}.sort_by{|b,c|-c}
idx=0
# a.sort!
# bc.sort_by!{|b, c| -c }
idx = 0
bc.each{|b, c|
  while idx <  n && a[idx] < c && b > 0
    a[idx] = c
    idx += 1
    b -= 1
  end
}
puts a.inject:+


Measured memory_bytes: 21024
#include <bits/stdc++.h>
#include <atcoder/segtree>

using namespace std;

const int MOD = 1000000007;
const int INF = 1e9;

int n,k;
const int MAX = 3*1e5;
int a[MAX + 1];
int ans = 0;
int max_a = 3 * 1e5;
vector<int> memo(MAX+1, 0);
map<pair<int, int>, int> m;

int op(int a, int b){
  return max(a, b);
}
int e(){
  return 0;
}

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

  atcoder::segtree<int, op, e> dp(MAX+k + 1);

  for(int i = 0; i < n; i++){
    int l = max(0, a[i]-k);
    int r = min(max_a + k, a[i]+k);
    dp.set(a[i], dp.prod(l, r+1) + 1);
  }

  for(int i = 0; i < n; i++){
    ans = max(ans, dp.get(a[i]));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll n, ans=1, big=1e18;

int main() {
	cin>>n;
	ll a[n];
	for (int i=0; i<n; i++) {
		cin>>a[i];
  	}
  	sort(a, a+n);
  	if (a[0]==0) ans=0;
  	else {
  		for (int i=0; i<n; i++) {
  			if (a[i]<=big/ans) ans*=a[i];
  			else {
  				ans=-1;
  				break;
			}
		}
	}
  	cout<<ans<<endl;
}


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

int main(){
   std::string N;
   std::cin >> N;
   int keta = N.size();
   int M = N.at(0) -'0';
   int L = N.at(N.size()-1) -'0';
   //std::cerr << M << std::endl;
   if (keta == 1){
      std::cout << M << std::endl;
   } else if (L == 9){
      std::cout << (keta-1)*9+M << std::endl;
   } else{
      std::cout << (keta-1)*9+(M-1) << std::endl;
   }

}



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

int main() {
    int N;
    cin >> N;
    string ans = "";
    while (N != 0) {
        if (N % 2 != 0) {
            N--;
            ans = "1" + ans;
            
        } else ans = "0" + ans;
        N /= -2;
    }
    
    if (ans == "") ans = "0";
    
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int N;
  cin >> N;
  if (N < 100)
  {
    cout << min(N, 9) << endl;
  }
  else if (N < 10000)
  {
    cout << min(999, N) - 99 + 9 << endl;
  }
  else
  {
    cout << min(99999, N) - 9999 + 909 << endl;
  }
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll t1, t2;
  ll a1, a2;
  ll b1, b2;
  cin >> t1 >> t2;
  cin >> a1 >> a2;
  cin >> b1 >> b2;

  a1 = t1 * a1;
  b1 = t1 * b1;
  a2 = t2 * a2;
  b2 = t2 * b2;
  if (a1 + a2 == b1 + b2) {
    cout << "infinity" << endl;
    return 0;
  }
  if (a1 <= b1) {
    ll tmp = a1;
    a1 = b1;
    b1 = tmp;
    tmp = a2;
    a2 = b2;
    b2 = tmp;
  }
  ll k = 1LL;

  ll d = b1 + b2 - a1 - a2;
  if (d < 0) {
    cout << 0 << endl;
    return 0;
  }

  k = floor((double)(a1 - b1) / d);
  k *= 2;
  if ((b1 - a1) % d != 0) {
    k++;
  }

  cout << k << endl;
}


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

int main() {
        int n;
        scanf("%d", &n);
        int odd = 0;
        for (int i = 0; i < n; i ++) {
                int a;
                scanf("%d", &a);
                odd += a & 1;
        }
        if (odd & 1) return !puts("NO");
        else return !puts("YES");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

const int MAXN = 200200;
const int MAXE = 400400;
const int INF = 0x3f3f3f3f;

template<typename T> inline void CheckMax(T &A, T B) {
	A < B ? A = B : A;
}

template<typename T> inline void CheckMin(T &A, T B) {
	A > B ? A = B : A;
}

template <typename T> inline void read(T &x) {
    int c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

int n, m;
int P[MAXN], cnt;

int solve() {
	int ans = 0;
	for(int i = 1; i * i <= m; i++) {
		if(m % i == 0) {
			if(m / i >= n) CheckMax(ans, i);
			if(m / (m / i) >= n) CheckMax(ans, m / i);
		}
	}
	return ans;
}

signed main() {
	read(n), read(m);
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int D;
	int T;
	int S;
	cin >> D >> T >> S;
	
	double result = (double)D / S;
	
	if(T>=result){
		cout << "Yes" << endl;
			return 0;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3636
N = int(input())

Not_Fizzbuzz = []

for i in range(1,N+1):
    if i % 15 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        Not_Fizzbuzz.append(i)


print(sum(Not_Fizzbuzz))

Measured memory_bytes: 30088
#include<stdio.h>
#include<string.h>
int main()
{
	char a[4001],b[4001];
	while(scanf("%s%s",a,b)>0)
	{
		static int x[2][4001],i,j,s,t,r,c;
		s=strlen(a),t=strlen(b);
		for(r=j=0;j<=t;++j)x[0][j]=0;
		for(c=i=0;i<s;++i,c=!c)for(j=0;j<t;++j)r=(r>(x[!c][j+1]=(a[i]==b[j]?x[c][j]+1:0))?r:x[!c][j+1]);
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 796