akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
long long n;
long long N;
inline bool div(long long t){
	N=n;
	while(N>=t){
		if(N%t==0)N/=t;
		if(N%t!=0){
			if((N-1)%t==0){
				N=1;
			}
			break;
		}
	}
	if(N==1)return 1;
	else return 0;
}
int main(){
	cin>>n;
	long long sum=0;
	for(long long k=1LL;k*k<=n;k++){
		if(n%k==0&&k!=1){
			if(div(k))sum++;
		}
		if(k*k!=n&&n%k==0){
			if(div(n/k))sum++;
		}
	}
	for(long long k=1;k*k<=(n-1);k++){
		if((n-1)%k==0)sum+=2;
		if(k*k==(n-1))sum--;
		if(k==1)sum--;
	}
	cout<<sum<<endl;
	return 0;
}

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

int main() {
    ll n,a,b;
    cin >> n >> a >> b;
    ll c = n/(a+b)*a;
    ll d = n%(a+b);
    if(d>a) d=a;
    cout << c+d << endl;
}

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

using namespace std;
using ll = long long;

ll ans =  0;

int main()
{
  ios_base::sync_with_stdio (0);
  cin.tie (0) ;
  string s, t;
  cin >> s >> t;
  int n = (int) s.length();
  vector<vector<int>>next (2 * n, vector<int> (26, -1) );
  for (int i = 2 * n - 2; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      if (s[ (i + 1) % n] - 'a' == j) {
        next[i][j] = i + 1;
      } else {
        next[i][j] = next[i + 1][j];
      }
    }
  }
  int idx = 0;
  if (s[0] == t[0]) {
    t.erase (0, 1);
  }
  for (auto c : t) {
    if (next[idx][c - 'a'] == -1) {
      cout << -1 << '\n';
      return 0;
    }
    ans += (next[idx][c - 'a']) - idx;
    idx = (next[idx][c - 'a']) % n;
  }
  ans += 1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 27088
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> A(n);
  rep(i,n) cin >> A[i];
  bool flg=true;
  rep(i,n){
    if(A[i]%2==0){
      if(A[i]%3==0 || A[i]%5==0){
        continue;
      }else{
        flg = false;
      }
    }else{
      continue;
    }
  }
  if(flg) cout << "APPROVED";
  else cout << "DENIED";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define All(A) A.begin(),A.end()
#define RAll(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const LL INF=1<<30;



int main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A.pb(a);
    }
    cout << *max_element(All(A))-*min_element(All(A)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> da(n);
  for(int i=0;i<n;i++)
    cin >> da.at(i);
  sort(da.begin(),da.end());
  int ans=1000000000;
  for(int i=0;i<n-k+1;i++){
    ans=min(ans,-da.at(i)+da.at(i+k-1));
   // cout << ans << "  ";
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
import sys

from math import log

def get_array(): return list(map(int, sys.stdin.readline().split()))
def get_ints(): return map(int, sys.stdin.readline().split())

def bin_pow(a,b):
    result = 1
    while b>0:
        if b&1:
            result*=a
        b>>=1
        a*=a
    return result

n = int(input())
print(bin_pow(2, int(log(n, 2))+1)-1)

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

int main() {
    int n;
    cin>>n;
    vector<int> a(n);
    int ans = 0;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2) ans++;
    }
    if(ans%2) cout<< "NO"<<endl;
    else cout<< "YES" << endl;
}



Measured memory_bytes: 640
import sys
N, M = map(int, input().split())

A = [-1] * N

for i in range(M):
  s, c = map(int, input().split())
  if A[s-1] != c and A[s-1] != -1:
    print(-1)
    sys.exit()
  else:
    A[s-1] = c
  
if N >= 2 and A[0] == 0:
  print(-1)
  sys.exit()

res = 0

for i in range(N):
  if A[i] == -1:
    if i == 0 and N >= 2:
      A[i] = 1
    else:
      A[i] = 0
  res += A[i] * 10 ** (N-i-1)

print(res)

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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define MOD 1000000007
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

using namespace std;

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

	string s; cin>>s;
	int n = s.length();
	ll pR[n]={0},pL[n]={0},ans[n]={0};

	ll cnt=0;
	f(i,0,n-1){
		if(s[i]=='R') cnt++;
		else cnt=0;

		pR[i]=cnt;
	}
	cnt=0;
	for(ll j=n-1;j>=0;j--){
		if(s[j]=='L') cnt++;
		else cnt=0;

		pL[j]=cnt;
	}

	f(i,0,n-2){
		if(s[i]=='R' and s[i+1]=='L'){
			ans[i]+=((pR[i]/2) + (pR[i]%2!=0));
			ans[i]+=(pL[i+1]/2);
			ans[i+1]+=((pL[i+1]/2) + (pL[i+1]%2!=0));
			ans[i+1]+=(pR[i]/2);
		}
	}
	// f(i,0,n-1) cout<<pR[i]<<" ";
	// cout<<endl;
	// f(i,0,n-1) cout<<pL[i]<<" ";
	// cout<<endl;

	f(i,0,n-1) cout<<ans[i]<<" ";

	return 0;
}

Measured memory_bytes: 3024
n = int(input())
march = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
for i in range(n):
    str = input()
    if str[0] in march:
        march[str[0]] += 1
for i in list(march):
    if march[i] == 0:
        march.pop(i)
