akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

static inline int in()
{
	int n = 0, c = getchar_unlocked();
	do {
		n = 10 * n + c - '0';
		c = getchar_unlocked();
	} while (c >= '0');
	return n;
}

int main()
{
	int C = 0, n = in(), q;
	int S[n];

	for (int &x: S)
		x = in();

	int *e = S + n;
	q = in();
	while (q--)
		if(binary_search(S, e, in()))
			C++;

	printf("%d\n", C);
}



Measured memory_bytes: 2968
#include<iostream>
#include<vector>
using namespace std;

int ans;
int H,W,C;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

void change(vector<vector<int> > &panels,vector<vector<bool> > &done,int x,int y,int color,int before_color){
	if(x<0 || y<0 || x>=W || y>=H) return;
	if(done[y][x]) return;
	done[y][x]=true;
	if(panels[y][x]!=before_color) return;
	panels[y][x]=color;
	for(int r=0;r<4;r++){
		change(panels,done,x+dx[r],y+dy[r],color,before_color);
	}
}

void count(vector<vector<int> > &panels,vector<vector<bool> > &done,int x,int y,int &num){
	if(x<0 || y<0 || x>=W || y>=H) return;
	if(done[y][x]) return;
	done[y][x]=true;
	if(panels[y][x]==C) num++;
	else return;
	for(int r=0;r<4;r++){
		count(panels,done,x+dx[r],y+dy[r],num);
	}
}

void check(int time,vector<vector<int> > panels){
	if(time==5){
		int num=0;
		vector<vector<bool> > done(H,vector<bool>(W,false));
		count(panels,done,0,0,num);
		ans=max(ans,num);
		return;
	}
	for(int color=1;color<=6;color++){
		if(time==4 && color!=C) continue;
		vector<vector<bool> > done(H,vector<bool>(W,false));
		vector<vector<int> > copy=panels;
		change(copy,done,0,0,color,copy[0][0]);
		check(time+1,copy);
	}
}

int main()
{
	while(cin>>H>>W>>C){
		if(H==0) return 0;
		vector<vector<int> > panels(H,vector<int>(W));
		for(int y=0;y<H;y++){
			for(int x=0;x<W;x++){
				cin>>panels[y][x];
			}
		}
		ans=0;
		check(0,panels);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int n,i;
char s[101],t[101];
int main()
{
	scanf("%d",&n);
	scanf("%s%s",s,t);
	for(i=0;i<n;++i)
	    printf("%c%c",s[i],t[i]);
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder_20190218
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');


            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);

            int result = 0;
            if(B%A==0)
            {
                result = A + B;
            }
            else
            {
                result = B- A;
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,i,x,a=2,b=1;
	cin>>n;

	if(n==0)
	{
		cout<<a<<endl;
		return 0;
		
	}
	if(n==1)
	{
		cout<<b<<endl;
		return 0;
	}	
	n=n-1;
	for(i=0;i<n;i++)
	{
	x=a+b;
	a=b;
	b=x;
	}
	cout<<x<<endl;
	
}

Measured memory_bytes: 3600
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int r[3];
    r[0]=a+b;
    r[1]=a-b;
    r[2]=a*b;
    int max=r[0];
    for(int i=1;i<3;i++)
    {
        if(r[i]>max)
            max=r[i];
    }
    cout<<max<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
   int i,j,n,a[1000],b[1000];
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%d",&a[i]);
   }
   for(j=0;j<n;j++){
      b[j]=a[n-j-1];
   }
   for(i=0;i<n;i++){
      printf("%d",b[i]);
      if(i!=n-1){
         printf(" ");
      }
   }
   printf("\n");
   return 0;
}

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

A = list(range(1,N+1))
B =[]
for i in A:
    if (i%3==0) and (i%5==0):
        t = 0
    elif (i%3==0):
        t = 0
    elif (i%5==0):
        t = 0
    else:
        t = i 
    B.append(t)
print(sum(B))



Measured memory_bytes: 56448
#include<stdio.h>
#include<math.h>
int main(){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(a>0 && c>0){
        c = c - b;
        if(c<=0)break;
        a = a - d;
    }
    if(a<=0)printf("No");
    else printf("Yes");
    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

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;}

int main(){
    string s;
    cin >> s;
    set<char> st;
    for(int i=0;i<s.size();i++){
        st.insert(s[i]);
    }
    if(s.size()==st.size()) cout << "yes" << endl;
    else cout << "no" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,x,y,n;
	x=0;
	y=0;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a>=b && a>=c){
		x=a;
		y=b+c;
	}
	if(b>=a && b>=c){
		x=b;
		y=a+c;
	}
	if(c>=a && c>=b){
		x=c;
		y=a+b;
	}
	if(x==y) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pii pair<int,int>
