akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e6+3 ;


vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    k%=mod-1;
    if(k<0)k+=mod-1;
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int q;
    cin>>q;
    mod_build(mod-1);
    while(q--){
        ll x,d,n;
        cin>>x>>d>>n;
        if(d==0||x==0){
            cout<<powmod(x,n)<<endl;
            continue;
        }
        if(n>=mod){
            cout<<0<<endl;
            continue;
        }
        x=x*inv[d]%mod;
        ll ret=1;
        ret=ret*powmod(d,n)%mod;
        ll res;
        if(x+n-1<mod){
            res=fact[x+n-1]*invfact[x-1]%mod;
        }
        else res=0;
        cout<<res*ret%mod<<endl;
    }
    return 0;
}

Measured memory_bytes: 24320
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
int main(){
    int best[40]={0};
    bool flg[40]={0};
    map<int,int> m;
    int x,y;
    while(1){
        scanf("%d,%d",&x,&y);
        if(x==0&&y==0)break;
        m[x]=y;
        flg[y]=1;
    }
    int out=1;
    for(int i=30;i>=0;i--){
        if(flg[i]){
            best[i]=out;
            out++;
        }
    }
    while(cin>>x){
        cout<<best[m[x]]<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
	int n, w;
	cin >> n >> w;
	vector<int> v(n);
	vector<int> ww(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> ww[i];
	}
	vector<int> dp(w+1, 0);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j+ww[i] <= w; j++) {
			dp[j+ww[i]] = max(dp[j+ww[i]], dp[j]+v[i]);
		}
	}
	cout << dp[w] << endl;
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    for(int i=0; i<M; i++){
        cin >> A[i];
    }

    ll sum =0;
    for(int i=0; i<A.size(); i++){
        sum += A[i];
    }

    if(sum <= N){
        cout << N-sum << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3656
//  ROAD TO GREEN
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <queue>
#include <set>
#include <bitset>

#define ll long long
#define uint unsigned int
#define ull unsigned ll
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define speedhack() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define do(x) for(int i = 1; i <= x; i++){ solve(); }
#define s(x) x.size()

using namespace std;
const ll MAXN = 2e9+2;
const ll SIZE = 1e5+2;
const ll mod = 1e9+7;
int dp[SIZE];
int cnt[SIZE];


void solve(){
	int n; cin >> n;
	vector<int> v;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		v.push_back(x);
	}
	ll sum = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(i != j){
				sum += v[i]*v[j];
			}
		}
	}
	cout << sum/2 << endl;
}