c = 0
if len(march) == 3:
    tmpc = 1
    for chr in march:
        tmpc *= march[chr]
    c += tmpc
elif len(march) == 4:
    for i in march:
        tmpm = march.copy()
        tmpm.pop(i)
        tmpc = 1
        for chr in tmpm:
            tmpc *= tmpm[chr]
        c += tmpc
elif len(march) == 5:
    keys = list(march.keys())
    for i in range(len(keys)):
        for j in range(i + 1, len(keys)):
            tmpm = march.copy()
            tmpm.pop(keys[i])
            tmpm.pop(keys[j])
            tmpc = 1
            for chr in tmpm:
                tmpc *= tmpm[chr]
            c += tmpc
print(c)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	string s;
	bool hi = true;
	cin >> s;
	if(s.size() % 2 == 1)hi = false;
	else {
		for (int i = 0; i < s.size(); i += 2) {
			if (s.substr(i, 2) != "hi") hi = false;
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
using namespace std;
const ll INF=1e9;
int a[1000];
bool per(int n,int k)
{
    for(int i=1;i<k;i++)
    {
        if(a[i]==n || abs(a[i]-n)==abs(i-k))
            return false;
    }
    return true;
}
ll res=0;
void nqueen(int n,int k=1)
{
    if(k==3)
    {
        res++;
        return;
    }
for(int i=1;i<=n;i++)
{
if(per(i,k))
{
    a[k]=i;
    cout<<i<<" "<<k<<endl;
    nqueen(n,k+1);

}
}
}
void solve(){
string s,b;
cin>>s;
cin>>b;
s+=b[(ll)b.size()-1];
if(s==b)
    cout<<"Yes";
else
    cout<<"No";
cout<<endl;
}

int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin >> t;
	while(t--){
		solve();
	}


	return 0;
}


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

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

  if(a > b + 1) cout << a + a - 1;
  else if(b > a + 1) cout << b + b - 1;
  else cout << a + b;
  cout << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10, mod = 998244353;

int n, q, ten[N], seg[N << 2], lazy[N << 2];

int t(int l, int r) {
  return ((ten[n - l + 1] - ten[n - r]) % mod + mod) % mod;
}

void push(int n, int i, int j) {
  if (lazy[n]) {
    if (i != j) {
      lazy[n << 1] = lazy[n << 1 | 1] = lazy[n];
    }
    seg[n] = (lazy[n] * t(i, j)) % mod;
    lazy[n] = 0;
  }
}

int query(int i, int j, int l, int r, int n) {
  if (i > r || j < l) {
    return 0;
  }
  if (i >= l && j <= r) {
    push(n, i, j);
    return seg[n];
  }
  push(n, i, j);
  int m = (i + j) >> 1;
  return (query(i, m, l, r, n << 1) + query(m + 1, j, l, r, n << 1 | 1)) % mod;
}

void update(int i, int j, int l, int r, int v, int n) {
  push(n, i, j);
  if (i > r || j < l) {
    return;
  }
  if (i >= l && j <= r) {
    lazy[n] = v;
    push(n, i, j);
    return;
  }
  int m = (i + j) >> 1;
  update(i, m, l, r, v, n << 1);
  update(m + 1, j, l, r, v, n << 1 | 1);
  seg[n] = (seg[n << 1] + seg[n << 1 | 1]) % mod;
}

int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);    
  cin >> n >> q;
  ten[1] = 1;
  for (int i = 2; i <= n; ++i) {
    ten[i] = (ten[i - 1] * 10) % mod;
  }
  for (int i = 2; i <= n; ++i) {
    ten[i] = (ten[i - 1] + ten[i]) % mod;
  }
  update(1, n, 1, n, 1, 1);
  while (q--) {
    int l, r, d;
    cin >> l >> r >> d;
    update(1, n, l, r, d, 1);
    cout << query(1, n, 1, n, 1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 13332
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a >= b&&b >= c) {
    cout << c <<" "<< b <<" "<< a << endl;
  }
  else if (a >= c&&c >= b) {
    cout << b <<" "<< c <<" "<< a << endl;
  }
  else if (b >= a&&a >= c) {
    cout << c <<" "<< a <<" "<< b << endl;
  }
  else if (b >= c&&c >= a) {
    cout << a <<" "<< c <<" "<< b << endl;
  }
  else if (c >= a&&a >= b) {
    cout << b <<" "<< a <<" "<< c << endl;
  }
  else {
    cout << a <<" "<< b <<" "<< c << endl;
  }
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S; cin>>S;
  S.pop_back();
  if(S.size()%2==1)
    S.pop_back();
  int n=S.size();
  rep(i,0,n/2){
    bool flag=1;
    int N=S.size();
    rep(j,0,N/2){
      if(S[j]!=S[j+N/2]){
        flag=0;
        break;
      }
    }
    if(flag){
        cout<<N<<endl;
        break;
      }
    S.pop_back();
    S.pop_back();
  }
  }



Measured memory_bytes: 256
s = input()
a = s[:2]
b = s[2:]
a = int(a)
b = int(b)
yymm = 0
mmyy = 0
if b >= 1 and b <= 12:
    yymm = 1
if a >= 1 and a <= 12:
    mmyy = 1
if yymm == 1 and mmyy == 1:
    print("AMBIGUOUS")
elif yymm == 1:
    print("YYMM")