#define pll pair<lli, lli>
#define vi  vector<int>
#define vii vector<pair<int,int>>
#define vll vector<lli>
#define pb  push_back
#define mpr  make_pair
#define ss  second
#define ff first
#define INF 1000000001
#define inf1 1000000000000000001
#define pie 3.14159265358979323846264338327950L
#define all(x) x.begin(),x.end()
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define testcase() int tc;cin>>tc;while(tc--)
#define clean(x) memset(x,0,sizeof(x))
const lli maxn = 300000+5;
const lli mod= 1000000007;
vector<lli> catlan(int n) {
    vector<lli> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;
    for (int i = 2; i <= n; i ++) {
        for (int j = 0; j < i; ++ j) {
            dp[i] += dp[j] * dp[i - j - 1];
        }
    }
    return dp;
}
lli digit(lli n){int res=(int)log10(n)+1;return res;}
lli lcm(lli a,lli b){lli ans=(a*b)/(__gcd(a,b));return ans;}
lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}
lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}
lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}
lli set_bits(lli n)
{
    int c=0;
    if(n==0)return 0;
    while(n)
    {
        if((n&1)==1)
        {
           cout<<c<<" ";
        }
        c++;
        n=n>>1;
    }
    return c;
}

lli inf = 5e17;
///=================== ALWAYS CHECK 1 or 0 base case=================================================================================///
///------------------ALWAYS lli-----TEMP TSF99--------------------------------------------------------------------------------------//


void solve()
{
    int n;cin>>n;
    lli res=power(10,n);
    res=(res-power(9,n)-power(9,n)+power(8,n))%mod;
    if(res<0)res+=mod;
    res=res%mod;
    cout<<res<<endl;
}
int main()
{
    solve();
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll a, b, n;
	cin >> a >> b >> n;
	ll x = min(b-1, n);
	cout << (a * x) / b - a * (x / b);

	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n, k;
    cin >> n >> k;

    ll res = 0;
    // N = p * b + r とする
    // 0, 1, 2, ... b-1, 0, 1, 2...の繰り返し
    for(ll b = 1; b <= n; ++b) {
        if (k >= b) continue;
        ll p = n / b;
        ll r = n % b;
        res += p * max(0ll, b - k) + max(0ll, r + 1 - k);
    }

    // k = 0の時は、a = 0がn個分(b = 1...n)含まれるので除く
    if (k == 0) res -= n;
    cout << res << endl;

    return 0;
}

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

struct box {
	int cost;
	bool flag;
};

#define dprintf(arg1, ... ) printf( arg1, __VA_ARGS__)
//#define dprintf(arg1, ... ) 


char* replnext( char** ppos ) {
	char* oldpos = *ppos;
	*ppos = strchr( *ppos, ' ' );
	if ( *ppos == NULL ) { return oldpos; }
	**ppos = '\0';
	(*ppos)++;
	return oldpos;
}

