akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int memo[1000*1000+1];

int main(){
  int p,q;
  while(~scanf("%d%d",&p,&q)){
    int cnt = 0;
    memset(memo,-1,sizeof(memo));
    while((p != 0) && (memo[p] == -1)){
      memo[p] = cnt++;
      p *= 10;
      int tmp = p/q;
      printf("%d",tmp);
      p -= q*tmp;
    }
    puts("");
    if(p == 0) continue;
    REP(i,cnt){
      if(i >= memo[p])
	putchar('^');
      else
	putchar(' ');
    }
    puts("");
  }
  return 0;
}

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

void solve() {
    string s;
    cin >> s;
    int n = s.length();
    for (int i = 0; i < n; i++) {
        if (s[i] != s[n - 1 - i]) {
            cout << "No";
            return;
        }
    }
    for (int i = 0; i < n / 2; i++) {
        if (s[i] != s[n / 2 - 1 - i]) {
            cout << "No";
            return;
        }
    }
    for (int i = n / 2 + 1; i < n; i++) {
        if(s[i] != s[n - 1 - (i - n / 2 - 1)]) {
            cout << "No";
            return;
        }
    }
    cout << "Yes" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
//110
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int H, W, h, w, A, B, C;
string s;

int main() {
	cin >> A >> B >> C;
	int ans = max(A, max(B, C)) * 10 + A + B + C - max(A, max(B, C));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    int a[5][5];
    int n;
    int b;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> b;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if( a[j][k] == b ){
                    a[j][k] = 0;
                }
            }
        }
    }

    int result = false;
    for(int i=0;i<3;i++){
        if( !a[i][0] && !a[i][1] && !a[i][2] || !a[0][i] && !a[1][i] && !a[2][i] ){
            result = true;
        }
    }

    if( !a[0][0] && !a[1][1] && !a[2][2] || !a[0][2] && !a[1][1] && !a[2][0] ){
        result = true;
    }

    if(result){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.array, std.range, std.conv,
    std.typecons, std.math, std.container, std.format;

void main(string[] args)
{
    if (readln.split.to!(long[]).sum >= 22)
    {
        writeln("bust");
    }
    else
    {
        writeln("win");
    }
}


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

for i in range(n+1):
    for j in range(n+1):
        num_sen = n - i - j
        if num_sen < 0:
            continue

        if 10000 * i + 5000 * j + 1000 * num_sen == y:
            print(i, j, num_sen)
            exit()
print(-1, -1, -1)



Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <limits>
#include <numeric>
#include <vector>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
bool compare_by_b(pair<int, long long> a, pair<int, long long> b) {
    if(a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}
int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> ve(M);
    rep(i, 0, M) { cin >> ve[i].first >> ve[i].second; }
    sort(ve.begin(), ve.end(), compare_by_b);

    int tmp = 0;
    int res = 0;
    rep(i, 0, M) {
        if(ve[i].first > tmp) {
            res++;
            tmp = ve[i].second - 1;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>

#include <sstream>
#include <string>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;

string S;
long long point;


void check( string val ){
	
	cout << val << endl;
}

void sum(string S){

	// cout << S << " : ";

	istringstream iss(S);
	long long  num = 0;
		
	for(int i = 0 ; i < 10 ; i++){
		long long n = 0;
		iss >> n;

		num +=n;
	}

	// cout << num << endl;

	point += num;
}

void loop(string str , int count){

	if(count == S.length()){
		sum(str);
		return;
	}
	int now = count;
	count ++;
	loop(str + S[now] , count);
	loop(str + " " + S[now] , count);
}

int main( int argc , char ** argv ){
	
	cin >> S;
	//check(S);

	point = 0;
	string buf;
	buf = S[0];
	loop( buf , 1 );

	cout << point << endl;

}



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

int main()
{
    double a,b,n=0,i,a1,b1,ans;
    scanf("%lf %lf",&a,&b);
    b1=b-1;
    a1=a-1;
    ans=b1/a1;
    printf("%.0lf\n",ceil(ans));

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int gcd(int a,int b){
	if(!b) return a;
	return gcd(b,a%b);
}

int n;

bool f(vi a){
	int t=0;
	for(int i=0;i<n;i++) t+=(a[i]+1)%2;
	if(t<n-1) return t%2==1;
	if(t%2==1) return 1;
	int g=0;
	for(int i=0;i<n;i++) if(a[i]==1) return 0;
	for(int i=0;i<n;i++) g=gcd(g,a[i]/2*2);
	for(int i=0;i<n;i++) a[i]/=g;
	return !f(a);
}

int main(){
	cin>>n;
	vi a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	cout<<(f(a)?"First":"Second")<<endl;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;

int main(){
  int n,k;cin>>n>>k;
  vector<int> v(n);
  vector<ld> d(n);
  ld a=0;
  ld u=1.0;
  
  rep(i,n){
    cin>>v.at(i);
    d.at(i)=(u+v.at(i))/2.0;
  }
  
  rep(i,k){
    a+=d.at(i);
  }
  ld c=a;
  rep(i,n-k){
    c += d.at(k+i);
    c -= d.at(i);
    a=max(a,c);
  }
  cout << fixed << setprecision(20);
  cout<<a<<endl;
}



Measured memory_bytes: 4096
#include <stdio.h>
int main(void){
	int num[32] = {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
	int input;
	
	scanf("%d",&input);
	printf("%d\n",num[input-1]);
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pair_ordered_set tree< pair<ll,ll> , null_type,less< pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update>
pair_ordered_set st;
const ll N=2e5+5;
ll n,k,ans,a[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>k;
    for(ll i=1;i<=n;i++)cin>>a[i],a[i]-=k,a[i]+=a[i-1];
    for(ll i=0;i<=n;i++){
        ll cnt = st.order_of_key({a[i]+1,-1});
        ans+=cnt;
        st.insert({a[i],i});
    }
    cout<<ans;
}




Measured memory_bytes: 15616
a = [int(input()) for i in range(5)]

sum = int(0)
min = int(10)
for i in range(5):
    x = a[i]%10
    sum += a[i]//10*10
    if min>x and x!=0:
            min = x
    if x!= 0:        
            sum += 10

print(sum + min-10)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define FOR(i,s,e) for (int i=s;i<e;i++)
#define FOE(i,s,e) for (int i=s;i<=e;i++)
#define FOD(i,s,e) for (int i=s;i>=e;i--)
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define LD long double
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>
#define PLI pair<LL,int>
#define PIL pair<int,LL>
#define PLL pair<LL,LL>
#define eps 1e-9
#define mp make_pair

LL n,a,b,c,d,ans;

int main () {
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);
	b=min(a*2,b);
	c=min(b*2,c);
	d=min(c*2,d);
	ans=(n/2)*d+(n%2)*c;
	printf("%lld\n",ans);
	return 0;	
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}


signed main(){start();
    string s;
    cin>>s;
    if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout<<"Bad"<<endl;
    else cout<<"Good"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 305;
const int MOD = 1e9 + 7;

struct ModInt
{
  int val;

  ModInt (): val(0) {}

  ModInt (int _val): val(_val) {}

  ModInt operator+(ModInt b)
  {
    ModInt c(val + b.val);
    if (c.val >= MOD)
      c.val -= MOD;
    return c;
  }

  void operator+=(ModInt b)
  {
    val += b.val;
    if (val >= MOD)
      val -= MOD;
  }
};

ModInt dp[2][N][N][3];
int n, m;
vector <pair<int, int> > query[N];

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


  for (int i = 0; i < m; i++)
  {
    int l, r, x;
    cin >> l >> r >> x;
    query[r].push_back({l, x});
  }

  for (int i = 0; i <= n; i++)
  {
    sort(query[i].begin(), query[i].end());
    vector <pair <int, int> > tmp;
    if (!query[i].empty())
      tmp.push_back(query[i][0]);

    for (int j = 0; j < (int)query[i].size(); j++)
    {
      if (j != (int)query[i].size() - 1)
      {
        if (query[i][j].first == query[i][j + 1].first && query[i][j].second != query[i][j + 1].second)
        {
          cout << 0 << '\n';
          return 0;
        }
        if (query[i][j].first < query[i][j + 1].first && query[i][j].second < query[i][j + 1].second)
        {
          cout << 0 << '\n';
          return 0;
        }
        if (query[i][j].second != query[i][j + 1].second)
          tmp.push_back(query[i][j + 1]), tmp.push_back(query[i][j]);
      }
      else
        tmp.push_back(query[i][j]);

    }
    query[i] = tmp;
  }

  int ptr = 0;
  dp[ptr][0][0][1].val = 1;

  for (int i = 0; i <= n; i++)
  {
    for (int l1 = 0; l1 <= n; l1++)
      for (int l2 = 0; l2 <= n; l2++)
        for (int o = 0; o < 3; o++)
        dp[ptr ^ 1][l1][l2][o].val = 0;



    for (int l1 = 0; l1 <= i; l1++)
    {
      for (int l2 = 0; l2 <= i; l2++)
      {
        for (int last_el = 0; last_el < 3; last_el++)
        {
          int pos_r, pos_g, pos_b;

          if (last_el == 0)
          {
            pos_r = i;
            pos_g = l1;
            pos_b = l2;
          }
          else if (last_el == 1)
          {
            pos_r = l1;
            pos_g = i;
            pos_b = l2;
          }
          else if (last_el == 2)
          {
            pos_r = l1;
            pos_g = l2;
            pos_b = i;
          }

          bool ok = true;
          for (auto it : query[i])
          {
            int cnt = (int)(pos_r >= it.first) + (int)(pos_g >= it.first) + (int)(pos_b >= it.first);
            ok &= cnt == it.second;
          }

          if (!ok)
            dp[ptr][l1][l2][last_el].val = 0;

          dp[ptr ^ 1][pos_g][pos_b][0] += dp[ptr][l1][l2][last_el];
          dp[ptr ^ 1][pos_r][pos_b][1] += dp[ptr][l1][l2][last_el];
          dp[ptr ^ 1][pos_r][pos_g][2] += dp[ptr][l1][l2][last_el];
        }
      }
    }
    ptr ^= 1;
  }

  ModInt res;
  res.val = 0;

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++)
      for (int k = 0; k < 3; k++)
        res += dp[ptr ^ 1][i][j][k];

  cout << res.val << '\n';
  return 0;
}


Measured memory_bytes: 2432
#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 sc(x) scanf("%d",&x);
int main(){
    bool check;
    vector<int> a(3), b(3);
    vector<vector<int> > c(3, vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++) sc(c[i][j])
    }
    for (int i = 0; i <= 100; i++){
        a[0] = i; b[0] = c[0][0] - a[0];
        for (int j = 1; j < 3; j++) b[j] = c[0][j] - a[0];
        for (int j = 1; j < 3; j++) a[j] = c[j][0] - b[0];
        check = true;
        for (int j = 1; j < 3; j++){
            for (int k = 1; k < 3; k++){
                if (c[j][k] != a[j] + b[k]) check = false;
            }
        }
        if (check) break;
    }
    if (check) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()
k=int(input())

moji=s[k-1]

line=[]

for i in range(n):
    line.append(s[i])

for i in range(len(s)):
    if s[i]!=moji:
        line[i]="*"

output=""

for i in range(len(line)):
    output=output+line[i]

print(output)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)


ll n,x;
vl pat(55);
vl size(55);


ll solve(int lev, ll num){
	if(lev==0){
		if(num==1)
			return 1;
		else
			return 0;
	}
	else{
		if(num==1)
			return 0;
		else if(num<=size[lev-1]+1){
			return solve(lev-1,num-1);
		}
		else if(num==size[lev-1]+2){
			return pat[lev-1]+1;
		}
		else if(num<=size[lev-1]*2+2){
			return solve(lev-1, num-size[lev-1]-2)+pat[lev-1]+1;
		}
		else{
			return pat[lev-1]*2+1;
		}

	}

}

int main(){
	cin >> n >>x;
	pat[0]=1;
	size[0]=1;
	REP(i,1,55){
		pat[i]=pat[i-1]*2+1;
		size[i]=size[i-1]*2+3;
	}
	ll ans=solve(n,x);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N;
    string s,t;
    cin>>N>>s>>t;
    for(int i=N;;i--){
        int flg=1;
        for(int j=N-i;j<N;j++){
            if(s[j]!=t[j-(N-i)])flg=0;
        }
        if(flg){
            cout<<N*2-i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

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


int main(){
    int n;
    cin >> n;
    cout << (n-1) / 2 + 1 << endl;


    return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
N = int(input())
a = list(map(int,input().split()))

c = [0]*N
n = 0
sign = 1
for h in range(H):
    state = [0]*W
    for w in range(W):
        if c[n]>=a[n]:
            n += 1
        state[w] = str(n+1)
        c[n] += 1
    sign = (sign+1)%2
    if sign:
        state = state[::-1]
    print(' '.join(state))

Measured memory_bytes: 3188
#include<stdio.h>
int n, s[100000000], count = 0;
void binarySearch ( int key ) {
    int left = 0;
    int right = n;
    while ( left < right ) {
        int mid = (left + right) / 2;
        if ( key == s[mid] ) {
            count++;
            break;
        }
        else if ( key < s[mid] ) right = mid;
        else left = ++mid;
    }   
}

int main(void) {
    int i, j, q, t[500000];
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) {
        scanf("%d", &s[i]);
    }
    scanf("%d", &q);
    for ( i = 0; i < q; i++ ) {
        scanf("%d", &t[i]);
        binarySearch(t[i]);
    }
    
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 2308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            int count = Integer.parseInt(br.readLine());
            String data[] = br.readLine().split(" ");
            for (int i = data.length - 1; i >= 0; i--)
                if (i == 0)
                    System.out.print(data[i]);
                else
                    System.out.printf("%s ", data[i]);
            System.out.print("\n");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24672
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#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 ALL(a) (a).begin(), (a).end()

int main() {
    int N, d[100000];
    cin >> N;
    REP(i, N) cin >> d[i];
    sort(d, d + N);
    cout << d[N / 2] - d[N / 2 - 1] << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
 
int main() {
  long N;
  cin >> N;
  vector<long>A(N);
  for(long i=0;i<N;i++){
    cin >> A.at(i);
  }
  long count=0;
  bool zero=false;
  for(long i=0;i<N;i++){
    if(A.at(i)<0){
      count++;
    }
    else if(A.at(i)==0){
      zero=true;
    }
  }
  long saisyou=1000000000;
  long long answar=0;
  if(count%2==0||zero){
    for(long i=0;i<N;i++){
      if(A.at(i)<0){
        answar+=-A.at(i);
      }
      else{
        answar+=A.at(i);
      }
    }
    cout << answar;
    return 0;
  }
  else{
    for(long i=0;i<N;i++){
        saisyou=min(saisyou,labs(A.at(i)));
    }
    for(long i=0;i<N;i++){
      if(A.at(i)<0){
      answar+=-A.at(i);
      }
      else{
        answar+=A.at(i);
      }
    }
    cout << answar-2*saisyou;
  }
}

Measured memory_bytes: 1024
arr= [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K  = int(input())
print(arr[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <utility>
#include <queue>

int main(int argc, char const *argv[]){
	int n,q,t = 0;
	std::cin >> n >> q;
	std::queue< std::pair<std::string,int> > que;
	
	for (int i = 0; i < n; ++i){
		std::string nm;
		int tm;
		std::cin >> nm >> tm;
		que.push(make_pair(nm,tm));
	} 

	while(!que.empty()){
		std::pair<std::string,int> front = que.front();
		que.pop();
		if(front.second-q > 0){
			t += q;
			que.push(make_pair(front.first,front.second-q));
		}else{
			t += front.second;
			std::cout << front.first << " " << t << std::endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6232
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []
    time = 0
    while True:
        prime = min(A)
        if prime > 316: break
        P.append(prime)
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
    for a in A: P.append(a)
    return P
l = eratosthenes(10**5)
ans = [0]*(10**5+1)
d = [0]*(10**5+1)
for i in l: d[i] += 1
for i in range(2, 10**5+1):
    ans[i] += ans[i-1]
    if i%2==1 and d[i] and d[(i+1)//2]: ans[i] += 1
for _ in range(int(input())):
    l, r = map(int, input().split())
    print(ans[r]-ans[l-1])

Measured memory_bytes: 7816
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,sse4,avx,avx2")
// #pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

mt19937 rnd(time(0));


int main()
{       
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    cout << !x << "\n";
    return 0;
}


Measured memory_bytes: 3616
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  tmp = input[1].split(" ");
  h = new Array(N);
  for(var i=0;i<N;i++){
    h[i]=parseInt(tmp[i]);
  }
  var mins=new Array(N).fill(Math.pow(10,9)+1);
  mins[0]=0;
  mins[1]=Math.abs(h[1]-h[0]);
  for(var i=2;i<N;i++){
    mins[i]=Math.min(mins[i-1]+Math.abs(h[i]-h[i-1]),mins[i-2]+Math.abs(h[i]-h[i-2]));
  }
  var ans = mins[N-1];
  console.log('%s', ans);
  return ans;
}
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 27572
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int A, B;
	cin >> A >> B;

	int ans1 = A + B;
	int ans2 = A - B;
	int ans3 = A * B;

	cout << max({ ans1,ans2,ans3 }) << endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

/*---素因数分解 from 20190929---*/
vector<pair<long long,int>> factorize(long long n) {
  vector<pair<long long,int>> res;
  for (long long i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main(){
    ll n;
    cin >> n;
    int ans = 0;
    auto f = factorize(n);
    rep(i,0,sz(f)-1){
        int tmp = 1,tot = 1;
        while(tot <= f[i].second){
            tmp++;
            tot += tmp;
            ans++;
        }
    }

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

    return 0;
}

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

void fnInput(string& rsNumStr)
{
  cin >> rsNumStr;
}

int fnMinDiffChk(string sNumStr)
{
  const int cnnNum = 753;
  int nMinDiff = INT_MAX;

  for (int i = 0; i < sNumStr.size() - 2; i++)
  {
    int nNum = (sNumStr[i]     - '0') * 100 + (sNumStr[i + 1] - '0') * 10 +
               (sNumStr[i + 2] - '0'); // char → int 変換

    nMinDiff = min(nMinDiff, abs(nNum - cnnNum));
  }
  return nMinDiff;
}

int main()
{
  string sNumStr;

  fnInput(sNumStr);
  cout << fnMinDiffChk(sNumStr) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int L[500];
int main()
{
    cin >> N;
    for(int i=0;i<2*N;++i) cin >> L[i];
    sort(L, L+2*N);
    long long ans = 0;
    for(int i=0;i<2*N;i+=2){
        ans += L[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()
takahashiHand =[]
ans = 0

for i in range(k):
    if t[i] == "r":
        takahashiHand.append("p")
    elif t[i] == "s":
        takahashiHand.append("r")
    elif t[i] == "p":
        takahashiHand.append("s")

for i in range(k, n):
    if t[i] == "r" and takahashiHand[i-k] == "p":
        takahashiHand.append(0)
    elif t[i] == "r" and takahashiHand[i-k] != "p":
        takahashiHand.append("p")
    elif t[i] == "s" and takahashiHand[i-k] == "r":
        takahashiHand.append(0)
    elif t[i] == "s" and takahashiHand[i-k] != "r":
        takahashiHand.append("r")
    elif t[i] == "p" and takahashiHand[i-k] == "s":
        takahashiHand.append(0)
    elif t[i] == "p" and takahashiHand[i-k] != "s":
        takahashiHand.append("s")

ans = r*takahashiHand.count("r") + s*takahashiHand.count("s") + p*takahashiHand.count("p")
print(ans)

Measured memory_bytes: 50032
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
 
#define MAX_N 3005
int n;
int px[MAX_N],py[MAX_N];
char ch[MAX_N];
 
int solve(int si){
  bool used[MAX_N]={};
  set< P > sx[MAX_N],sy[MAX_N];
  for(int i=0;i<n;i++){
    if(i==si)continue;
    sx[ px[i] ].insert( P(py[i],i) );
    sy[ py[i] ].insert( P(px[i],i) );
  }
  int res=1;
  int x=px[si],y=py[si];
  char dir=ch[si];
 
  set< P > :: iterator it;
  while(1){
    P next;
    if(dir=='v'){
      it= sx[x].lower_bound( P(y,0) );
      if(it==sx[x].end())break;
      next=*it;
    }else if(dir=='^'){
      it= sx[x].lower_bound( P(y,0) );
      if(it==sx[x].begin())break;
      it--;
      next=*it;
    }else if(dir=='>'){
      it= sy[y].lower_bound( P(x,0) );
      if(it==sy[y].end())break;
      next=*it;      
    }else if(dir=='<'){
      it= sy[y].lower_bound( P(x,0) );
      if(it==sy[y].begin())break;
      it--;
      next=*it;
    }
    res++;
    int id=next.second;
    x=px[id];
    y=py[id];
    dir=ch[id];
    sx[ x ].erase(P(y,id));
    sy[ y ].erase(P(x,id));
  }
  return res;
}
 
int main(){
  vector<int> X,Y;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>px[i]>>py[i]>>ch[i];
    X.push_back(px[i]);
    Y.push_back(py[i]);
  }
  sort(X.begin(),X.end());
  sort(Y.begin(),Y.end());
  X.erase(unique(X.begin(),X.end()),X.end());
  Y.erase(unique(Y.begin(),Y.end()),Y.end());
 
  for(int i=0;i<n;i++){
    px[i]=lower_bound(X.begin(),X.end(),px[i])-X.begin();
    py[i]=lower_bound(Y.begin(),Y.end(),py[i])-Y.begin();
  }
 
 
 
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,solve(i));
  }
  cout<<ans<<endl;
  return 0;
}

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

int N;

int main() {
    cin >> N;

    if (N%10 == 3) cout << "bon" << endl;
    else if ((N%10 == 0) || (N%10 == 1) || (N%10 == 6) || (N%10 == 8)) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

Measured memory_bytes: 3632
#![allow(unused_imports)]

use std::cmp;
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::stdin;
use std::ops::*;
use std::process::exit;
use std::str::FromStr;

pub const MOD: usize = 1000000007;

fn main() {
    let s: String = input();

    println!("2018{}", &s[4..]);
}



pub fn input<T: FromStr>() -> T {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().ok().unwrap()
}

pub fn input_vec<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>()
}

pub fn input_lines<T: FromStr>(l: usize) -> Vec<T> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input());
    }
    res
}

pub fn input_lines_two<T: FromStr, U: FromStr>(l: usize) -> Vec<(T, U)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_two());
    }
    res
}

pub fn input_lines_three<T: FromStr, U: FromStr, V: FromStr>(l: usize) -> Vec<(T, U, V)> {
    let mut res = Vec::new();
    for _i in 0..l {
        res.push(input_three());
    }
    res
}

pub fn input_two<T: FromStr, U: FromStr>() -> (T, U) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
    )
}

pub fn input_three<T: FromStr, U: FromStr, V: FromStr>() -> (T, U, V) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse::<T>().ok().unwrap(),
        s[1].parse::<U>().ok().unwrap(),
        s[2].parse::<V>().ok().unwrap(),
    )
}

pub fn input_four<T: FromStr, U: FromStr, V: FromStr, W: FromStr>() -> (T, U, V, W) {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let s: Vec<&str> = buf.split_whitespace().collect();
    (
        s[0].parse().ok().unwrap(),
        s[1].parse().ok().unwrap(),
        s[2].parse().ok().unwrap(),
        s[3].parse().ok().unwrap(),
    )
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define vi vector<int>
#include <algorithm>
#include <iterator>
#include<iostream>

using namespace std;

string s;
int main()
{
   int a[100000];
   int n;
   scanf("%d", &n);

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

   int dp[n+1];
   dp[0] = 0;
   dp[1] = dp[0]+ abs(a[0]- a[1]);

   for(int i =2;i<n;++i)
   {
     dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]), dp[i-2] + abs(a[i]-a[i-2]));
   }

   cout<<dp[n-1];

   return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,cnt=0;
  cin>>n;
  rep(i,n) {
    int a;
    cin>>a;
    cnt+=a-1;
  }
  cout<<cnt<<endl;
}

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


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

for(int i = 0;i < (n-1);i++){
    int tinnko = a[i+1]-a[i];
if(tinnko > max){
  max = tinnko;
  }
}
if(max < (k-a[n-1]+a[0])){
  max = (k-a[n-1]+a[0]);
}

cout << k-max<<endl;

}



Measured memory_bytes: 1024
/*ID:PROG:LANG:*/
#include<bits/stdc++.h>
#define LL long long
#define INF 0x3f3f3f3f
#define MOD 924844033
#define MAXN 200005
using namespace std;
struct Edge{
	int to,nex;Edge(int _=0,int __=0){to=_,nex=__;}
}e[MAXN<<1];
const LL g=5,gi=554906420;
LL n,cnt,mx=1,len,hd[MAXN],jc[MAXN],njc[MAXN],sz[MAXN],num[MAXN],f[MAXN],r[MAXN<<2],a[MAXN<<2],b[MAXN<<2];
LL rd(){
	LL x=0,tp=1;char c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){x=(x*10+c-'0');c=getchar();}
	return x*tp;
}
void adde(int x,int y){
	e[++cnt]=Edge(y,hd[x]);
	hd[x]=cnt;
}
LL quick_mod(LL a,LL x){LL res=1;while(x){if(x&1)(res*=a)%=MOD;(a*=a)%=MOD,x>>=1;}return res;}
LL C(int n,int m){if(n<m)return 0;return jc[n]*njc[m]%MOD*njc[n-m]%MOD;}
void ntt(LL *a,LL n,LL tp){
	for(int i=0;i<mx;i++)if(i<r[i])swap(a[i],a[r[i]]);
	for(int mid=1;mid<n;mid<<=1){
		LL Wn=quick_mod((tp==1)?g:gi,(MOD-1)/(mid<<1));
		for(int i=0;i<n;i+=mid<<1){
			LL w=1;
			for(int j=0;j<mid;j++){
				LL x=a[i+j],y=w*a[i+j+mid]%MOD;
				a[i+j]=(x+y)%MOD,a[i+j+mid]=(x-y+MOD)%MOD;
				(w*=Wn)%=MOD;
			}
		}
	}
	LL inv=quick_mod(n,MOD-2);
	if(tp==-1)for(int i=0;i<mx;i++)(a[i]*=inv)%=MOD;
}
void dfs(int now,int fa){
	sz[now]=1;
	for(int i=hd[now];i;i=e[i].nex)
		if(e[i].to!=fa)
			dfs(e[i].to,now),sz[now]+=sz[e[i].to];
	if(fa)num[sz[now]]++,num[n-sz[now]]++;
}
int main(){
	// freopen("testdata.in","r",stdin);
	// freopen("1.out","w",stdout);
	int x,y;jc[0]=njc[0]=1;
	n=rd();
	for(int i=1;i<=n;i++)jc[i]=jc[i-1]*i%MOD;
	njc[n]=quick_mod(jc[n],MOD-2);
	for(int i=n-1;i>=1;i--)njc[i]=njc[i+1]*(i+1)%MOD;
	for(int i=1;i<n;i++){
		x=rd(),y=rd();
		adde(x,y),adde(y,x);
	}
	dfs(1,0);
	while(mx<=(n<<1))mx<<=1,len++;
	for(int i=1;i<mx;i++)r[i]=(r[i>>1]>>1)|((i&1)<<len-1);
	for(int i=1;i<=n;i++)a[i]=num[i]*jc[i]%MOD;
	for(int i=0;i<=n;i++)b[n-i]=njc[i];
	ntt(a,mx,1),ntt(b,mx,1);
	for(int i=0;i<mx;i++)(a[i]*=b[i])%=MOD;
	ntt(a,mx,-1);
	for(int i=1;i<=n;i++)f[i]=a[n+i]*njc[i]%MOD;
	for(int i=1;i<=n;i++)printf("%lld\n",(n*C(n,i)%MOD-f[i]+MOD)%MOD);
	// printf("%.2lf\n",(double)clock()/CLOCKS_PER_SEC);
	return 0;
}

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

using namespace std;
#define X first
#define Y second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int main(){
    std::ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vi arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    int Mi = *min_element(arr.begin(), arr.end());
    int Ma = *max_element(arr.begin(), arr.end());

    if (Mi == Ma){
        if (Mi == n-1){
            cout << "Yes" << endl;
        } else {
            int rem = Mi;
            if (n >= rem*2){
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        return 0;
    }
    if (Mi + 1 != Ma) {
        cout << "No" << endl;
        return 0;
    }

    int numMi = 0, numMa = 0;
    for (int i = 0; i < n; i++){
        if (arr[i] == Mi) numMi++;
        if (arr[i] == Ma) numMa++;
    }

    if (numMi > Mi) {
        cout << "No" << endl;
        return 0;
    }

    int rem = Mi - (numMi - 1);
    // debug(numMi);
    // debug(numMa);
    // debug(rem);
    if (numMa >= rem*2){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

// 素数判定
bool isPrime(int a) {
    if (a == 1) return false;
    for (int i = 2; i * i <= a; i++) {
        if(a % i == 0) return false;
    }
    return true;
}

ll n, m;
vector<ll> factor;
vector<ll> factors;
void dfs(int num, int ind)
{
  if (ind >= factor.size()) 
  {
    factors.emplace_back(num);
    return;
  }
  if (num * factor[ind] * n > m)
  {
    factors.emplace_back(num);
    return;
  }
  else
  {
    dfs(num * factor[ind], ind + 1);    
    dfs(num, ind + 1);
  }
}

void solve()
{
  cin >> n >> m;

  if (n == 1)
  {
    cout << m;
    return;
  }


  ll ans = 1;
  for(ll i = 2; i * i <= m; ++i)
  {
    if (m % i == 0 && i * n <= m)
    {
      ans = max(ans, i);
      if (m / i * n <= m) ans = max(ans, m / i);
    }
  }
  cout << ans;
  return;


  //*
  if (isPrime(m))
  {
    cout << 1;
    return;
  }
  //*/

  int temp_m = m;
  for(int p = 2; p * p <= temp_m; ++p)
  {
    while(temp_m % p == 0)
    {
      if (p <= n) factor.emplace_back(p);
      temp_m /= p;
    }
  }

  factors.emplace_back(1);
  dfs(1, 0);
  sort(factors.begin(), factors.end());
  factors.erase( unique(factors.begin(), factors.end()), factors.end() );

  cout << factors.back();


}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int arith(int a, int b, char op);
int main(){
  vector<int> n(4);
  vector<char> a(3),b(3),c(3);
  a[0] = '+';a[1] = '-';a[2] = '*';
  sort(a.begin(),a.end());
  for(int i=0; i<3; i++) b[i] = c[i] = a[i];
  while(cin >>n[0]>>n[1]>>n[2]>>n[3],n[0]||n[1]||n[2]||n[3]){
    sort(n.begin(),n.end());
    do{
      do{
	do{
	  do{
	    if(arith(arith(arith(n[0],n[1],a[0]),n[2],b[0]),n[3],c[0]) == 10){
	      cout <<"((("<<n[0]<<" "<<a[0]<<" "<<n[1]<<") "<<b[0]<<" "<<n[2]<<") "<<c[0]<<" "<<n[3]<<")"<<endl;
	      goto flag;
	    }
	    if(arith(arith(n[0],n[1],a[0]),arith(n[2],n[3],c[0]),b[0]) == 10){
	      cout <<"(("<<n[0]<<" "<<a[0]<<" "<<n[1]<<") "<<b[0]<<" ("<<n[2]<<" "<<c[0]<<" "<<n[3]<<"))"<<endl;
	      goto flag;
	    }
	    if(arith(arith(n[0],arith(n[1],n[2],b[0]),a[0]),n[3],c[0]) == 10){
	      cout <<"(("<<n[0]<<" "<<a[0]<<" ("<<n[1]<<" "<<b[0]<<" "<<n[2]<<")) "<<c[0]<<" "<<n[3]<<")"<<endl;
	      goto flag;
	    }
	    if(arith(n[0],arith(arith(n[1],n[2],b[0]),n[3],c[0]),a[0]) == 10){
	      cout <<"("<<n[0]<<" "<<a[0]<<" (("<<n[1]<<" "<<b[0]<<" "<<n[2]<<") "<<c[0]<<" "<<n[3]<<"))"<<endl;
	      goto flag;
	    }
	    if(arith(n[0],arith(n[1],arith(n[2],n[3],c[0]),b[0]),a[0]) == 10){
	      cout <<"("<<n[0]<<" "<<a[0]<<" ("<<n[1]<<" "<<b[0]<<" ("<<n[2]<<" "<<c[0]<<" "<<n[3]<<")))"<<endl;
	      goto flag;
	    }
	  }while(next_permutation(a.begin(),a.end()));
	}while(next_permutation(b.begin(),b.end()));
      }while(next_permutation(c.begin(),c.end()));
    }while(next_permutation(n.begin(),n.end()));
    cout <<"0"<<endl;
  flag:;
  }
  return 0;
}
int arith(int a, int b, char op){
  if(op == '+') return a+b;
  if(op == '-') return a-b;
  if(op == '*') return a*b;
  return -1;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K,A,B;
  cin >> K;  
  cin >> A >> B;
  
  string res = "NG";
  
  for(int i=A; i<=B; i++){
    if(i%K==0){
      res = "OK";
      break;
    }
  }
  
  cout << res << endl;
}

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

public class Main {


    public static void main(String[] args) throws Exception {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String s = in.readLine();
        if(s.equals("ARC")) {
            System.out.println("ABC");
        } else {
            System.out.println("ARC");
        }
    }

}


Measured memory_bytes: 25256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
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;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a == b)
        cout << a + b << endl;
    else
        cout << max(a, b) * 2 - 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#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;
using namespace std::chrono;

#define ll long long
#define ld long double
#define pq priority_queue
#define ff first
#define ss second
#define pb push_back
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(c) ((ll)c.size())
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MOD1 998244353
#define MOD2 1000000007

#ifdef LL
const ll INF = 1e18;
#else 
const ll INF = 1e9;
#endif

typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

high_resolution_clock::time_point setTime() { return high_resolution_clock::now(); }
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);} //Just add this as a third argument to sort() while sorting an array of pairs; NO NEED FOR ANY ARGUMENTS;
template <typename T>
T fact(T a, T mod){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=mod;} return res; }
template <typename T>
ll powmod(T a,T b,ll m){ ll ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
ll power(T a, T b){ ll ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}
template <typename T>
T max3(T a, T b, T c) { return max((max(a,b), max(b,c))); }
template <typename T>
T min3(T a, T b, T c) { return min((min(a,b), min(b,c))); }
template <typename T>
T mid3(T a, T b, T c) { return a+b+c-max3(a,b,c)-min3(a,b,c); }
template <typename T>
T mid(T a, T b) { return min(a,b)+((max(a,b)-min(a,b))/2); }
template <typename T>
T gcd(T a,T b){ return (b?__gcd(a,b):a); }
template <typename T>
T lcm(T a, T b){ return (a*(b/gcd(a,b))); }
template <typename T>
T cl(T a, T b){ return (a+b-1)/b; }
template <typename T>
T to_upper(T s){ return transform(s.begin(), s.end(), s.begin(), ::toupper); }
template <typename T>
T to_lower(T s){ return transform(s.begin(), s.end(), s.begin(), ::tolower); }

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    auto startTime = setTime();

    int n;
    cin>>n;

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

    ld dp[n+1][n+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<n+1;j++) dp[i][j]=0;
    }
    for(int i=1;i<=n;i++) dp[i][0] = 1-p[i-1];
    dp[0][0]=1;

    for(int i=1;i<=n;i++)
    {
        dp[i][0] = dp[i-1][0]*(1-p[i-1]);
        for(int j=1;j<=n;j++)
        {
            dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
        }
    }

    ld ans=0.0;
    
    for(int i=n/2+1;i<=n;i++)
    {
        ans+=dp[n][i];
    }

    cout<<setprecision(10)<<ans<<endl;
    auto stopTime = setTime();
    auto duration = duration_cast<microseconds>(stopTime - startTime);
    //cout<<"Program ran for "<<(ld)duration.count()/1e6<<" "<<"seconds"<<endl;
}


Measured memory_bytes: 144388
while gets
a=$_.split.map(&:to_i)
b=gets.split.map(&:to_i)
c,d=0,0;
4.times{|i|
c+=1 if a[i]==b[i]
d+=1 if b.find{|j|j==a[i]}&&a[i]!=b[i]
}
print c," ",d,"\n"
end

Measured memory_bytes: 8620
#include <iostream>
#include <vector>

int main()
{
    int N;
    std::cin >> N;

    std::vector<int> A(N);
    for (int i = 0; i < N; i++) {
        std::cin >> A[i];
    }

    int max = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            max = std::max(max, abs(A[i] - A[j]));
        }
    }
    std::cout << max << std::endl;
    return 0;
}


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

long long gcd(int x,int y){
    if(x<y){return gcd(y,x);}
    else if(y==0){return x;}
    else{
        gcd(y,x%y);
    }
}

int main(){
    long long a,b;cin>>a>>b;
    //long long ans = lcm(a,b);
    long long ans = a/gcd(a,b)*b;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
ans=0
U = UnionFind(n)
for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  U.union(a,b)
print(U.group_count()-1)

Measured memory_bytes: 75136
using System;
using static System.Console;

namespace TestField
{
    class Program
    {
        static void Main(string[] args)
        {
            string b = ReadLine();
            if (b == "A" || b == "T")
            {
                WriteLine(b == "A" ? "T" : "A");
            }
            else
            {
                WriteLine(b == "C" ? "G" : "C");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
    int n;
    int old;
    int num[7];

    while (cin >> n) {
        if (!n)
            break;

        for (int i = 0; i < 7; i++)
            num[i] = 0;

        for (int i = 0; i < n; i++) {
            cin >> old;

            for (int j = 60; j >= 0; j -= 10)
                if (old >= j) {
                    num[j / 10]++;
                    break;
                }
        }
    
        for (int i = 0; i < 7; i++) 
            cout << num[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<long int>v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	vector<long int>dp(n,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
		{
			if(j<n)
			dp[j]=min(dp[j],dp[i]+abs(v[i]-v[j]));
		}
	}
	cout<<dp[n-1]<<endl;
}

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

using namespace std;

const int MAXN = 1000;

int A[MAXN+1];
int main()
{
    int n,ans = 0, cnt=1;
    scanf("%d",&n);

    for(int i=1;i<=n;i++)
        scanf("%d",&A[i]);

    for(int i=1;i<=n;i++)
    {
        if(A[i]!=A[i-1]){
            ans+=cnt/2; cnt = 1;
        }

        else cnt++;
    }
    ans+=cnt/2;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 384
N = int(input())
fs = [list(map(int,input().split())) for i in range(N)]
ps = [list(map(int,input().split())) for i in range(N)]

INF = float('inf')
ans = -INF
for b in range(1,2**10):
    tmp = 0
    for f,p in zip(fs,ps):
        c = 0
        for k in range(10):
            if b&(1<<k)==0: continue
            if f[k]: c += 1
        tmp += p[c]
    ans = max(ans, tmp)
print(ans)

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

int main()
{
	string s;
	cin>>s;
	ll n=s.length(),f=0;
	if(n%2!=0)
	{
		f=1;
	}
	else
	{
	for(ll i=0;i+1<n;i=i+2)
	{
		if(s[i]!='h' || s[i+1]!='i')
		{
		f=1;
		break;
		}
	}
	}
	if(f==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	cout<<"No"<<endl;
}

Measured memory_bytes: 256