elif mmyy == 1:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
MOD = 1000000007
N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))


def getPatternNum(num):
    pattern = [0] * (num + 2)
    pattern[0] = 0
    for i in range(1, num + 2):
        if i == 0 or i == 1:
            pattern[i] = 1
            continue
        pattern[i] = (pattern[i - 2] + pattern[i - 1]) % MOD
    return pattern

def solve():
    # 階段の連続してる数のリスト
    stepsList = [0] * (M + 1)
    maxSteps = 0
    if M > 0:
        stepsList[0] = a[0]
        for j in range(1, M):
            stepsList[j] = a[j] - a[j - 1] - 1
            if stepsList[j] == 0:
                return 0
        stepsList[M] = N - a[M - 1]
    else:
        stepsList = [N + 1]
    pattern = getPatternNum(max(stepsList) + 1)
    # こわれてるところ以外のパターンを掛ける
    # print("#", pattern)
    for k in range(len(stepsList)):
        if k == 0:
            total = pattern[stepsList[k]]
        else:
            total = (total * pattern[stepsList[k]]) % MOD
        # print("##", k, stepsList[k], pattern[stepsList[k]], total)

    return total


ans = solve()
print(ans)

Measured memory_bytes: 7848
N,A,B = list(map(int,input().split(" ")))

if A>B:
    print(0)
    exit()
elif N==1:
    if A!=B:
        print(0)
    else:
        print(1)
    exit()
else:
    max_ = B*(N-1)+A
    min_ = A*(N-1)+B
    print(max_ - min_ + 1)

Measured memory_bytes: 3060
import java.util.*

data class Edge(val from: Int, val to: Int, val weight: Long)

const val INF = Long.MAX_VALUE / 4

fun maxFlow(capacity: Array<LongArray>, s: Int, t: Int): Long {
  // Edmonds-Karp Algorithm
  val n = capacity.size
  val flow = Array(n, { LongArray(n) })
  fun residual(v1: Int, v2: Int): Long {
    return capacity[v1][v2] - flow[v1][v2]
  }
  fun getPath(prevs: IntArray): IntArray {
    val path = mutableListOf<Int>()
    var current = t
    path.add(current)
    while (current != s) {
      current = prevs[current]
      path.add(current)
    }
    path.reverse()
    return path.toIntArray()
  }
  var total = 0L
  while (true) {
    val queue = ArrayDeque<Int>()
    val prevs = IntArray(n, { -1 })
    queue.offer(s)
    while (queue.isNotEmpty()) {
      val v1 = queue.pop()
      for (v2 in 0 until n) {
        if (residual(v1, v2) == 0L || prevs[v2] >= 0) continue
        prevs[v2] = v1
        queue.offer(v2)
      }
    }
    if (prevs[t] == -1) return total
    val path = getPath(prevs)
    val inc = (0..(path.size - 2)).map { residual(path[it], path[it + 1]) }.min()!!
    (0..(path.size - 2)).forEach {
      flow[path[it]][path[it + 1]] += inc
      flow[path[it + 1]][path[it]] -= inc
    }
    total += inc
  }
}

fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val xs = longArrayOf(0) + readLine()!!.split(" ").map(String::toLong)
  val capacity = Array(n + 2, { LongArray(n + 2) })
  val s = 0
  val t = n + 1
  for (k in 1..n) {
    if (xs[k] >= 0) {
      capacity[k][t] = xs[k]
    } else {
      capacity[s][k] = -xs[k]
    }
  }

  for (i in 1..n) {
    for (j in (i + 1)..n) {
      if (j % i == 0) {
        capacity[i][j] = INF
      }
    }
  }

  val maxFlow = maxFlow(capacity, s, t)
  val ans = xs.filter { it >= 0 }.sum() - maxFlow
  println(ans)
}


Measured memory_bytes: 39420
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define UN unsigned int
#define mod 1000000007
#define F first
#define S second
#define mk make_pair
#define B(v) v.begin(), v.end()
#define BS binary_search

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	double doo=0.0,re=a[0];
	for(int i=1;i<n;i++)
	{
		re=(re+a[i])/2.0;

	}
	printf("%.12lf\n",re);
}

Measured memory_bytes: 256
def main():
    h, w = map(int, input().split())
    campus = []
    
    for i in range(h):
        campus.append(input())
    
    for y in range(h):
        for x in range(w):
            if campus[y][x] == '.':
                continue
            
            flg = True
            
            for l, k in [1, 0], [0, 1], [-1, 0], [0, -1]:
                ad_y, ad_x = y + l, x + k
                
                if ad_y < 0 or h <= ad_y or ad_x < 0 or w <= ad_x:
                    continue
                
                if campus[ad_y][ad_x] == '#':
                    flg = False
            
            if flg:
                print('No')
                return
    
    print('Yes')
    
if __name__ == '__main__':
    main()

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

int six[6] = {6, 36, 216, 1296, 7776, 46656};
int nine[5] = {9, 81, 729, 6561, 59049};

int func(int num, int ans){
    if(num <= 8) return ans + num / 6 + num % 6;
    int i6, i9;
    i6 = upper_bound(six, six + 6, num) - six;
    i6 = max(0, i6 - 1);
    i9 = upper_bound(nine, nine + 5, num) - nine;
    i9 = max(0, i9 - 1);
    ans++;
    return min(func(num - six[i6], ans), func(num - nine[i9], ans)); 
} 

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

    int n;
    cin >> n;

    cout << func(n, 0) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main()
{
int a,b,flag,i,str1=0,str2=0;

scanf("%d %d",&a,&b);
if(a+b<24)
{
printf("%d",a+b);
}
else{
    printf("%d",a+b-24);
}

    return 0;
}


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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

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

