akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
signed main(){
	int n,k;
	cin>>n>>k;
	if(k%2==1){
		int a=n/k;
		cout<<a*a*a<<endl;
	}else{
		int ans=0;
		int a=2*n/k;
		if(a%2==0) a--;
		
		a=(1+a)/2;
		ans+=a*a*a;

		a=n/k;
		ans+=a*a*a;

		cout<<ans<<endl;
	}



	return 0;
}



Measured memory_bytes: 3648
#include <stdio.h>
int main(void) {
  int H[100000], W[100000];
  int i, j, k, n = 0;

  do {
    scanf("%d %d", &H[n], &W[n]);
    n++;
  } while (!(H[n - 1] == 0 && W[n - 1] == 0));

  for (j = 0; j < H[0]; j++) {
    for (k = 0; k < W[0]; k++) {
      printf("#");
    }
    puts("");
  }

  for (i = 1; i < n; i++) {
    puts("");
    for (j = 0; j < H[i]; j++) {
      for (k = 0; k < W[i]; k++) {
        printf("#");
      }
      puts("");
    }
  }

  return 0;
}

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

int main(){
  int64_t x;
  cin>>x;
  if(x%11==0) cout<<2*(x/11)<<endl;
  else if(x%11<=6) cout<<2*(x/11)+1<<endl;
  else cout<<2*(x/11)+2<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

vector<P> dif;

int main(){
    int N; cin >> N;
    int x[55], y[55];
    for(int i=0; i<N; i++){
        cin >> x[i] >> y[i];
    }

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(i==j) continue;
            dif.push_back(P(x[i]-x[j], y[i]-y[j]) );
        }
    }
    sort(dif.begin(),dif.end());
    int num=0;
    for(int i=0; i<dif.size(); i++){
        int a = upper_bound(dif.begin(),dif.end(),dif[i])-lower_bound(dif.begin(),dif.end(),dif[i]);
        num = max(num,a);
    }
    cout << N-num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

struct Node{
	ll ch[2];
	int cost;
	int h;

	Node(){
		memset(ch, -1, sizeof ch);
		cost = 0;
		h = 0;
	}
};

vector<Node> trie;

void add_str(int v, string &s, int i, int cost){
	if(s.size() == i){
		trie[v].cost = cost;
		return;
	}

	trie[v].h = i;
	if(trie[v].ch[s[i]-'0'] == -1){
		trie.push_back(Node());
		trie[v].ch[s[i]-'0'] = trie.size()-1;
	}

	add_str(trie[v].ch[s[i]-'0'], s, i+1, cost);
}

ll modpow(ll a, ll b){
	if(b < 0) return 0;
	if(b == 0) return 1;
	if(b % 2) return (a*modpow(a,b-1))%3;
	ll ret = modpow(a, b/2);
	return ret*ret%3;
}

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

	ll N, L;
	ll res = 0;
	cin >> N >> L;
	trie.push_back(Node());
	REP(i, N){
		string s;
		cin >> s;
		add_str(0, s, 0, 0);
	}
	REP(i, trie.size()){
		if(trie[i].ch[0] * trie[i].ch[1] < 0){
			res ^= (L-trie[i].h)&-(L-trie[i].h);
		}
	}
	if(res == 0){
		cout << "Bob" << endl;
	}else{
		cout << "Alice" << endl;
	}
}


Measured memory_bytes: 13760
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,z,w;
	cin>>n>>z>>w;
  	vector<int> a(n);
  	for(int i=0;i<n;i++) cin>>a[i];
  	if(n==1) cout<<abs(w-a[0])<<endl;
  	else cout<<max(abs(a[n-1]-a[n-2]),abs(w-a[n-1]))<<endl;
}

