akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using UL=unsigned int;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(UL i=0; i<(n); i++)

UL N;
pair<LL,LL> X[500000];

LL div_conq(UL l, UL r){
 if(l+1>=r) return (LL)1e15;
 UL m=(l+r)>>1;
 LL x=X[m].first;
 LL q1=min(div_conq(l,m),div_conq(m,r));
 static pair<LL,LL> bufl[500000], bufr[500000];
 for(UL i=l; i<m; i++) bufl[i-l]=X[i]; bufl[m-l]={(LL)1e15,(LL)1e15};
 for(UL i=m; i<r; i++) bufr[i-m]=X[i]; bufr[r-m]={(LL)1e15,(LL)1e15};
 UL lp=0, rp=0;
 while(lp+rp < r-l){
  if(bufl[lp] < bufr[rp]) { X[l+lp+rp]=bufl[lp]; lp++; }
  else { X[l+lp+rp]=bufr[rp]; rp++; }
 }
 LL ans=q1;
 deque<pair<LL,LL>> D;
 rep(i,4) D.push_back({10000000*(i+1),10000000*(i+1)});
 for(UL i=l; i<r; i++){
  D.pop_front();
  D.push_back(X[i]);
  rep(j,4) rep(k,4){
   if(j==k) continue;
   LL dx=D[j].first-D[k].first;
   LL dy=D[j].second-D[k].second;
   ans=min(ans,dx*dx+dy*dy);
  }
 }
 return ans;
}

int main(){
 scanf("%u",&N);
 rep(i,N){
  int x,y; scanf("%d%d",&x,&y);
  X[i]={x,y};
 }
 sort(X,X+N);
 LL ans=div_conq(0,N);
 printf("%lld\n",ans);
 return 0;
}



Measured memory_bytes: 18840
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(a < b && b < c ? "Yes" : "No");
        sc.close();
    }
}



Measured memory_bytes: 26160
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>
// #include <atcoder/fenwicktree>

using namespace std;
// using namespace atcoder;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 998244353;

void append(vector<ll> &A, ll a, ll b) {
  A.pb(a);
  A.pb(b);
  if(a < 0 && b >= 0) {
    A.pb(0);
    A.pb(-1);
  }
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);
 ll a,b,c,d;cin>>a>>b>>c>>d;
 vector<ll> A, B;
 append(A, a, b);
 append(B, c, d);
 ll ans = LONG_LONG_MIN;
 for(auto x : A) {
   for(auto y : B) {
     ans = max(ans, x*y);
   }
 }
 cout << ans << "\n";

 return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define M 998244353
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll power(ll a,ll n)
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main(){
		ios;
		ll s,w;
		cin>>s>>w;
		if(w>=s){
			cout<<"unsafe"<<endl;
		}
		else{
			cout<<"safe"<<endl;
		}
		return 0;
}

Measured memory_bytes: 3648
function Main(input) {
    input = input.split("\n");        
    var b = input[1].split(" ").map(e=>parseInt(e,10));    
    
    var c = []
    b.forEach((ele,ind)=>{
        c[ele-1]=ind+1        
    })

    console.log(c.reduce((prev,curr)=>{
        return prev+" "+curr;
    },"").slice(1))
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 58712
N=int(input())
A=[int(i) for i in input().split()]
ans=0
for i in range(N):
    minj=i
    for j in range(i,N):
        if A[j]<A[minj]:
            minj=j
    if i!=minj:
        A[i],A[minj]=A[minj],A[i]
        ans+=1
print(" ".join([str(i) for i in A]))
print(ans)



Measured memory_bytes: 5608
/*
*
*   Bismillah Hir Rahman Nir Raheem
*   Name: Jaied Al Sabid
*
*/

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

#define pf printf
#define sf scanf
#define elif else if

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    short int a,b,c;
    cin>>a>>b>>c;
    if((a+b+c) < 22)
    {
        pf("win\n");
    }
    else{pf("bust\n");}

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    int c, d;
    cin >> c >> d;
    ATYN((abs(a-c) <= d ) || (abs(a-b) <=d && abs(b-c) <= d))

    return 0;
}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        string N; cin >> N;
        vector<int> A(N.size());
        rep(i, N.size()) A[i] = N[N.size() - i - 1] - '0';
        A.push_back(0);
        ll ans = 0;
        rep(i, A.size()) {
            int a = A[i];
            if(a > 10 - a or (i + 1 < A.size() and a == 5 and A[i + 1] >= 5)) {
                ans += 10 - a;
                // assert(i + 1 < A.size());
                A[i + 1]++;
            } else ans += a;
        }
        cout << ans << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 11164