int main(void)
{
  int r;
  scanf("%d",&r);
  char str[7];
  if(r<1200) strcpy(str,"ABC");
  else if(r<2800) strcpy(str,"ARC");
  else strcpy(str,"AGC");
  printf("%s",str);
  return 0;
}


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

int n, k;
int main()
{
  	cin >> n >> k;
  	vector<int> repr;
  	while(n){
    	repr.push_back(n%k);
      	n /= k;
    }
  	cout << repr.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll S;
  cin >> S;
  ll X1, Y1, X2, Y2, X3, Y3;
  X1 = 0;
  Y1 = 0;
  X2 = ll(1e+9);
  Y2 = 1;
  Y3 = (S + ll(1e+9) - 1) / ll(1e+9);
  X3 = ll(1e+9) * Y3 - S;

  cout << X1 << ' ';
  cout << Y1 << ' ';
  cout << X2 << ' ';
  cout << Y2 << ' ';
  cout << X3 << ' ';
  cout << Y3;
  cout << endl;
}

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/




ll a[N];


int main()
{
    ll n,i,j=1,k=0;
    cin>>n;
    for1(i,n)
        cin>>a[i];

    for(i=1;i<=n;i++)
    {
        if(a[i]==j)
        {
            k++;
            j++;
        }
    }
    if(k==0)
        cout<<-1<<endl;
    else
        cout<<n-k<<endl;
	return 0;
}





























Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();

        for (int i = 0; i < line.length(); i++) {
            char c = line.charAt(i);
            char out = c;
            if (c >= 'a' && c <= 'z') {
                out = (char) (c - ('a' - 'A'));
            } else if (c >= 'A' && c <= 'Z') {
                out = (char) (c + ('a' - 'A'));
            }
            System.out.print(out);
        }
        System.out.println();
    }
}

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

int main(){

    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0;i<N;i++)
        cin >> A[i];

    int sum = 0;
    for(int i=0;i<N;i++)
        sum = sum ^ A[i];

    for(int i=0;i<N;i++){
        cout << (sum ^ A[i]);
        if(i<N-1) cout << " ";
    }
    
    return 0;
}

Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
string o,e;
int numo=0,nume=0;
int main() {
cin>>o>>e;
for(int i=0;i<o.length()+e.length();i++) {
	if(i%2==0) {
		cout<<o[numo++];
	} else {
		cout<<e[nume++];
	}
}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  
  int count = 0;
  int div = 0;
  while (count < N) {
    if (a.at(count) % 2 == 0) {
      div++;
      a.at(count) /= 2;
    }
    else count++;
  }
  
  cout << div << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
//---------------------------------------------------------------------------------------------------
ll MOD = 1000000007;
ll f[201010], rf[201010];
ll inv(ll x) {
    ll res = 1;
    ll k = MOD - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % MOD;
        y = (y * y) % MOD;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    for(int i = 1; i < 201010; i++) f[i] = (f[i - 1] * i) % MOD;
    for(int i = 0; i < 201010; i++) rf[i] = inv(f[i]);
}
ll C(int n, int k) {
    if(n < k) return 0;
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % MOD;

    return (a * bc) % MOD;
}
//---------------------------------------------------------------------------------------------------

int main()
{
    init();
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    int odd = 0;
    for(int i = 0; i < n; i++)
    {
        if(a[i] % 2 == 1) odd++;
    }
    ll ans = 0;
    for(int i = 1; i <= odd; i += 2)
    {
        ans += C(odd, i) * pow(2, n-odd);
    }
    if(p == 1) cout << ans << endl;
    else cout << ll(pow(2, n) - ans) << endl;
}


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

namespace abc115_a
{
    class Program
    {
        public static string Xmas(int D)
        {
            if (D == 22) return "Christmas Eve Eve Eve";
            else if (D == 23) return "Christmas Eve Eve";
            else if (D == 24) return "Christmas Eve";
            else if (D == 25) return "Christmas";
            else return "error";
        }

        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            Console.WriteLine(Xmas(D));

        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main(){
  int i,j,a,b;
  char c[3][12];
  scanf("%s",c[0]);
  scanf("%s",c[1]);
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%s",c[2]);
  for(i=0;i<12;i++){
    if(c[0][i]!=c[2][i]){
      b--;
      break;
    }
    if(c[0][i]==0){
      a--;
      break;
    }
  }
  printf("%d ",a);
  printf("%d",b);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int n, s, i;
  scanf("%d %d", &n, &s);
  
  int arr[n];

  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }

  int curSum = arr[0], curSize = 0, smallestSize = n + 1;
  int left = 0, right = 0;

  while (1) {
    if (right > n - 1) {
      break;
    }

    //printf("curSum is: %d, left is: %d, right is: %d\n", curSum, left, right);
    if (curSum >= s) {
      curSize = right + 1 - left;
      smallestSize = smallestSize < curSize ? smallestSize : curSize;
      curSum -= arr[left];
      left++;
    } else {
      right++;
      curSum += arr[right];
    }
  }

  if (smallestSize == n + 1)
    smallestSize = 0;

  printf("%d\n", smallestSize);
}



Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);

  int n;
  cin >> n;
  cout << (((n-1) / 1000) + 1) * 1000 - n << endl;
}