int main(){
	speedhack()
	// int it; cin >> it;
	int it = 1;
	do(it);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

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

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll N, K;
vector< ll > A;

vector< ll > V1;
vector< ll > V2;

signed main()
{
  cin >> N >> K;
  A.resize(N + 1);
  REP(i, N)
  {
    ll ci;
    cin >> A[i + 1];
  }

  ll cnt = 0;
  ll i = 1;

  V1.resize(N + 1, -1);

  while (cnt < K)
  {
    if (V1[i] >= 0)
    {
      // すでにV[i]に訪れている場合
      // cnt + x(cnt - V[i]) 目は必ずiにテレポートする
      // 残りだけ数えればいい
      // printf("%lld, %lld, %lld, %lld\n", i, K, V1[i], cnt);
      if (K - cnt > 0)
      {
        K = (K - cnt) % (cnt - V1[i]);
        cnt = 0;
        V1.assign(N + 1, -1);

        if (K == 0)
        {
          break;
        }
      }
    }
    V1[i] = cnt;

    // テレポート
    ++cnt;
    i = A[i];
  }

  cout << i << endl;
}

Measured memory_bytes: 6404
#include<iostream>
#include<queue>

using namespace std;

int main() 
{
    long N,M;
    cin >>N>>M;

    priority_queue<long>A;
    for(long i=0;i<N;++i)
    {
        long a;
        cin>>a;
        A.push(a);
    }
    
    long ans=0;
    while(M>0)
    {
        --M;

        long target = A.top();
        A.pop();
        target /= 2;
        A.push(target);
    }
    while(!A.empty())
    {
        ans+=A.top();
        A.pop();
    }

    cout << ans << endl;    

    return 0;
}

Measured memory_bytes: 4240
#include <cstdio>
using namespace std;

long long lsum[50] = { 1, 5, 13, 29, 61, 125, 253, 509, 1021, 2045, 
4093, 8189, 16381, 32765, 65533, 131069, 262141, 524285, 1048573, 2097149, 
4194301, 8388605, 16777213, 33554429, 67108861, 134217725, 268435453, 536870909, 1073741821, 2147483645, 
4294967293, 8589934589, 17179869181, 34359738365, 68719476733, 137438953469, 274877906941, 549755813885, 1099511627773, 2199023255549, 
4398046511101, 8796093022205, 17592186044413, 35184372088829, 70368744177661, 140737488355325, 281474976710653, 562949953421309, 1125899906842621, 2251799813685245 };



int main()
{
	int N, i;
	long long X, ans = 0;
	scanf("%d %lld", &N, &X);
	long long curX = X;

	for (i = N-1; i > 0; i--)
	{
		if (curX == 1)
			break;
		else if (curX < 2 + lsum[i]) {
			curX--;
			continue;
		}
		else if (curX == 2 + lsum[i]) {
			ans += lsum[i-1] + 3;
			break;
		}
		else if (curX < 3 + 2 * lsum[i]) {
			ans += lsum[i-1] + 3;
			curX -= 2 + lsum[i];
			continue;
		}
		else{
			ans += 2 * lsum[i-1] + 5;
			break;
		}
	}

	if (i == 0) {
		if (curX == 1)
			;
		else if (curX < 5)
			ans += curX - 1;
		else
			ans += 3;
	}

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

	return 0;
}

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

typedef long long ll;
 
int main(){
	
//ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
		
char n[100],m[100];

	cin >> n;
	cin >> m;
	

cout << m << n << endl;
   
return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define lmin LONG_MIN
#define lmax LONG_MAX
#define imin ll_MIN
#define imax ll_MAX
#define ffor(i,a,b) for(i=a;i<b;i++)
#define bfor(i,a,b) for(i=a-1;i>=b;i--)
#define mset(f,a) memset(f,a,sizeof(f))
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAXN   10000009


ll mod = 1e9 +7;



int main() 
{
    ll t=1,temp;
    //cin>>t;
    ffor(temp,0,t)
    {
        fastio;
        ll a,b,c;
        cin>>a>>b>>c;
        if(b*c>=a)
            cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
    }
      
    
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main(void){
	string s,t;
	cin >> s >> t;

	const int n = s.size(), m = t.size();

	{
		bool can = false;

		rep(i,n-m+1){
			bool ok = true;
			rep(j,m){
				if(s[i+j]=='?') continue;
				if(s[i+j]!=t[j]) ok = false;
			}
			if(ok) can |= true;
		}

		if(can == false){
			puts("UNRESTORABLE");
			return 0;
		}
	}

	rep(k,n){
		if(s[k]!='?') continue;
		rep(c,26){
			s[k] = char(c+'a');
			bool can = false;
			rep(i,n-m+1){
				bool ok = true;
				rep(j,m){
					if(s[i+j]=='?') continue;
					if(s[i+j]!=t[j]) ok = false;
				}
				if(ok) can |= true;
			}
			if(can) break;
		}		
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	swapCount := 0
	for i := 0; i < n; i++ {
		minIndex := i
		for j := i; j < n; j++ {
			if a[j] < a[minIndex] {
				minIndex = j
			}
		}
		if a[i] > a[minIndex] {
			swapCount++
			a[i], a[minIndex] = a[minIndex], a[i]
		}
	}

	str := fmt.Sprint(a)
	fmt.Println(str[1:len(str)-1])
	fmt.Println(swapCount)
}

Measured memory_bytes: 1164
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# a, b, c, k = list(map(int, input().split()))
# a = list(map(int, input().split()))
# abc = [int(input()) for i in range(5)]
n = int(input())
# h1, m1, h2, m2, k = list(map(int, input().split()))
#a, b = list(map(float, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
# p = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# py = [list(map(int, input().split())) for i in range(m)]


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def pre(k):
    for divisor in range(2, math.floor(math.sqrt(k))+1):
        if k % divisor == 0:
            return False
    return True


def judge(z):
    if n % z != 0:
        return False
    elif pre(z):
        return True
    else:
        for i in range(2, z+1):
            if z % i == 0:
                a = 1
                while(a < z):
                    a *= i
                #print(a, end=" ")
                # print(z)
                if a == z:
                    return True
                else:
                    return False


data = make_divisors(n)
count = 0
for i in range(len(data)):
    if judge(data[i]):
        n /= data[i]
        count += 1
print(count-1)
# print(data)


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

using namespace std;
#define mx 200000
#define ll long long
char s[100002];
int ar[5][10002];
int main()
{


    ll n;

    cin>>n;

    for(ll i=0; i<=n; i++)
    {
        for(ll  j=0; j<=n; j++)
        {
            if( i*100+j*101>n)
                break;
            for(ll k=0; k<=n; k++)
            {
                if( i*100+j*101 + k* 102>n)
                    break;
                for(ll l=0; l<=n; l++)
                {
                    if( i*100+j*101>n +k*102+l*103>n)
                        break;
                    for(ll m=0; m<=n; m++)
                    {
                        if( i*100+j*101 + k*102 +l*103+m*104>n)
                            break;
                        for(ll p=0; p<=n; p++)
                        {
                            if( i*100+j*101 + k*102+l*103+m*104 + p*105>n)
                                break;

                            if(i*100+j*101 + k*102+l*103+m*104 + p*105==n)
                            {
                                cout<<1<<endl;
                                return 0;
                            }
                        }
                    }
                }
            }
        }
    }

    cout<<(0)<<endl;

    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
	
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		StringBuilder sb = new StringBuilder();
		
		String[] num = line.split(" ");
		int a = Integer.parseInt(num[0]);
		int b = Integer.parseInt(num[1]);
		
		int d = a/b;
		int r = a%b;
		String f = String.format("%.5f",((double)a / (double)b));
		
		sb.append(d).append(" ").append(r).append(" ").append(f).append("\n");
		System.out.print(sb);
	}
}

Measured memory_bytes: 24860
n = int(input())
h = list(map(int,input().split()))
h.append(0)
cnt = 0
maxh = max(h)
for i in range(maxh):
    point = -1
    for j in range(n+1):
        if j <= point:
            continue
        #print(h)
        for k in range(j+1,n+1):
            #print(h)
            if j <= point:
                continue
            if (h[j] != 0 and h[k] == 0):
                for l in range(j,k):
                    h[l] -= 1
                cnt += 1
                point = k
        #print(point)
            # if k == n-1:
            #     for l in range(j,k+1):
            #         if h[l] == 0 or l == k:
            #             cnt += 1
            #             break
            #         h[l] -= 1
                #cnt += 1
                #break
            # if max(h) == 0:
            #     print(cnt)
            #     exit()
    #print(h)
#print(h)
print(cnt)

Measured memory_bytes: 3064
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1),1):
    ans.append(i)
for i in range(b,max(a,b-k),-1):
    ans.append(i)
ans=list(set(ans)) #重複を削除
ans.sort() #ソート
for i in ans:
    print(i)

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

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        int N = nextInt();

        N %= 1000;
        
        if(N==0) N = 1000;

        System.out.println(1000 - N);

    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll A, B, V, W, T;
  cin >> A >> V;
  cin >> B >> W;
  cin >> T;
  if(V<=W)cout << "NO";
  else{
    if(abs(A-B)<=T*abs(V-W)){
      cout << "YES";
    }else{
      cout << "NO";
    }
  }
  return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define MAX_N 102

int a[MAX_N];

void dump(int n)
{
	int i;

	printf("%d", a[0]);
	for (i = 1; i < n; i++) printf(" %d", a[i]);
	putchar('\n');
}

void insertion_sort(int n)
{
	int i, j, key;

	dump(n);
	for (i = 1; i < n; i++) {
		key = a[i];
		j = i-1;
		while (j >= 0 && a[j] > key) a[j+1] = a[j], j--;
		a[j+1] = key;
		dump(n);
	}
}

int main()
{
	int N, i;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	insertion_sort(N);
	return 0;
}




Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using llong = long long;

void input(llong& rnCoordx, llong& rnTimes, llong& rnMovmnt)
{
  cin >> rnCoordx >> rnTimes >> rnMovmnt;
}
  
llong calcMinCoordx(llong nCoordx, llong nTimes, llong nMovmnt)
{
  llong nQuotnt = abs(nCoordx) / nMovmnt;
  llong nRemain = abs(nCoordx) % nMovmnt;

  if (nQuotnt <= nTimes)
    if (nQuotnt % 2 == nTimes % 2)
      return nRemain;
    else
      return abs(nRemain - nMovmnt);
  else
    return abs(nCoordx) - nTimes * nMovmnt;
}
  
int main()
{
  llong nCoordx, nTimes, nMovmnt;

  input(nCoordx, nTimes, nMovmnt);
  cout << calcMinCoordx(nCoordx, nTimes, nMovmnt) << endl;

  return 0;
}

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

int main(void){
  int A, B;
  int big, small;
  cin >> A >> B;
  big = max(A, B);
  small = min(A, B);
  for(int i = 0; i < big; i++){
    cout << small;
  }
}
  

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

main :: IO ()
main = do
  _ <- getLine
  as <- fmap (map read . words) getLine :: IO [Int]
  let (sorted, n) = bubbleSortC as
  putStrLn . unwords . map show $ sorted
  print n

bubbleSortC :: (Ord a) => [a] -> ([a], Int)
bubbleSortC [] = ([], 0)
bubbleSortC as = cons' (x, i) $ bubbleSortC $ xs
  where
    ((x:xs), i) = foldr bubble ([], 0) as

    bubble :: (Ord a) => a -> ([a], Int) -> ([a], Int)
    bubble x ([], i) = ([x], i)
    bubble x ((a:as), i)
      | a < x     = (a:x:as, i + 1)
      | otherwise = (x:a:as, i)

    cons' :: (Ord a) => (a, Int) -> ([a], Int) -> ([a], Int)
    cons' a b = let (x, i) = a
                    (xs, j) = b
                in (x:xs, i + j)



Measured memory_bytes: 3956
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


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


def solve():
    X = int(input())
    y = 0
    now = 100
    while now < X:
        now = now + (now // 100)
        y += 1
    
    print(y)


def main():
    solve()


if __name__ == '__main__':
    main()


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

int main() {
  string s;
  cin >> s;
  int ans=0;
  int x=s.length();
  int y=0;
  for (int i=0; i<s.length(); i++) {
    if (s[i]=='A') {
      x=min(x,i);
    }
    if (s[i]=='Z') {
      y=max(y,i);
    }
  }
  cout << y-x+1 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
#define PI  acos(-1)
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


signed main(){
  int N,K;cin>>N>>K;
  vector<int> arr(N),both(N,0);
  REP(i,0,N)cin>>arr[i];
  int ans=0;
  REP(i,0,N){
    int cnt1=0,cnt2=0;
    for(int j=0;j<i;j++){
      if(arr[j]>arr[i]){
        cnt1++;
      }
    }
    for(int j=0;j<N;j++){
      if(arr[j]>arr[i]){
        cnt2++;
      }
    }
    ans+=cnt1*K+(K*(K-1)/2)%MOD*cnt2%MOD;
    ans%=MOD;
  }
  print(ans);

}


Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    print("ABC" if input() == "ARC" else "ARC")
if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 9712
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++) if((i % 2 == 0 && j % 2 == 1) || (i % 2 == 1 && j % 2 == 0))cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

ll mod = 1e9 + 7;


int main(){
	string s,t;
	cin >> s >> t;

	cout << t << s <<  endl;
	

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

//?????\?????????
public class Main{

	public static void main(String[] args) throws Exception {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

		int n = readInt(r);
		String[] numArrayStr = r.readLine().split(" ");

		int[] numArrayInt = new int[n];
		for(int i = 0; i < n; i++){
			numArrayInt[i] = Integer.parseInt(numArrayStr[i]);
		}

		printBlank(numArrayInt);

		for(int y = 1; y < n; y++){
			int kijun = numArrayInt[y];
			int j = y - 1;
			while(j >= 0 && numArrayInt[j] > kijun){
				numArrayInt[j + 1] = numArrayInt[j];
				j--;
			}
			numArrayInt[j + 1] = kijun;
			printBlank(numArrayInt);
		}

	}

	public static int readInt(BufferedReader r) throws Exception{
        return Integer.parseInt(r.readLine());
    }

	public static void printBlank(int[] numArrayInt){
		StringBuilder builder = new StringBuilder();
		for(int i = 0; i < numArrayInt.length; i++){
			builder.append(numArrayInt[i]);
			builder.append(" ");
		}

		System.out.println(builder.toString().trim());
	}

}

Measured memory_bytes: 26804
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...)); }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  int n; cin >> n;
  vector<int> a(n), b(n);
  REP (i, n) cin >> a[i];
  REP (i, n) cin >> b[i];
  int ans = 0;
  REP (i, n) {
    if (a[i] - b[i] > 0) ans += a[i] - b[i];
  }
  cout << ans << endl;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<string>a(n); 
  for (int i = 0;i<n;i++) {
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  for (int i = 0;i<n;i++) {
    cout << a.at(i);
  }    
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    int count(long[] target, long a, int start) {
        int n = 0;
        for (int i = start; i < target.length; i++) {
            if (target[i] == a) {
                n++;
            }
        }
        return n;
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        long[] v = new long[N];
        for (int i = 0; i < N; i++) {
            v[i] = sc.nextLong();
        }
        long[][] combination = new long[N + 1][N + 1];
        for (int i = 1; i <= N; i++) {
            for (int j = 0; j <= i; j++) {
                if (i == 0 || i == j) {
                    combination[i][j] = 1;
                } else if (i == 1) {
                    combination[i][j] = i;
                } else {
                    try {
                        combination[i][j] = combination[i - 1][j - 1] + combination[i - 1][j];
                    } catch (ArrayIndexOutOfBoundsException e) {
                        combination[i][j] = 1;
                    }
                }

            }
        }
        Arrays.sort(v);
        for (int i = 0; i < N / 2; i++) {
            long tmp = v[i];
            v[i] = v[N - i - 1];
            v[N - i - 1] = tmp;
        }
        long sum = 0;
        for (int i = 0; i < A; i++) {
            sum += v[i];
        }
        System.out.println((double) sum / A);
        long pattern = 0;
        if (v[0] == v[A - 1]) {
            int n = count(v, v[A - 1], 0);
            for (int i = A; i <= B; i++) {
                if (v[A - 1] != v[i - 1]) {
                    break;
                }
                pattern += combination[n][n - i];
            }
        } else {
            int n = count(v, v[A - 1], 0);
            int r = count(v, v[A - 1], A);
            pattern = combination[n][r];

        }
        System.out.println(pattern);
    }
}