#include <stdio.h>
#include <limits.h>
#include <algorithm>

using namespace std;

int cmp_count = 0;


void merge(int A[],int left,int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int L[n1+1],R[n2+1];
	for(int i = 0; i < n1; i++) L[i] = A[left + i];
	for(int i = 0; i < n2; i++) R[i] = A[mid + i];
	L[n1] = R[n2] =  INT_MAX;

	int i = 0, j = 0;
	for(int k = left;k < right; k++){
		if(L[i] <= R[j]){
			A[k] = L[i++];
			cmp_count++;
		}else{
			A[k] = R[j++];
			cmp_count++;
		}
	}
}

void mergeSort(int A[],int left,int right){
	if(left+1 < right){
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int main(){
	int n;
	scanf("%d",&n);
	int S[n];
	for(int i = 0; i < n; i++) scanf("%d",&S[i]);

	mergeSort(S,0,n);

	for(int i = 0; i < n-1; i++) printf("%d ",S[i]);
	printf("%d\n",S[n-1]);
	printf("%d\n",cmp_count);

}


Measured memory_bytes: 6508
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  ll k; cin >> k;
  vector<int> A(n + 1);
  A[0] = INT_MAX;
  rep1(i, n) cin >> A[i];

  unordered_set<int> seen;
  vector<int> order;

  seen.insert(1);
  order.push_back(1);
  int cur = 1;

  int break_town;
  while(true) {
    int next = A[cur];
    // cout << cur << "->" << next << endl;
    if(seen.find(next) != seen.end()) {
      break_town = next;
      break;
    }

    order.push_back(next);
    if(order.size() == k + 1) {
      cout << next << endl;
      return 0;
    }
    seen.insert(next);
    cur = next;
    continue;
  }

  int circ_start = find(order.begin(), order.end(), break_town) - order.begin();
  k -= circ_start;

  int ansi = k % (order.size() - circ_start);

  cout << order[circ_start + ansi] << endl;
}


Measured memory_bytes: 11532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
//const ll mod=1000000007;
int mod;
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=160;
int n,k;

ll dp[N][N];
ll solvee(int n,int k) {
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	rep(i,0,n) rep(j,0,k+1) {
		dp[i+1][0]=(dp[i+1][0]+dp[i][j])%mod;
		if (j+1<=k) dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
	}
	ll ans=0;
	rep(j,0,k+1) ans=(ans+dp[n][j])%mod;
	return ans;
}

ll dp2[N][N][N];

void upd(ll &a,ll b) {
	a+=b; if (a>=mod) a-=mod;
}

bool valid(int a,int b) {
	if (a==0||b==0) return 1;
	return a-1+b-1<k;
}

int main() {
	scanf("%d%d%d",&n,&k,&mod);
	if (k%2==0) {
		printf("%lld\n",solvee(n/2,k/2)*solvee(n-n/2,k/2)%mod);
	} else {
		if (n==1) {
			puts("2");
			return 0;
		}
		ll ans=0;
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		for (int i=1;i<=k;i+=2) rep(j,0,k+1) {
			dp[i/2+1][0]=(dp[i/2+1][0]+dp[i/2][j])%mod;
			dp[i/2+1][j+1]=(dp[i/2+1][j+1]+dp[i/2][j])%mod;
		}
		rep(p1,0,n+1) rep(p2,0,n+1) if (valid(p1,p2)) {
			dp2[0][p1][p2]=dp[k/2+1][p2];
		}
		for (int i=0;i+2<n;i+=2) rep(p1,0,n+1) rep(p2,0,n+1) if (valid(p1,p2)) {
			// fix i+2, i+k+2
			//printf("gg %d %d %d %lld\n",i,p1,p2,dp2[i][p1][p2]);
			if (p1>0) {
				if (i+k+2<n) {
					upd(dp2[i+2][p1-1][0],dp2[i][p1][p2]);
					if (valid(p1-1,p2+1)) upd(dp2[i+2][p1-1][p2+1],dp2[i][p1][p2]);
				} else {
					upd(dp2[i+2][p1-1][0],dp2[i][p1][p2]);
				}
			} else {
				for (int l=0;l<=n;l++) {
					if (i+k+2<n) {
						upd(dp2[i+2][l][0],dp2[i][p1][p2]);
						if (valid(l,p2+1)) upd(dp2[i+2][l][p2+1],dp2[i][p1][p2]);
					} else {
						upd(dp2[i+2][l][0],dp2[i][p1][p2]);
					}
				}
			}
		}
		for (int p1=0;p1<=1;p1++) for (int p2=0;p2<=n;p2++) if (valid(p1,p2)) {
//			printf("%d %d %lld\n",p1,p2,dp2[4][p1][p2]);
			upd(ans,dp2[n-((n%2)?1:2)][p1][p2]);
		}
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 30080
// ------------------------------------
// Date:2018/ 3/24
// Problem:One Stroke Path re_c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 8;


struct Edge {
  Edge(int _to)
    : to(_to){}
  int to;
};

vector< Edge > e[MAX_N];

int N;

bool check(vector< bool > state)
{
  REP(v, state.size()) {
    if (!state[v]) return false;
  }
  return true;
}

int dfs(int from)
{
  int res = 0;
  vector< bool > state(N, false);
  state[0] = true;
  
  queue< pair< int, vector< bool > > > q;
  q.push(make_pair(from, state));
  
  while(!q.empty()) {
    int from;
    vector< bool > _state;
    tie(from, _state) = q.front();
    q.pop();
    // debug(from);
    _state[from] = true;
    
    if (check(_state)) {
      res++;
    }
    EACH(to, e[from]) {
      if (_state[to.to]) continue;
      q.push(make_pair(to.to, _state));
    }
  }
  return res;
}

int main()
{
  int M;
  cin >> N >> M;
  vector< int > a(M);
  vector< int > b(M);
  REP(i, M) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    e[a[i]].emplace_back(Edge(b[i]));
    e[b[i]].emplace_back(Edge(a[i]));
  }

  int ans = dfs(0);

  cout << ans << endl;

  
  return 0;
}



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

using namespace std;

long long pw10[18], res = 0;
int n;

long long bt (int pos, long long rem, bool zero) {
    if (pos == 0) return (rem == 0 ? 1 : 0);
    if (pos == 1) return (rem == 0 ? 10 : 0);

    long long ans = 0;
    for (int i = -9; i <= 9; i++) {
        long long cur = rem - 1LL * i * (pw10[pos - 1] - 1);
        if (cur % 10 == 0) {
            if (!zero) {
                if (i >= 0) ans += bt(pos - 2, cur / 10, true) * (9 - abs(i));
            }
            else ans += bt(pos - 2, cur / 10, true) * (10 - abs(i));
        }
    }

    return ans;
}

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

    pw10[0] = 1;
    for (int i = 1; i < 18; i++) pw10[i] = 1LL * pw10[i - 1] * 10;
    for (int i = 1; i <= 18; i++) res += bt(i, n, false);

    printf("%lld", res);
    return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>

using namespace std;

#define sz(X) ((int)(X).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()
#define FOR(i, a, n) for(int i=(a), __ ## i=(n); i<__ ## i; i++)
#define REP(I,N) FOR(I,0,N)
#define PR(X) cout<<#X<<" = "<<(X)<<" "
#define PRL cout<<endl
#define PRV(X) {cout<<#X<<" = {";REP(__prv,sz(X)-1)cout<<(X)[__prv]<<",";if(sz(X))cout<<*(X).end();cout<<"}"<<endl;}

template<class T> ostream &operator<<(ostream &os, const vector<T> &vec)
{
	os << '{';
	REP(i, sz(vec))
	{
		os << vec[i];
		if (i + 1 != sz(vec))
			os << ',';
	}
	os << '}';
	return os;
}

template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &par)
{
	os << '(' << par.X << ',' << par.Y << ')';
	return os;
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<unsigned long long> VULL;
typedef vector<vector<int>> VVI;
typedef queue<int> QI;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : abs(x);
}

template<class T> T sqr(T x)
{
	return x * x;
}

int a[100000];

int main()
{
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	REP(i, N)
		cin >> a[i];

	sort(a, a + N);

	if (a[N - 1] - a[0] > 1)
	{
		cout << "No";
		return 0;
	}

	if (a[0] == a[N - 1])
	{
		if (a[0] == N - 1 || a[0] <= N / 2)
			cout << "Yes";
		else
			cout << "No";
	}
	else
	{
		int dif = 0;
		REP(i, N)
			if (a[i] == a[N - 1])
			{
				dif = i;
				break;
			}

		if (a[N - 1] > dif && a[N-1] - dif <= (N - dif) / 2)
			cout << "Yes";
		else
			cout << "No";
	}


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int>A(4);
  for (int i = 0; i < 4; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  if (A.at(0) == 1 && A.at(1) == 4 && A.at(2) == 7 && A.at(3) == 9){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}



Measured memory_bytes: 3608
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt(),i=0;
        int[]a=new int[n];
        for(;i<n;){
            a[i++]=sc.nextInt();
        }
        Arrays.sort(a);
        int sum=1000000000;
        for(i=0;i+m-1<n;i++){
            sum=Math.min(sum,a[i+m-1]-a[i]);
        }
        System.out.print(sum);
    }
}


Measured memory_bytes: 50400
#include <bits/stdc++.h>
#include <queue>
using namespace std;
int main(void){
    long long N,A,B;
    cin >> N >> A >> B;
    long long C = N / (A+B);
    long long D;
    if(N-C*(A+B) >= A) D = A;
    else D = N - C*(A+B);
    cout << A*C + D << endl;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x, k, d := scanInt(), scanInt(), scanInt()
	x = abs(x)
	if (x+d-1)/d <= k {
		t := k - x/d
		if t%2 == 0 {
			fmt.Fprintln(wr, x%d)
		} else {
			fmt.Fprintln(wr, d-x%d)
		}
	} else {
		fmt.Fprintln(wr, x-d*k)
	}
}


Measured memory_bytes: 1780
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;

int main()
{
    int x,n,y;
    sii(x,n);

    int a[n+2];
    map<int,int> mp;


    Rep(i,1,n)
    {
        si(y);
        mp[y]=1;
    }


   int mn=inf,value;

   for(int i=-1000;i<=1000;i++)
   {
       if(mp[i]==0)
       if(mn>abs(x-i))
       {
           mn=abs(x-i);
           value=i;
       }
   }

   if(n==0)
    value=x;


   printf("%d\n",value);


    return 0;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,n,t;
    cin>>n>>x>>t;
    int q=n/x;
    int ans=t*q;
    if(n%x!=0){
        ans+=t;
    }
    cout<<ans<<endl;
    return 0;
}

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

int n, position;
vector<int> pre;
vector<int> in;
vector<int> post;

void rec (int l, int r) {
  if (r <= l) {
    return;
  }
  int root = pre[position++];
  int m = distance(in.begin(), find(in.begin(), in.end(), root));
  rec(l, m);
  rec(m + 1, r);
  post.push_back(root);
}

void f () {
  position = 0;
  rec(0, pre.size());
  for (int i = 0; i < n; i++) {
    cout << post[i];
    if (i != n - 1) {
      cout << " ";
    }
  }
  cout << endl;
}

int main() {

  cin >> n;

  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    pre.push_back(k);
  }

  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    in.push_back(k);
  }

  f();

  return 0;

}