Measured memory_bytes: 3640
from collections import defaultdict
n=int(input())
a=list(map(int,input().split()))
even=defaultdict(int)
odd=defaultdict(int)
for i in range(n):
  if i%2==0:
    even[a[i]]+=1
  else:
    odd[a[i]]+=1
tmp=0
v1=-1
for key in even.keys():
  if even[key]>tmp:
    tmp=even[key]
    v1=key
tmp=0
v2=-1
for key in even.keys():
  if even[key]>tmp and key!=v1:
    tmp=even[key]
    v2=key
  
tmp=0
v3=-1   
for key in odd.keys():
  if odd[key]>tmp:
    tmp=odd[key]
    v3=key
  
tmp=0
v4=-1   
for key in odd.keys():
  if odd[key]>tmp and key!=v3:
    tmp=odd[key]
    v4=key

if v1!=v3:
  V1=n//2-even[v1]
  V2=n//2-odd[v3]
  print(V1+V2)
else:
  V1=n-even[v1]-odd[v4]
  V2=n-even[v2]-odd[v3]
  print(min(V1,V2))

Measured memory_bytes: 60268
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define x first
#define y second

using namespace std;
int tmp[105];
int solve()
{
	int x,n;
	int in;
	cin >> x >> n;
	if(n==0)
		return x;
	for(int i=0;i<n;i++)
	{
		cin >> in;
		tmp[in] = 1;
	}
	if (tmp[x] == 0)
		return x;
	int down = x-1,up = x+1;

	while(tmp[down] == 1 && tmp[up] == 1)
	{
		down--;
		up++;
	}
	if(down == -1)
		return -1;
	if(tmp[down] == 0)
		return down;

	return up;
}
int main() 
{
// 	freopen("c.in","r",stdin);
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n,m; cin >> n >> m;
    vl a(n);
    ll sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    priority_queue<ll> pq;
    rep(i,n){
        while(a[i]>0){
            pq.push(a[i]-a[i]/2);
            a[i] /= 2;
        }
    }
    ll minus = 0;
    rep(i,m){
        minus += pq.top(); pq.pop();
    }
    cout << max(0LL,sum - minus) << endl;
}


Measured memory_bytes: 35684
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cmath>
#include<bitset>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define pii(p)			pair<int,int> p
#define mii(m)			map<int, int> m
#define msi(m)			map<string, int, less<>> m
#define mmsi(m)			multimap<string, int, less<>> m
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
#define PI 3.141592
#define MOD 1e9+7
using namespace std;

void solve() {
	int n;
	cin >> n;
	vi(p)(n);
	FOR(n)
		cin >> p[i];
	int ans = 1, min = p[0];
	for (int i = 1; i < n; ++i)
		if (p[i] < min)
		{
			min = p[i];
			ans++;
		}
	cout << ans << endl;
}

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

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

#include <vector>
#define debug(x) print(x, #x)
#define debug_1d(arr, len) print(arr, len, #arr)
#define debug_2d(arr, row, col) print((decltype(&arr[0][0]))arr, row, col, sizeof(*arr)/sizeof(**arr), #arr)
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a1,a2,a3,x,...) x
#define deb(...) CHOOSE((__VA_ARGS__,debug_2d,debug_1d,debug,~))(__VA_ARGS__)
template<typename T> void print(T x, string tag="") {
	if (tag.empty()) cout << x << endl;
	else cout << tag << ": " << x << endl;
}
template<typename T> void print(T *ar, int len, string tag="") {
	if (!tag.empty()) cout << tag << ": ";
	for (int i = 0; i < len; ++i) cout << ar[i] << ' ';
		cout << endl;
}
template<typename T> void print(T *ar, int row, int col, int C, string tag="") {
	if (!tag.empty()) cout << tag << ": " << endl;
	for (int i = 0; i < row; ++i) {
		for (int j = 0; j < col; ++j) {
			cout << ar[i*C + j] << ' ';
		}
		cout << endl;
	}
}
template<typename T> void print(vector<T> v, string tag="") {
	if (!tag.empty()) cout << tag << ": ";
	for (T e : v) cout << e << ' ';
	cout << endl;
}
template<typename T> void print(vector<vector<T>> v, string tag="") {
	if (!tag.empty()) cout << tag << ": " << endl;
	for (auto ev : v) {
		for (auto e : ev) cout << e << ' ';
		cout << endl;
	}
}



long long mod(long long a, long long m) {
	a %= m;
	return a >= 0 ? a : a+m;
}

int popcount(long long x) {
	int res = 0;
	while (x > 0) {
		if (x & 1) res++;
		x >>= 1;
	}
	return res;
}

