akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)output(a[i],i!=n-1?',':10);}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

vector<int> g[1000];
int grundy(int v, int p);

int vvv;
void dfs(int v, int p, int gr, int vvv, vector<int> &gv) {
  FOR(it, g[v]) {
    if (*it == p) continue;
    gr ^= grundy(*it, v);
  }
  // if (gr == 0) {
  //   cout << p+1 << " " << vvv+1 << " " << v+1 << endl;
  // }
  gv.push_back(gr);
  FOR(it, g[v]) {
    if (*it == p) continue;
    dfs(*it, v, gr ^ grundy(*it, v), vvv, gv);
  }
}

int dp[1000];
int grundy(int v, int p) {
  if (dp[v] >= 0) return dp[v];
  vvv= v;
  vector<int> gv;
  dfs(v,p,0,v,gv);
  sort(ALL(gv));
  int res = 0;
  gv.erase(unique(ALL(gv)), gv.end());
  REP(i,gv.size()) {
    if (gv[i] != res) break;
    res++;
  }
  // cout << v+1 << " " << gv << " " << res << endl;
  return dp[v] = res;
}

int main() {
  int n,m;
  while(cin >> n >> m) {
    REP(i,n) g[i].clear();
    vector<int> num(n);
    REP(i,m) {
      int p; cin >> p;
      g[p-1].push_back(i);
      num[i]++;
    }
    memset(dp,-1,sizeof(dp));
    int gr = 0;
    REP(i,n) {
      if (num[i] == 0) {
        gr ^= grundy(i,-1);
      }
    }
    // output(dp,n);
    cout << (gr?"Alice":"Bob") << endl;
  }
}


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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

string K;
int D;
int dp[11111][2][111]; // dp[i桁目][未満フラグ][mod Dした値] = 総数

signed main() {
  cin >> K >> D;

  dp[0][0][0] = 1; // 初期化
  // DP
  for (int digit = 0; digit < K.size(); digit++) {
    for (int smaller : {0, 1}) {
      for (int modD = 0; modD < D; modD++) {
        int lim = (smaller ? 9 : K[digit] - '0');
        for (int num = 0; num <= lim; num++) {
          int nSmaller = smaller || (num < lim);
          Add(dp[digit+1][nSmaller][(modD + num) % D], dp[digit][smaller][modD]);
        }
      }
    }
  }

  int ans = 0;
  for (int smaller : {0, 1}) {
    Add(ans, dp[K.size()][smaller][0]);
  }

  Add(ans, -1LL); // 0になる場合の数を引く
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,a[110],sum = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		sum += a[i];
	}
	int mi = INF,mii;
	for(int i = 0;i < n;i++){
		if(mi > abs(sum - a[i] * n)){
			mi = abs(sum - a[i] * n);
			mii = i;
		}
	}
	cout << mii << endl;
}

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

int main() {
    string s;
    cin>>s;
    int len=s.size();
    long long ans=0;
    for(int i=0;i<len;i++){
        ans+=s[i]-'0';
    }
    if(ans%9==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}


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

d = []
for i in range(m):
    a,b,c = list(map(int,input().split()))
    d.append([a-1,b-1,c])

e = [[100000 for i in range(n)] for j in range(n)]

for i in range(n):
    e[i][i] = 0
for i in d:
    e[i[0]][i[1]] = i[2]
    e[i[1]][i[0]] = i[2]

for k in range(n):
    for i in range(n):
        for j in range(n):
            e[i][j] = min(e[i][j],e[i][k]+e[k][j])

ans = 0

for i in d:
    if e[i[0]][i[1]] != i[2]:
        ans += 1
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
#include <algorithm>
#include <utility>
#include <list>
#include <tuple>
#include <map>
#include <stack>
#include <queue>
#include <string>

using std::cout;
using std::cin;
using std::cerr;
using std::endl;
using std::vector;

int evaluation(const vector<int>& c, const vector<vector<int>>& s, const vector<int>& last, int day, int t) {
    int result = s[day - 1][t - 1];
    for (int i = 0, size = c.size(); i < size; i++) {
        result -= c[i] * (day - last[i]);
    }
    return result;
}

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

    vector<int> c(26);
    vector<vector<int>> s(d, vector<int>(26));
    vector<int> t(d);
    vector<int> last(26, 0);

    for (auto&& v : c) {
        cin >> v;
    }
    for (auto&& vec : s) {
        for (auto&& v : vec) {
            cin >> v;
        }
    }

    int score = 0;
    for (int i = 0; i < d; i++) {
        int max = INT_MIN;
        int max_idx;
        for (int j = 0; j < 26; j++) {
            int tmp = last[j];
            last[j] = i + 1;
            int eva = evaluation(c, s, last, i + 1, j + 1);
            if (max < eva) {
                max = eva;
                max_idx = j;
            }
            last[j] = tmp;
        }
        last[max_idx] = i + 1;
        t[i] = max_idx + 1;
        score += evaluation(c, s, last, i + 1, t[i]);
    }

    for (const auto& v : t) {
        cout << v << endl;
    }
    return 0;
}

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