Measured memory_bytes: 3160
#include<iostream>
    #include<iomanip>
    #include<map>
    #include<set>
    #include<string>
    #include<algorithm>
    #include<cmath>
    #include<vector>
    #include<queue>
    #include<stack>
     
    using namespace std;
     
    #define P(p) cout<<(p)<<endl
    #define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
    #define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
    #define vsort(v) sort(v.begin(), v.end());
    #define rvsort(v) sort(v.begin(), v.end(),greater<int>());
    #define YES cout<<"YES"<< endl
    #define NO cout<<"NO"<<endl
    #define Yes cout<<"Yes"<<endl
    #define No cout<<"No"<<endl  
    #define yes cout<<"yes"<<endl
    #define no cout<<"no"<<endl
    #define ret return
    #define C(i) cin>>i
    #define C2(i,j) cin>>i>>j
    #define C3(i,j,k) cin>>i>>j>>k
    #define C4(i,j,k,m) cin>>i>>j>>k>>m
    ////////////////////////////////////////////////////////////
     
    int main(){
      long n,a,b,sum = 0 , ksum = 0;
      C3(n,a,b);
      
      for(long i = 0 ; i < n ; i++ ){
        char c;
        cin >> c;
        if(c == 'a' && sum < a + b){
          Yes;
          sum++;
        }
        else if(c == 'b' && ksum < b && sum < a+b){
          Yes;
          sum++;
          ksum++;
        }
        else
          No;
     
      }
      ret 0;
    }

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdlib.h>  
#include <unordered_map> 
using namespace std;
int main()
{
	long long int n;
	cin>>n;
	long long int a[n];
	for( long long int i=0;i<n;i++)
		{
			cin>>a[i];

		}
	sort(a,a+n);
	long long int j=n-1;
	bool side1found,side2found;
	side1found=false;
	side2found=false;
	long long int s1,s2;
	while(j>=0 && (side2found==false))
	{
		if(a[j]==a[j-1])
		{
			if(side1found==false)
			{
				side1found=true;
				s1=a[j];
			}
			else
			{
				side2found=true;
				s2=a[j];
				break;
			}
			long int count=0;
			while(a[j]==a[j-1] && j>=0 && count<4)
				{
					count++;
					j--;
				}
			//cout<<count<<endl;
			if(count==3 || count==4)
			{
				side2found=true;
				s2=s1;
				break;
			}	
		}
		else
			j--;
	}
	
	if(side2found==true && side1found==true)
		cout<<s1*s2;
	else
		cout<<"0";
	cout<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define LL long long
using namespace std;
const int N=2e3+10;
int n;
LL dp[N][N],ans,minn=3e18,x,a[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline I abss(I&x){return x>0 ? x : -x;}
template<typename I>inline I mi(const I&a,const I&b){return a<b ? a : b;}
int main()
{
	//freopen("Colorful Slimes.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n,x);
	for(int i=0;i<n;i++) read(a[i]);
	memset(dp,0x3f,sizeof dp);
	for(int i=0;i<n;i++)
	{
		dp[i][0]=a[i];
		for(int j=1;j<n;j++) dp[i][j]=mi(dp[i][j-1],a[(i-j+n)%n]);
	}
	for(int i=0;i<n;i++)
	{
		ans=0;
		for(int j=0;j<n;j++) ans+=dp[j][i];
		minn=mi(minn,ans+x*i);
	}
	printf("%lld\n",minn);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 31872
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
# sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
# from collections import deque, Counter                          # キュー・個数カウント
# from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
# from operator    import itemgetter                              # ソート補助
# from bisect      import bisect_left, bisect_right, bisect       # 二分探索
# from heapq       import heappop, heappush                       # プライオリティキュー
# from fractions   import gcd                                     # 最大公約数
# from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
# from copy        import deepcopy                                # オブジェクトコピー
# import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    n, m = im.inputMultiple()
    left = 0
    right = n
    for _ in range(m):
        l, r = im.inputMultiple()
        left = max(left, l - 1)
        right = min(right, r - 1)
    # Logic ############################################################################################################

    # Output ###########################################################################################################
    if (right - left) >= 0:
        print(right - left + 1)
    else:
        print(0)
    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll , ll> P;
typedef pair<ll, ll> PL;
const ll INT_INF = 2147483646;
const ll ll_INF = 9223372036854775807;
ll mod = 1e9+7;

bool SecondCompare(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
       return a.second>b.second;
}

int x,y;

int main(){
    cin >> x >> y;
    cout << x + y/2 << endl;
}

Measured memory_bytes: 256
//Awwawa! Dis cold yis ratten buy tEMMIE!
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second

template <typename T> bool chkmax(T &x,T y){return x<y?x=y,true:false;}
template <typename T> bool chkmin(T &x,T y){return x>y?x=y,true:false;}

using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int s[500][27];
int c[27];
int cal(int x) {
	return (x - 1) * x / 2;
}
int n;
int l[27];
int val(vi t) {
	int ans = 0;
	memset(l, -1, sizeof(l));
	for (int i = 0; i < n; i++)
		ans += s[i][t[i]], 
		ans -= c[t[i]] * cal(i - l[t[i]]), 
		l[t[i]] = i;
	for (int i = 0; i < 27; i++)
		ans -= cal(n - l[i]) * c[i];
	return ans;
}
vi upd(vi s) {
	int nans = val(s);
	while (1.0 * clock() / CLOCKS_PER_SEC < 1.5) {
		int fl = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 26; j++) {
				vi e = s;
				e[i] = j;
				int na = val(e);
				if (chkmax(nans, na)) 
					s = e, fl = 0;
			}
		if (fl) break;
	}
	return s;
}
int main() {
	cin >> n;
	for (int i = 0; i < 26; i++)
		cin >> c[i];
	vi cur(n);
	for (int i = 0; i < n; i++) 
		for (int j = 0; j < 26; j++) {
			cin >> s[i][j];
			if (s[i][j] > s[i][cur[i]])
				cur[i] = j;
		}
	vi fn = upd(cur);
	for (auto v : fn) 
		cout << v + 1 << endl;
//	cout << endl;
//	cout << val(fn) << endl;
	return 0;
}


Measured memory_bytes: 3700
//ドハマりした。
#include <iostream>
#include <string>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h[4], w[4];
string a[4][4];
string b[4];

bool check(int i, int y, int x) {
	int j, k;
	rep(j, h[i]) {
		rep(k, w[i]) {
			if (a[i][j][k] == '.') continue;
			if (y + j >= 4 || x + k >= 10 || b[y + j][x + k] != '.') return false;
		}
	}
	return true;
}

bool dfs(int y, int x, int used, int cnt) {
	if (cnt == 0) {
		return true;
	}
	if (y == 4) { return false; }
	if (x == 10) { return dfs(y + 1, 0, used, cnt); }
	
	//if (b[y][x] != '.') { return dfs(y, x + 1, used, cnt); }
	
	int i, j, k;
	rep(i, 4) {
		if ((used >> i) % 2) continue;
		if (!check(i, y, x)) continue;

		string bb[4];
		rep(j, 4) bb[j] = b[j];
		rep(j, h[i]) {
			rep(k, w[i]) {
				if (a[i][j][k] == '.') continue;
				b[y + j][x + k] = (char)('0' + i + 1);
			}
		}
		bool res = dfs(y, x + 1, used + (1 << i), cnt - 4);
		rep(j, 4) b[j] = bb[j];
		if (res) return true;
	}
	return dfs(y, x + 1, used, cnt);
}

int main() {
	int i, j, k;
	
	rep(i, 4) {
		cin >> h[i] >> w[i];
		rep(j, h[i]) cin >> a[i][j];
	}
	
	int n;
	cin >> n;
	rep(i, n) {
		rep(j, 4) cin >> b[j];
		
		int cnt = 0;
		rep(j, 4) rep(k, 10) if (b[j][k] == '.') cnt++;
		bool res = dfs(0, 0, 0, cnt);
		if (res) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3188
X, Y = map(int, input().split())

if X == 1 and Y == 1:
    print(1000000)
elif X > 3 and Y > 3:
    print(0)
elif (X == 1 and Y == 2) or (X == 2 and Y == 1):
    print(500000)
elif (X == 1 and Y == 3) or (X == 3 and Y == 1):
    print(400000)
elif (X == 1 and Y > 3) or (X > 3 and Y == 1):
    print(300000)
elif (X == 2 and Y == 2):
    print(400000)
elif (X == 2 and Y == 3) or (X == 3 and Y == 2):
    print(300000)
elif (X == 2 and Y > 3) or (X > 3 and Y == 2):
    print(200000)
elif (X == 3 and Y == 3) or (X == 3 and Y == 3):
    print(200000)
elif (X == 3 and Y > 3) or (X > 3 and Y == 3):
    print(100000)





Measured memory_bytes: 3064
#include <iostream>
#include  <string.h>
using namespace std;
int main()
{
    int n,T,i=0;
    int t[200001];
    cin>>n>>T;
    int goukei=0;
    
    for(i=1;i<=n;i++){
        cin >>t[i];
    }
    for(i=1;i<n;i++){
        if(t[i+1]-t[i]>=T){
            goukei = goukei + T;
        }
        else{
            goukei = goukei +t[i+1]-t[i];
        }
    }
    cout << goukei+T << endl;
    
    return 0;
    
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> cnt(26, 0);
    for (int i = 0; i < n; i++)
    {
        cnt[s[i] - 'a']++;
    }
    ll ret = 1;
    for (int i = 0; i < 26; i++)
    {
        ret *= (cnt[i] + 1);
        ret %= MOD;
    }
    ret = (ret + MOD - 1) % MOD;
    cout << ret << endl;
}


Measured memory_bytes: 512
from collections import deque
mod=10**9+7
H,W = map(int,input().split())
Gd = [list(input()) for _ in range(H)]
INF = 0
direc = [[1,0],[0,1]]
def dfs(start):
  Rt = [[INF]*W for _ in range(H)]
  Rt[start[0]][start[1]]=1
  q = deque([])# スタック
  q.append(start)
  while len(q)!=0:
    h,w = q.popleft()# スタック取りだし（はじめ）
    for d in direc:
      hs, ws = h + d[0], w + d[1]
      if not (0<=hs<H and 0<=ws<W):
        continue
      if Gd[hs][ws]=='.':
        if Rt[hs][ws]==INF:
          q.append([hs,ws])
        Rt[hs][ws] = (Rt[hs][ws] + Rt[h][w])%mod
  return Rt[H-1][W-1]
print(dfs([0,0]))

Measured memory_bytes: 51872
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
int count(ll x){
	int cnt = 0;
	while(x != 0){
		cnt++;
		x /= 10;
	}
	return cnt;
}
int main()
{
	ll n;
	cin >> n;
	int ans = 99999999;
	for(ll i = 1 ; i * i  <= n ; i++){
		if(n % i == 0){
			ans = min(ans , max(count(i) , count(n/i)));
		}
	}
	cout << ans << endl;
	return 0;
	
}



Measured memory_bytes: 256
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}

signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf    
    #ifndef ONLINE_JUDGE    
           freopen("input.txt","r",stdin);
           freopen("output.txt","w",stdout);
    #endif//*/
    int n;
    cin>>n;
    int a[n];
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        a[i]%=2;
        if(a[i])
            ans++;
    }
    if(ans%2)
        cout<<"NO"<<endl;
    else
        cout<<"YES"<<endl;


    printclock;
    return 0;
}


Measured memory_bytes: 4544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,ans,sum=0,arr[87],n,m;
    arr[0]=2;
    arr[1]=1;
    cin>>n;
    for(i=2;i<=n;i++)
    {
        arr[i]=arr[i-1]+arr[i-2];
    }
    cout<<arr[n]<<endl;
}