int main() {
	int n;
	string s;
	cin >> n >> s;
	vector<int> X(n);
	vector<int> ans(n);
	long long num_of_ones = 0;
	for (int i = 0; i < n; i++) {
		X[i] = s[n-1-i] - '0';
		if (X[i] == 1) num_of_ones++;
	}
	long long mod_minus = num_of_ones - 1, mod_plus = num_of_ones + 1;
	vector<long long> pow2plus(n+2), pow2minus(n+2);
	pow2plus[0] = pow2minus[0] = 1;
	for (int i = 1; i < n+2; i++) {
		pow2plus[i] = pow2plus[i-1] * 2 % mod_plus;
		if (mod_minus > 0) pow2minus[i] = pow2minus[i-1] * 2 % mod_minus;
	}
	long long sum_plus = 0, sum_minus = 0;
	for (int i = 0; i < n; i++) {
		sum_plus += X[i] * pow2plus[i];
		if (mod_minus > 0) sum_minus += X[i] * pow2minus[i];
	}
	for (int i = 0; i < n; i++) {
		if (X[i] == 0) {
			long long k = mod(sum_plus + pow2plus[i], mod_plus);
			long long a = 1;
			while (k > 0) {
				a++;
				k = k % popcount(k);
			}
			ans[i] = a;
		} else {
			if (mod_minus == 0) {
				ans[i] = 0;
				continue;
			}
			long long k = mod(sum_minus - pow2minus[i], mod_minus);
			long long a = 1;
			while (k > 0) {
				a++;
				k = k % popcount(k);
			}
			ans[i] = a;
		}
	}
	for (int i = n-1; i >= 0; i--) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int p = 0;
	if(a == b){
		p++;
    }
	if(b == c){
		p++;
    }
	if(c == a){
		p++;
    }
	if(p == 1){
		cout << "Yes";
    } else {
		cout << "No";
    }
}

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

typedef long long ll;

#define MOD 1000000007LL

ll n, m;
ll t[100002];

int main(){
  while(cin >> n >> m){
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }
    sort(t, t + n);

    ll ans = 1;

    for(int i = 0; i < n; i++){
      int pos = lower_bound(t, t + n, t[i] - m) - t;
      ans *= (ll)(i - pos + 1);
      ans %= MOD;
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1956
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int counter = 0;
		try (Scanner sc = new Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			for(int i = a; i <= b; i++) {
				if(c % i == 0) {
					counter++;
				}
			}
			System.out.println(counter);

		}
	}
}



Measured memory_bytes: 26220
s = input()
t = input()

dp = [[0 for i in range(len(s)+1)] for j in range(len(t)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dp[j+1][i+1] = dp[j][i] + 1
        else:
            dp[j+1][i+1] = max(dp[j][i+1],dp[j+1][i])
 
i = len(s)
j = len(t)

ans = ''

while i > 0 and j > 0:
    if dp[j][i] == dp[j][i-1]:
        i -= 1
    elif dp[j][i] == dp[j-1][i]:
        j -= 1
    else:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])



Measured memory_bytes: 153168
#include<bits/stdc++.h>
#define loop(n,i) for(register int i=1;i<=(n);++i)
#define zxc(x) cerr<<(#x)<<'='<<(x)<<'\n' 
#define zxcv(x) cerr<<(#x)<<'='<<(x)<<',' 
#define zcx zxc
#define MAX 200009
#define int long long
#define P 1000000007
using namespace std;
inline int icin(){
	char c=getchar();int s=0;bool sign=0;
	while(!isdigit(c)&&c^'-')c=getchar();
	if(c=='-')c=getchar(),sign=1;
	while(isdigit(c))s=(s<<1)+(s<<3)+c-'0',c=getchar();
	return sign?-s:s;
}
int n,m;
int a[18];
int f[18][1<<17|233];
int fact[1<<17|233],ifact[1<<17|233];
inline int Quick(int a,int m){int ans=1;for(;m;m>>=1,a=a*a%P) if(m&1) ans=ans*a%P;return ans;}
inline void prefact(int n){
	fact[0]=1;for(register int i=1;i<=n;++i) fact[i]=fact[i-1]*i%P;
	ifact[n]=Quick(fact[n],P-2); for(register int i=n;i;--i) ifact[i-1]=ifact[i]*i%P;
}
inline int binom(int n,int m){return n<m?0:fact[n]*ifact[m]%P*ifact[n-m]%P;}
main(){
	n=icin(),m=icin();
	prefact(1<<n);
	loop(m,i) a[i]=icin();
	sort(a+1,a+m+1);
	f[m+1][0]=1;
	for(register int i=m;i>=1;--i){
		for(register int S=0;S<1<<n;++S){
			(f[i][S]+=f[i+1][S])%=P;
			for(register int j=0;j<n;++j){
				if(~S>>j&1){
					(f[i][S|1<<j]+=f[i+1][S]*binom((1<<n)-S-a[i],(1<<j)-1)%P*fact[1<<j]%P)%=P;
				}
			}
		}
	}
	int ans=0;
	for(register int S=0;S<1<<n;++S){
		(ans+=(__builtin_popcount(S)&1?P-1:1)*f[1][S]%P*fact[(1<<n)-1-S])%=P;
	}
	cout<<ans*(1<<n)%P;
}

Measured memory_bytes: 19712
#include <stdio.h>
int mintwo(int kouyaku1,int kouyaku2);
int minthree(int kouyaku1,int kouyaku2,int kouyaku3);
void kouyakutwo();
void kouyakuthree();

int main(void){
    int n=0;
    
    scanf("%d",&n);
    if(n==2){
        kouyakutwo();
    }else{
        kouyakuthree();
    }

}

