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

int n, k;
string a[11];
set<string> all;
bool flag[11];

void solve(int num, string s) {
  if( num == k ) {
    all.insert(s);
    return;
  }
  for(int i=0; i<n; i++) {
    if( flag[i] ) continue;
    flag[i] = true;
    solve(num + 1, s + a[i]);
    flag[i] = false;
  }
}

int main() {
  while( cin >> n >> k, n + k ) {
    all.clear();
    for(int i=0; i<n; i++) {
      cin >> a[i];
    }
    for(int i=0; i<11; i++) flag[i] = false;
    solve(0, "");
    cout << all.size() << endl;
  }
}

Measured memory_bytes: 1460
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring> 
#include<queue>
#include<stack> 
#include<string.h>
#include<set>
#define ll long long
using namespace std;
int ct[100]={0,1,2,1,3,1,3,1,1,3,1,3,1};
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	
	if(ct[n]==ct[m])
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

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


	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string [] values = Console.ReadLine().Split(' ');
			int[] nums=new int[n];
			for (int i = 0; i <n; i++)
			{
				nums[i] = int.Parse(values[i]);
			}

			int count = 0;
			for (int i = 2; i <n; i++)
			{
				if (nums[i - 1] < nums[i - 2] && nums[i - 1] > nums[i]) {
					count++;
				}
				if (nums[i - 1] > nums[i - 2] && nums[i - 1] < nums[i])
				{
					count++;
				}
			}
			Console.WriteLine(count.ToString());

		
	}
}

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

#define REP(i,n) for (int i=0;i<(n);i++);
#define PII pair<int,int>
#define LL long long