Measured memory_bytes: 256
<?php
list($W, $H, $x, $y, $r) = array_map('intval', explode(" ", trim(fgets(STDIN))));

$left = $x - $r;
$right = $x + $r;
$upper = $y + $r;
$lower = $y - $r;

if ($left >= 0 && $right <= $W && $upper <= $H && $lower >= 0) {
    echo "Yes\n";
} else {
    echo "No\n";
}
?>


Measured memory_bytes: 9224
// Snippets
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")
    };
}

macro_rules! stdin {
    () => ({
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    })
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => (
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input.to_string()), $output);
            )*
        }
    )
}

// End Snippets

fn main() {
    println!("{}", solve(stdin!()));
}

fn solve(src: String) -> String {
    input!{
        source = src,
        b: String
    }
    let ans = match b.as_str() {
        "A" => "T",
        "T" => "A",
        "C" => "G",
        "G" => "C",
        _ => "A",
    };
    ans.to_string()
}

test! {
    "A" => "T",
    "G" => "C"
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
   int n;
   cin >> n;
   map<pll, int>mp;
   vector<pll>a(n);
   rep(i, 0, n)cin >> a[i].first >> a[i].second;

   rep(i, 0, n){
       rep(j, 0, n){
           if(i==j)continue;
           ll p = a[i].first-a[j].first;
           ll q = a[i].second-a[j].second;
           mp[pll(p,q)]++;
       }
   }
   int c = 0;
   for(auto i:mp){
       c = max(c, i.second);
   }
   cout << 1+(n-1)-c << endl;
}

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