Measured memory_bytes: 23764
# Binary Search
from bisect import bisect_left

def main():
  n = int(input())
  S = list(map(int, input().split()))
  m = int(input())
  T = list(map(int, input().split()))
  count = 0
  for i in T:
    index = bisect_left(S, i)
    if index != len(S) and S[index] == i:
      count += 1
  print(count)

main()



Measured memory_bytes: 16748
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vl = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    int N, M; cin >> N >> M;
    vvi sc(M, vi(0));
    for(int i=0; i<M; i++){
        int k; cin >> k;
        for(int j=0; j<k; j++){
            int g; cin >> g; 
            sc[i].emplace_back(g);
        }
    }
    vi p(M);
    for(int i=0; i<M; i++){
        cin >> p[i];
    }
    int c = 0;
    for(int i=0; i<pow(2,N); i++){
        stringstream rr;
        rr << bitset<10>(i);
        string r = rr.str();
        bool b = true;
        for(int j=0; j<M; j++){
            int m=0;
            for(auto x: sc[j]){
                if(r[10-x] == '1'){m++;}
            }
            if(m%2 != p[j]){
                b = false;
            }
        }
        if(b == true){
            c++;
        }
    }
    cout <<c;
}

Measured memory_bytes: 256
A=list(input())
n=len(A)
if(A[0]!="A"):print("WA")
elif(A.count("C")!=1):print("WA")
elif(A.index("C")<2 or A.index("C")>n-2):print("WA")
else:
  A.pop(A.index("C"))
  A.pop(0)
  S="".join(A)
  if(S.islower()):print("AC")
  else:print("WA")


