akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;


void solve(){
    string s,t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    int ans =INF;
    for(int i = 0;i<n;i++){
        if((i+m-1) >= n) break;
        int cnt = 0;
        for(int j = i,k=0;k<m;k++,j++){
            cnt += (s[j] != t[k]);
        }
        ans= min(ans,cnt);
    }
    cout << ans << endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

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

void solve_A(){
    int k;
    cin >> k;
    int a, b;
    cin >> a >> b;

    bool flag = false;
    int i = 1;
    while(i* k <= b){
        if(a <= i*k && i*k <= b) flag = true;
        i++;
    }

    if(flag) cout << "OK";
    else cout << "NG";
}

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

Measured memory_bytes: 3628
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map>  
using namespace std; 
const long long int INF = 1LL << 50;

/*start:17/5/19 16:33*/
/*end:17/5/19   16:  */

int w[2005],v[2005];
long long int lu[2005];
long long int l,dis[3005];
int n,m,x,y,i,k;

bool check;

int main()
{
	int j;
	memset(w,0,sizeof(w));
	memset(v,0,sizeof(v));
	memset(lu,0,sizeof(lu));
	cin>>n>>m;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y>>l;
		w[i]=x;
		v[i]=y;
		lu[i]=-l;
	}
	for(i=1;i<=n;i++)
		dis[i]=INF;
	dis[1]=0;
	//MAX=INF;
	for(i=1;i<=n-1;i++)
	{	
		check=false;
		for(j=1;j<=m;j++)
		{
			if(dis[v[j]]>dis[w[j]]+lu[j])
			{
				check=true;
				dis[v[j]]=dis[w[j]]+lu[j];
			}
		}
		if(!check)
			break;
	}
	l=dis[n];
	for(j=1;j<=m;j++)
	{
		if(dis[v[j]]>dis[w[j]]+lu[j])
		{
			dis[v[j]]=dis[w[j]]+lu[j];
		}
	}

	if(dis[n]==INF)
	{
		cout<<"inf"<<endl;
		return 0;
	}
	if(dis[n]!=l)
	{
		cout<<"inf"<<endl;
		return 0;
	}
	cout<<-dis[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        s[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if s[j] == 1:
                cnt += 1
        if cnt % 2 == a[i]:
            s[i] = 0
        else:
            s[i] = 1
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)


Measured memory_bytes: 7148
#include<stdio.h>
#define MAX 101
void depth(int);
int n,co=1,a[MAX][MAX],b[MAX],c[MAX],d[MAX];
int main(){
  int i,j,k,u,v;
scanf("%d",&n);
b[0]=0;
for(i=0;i<n;i++){
  for(j=0;j<n;j++){
    a[i][j]=0;
  }
 }
for(i=0;i<n;i++){
  scanf("%d%d",&u,&k);
  for(j=0;j<k;j++){
    scanf("%d",&v);
    a[u-1][v-1]=1;
  }
 }
for(i=0;i<n;i++){
  if(b[i]==0){
    depth(i);
  }
 }
for(i=0;i<n;i++){
  printf("%d %d %d\n",i+1,c[i],d[i]);
 }
return 0;
}
void depth(int q){
  int p;
  c[q]=co++;
  b[q]=1;
  for(p=0;p<n;p++){
    if(a[q][p]==1 && b[p]==0){
      depth(p);
    }
  }
  d[q]=co++;
}
    



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

using namespace std;
const int N = 202;
int n, m, r, target[N];
long long dist[N][N];
void floyd() { // set global var n to node count, dist[n][n] to infinity and edge costs
	int i, j, k;
	for (k = 1; k <= n; k++)
		for (i = 1; i <= n; i++)
			for (j = 1; j <= n; j++)
				if (dist[i][k] + dist[k][j] < dist[i][j])
					dist[i][j] = dist[j][i] = dist[i][k] + dist[k][j];
}
int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	memset(dist, 0x3f, sizeof dist);
	scanf("%d %d %d", &n, &m, &r);
	for (int i = 0; i < r; ++i)
		scanf("%d", target + i);
	while (m--) {
		int u, v, c;
		scanf("%d %d %d", &u, &v, &c);
		dist[u][v] = dist[v][u] = c;
	}
	floyd();
	sort(target, target + r);
	long long result = 2e18;
	do {
		long long cost = 0;
		for (int i = 1; i < r; ++i) {
			cost += dist[target[i - 1]][target[i]];
		}
		result = min(result, cost);
	} while (next_permutation(target, target + r));
	printf("%lld\n", result);
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    long long n, m, l;
    int i, j;
    scanf("%lld %lld %lld", &n, &m, &l);

    long long A[n][m];
    long long B[m][l];
    long long C[n][l];

    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            scanf("%lld", &A[i][j]);
        }
    }
    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
            scanf("%lld", &B[i][j]);
        }
    }
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            C[i][j] = 0;
        }
    }

    int k;
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            for(k = 0; k < m; k++){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }
    for(i = 0; i < n; i++){
        for(j = 0; j < l; j++){
            printf("%lld", C[i][j]);
            if(j < l -1){
                printf(" ");
            }
        }
        if(i < n - 1){    
            printf("\n");
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat 
using namespace std;
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef priority_queue<pr,Vpr,greater<pr> > PQ;
const int INF=1<<30;
const int SIZE=3*1e5;
const int BITSIZE=1<<17;
const int TIMES=40;
const LL p=7+1e9;
LL N,M,K,H,W,C;
bool poss[SIZE];
int nums[SIZE];
int main(){
	cin >> N >> M;
	FOR(i,1,N+1)
		nums[i]=1;
	poss[1]=true;
	int a,b;
	REP(i,M){
		cin >> a >> b;
		poss[b]|=poss[a];
		nums[a]--;
		nums[b]++;
		if(nums[a]==0) poss[a]=false;
	}
	int ans=0;
	FOR(i,1,N+1){
		if(poss[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int64_t>v(n);
    vector<int64_t>s(n+1);
    s[0]=0;
    for(int i=1; i<=n; i++){
        if(i%3!=0 and i%5!=0) v[i-1]=i;
        s[i]=s[i-1]+v[i-1];
    }
    cout<<s[n]<<endl;
}



Measured memory_bytes: 18676
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll k, n;
  cin >> k >> n;
  ll a[n];
  REP(i, n) { cin >> a[i]; }
  int max_d = 0, max_i = 0;
  REP(i, n) {
    int d;
    if(i == n - 1) {
      d = (k - a[n - 1]) + a[0];
    } else {
      d = a[i + 1] - a[i];
    }
    if(d > max_d) {
      max_d = d;
      max_i = i;
    }
  }

  int x = a[n - 1] - a[0] - max_d;
  if(max_i == n - 1) {
    x = a[n - 1] - a[0];
  } else {
    x += k - a[n - 1] + a[0];
  }

  cout << x << endl;
  return 0;
}


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

int main(){
    int n,ans=1;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n-1;i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

int n,x;
vector <int> a,b;

int get(vector <int> &a)
{
	int ans=0;
	vector <int> s=a;
	sort(s.begin(),s.end());
	do
	{
		if(s==a) return ans;
		ans++;
	}
	while(next_permutation(s.begin(),s.end()));
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>x,a.push_back(x);
	for(int i=0;i<n;i++) cin>>x,b.push_back(x);
	cout<<abs(get(a)-get(b));
}

Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include<stack>

#define MOD1e9 1000000007
#define INT_MAX       2147483647
#define INT_MIN     (-2147483647 - 1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define rep(c) for(int i = 0; i <(c); ++i)
#define rrep(n) for(int i = (n) ; i >=0 ; --i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define endl "\n"
#define ret(n) return n
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
//Typedefs
typedef long long ll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef priority_queue<int> pqint;
typedef priority_queue<ll> pqll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<long> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb;

void dfs(int node, vi adj[], vb& visited, vi& dp)
{
	visited[node] = true;

	for (auto next : adj[node])
	{
		if (!visited[next])
		{
			dfs(next, adj, visited, dp);
		}
		dp[node] = max(dp[node], 1 + dp[next]);
	}
	
}

int main()
{
	int n, m;
	cin >> n >> m;
	vi* adj = new vi[n + 1];
	rep(m)
	{
		int x, y;
		cin >> x >> y;
		adj[x].push_back(y);
	}
	vi dp(n + 1, 0);
	vb visited(n + 1, false);
	fora(i, 1, n + 1)
	{
		if (!visited[i])
			dfs(i, adj, visited, dp);
	}
	int ans = -1;
	fora(i, 0, n + 1)
	{
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
	ret(0);
}


Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  ll n, k;
  cin >> n >> k;
  ll h[200010];
  rep(i, n) cin >> h[i];
  sort(h, h + n);
  ll sum = 0;
  rep(i, n - k) sum += h[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int d = Integer.parseInt(in.next());
            int x = Integer.parseInt(in.next());
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            int ans = x;

            for (int i = 0; i < n; i++) {
                ans = ans + ((d - 1) / a[i] + 1);
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int x;
bool dp[N];
int main()
{
	dp[0]=1;
	scanf("%d",&x);
	for(int i=100;i<=105;++i)
	{
		for(int j=i;j<=x;++j)
		dp[j]|=dp[j-i];
	}
	printf("%1d\n",dp[x]);
	return 0;
}

Measured memory_bytes: 384
from fractions import gcd
N,K=map(int,input().split())
A=[int(i) for i in input().split()]

def f(L):
    if N==1:
        return L[0]
    else:
        a = gcd(L[0],L[1])
        for i in range(2,N):
            a = gcd(a,L[i])
        return a

s=f(A)
if max(A)<K or K%s!=0:
    print('IMPOSSIBLE')
else:
    print('POSSIBLE')

Measured memory_bytes: 16240
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <functional>

using namespace std;

int main() {
    int i,lens,lent,len,flag = 0;
    string s,t;

    cin >> s >> t;
    
    lens = s.size();
    lent = t.size();

    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(lens >= lent){
        len = lent;
    }
    else{
        len = lens;
        for(i = 0;i < lens;i++){
            if(s[i] <= t[i]){
                flag = 1;
            }
            else{
                flag = 0;
                break;
            }
        }
    }

    for(i = 0;i < len;i++){
        if(s[i] < t[i]){
            flag = 1;
            break;
        }
    }

    

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i,n) for(int i=0;i<n;i++)
#define unsigned long ul
using namespace std;

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	char s;
    cin >> s;
    if(s == 'A')printf("T");
    if(s == 'T')printf("A");
    if(s == 'G')printf("C");
    if(s == 'C')printf("G");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
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 T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

ll solve(ll N){
  ll ret = 0;
  ll till = (ll)sqrt(N);
  for(ll a = 1 ; a <= till ; a++ ){
    if(N % a == 0){
      if((N/a - 1) <= a){
        continue;
      }
      ret = ret + (N/a - 1);
    }
  }
  return ret;
}

ll N;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N;
  ll ret = solve(N);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

w, h, x, y = li()

ans = w*h / 2

if x == w/2 and y == h/2:
    print(ans, 1)
else:
    print(ans, 0)

Measured memory_bytes: 3064
H, W = map(int, input().split())
c = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

for k in range(10):
	for i in range(10):
		for j in range(10):
			if c[i][k] + c[k][j] < c[i][j]:
				c[i][j] = c[i][k] + c[k][j]

ans = 0

for h in range(H):
	for w in range(W):
		if A[h][w] != -1:
			ans += c[A[h][w]][1]

print(ans)

Measured memory_bytes: 3316
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int MAX = 10000;
class shuturyoku_unko {
public:
	char C[MAX * 4];
	constexpr shuturyoku_unko() : C() {
		rep(i, MAX) {
			int X = i;
			rep(j, 4) {
				C[i * 4 + 3 - j] = '0' + X % 10;
				X /= 10;
			}
		}
	}
};
constexpr shuturyoku_unko f;
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	if (X >= 10000) {
		if (X >= 100000) {
			memcpy(di, f.C + X / 10000 * 4 + 2, 2);
			memcpy(di + 2, f.C + X % 10000 * 4, 4);
			di += 6;
		}
		else {
			memcpy(di, f.C + X / 10000 * 4 + 3, 1);
			memcpy(di + 1, f.C + X % 10000 * 4, 4);
			di += 5;
		}
	}
	else {
		if (X >= 1000) memcpy(di, f.C + X * 4, 4), di += 4;
		else if (X >= 100) memcpy(di, f.C + X * 4 + 1, 3), di += 3;
		else if (X >= 10) memcpy(di, f.C + X * 4 + 2, 2), di += 2;
		else memcpy(di, f.C + X * 4 + 3, 1), di += 1;
	}
	*di++ = '\n';
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 14956
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define BUF_SIZE 10

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// 446*447 < 100000*2 < 447*448=200256
#define N2_MAX 447
#define NUM_MAX 110000

int main(void) {
    static int map[NUM_MAX];
    int i, j;

    int num = get_int();
    // special case with n=1
    if(num == 1) {
        printf("Yes\n");
        printf("2\n"); // k=2
        printf("1 1\n");
        printf("1 1\n");
        return 0;
    }

    for(i = 2; i <= N2_MAX; i++) {
        map[i*(i+1)/2] = i;
    }
    int unit_num = map[num]; // i

    if(!unit_num) {
        printf("No\n"); return 0;
    } else {
        printf("Yes\n");
    }
    // all numbers use twice
    int k = (num*2)/unit_num; // i+1
    printf("%d\n", k);

    static int units[N2_MAX+1][N2_MAX+1];
    int idx = 1;
    for(i = 1; i <= k; i++) {
        for(j = 1; j <= (i-1); j++) {
            // fetch 1st one
            units[i][j] = units[j][i-1];
        }
        // get new one
        for(j = i; j <= unit_num; j++) {
            units[i][j] = idx++;
        }
    }

    for(i = 1; i <= k; i++) {
        printf("%d ", unit_num);
        for(j = 1; j <= unit_num; j++) {
            char n = (j == unit_num) ? '\n' : ' ';
            printf("%d%c", units[i][j], n);
        }
    }

    return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    int res = 1;
    int cnt = 0;
    while (res < B) {
        --res;
        res += A;
        ++cnt;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
//    long long L,R;
//    cin >> L >> R;
//
//    long long ans = 0;
//    long long L_by_2019 = L / 2019;
//    long long R_by_2019 = R / 2019;
//    long long L_mod_2019 = L % 2019;
//    long long R_mod_2019 = R % 2019;
//    if (L_by_2019 != R_by_2019) {
//        ans = 0;
//    }
//    else{
//        ans = L_mod_2019 * (L_mod_2019+1);
//    }
//    ans = ans % 2019;
//    cout << ans << endl;
    
    long N, D;
    cin >> N>>D;
    vector<vector<double>> X(N, vector<double>(D));
    for (long i=0; i<N; i++) {
        for (long j=0; j<D; j++) {
            cin >> X[i][j];
        }
    }
    long ans = 0;
    for (long i=0; i<N; i++) {
        for (long k=i+1; k<N; k++) {
            double dist = 0.0;
            for (long j=0; j<D; j++) {
                dist += pow(X[i][j]-X[k][j], 2);
            }
            dist = sqrt(dist);
            if (ceil(dist) == floor(dist)) {
                ans++;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef vector<ll> Vl;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;



string s;
int x;
bool f = false;

int main() {

	cin >> s;

	x = s.size();

	rep(i, x / 2 + 1) {
		if (s[i] != s[x - i - 1])f = true;
	}

	rep(i, x / 4) {
		if (s[i] != s[(x / 2) - i - 1])f = true;
	}

	if (f)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>

using namespace std;

double DegToRad(double deg){
    return (deg/360) * 2 * M_PI;
}

int main(){
    int A,B;
    int H,M;
    cin >> A >> B >> H >> M;

    double angleA, angleB;
    angleA = (double)(H*60+M) / (12*60) * 360;
    angleB = (double)(M) / 60 * 360;

    // cout << "A: " << angleA << "\tB: " << angleB << endl;

    double angle = (angleA-angleB>0) ? angleA-angleB : angleB-angleA;
    double res = sqrt(A*A + B*B - 2*A*B*cos(DegToRad(angle)));

    cout << fixed << setprecision(20) << res << endl;
}

Measured memory_bytes: 4196
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define pb(a) push_back(a)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
using namespace std;

int sort(int result[55][4], int n){
    range(i,1,n){
        range(j,1,n-1){
            if( (result[j][3] < result[j + 1][3]) || (result[j][3] == result[j + 1][3] && result[j][0] > result[j + 1][0]) ){
                rep(k,4){
                    int temp = result[j][k];
                    result[j][k] = result[j + 1][k];
                    result[j + 1][k] = temp;
                }
            }
        }
    }
}

int main(){
    int T, P, R;
    while(cin >> T >> P >> R, T||P||R){
        int tID, pID, time, list[55][15] = {0}, result[55][4]= {0};
        string massage;
        rep(i,54) result[i][2] = i;
        rep(i,R){
            cin >> tID >> pID >> time >> massage;
            if(massage == "CORRECT" & list[tID][pID] <= 0){
                result[tID][0]+= abs(list[tID][pID]) * 1200 + time;
                result[tID][1]+= abs(list[tID][pID]);
                result[tID][3]++;
                list[tID][pID] = 1;
            }else if(massage == "WRONG" && list[tID][pID] <= 0){
                list[tID][pID]--;
            }
        }
        sort(result, T + 1);
        range(i,1,T + 1){
            cout << result[i][2] << ' ' << result[i][3] << ' ' << result[i][0] << endl;
        }
    }   
}

Measured memory_bytes: 1220
import java.util.Scanner;

//War
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		long res = 0;
		for(int i=0;i<n;i++)res+=h[i]=sc.nextInt();
		for(int d=1;d<125;d++){
			int c = 0;
			for(int x:h)c+=x>=d?1:0;
			res-=Math.max(0, c-d*4);
		}
		System.out.println(res+1);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

ll C[2005][2005];
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}

/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/
ll n,k;
int main(){FAST;
cin>>n>>k;
nCr(2000,2000);
for(ll i=1;i<=k;i++){
	ll ans = 0;
	if(i == 1){
		cout<<n-k+1<<'\n';
		continue;
	}
	for(ll j=i-1;j<=n-k;j++){
		ll TOT = j;
		ll VAR = i-1;
		ll ways = (C[TOT-1][VAR-1]*(n-k-j+1))%MOD;
		ways=(ways*C[k-1][i-1])%MOD;
		ans=(ans+ways)%MOD;
	}
	cout<<ans<<'\n';
}
return 0;
}

Measured memory_bytes: 30208
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int L[1<<18],R[1<<18];
vector<pair<int,int>> add[1<<18];
int ret[1<<18];

unsigned long long bitrev(unsigned long long x,int d=64) {
	x = (((x & 0xaaaaaaaaaaaaaaaaULL) >> 1) | ((x & 0x5555555555555555ULL) << 1));
	x = (((x & 0xccccccccccccccccULL) >> 2) | ((x & 0x3333333333333333ULL) << 2));
	x = (((x & 0xf0f0f0f0f0f0f0f0ULL) >> 4) | ((x & 0x0f0f0f0f0f0f0f0fULL) << 4));
	x = (((x & 0xff00ff00ff00ff00ULL) >> 8) | ((x & 0x00ff00ff00ff00ffULL) << 8));
	x = (((x & 0xffff0000ffff0000ULL) >>16) | ((x & 0x0000ffff0000ffffULL) <<16));
	x = ((x >> 32) | (x << 32));
	
	return x>>(64-d);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,1<<N) {
		cin>>x;
		if(x==0) L[i]=0,R[i]=(1<<N)-1;
		else L[i]=R[i]=x-1;
	}
	
	FOR(i,N) {
		FOR(x,1<<N) {
			if(x&(1<<i)) L[x]=max(L[x],L[x^(1<<i)]+1);
			else R[x]=min(R[x],R[x^(1<<i)]-1);
		}
	}
	
	FOR(i,1<<N) {
		if(L[i]>R[i]) return _P("NO\n");
		add[L[i]].push_back({R[i],i});
	}
	
	set<pair<int,int>> S;
	FOR(i,1<<N) {
		FORR(e,add[i]) S.insert(e);
		if(S.empty()) return _P("NO\n");
		auto a=*S.begin();
		S.erase(S.begin());
		if(a.first<i) return _P("NO\n");
		ret[a.second]=i+1;
	}
	
	cout<<"YES"<<endl;
	FOR(i,1<<N) cout<<ret[bitrev(i,N)]<<" ";
	cout<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 24192
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int main(){
    int a,b;
    cin >> a >> b;
    int ans = max(a + b, a - b);
    ans = max(ans, a * b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i=0;i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
 
 
int main() {
    ll n,ans=0;
    string S;
    cin >> n >> S;
    vector<int> a(n);
    rep(i,n) {
        if(S[i]=='R') a[i]=0;
        else if (S[i]=='G') a[i]=1;
        else a[i]=2;
    }
    vector<ll> cnt(3);
    rep(i,n) {
        cnt[a[i]]++;
    }
    rep(j,n) rep(i,j){
        int k = j + (j-i);
        if(k<n){
            if (a[i]==a[j]||a[i]==a[k]||a[j]==a[k]) continue;
            ans--;
        }
    }
    ans += cnt[0]*cnt[1]*cnt[2];
    cout << ans << endl;
}

Measured memory_bytes: 3596
cnt = 0
li = range(10)
n, s = 0, 0

def dfs(i, num, total):
    global cnt
    if i <= 10 and num == n and total == s:
        #answer is finded
        cnt += 1
        return;
    if i >= 10 or num > n or total > s:
        #out of range
        return;
        
    #when use i
    dfs(i+1, num+1, total+i)
    #when skip i
    dfs(i+1, num, total)
        
while True:
    n, s = map(int, raw_input().split())
    if n == s == 0:
        break
    cnt = 0
    dfs(0, 0, 0)
    print cnt

Measured memory_bytes: 6248
#include <iostream>
using namespace std;
int main() {
	long long k,p,q,a;
	cin>>k;
	p=k/50;
	q=k%50;
	cout<<50<<endl;
	for(int i=1;i<=49;i++){
	    a=p-q+48;
	    if(i<=q){
	        a+=51;
	    }
	    cout<<a<<" ";
	}
	cout<<p-q+49<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int N = in();
  stringstream ss;
  rep(i, N) { ss << in(); }
  auto s = ss.str();
  rep(i, 1000000) {
    stringstream ss;
    ss << i;
    if (s.find(ss.str()) == string::npos) {
      pr(i);
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
#define mk make_pair
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
int main(){
  int h,w;
  cin>>h>>w;
  string s[h];
  r(i,h)cin>>s[i];
  r(i,h){r(j,w){
    if(s[i][j]=='#')cout<<'#';
    else{
      int g=0;
      r(k,8){
        int y=i+dy[k];
        int x=j+dx[k];
        if(x<0||y<0||x>=w||y>=h)continue;
        if(s[y][x]=='#')g++;
      }
      cout<<g;
    }
  }cout<<endl;}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int W, H;
    int x, y, r;
 
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 2100
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
    ll N;   cin >> N;
    ll **A = new ll *[2];
    A[0] = new ll[N];
    A[1] = new ll[N];

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < N; j++)
            cin >> A[i][j];
    }

    ll **dp = new ll *[2];
    dp[0] = new ll[N];
    dp[1] = new ll[N];

    dp[0][0] = A[0][0];
    dp[1][0] = A[0][0] + A[1][0];

    for (int i = 0; i < N-1; i++)
        dp[0][i+1] = dp[0][i] + A[0][i+1];
    for (int i = 0; i < N-1; i++) 
        dp[1][i+1] = max(dp[1][i], dp[0][i+1]) + A[1][i+1];
    
    cout << dp[1][N-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <list>
#define all(x) x.begin(), x.end()
#define rep(n) for (int i=0; i<n; ++i)

using namespace std;

int main(void){
  int n;
  cin >> n;
  vector<int> front, back;
  rep(n){
    int cur;
    cin >> cur;
    if(i%2 == 0){
      front.push_back(cur);
    } else {
      back.push_back(cur);
    }
  }
  if (n%2 == 1) reverse(all(front));


  if(n%2 != 0){
    for(auto it = front.begin(); it != front.end(); ++it){
      cout << *it << " ";
    }
    for(auto it = back.begin(); it != back.end(); ++it){
      cout << *it;
      if (it != back.end()-1) cout << " ";
    }
  }else{
    for(auto it = back.end()-1; it >= back.begin(); --it){
      cout << *it << " ";
    }
    for(auto it = front.begin(); it != front.end(); ++it){
      cout << *it;
      if (it != front.end()-1) cout << " ";
    }
  }
  cout << endl;
  return 0;
}

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

int main()
{
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(s == u)
  {
    cout << (a-1) << " " << b << endl;
  }
  else
  {
    cout << a << " " << (b-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using p = pair<int, int>;
 
int main() {
  int n;
  cin >> n;
  
  cout << (n + 1) / 2 << endl;
 
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long ans;
	int N,K;
	int v[200005];
	scanf("%d %d",&N,&K);
	for(int i=0;i<N;i++){
		scanf("%d",&v[i]);
	}
	sort(v,v+N);
  	reverse(v,v+N);
	for(int i=K;i<N;i++) ans+=v[i];
  	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    int sum = 0;
    rep(i, n) sum += a[i];
    sum -= a[n - 1] / 2;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int a,b; 
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b;
	if (a%b==0) cout<<-1;
	else cout<<a;
	return 0;
}

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

int main(void){
    
    long long A,B,C;
    cin >> A >> B >> C;
    
    long long ans;
    ans  = B;
    
    if(C<=A+B)ans += C;
    else ans += B + A + 1;
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        p: [(usize, usize); n],
    }
    let mut g = 0;
    for (a, b) in p {
        let mut l = b / 2;
        let mut r = b;
        let mut dp = [0, 1];
        while l >= a {
            let (ll, rr) = (l / 2, l);
            let mut u = [false; 3];
            u[dp[(r - 2 * rr) % 2]] = true;
            u[dp[(r - (rr + 1)) % 2]] = true;
            let x = u.iter().position(|p| !*p).unwrap();
            let mut u = [false; 3];
            u[x] = true;
            u[dp[(r - 2 * (rr - 1)) % 2]] = true;
            let y = u.iter().position(|p| !*p).unwrap();
            dp = [x, y];
            l = ll;
            r = rr;
        }
        g ^= dp[(r - a) % 2];
    }
    let ans = if g > 0 {"mo3tthi"} else {"tubuann"};
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 10892
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
LCM = A[0]
for i in range(1, N):
    LCM = LCM * A[i] // math.gcd(LCM, A[i])
 
for i in range(N):
  temp = LCM//A[i]
  if temp%2 == 0: #存在しない
    print(0)
    exit()
MIN = LCM//2
nokori = M - MIN
#print(MIN,nokori,LCM)
ans = nokori//LCM + 1
print(ans)

Measured memory_bytes: 84976
/*
  AtCoder Beginner Contest 098
  B - Cut and Count
*/

#include<iostream>
#include<string>
using namespace std;

int N;
char S[101];
int C[100];

int main() {
  scanf("%d", &N);
  scanf("%s", S);
  for (int i = 0; i < N; ++i) C[i] = 1 << (S[i] - 'a');
  
  int s1 = 0x0, s2;
  int maxval = 0;
  for (int i = 1; i < N; ++i) {
    s1 |= C[i-1];
    s2 = 0x0;
    for (int j = i; j < N; ++j)s2 |= C[j];
    int check = s1 & s2;

    int val = 0;
    for (int j = 0; j < 26; ++j) val += (check >> j) & 1;
    if (val > maxval) maxval = val;
  }

  printf("%d\n", maxval);
  return 0;
}

Measured memory_bytes: 384
object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val h, w, a, b = sc.nextInt
    sc.close()

    (0 until h).foreach(hh => {
      if (hh < h - b) println("0" * a + "1" * (w - a))
      else println("1" * a + "0" * (w - a))
    })
  }
}

Measured memory_bytes: 36704
#[allow(unused_macros)]
macro_rules! input {
    ( $($t:ty),* ) => {{
        let mut s = String::new();
        std::io::stdin().read_line(&mut s);
        let mut splits = s.trim().split_whitespace();
        ($( { splits.next().unwrap().parse::<$t>().unwrap() },)*)
    }}
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
fn solve() {
    let (n, m) = input!(u64, u64);

    println!("{}", n * m);
}

fn main() {
    solve();
}


Measured memory_bytes: 2076
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Low Elements
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

template <typename T, const int MAX_N>
struct BIT {
  int n;
  T bits[MAX_N + 1];
  BIT() {}

  void init(int _n) {
    n = _n;
    //memset(bits, 0, sizeof(bits));
  }

  T sum(int x) {
    T s = 0;
    while (x > 0) {
      s += bits[x];
      x -= (x & -x);
    }
    return s;
  }

  void add(int x, T v) {
    while (x <= n) {
      bits[x] += v;
      x += (x & -x);
    }
  }
};

/* global variables */

BIT<int,MAX_N> bit;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

  bit.init(n);
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    int pi;
    scanf("%d", &pi);

    int s = bit.sum(pi);
    if (s == 0) cnt++;
    //printf("%d: %d\n", pi, s);

    bit.add(pi, 1);
  }

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 1024