void kouyakutwo(){
    int kouyaku1=0,kouyaku2=0,i=1;
    int minvalue;
    scanf("%d %d",&kouyaku1,&kouyaku2);//数値を入力

    minvalue=mintwo(kouyaku1,kouyaku2);

    while(i <= minvalue)
    {
        if(kouyaku1%i==0&&kouyaku2%i==0)
        {
            printf("%d\n",i); // 改行を入れる
        }
        i=i+1;
    }
    
}

void kouyakuthree(){
    int kouyaku1=0,kouyaku2=0,kouyaku3=0;
    int i=1;
    int minvalue;

    scanf("%d %d %d",&kouyaku1,&kouyaku2,&kouyaku3);

    minvalue=minthree(kouyaku1,kouyaku2,kouyaku3);

    while(i <= minvalue)
    {
        if(kouyaku1%i==0&&kouyaku2%i==0&&kouyaku3%i==0)
        {
            printf("%d\n",i);
        }
        i=i+1;
    }
    
}

int mintwo(int kouyaku1,int kouyaku2){
    int minvalu;

    if(kouyaku1<kouyaku2){
        minvalu=kouyaku1;
    }else{
        minvalu=kouyaku2;
    }

    return minvalu;

}

int minthree(int kouyaku1,int kouyaku2,int kouyaku3){
    int minvalu;
    minvalu=kouyaku1;
    if(minvalu>kouyaku2){
        minvalu=kouyaku2;
    }
    if(minvalu>kouyaku3){
        minvalu=kouyaku3;
    }

    return minvalu;
}


Measured memory_bytes: 2104
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <type_traits>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std;
using namespace placeholders;

using LL = long long;
using ULL = unsigned long long;
using VI = vector< int >;
using VVI = vector< vector< int > >;
using VS = vector< string >;
using ISS = istringstream;
using OSS = ostringstream;
using PII = pair< int, int >;
using VPII = vector< pair< int, int > >;
template < typename T = int > using VT = vector< T >;
template < typename T = int > using VVT = vector< vector< T > >;
template < typename T = int > using LIM = numeric_limits< T >;

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define NUMBERED( name, number ) NUMBERED2( name, number )
#define NUMBERED2( name, number ) name ## _ ## number
#define REP1( n ) REP2( NUMBERED( REP_COUNTER, __LINE__ ), n )
#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2, REP1 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &&e : c )
#define ALL( c ) begin( c ), end( c )
#define AALL( a ) ( remove_all_extents< decltype( a ) >::type * )a, ( remove_all_extents< decltype( a ) >::type * )a + sizeof( a ) / sizeof( remove_all_extents< decltype( a ) >::type )
#define DRANGE( c, p ) begin( c ), begin( c ) + ( p ), end( c )

#define SZ( v ) ( (int)( v ).size() )
#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

template < typename T > inline bool chmin( T &a, const T &b ){ if ( b < a ) { a = b; return true; } return false; }
template < typename T > inline bool chmax( T &a, const T &b ){ if ( a < b ) { a = b; return true; } return false; }

#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int solve( const int K, const int N, const int S )
{
	if ( K == 0 )
	{
		return ( N == 0 || N == 1 ) && S == 0;
	}

	return solve( K - 1, N - 1, S - K ) + solve( K - 1, N, S );
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );
	cout << setprecision( 12 ) << fixed;

	for ( int N, S; cin >> N >> S, ( N || S ); )
	{
		cout << solve( 9, N, S ) << endl;
	}

	return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
ll dp0[366][366],dp1[366][366];
int main()
{
    int N,V,P;
    ll M;
    cin >> N >> M >> V >> P;
    vector<ll>A(N);
    rep(i,N)cin >> A[i];
    sort(A.begin(),A.end());
    int l=-1,r=N;
    while(r-l>1){
        int mid=(l+r)/2;
        int res=V-mid-1;
        bool ok =true;
        for(int i=mid+1;i<N-P+1;i++){
            ok&=(A[mid]+M>=A[i]);
        }
        if(!ok){l=mid;continue;}
        ll sum = (res-P+1)*M;
        for(int i=mid+1;i<N-P+1;i++){
            sum-=min(M,A[mid]+M-A[i]);
        }
        if(sum>0){l=mid;}
        else{r=mid;}
    }
    cout << N-l-1 << endl;
    return 0;
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
  string s;
  cin >> s;

  if(s.size() == 2){
  }else{
    reverse(all(s));
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    int n, m;
    n = sc.nextInt();
    m = sc.nextInt();

    int x, y, l, r;
    l = 0;
    r = (int)1E5 + 10;

    for (int i = 0; i < m; i++) {
      x = sc.nextInt();
      y = sc.nextInt();
      l = Math.max(x, l);
      r = Math.min(y, r);
    }

    System.out.println(l <= r ? r - l + 1 : 0);
  }
}


Measured memory_bytes: 62984
manhattan_distance = lambda x1, y1, x2, y2 : abs(x1-x2)+abs(y1-y2)

def solve():
    N = int(input())
    t_pre = 0
    x_pre = 0
    y_pre = 0
    for _ in range(N):
        t, x, y = map(int, input().split())
        # print(manhattan_distance(x, y, x_pre, y_pre), t - t_pre)
        reach = (t - t_pre) - manhattan_distance(x, y, x_pre, y_pre)
        if not ( reach >= 0 and reach%2 == 0):
            print('No')
            return
        
    print('Yes')
    