int main() {

  int N;
  int ans = 0;

  cin >> N;
  for(int i=0;i<N;++i){
    int a,b; cin >> a >> b;
    if(a == b){
      ans++;
    }else{
      ans = 0;
    }

    if(ans == 3){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
    long double n, m ,d;
    cin >> n >> m >> d;

    if(d == 0){
        printf("%.10Lf\n", (m-1)/n);
    }
    else{
        printf("%.10Lf\n", 2*(n-d)*(m-1)/(n*n));
    }
    return 0;
}

Measured memory_bytes: 3780
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
from collections import Counter
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def combination(m,n):
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))


N, K= [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
go = 0

for i in range(K,N+2):
    ans_= (i*(N-i+1) + 1) % 1000000007
    ans += ans_
    go += 1
    

print(ans%1000000007)

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


int main(){
  int r;
  cin >>r;
  if(r<1200){
    cout << "ABC" << endl;
  }
  else if(r<2800){
    cout <<"ARC" << endl;
  }
  else{
    cout << "AGC" << endl;
  }
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=61
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef pair<int,int> pairii;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int a,b,x;
  cin>>a>>b;
  if(b<10)x=10*a+b;
  else if(b==100)x=1000*a+b;
  else x=100*a+b;
  rep(i,2000){
    if(i*i==x){cout<<"Yes"<<endl;return 0;}
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = n
for i in range(n+1):
    j = n - i
    preans = 0
    while i > 0:
        preans += i % 6
        i //= 6
    while j > 0:
        preans += j % 9
        j //= 9
    ans = min(ans, preans)
print(ans)

Measured memory_bytes: 40940
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N,M = inpl()
kk = []
ss = []
for i in range(M):
    ks = inpl()
    kk.append(ks[0])
    ss.append(ks[1:])

pp = inpl()

ans = 0
for bit in range(1<<N):
    on = [False]*N
    for b in range(N):
        if bit & (1<<b):
            on[b] = True
    for m in range(M): #電球
        k = kk[m]
        tmp = 0
        for n in range(N): # スイッチ
            if on[n] and (n+1 in ss[m]):
                tmp += 1
        if tmp%2 != pp[m]:
            break
    else:
        ans += 1

print(ans)


Measured memory_bytes: 4340
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <tuple>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

using T = tuple<ll,ll>;
using Graph = vector<vector<T>>;

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

    ll k;
    string s;
    cin >> k >> s;

    //cout << k << ' ' << s.size() << endl;

    if (k<s.size())
    {
        rep(i,0,k) cout << s[i];
        cout << "..." << endl;
    }
    else
    {
        rep(i,0,s.size()) cout << s[i];
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#pragma GCC optimize("Ofast")
#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 <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,M;
    cin >> N >> M;
    vector<int> A(N),B(N);
    for(int i=0; i<N; i++){
      cin >> A[i] >> B[i];
    }
    vector<int> C(M),D(M);
    for(int i=0; i<M; i++){
      cin >> C[i] >> D[i];
    }
    vector<int> ans(N);
    for(int i=0; i<N; i++){
      int mn = inf;
      for(int j=0; j<M; j++){
        if(chmin(mn,abs(A[i]-C[j])+abs(B[i]-D[j]))){
          ans[i] = j+1;
        }
      }
    }
    for(int i=0; i<N; i++){
      cout << ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	private static List<Long> getStrings(Scanner sc, int num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			long nextInt = sc.nextLong();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Long> list = getStrings(sc, n);
		long sum = 0;
		for (int i = 0; i < list.size(); i++) {
			sum = sum ^ list.get(i);
		}
		for (int i = 0; i < list.size(); i++) {
			System.out.println(sum ^ list.get(i));
		}
	}

}


Measured memory_bytes: 68520
#include<iostream>
using namespace std;
#define MAX 10000

int search(int S[], int n, int x){
    S[n] = x;
    int j = 0;
    while ( S[j] != x ){
        j++;
    }
    if ( j == n) return 0;
    else return 1;
}

int main(){
    int n, q, S[MAX], c = 0, v;
    cin >> n;
    for ( int i = 0; i < n; i++) cin >> S[i];
    cin >> q;
    for ( int i = 0; i < q; i++){
        cin >> v;
        c += search(S, n, v);
    }

    cout << c << endl;

    return 0;
}


Measured memory_bytes: 3116
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

last = 9
if a % 10 != 0:
  last = a
if (b % 10 != 0 and last % 10 > b % 10):
  last = b
if (c % 10 != 0 and last % 10 > c % 10):
  last = c
if (d % 10 != 0 and last % 10 > d % 10):
  last = d
if (e % 10 != 0 and last % 10 > e % 10):
  last = e
if (a % 10 == 0 and b % 10 == 0 and c % 10 == 0 and d % 10 == 0 and e % 10 == 0):
  last = a
  
print(-(-a // 10) * 10 - (-b // 10) * 10 -(-c // 10) * 10 - (-d // 10) * 10 -(-e // 10) * 10 + last + (-last // 10) * 10)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <cstdlib>  // abs() for integer
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

//深さ優先探索


int main(void) {
    int M,D;
    cin >> M>>D;
    int day=0;
    
    for (int i =1;i<D+1;i++)
    {int d1 = i/10;
        int d2 = i%10;
        if (d1 <=1) continue;
        else if (d2 <=1) continue;
        
        else if (d1*d2<=M) day++;
        }
    cout << day;
}


Measured memory_bytes: 256
import itertools
import numpy as np
import sys
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,M = IL()
print( ((N-M)*100 + M*1900)*2**M )

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

using namespace std;

int main() {
    long long N;
    long long num_min = 1LL << 62;

    cin >> N;
    for (int i = 0; i < 5; i++) {
        long long num;
        cin >> num;

        num_min = min(num_min, num);
    }

    cout << 4 + (N + num_min - 1)/num_min << endl;
    return 0;
}



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

D = [[0 for j in range(64)] for i in range(N-2)]

for i in range(64):
    if i%4==0 and (i//4)%4==1 and  (i//16)%4==2:
        D[0][i]=0
    elif i%4==0 and (i//4)%4==2 and  (i//16)%4==1:
        D[0][i]=0
    elif i%4==1 and (i//4)%4==0 and  (i//16)%4==2:
        D[0][i]=0
    else:
        D[0][i]=1
for i in range(N-3):
    for j in range(64):
        for k in range(4):
            if (j//4)%4==0 and (j//16)%4==1 and  k==2:
                add = 0
            elif (j//4)%4==0 and (j//16)%4==2 and  k==1:
                add = 0
            elif (j//4)%4==1 and (j//16)%4==0 and  k==2:
                add = 0
            elif j%4==0 and (j//4)%4==1 and  k==2:
                add = 0
            elif j%4==0 and (j//16)%4==1 and  k==2:
                add = 0
            else:
                new_index=(j//4)%4+((j//16)%4)*4 + k*16
                D[i+1][new_index]=(D[i+1][new_index]+D[i][j])%(10**9+7)
                
                
print(sum(D[N-3])%(10**9+7))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    ll cur = 0;
    ll now = -2;
    vector<ll> v;
    if(N==0)v.push_back(0);
    while(N != 0){
        if(N % now == 0){
            v.push_back(0);
        }else{
            v.push_back(1);
            N--;
        }
        N /= -2;
    }
    reverse(v.begin(),v.end());
    rep(i,v.size()){
        cout << v[i];
    }
    cout << endl;
}

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

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

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

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


int main() {
    int n;
    scanf("%d",&n);
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    sort(a,a+n);
    ll ans = 1;

    if(n%2==0){
        rep(i,n/2){
            if(a[i*2]==i*2+1&&a[i*2+1]==i*2+1){
                ans*=2;
                ans %= 1000000007;
            }else{
                ans = 0;
                break;
            }
        }
    }else{
        if(a[0]!=0){
            ans = 0;
        }
        rep(i,n/2){
            if(a[(i+1)*2-1]==(i+1)*2&&a[(i+1)*2]==(i+1)*2){
                ans*=2;
                ans %= 1000000007;
            }else{
                ans = 0;
                break;
            }
        }
    }

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



Measured memory_bytes: 1024
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main(void) {
	vector<int> r;
	while (true)
	{
		int n=0,m=0,p=0;
		scanf("%d %d %d",&n,&m,&p);
		if (n==0 && m==0 && p==0){
			break;
		}
		int ticket=0,winner=0;
		for (int i=0; i<n; i++)
		{
			int x;
			scanf("%d", &x);
			ticket += x;
			if (i == m-1)
			{
				winner = x;
			}
		}
		if (winner != 0)
		{
			r.push_back(ticket*(100-p)/winner);
		} else {
			r.push_back(0);
		}
	}
	for(int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
 using namespace std;
 
 #define REP(i, a, n) for(int i=a; i<n; i++)
 #define sortv(v) sort(v.begin(), v.end());
 #define sortg(v) sort(v.begin(), v.end(), greater<>());
 int main() {
   int a, b, t;
   cin >> a >> b >> t;
   cout << t/a*b << endl;
 }
 

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    rep(i, N) cin >> A.at(i);
    long long sum1 = 0, sum2 = 0;
  
   rep(j, K){
        sum1 += A.at(K-j-1);
        sum2 += A.at(K-j);
     }
        if(sum1<sum2) cout << "Yes" << endl;
        else cout << "No" << endl;
    
    for(int i=0; i<N-K-1; i++){
    	sum1 = sum1 - A.at(i) + A.at(i+K);
      	sum2 = sum2 -A.at(i+1) + A.at(i+K+1);
      
      	if(sum1<sum2) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int n;

int main() {
  while (1) {
    scanf("%d", &n);
    if (n == 0) return 0;

    int sum = 0;
    int max_s = -1;
    int min_s = 1001;
    for (int i=0; i<n; i++) {
      int s;
      scanf("%d", &s);
      sum += s;
      max_s = max(max_s, s);
      min_s = min(min_s, s);
    }

    printf("%d\n", (sum-max_s-min_s)/(n-2));
  }
}

Measured memory_bytes: 2672
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def dijkstra(start):
    INF = 10 ** 15
    dist = [INF] * (N+1)
    dist[start] = 0
    que = [(0, start)]
    while que:
        d, prev = heappop(que)
        if dist[prev] < d:
            continue
        for next in graph[prev]:
            d1 = d + 1
            if dist[next] > d1:
                dist[next] = d1
                heappush(que, (d1, next))
    return dist

N = ir()
graph = [[] for _ in range(N+1)] # 1-indexed
for _ in range(N-1):
    a, b = lr()
    graph[a].append(b)
    graph[b].append(a)

# １を根とする
dist = dijkstra(1)
dist = sorted([(x, i) for i, x in enumerate(dist)], reverse=True)
new_root = dist[1][1]
dist = dijkstra(new_root)
diameter = max(dist[1:]) + 1
bl = diameter % 3 != 2
print('First' if bl else 'Second')
# 22

Measured memory_bytes: 89856
import sys

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())

flag = False
s = rr()
q = ri()
front = ''
end = ''
for _ in range(q):
    query = list(rs())
    if query[0] == '1':
        flag = not flag
        continue
    else:
        f = int(query[1])
        c = query[-1]
        if flag == True:
            if f == 1:
                end += c
            else:
                front = c+front
        else:
            if f == 1:
                front = c+front
            else:
                end += c
if flag:
    print((front+s+end)[::-1])
else:
    print(front+s+end)            

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

#define all(c) ((c).begin()), ((c).end())
#define dump(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define REP(i, a, b) for (int i = a; i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define mp make_pair
#define fst first
#define snd second
#define pb push_back
#define debug( fmt, ... ) \
        fprintf( stderr, \
                  fmt "\n", \
                  ##__VA_ARGS__ \
        )

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1 << 30;
const double EPS = 1e-10;

double zero(double d) {
    return d < EPS ? 0.0 : d;
}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a) {
    os << '[';
    rep(i, a.size()) os << (i ? " " : "") << a[i];
    return os << ']';
}

string toString(int i) {
    stringstream ss;
    ss << i;
    return ss.str();
}

const int MOD = 1000000007;
// a^k
ll fpow(ll a, ll k, int M) {
    ll res = 1ll;
    ll x = a;
    while (k != 0) {
        if ((k & 1) == 1)
            res = (res * x) % M;
        x = (x * x) % M;
        k >>= 1;
    }
    return res;
}

struct prepare {
	prepare() {
	    cout.setf(ios::fixed, ios::floatfield);
	    cout.precision(8);
	    ios_base::sync_with_stdio(false);
	}
} _prepare;

int main() {
	int N;
    cin >> N;
    vi A(N);
    rep(i, N)
        cin >> A[i];

    bool kuri = false;
    ll ans = 0;
    rep(i, N) {
        if(A[i] % 2 == 0) {
            ans += A[i] / 2;
            if(A[i] == 0)
                kuri = false;
        }
        else {
            if(kuri) {
                ans += (A[i] + 1) / 2;
                kuri = false;
            }
            else {
                ans += A[i] / 2;
                kuri = true;
            }
        }

    }

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


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

std::string s;

bool able();

int main()
{
	std::cin >> s;
	if (!able())
	{
		printf("-1\n");
		return 0;
	}
	int pre{0};
	for (unsigned int i = 0; i < s.size() - 1; i++)
	{
		printf("%d %d\n", pre + 1, i + 2);
		if (s[i] == '1') pre = i + 1;
	}

	return 0;
}

bool able()
{
	if (s.front() == '0' || *(s.end() - 2) == '0' || s.back() == '1') return false;
	for (unsigned int i = 0; i < s.size() - 1; i++)
		if (s[i] != s[s.size() - i - 2]) return false;
	return true;
}

Measured memory_bytes: 1664
N = int(input())
S = input()


ans = N+1

# ...
wnum = S.count('.')
# ###
bnum = S.count('#')

# ...###
wcnt = 0
bcnt = 0
for i, s in enumerate(S):
    l_wnum = wcnt
    l_bnum = bcnt
    r_wnum = wnum - l_wnum
    step = l_bnum + r_wnum
    if step < ans:
        ans = step

    #print('i: ', i)
    if s == '.':
        wcnt += 1
    else:
        bcnt += 1

# ...
if bnum < ans:
    ans = bnum

print(ans)


Measured memory_bytes: 3500
//INCLUDE
//------------------------------------------
#include <iostream>
#include <functional>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <string>
#include <cstring>
#include <vector>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
using namespace std;
//-------------------------------------------
int main(void){
  ll N,M;cin>>N>>M;
  vector<vi> s(M);ll K;
  REP(i,M){
    cin>>K;
    s[i]=vi(K);
    REP(j,K){
      cin>>s[i][j];
      s[i][j]--;
    }
  }
  vi p(M);
  REP(i,M){
    cin>>p[i];
  }
  ll ans=0;
  for(int i=0;i<(1<<N);i++){
    bool is=true;
    REP(j,M){
      int count=0;
      REP(k,s[j].size()){
        if(i&(1<<s[j][k]))count++;
      }
      if(count%2!=p[j]){
        is=false;
        break;
      }
    }
    if(is)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll pow(ll n, ll k = 5) {
	
	ll ans = 1;
	
	while (k > 0) {
		
		if (k & 1)
			ans = ans * n;
			
		n = n * n;
		k >>= 1;
	}
	
	return ans;
}

ll binarysearch (ll value, bool *flag) {
	
	ll front, end;
	
	if (value > 0)
		front = 0, end = 1001;
	else
		front = -1001, end = 0;
//	cout << front << " " << end << " ";
	while (front <= end) {
		
		ll mid = front + (end - front) / 2;
		
		ll x = pow(mid, 5);
		
		if (x == value)
			return mid;
			
		else if (x < value)
			front = mid + 1;
		else
			end = mid - 1;
	}
	
	*flag = false;
	return -1;
}

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    
	ll x, a, b;
	cin >> x;
	bool flag = false;
	rep_a(i,1,1001) {
		b = (ll)i;
		ll y = pow(b,5);
		
		flag = true;
		a = binarysearch(x + y, &flag);
		if (flag)
			break;
			
		flag = true;
		b = (-1)*b;
		a = binarysearch(x - y, &flag);
		if(flag)
			break;
	}
	
	cout << a << " " << b << "\n";
	
	//code
	return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  int sek = a*b;
  
  if( sek%2 == 0 ){
	cout << "Even" << endl;
  	}else{
    cout << "Odd" << endl;
   	}  
}


Measured memory_bytes: 256
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  if s[0] == s[1]:
    if s[2] == s[3]:
      print('Yes')
    else:
      print('No')
  elif s[0] == s[2]:
    if s[1] == s[3]:
      print('Yes')
    else:
      print('No')
  elif s[0] == s[3]:
    if s[1] == s[2]:
      print('Yes')
    else:
      print('No')
  else:
    print('No')

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
#if DEBUG
            ReadLine();
#endif
        }

        void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            int k = cin.ReadInt;

            n = n % 2 == 0 ? n : n + 1;
            string result = (n / 2 >= k) ? "YES" : "NO";

            Console.WriteLine(result);
        }

        class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;

            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }

            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }

            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}

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

ll solve() {
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> w1(N,-1), w2(N,-1);
    int nw = 0, r = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( S[i] == 'o' && r == 0 ) {
            nw++;
            w1[i] = nw;
            r = C;
        } else {
            if ( r > 0 ) r--;
        }
    }
    if ( nw > K ) {
        cout << "\n";
        return 0;
    }

    nw = 0, r = 0;
    for ( int i = N-1; i >= 0; i-- ) {
        if ( S[i] == 'o' && r == 0 ) {
            nw++;
            w2[i] = nw;
            r = C;
        } else {
            if ( r > 0 ) r--;
        }
    }
    for ( int i = 0; i < N; i++ ) {
        if ( w1[i] >= 0 && w2[i] >= 0 && w1[i] + w2[i] == K+1 ) {
            cout << i+1 << "\n";
        }
    }
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3332
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner scan=new Scanner(System.in);
Formatter f=new Formatter();
int a=scan.nextInt();
int b=scan.nextInt();
int d=a/b;
int r=a%b;
f.format("%.5f",(double)a/b);
System.out.println(d+" "+r+" "+f);
}}

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

int main(){

  char s[4];

  cin >> s[0] >> s[1] >> s[2] >> s[3];
  int a,b;
  a = (s[0] -'0')*10 + (s[1] - '0');
  b = (s[2] - '0')*10 + (s[3] - '0');

  if(a>=1&&a<=12){
    if(b>=1&&b<=12){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "MMYY" << endl;
    }
  }else{
    if(b>=1&&b<=12){
      cout << "YYMM" << endl;
    }else{
      cout << "NA" << endl;
    }
  }


}


Measured memory_bytes: 256
let solve w =
  let rec doit i s acc =
    let g = 2. ** float i |> truncate in
    if g = s then g :: acc
    else if g > s then doit (i - 1) s acc
    else doit (i - 1) (s - g) (g :: acc) in
  doit 9 w []

let () =
  let rec main_loop () =
    read_int () |> solve |> List.iteri (fun i e -> Printf.printf (if i = 0 then "%d" else " %d") e);
    print_newline ();
    main_loop () in
  try main_loop () with _ -> ()

Measured memory_bytes: 2396
#include<stdio.h>
#include<string.h>
int main()
{
	int i,x,y,len,len1,len2;
	char a[51],b[51];
	while(scanf("%s",a)!=EOF)
	{
		x=0;y=0;
		getchar();
		scanf("%s",b);
		getchar();
		len1=strlen(a);
		len2=strlen(b);
		len=len1+len2;
		for(i=0;i<len;i++)
		{
			if(i%2==0)
			   printf("%c",a[x++]);
			else
			   printf("%c",b[y++]);
		}
		printf("\n");
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
	}
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll N;cin>>N;
    string S;cin>>S;
    vector<ll>red;
    rep(i,N){
        if(S[i]=='R'){
            red.push_back(i);
        }
    }
    ll M=red.size();
    if(M==0||M==N){
        cout<<0<<endl;
    }
    else{
        ll ans=0;
        int mark=1;
        rep(i,N){
            if(mark>=M||i>=red[M-mark]){
                break;
            }
            if(S[i]=='W'){
                S[red[M-mark]]='W';
                S[i]='R';
                ans++;
                mark++;
            }
        }
        rep(i,N-1){
            if(S[i]=='W'&&S[i+1]=='R'){
                S[i]='R';
                ans++;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
char num[20];
int main()
{
	while(~scanf("%s",num))
	{
		int len=strlen(num);
		int i=len-1;
		for(;i>=0;i--)
		{
			if(num[i]!='9') break;
		}
		if(i==-1) printf("%d\n",len*9);
		else if(i==0) printf("%d\n",(len-1)*9+num[0]-'0');
		else printf("%d\n",(len-1)*9+num[0]-'0'-1);
	}
	return 0;
} 

Measured memory_bytes: 128
//http://code-festival-2016-qualb.contest.atcoder.jp/tasks/codefestival_2016_qualB_c
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;

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

typedef long long ll;

int main()
{
	int W, H;
	cin >> W >> H;
	typedef pair<ll, bool> t; //(cost, p_or_q)
	vector<t> es;
	REP(i, W) {
		int p;
		cin >> p;
		es.emplace_back(p, true);
	}
	REP(j, H) {
		int q;
		cin >> q;
		es.emplace_back(q, false);
	}
	sort(ALL(es));

	ll ans = 0;
	ll a = W + 1;
	ll b = H + 1;
	for (const auto& e : es) {
		ll cost;
		bool p_or_q;
		tie(cost, p_or_q) = e;
		if (p_or_q) {
			a--;
			ans += cost * b;
		} else {
			b--;
			ans += cost * a;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4592
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int x1,x2,y1,y2,i,j,k;
    scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
    i=max(x1,x2);
    j=min(y1,y2);
    if(i>j)
    {
        printf("0\n");
        return 0;
    }
    else
    {
        k=j-i;
        printf("%d\n",k);
        return 0;
    }
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <utility>
int main() {
  int N;
  std::cin >> N;
  std::unordered_map<int, int> m{};
  for (int i = 0; i < N; ++i) {
    int n;
    std::cin>>n;
    ++m[n];
    ++m[n - 1];
    ++m[n + 1];
  }

  int max = 0;
  for (auto &n : m) {
    max = std::max(max, n.second);
  }

  std::cout << max << std::endl;
}


Measured memory_bytes: 4260
import java.util.*;
class Main
{
  static long fact(int n)
  {
    long f=1;
    for(;n>0;n--)
      f*=n;
    return(f);
  }
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int N=sc.nextInt();
    int M=sc.nextInt();long a,b;
    if(M==2)
      a=1;
    else
     a=(M*(M-1))/2;
    if(N==2)
       b=1;
    else
     b=(N*(N-1))/2;
    System.out.println(a+b);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define FORD(i,a,b) for(int i=(a);i>=b;i--)
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)
#define ll long long
using namespace std;
int main() {
	int n,m;
	cin>>n>>m;
	if(n>m) FOR(i,0,n)cout<<m;
	else FOR(i,0,m)cout<<n;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    ll n, k;
    cin >> n >> k;

    vector<ll> arr(n);

    for (ll &x : arr)
        cin >> x;
    sort(arr.begin(), arr.end());

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (n - i <= k)
            break;
        ans += arr[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll n,w;
    cin>>n>>w;
    ll a[n+1],b[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i];
    }
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        dp[i][j]=0;
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++) {
            if (a[i] <= j) {
                dp[i][j] = max(dp[i - 1][j], b[i] + dp[i - 1][j - a[i]]);
            } else {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[n][w];
    return 0;
}

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

Measured memory_bytes: 760
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
// #define DEBUG 10
 
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const ll mod = 1e9+7, maxn = (2 * 1e5) + 10 , maxm = (1 << 18);
const ld PI = acos(-1);
int parent[maxn];

void init(int n){
    for (int i=0; i<=n; i++) parent[i] = i;
}

int find(int x){
    if (x == parent[x]) return x;
    else return parent[x] = find(parent[x]);
}

void union_set(int a, int b){
    a = find(a);
    b = find(b);
    if (a == b) return;
    if (a > b) swap(a, b);

    parent[b] = a;
}

int main (){
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    set<int> ans;
    init(n);

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

    for (int i=1; i<=n; i++){
        ans.insert(find(i));
    }

    cout << ans.size() << endl;
    return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 2e5 + 5;

void fail(bool iff, int step) {
    if (iff) {
        debug(cout << "Failed at step " << step << endl;)
        cout << "No" << endl;
        exit(0);
    }
}

bool f(vector<int>& x, vector<char>& ans, const vector<pair<char, char>>& q, int i) {
    for (int i = 0; i < 3; i++) {
        if (x[i] < 0)
            return false;
    }

    if (i == (int)q.size())
        return true;

    auto [a, b] = q[i];
    a -= 'A';
    b -= 'A';

    ans.push_back(a + 'A');
    x[a]++;
    x[b]--;
    bool done = f(x, ans, q, i+1);
    if (done)
        return true;

    x[a] -= 2;
    x[b] += 2;
    ans.pop_back();
    ans.push_back(b + 'A');
    done = f(x, ans, q, i+1);
    if (done)
        return true;

    x[a]++;
    x[b]--;
    ans.pop_back();
    return false;
}

int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n; cin >> n;
    vector<int> x(3);
    for (auto& y : x) cin >> y;

    string s;
    vector<pair<char, char>> q(n);
    for (int i = 0; i < n; i++) {
        cin >> s;
        q[i] = { s[0], s[1] };
    }

    vector<char> ans; ans.reserve(n);
    bool done = f(x, ans, q, 0);

    fail(!done, -1);

    cout << "Yes" << endl;
    for (char c: ans)
        cout << c << endl;
    cout << endl;

    return 0;
%>

Measured memory_bytes: 13132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,e,m,n,t;
    string s1,s2, s3;
    
    /*
    cin>>t;
    while(t--)
    {
        
    }
    */
    cin>>s1>>s2;
    cout<<s2<<s1;
    
    return 0;
}

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

bool usednumber[1000005];
bool ng[1000005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.begin(), a.end());
    a.emplace_back(a.back() + 1);
    
    int ans = 0;
    for(int i = 0; i < n; ++i){
        if(usednumber[a[i]] || ng[a[i]])    continue;
        usednumber[a[i]] = true;
        if(a[i] != a[i + 1])    ++ans;
        for(int j = a[i] * 2; j < a[n]; j += a[i]){
            if(*lower_bound(a.begin() + i + 1, a.end(), j) == j)    ng[j] = true;
        }
    }
    cout << ans << endl;
}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int res = 0;
	for (int i = 1; i <= 5; ++i){
		int x;
		cin>>x;
		if (!x){
			res = i;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3648