int main(void) {
	
	while(1) {
		int width, height;
		scanf("%d %d\n", &width, &height);
		if ( width == 0 && height == 0 ) { break; }
		
		struct box map[30/*h*/][30/*w*/];
		unsigned char tatekabe[30][31];
		unsigned char yokokabe[31][30];
		
		char buf[256];
		
		for ( int loo=0; loo< (height*2 - 1); loo++ ) {
			int i = loo/2;
			
			fgets(buf, 256, stdin);
			*(strchr(buf, '\n')) = '\0';
			char* pos = buf;
			
			if ( loo % 2 == 0 ) {
				//tatekabe
				tatekabe[i][0] = 1;
				tatekabe[i][width] = 1;
				
				if ( buf[0] == ' ') { replnext(&pos); }
				for ( int loo2 = 1; loo2 < width; loo2++ ) {
					tatekabe[i][loo2] = atoi( replnext(&pos) );
				}
			} else {
				//yokokabe
				for ( int loo2 = 0; loo2 < width; loo2++ ) {
					yokokabe[i+1][loo2] = atoi( replnext(&pos) );
				}
			}
		}
		
		for ( int loo=0; loo<width; loo++ ) {
			for ( int loo2 = 0; loo2<height; loo2++ ) {
				map[loo2][loo].cost = INT_MAX;
				map[loo2][loo].flag = false;
			}
			yokokabe[0][loo] = 1;
			yokokabe[height][loo] = 1;
		}
		//yokokabe[0][0] = 0;
		//yokokabe[height][width-1] = 0;
		
		map[0][0].cost = 0;

		while(1) {
			int min_x = -1, min_y = -1;
			int minval = INT_MAX;
			for ( int loo=0; loo<width; loo++ ) {
				for ( int loo2 = 0; loo2<height; loo2++ ) {
					if ( map[loo2][loo].cost == -1 ) { continue; }
					if ( map[loo2][loo].flag == true ) { continue; }
					if ( map[loo2][loo].cost < minval ) {
						min_x = loo;
						min_y = loo2;
						minval = map[loo2][loo].cost;
					}
				}
			}
			if ( min_x == -1 && min_y == -1 ) { break; }

			map[min_y][min_x].flag = true;

			//up
			if ( yokokabe[min_y][min_x] == 0 && map[min_y-1][min_x].cost > map[min_y][min_x].cost +1 ) {
				map[min_y-1][min_x].cost = map[min_y][min_x].cost + 1;
			}

			//down
			if ( yokokabe[min_y+1][min_x] == 0 && map[min_y+1][min_x].cost > map[min_y][min_x].cost +1 ) {
				map[min_y+1][min_x].cost = map[min_y][min_x].cost + 1;
			}

			//left
			if ( tatekabe[min_y][min_x] == 0 && map[min_y][min_x-1].cost > map[min_y][min_x].cost +1 ) {
				map[min_y][min_x-1].cost = map[min_y][min_x].cost + 1;
			}

			//right
			if ( tatekabe[min_y][min_x+1] == 0 && map[min_y][min_x+1].cost > map[min_y][min_x].cost +1 ) {
				map[min_y][min_x+1].cost = map[min_y][min_x].cost + 1;
			}
		}

		if ( map[height-1][width-1].cost == INT_MAX ) { puts("0"); }
		else { printf("%d\n", map[height-1][width-1].cost+1 ); }

		/*
		for ( int loo2 = 0; loo2<height; loo2++ ) {
			for ( int loo=0; loo<width; loo++ ) {
				printf("%d ", map[loo2][loo]);
			}
			printf("\n");
		}
		*/
	
	}
	return 0;
}

Measured memory_bytes: 780
N,K,Q = map(int,input().split())
A = [int(input()) for i in range(Q)]
score = []
for i in range(N):
    score.append(K-Q)

for i in A:
    score[i-1] += 1

for i in range(N):
    if score[i] <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 11776
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
string s;
int main()
{
  cin>>s;
  int r=0,b=0;
  int len=s.size();
  for(int i=0;i<len;i++)
  {
      if(s[i]=='0')r++;
      else b++;
  }
  int res=min(r,b);
  printf("%d\n",2*res);
}


Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n;cin>>n;
  vector<ll> A(n+1), S(n+2,0);
  rep(i,n+1){
    cin>>A[i];
  }
  REP(i,n+1){
    S[i] = S[i+1] + A[i];
  }

  vector<ll> D2(n+1);
  D2[0] = 1;
  rep(i,n){
    D2[i+1] = min(D2[i] * 2, LINF);
  }

  ll a = min({S[0], D2[0], (ll)1});
  ll ans = 0;
  rep(i,n+1){
    if(a == 0){
      cout<<-1<<endl;
      return 0;
    }
    if(a < A[i]){
      cout<<-1<<endl;
      return 0;
    }
    ans += a;
    if(i == n+1){
      break;
    }
    a -= A[i];
    a = min({S[i+1], D2[i+1], a*2});
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  priority_queue<ll> que;
  rep(i, n) { 
    ll temp;
    cin >> temp;
    que.push(temp);
  }

  rep(i, m) {
    ll temp = que.top();
    que.pop();
    que.push(temp/2);
  }
  ll ans = 0;
  while (!que.empty()) {
    ans += que.top();
    que.pop();
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

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

        boolean result =
                (N%1000)%111 == 0 || (N/10)%111 == 0 ;

        System.out.println(result ? "Yes":"No");
        }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define mp make_pair

#define F first
#define S second

using ll = long long;
using namespace std;

void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }

const int mod = 1000000007;
const int INF = 1e+9;

int main() {
    string s; cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
long long mod = 1e9 + 7;
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> stone;
	vector<int>color[200004];
	long long dp[200004] = { 0 };
	int n;
	cin >> n;
	int a[200004];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	stone.push_back(a[0]);
	color[a[0]].push_back(0);
	for (int i = 1; i < n; i++) {
		if (a[i] != a[i - 1]) {
			stone.push_back(a[i]);
			color[a[i]].push_back(stone.size() - 1);
		}
	}
	dp[0] = 1;
	for (int i = 0; i < stone.size()-1; i++) {
		dp[i + 1] += dp[i];
		dp[i + 1] %= mod;
		auto num = upper_bound(color[stone[i]].begin(), color[stone[i]].end(), i);
		if (num != color[stone[i]].end()) {
			dp[*num] += dp[i];
			dp[*num] %= mod;
		}
	}
	cout << dp[stone.size() - 1];
}