Measured memory_bytes: 256
/**
 *      purpose : ABC 122 B
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

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

  string s; cin >> s;
  int SIZE = s.size();

  int beg = 0;
  int ans = 0;
  while (beg < SIZE){
    int end = beg;
    while (end < SIZE && (s[end] == 'A' || s[end] == 'T' || s[end] == 'C' || s[end] == 'G')){
      ++end;
    }
    int len = end - beg;
    ans = max(ans, len);
    beg = end + 1;
  }

  print(ans);

  return 0;
}

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

int main(){
	bool isValid = true;
	bool isNExist = false, isSExist = false, isRExist = false;
	string input;
	cin >> input;

	if(input.size() < 6)  isValid = false;

	for(int i=0; i < input.size(); i++){
		if('0' <= input[i] && input[i] <= '9') isNExist = true;
		if('a' <= input[i] && input[i] <= 'z') isSExist = true;
		if('A' <= input[i] && input[i] <= 'Z') isRExist = true;
	}
	if(!(isNExist && isSExist && isRExist))  isValid = false;

	if(isValid) cout << "VALID" << endl;
	else cout << "INVALID" << endl;
}

Measured memory_bytes: 1180
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    n = f.read_int()
    a = f.read_int_list()

    i = max(a)
    a.remove(i)
    j = sorted(a, key=lambda x: abs(x*2-i))[0]

    return "%d %d"%(i,j)


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

int dr[4]={-1,0,0,1};
int dc[4]={0,-1,1,0};

void bfs(const vector<vc> &field, vector<vi> &dist){
    queue<pair<int,int>> que;
    que.push({1,1});
    dist[1][1]=0;
    while(!que.empty()){
        auto x=que.front(); que.pop();
        for(int i=0;i<4;i++){
            int nr=x.first+dr[i];
            int nc=x.second+dc[i];
            if(field[nr][nc]=='#') continue;
            if(dist[nr][nc]!=-1) continue;
            dist[nr][nc]=dist[x.first][x.second]+1;
            que.push({nr,nc});
        }
    }
}

int main(){
    int r,c;
    cin >> r >> c;
    vector<vc> field(r+2,vc(c+2,'#'));
    int ans=0;
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            cin >> field[i][j];
            if(field[i][j]=='.') ans++;
        }
    }
    vector<vi> dist(r+2,vi(c+2,-1));
    bfs(field,dist);
    if(dist[r][c]==-1){
        cout << "-1" << endl;
        return 0;
    }
    cout << ans-dist[r][c]-1 << endl;
    
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <ctype.h>

int main(void){
    int count[26]={};
    int n, i;
    char ch;
    
    while((ch=getchar())!=EOF){
        ch=tolower(ch);
        n=ch-'a';
        count[n]++;
    }
    
    for(i=0; i<26; i++){
        printf("%c : %d\n", i+'a', count[i]);
    }
    
    return 0;
}

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

int main() {
	int yen500 = 500;
	int A;
	int N;
	int needA;
	
	cin >> N >> A;

	if (N >= 1 && N <= 10000 && A >= 0 && A <= 1000) {
		needA = N % yen500;

		if (needA <= A) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	} else {
		cout << "N  は 1 以上 10000 以下の整数" << endl;
		cout << "A  は 0 以上 1000 以下の整数を入れてください" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
	string S, T;
	int index = -1;
	cin >> S >> T;
	int SL = S.length(), TL = T.length();

	for(int i = 0 ; i < SL; i++){
		if ((i + TL) > SL) break;
		if(S[i] == T[0] || S[i] == '?'){
			int ii = i+1;
			int j;
			for(j = 1; j < TL; j ++){
				if(S[ii] != '?' &&  S[ii] != T[j])break;
				else{
					ii++;
				}
			}
			if (j >= TL) index = i;
		}	
	}
	if (index == -1){cout << "UNRESTORABLE" << endl;}
	else {
		string res = "";
		for(int i = 0 ; i < SL; i++){
			if (i == index){
				res.append(T);
				i = i + TL-1;
			}	
			else{
				if (S[i] == '?'){
					res+='a';
				}
				
				else res+=S[i];			
			}
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits> 
#include <time.h>

int main(void){
    long N,M,X;
    std::cin >> N >> M >> X;
    long C[12]={};
    long A[12][12]={};
    for(long i=0; i<N; i++){
        std::cin >> C[i];
        for(long j=0; j<M; j++){
            std::cin >> A[i][j];
        }
    }

    long num=1;
    for(long i=0; i<N; i++){
        num*=2;
    }

    long temp_min=20*1000000;
    long money=0;
    for(long i=0; i<num;i++){
        bool B[12]={};
        long und[12]={};
        bool flag=1;
        money=0;
        for(long j=0; j<N; j++){
            B[j]=(i>>j)&1;
        }
        for(long j=0; j<N; j++){
            if(B[j]==1){
                for(long k=0; k<M; k++){
                    und[k]+=A[j][k];
                }
                money+=C[j];
            }
        }
        for(long j=0; j<M; j++){
            if(und[j]<X){
                flag=0;
            }
        }
        if(flag){
            if(money<temp_min){
                temp_min=money;
            }
        }
    }

    if(temp_min==20*1000000){
        std::cout << -1 << std::endl;
    }else{
        std::cout << temp_min << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3636
a,b,c,d = map(int,input().split())
n = int(input())
aval = 4*a
bval = 2*b
cval = c
dval = d/2
if aval == min(aval,bval,cval,dval):
         print(aval*n)
elif bval == min(aval,bval,cval,dval):
         print(bval*n)
elif cval == min(aval,bval,cval,dval):
         print(cval*n)
elif dval == min(aval,bval,cval,dval) and n %2 == 0:
         print(d*(n//2))
else:
         if aval == min(aval,bval,cval):
                  print(d*(n//2) + aval)
         elif bval == min(aval,bval,cval):
                  print(d*(n//2) + bval)
         else:
                  print(d*(n//2) + cval)


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

int main(){
	// sengen
	int H,W,h,w;
	// nyuryoku
	cin >> H >> W >> h >> w;
	// keisan
	cout << (H-h)*(W-w) << endl;
	// syutsuryoku
}

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

void toBit(unsigned long x);



int main(void){
  unsigned long x;
  cin>>x;
  toBit(x);
  toBit(pow(2,32)-1-x);
  toBit(2*x);
  toBit(x/2);
  return 0;
}

void toBit(unsigned long x){
  x=x%((unsigned long)pow(2,32));
  for(int i=31;i>=0;i--){
    if(pow(2,i)<=x){
      cout<<1;
      x-=pow(2,i);
    }
    else{
      cout<<0;
    }
  }
  cout<<endl;
}



Measured memory_bytes: 3268
#include<bits/stdc++.h>
using namespace std;
const int maxN = 1e2+2;
const int maxW = 1e5+5;
typedef long long ll;
int N, W;
int v[maxN], w[maxN];
ll f[maxN][maxW];
int main() {
    cin >> N >> W;
    for(int i = 1; i <= N; ++i)
        cin >> w[i] >> v[i];
    ll ans = 0;
    for(int i = 1; i <= N; ++i)
        for(int j = 0; j<=W; ++j) {
            f[i][j] = f[i-1][j];
            if (j - w[i] >= 0)
                f[i][j] = max(f[i][j], f[i-1][j-w[i]]+v[i]);
        }
    for(int i = 0; i <= W; ++i) ans = max(ans, f[N][i]);
    cout << ans << endl;
}


Measured memory_bytes: 78336
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> color(9, 0);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        color[min(a / 400, 8)]++;
    }

    int r = 0;
    for (int i = 0; i < 8; i++) {
        if (color[i] > 0) {
            r++;
        }
    }

    cout << (r + (r == 0 && color[8] > 0 ? 1 : 0)) << " " << (r + color[8]) << endl;
}


Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    K = I()
    A, B = LI()

    if B >= K * (B//K) >= A:
        print('OK')
    else:
        print('NG')

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 9216
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n;
string s, t;
LL in[30];
LL dp[101010];
const LL mod = 1e9 + 7;

int main(){
	cin >> n;
	cin >> s >> t;
	s = '+' + s;
	t = '+' + t;
	dp[1] = 1;
	for(int i = 2;i <= n;i++){
		(in[s[i - 1] - 'a'] += (!i ? 0 : dp[i - 1])) %= mod;
		(dp[i] += in[t[i] - 'a']) %= mod;
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 4116
import math
import itertools


N = int(input())

array = [list(map(int, input().split())) for _ in range(N)]

result = 0
count = 0
permutation_list = itertools.permutations([x for x in range(N)])

calc = [[0] * 10 for i in range(10)]
for i in range(N):
    for j in range(N):
        calc[i][j] = math.sqrt((array[i][0] - array[j][0]) ** 2 +
                               (array[i][1] - array[j][1]) ** 2)
        calc[j][i] = math.sqrt((array[i][0] - array[j][0]) ** 2 +
                               (array[i][1] - array[j][1]) ** 2)

for data in permutation_list:
    count += 1
    for i in range(1, len(data)):
        result += calc[data[i - 1]][data[i]]
print(result / count)


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

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

int main()
{
    int N, K, X, Y;
    cin >> N;
    cin >> K;
    cin >> X;
    cin >> Y;

    if (N <= K) { cout << X * N << endl; }
    else{cout << X * K + Y * (N - K) << endl;}

}

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

long long cmb(long i){
    return i*(i-1)/2;
}

int main()
{
    char s[2000001];
    cin >> s ;
    long len;
    len = strlen(s);
    long long sum = 1+cmb(len);
    long long count[200]={0};
    for(long i=0;i<len;i++){
        count[(int)s[i]]+=1;
    }
    for(int k=97;k<123;k++){
        sum-=cmb(count[k]);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 512
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

N=I()
A=[I() for i in range(N)]
counts = collections.Counter(A)
ans=0
for i in counts.values():
    if i%2 == 1: 
        ans += 1
print(ans)


Measured memory_bytes: 18704
# For taking integer inputs.
import math


def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()
blue = []
red = []
for _ in range(n):
    blue.append(input())

m = inp()
for _ in range(m):
    red.append(input())
res = 0
for b in blue:
    res1 = blue.count(b)
    res2 = red.count(b)
    res = max(res, res1 - res2)
print(res)


Measured memory_bytes: 3064
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#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!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  string s;
  cin >> s;
  deque<char> ans;
  for(char c: s){
    ans.push_back(c);
  }
  int q;
  cin >> q;
  int t,f;
  char c;
  int cnt = 0;
  rep(i,q){
    cin >> t;
    if(t==1) cnt++;
    else{
      cin >> f >> c;
      if(f==1){
        if(cnt%2==0) ans.push_front(c);
        else ans.push_back(c);
      }else{
        if(cnt%2==0) ans.push_back(c);
        else ans.push_front(c);
      }
    }
  }
  if(cnt%2!=0) reverse(ans.begin(),ans.end());
  for(char c: ans){
    printf("%c", c);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 896
local n,k=io.read("n","n")
local d={}
for i=1,k do
    d[io.read("n")]=true
end
for i=n,10*n do
    local copi=i
    local checker=true
    while copi>0 do
        if d[copi%10] then
            checker=false
            break
        end
        copi=copi//10
    end
    if checker then
        print(i)
        return
    end
end

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;
const int INFTY = 1e9+7;

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

  ll x = 0;
  for (ll i=1; i<M; i++) {
    x += i*(i+1)/2;
    x %= INFTY;
  }
  ll N2 = (N*N)%INFTY;
  x = (x*N2)%INFTY;

  ll y = 0;
  for (ll i=1; i<N; i++) {
    y += i*(i+1)/2;
    y %= INFTY;
  }
  ll M2 = (M*M)%INFTY;
  y = (y*M2)%INFTY;

  ll sum = (x+y)%INFTY;  // distance of each 2 points

  int n = N*M-2;
  int r = K-2;
  r = min(r,n-r);

  if (r == 0) {
    cout << sum << endl;
    return 0;
  }

  if (r == 1) {
    cout << (sum*n)%INFTY << endl;
    return 0;
  }

  int numerator[r], denominator[r];
  rep(i,r) {
    numerator[i] = n-r+i+1;
    denominator[i] = i+1;
  }

  for (int p=2; p<=r; p++) {
    int pivot = denominator[p-1];
    if (pivot > 1) {
      int offset = (n-r)%p;
      for (int i=p-1; i<r; i+=p) {
        numerator[i-offset] /= pivot;
        denominator[i] /= pivot;
      }
    }
  }

  ll comb = 1;
  rep(i,r) {
    if (numerator[i] > 1) {
      comb *= numerator[i];
      comb %= INFTY;
    }
  }

  cout << (sum*comb)%INFTY << endl;
  return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100009;
int x, y, a, b, c, p[N], q[N], r[N];

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> x >> y >> a >> b >> c;
    for(int i = 0; i < a; ++i) {
        cin >> p[i];
    }
    for(int i = 0; i < b; ++i) {
        cin >> q[i];
    }
    for(int i = 0; i < c; ++i) {
        cin >> r[i];
    }

    sort(p, p+a);
    sort(q, q+b);

    priority_queue<int, vector<int>, greater<int>> pq;
    
    for(int i = 0; i < a && i < x; ++i) {
        pq.push(p[a-1-i]);
    }
    for(int i = 0; i < b && i < y; ++i) {
        pq.push(q[b-1-i]);
    }

    for(int i = 0; i < c; ++i) {
        int cur = r[c-1-i];
        pq.push(cur);
        if((int)pq.size() > x+y) {
            pq.pop();
        }
    }

    int ans = 0;
    while(!pq.empty()) {
        ans += pq.top();
        pq.pop();
    }

    cout << ans << '\n';
    
    return 0;
}


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

using namespace std;
int MAX = 200000;

int main() {
    int R[MAX], n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];
    int maxv = -2000000000;
    int minv = R[0];
    
    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;
    
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;

ll mod_pow(ll x,ll n, ll mod){
  if(n==0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
 
  if(n&1) res = res*x%mod;

  return res;
}

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

  map<int, int> m;

  REP(i,N){
    int a;
    cin >> a;
    m[a]++;
  }

  if(N&1){
    for(int i = 0; i < N; i+=2){
      if(i==0){
        if(m[i]!=1){
          cout << 0 << endl;
          return 0;
        }
      }else{
        if(m[i]!=2){
          cout << 0 << endl;
          return 0;
        }
      }
    }
  }else{
    for(int i = 1; i < N; i+=2){
      if(m[i]!=2){
        cout << 0 << endl;
        return 0;
      }
    }
  }

  cout << mod_pow(2, N/2, MOD) << endl;
}



Measured memory_bytes: 3200
n, m = map(int,input().split())
a_l = list(map(int,input().split()))

cb_l = []
for i in range(m):
    b,c = map(int,input().split())
    cb_l.append((c,b))

a_l.sort()
cb_l.sort(reverse=True)

b_count = 0
j = 0
for i in range(n):
    if a_l[i] < cb_l[j][0]:
        a_l[i] = cb_l[j][0]
        b_count += 1
        if b_count == cb_l[j][1]:
            j += 1
            b_count = 0
    else:
        break
    if j == m:
        break

ans = 0
for val in a_l:
    ans += val
print(ans)


Measured memory_bytes: 20960
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

ans = 0
for i in range(N):
    v = C
    for j in range(M):
        v += A[i][j] * B[j]
    if v > 0:
        ans += 1

print(ans)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int H[100100];
int A[100100];

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

  std::cin >> N;

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

  for(int i=N-2;i>=0;--i){
      if(H[i] >= H[i+1]){
          A[i] = A[i+1] + 1;
      }
  }

  int res = *std::max_element(A, A + N);
  std::cout << res << std::endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
main() {
  int H,W,i,j;
  cin>>H>>W;
  vector<vector<char>>S(H,vector<char>(W));
  for(i=0;i<H;i++)for(j=0;j<W;j++)cin>>S.at(i).at(j);
  for(i=0;i<H;i++){
    for(j=0;j<W;j++)if(S.at(i).at(j)=='#')break;
    if(j==W)for(j=0;j<W;j++)S.at(i).at(j)='-';
  }
  for(i=0;i<W;i++){
    for(j=0;j<H;j++)if(S.at(j).at(i)=='#')break;
    if(j==H)for(j=0;j<H;j++)S.at(j).at(i)='-';
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(S.at(i).at(j)!='-'){
        cout<<S.at(i).at(j);
      }
    }
    for(j=0;j<W;j++)if(S.at(i).at(j)=='#')break;
    if(j!=W)cout<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	
		while(true){
			int d=sc.nextInt(); // 高さ
			int w=sc.nextInt(); // 幅
			if(d==0&&w==0) break;
			int cells[][] = new int[d][w];
			for(int j=0;j<d;++j) {
				for(int i=0;i<w;++i) {
					cells[j][i]=sc.nextInt();
				}
			}
			
			// calculate
			int ans=0; // 結果
			for(int pd=3;pd<=d;++pd) {  // 高さのサーチサイズ（3~d）
				for(int pw=3;pw<=w;++pw) { // 幅のサーチサイズ（3~w）
					
					for(int j=0;j<=d-pd;++j) { // サーチ軸（縦方向）
						for(int i=0;i<=w-pw;++i) { // サーチ軸（横方向）
							int Maxhar; // 池の境界の最小値
							Maxhar=search(cells,i,j,pw+i,pd+j); // 池の境界の最小値を計算
							int ans_if=0; // この条件下での池の容量
							ans_if=calculate(cells,i,j,pw+i,pd+j,Maxhar); // この条件下での池の容量を計算
							if(ans<ans_if) ans=ans_if; // 池の容量を更新
						}
					}
				}
			}
			System.out.println(ans); // 計算結果の出力
		}
	}
	
	// 池の境界の最小値を計算
	public static int search(int[][] cells, int sw, int sd, int pw, int pd) {
		int min=cells[sd][sw]; // 池の境界の最小値
		for(int i=sw;i<pw;++i) {
			if(min>cells[sd][i]) min=cells[sd][i];
		}
		for(int i=sd;i<pd;++i) {
			if(min>cells[i][pw-1]) min=cells[i][pw-1];
		}
		for(int i=sw;i<pw;++i) {
			if(min>cells[pd-1][i]) min=cells[pd-1][i];
		}
		for(int i=sd;i<pd;++i) {
			if(min>cells[i][sw]) min=cells[i][sw];
		}
		return min;
	}
	
	// この条件下での池の容量を計算
	public static int calculate(int[][] cells, int sw, int sd, int pw, int pd, int min) {
		int sum=0; // 池の容量
		for(int j=sd+1;j<pd-1;++j) {
			for(int i=sw+1;i<pw-1;++i) {
				if(min<=cells[j][i]) return 0; // もしも池になっていなければ、計算を終了、0を返す
				else sum+=min-cells[j][i]; // 池の容量の計算（境界との誤差）
			}
		}
		return sum;
	}
}



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

int main(){
  int n, k; cin >> n >> k;
  string s; cin >> s;
  int len = 1; // 反転した数だけ不幸せな人がいる
  for(int i=1; i<n; i++){
    if(s[i] != s[i-1]) len++;
  }

  int unhapp = max(len - 2*k, 1); // 1度の反転でmax2人幸せになれる
  cout << n - unhapp << endl;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Text;

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

            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);

            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else if (a > b)
            {
                Console.WriteLine("a > b");
            }
            else if (a == b)
            {
                Console.WriteLine("a == b");
            }

            
            //int n =int.Parse(s);
        }
    }
}

Measured memory_bytes: 5284
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();
		long sum=0;
		for(int i=0; i<n; i++){
			sum+=sc.nextInt();
		}
		if(sum>=h){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 46992
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var t=sc.S;
		int ans=0;
		for(int i = 0;i<n-2;i++) {
			if(t[i]=='A'&&t[i+1]=='B'&&t[i+2]=='C'){
				ans++;
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13268
# 貪欲+焼き鈍し(日付とコンテストをランダムに2つ選ぶ)
import time
import random

d = int(input())
dd = d * (d + 1) // 2
*C, = map(int, input().split())
S = [list(map(int, input().split())) for i in range(d)]
T = []
L = [-1 for j in range(26)]
for i in range(d):
    max_diff = -10**7
    arg_max = 0
    for j in range(26):
        memo = L[j]
        L[j] = i
        diff = S[i][j] - sum([C[k] * (i - L[k]) for k in range(26)])
        if diff > max_diff:
            max_diff = diff
            arg_max = j
        L[j] = memo
    T.append(arg_max)
    L[arg_max] = i


def calc_score(T):
    L = [-1 for j in range(26)]
    X = [0 for j in range(26)]
    score = 0
    for i in range(d):
        score += S[i][T[i]]
        X[T[i]] += (d - i) * (i - L[T[i]])
        L[T[i]] = i
    for j in range(26):
        score -= C[j] * (dd - X[j])
    return score


score = calc_score(T)
start = time.time()
while True:
    now = time.time()
    if now - start > 1.8:
        break
    p0, p1 = tuple(random.sample(range(d), 2))
    q0, q1 = tuple(random.sample(range(26), 2))
    memo = T[p0], T[p1]
    T[p0], T[p1] = q0, q1
    new_score = calc_score(T)
    temp = 20000 * (1 - (now - start) / 2)
    prob = 2**((new_score - score) / temp)
    if random.random() < prob:
        score = new_score
    else:
        T[p0], T[p1] = memo

for t in T:
    print(t + 1)


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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  char s[101];
  int64 k;
  scanf("%s",s);
  scanf("%lld",&k);
  int n=0;
  while(s[n]!='\0') n++;
  int i=0;
  while(i<n && i<k-1 && s[i]=='1') i++;
  printf("%c\n",s[i]);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i,j;
	int n,m;
	cin>>n>>m;
	ll sum=0;
	for(i=0;i<m;i++){
		ll x;
		cin>>x;
		sum+=x;
	}
	if(n>=sum) cout<<n-sum<<endl;
	else cout<<-1<<endl;

}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int W, H, N;
	cin >>W >>H >>N;
	int L=0;
	int R=W;
	int low=0;
	int high=H;
	for (int i=0; i<N; i++) {
		int x, y, a;
		cin >>x >>y >>a;
		switch (a) {
			case 1:
				L=max(L, x);
				break;
			case 2:
				R=min(R, x);
				break;
			case 3:
				low=max(low, y);
				break;
			case 4:
				high=min(high, y);
				break;
		}
	}
	cout <<max(0, (R-L))*max(0, (high-low)) <<endl;
	return 0;
}



Measured memory_bytes: 256
s = input()
t = input()
ls,lt = len(s),len(t)
i = j = 0
si = lp = 0
while True:
    tc = t[i]
    si = s.find(tc)
    if si == -1:
        print(-1)
        exit(0)
    else:
        if i == lt-1:
            print(lp*ls + si+1)
            exit(0)
        else:
            while True:
                if t[i+1] in s[si+1:]:
                    si = s[si+1:].find(t[i+1]) + si +1
                    if i+1 == lt-1:
                        print(lp*ls + si+1)
                        exit(0)
                    else:
                        i+=1
                else:
                    i+=1
                    break
    lp += 1
    if i >= lt:
        print(-1)
        break

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
  ll a, b, k;
  cin >> a >> b >> k;
  
  if (a <= k)
    cout << 0;
  else
    cout << a - k;
  
  k = max(k - a, 0LL);
  cout << " ";
  if (b <= k)
    cout << 0 << endl;
  else
    cout << b - k << endl;
  
  return 0;
}


Measured memory_bytes: 256
from itertools import product

N = int(input())
num_list = ["3", "5", "7"]
count = 0

for i in range(3, 10):
    for t in (product(num_list, repeat=i)):
        check = t.count("3")*t.count("5")*t.count("7")
        if int("".join(t)) <= N and check:
            count += 1


print(count)

Measured memory_bytes: 3060
using System;
class Program
{
 static void Main(string[] args)
 {
  string s = Console.ReadLine().Trim();
  string O = "NO";
  if (s == "5 5 7" || s == "5 7 5" || s == "7 5 5") { O = "YES"; }
  Console.WriteLine(O);
 }
}


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

int main(){
	int N, A, B;
	cin >> N >> A >> B;
	int a, b, c, d, e, f, ans = 0;

	for (int i = 1; i <= N; i++){
		a = i % 10;
		b = (i / 10) % 10;
		c = (i / 100) % 10;
		d = (i / 1000) % 10;
		e = (i / 10000) % 10;
		f = a + b + c + d + e;
		if (A <= f&&f <= B){
			ans += i;
		}
	}
	cout << ans;
}

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

int main()
{
  int n, m;
  int i, j, closest;
  long int *a, *b, *c, *d;
  long int distance, min;

  scanf("%d %d\n", &n ,&m);

  a = (long int *)malloc(sizeof(long int) * n);
  b = (long int *)malloc(sizeof(long int) * n);
  c = (long int *)malloc(sizeof(long int) * m);
  d = (long int *)malloc(sizeof(long int) * m);

  for (i = 0; i < n; ++i)
    scanf("%ld %ld\n", &a[i], &b[i]);
  for (i = 0; i < m; ++i)
    scanf("%ld %ld\n", &c[i], &d[i]);

  for (i = 0; i < n; ++i) {
    min = 1000000000;
    for (j = 0; j < m; ++j) {
      distance = fabs(a[i] - c[j]) + fabs(b[i] - d[j]);
      if (distance < min) {
	min = distance;
	closest = j;
      }
    }
    printf("%d\n", closest + 1);
  }

  free(a);
  free(b);
  free(c);
  free(d);
}


Measured memory_bytes: 128
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        d: usize,
        n: usize,
    }
    let b = if d == 0 { 1 } else { 100usize.pow(d as u32) };
    if n == 100 {
        println!("{}", b * 101);
    } else {
        println!("{}", b * n);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <array>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int mod(int x, int md) {
  x %= md;
  if (x < 0) {
    x += md;
  }
  return x;
}

int main() {
  int N, L, T;
  std::cin >> N >> L >> T;
  std::vector<int> X(N), D(N);
  std::vector<int> after(N);
  for (int i: range(0, N)) {
    std::cin >> X[i] >> D[i];
    after[i] = mod(X[i] + T * (D[i] == 1 ? 1 : -1), L);
  }
  int origin = after[0];
  std::sort(after.begin(), after.end());
  int pos = std::lower_bound(after.cbegin(), after.cend(), origin) - after.cbegin();
  int count = 0;
  if (D[0] == 1) {
    for (int i: range(1, N)) {
      if (D[i] == 2) {
        int val = 2 * T - (X[i] - X[0]);
        if (val > 0) {
          count += (val - 1) / L + 1;
          count = mod(count, N);
        }
      }
    }
  }
  else {
    for (int i: range(1, N)) {
      if (D[i] == 1) {
        int val = 2 * T - (L - X[i] + X[0]);
        if (val >= 0) {
          count -= val / L + 1;
          count = mod(count, N);
        }
      }
    }
  }
  std::vector<int> ans(N);
  for (int i: range(0, N)) {
    ans[mod(count + i, N)] = after[mod(pos + i, N)];
  }
  for (int x: ans) {
    std::cout << x << '\n';
  }
  return 0;
}


Measured memory_bytes: 2816
object Main{
  def main(args:Array[String]):Unit={
    var nm = readLine.split(" ").map(x => x.toInt)  
    var n = nm(0)
    var m = nm(1)
    var max = m/n
    var flag = true
    for(i <- max until 0 by -1 if flag){
      if(m%i==0){
        println(i)
        flag = false
      }
    }
  }
}

Measured memory_bytes: 27884
#include <stdio.h>

int main(void)
{
	//printf("helloWorld\n");
	//変数定義
	int iHeight;					//縦の長さ
	int iWidth;						//横の長さ
	int iHeightCount;			//縦カウンタ
	int iWidthCount;			//横カウンタ

	//0以外の整数で初期化
	iHeight = 1;
	iWidth = 1;

	//縦の長さiHeight=0、横の長さiWidth=0になるまでループ
	while (iHeight != 0 && iWidth != 0)
	{
		//縦の長さiHeightと横の長さiWidthを入力
		scanf("%d %d", &iHeight, &iWidth);

		//iHeight = 0 かつ iWidth = 0 になったときループから抜ける
		if (iHeight == 0 && iWidth == 0)
		{
			break;
		}
		//縦の長さがiHeightになるまでループ
		for (iHeightCount = 1; iHeightCount <= iHeight; iHeightCount++)
		{
			//横の長さがiWidthになるまでループ
			for (iWidthCount = 1; iWidthCount <= iWidth; iWidthCount++)
			{
				//iHeightとiWidhtの加算が奇数になるとき'.'を出力する
				if (((iHeightCount + iWidthCount) % 2) == 1)
				{
					printf(".");
				}
				//偶数のとき'#'を出力する
				else
				{
					printf("#");
				}
			}
			//1行分の出力が終わったら改行する
			printf("\n");
		}
		//最終行を迎えたら1つのデータセットの出力が終了のため、改行する
		printf("\n");
	}
	return 0;
}


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

bool S;
vector<int>A;
vector<int>B;
vector<int>C;
int d[9]; char e[9];
void saiki(int a) {
	if (a == 9) {
		int sum = 0;
		if (e[A[0]] == e[A[1]] && e[A[1]] == e[A[2]]) {
			int f[3];
			f[0] = d[A[0]]; f[1] = d[A[1]]; f[2] = d[A[2]];
			sort(f, f + 3);
			if (f[0] == f[1] && f[1] == f[2])sum++;
			if (f[0]+1 == f[1] && f[1]+1 == f[2])sum++;
		}
		if (e[B[0]] == e[B[1]] && e[B[1]] == e[B[2]]) {
			int f[3];
			f[0] = d[B[0]]; f[1] = d[B[1]]; f[2] = d[B[2]];
			sort(f, f + 3);
			if (f[0] == f[1] && f[1] == f[2])sum++;
			if (f[0] + 1 == f[1] && f[1] + 1 == f[2])sum++;
		}
		if (e[C[0]] == e[C[1]] && e[C[1]] == e[C[2]]) {
			int f[3];
			f[0] = d[C[0]]; f[1] = d[C[1]]; f[2] = d[C[2]];
			sort(f, f + 3);
			if (f[0] == f[1] && f[1] == f[2])sum++; if (f[0] + 1 == f[1] && f[1] + 1 == f[2])sum++;
		}
		if (sum == 3)S = true;
	}
	else {
		if (A.size() < 3) { A.push_back(a); saiki(a + 1); A.pop_back(); }
		if (B.size() < 3) { B.push_back(a); saiki(a + 1); B.pop_back();}
		if (C.size() < 3) { C.push_back(a); saiki(a + 1); C.pop_back();}
	}
}
int main()
{   
	int a; cin >> a;
	for (int b = 0; b < a; b++) {
		S = false; A.clear(); B.clear(); C.clear();
		for (int g = 0; g < 9; g++)scanf("%d", &d[g]);
		for (int g = 0; g < 9; g++)cin >> e[g];
		saiki(0);
		cout << S << endl;
	}
}

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

int main()
{
    int a = (cin >> (a), a),
        b = (cin >> (b), b);

    if (a == 1)
        a += 13;
    if (b == 1)
        b += 13;

    if (a < b)
        cout << "Bob" << endl;
    else if (a == b)
        cout << "Draw" << endl;
    else
        cout << "Alice" << endl;

    return 0;

    //system("pause");
    return 0;
}

Measured memory_bytes: 888
#include <stdio.h>

int main(void) {
	int K,S,i,j,k,res=0;
	scanf("%d%d",&K,&S);
	for(i=0;i<=K;i++){
		for(j=0;j<=K;j++){
			if(S-i-j>=0&&S-i-j<=K){
				res++;
			}
		}
	}
	printf("%d",res);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int mod = 1e9+7;

int main(){
 
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n, weight;
    cin>>n>>weight;

    ll W[n], V[n];
    ll value_sum = 0;
    for(ll i=0; i<n; i++){
    	cin>>W[i]>>V[i];
    	value_sum+=V[i];
    }



    vector<vector<ll>> dp(value_sum+1, vector<ll>(n+1, INT_MAX));
    dp[0][0]=0;
    for(ll i=0; i<=value_sum; i++){
    	for(ll j=1; j<=n; j++){
    		if(!i){
    			dp[i][j] = 0;
    			continue;
    		}
    		if(V[j-1]<=i){
    	 		dp[i][j] = min(dp[i][j-1], dp[i-V[j-1]][j-1] +W[j-1]);
    	 		// cout<<dp[i-W[j-1]][j-1]+V[j-1]<<dp[i][j]<<endl;
    		}else dp[i][j] = dp[i][j-1];
    		// cout<<dp[i][j-1]<<" "<<dp[i][j]<<"    ";
    	}
    	// cout<<endl;
    }
    ll ans = 0;
    // cout<<weight<<endl;
    for(ll i=0; i<=value_sum; i++){
    	// cout<<i<<" ";
    	for(ll j=0; j<=n; j++){
    		// cout<<dp[i][j]<<" ";
			if(dp[i][j]<=weight){
				ans = max(ans, i);
			}
    	}
    	// cout<<endl;
    }

	cout<<ans;
	return 0;
}		


Measured memory_bytes: 82304