solve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    ll k=n/500;
    ans=ans+k*1000;
    n=n-k*500;
    k=n/5;
    ans=ans+k*5;
    cout<<ans<<endl;
    return 0;
    

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int K = 0;
    int N = 0;
    int max = 0;

    scanf("%d %d", &K, &N);

    int A[N];
    int distance[N];

    for (int i = 0; i < N; i++){
        scanf("%d", &A[i]);

        if (i > 0){
            distance[i] = A[i] - A[i - 1];
        }
        if (distance[i] > max){
            max = distance[i];
        }
        //printf("max:%d\n", max);
    }
    distance[0] = (K - A[N - 1]) + A[0];

    if (distance[0] > max){
        max = distance[0];
    }
    max = K - max;

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

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
int n;
ll s[1<<18];
vector<ll> v[2];
multiset<ll> st;
int main()
{
	bool ans=true;
	cin>>n;
	for(int i=0;i<(1<<n);i++)
	{
		cin>>s[i];
		st.insert(s[i]);
	}
	sort(s,s+(1<<n));
	reverse(s,s+(1<<n));
	//最初は最大で固定
	v[0].push_back(s[0]);
	st.erase(st.find(s[0]));
	int cnt=0;
	while(st.size()>0)
	{
		cnt++;
		//cerr<<"loop"<<cnt<<endl;
		v[cnt&1].clear();
		for(int i=0;i<v[(cnt+1)&1].size();i++)
		{
			v[cnt&1].push_back(v[(cnt+1)&1][i]);
			//上回らない最大の数を探す
			auto itr=st.lower_bound(v[(cnt+1)&1][i]);
			if(itr==st.begin())
			{
				ans=false;
				break;
			}
			itr--;
			//cerr<<(*itr)<<endl;
			v[cnt&1].push_back(*itr);
			st.erase(itr);
		}
		if(!ans)
			break;
		sort(v[cnt&1].begin(),v[cnt&1].end());
		reverse(v[cnt&1].begin(),v[cnt&1].end());
	}
	//最後に残ったものを順番に割付
	// sort(v[cnt&1].begin(),v[cnt&1].end());
	// auto itr=st.begin();
	// for(int i=0;i<v[cnt&1].size();i++)
	// {
	// 	if((*itr)>=v[cnt&1][i])
	// 	{
	// 		ans=false;
	// 		break;
	// 	}
	// 	itr++;
	// }
	if(ans)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

int count(string a, string b){
    int count = 0;
    for(int i = 0; i < a.size(); ++i){
        if(a[i]!=b[i]) count++;
    }
    return count;
}

int main(){
    string a,b;
    cin >> a >> b;
    cout << count(a,b);
    return 0;
}

Measured memory_bytes: 4052
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  if (a == 7 && b == 5 && c == 5) cout << "YES" << endl;
  else if (a == 5 && b == 7 && c == 5) cout << "YES" << endl;
  else if (a == 5 && b == 5 && c == 7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 500010;

typedef pair<pi,int> pii;
const int len = 900;

int n,q;
int A[maxn];
int co[maxn];
int rans = 0;

struct query {
	int l,r,index,ans;
	void read(int _l, int _r, int _index) {
		l = _l; 
		r = _r;
		index = _index;
		ans = 0;
	}
};

vector <query> queries;


bool cmp(const query &a, query &b) {
	int buc1 = a.l/len, buc2 = b.l/len;
	if (buc1 == buc2) return a.r < b.r;
	else return buc1 < buc2;
}

bool cmpind(const query &a, const query &b) {
	return a.index < b.index;
}

void add(int x) {
	co[A[x]]++;
	if (co[A[x]] == 1) rans++;
}

void rem(int x) {
	co[A[x]]--;
	if (co[A[x]] == 0) rans--;
}

int32_t main() {
	FAST
	cin >> n >> q;
	for (int i =0;i<n;i++) cin >> A[i];
	for (int i =0;i<q;i++) {
		int l,r; cin >> l >> r;
		queries.push_back(query());
		queries[i].read(--l,--r,i);
	}
	
	sort(queries.begin(),queries.end(),cmp);

	//cout << "HELLO\n";
	//for (auto i: queries) {
		//cout << i.l << " " << i.r << "\n";
	//}

	int ql = 1, qr = 0;
	for (int i =0;i<q;i++) {
		int l = queries[i].l, r = queries[i].r;
		while (ql > l) add(--ql);
		while (ql < l) rem(ql++);
		while (qr < r) add(++qr);
		while (qr > r) rem(qr--);
			
		queries[i].ans = rans;
	}
	
	sort(queries.begin(),queries.end(),cmpind);
	for (int i =0;i<q;i++) {
		cout << queries[i].ans << "\n";
	}
}




Measured memory_bytes: 27408
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb emplace_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
int a[20][20];
int dp[(1ll<<20)];
bool used[(1ll<<20)];

int solve(int S){
    if(used[S])return dp[S];
    used[S]=true;
    int tmp=0;
    rep(i,0,N)rep(j,i+1,N)if((S&(1<<i))&&(S&(1<<j)))tmp+=a[i][j];
    rep(T,0,S)if((T|S)==S){
        chmax(tmp,solve(T)+solve(S^T));
    }
    return dp[S]=tmp;
}
 
signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N;
    rep(i,0,N)rep(j,0,N)cin>>a[i][j];
    cout<<solve((1ll<<N)-1)<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 896