Measured memory_bytes: 14324
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;


int main(){
    ll n,k; cin>>n>>k;
    vector<ll>d(k);
    vector<bool>b(10,false);
    rep(i,k){
        cin>>d[i];
        b[d[i]]=true;
    }
    bool jud;
    for(ll i=n;;i++){
        ll nn=i;
        jud=true;
        while(nn>0){
            if(b[nn%10]){
                jud=false;
                break;
            }
            nn/=10;
        }
        if(jud){
            cout<<i<<endl;
            return 0;
        }
    }
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std;
static const int INF = 1ll<<60;
static const int mod = 1e9+7;
static const int dx[] = {0,0,1,-1};
static const int dy[] = {1,-1,0,0};
typedef pair< int,int > PII;
typedef pair< int,pair<int,int> > PPII;

int N;
int A[100005];

int F[100005];
int P=1;
int Q;
int R=1;

signed main(){
    cin>>N;
    for(int i=0;i<N;++i){
        cin>>A[i];
        F[A[i]]++;
        if(F[A[i]]==1&&A[i]!=0){
            //cout<<A[i]<<endl;
            P*=2;
            P%=mod;
        }
        int p=(A[i]+N-1)/2+1;
        int q=N-p+1;
        if(F[A[i]]>=3||abs(p-q)!=A[i]||F[0]>=2){
            //cout<<p<<" "<<q<<" "<<A[i]<<endl;
            cout<<0<<endl;
            return 0;
        }
    }
    for(int i=0;i<N;++i){
        if(F[A[i]]==0)Q++;
        Q%=mod;
    }
    for(int i=1;i<=Q;++i){
        R*=i;
        R%=mod;
    }
    //cout<<P<<" "<<R<<endl;
    cout<<(R*P)%mod<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	int n;
	cin >> n;


	if (n % 2 == 0) {

	cout << n/2 << endl;
	}
	else {
		cout << n / 2 + 1 << endl;

	}

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int N,K,result = 0;
    int h[100000];
    scanf("%d %d",&N,&K);
    for(int i = 0;i < N;i++)scanf("%d",&h[i]);
    for (int i = 0; i < N; i++)if(h[i] >= K)result++;
    printf("%d",result);
    return 0;
}

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

using namespace std;

int main() {
    string s;

    cin >> s;

    int ans = 0;

    for (int i = 1; i < s.size(); i++) {
        if (s[i] != s[i-1]) {
            ans++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 512
n=int(input())
s=input()
l=list(s.split())
sum1=0
sum2=0
for i in range(0,n):
    sum1=sum1+int(l[i])
    sum2=sum2+(int(l[i])*int(l[i]))
ans=((sum1**2)-sum2)//2
ans=ans%1000000007
print(ans)


Measured memory_bytes: 95184
import sys
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    S = in_s()
    _ = in_s()

    mod = 1000000007

    gr = itertools.groupby(S)
    domino = []
    for k, v in gr:
        domino.append(len(list(v)))

    if domino[0] == 1:
        ans = 3
    else:
        ans = 6

    for i in range(len(domino) - 1):
        if domino[i] == 1 and domino[i + 1] == 1:
            ans *= 2
        elif domino[i] == 1 and domino[i + 1] == 2:
            ans *= 2
        elif domino[i] == 2 and domino[i + 1] == 1:
            pass
        elif domino[i] == 2 and domino[i + 1] == 2:
            ans *= 3
        ans %= mod

    print(ans % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
ll sz, arr[600005], dp[600005];
int main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
freopen("outd.txt", "rt", stdin);
#endif*/
  // code
  for (int i = 0; i <= 500005; i++) {
    dp[i] = 10000000;
  }
  cin >> sz;
  forn(sz) { cin >> arr[i]; }
  dp[1] = 0LL;
  dp[2] = abs(arr[1] - arr[2]);
  forn(sz) {
    dp[i + 1] = min(dp[i] + abs(arr[i] - arr[i + 1]), dp[i + 1]);
    dp[i + 2] = abs(arr[i + 2] - arr[i]) + dp[i];
  }
  cout << dp[sz];
// endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (b) - 1; i >= (a); --i)
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " "
#define endl '\n'
#define pw(x) (1ll<<(x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x. size()
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N=20;
char s[N];

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

    while(cin>>s+1)
    {
        int l=strlen(s+1);
        bool f=0;
        rep(i,1,l+1)
        {
            if((i&1)&&s[i]!='h')f=1;
            if(!(i&1)&&s[i]!='i')f=1;
        }
        if(l&1)f=1;
        if(f)cout<<"No\n";
        else cout<<"Yes\n";
    }

    return 0;
}


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

bool isPrime(int n) {
	if( n==2)
		return true;
	if( n<2 || n%2 == 0)
		return false;
	int i = 3;
	while( i<= sqrt(static_cast<double>(n)) )
	{
		if(n%i == 0)
			return false;
		i += 2;
	}
	return true;
}

int main() {
	int n;
	cin >> n;
	int suuti;
	int counter = 0;
	for(int i =0; i<n; i++) {
		cin >> suuti;
		if(isPrime(suuti))
			counter++;
	}
	cout << counter << endl;

}


Measured memory_bytes: 3092
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
using namespace std;

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

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=998244353;
const int maxn=1e6+9;
const int maxx=1e9+9;



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


Measured memory_bytes: 3192
//file_name:ABC78_D.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    ll n,z,w;
    scanf("%lld%lld%lld",&n,&z,&w);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    ll ans = 0;

    if(n==1){
        ans = abs(a[n-1]-w);
        cout << ans << endl;
        return 0;
    }

    ans = max(abs(a[n-1]-w),abs(a[n-1]-a[n-2]));

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



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

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

    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    const int INF = 1001001001;
    vector<vector<int>> dp(n, vector<int>(22000, INF));
    dp[0][0] = 0;
    rep(j, 22000){
        if(j%a[0] == 0) dp[0][j] = b[0] * (j/a[0]);
    }

    rep1(i, n) rep(j, 22000){
        if(j < a[i]) dp[i][j] = dp[i-1][j];
        else dp[i][j] = min(dp[i-1][j], dp[i][j-a[i]] + b[i]);
    }

    int res = INF;
    for(int i = h; i < 22000; ++i){
        if(dp[n-1][i] != INF){
            res = min(res, dp[n-1][i]);
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 86400
from collections import deque

S = input()
Q = int(input())
d = deque(list(S))
tf = 1

for i in range(Q):
    Queryi = list(map(str, input().split()))
    if Queryi[0] == '1':
        tf *= -1
    else:   #Queryi[0] == '2'
        if tf == 1:
            if Queryi[1] == '1':
                d.appendleft(Queryi[2])
            else: #Queryi[1] == '0'
                d.append(Queryi[2])
        else: #tf = -1
            if Queryi[1] == '1':
                d.append(Queryi[2])
            else: #Queryi[1] == '1'
                d.appendleft(Queryi[2])

if tf == -1:
    d.reverse()

print(''.join(d))

Measured memory_bytes: 8676
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();
		sc.close();

		if (S.equals(U)) {
			A = A - 1;
		} else {
			B = B - 1;
		}
		System.out.println(A + " " + B);
	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, n) for (ll(i) = 0; i < (ll)(n); ++(i))
#define INF 10e12
#define MOD 1000000000 + 7
#define MX 51000
#define all(x) (x).begin(), (x).end()
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))

using namespace std;

struct nap
{
    ll w;
    ll v;
};

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, W;
    cin >> N >> W;
    ll takadaka = 1000 * N + 1;
    vector<ll> w(N);
    vector<ll> v(N);
    for (ll i = 0; i < N; ++i)
        cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N + 1, vector<ll>(takadaka + 1, INF));
    dp[0][0] = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int sum_v = 0; sum_v < takadaka; ++sum_v)
        {

            // i 番目の品物を選ぶ場合
            if (sum_v >= v[i])
                dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - v[i]] + w[i]);

            // i 番目の品物を選ばない場合
            else
                dp[i + 1][sum_v] = dp[i][sum_v];
        }
    }

    // 最適値の出力
    long long res = 0;
    for (int sum_v = 0; sum_v < takadaka; ++sum_v)
    {
        if (dp[N][sum_v] <= W)
            res = sum_v;
    }
    cout << res << endl;
}


