akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
int bubbleSort(int *,int);
void swap(int *x,int *y);

int main(){
  int i,n,*m,count;
  scanf("%d",&n);
  m = (int *)malloc(n * sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d",&m[i]);
  }
  count = bubbleSort(m,n);
  for(i=0;i<n;i++){
    printf("%d",m[i]);
    if(i!=n-1){
      printf(" ");
    }
    else printf("\n");
  }
  printf("%d\n",count);
  return 0;
}

int bubbleSort(int *m,int n){
  int flag=1,i,count=0;
  while(flag){
    flag=0;
    for(i=n-1;i>0;i--){
      if(m[i]<m[i-1]){
        swap(&m[i],&m[i-1]);
        flag=1;
        count++;
      }
    }
  }
  return count;
}

void swap(int *x,int *y){
  int r;
  r=*x;
  *x=*y;
  *y=r;
}


Measured memory_bytes: 2144
/******************************************************************************

рассвет.

*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int>
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s)
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i];
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=5e4+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("bridges.in", "r", stdin);
    //freopen("bridges.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
         readll(n);
         vlli a(n);
         fr(i,n) cin >> a[i];
         srt(a);
         lli ans=0;
         fr(i,n){
             fr(j,i){
                 lli k=lower_bound(all(a),a[i]+a[j])-a.begin();
                 ans+=k-i-1;
             }
         }
         cout << ans;
    }
    return 0;
}

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

using namespace std;

int H, W;

string s[55];

bool CHECK(void) {

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (s[i][j] != '#') {
				continue;
			}

			if (s[i - 1][j] != '#' && s[i + 1][j] != '#' &&s[i][j - 1] != '#' && s[i][j + 1] != '#') { return false; }
		}
	}
	return true;
}
int main(void) {

	cin >> H >> W;

	string tmp;

	for (int i = 1; i <= 55; i++) {
		tmp += "?";
	}
	s[0] = tmp;
	s[H+1] = tmp;
	for (int i = 1; i <= H; i++) {
		cin >> tmp;
		s[i] = "?" + tmp + "?";
	}

	if (CHECK()) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }

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

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

ll n, k, r, s, p;

int rotate(int x) {
  if (x == 0) return 2;
  else return x-1;
}

int point(int x) {
  if (x == 0) return r;
  else if (x == 1) return s;
  else return p;
}

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

  cin >> n >> k >> r >> s >> p;
  //char t[n];
  int tmp[n];
  rep(i, n) {
    char t;
    cin >> t;
    if (t == 'r') tmp[i] = 0;
    if (t == 's') tmp[i] = 1;
    if (t == 'p') tmp[i] = 2;
  }
  int win[n];
  vector<bool> won(n, true);
  // kの制約を無視してとりあえず勝ち手を考える
  rep(i, n) {
    if(tmp[i] == 0) win[i] = 2;
    else win[i] = tmp[i]-1;
  }

  ll ans = 0;
  // 駄目なところを探す
  for(ll i = 0; i < n-k; i++) {
    if (win[i] == win[i+k]) {
      won[i+k] = false;
      win[i+k] = rotate(win[i+k]);
      if (i < n-k-k && win[i+k] == win[i+k+k]) {
        win[i+k] = rotate(win[i+k]);
      }
    }
  }
  //rep(i, n) {
  //  printf("%d", int(tmp[i]));
  //}
  //printf("\n");
  //rep(i, n){
  //  printf("%d", int(win[i]));
  //}
  //printf("\n");
  //rep(i,n) {
  //  printf("%d", int(won[i]));
  //}

  // 加点
  rep(i, n) {
    if(won[i])ans += point(win[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    cout << "Christmas ";
    while (n < 25) cout << "Eve ", n++;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    vector<string> a;
    string tmp_str;
    int h, w;
    cin >> h >> w;
    for(int i = 0; i < h; i++){
        cin >> tmp_str;
        a.push_back(tmp_str);
    }
    bool erase = true;
    for(int i = 0; i < h; i++){
        erase = true;
        tmp_str = a[i].c_str();
        for(int j = 0; j < w; j++){
            if(tmp_str[j] != '.'){
                erase = false;
                break;
            }
        }
        if(erase){
            a.erase(a.begin() +i);
            h--;
            i--;
        }
    }
    for(int j = 0; j < w; j++){
        erase = true;
        for(int i = 0; i < h; i++){
            tmp_str = a[i].c_str();
            if(tmp_str[j] != '.'){
                erase = false;
                break;
            }
        }
        if(erase){
            for(int i = 0; i < h; i++){
                tmp_str = a[i].c_str();
                tmp_str.erase(j, 1);
                a[i] = tmp_str;
            }
            w--;
            j--;
        }
    }
    for(int i = 0; i < h; i++){
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x[4],y[4];
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    
    int yd=abs(y[1]-y[0]);
    int xd=abs(x[1]-x[0]);
    
    if(x[0]<x[1]){
        if(y[0]<y[1]){
            x[2] = x[1] - yd;
            y[2] = y[1] + xd;
            x[3] = x[2] - xd;
            y[3] = y[2] - yd;
        }else{
            x[2] = x[1] + yd;
            y[2] = y[1] + xd;
            x[3] = x[2] - xd;
            y[3] = y[2] + yd;
        }
    }else{
        if(y[0]<y[1]){
            x[2] = x[1] - yd;
            y[2] = y[1] - xd;
            x[3] = x[2] + xd;
            y[3] = y[2] - yd;
        }else{
            x[2] = x[1] + yd;
            y[2] = y[1] - xd;
            x[3] = x[2] + xd;
            y[3] = y[2] + yd;
        }
    }
    
    cout << x[2] <<" "<< y[2] <<" "<<x[3]<<" "<<y[3]; 
    
}


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

const int maxn=10005;
int ans[maxn][maxn];
int n, h, w, data[maxn*2];

int main()
{
    while(~scanf("%d%d", &h, &w)){
        scanf("%d", &n);
        int cnt=0, now=1, pos=1;
        int i=0, j=0;
        for(int k=1;k<=n;k++){
            scanf("%d", &data[k]);
            while(data[k]--){
                ans[i][j]=k;
                if(i%2==0){
                    j++;
                    if(j==w){
                        i++;
                        j=w-1;
                    }
                }
                else{
                    j--;
                    if(j==-1){
                        i++;
                        j=0;
                    }
                }
            }
        }
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                printf("%d", ans[i][j]);
                printf("%s", j==w-1?"\n":" ");
            }
        }
    }
    return 0;
}


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

#define all(c) (c).begin(),(c).end()

using namespace std;

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

int main(void){
  ll n,m;
  cin >> n >> m;
  vector<pii> ab(n);
  for(int i=0;i<n;i++){
    cin >> ab[i].first >> ab[i].second;
  }
  sort(all(ab));
  ll sum=0, i=0;
  while(m>0){
    sum += ab[i].first * min(m, ab[i].second);
    m-=ab[i++].second;
  }
  cout << sum << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll int64_t
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

ll dp[101][101010];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,W;
    cin>>N>>W;
    vector<int> We(N),V(N);
    REP(i,N) cin>>We[i]>>V[i];

    REP(i,N){
        for(int w=0;w<=W;w++){
            chmax(dp[i+1][w],dp[i][w]);
            if(w-We[i]>=0) chmax(dp[i+1][w],dp[i][w-We[i]]+V[i]);

        }
    }
    cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 79104
n,k=map(int,input().split())
a=list(map(int,input().split()))
d={}
l=[]
for i in range(n):
    try:
        l[d[a[i]]]+=1
    except:
        d[a[i]]=len(l)
        l.append(1)
ans=0
l.sort()
for i in range(len(l)-k):
    ans+=l[i]
print(ans)

Measured memory_bytes: 36384
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[] a, b, c, d;
	int base;
	
	static Comparator<int[]> comp = Comparator.comparingInt(e -> e[0]);
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		a = new int[N];
		b = new int[N];
		c = new int[N];
		d = new int[N];
		for (int i = 0; i < N; i++) a[i] = sc.nextInt();
		for (int i = 0; i < N; i++)	b[i] = sc.nextInt();
		for (int i = 0; i < N; i++) c[i] = a[i] ^ a[(i+1)%N];
		for (int i = 0; i < N; i++) d[i] = b[i] ^ b[(i+1)%N];
		
		int[][] cmap = new int[N][2];
		for (int i = 0; i < N; i++) { cmap[i][0] = c[i]; cmap[i][1] = i; }
		Arrays.sort(cmap, comp);
		int s = 0;
		int min = Integer.MAX_VALUE;
		int minv = -1;
		int cnt = 1;
		int idx = -1;
		for (int i = 0; i < N; i++) {
			if (i == N-1 || cmap[i][0] != cmap[i+1][0]) {
				if (cnt < min) {
					min = cnt;
					minv = cmap[i][0];
					idx = s;
				}
				s = i;
				cnt = 0;
			}
			cnt++;
		}
		int[][] dmap = new int[N][2];
		for (int i = 0; i < N; i++) { dmap[i][0] = d[i]*2; dmap[i][1] = i; }
		Arrays.sort(dmap, comp);
		int didx = -1-Arrays.binarySearch(dmap, 0, N, new int[] {2*minv-1}, comp);
		int dcnt = -1-Arrays.binarySearch(dmap, 0, N, new int[] {2*minv+1}, comp)-didx;
		
		base = -1;
		for (int j = 0; j < dcnt; j++) {
			int k = 0;
			for (; k < N; k++)
				if (c[(cmap[idx][1]+k)%N] != d[(dmap[j+didx][1]+k)%N]) break;
			if (k == N) {
				base = (N+cmap[idx][1]-dmap[j+didx][1])%N;
				break;
			}
		}
		if (base == -1) return;
		Set<Integer> divs = new TreeSet<>();
		for (int i = 1; i <= Math.sqrt(N); i++) {
			if ((N%i)!=0) continue;
			divs.add(i);
			divs.add(N/i);
		}
		int[] ans = new int[N];
		for (int i = 0; i < N; i++) ans[i] = -1;
		ans[base] = a[base]^b[0];
		for (int div : divs) {
			if (ans[div%N] != -1) continue;
			if (checkSeq(div))
				for (int i = div; i <= N; i += div)
					ans[(base+i)%N] = a[(base+i)%N]^b[0];
		}
		for (int i = 0; i < N; i++)
			if (ans[i] > -1) System.out.println(i+" "+ans[i]);
	}
	
	private boolean checkSeq(int div) {
		if (div == N) return true;
		for (int i = 0; i < N; i++)
			if (c[i] != c[(i+div)%N]) return false;
		return true;
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 169724
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   cin>>n;

   int xo = 0;
   for (int i = 0; i < n; ++i)
   {
      cin>>a[i];
      xo ^= a[i];
   }

   if (xo == 0){
      cout<<"Yes\n";
   }
   else{
      cout<<"No\n";
   }

   

   return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>){
	Range()
}

fun Range(){
	val abc = readLine()!!.split(" ").map(String::toInt)
	val a = abc[0]
	val b = abc[1]
	val c = abc[2]
	when{
		a<b && a<c && b<c ->{
			println("Yes")
		}
		else ->{
			println("No")
		}
	}
}


Measured memory_bytes: 31996
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll>pii;
typedef vector<int>vi;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define fi first
#define se second
#define de(x) cout<<#x<<"="<<x<<"\n"
#define dd(x) cout<<#x<<"="<<x<<" "
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lowbit(a) ((a)&-(a))
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
const int N=4e5+5;
int A,B,M;
int a[N],b[N];
int main()
{
	cin>>A>>B>>M;
	int t1 ,t2;
	t1 = t2 = 1e9;
	rep(i , 1,  A + 1)
		cin>>a[i],t1 = min(t1,a[i]);
	rep( i , 1 , B + 1)
		cin>>b[i],t2 = min(t2,b[i]);
	int mn = 1e9;
	int x,y,c;
	while(M--){
		cin>>x>>y>>c;
		int now = a[x] + b[y] - c;
		mn = min(mn,now);
	}
	mn = min(mn,t1 + t2);
	cout<<mn;
	return 0;
}



Measured memory_bytes: 1024
# coding: utf-8
import sys
import numpy as np

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

U = 10 ** 7 + 10
is_prime = np.zeros(U, np.bool)
is_prime[2] = 1
is_prime[3::2] = 1
for p in range(3, U, 2):
    if p*p > U:
        break
    if is_prime[p]:
        is_prime[p*p::p+p] = 0

M = 10 ** 6
small_primes = np.where(is_prime[:M])[0].tolist()

N = ir()
answer = 0
used = set([1])
for p in small_primes:
    d = p
    while N%d == 0:
        answer += 1
        N //= d
        used.add(d)
        d *= p
    while N%p == 0:
        N //= p

if N > 1 and N not in used:
    answer += 1

print(answer)


Measured memory_bytes: 40360
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <functional>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0スタート
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1スタート
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //aからb - 1まで
#define p(x) cout<<x<<endl  //xを改行付きで出力
const int INF = 1000000007;  //最大値兼MOD
//  cin.tie(0);
//  ios::sync_with_stdio(false);
typedef long long ll;
using namespace std;
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(){
  int a,b;
  cin>>a>>b;
  int temp = 0;
  int count = 0;
  rep0(i,a){
    cin >> temp;
    if(b <= temp)count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String st = sc.next();
        if(st.charAt(0) == st.charAt(1) && st.charAt(0) == st.charAt(2)){
        	System.out.println("No");
        }else{
        	System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 35760
import sys
from itertools import product

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

N, *S = map(str, read().split())
N = int(N)
x = 0
answer = 0
for y in range(N):
    for i, j in product(range(N), repeat=2):
        if S[(i + x) % N][(j + y) % N] != S[(j + x) % N][(i + y) % N]:
            break
    else:
        answer += N

print(answer)


Measured memory_bytes: 43880
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.next());
		String s = in.next();
		String t = in.next();
		for(int i = 0; i < n; i++) {
			System.out.print(s.charAt(i) + "" + t.charAt(i));
		}
		System.out.print("\n");
	}
}

Measured memory_bytes: 22868
#include <iostream>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;

#define MAX 999999999;
#define EPS (1e-8)

struct P : public vector<double>{
  P(const double &a, const double &b, const double &c){
    push_back(a);
    push_back(b);
    push_back(c);
  }
  P(const int &size){
    push_back(NAN);
    push_back(NAN);
    push_back(NAN);
  }
  P(){
    push_back(NAN);
    push_back(NAN);
    push_back(NAN);
  }
};

P operator+(P a, P b){
  for(int i = 0; i < a.size(); i++){
    a[i] += b[i];
  }
  return a;
}

P operator-(P a, P b){
  for(int i = 0; i < a.size(); i++){
    a[i] -= b[i];
  }
  return a;
}

P operator*(P a, double d){
  for(int i = 0; i < a.size(); i++){
    a[i] *= d;
  }
  return a;
}

P operator/(P a, double d){
  for(int i = 0; i < a.size(); i++){
    a[i] /= d;
  }
  return a;
}

double abs2(P a){
  double res = 0;
  for(int i = 0; i < a.size(); i++){
    res += a[i] * a[i];
  }
  return res;
}

double abs(P a){
  return sqrt(abs2(a));
}

double dot(const P &a, const P &b){
  double res = 0;
  for(int i = 0; i < a.size(); i++){
    res += a[i] * b[i];
  }
  return res;
}

P cross(const P &a, const P &b){
  P res(3);
  for(int i = 0; i < a.size(); i++){
    res[i]  = a[(i + 1) % 3] * b[(i + 2) % 3];
    res[i] -= b[(i + 1) % 3] * a[(i + 2) % 3];
  }
  return res;
}

double dLP(const P &p1, const P &p2, const P &q){
  return abs(cross(p2 - p1, q - p1)) / abs(p2 - p1);
}

double dLL(const P &p1, const P &p2, const P &q1, const P &q2){
  P p = q1 - p1;
  P u = p2 - p1;
  P v = q2 - q1;

  double d = abs2(u) * abs2(v) - dot(u, v) * dot(u, v);
  if(abs(d) < EPS) return dLP(q1, q2, p1);
  double s = (dot(p, u) * abs2(v) - dot(p, v) * dot(u, v)) / d;
  return dLP(q1, q2, p1 + (u * s));
}

int main(){
  int n;
  P p[110][2];
  double t[110][110];

  while(cin >> n, n){
    double x, y, z;

    for(int i = 0; i < 2; i++){
      cin >> x >> y >> z;
      p[i][0] = P(x, y, z);
    }

    for(int i = 2; i < n + 2; i++){
      for(int j = 0; j < 2; j++){
        cin >> x >> y >> z;
        p[i][j] = P(x, y, z);
      }
    }

    for(int i = 0; i < n + 2; i++){
      for(int j = 0; j < n + 2; j++){
        if(i == j){
          t[i][j] = MAX;
        }
        else if(i <= 1 && j <= 1){
          t[i][j] = abs(p[i][0] - p[j][0]);
        }
        else if(i <= 1){
          t[i][j] = dLP(p[j][0], p[j][1], p[i][0]);
        }
        else if(j <= 1){
          t[i][j] = dLP(p[i][0], p[i][1], p[j][0]);
        }
        else{
          t[i][j] = dLL(p[i][0], p[i][1], p[j][0], p[j][1]);
        }
      }
    }

    for(int k = 0; k < n + 2; k++){
      for(int i = 0; i < n + 2; i++){
        for(int j = 0; j < n + 2; j++){
          if(i == j) continue;

          t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
        }
      }
    }

    printf("%.3f\n", t[0][1]);
  }

}

Measured memory_bytes: 1096
#include<iostream>
#include<algorithm>
using namespace std;
int a[100010];
int main()
{
	int n,m;	cin>>n>>m;
	for(int i=1;i<=m;i++)
		cin>>a[i];
	sort(a+1 ,a+1+m);
	for(int i=m;i>=2;i--)
		a[i]=a[i]-a[i-1];
	sort(a+2 , a+1+m);
	int ans=0;
	for(int i=2;i<=m-n+1;i++)
		ans+=a[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    ll k;
    cin >> k;
    ll a[n];
    rep(i,n) cin >> a[i];

    ll l = 0, r = 1001001001;
    while(l+1<r){
        ll m = (l+r)/2;
        ll cnt = 0;
        rep(i,n){
            cnt += (a[i]-1)/m;
        }
        if(cnt<=k){
            r = m;
        }else{
            l = m;
        }
    }
    cout << r << endl;
    return 0;
}




Measured memory_bytes: 5144
#include<iostream>

using namespace std;

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

int val[4] = {10,50,100,500}; 
int tmp[4],c[4],_min[4],minnum,now;
int main()
{
	int n;
	bool first = true;
	while(cin >> n,(n))
	{
		if(!first)cout << endl;
		first = false;
		minnum = 1000,now = 0;
		REP(i,4)
		{
			cin >> c[i];now += c[i];
			tmp[i] = 0;_min[i] = 100;
		}
		
		REP(i,c[0]+1)REP(j,c[1]+1)REP(k,c[2]+1)REP(l,c[3]+1)
		{
			int sum = 10 * i + 50 * j + 100 * k + 500 * l;
			if(sum < n)continue;
			int tmpnum = now-i-j-k-l,otu = sum - n;
			
			REP(a,4)
			{
				int num = otu / val[3-a];
				tmp[3-a] = num;
				otu -= num * val[3-a];
				tmpnum += num;
			}
			if(minnum > tmpnum)
			{
				minnum = tmpnum;
				_min[0] = i;
				_min[1] = j;
				_min[2] = k;
				_min[3] = l;
			}
			
		}
		
		REP(i,4)
		{
			if(_min[i]) cout << val[i] << ' ' << _min[i] << endl;
		}
		
	}
		
			
	
	return 0;
}
		

Measured memory_bytes: 3076
inp_list = list(map(int, input().split()))
n = inp_list[0]
k = inp_list[1]
q = inp_list[2]
ans_list = [k-q]*n
for i in range(q):
    ans_list[int(input())-1] += 1

for ans in ans_list:
    if ans > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 6664
#f
import sys
sys.setrecursionlimit(2 * 10 ** 5 + 10)
 

n = int(input())
E = [[] for _ in range(n)]
mod = 10**9 + 7

for i in range(n-1):
    a,b = [int(x) for x in input().split()]
    E[a-1].append((b-1, i)) 
    E[b-1].append((a-1, i)) 
    
X = [0] * n
    
def dfs(u,e):
    num = 1
    for v,c in E[u]:
        if c != e:
            num += dfs(v,c)
    X[e] = num 
    return num

dfs(0, -1)

I = [1]
inv = pow(2, mod-2, mod)
for i in range(n):
    I.append(I[-1] * inv % mod)

ans = 0
for i in range(n):
    x = X[i]
    ans += (1-I[x])*(1-I[n-x]) % mod
    
ans -= n * I[1]
ans += 1 - I[n]
ans %= mod
print(ans)



Measured memory_bytes: 198572
#include <bits/stdc++.h>
using namespace std;
typedef long long lt;
typedef double dd;
#define eps 1e-6
#define sqr(x) ((x)*(x))


const int maxn=10010;
int n;
struct point{dd x,y;}p[maxn],O;
dd R;

dd getd(point a,point b){ return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));}
point getO(point p1,point p2,point p3)
{
    point res;
    dd a=p2.x-p1.x,b=p2.y-p1.y,c=p3.x-p2.x,d=p3.y-p2.y;
    dd e=sqr(p2.x)+sqr(p2.y)-sqr(p1.x)-sqr(p1.y);
    dd f=sqr(p3.x)+sqr(p3.y)-sqr(p2.x)-sqr(p2.y);
    res.x=(f*b-e*d)/(c*b-a*d)/2.0;
    res.y=(a*f-e*c)/(a*d-b*c)/2.0;
    return res;
}

void mincir()
{
    O=p[1]; R=0;
    for(int i=1;i<=n;++i)
    if(getd(p[i],O)-R>eps)
    {
        O=p[i]; R=0;
        for(int j=1;j<i;j++)
        if(getd(p[j],O)-R>eps)
        {
            O=(point){(p[i].x+p[j].x)/2.0,(p[i].y+p[j].y)/2.0};
            R=getd(p[i],p[j])/2.0;

            for(int k=1;k<j;++k)
            if(getd(p[k],O)-R>eps)
            {
                O=getO(p[i],p[j],p[k]);
                R=getd(p[i],O);
            }
        }
    }
}

int main()
{
    scanf("%d", &n);
    for(int i=1;i<=n;++i)
    scanf("%lf%lf",&p[i].x,&p[i].y);

    random_shuffle(p+1,p+1+n);

    mincir();
    printf("%.8f", R);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define reg register
#define in cin>>
#define out cout<<
using namespace std;
int main(){
	reg int a,b,c;
	in a>>b>>c;
	if(a+b>=c)out "Yes\n";
	else
	out "No\n";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] n = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            char[] d = Console.ReadLine().Split(' ').Select(char.Parse).ToArray();
            int i;
            for (i=n[0]; ; i++)
            {
                string s = i.ToString();
                bool l = false;
                for(int j = 0; j < s.Length; j++)
                {
                    for(int z = 0; z < n[1]; z++)
                    {
                        if (s[j] == d[z])
                        {
                            l = true;
                        }
                    }
                }
                if (l)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(i);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 N;
  cin >> N;
  vi A(N-1);
  cin >> A;

  vi B(N, 0);
  for(auto &i : A) B[i-1]++;
  for(auto &i : B){
    cout << i << "\n";
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 6352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
	int x,a,b;
	scanf("%d%d%d",&x,&a,&b);
	
	printf("%d",(x-a)%b);
	return 0;
}


Measured memory_bytes: 256
def main():
  N, M = list(map(int, input().split()))
  inN = [0 for i in range(N)]
  outN = [[] for i in range(N)]
  
  for i in range(N + M - 1):
    Data = list(map(int, input().split()))
    inN[Data[1] - 1] += 1
    outN[Data[0] - 1].append(Data[1] - 1)
  
  D = []
  for i in range(N):
    if inN[i] == 0:
      D.append(i)
      
  L = []
  while D != []:
    t = D.pop()
    L.append(t)
    for i in outN[t]:
      inN[i] -= 1
      if inN[i] == 0:
        D.append(i)
   
  Ans = [0 for i in range(N)]
  for i in L:
    for j in outN[i]:
      Ans[j] = i + 1
      
  for i in Ans:
    print(i)
main()

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

int main(){
	int n,m;

	scanf("%d", &n);

	int cur = 1;
	for(int i = 0; i < n; i++) {
		scanf("%d", &m);
		if(m == cur) cur++;
	}

	if(cur == 1) printf("-1\n");
	else printf("%d\n", n-cur+1);

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = (1953125 << 9);
const ll maxn = 1 * 1e5 + 5;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout);

	string s;
	cin >> s;
	sort(s.begin(), s.end());
	cout << (s == "abc" ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

signed main(){
    string S, T;
    cin >> S >> T;
    REP(i, S.length()){
        if(S[i] != T[i]){
            PRINT("No");
            return 0;
        }
    }
    PRINT("Yes");
    return 0;
}

Measured memory_bytes: 3592
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> b;
  if (a + b >= 10)
    Cout("error");
  else
    Cout(a + b);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int T=scanner.nextInt();
		
		int min=1000000000;
		for(int i=0;i<n;i++) {
			int c=scanner.nextInt();
			int t=scanner.nextInt();
			if(t<=T) {
				min=Math.min(min, c);
			}
		}
		if(min==1000000000) {
			System.out.println("TLE");
			return;
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 23124
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;


#define int long long
#define all(v) v.begin() , v.end()

template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;}
template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;}

int a , b , res = 2e10 ;

int d ( int a , int b ) {
	if ( b < a ) return 2e10 ;
	return b - a ; 
}

int32_t main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b ;
	smin ( res , d ( a , b ) ) ;
	smin ( res , d ( a , -b ) + 1 ) ;
	smin ( res , d ( -a , b ) + 1 ) ;
	smin ( res , d ( -a , -b ) + 2 ) ;
	cout << res << '\n' ; 
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 1000000
#define INF   1000000000

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll to[MAX_N];
ll d[MAX_N];
bool visited[MAX_N];

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

    ll N, K;
    cin >> N >> K;

    ll A; 
    for (ll i = 1; i <= N; i++) {cin >> A; to[i] = A;}

    fill(visited, visited + MAX_N, false);
    fill(d, d + MAX_N, INF);

    vector<ll> v;    
    bool loop = false;
    ll len_loop = 0;
    ll len_before_loop = 0;    
    ll now = 1;
    ll next = 1;
    ll loop_s, loop_e;
    
    for (ll i = 0; i <= K; i++) {

      now = next;
      d[now] = i;
      visited[now] = true;
      v.push_back(now);
      next = to[now];
      
      if (visited[to[now]] == true) {
	loop = true;	
	loop_s = to[now];
	loop_e = now;
	len_loop = d[loop_e] - d[loop_s] + 1;	
	len_before_loop = i - (len_loop-1);
	break;
      }

    }
    
    ll ans;
    if(loop) {
      ll m  = (K - len_before_loop) % len_loop;
      cout << v[len_before_loop + m] << endl;
    }
    else {
      cout << now << endl;
    }
    
    return 0;
}


Measured memory_bytes: 15160
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, l;
int main() {
   cin >> n >> l;
   if (l>=0) cout << (2*l+n)*(n-1)/2;
   else if (n>abs(l)) cout << (2*l+n-1)*n/2;
   else cout << (2*l+n-2)*(n-1)/2;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define ub            upper_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(4e18)
// #define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>
#define ordered_set   tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int M = 1e9+7;
const int N = 1e4+1;

int f[N], inv[N];

int Pow(int x, int p) {
	int ans = 1;
	while(p) {
		if(p&1) ans = (ans*x)%M;
		x = (x*x)%M;
		p >>= 1;
	}
	return ans;
}

int ncr(int n, int r) {
	return f[n]*inv[r]%M*inv[n-r]%M;
}

void pre() {
	f[0] = inv[0] = 1;
	for(int i = 1; i < N; i++) {
		f[i] = f[i-1]*i%M;
		inv[i] = Pow(f[i], M-2);
	}
}

void solve() {
	pre();
	int n; cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		int tmp = n-i*3;
		if(tmp >= 0) {
			ans += ncr(tmp+i-1, i-1);
		}
	}
	cout << ans%M << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    // freopen("error.txt", "w", stderr);
    // #endif

    int test = 1;
    // cin >> test;
    
    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
    	solve();
    }

    cerr << time(start);
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s.size()%2==1){
    cout << "No" << endl;
  }else{
    bool flg=true;
    for(int i=0;i<s.size();i+=2){
      if(s.at(i)!='h' || s.at(i+1)!='i'){
        flg=false;
      }
    }
    if(flg){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
e = list(map(lambda x: (1 + int(x)) / 2, input().split()))
mt = sum(e[:k])
mf = mt
for i in range(1, n - k + 1):
  mt -= e[i - 1]
  mt += e[i - 1 + k]
  if mt > mf:
    mf = mt
print(mf)


Measured memory_bytes: 23524
class Fi:
    def __init__(self):
        self.fi = []
    def setfi(self, z, zz):
        self.xl, self.y = z, zz
        for _ in range(self.xl):
            fi = raw_input()
            fisub = []
            for i in range(len(fi)):
                fisub += fi[i]
            self.fi.append(fisub)  

    def fit(self):
        x, y = 0, 0

        count = 0

        while(True):
            if self.fi[x][y] == ">":
                self.fi[x][y] = "#"
                y = y + 1
            elif self.fi[x][y] == "<":
                self.fi[x][y] = "#"
                #x = x
                y = y - 1
            elif self.fi[x][y] == "^":
                self.fi[x][y] = "#"
                x = x - 1
                #y = y
            elif self.fi[x][y] == "v":
                self.fi[x][y] = "#"
                x = x + 1
                #y = y
            elif self.fi[x][y] == ".":
                print y ,x
                break
            else:
                print "LOOP"
                break

            count = count + 1


def main():

    while(True):
        x, y = map(int, raw_input().split())
        if x == 0 and y == 0:
            break
        a = Fi();a.setfi(x ,y);a.fit()


if __name__=="__main__":
    main()

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

def solve(a: int, b: int, n: int) -> int:
    x = min(n, b - 1)
    return (a * x) // b - a * (x // b)

# generated by online-judge-template-generator v4.1.0 (https://github.com/kmyk/online-judge-template-generator)
def main():
    A, B, N = map(int, input().split())
    guy = solve(A, B, N)
    print(guy)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <stdio.h>

using namespace std;
typedef long long llong;

#define MAX 10001
const llong mod = 1000000000 + 7;

int main()
{
  int N, M;
  int A;

  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++)
  {
    scanf("%d", &A);
    N -= A;
  }

  if (N >= 0)
    printf("%d\n", N);
  if (N < 0)
    printf("-1");

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector <int> A(N);
    vector <int> B(N-1);

    for(int i = 0; i < N-1; i++) {
        cin >> B[i];
    }

    A[0] = B[0];
    for(int i = 1; i < N-1; i++) {
        A[i] = min(B[i-1], B[i]);
    }
    A[N-1] = B[N-2];

    int ans = 0;
    for(int i = 0; i < N; i++) {
        ans += A[i];
    }

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

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

int main(){
  int n, k, min=1e9, sa;
  vector<int> v;
  cin >> n >> k;
  v.resize(n);
  for( int i=0;i<n;i++){
    cin >> v[i];
  }
  if(n==1){
    cout << abs(v[0]) << endl;
    return 0;
  }
  if(k==1){
    for(int i=0;i<n;i++){
      if(min>abs(v[i]))min = abs(v[i]);
    }
    cout << min << endl;
    return 0;
  }
  for(int i=0;i<n-k+1;i++){
    if(v[i+k-1] <= 0){
      sa = -v[i];
    }
    else if(v[i] >= 0){
      sa = v[i+k-1];
    }
    else{
      sa = v[i+k-1] - v[i];
      if(abs(v[i]) < abs(v[i+k-1])){
        sa = sa - v[i];
      }
      else{
        sa = sa + v[i+k-1];
      }
    }
    if(min > sa){
      min = sa;
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  char s[100001];
  scanf("%s",s);
  int a=0,b=0,c=0;
  while(s[a]!='\0'){
    if(s[a]=='0'){
      if(a%2){
        b++;
      }else{
        c++;
      }
    }else{
      if(a%2){
        c++;
      }else{
        b++;
      }
    }
    a++;
  }
  printf("%d",b<c?b:c);
  return 0;}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	int b,c;
	cin>>a;
	b=a.size();
	for(register int i=0;i<=b;i++){
		if(a[i]=='C'){
		    c=i;
		    break;
		}
	}
	for(register int i=b;i>c;i--){
		if(a[i]=='F'){
		    cout<<"Yes"<<endl;
            return 0;
		}
	}
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    int x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    for(int i=0; i<5; ++i){
        if(x[i] == 0){
            cout << (i+1) << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
# D - Rain Flows into Dams

N = int(input())
A = list(map(int, input().split()))

rain = [-1]*N

sum_all = sum(A)
sum_skip = sum([A[idx] for idx in range(0,N-1,2)])

rain[-1] = sum_all - 2*sum_skip

for idx in reversed(range(N-1)):
    rain[idx] = 2*(A[idx] - rain[idx+1]//2)

print(*rain)

Measured memory_bytes: 64996
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
ios::sync_with_stdio(false);cin.tie(0);
    int N,M;
    cin>>N>>M;
    UnionFind uf(N);
    for (size_t i = 0; i < M; i++)
    {
        int a,b;
        cin>>a>>b;
        a--;b--;
        uf.unite(a,b);
    }
    set<int> p;
    for (size_t i = 0; i < N; i++)
    {
        p.insert(uf.find(i));
    }
    cout<<p.size()-1<<endl;
    return 0;
}

Measured memory_bytes: 7680