int main(){
  string s;
  cin >> s;
  for(int i=0; i<19;i++){
    if(s.at(i)==','){
      s.at(i)=' ';
    }
  }
  cout<< s;
  

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define scn(n) scanf("%d",&n)
using namespace std;
 
int main() {
	
	int n,m;
	ll k;
	cin>>n>>m>>k;
	
	ll arr1[n+2]={0};
	ll arr2[m+2]={0};
	
	for(int i=1;i<=n;i++)
	{
	    cin>>arr1[i];
	    arr1[i]+=arr1[i-1];
	}
	
	for(int i=1;i<=m;i++)
	{
	    cin>>arr2[i];
	    arr2[i]+=arr2[i-1];
	}
	
	int j=m,ans=0;
	
	for(int i=0;i<=n;i++)
	{
	    if(arr1[i]>k)
	    break;
	    while(arr2[j]>(k-arr1[i]))
	    j--;
	    
	    ans=max(ans,(i+j));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 6716
import java.util.Scanner;

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

        int x = sc.nextInt();
        int t = sc.nextInt();
        if (x >= t)
            System.out.println(x - t);
        else
            System.out.println(0);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    int len = t.size();
    for (int i = 0; i < s.size() - len + 1; ++i) {
        int cnt = 0;
        string ss = s.substr(i, len);
        for (int j = 0; j < len; ++j) {
            if (ss[j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

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



int main() {
int n;
cin>>n;
  vector<vector<int>>dp(10,vector<int>(10,0));
 
 for(int i=1;i<=n;i++)
 {   int tail=i%10;
     int temp=i;
     while(temp>9)
     {
         temp/=10;
     }
     int head=temp;
     dp[head][tail]++;
 }
 int ans=0;
 for(int i=0;i<=9;i++)
 {
     for(int j=0;j<=9;j++)
     {
         ans+=dp[i][j]*dp[j][i];
     }
 }
 cout<<ans;
	return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> res;
	vector<bool> prime(55555 + 1, true);
	prime[0] = prime[1] = false;
	int next = 2;
	for (int i = next; i * i < 55555 + 1; i++) {
		int flg = 0;
		rep (j, next + 1, 55555 + 1) {
			if (j % i == 0) {
				prime[j] = false;
			} else if (j % 5 != 1) {
				prime[j] = false;
			} else {
				if (!flg) {
					flg = 1;
					next = j;
				}
			}
		}
	}

	int count = 0;
	for (int i = 11; i < 55555 + 1; i += 5) {
		if (prime[i]) {
			cout << i << " ";
			count++;
 		}

		if (count >= n)
			break;
	}
	cout << "\n";

	return 0;
}


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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair


ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

ll c[1001][1001];//
ll fact[1001];
ll _f[1001][1001];

void _prepare(int N) {
    c[0][0] = 1;
    c[1][0] = c[1][1] = 1;
    for (int n=2; n<=N; ++n) {
        c[n][0] = c[n][n] = 1;
        for (int j=1; j<n; ++j) {
            c[n][j] = ADD(c[n-1][j-1], c[n-1][j]);
        }
    }

    fact[0] = fact[1] = 1;
    for (int i=2; i<=1000; ++i) fact[i] = MUL(fact[i-1], i);

    rep(i,1001) rep(j,1001) _f[i][j] = -1;
}

//

int N,A,B,C,D;

void solve(){
    vector<ll> x(N+1, 0);
    x[0] = 1LL;
    for (int u=A; u<=B; ++u) {
        vector<ll> x2 = x;
        for (int b=0; b<N; ++b) { // base
            ll cx = 1;
            for (int k=1; k<=D; ++k) {
                if (b+u*k > N) break;
                cx = DIV(MUL(cx, c[b+u*k][u]), k);
                if (k < C) continue;
                x2[b+u*k] = ADD(x2[b+u*k], MUL(x[b], cx));
            }
        }
        x = x2;
#ifdef DEBUG
        cerr << x << endl;
#endif
    }
    cout << x[N] << endl;
}

int main() {
    _prepare(1000);

    cin >> N>>A>>B>>C>>D;
    solve();
    return 0;
}


Measured memory_bytes: 15872
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <queue>
#define SIZE 100005
#define INF 1000000000000005LL

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

struct edge
{
	int to,cost;
	edge(int to=0,int cost=0):to(to),cost(cost){}
};
vector <edge> vec[SIZE];
vector <P> query[SIZE];
ll mn[SIZE];
ll dist[SIZE];
bool use[SIZE];
int dp[SIZE];

int main()
{
	int r,c;
	scanf("%d %d",&r,&c);
	int n;
	scanf("%d",&n);
	for(int i=0;i<c;i++) mn[i]=INF;
	for(int i=0;i<n;i++)
	{
		int x,y,a;
		scanf("%d %d %d",&x,&y,&a);
		x--,y--;
		query[x].push_back(P(y,a));
		mn[y]=min(mn[y],(ll) a);
	}
	for(int i=0;i<r;i++)
	{
		for(int j=0;j+1<query[i].size();j++)
		{
			P p=query[i][j],q=query[i][j+1];
			vec[p.first].push_back(edge(q.first,q.second-p.second));
			vec[q.first].push_back(edge(p.first,p.second-q.second));
		}
	}
	for(int i=0;i<c;i++) dist[i]=INF;
	for(int i=0;i<c;i++)
	{
		if(!use[i])
		{
			dist[i]=0;
			queue <int> que;
			que.push(i);
			ll all=0,all2=mn[i];
			while(!que.empty())
			{
				int v=que.front();que.pop();
				use[v]=true;
				all=min(all,dist[v]);
				all2=min(all2,mn[v]-dist[v]);
				for(int j=0;j<vec[v].size();j++)
				{
					edge e=vec[v][j];
					if(dist[e.to]==INF)
					{
						dist[e.to]=dist[v]+e.cost;
						que.push(e.to);
					}
					else if(dist[e.to]!=dist[v]+e.cost)
					{
						puts("No");
						return 0;
					}
				}
			}
			//Xj=Xi+dist[j]
			//Xj=Xk+dist[j]-dist[k]
			//-> (Xk-dist[k])+all で 0未 があればやばい
			if(all2+all<0)
			{
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <math.h>
using namespace std;

int main(){

    int r;
    cin >> r;
    //double S=PI*r*r/2;
    //1=PI:1*1\2  S=npi/2 n=r*rf
    cout << r*r;
    return 0;
    }


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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; }}

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, r, s, p; cin >> n >> k >> r >> s >> p;
    int ans = 0;
    string t; cin >> t;

    map<char, int> mp;
    mp['r'] = p;
    mp['s'] = r;
    mp['p'] = s;

    v< pair<int, char> > score;
    score.push_back(make_pair(p, 'r'));
    score.push_back(make_pair(r, 's'));
    score.push_back(make_pair(s, 'p'));
    sort(score.begin(), score.end());

    rep(i,n) {
        ans += mp[t[i]];
    }

    rep(i, 3) {
        int d = score[i].first;
        char c = score[i].second;

        rep(j, n-k) {
            if (t[j] == t[j+k]) {
                if (t[j] == c) {
                    ans -= d;
                    t[j+k] = ' ';
                }
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
#define PI 3.14159265358979323846
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define mini(x,y) (y + ((x - y) & ((x - y) >>(sizeof(int) * CHAR_BIT - 1))))
#define maxi(x,y) (x - ((x - y) & ((x - y) >> (sizeof(int) * CHAR_BIT - 1))))
#define fr(j,a,b) for(j=a;j<b;j++)

int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli i,j,n,x;
    x=0;
    string s,t;
        cin>>s>>t;
        n=s.length();
        for(i=0;i<n;i++){
            if(s[i]!=t[i]){
                x++;
            }
        }
    cout<<x;
    
}



Measured memory_bytes: 3784
import java.util.Scanner;

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

Scanner sc = new Scanner(System.in);

int k = sc.nextInt();
int x = sc.nextInt();
    
for(int i = x-k+1; i < x+k; i++){
  System.out.print(i);
  if(i<x+k-1){
    System.out.print(" ");
  }
}
}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  string T;
  for(int i = 0; i < N; i++) {
    if(i % 2 == 0) {
      T.push_back('0');
    }
    else {
      T.push_back('1');
    }
  }
  int count_T = 0;
  for(int i = 0; i < N; i++) {
    if(S[i] != T[i]) {
      count_T++;
    }
  }
  if(count_T * 2 < N) {
    cout << count_T << endl;
  }
  else {
    cout << N - count_T << endl;
  }
}

Measured memory_bytes: 3704
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a, b):
    return (a * b)//gcd(a,b)

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

lcm_a = 1

for i in A:
    lcm_a = lcm(lcm_a,i)

ans = 0
for i in A:
    ans +=lcm_a//i 
    
print(ans%int(1e9+7))

Measured memory_bytes: 4084
N = int(input())
A = [int(x) for x in input().split()]
freq = [0 for i in range(10**5+1)]
for x in A:
    freq[x] += 1
ans = sum(A)
for q in range(int(input())):
    B, C = map(int,input().split())
    ans -= B*freq[B]
    ans += C*freq[B]
    freq[C] += freq[B]
    freq[B] = 0
    print(ans)

Measured memory_bytes: 83428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1000000007;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	if (N % 2 == 0) {
		for (int i = 0; i < N; i++) {
			if (A[i] != ((i / 2)*2) + 1) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if (A[i] != ((i+1) / 2)*2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	int res = 1;
	for (int i = 0; i < (N / 2); i++) {
		res = (res * 2) % MOD;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) ((int)(x).size())
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

const int inf = 1 << 30;
const ll INF = 1LL << 60;

int main(){
    int n;
    string s;
    cin >> n >> s;
    vector<string> tl = {"SS", "SW", "WS", "WW"};
    rep(i,4){
        string t = tl[i];
        for(int i = 1; i < n-1; i++){
            if ((t[i] == 'W' && s[i] == 'o') || (t[i] == 'S' && s[i] == 'x')){
                if (t[i-1] == 'S') t += 'W';
                else t += 'S';
            }else{
                if (t[i-1] == 'S') t += 'S';
                else t += 'W';
            }
        }
        t = t[sz(t)-1] + t + t[0];
        bool ok = true;
        for(int i = 1; i <= n; i++){
            if ((t[i] == 'W' && s[i-1] == 'o') || (t[i] == 'S' && s[i-1] == 'x')){
                if (t[i-1] == t[i+1]) ok = false;
            }else{
                if (t[i-1] != t[i+1]) ok = false;
            }
        }
        if (!ok) continue;
        t = t.substr(1, n);
        view(t);
        return 0;
    }
    view(-1);
    return 0;
}

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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
bool chmax(T &a, const T &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

//素因数分解 o(√n)
map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  if (n == 1) {
    return cout << 0 << '\n', 0;
  }
  int ans = 0;
  map<int, int> x = prime_factor(n);
  arep(e, x) {
    int z = e.second, t = 1;
    while (z >= t) {
      ++ans;
      z -= t;
      ++t;
    }
  }
  cout << ans << '\n';
  return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N,W;
	cin>>N>>W;
	vector<int> DP(100010,INF);
	DP[0]=0;
	int w,v;
	int ans=0;
	rep(i,0,N)
	{
		cin>>w>>v;
		rrep(j,0,100010)
		{
			if(DP[j]==INF)continue;
			chmin(DP[j+v],DP[j]+w);
			if(DP[j+v]<=W)chmax(ans,j+v);
		}
	}

	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
import math
import numpy as np
import queue
from collections import deque,defaultdict
import heapq
from sys import stdin,setrecursionlimit
from scipy.sparse.csgraph import dijkstra
from scipy.sparse import csr_matrix
input = stdin.readline
setrecursionlimit(10**7)

def main():
    do = defaultdict(int)
    de = defaultdict(int)
    do[-1] = 0
    de[-1] = 0
    n = int(input())
    v = list(map(int,input().split()))
    for i,vi in enumerate(v):
        if i%2 == 0:
            de[vi] += 1
        else:
            do[vi] += 1
    dem = 0
    demk = 0
    dom = 0
    domk = 0
    for dek,dev in de.items():
        if dem < dev:
            demk = dek
            dem = dev
    for dok,dov in do.items():
        if dom < dov:
            domk = dok
            dom = dov

    if demk == domk:
        if list(do.values()).count(dom) > 1 or list(de.values()).count(dem) > 1:
            print(n-dem-dom)
        else:
            de[demk] = 0
            do[domk] = 0
            dxm = dem
            dem = max(de.values())
            dom = max(do.values())
            if dem > dom:
                print(n-dxm-dem)
            else:
                print(n-dxm-dom)
    else:
        print(n-dem-dom)


if __name__ == '__main__':
    main()


Measured memory_bytes: 28284
#include <iostream>

using namespace std;

const long T = 1000000007;

int main()
{
    int n;
    cin >> n;
    long ans = 1;
    for (int i = 1; i <= n; ++i) {
        ans = ans * i % T;
    }

    cout << ans << endl;

    return 0;
}

    

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

int main() {
  string b;
  cin >> b;
  if (b == "A" ) 
    cout << "T" << endl;
  else if (b == "T")
    cout << "A" << endl;
  else if (b == "C") 
    cout << "G" << endl;
  else if (b == "G")
    cout << "C" << endl;
  }

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

l.sort(reverse=True)
# print(l)

d = list(map(lambda x: l[x] - l[x + 1], range(m - 1)))
d.sort(reverse=True)

# print(l, d)

x = l[0]-l[-1]-sum(d[:n-1])

# print(l[0]-l[-1])
print(x)


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

int main() {
	int num;
  	cin>>num;
  	int x = ((num/1000)+1) * 1000;
  	int y = x - num;
  	int z = num%1000;
  	if(z==0)
      cout<<z;
  	else
      cout<<y;
  	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define NINTH_POWER_OF_TEN 1000000000
#define LL_INF (numeric_limits<long long>::max()/2)
#define int long long

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

const int kMaxN = 100;
const int kMaxM = 100;

int N, M, X, Y;
string ans;

int x[kMaxN], y[kMaxM];

signed main() {
  cin >> N >> M >> X >> Y;
  REP(i, N) { cin >> x[i]; }
  REP(i, M) { cin >> y[i]; }

  sort(x, x+N);
  sort(y, y+M);
  ans = "War";
  FOR(i, X+1, Y) {
    if (x[N-1] < i && i <= y[0]) {
      ans = "No War";
      break;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main(){
  int x, a, b;
  cin >> x >> a >> b;
  if(b <= a){
    cout << "delicious" << endl;
  }else if(b <= a + x){
    cout << "safe" << endl;
  }else{
    cout << "dangerous" << endl;
  }
}

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

void merge( int *a , int left , int middle , int right )
{
	int i , j , k , *b , nb;

	i = left;
	j = middle + 1;
	k = 0;

	nb = right - left + 1;
	if( ( b = ( int *) malloc( sizeof( int )*nb ) )  == NULL ){
		fprintf( stderr , "MEM malloc error...\n" );
		return ;
	}

	while( i <= middle && j <= right ){
		if( a[i] <= a[j] ){
			b[k] = a[i];
			i++;
		}
		else{
			b[k] = a[j];
			j++;
		}
		k++;
	}

	if( i == middle + 1 ){
		while( j <= right ){
			b[k] = a[j];
			j++;
			k++;
		}
	}
	else{
		while( i <= middle ){
			b[k] = a[i];
			i++;
			k++;
		}
	}

	for( i=0 ; i<k ; i++ )
		a[left+i] = b[i];
	
}

void merge_sort( int *a , int left , int right )
{
	int middle;

	if( left == right ) return;
	
	middle = ( right + left )/2;
	
	merge_sort( a , left , middle );
	merge_sort( a , middle + 1 , right );
	merge( a , left , middle , right );
	
}


int main(void)
{
    int *a ,i,ans;

    a = (int*)malloc(sizeof(int)*3);

    for(i=0;i<3;i++)
        scanf("%d" , &a[i]);

    merge_sort(a,0,2);

    ans=0;
    for(i=0;i<2;i++){
        ans+= abs(a[i+1]-a[i]);
    }

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

    
}

Measured memory_bytes: 128
cooks = []
for i in range(5):
    cooks.append(int(input()))

diff = []
result = 0
for i in cooks:
    result += i
    x = 10 - (i % 10)
    if x == 10:
        x = 0

    diff.append(x)

diff.sort()
last = diff.pop()
result += sum(diff)

print(result)

Measured memory_bytes: 3064
while True:
    [h,w] = map(int,input().split())
    if h==0 and w ==0: break
    s = ['#'*w+'\n', (('#' + '.'*(w-2) + '#')[0:w]+'\n')*(h-2), '#'*w+'\n' ]
    t = list(filter(lambda x: x!='', s))
    print(''.join(t[0:h]))

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int n,x,y,i,j,r[2000];
    cin >> n >> x >> y;
    for (i,1,n)
        r[i]=0;
    for (i,1,n)
        for (j,i+1,n+1)
    {
        int ans = j-i;
        int bns = abs(j-y)+abs(i-x)+1;
        r[min(ans,bns)]++;
    }
    for (i,1,n)
        cout << r[i] << endl;
    return 0;
}


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

int main() {
	string s,t;cin>>s>>t;
	bool flag=0;
	for(int i=0;i<s.size()-t.size()+1;i++){
		bool b=1;
		for(int j=0;j<t.size();j++)if(t[j]!='_'&&t[j]!=s[i+j])b=0;
		if(b)flag=1;
	}cout<<(flag?"Yes\n":"No\n");
	return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

bool is_prime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
  int x; cin >> x;
  
  while(true){
    if(is_prime(x)){
      cout << x << endl;
      return 0;
    }
    x++;
  }
  return 0;
}

Measured memory_bytes: 256
#D
import heapq

n,m = map(int,input().split())
a = list(map(int,input().split()))
bc = []
for i in range(m):
    b,c = map(int,input().split())
    bc.append((b,c))
bc.sort(key=lambda x:-x[1])
heapq.heapify(a)
for i in range(m):
    b,c = bc[i][0],bc[i][1]
    for j in range(b):
        p = heapq.heappop(a)
        if c > p:
            heapq.heappush(a,c)
        else:
            heapq.heappush(a,p)
            break
            
            
print(sum(a))

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    cout << (s[0] == 'S' ? "Cloudy" : s[0] == 'C' ? "Rainy" : "Sunny") << "\n";
    return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60, lmod = 1e9+7;

const int MAX_N = 202;

int main(){
  string s; cin >> s;
  int N = s.size();
  int ans = INF;
  for(char c='a';c<='z';c++){
    string a = s;
    int sz = N;
    while(true){
      bool same=true;
      rep(i,sz) same &= (a[i]==c);
      if(same) break;
      else sz--;
      rep(i,sz){
        if(a[i]==c || a[i+1]==c){
          a[i] = c;
        }else{
          a[i] = c-1;
        }
      }
      // cout << sz << ","<< a << endl;
    }
    // cout << sz << endl;
    ans = min(ans,N-sz);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;	





int main(){
	
	int a,b;
	
	cin >> a >> b; 
	
	a--; 
	b--;
	cout << a*b << endl; 

	
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
const int maxn = 3e6 + 10;
int fact[maxn], inv[maxn];
int mod = 998244353;
inline int mu(int x,int y){ return 1LL * x * y % mod; }
inline int ad(int x,int y){
	x += y;
	if(x < mod)
		return x;
	return x - mod;
}
inline int bpow(int x,int y){
	int res = 1;
	while(y){
		if(y&1)
			res = mu(res, x);
		x = mu(x, x);
		y >>= 1;
	}
	return res;
}
void prep(){
	for(int i=0; i<maxn; i++)
		fact[i] = (!i ? 1 : mu(fact[i - 1], i));
	inv[maxn - 1] = bpow(fact[maxn - 1], mod - 2);
	for(int i=maxn - 2; i>=0; i--)
		inv[i] = mu(inv[i + 1], i + 1);
}
inline int C(int r,int n){
	if(r < 0 || n < 0 || r > n)
		return 0;
	return mu(fact[n], mu(inv[r], inv[n - r]) );
}
int get(int m,int sum,int n){
	int ans = 0;
	for(int od=0; od<=m; od++){
		int rem = sum - od;
		if(rem & 1)
			continue;
		int z = C(od, n);
		z = mu(z, C(n - 1, n - 1 + rem/2));
		ans = ad(ans, z);
	}
	return ans;
}
int32_t main(){
	IOS;
	prep();
	int n, m;
	cin >> n >> m;
	int ans = 0;
	for(int od = 0; od <= m && od <= n; od++){
		int rem = 3 * m - od;
		if(rem & 1)
			continue;
		int z = C(od, n);
		z = mu(z, C(n - 1, n - 1 + rem/2));
		ans = ad(ans, z);
	}
	int t = 0;
	t = mod - get(m, m, n);
	t = ad(t, get(m, m, n - 1) );
	t = mu(t, n);
	ans = ad(ans, t);
	cout << ans << endl;
	
}

Measured memory_bytes: 23680
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	h := getNextInt(scanner)
	w := getNextInt(scanner)
	m := getNextInt(scanner)
	hh := make([]int, m)
	ww := make([]int, m)
	sh := make([]int, h+1)
	sw := make([]int, w+1)
	hw := make([][]int, h)
	for i := 0; i < m; i++ {
		hh[i] = getNextInt(scanner) - 1
		ww[i] = getNextInt(scanner) - 1
		sh[hh[i]]++
		sw[ww[i]]++
		hw[hh[i]] = append(hw[hh[i]], ww[i])
	}
	mh := 0
	mhc := 0
	mw := 0
	mwc := 0
	for i := 0; i < h; i++ {
		if mh < sh[i] {
			mh = sh[i]
		}
	}
	for i := 0; i < w; i++ {
		if mw < sw[i] {
			mw = sw[i]
		}
	}
	for i := 0; i < h; i++ {
		if mh == sh[i] {
			mhc++
		}
	}
	for i := 0; i < w; i++ {
		if mw == sw[i] {
			mwc++
		}
	}
	for i := 0; i < h; i++ {
		if sh[i] < mh {
			continue
		}
		c := mwc
		for _, tw := range hw[i] {
			if sw[tw] == mw {
				c--
			}
		}
		if c > 0 {
			fmt.Fprintln(writer, mw+mh)
			return
		}
	}
	fmt.Fprintln(writer, mw+mh-1)
}


Measured memory_bytes: 30976
// AOJ 1531: Remainder Zero
// 2019.2.21 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long long gcd(long long a, long long b)
{
	long long r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

long long lcm(long long a, long long b, long long lim)
{
	long long g = gcd(a, b);
	a /= g;
	if ((double)a * b > lim) return -1;
	return a * b;
}

int power[15], sz;
int ptbl[] = {
		 3,   5,   7,  11,  13,  17,  19,  23,  29,
   31,  37,  41,  43,  47,  53,  59,  61,  67,  71,
   73,  79,  83,  89,  97, 101, 103, 107, 109, 113,
  127, 131, 137, 139, 149, 151, 157, 163, 167, 173,
  179, 181, 191, 193, 197, 199, 211, 223, 227, 229,
  233, 239, 241, 251, 257, 263, 269, 271, 277, 281,
  283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
  353, 359, 367, 373, 379, 383, 389, 397, 401, 409,
  419, 421, 431, 433, 439, 443, 449, 457, 461, 463,
  467, 479, 487, 491, 499, 503, 509, 521, 523, 541,
  547, 557, 563, 569, 571, 577, 587, 593, 599, 601,
  607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
  661, 673, 677, 683, 691, 701, 709, 719, 727, 733,
  739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
  811, 821, 823, 827, 829, 839, 853, 857, 859, 863,
  877, 881, 883, 887, 907, 911, 919, 929, 937, 941,
  947, 953, 967, 971, 977, 983, 991, 997, 0 };

void prime_factor(long long n)
{
	int i, b, sw;
	int *pp, *p;

	pp = power;
	if ((n & 1) == 0) {
		do n >>= 1LL, (*pp)++;
		while ((n & 1) == 0);
		pp++;
	}
	for (p = ptbl; n > 1 && *p > 0; p++) {
		if (n % *p) continue;
		b = *p;
		do n /= b, (*pp)++;
		while (n % b == 0);
		pp++;
	}
	if (n > 1) {
		b = (int)sqrt((double)n);
		for (i = 1009, sw = 0; n > 1; ) {
			if (i > b) { *pp++ = 1; break; }
			if (n % i == 0) {
				do n /= i, (*pp)++;
				while (n % i == 0);
				pp++;
			}
			if (sw) i += 2, sw = 0;
			else    i += 4, sw = 1;
		}
	}
	sz = pp - power;
}

int N, M;
long long A[10], B[10];

int main()
{
	int i, ans;
	long long a_gcd, b_lcm;

	scanf("%d%d", &N, &M);
	for (i = 0; i < N; i++) scanf("%lld", A + i);
	for (i = 0; i < M; i++) scanf("%lld", B + i);

	a_gcd = A[0];
	for (i = 1; i < N; i++) a_gcd = gcd(a_gcd, A[i]);
	b_lcm = B[0];
	if (b_lcm > a_gcd) goto ZERO;
	for (i = 1; i < M; i++) {
		b_lcm = lcm(b_lcm, B[i], a_gcd);
		if (b_lcm < 0 || b_lcm > a_gcd) goto ZERO;
	}

//	printf("gcd %lld, lcm %lld\n", a_gcd, b_lcm);
	ans = 1;
	if (a_gcd < b_lcm) {
ZERO:	ans = 0;
	}
	else if (a_gcd == b_lcm) ;
	else {
		a_gcd /= b_lcm;
		prime_factor(a_gcd);
//		printf("sz=%d:", sz);
//		for (i = 0; i < sz; i++) printf(" %d", power[i]);
//		printf("\n");
		for (i = 0; i < sz; i++) ans *= 1 + power[i];
	}
	printf("%d\n", ans);
	return 0;
}


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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    if(n < 1200)
    {
        cout << "ABC";
    }
    else
    if(n < 2800 and n >= 1200)
    {
        cout << "ARC";
    }
    else
    cout << "AGC";
    return 0;
}


Measured memory_bytes: 4352
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  [a, b, c, d] <- readInts
  putStrLn $ if solve a b c d then "Yes" else "No"

solve :: Int -> Int -> Int -> Int -> Bool
solve a b c d =
  if abs (a - c) <= d
    then True
    else if abs (a - b) <= d && abs (b - c) <= d
      then True
      else False

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx

while :: Monad m => m Bool -> m () -> m ()
while cond body = do
  b <- cond
  when b $ do
    body
    while cond body


Measured memory_bytes: 380
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

// ax - x + 1 >= b
// ax - x >= b - 1
// x(a-1) >= b - 1
// x = (b-1) / (a-1)
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int a, b;
	cin >> a >> b;

	int num = b - 1, den = a - 1;

	cout << (num + den - 1) / den << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <cstring>
#include <istream>
#include<cmath>
#include<map>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<cstring>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
int k;
int vis[60][maxn];
int dfs(int x, int y) {
	if (x < 0) return 0;
	if (x == 0 && y == 0)return 1;
	if (vis[x][y]) return 0;
	vis[x][y] = 1;
	for (int s = 0; s < 10; s++)
		if (dfs(x - s, (y * 10 + s) % k))return 1;
	return 0;
}
int main()
{
	while (~scanf("%d", &k)) {
		int m = 0;
		int n = k;
		while (n) {
			for (int i = 0; i < n; i++)
				m += n % 10;
			n /= 10;
		}
		memset(vis, 0, sizeof(vis));
		int ans = m;
		for (int j = 1; j < m; j++) {
			if (dfs(j, 0)) {
				ans = j;
				break;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 26752
INF = float('inf')
n, m = map(int, input().split())
a = list(map(int, input().split()))
cost = [2, 5, 5, 4, 5, 6, 3, 7, 6]
l = [[x, cost[x-1]] for x in a]
l = sorted(l, key = lambda x: x[1]*10-x[0])
r = l[0]
k = max(n-200, 0)//r[1]
n -= r[1]*k
_max = [0] + [-INF]*n
for i in range(1, n+1):
  if 50 < i < n-50:
    _max[i] = max(_max[i], _max[i-r[1]]*10 + r[0])
  else:
    for x in l:
      ind = i-x[1]
      if ind >= 0:
        _max[i] = max(_max[i], _max[ind]*10 + x[0])
ans = str(_max[n])
ans = ans[:10] + str(r[0])*k + ans[10:]
print(ans)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        private static List<long> ps = null;
        static void Solve()
        {
            var nhw = ReadAndParseIntArr();
            int n = nhw[0];
            int h = nhw[1];
            int w = nhw[2];
            int[] a = new int[n];
            int[] b = new int[n];
            for(int i=0;i<n;++i)
            {
                var t = ReadAndParseIntArr();
                a[i] = t[0];
                b[i] = t[1];
            }

            int ans = 0;
            for(int i = 0; i < n; ++i)
            {
                if( a[i] >= h && b[i] >= w)
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }


        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using l = long;
using ul = unsigned long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define itn int
#define ocut cout
#define ouct cout
#define outc cout
int main(){
    int n,m;
    cin >> n >> m;
    int p[m],a[n];
    bool o[n];
    string s[m];
    REP(i,n){
        a[i]=0;
        o[i]=false;
    }
    int r;
    REP(i,m){
        cin >> p[i] >> s[i];
        r=p[i]-1;
        if(s[i]=="WA"&&o[r]==false){
            a[r]++;
        }
        else{
            o[r]=true;
        }
    }
    int a1=0,a2=0;
    REP(i,n){
        if(o[i]==true){
            a1++;
            a2+=a[i];
        }
    }
    cout << a1 <<" "<< a2;
}


Measured memory_bytes: 6528
s = input()
s_l = list(s)
t = input()
t_l = list(t)

pre_dict = {}
post_dict = {}
ans = True
for i in range(len(s_l)):
    if s_l[i] in pre_dict.keys():
        if t_l[i] not in pre_dict[s_l[i]]:
            ans = False
    else:
        pre_dict[s_l[i]] = [t_l[i]]
    
    if t_l[i] in post_dict.keys():
        if s_l[i] not in post_dict[t_l[i]]:
            ans = False
    else:
        post_dict[t_l[i]] = [s_l[i]]

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

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

typedef long long ll;

int main() {         
	int n, m;
	cin >> n >> m;
	char v[n][m];
    bool d = 1;
    for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> v[i][j];
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (v[i][j] == '#') {
				int cnt = 0;
				if (i + 1 < n && v[i + 1][j] == '#')cnt++;
				if (i - 1 >= 0 && v[i - 1][j] == '#')cnt++;
				if (j + 1 < m && v[i][j + 1] == '#')cnt++;
				if (j - 1 >= 0 && v[i][j -1] == '#')cnt++;
				if (!cnt) {
					d = 0;
				} 
			}
		}
	}
    if (d) {
		cout << "Yes";
	}else {
		cout << "No";
	}
}


Measured memory_bytes: 3596