Measured memory_bytes: 3060
package main 

import (
  "fmt"
  "sort"
)

func main() {
  var n, l int
  fmt.Scan(&n, &l)

  s := make([]string ,n)
  for i := 0; i < n; i++ {
    fmt.Scan(&s[i])
  }
  
  sort.Strings(s)
  
  for j := 0; j < n; j++ {
    fmt.Print(s[j])
  }
  fmt.Print()
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		
		int[] dp = new int[H+1];
		final int MAX = 1000000000;
		Arrays.fill(dp, MAX);
		dp[H]=0;
		for(int i=H; i>0; i--) {
			if(dp[i]<MAX) {
				for(int j=0; j<N; j++) {
					int next = Math.max(0, i-A[j]);
					dp[next] = Math.min(dp[next], dp[i]+B[j]);
				}
			}
		}
		
		System.out.println(dp[0]);
	}

}



Measured memory_bytes: 27348
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

const ll M = 998244353;
vector<ll> fac(300001);
vector<ll> ifac(300001);

int Combination(int n, int r){
        int num = 1;
        for(int i = 1; i <= r; i++){
            num = num * (n - i + 1) / i;
        }
        return num;
    }

int main(void)
{
    int N, M;
    cin >> N >> M;
    
    int ans = 0;
    ans += Combination(N, 2);
    ans += Combination(M, 2);


    cout << ans << endl;
}