#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;

using namespace std;

long long arr[101][100001];
int v[101];
int w[101];

int main() {

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

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

	int N, W;
	cin >> N >> W;
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i <= W; ++i)
	{
		arr[0][i] = 0;
	}

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

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			arr[i][j] = (j - w[i] >= 0) ? max(arr[i - 1][j], v[i] + arr[i - 1][j - w[i]]) : arr[i - 1][j];
		}
	}

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

Measured memory_bytes: 82412
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

int n, m, d;

int read() {
  if (scanf("%d%d%d", &n, &m, &d) < 3) {
    return false;
  }
  return true;
}

const char chs[] = "RYGB";

void solve() {
  if (d & 1) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        printf("%c", chs[(i + j) & 1]);
      }
      printf("\n");
    }
    return;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      int x, y;
      if ((i + j) & 1) {
        x = (i + j - 1) / 2;
        y = (i - j - 1) / 2;
      } else {
        x = (i + j) / 2;
        y = (i - j) / 2;
      }
      x %= d;
      y = (y % d + d) % d;
      int col = (((int) (2 * x >= d)) << 1) | ((int) (2 * y >= d));
      printf("%c", chs[col]);
    }
    printf("\n");
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 512
# include <iostream>
using namespace std;
const int N=106,M=10006;
int a[N][N],b[M];
int n,m,p;
void work (void)
{
	int i,j,k,t,f;
	f=1;
	i=1;
	j=1;
	k=1;
	t=b[1];
	while (k<=p)
	if (f==1)
	{
		a[i][j]=k;
		t--;
		if (t==0)
		{
			k++;
			t=b[k];
		}
		j++;
		if (j==m+1)
		{
			i++;
			j--;
			f=-1;
		}
	}
else
    {
    	a[i][j]=k;
    	t--;
    	if (t==0)
		{
			k++;
			t=b[k];
		}
		j--;
    	if (j==0)
    	{
    		i++;
    		j++;
    		f=1;
    	}
    }
    for (i=1;i<=n;i++)
    {
    	for (j=1;j<m;j++)
    	cout<<a[i][j]<<" ";
    	cout<<a[i][m]<<endl;
    }
}
int main (void)
{
	int i;
	cin>>n>>m;
	cin>>p;
	for (i=1;i<=p;i++)
	cin>>b[i];
	work ();
	return 0;
}