Measured memory_bytes: 80384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    string s;
    cin>>s;
    int l=s.length();
    for(int i=0;i<l;i++){
        for(int j=0;j<i;j++){
            if(s[i]==s[j]){
                cout<<"no"<<endl;
                return 0;
            }
        }
    }
    cout<<"yes"<<endl;
    return 0;
}



Measured memory_bytes: 256
s = input()
s = s[::-1]
j = 0
p = len(s)
while True:
    if s[j:j+5] == 'maerd':
        j += 5
    elif s[j:j+7] == 'remaerd':
        j += 7
    elif s[j:j+5] == 'esare':
        j += 5
    elif s[j:j+6] == 'resare':
        j += 6
    else:
        print('NO')
        break
    if j == p:
        print('YES')
        break

Measured memory_bytes: 9220
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;

int k;
ll ruiseki(int x, int y, vector<vector<int>>& a) {
	return a[x + k][y + k] + a[x][y] - a[x + k][y] - a[x][y + k];
}

int main() {
	int n; cin >> n >> k;
	vector<vector<int>> a(2 * k),sum(4*k);
	rep(i, 0, 2 * k) a[i].resize(2 * k, 0);
	rep(i, 0, 4 * k) sum[i].resize(4 * k, 0);
	rep(i, 0, n) {
		int x, y; string p;
		cin >> x >> y >> p;
		if (p == "W")y += k;
		x %= (2 * k); y %= (2 * k);
		a[x][y]++;
	}
	rep(i, 0, 4 * k-1)rep(j, 0, 4 * k-1) {
		sum[i + 1][j + 1] = sum[i + 1][j] + a[i % (2 * k)][j % (2 * k)];
	}
	rep(i, 0, 4 * k - 1)rep(j, 0, 4 * k - 1) {
		sum[j + 1][i + 1] += sum[j][i + 1];
	}
	ll ans = 0;
	rep(i, 0, 2 * k)rep(j, 0, 2 * k) {
		ans = max(ans, ruiseki(i, j, sum) + ruiseki(i + k, j + k, sum));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 78592
#define loop(i, s, e) for(ll i = s;i < e;i++)

#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>
//#include "vector2d.cpp"

using namespace std;
//using namespace libcgl;
typedef long long signed ll;

ll n, a[100002];

int main() {
    cin >> n;
    loop(i, 1, n+1) { cin >> a[i]; }
    ll dist = 0;
    loop(i,1,n+2) {
        dist += abs(a[i] - a[i-1]);
    }
    loop(i, 1, n+1) {
        if( (a[i-1] - a[i]) * (a[i+1] - a[i]) < 0) cout << dist << endl;
        else cout << dist + abs(a[i-1] - a[i+1]) - abs(a[i-1] - a[i]) - abs(a[i+1] - a[i]) << endl;
    }
}



Measured memory_bytes: 2556
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
const ll mod=1000000007;
const ll INF=1e15;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back

int main(){
    char x; cin>>x;
    x++;
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<utility>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> piii;

void print(piii p){
	if(p.first.first<10)cout<<0<<p.first.first;
	else cout<<p.first.first;
	cout<<":";
	if(p.first.second<10)cout<<0<<p.first.second;
	else cout<<p.first.second;
	cout<<":";
	if(p.second<10)cout<<0<<p.second<<endl;
	else cout<<p.second<<endl;
}

int main(){
	int h,m,s,rh,rm,rs,res=120*60;
	piii ans[2];
	while(1){
		scanf("%d %d %d",&h,&m,&s);
		if(h==-1 && m==-1 && s==-1)break;
		res=120*60-(h*60*60+m*60+s);
		rh=res/3600;
		res%=3600;
		rm=res/60;
		res%=60;
		rs=res;
		ans[0]=piii(pii(rh,rm),rs);
		res=120*60-(h*60*60+m*60+s);
		res*=3;
		rh=res/3600;
		res%=3600;
		rm=res/60;
		res%=60;
		rs=res;
		ans[1]=piii(pii(rh,rm),rs);
		print(ans[0]);
		print(ans[1]);
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
// template<class T> T gabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    for (int i = 0; i < 3; ++i) {
        reverse(begin(s[i]), end(s[i]));
    }
    int t = 0;
    while (!s[t].empty()) {
        char c = s[t].back();
        s[t].pop_back();
        if (c == 'a') t = 0;
        if (c == 'b') t = 1;
        if (c == 'c') t = 2;
    }
    cout << "ABC"[t] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define mod 1000000007
#define PI 3.1415926535
using namespace std;
ll power(ll x, ll y)
{
	if (y == 0)
		return 1;
	else if (y % 2 == 0)
		return power(x, y / 2) * power(x, y / 2);
	else
		return x * power(x, y / 2) * power(x, y / 2);
}
ll modExpo(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return modExpo((x*x)%mod,n/2);
    else                            
        return (x*modExpo((x*x)%mod,(n-1)/2))%mod;

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	ll n,k;
	cin>>n>>k;
	ll i,a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	ll dp[n];
	for(i=0;i<n;i++)
		dp[i]=INT_MAX;
	dp[0]=0;
	for(i=1;i<n;i++)
	{
		for(ll j=1;i-j>=0 && j<=k;j++)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
	}
	cout<<dp[n-1]<<endl;
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


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

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

using namespace std;

int main(){
  int x,y,s;
  while( cin >> x >> y >> s, x|y|s ){
    int maxi = 0;
    for(int p1=1;p1<s;p1++){
      for(int p2=p1;p2<s;p2++){
        int np1 = p1 * ( 100 + x ) / 100.0;
        int np2 = p2 * ( 100 + x ) / 100.0;
        if( np1 + np2 == s ) {
          np1 = p1 * ( 100 + y ) / 100.0;
          np2 = p2 * ( 100 + y ) / 100.0;
          maxi = max(maxi,np1+np2);
        }
      }
    }
    cout << maxi << endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
	char *tmp, *arr[101];
	int i,j,n=-1,ar[101], pos[101], temp;
	scanf("%d", &n);

	for(i=0; i<n; i++)
	{
		arr[i] = (char *)malloc(12*sizeof(char));
		scanf("%s %d", arr[i], &ar[i]);
	}
	for(i=0; i<=n; i++)
		pos[i] = i+1;
	for(i=0; i<n-1; i++)
		for(j=i+1; j<n; j++)
		{
			if(strcmp(arr[i], arr[j])>0)
			{
				tmp = arr[i];
				arr[i] = arr[j];
				arr[j] = tmp;

				temp = ar[i];
				ar[i] = ar[j];
				ar[j] = temp;

				temp = pos[i];
				pos[i] = pos[j];
				pos[j] = temp;
			}
			else if(strcmp(arr[i], arr[j])==0)
			{
				if(ar[i]<ar[j])
				{
					tmp = arr[i];
					arr[i] = arr[j];
					arr[j] = tmp;

					temp = ar[i];
					ar[i] = ar[j];
					ar[j] = temp;

					temp = pos[i];
					pos[i] = pos[j];
					pos[j] = temp;
				}
			}
		}
	/*for(i=0; i<n; i++)
	{
		printf("%s %d\n", arr[i], ar[i]);
	}*/
	for(i=0; i<n; i++)
	{
		printf("%d\n", pos[i]);
	}
	return 0;
}

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

mod = 10**9 + 7

if abs(n-m) >= 2:
    print(0)
else:
    dog = 1
    mon = 1
    
    for i in range(n,0,-1):
        dog *= i
        dog %= mod
        
    for i in range(m,0,-1):
        mon *= i 
        mon %= mod
        
    if abs(n-m) == 0:
        print(dog*mon*2%mod)
    else:
        print(dog*mon%mod)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int dp[100001][3];

int main(){
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif

    fast_io();
    
    int n;
    cin>>n;

    vector<vector<int > > a(n+1, vector<int>(3, 0));

    for(int i=0; i<n; i++){
        int x, y, z;
        cin>>x>>y>>z;

        a[i][0] = x;
        a[i][1] = y;
        a[i][2] = z;
    }

    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];

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

    cout<<max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2])<<"\n";

    return 0;

}
  

Measured memory_bytes: 9728
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void log(A...)(A arg) {
    stderr.writeln(arg);
}
int size(T)(in T s) {
    return cast(int)s.length;
}

class Graph {
    int V;
    int[][] g, rg;
    this(int V) {
        g = new int[][V];
        rg = new int[][V];
        this.V = V;
    }
    void addEdge(int from, int to) {
        g[from] ~= to;
        rg[to] ~= from;
    }
    /* ????????????????????????????????????????????? */
    int[] scc() {
        auto used = new bool[V];
        int[] vs;
        void dfs1(int v) {
            used[v] = true;
            foreach (u; g[v]) {
                if (used[u]) continue;
                dfs1(u);
            }
            vs ~= v;
        }
        void dfs2(int v, int k, int[] order) {
            used[v] = true;
            order[v] = k;
            foreach (u; rg[v]) {
                if (used[u]) continue;
                dfs2(u, k, order);
            }
        }
        foreach (v; 0 .. V) {
            if (used[v]) continue;
            dfs1(v);
        }
        used[] = false;
        int k = 0;
        auto ord = new int[V]; ord[] = -1;
        foreach_reverse (v; vs) {
            if (used[v]) continue;
            dfs2(v, k++, ord);
        }
        return ord;
    }
}

void main() {
    while (true) {
        int N; readf("%d\n", &N);
        if (N == 0) break;
        auto P = new real[N];
        auto g = new Graph(N);
        foreach (i; 0 .. N) {
            real p; int m; readf("%s %d", &p, &m);
            auto a = readln.strip.split(" ").map!((s) => s.to!int - 1);
            P[i] = p;
            foreach (x; a) {
                g.addEdge(i, x);
            }
        }
        auto ord = g.scc();
        auto used = new bool[N];
        void dfs(int v) {
            foreach (u; g.g[v]) {
                if (used[u]) continue;
                used[u] = true;
                dfs(u);
            }
        }
        real ans = 1.0;
        foreach (int k; 0 .. ord.reduce!max + 1) {
            foreach (i; 0 .. N) {
                if (ord[i] != k) continue;
                real p = 1.0;
                if (used[i]) continue;
                foreach (j; 0 .. N) {
                    if (ord[i] == ord[j]) {
                        p *= P[j];
                    }
                }
                ans *= 1.0 - p;
                used[i] = true;
                dfs(i);
            }
        }
        writefln("%.9f", ans);
    }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n), dp(n);
    
    for(int i = 0; i < n; i++)
        cin >> v[i];
	if(n == 1){
      cout << 1 ;
      return 0;
    }
    dp[0] = 0;
    for(int i = 1; i < min(k, n); i++)
        dp[i] = abs(v[i] - v[0]);
    
    int ans = INT_MAX;
    for(int i = k; i < n ; i++){
        int mini = INT_MAX;
        for(int j = 1; j <= k; j++){
            mini = min(mini, abs(v[i] - v[i-j]) + dp[i-j]);            
        }
        dp[i] = mini;
    }
    
    // for(auto x : dp)
    //     cout << x << " ";
    
    cout << dp[n-1];
}

Measured memory_bytes: 4068
//https://kimiyuki.net/writeup/algo/etc/icpc-2017-asia-c/　を参考
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,t;
int main()
{
    ll start=0;//生徒ごとの検査開始時刻.(h[i]を足していくだけで良い)
    ll interval=0;
    cin >> n >> t;
    ll student[n];
    ll resttime[n];
    ll h[n];
    memset(student,0,sizeof(student));
    memset(h,0,sizeof(h));
    for(int i=0;i<n;i++)
    {
        cin >> h[i];
        //長いintervalの影響を受けるのは,このi以降のインデックスの人のみ.
        //このiより前のインデックスの人は長いintervalの内にどんどん先の機械に移る事ができるので,
        //前のインデックスの人が後のインデックスの人のintervalに悩まされる事はない.
        interval=max(interval,h[i]);
        //確定で検査できる機械の番号は割り算で求める.
        student[i]=max(0LL,(t-start)/interval);
        //その後,intervalで割った時の余りの時間,あと1つの機械が使える.余りの時間がh[i]以上ならギリギリ1つ完了する.
        resttime[i]=(t-start)%interval;
        if(resttime[i]>=h[i]) student[i]++;
        //調整(出力は現在こなしている機械or"待っている"機械なので.)
        student[i]++;
        start+=h[i];
    }
    for(int i=0;i<n;i++)
    {
        cout << student[i] << endl;
    }

}


Measured memory_bytes: 5448
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,X;
cin>>N>>X;
vector<int>L(N);
int sum=0,cnt=1,num;
for(int i=0;i<N;i++){
    cin>>num;
    sum+=num;
    if(sum<=X)cnt++;
}
cout<<cnt;
return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

debug = False

# debug = True
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def dprint(*objects):
    if debug == True:
        print(*objects)

def solve():
    N = II()
    divisors = []

    sq = N**0.5
    nearest = -1

    for i in range(1, int(N**0.5)+1):
        if N % i == 0:
            divisors.append(i)
            if abs(sq - nearest) > abs(sq-i):
                nearest = i
    dprint(nearest, N//nearest)
    print((nearest-1)+(N//nearest)-1)
solve()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define mod 1000000009
#define int long long
#define garou ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
int pow(int p,int r){
	int ans=1;
	while(r>0){
     if(r&1){
		 ans=((ans%mod)*(p%mod))%mod;
	 }
	 r=r>>1;
     p=((p%mod)*(p%mod))%mod;
	}
}
signed main() {
	 garou;
	 int n;
	 cin>>n;
	 n%=10;
	 if(n==2||n==4||n==5||n==7||n==9)
	 cout<<"hon";
	 else if(n==0||n==1||n==6||n==8)
	 cout<<"pon";
	 else
	 {
		 cout<<"bon";
	 }
	 
}

Measured memory_bytes: 3564
N = int(input())
# A, B = map(int, input().split())
# A = list(map(int, input().split()))
# d = [list(map(int, input().split())) for _ in range(N)]
# s = input()

ans = 0
for j in range(1,N+1):
    count = 0
    if j % 2 == 0:
        continue
    for i in range(1,j+1):
        if (j % i) == 0:
            count += 1
    if count == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060