Measured memory_bytes: 7832
#include<stdio.h>
int main(){
  int N,K;
  scanf("%d%d",&N,&K);
  char swap,S[100];
  scanf("%s",S);
  swap = S[K-1];
  if(swap == 'A')swap = 'a';
  else if(swap == 'B')swap = 'b';
  else swap = 'c';
  S[K-1] = swap;
  printf("%s",S);
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <stack>
#include <string>

using namespace std;

int main() {
  string symbol;
  stack<int> memory;
  while (cin >> symbol) {  // BUG: Can't break while loop.
    if (symbol == "+" || symbol == "-" || symbol == "*") {
      int x = memory.top();
      memory.pop();
      int y = memory.top();
      memory.pop();
      if (symbol == "+")
        memory.push(x + y);
      else if (symbol == "-")
        memory.push(y - x);
      else if (symbol == "*")
        memory.push(x * y);
    } else {
      memory.push(stoi(symbol));
    }
  }
  cout << memory.top() << endl;
}

Measured memory_bytes: 3164
N,M = list(map(int, input().split()))
S = set()
for _ in range(M):
  S.add(tuple(map(int, input().split())))

ans = "-1"
for i in range(10**N):
  x = str(i)
  if len(x) != N:
    continue
  dbl = False
  for l in S:
    idx, num = l[0] - 1, str(l[1])
    if x[idx] != num:
      dbl = True
      break
  if dbl:
    continue
  ans = x
  break
  
print(ans)
    

Measured memory_bytes: 3064
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000009
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	// 解説を参考にした別解
	// > そのため、一度与えられた数列をソートすると、全ての隣接する 2 項を比較し、
	// > 等しい値がなければ YES で、等しい値があれば NO です。
	N := nextInt()
	list := make([]int, N)
	for i := 0; i < N; i++ {
		list[i] = nextInt()
	}
	sort.Ints(list)
	for i := 1; i < N; i++ {
		if list[i-1] == list[i] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 40320
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll t;
  // cin>>t;
  t=1;
  while(t--){
    ll x,k,d;
    cin>>x>>k>>d;
    if(x<0)
      x*=-1;
    ll steps = (x+d-1)/d;
    if(steps>k){
      x-=k*d;
      cout<<abs(x)<<endl;
    }else{
      x -= steps*d;
      k-=steps;
      if(k%2==1){
        x+=d;
      }
      cout<<abs(x)<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3664
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repv(t,it,v) for(vector<t>::iterator it = v.begin() ; it != v.end() ; ++it)

typedef long long LL;

int N,A,B,C,D;
LL mod = 1e9 + 7;
LL con[1010][1010];
LL dp[1010][1010];
LL r[1010];

int main(){
	scanf("%d%d%d%d%d" , &N , &A , &B , &C , &D);
	con[0][0] = 1;
	repp(i,1,N+1){
		con[i][0] = con[i][i] = 1;
		repp(j,1,i){
			con[i][j] = (con[i-1][j-1] + con[i-1][j]) % mod;
		}
	}
	{
		int x = mod - 2;
		r[N] = 1;
		repp(i,2,N+1){
			(r[N] *= i) %= mod;
		}
		LL y = r[N];
		r[N] = 1;
		while(x > 0){
			if(x%2==1) (r[N] *= y) %= mod;
			(y *= y) %= mod;
			x /= 2;
		}
	}
	repm(i,N,0){
		r[i-1] = r[i] * i % mod;
	}
	dp[0][A-1] = 1;
	repp(i,0,N+1){
		repp(j,A,B+1){
			(dp[i][j] += dp[i][j-1]) %= mod;
			if(i+j*C>N) continue;
			LL z = 1;
			repp(k,0,C){
				(z *= con[N-i-j*k][j]) %= mod;
			}
			repp(k,C,D){
				dp[i+j*k][j+1] += dp[i][j] * z % mod * r[k] % mod;
				if(i+j+j*k>N) break;
				(z *= con[N-i-j*k][j]) %= mod;
			}
			if(i+j*D<=N) dp[i+j*D][j+1] += dp[i][j] * z % mod * r[D] % mod;
		}
	}
	printf("%lld\n" , (dp[N][B] + dp[N][B+1]) % mod);
	return 0;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int h,w;
string board[2005];
int U[2005][2005];
int L[2005][2005];
int R[2005][2005];
int D[2005][2005];
int ans=0;
int main(int argc,char const* argv[])
{
  cin >> h >> w;
  for(int i=0;i<h;i++)
    {
      cin >> board[i];
    }
  //cout << "L U " << endl;
  for(int i=0;i<h;i++)
    {
      //L[i+1][j+1]=L[i+1][j];
      for(int j=0;j<w;j++)
	{
	  L[i+1][j+1]=L[i+1][j];
	  U[i+1][j+1]=U[i][j+1];
	  if(board[i][j]=='#')
	    {
	      U[i+1][j+1]=i+1;
	      L[i+1][j+1]=j+1;
	    }
	  //cout << i+1 <<' '<< j+1 << ' '<< L[i+1][j+1] << ' '<< U[i+1][j+1] << endl;
	}
    }
  //cout << "R D " << endl;
  for(int i=h-1;i>=0;i--)
    {
      //L[i+1][j+1]=L[i+1][j];
      for(int j=w-1;j>=0;j--)
	{
	  R[i+1][j+1]=R[i+1][j+2];
	  D[i+1][j+1]=D[i+2][j+1];
	  if(board[i][j]=='#')
	    {
	      D[i+1][j+1]=i+1;
	      R[i+1][j+1]=j+1;
	    }
	  //cout << i+1 <<' '<< j+1 << ' '<< R[i+1][j+1] << ' '<< D[i+1][j+1] << endl;
	}
    }

  //cout << "A" << endl;
  /*
  for(int i=1;i<=h;i++)
    {
      for(int j=1;j<=w;j++)
	{
	  cout << "lrlight " << i << endl;
	  for(int k=0;k<int(lrlight[i].size());k++)
	    {
	      cout << lrlight[i][k] << ' ';
	    }
	  cout << endl;
	  cout << "udlight " << j << endl;
	  for(int k=0;k<int(udlight[j].size());k++)
	    {
	      cout << udlight[j][k] << ' ';
	    }
	  cout << endl;
	}
	}*/

  for(int i=1;i<=h;i++)
    {
      for(int j=1;j<=w;j++)
	{
	  int tmp=1;
	  int l=0,r=0,d=0,u=0;
	  if(board[i-1][j-1]=='#') continue;
	  //auto lit=lower_bound(lrlight[i].begin(),lrlight[i].end(),0);
	  //auto rit=lower_bound(lrlight[i].begin(),lrlight[i].end(),j);
	  //auto dit=lower_bound(udlight[j].begin(),udlight[j].end(),i);
	  //auto uit=lower_bound(udlight[j].begin(),udlight[j].end(),0);
	  if(j<L[i][j]) l=j-1;
	  else l=max(0,j-L[i][j]-1);
	  if(i<U[i][j]) u=i-1;
	  else u=max(0,i-U[i][j]-1);
	  //cout << i << ' ' << j << ' ' << *rit << ' ' << *dit << endl;
	  if(j>R[i][j]) r=max(0,w-j);
	  else r=max(0,R[i][j]-j-1);
	  if(i>D[i][j])d=max(0,h-i);
	  else d=max(0,D[i][j]-i-1);
	  //cout << i << ' '<< j  << ' ' << l << ' ' << r << ' ' << u << ' ' << d << endl;
	  ans=max(ans,tmp+l+r+d+u);
	}
    }
  cout << ans << endl;
  return 0;
}


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

int main(){
    string S;
    cin >> S;
    
    if(S[0]!='A'){
        cout << "WA" << endl;
    }
    else{
        bool flag=true;
        int cnt=0, n=0;
        for(int i=2; i<S.length()-1; i++){
            if(S[i]=='C'){
                cnt++;
                n=i;
            }
        }
        if(cnt!=1) flag=false;
        
        for(int i=1; i<S.length(); i++){
            if(i!=n && (S[i]<'a'||S[i]>'z'))
                flag=false;
        }
        
        cout << ((flag)?"AC":"WA") << endl;
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
 
 
int main(){
 
	string s;
	cin>>s;
	string t;
	cin>>t;
	int flag = 1;
	for(int i=0;i<s.size();i++){
		if(s[i] != t[i])
			flag = 0;
	}
	if(flag == 0)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
 
 
	return 0;
}

Measured memory_bytes: 3644
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int min = 753;

            for (int i = 0; i < input.Length-2; i++)
            {
                int zantei = System.Math.Abs(753 - int.Parse(input.Substring(i, 3)));
                if (zantei < min)
                {
                    min = zantei;
                }
            }
            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 11220
N = int(input())
*a, = map(int, input().split())
two, four, no = 0, 0, 0
for i in range(N):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1
    else:
        no += 1

ok = four == no or (four+two) == N
ok = ok or ((four+no) == N and abs(four-no) <= 1)
if ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 62576