Measured memory_bytes: 384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int a,b,m; cin >> a >> b >> m;
  vector<int> va(a);
  int amn=inf;
  int bmn=inf;
  rep(i,a){
    cin >> va[i];
    chmin(amn,va[i]);
  }
  vector<int> vb(b);
  rep(i,b){
    cin >> vb[i];
    chmin(bmn,vb[i]);
  }
  int ans=amn+bmn;
  rep(i,m){
    int x,y,c;
    cin >> x >> y >> c;
    x--; y--;
    int sum=va[x]+vb[y]-c;
    chmin(ans,sum);
  }
  cout << ans << endl;
}

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

int main() {
	uint32_t N, K;
	cin >> N >> K;
	
	vector<uint32_t>a(N);
	for(uint32_t i=0; i<N; i++) cin >> a[i];
	
	sort(a.begin(), a.end());
	
	vector<bool> dp(K+1);

	for(uint32_t i=1; i<=K; i++) {
		for(uint32_t j=0; j<N; j++) {
			uint32_t aj = a[j];
			if(aj > i) break;
			
			dp[i] = dp[i] | !dp[i-aj]; 
		}
	}
	
	string ans = dp[K] ? "First" : "Second";
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 384
n,k=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
#n,k=200000,200000
#a=[0]*200000
if k>40
  puts ([n]*n).join(" ")
  exit
end
z=[0]*n
[k,40].min.times do
  b=[]
  l=z.dup
  c=0
  0.upto(n-1) do |i|
    c+=1
    if i+a[i]<n-1
      l[i+a[i]]+=1
    end
    b[i]=c
    c-=l[i]
  end
  l=z.dup
  c=0
  (n-1).downto(0) do |i|
    if i-a[i]>0
      l[i-a[i]]+=1
    end
    b[i]+=c
    c-=l[i]
    c+=1
  end
  a=b.dup
end
puts a.join(" ")


Measured memory_bytes: 103852
#include <bits/stdc++.h>
using namespace std;
#define F first  
#define S second
#define ll long long
#define pb push_back
#define pr pair<ll,ll>

const ll N=1e5+9,mod=1e9+7,inf=1e18;

int main(int argc, char const *argv[])
{
	char c;cin>>c;
	c++;
	cout<<c<<"\n";
	
	
	return 0;
}


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

using namespace std;



long long n,k;
long long a[2000100];

long long  t=0;
long long b[2000100];
long long p=1;

int main() {

  cin >> n >> k;
  for(long long i=0 ; i<n ; i++)
    cin >> a[i+1];

  for(long long i=1 ; i<=n ; i++)
    b[i]=0;

  // cout << "data "<<endl;

  t=k;

  while(t>0){

    // cout << "t "<<t<<" p "<<p<<" ";
    p=a[p];

    if(b[p]!=0){
      //  cout << "reached "<<b[p];

      long long d = b[p]-t;

      // cout << " t:"<<t<<" d:"<<d;
      if(t>d){
	t = t%d-1+d;     
	b[p]=t;
      }
      else{
	b[p]=t;
	t--;

      }
    }
    else{
      b[p]=t;
      t--;
    }
    
    // cout << endl;
  
  }

  cout << p << endl;
  
  
  return 0;
}


  


Measured memory_bytes: 6764
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int n;
	string s;
	cin>>n>>s;
	s += s[0];
	rep(i, 4){
		vector<int> v(n+2);
		v[0] = i%2; v[1] = i/2;
		for(int j = 1; j <= n; j++){
			int t = s[j]=='x';
			if(v[j]==1) t = !t;
			v[j+1] = v[j-1]^t;
		}
		if(v[0]==v[n] && v[1]==v[n+1]){
			string res = "";
			rep(k, n) res += (v[k]?'W':'S');
			cout<<res<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 1052