akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b,c,d,e,f;
    cin >> a >> b>>c>>d>>e>>f;
    ll all = 0;
    ll sugar = 0;
    ld concent = -1;
    rp(w1,31) rp(w2,31){
      if(w1 == w2 && w2 == 0) continue;
      rp(s1,d+5){
        ll uB = (f-100*a*w1-100*b*w2-c*s1)/d;
        ll desiredVal = (e*(a*w1+b*w2)-c*s1)/d;
        ll s2 = min(uB,desiredVal);
        if(s2 < 0) continue;
        if(concent*(a*w1+b*w2) < (c*s1 + d*s2) && (100*a*w1+100*b*w2+c*s1+d*s2) <= f && e*(a*w1+b*w2)>=(c*s1+d*s2) ){
          concent = (c*s1 + d*s2);
          concent /= (a*w1+b*w2);
          all = 100*a*w1+100*b*w2+c*s1+d*s2;
          sugar = c*s1+d*s2;
        }
      }
    }
    cout << all << " "<<sugar<<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <set>

std::set< int > s;
std::string     str, res;
bool flag = true;

int main() {
    std::cin >> str;
    for (int i=0; i<str.size(); ++i) {
        if (s.find(str[i]) == s.end()) {
            s.insert(str[i]);
        } else {
            flag = false;
        }
    }
    res = (flag) ? "yes" : "no";
    std::cout << res << std::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 = sc.nextInt();
		int p[] = new int[N];
		int sum = 0;
		int max = 0;
		for(int i = 0; i < N; i++) {
			p[i] = sc.nextInt();
			sum += p[i];
			max = Math.max(max, p[i]);
		}
		
		System.out.println(sum - max / 2);
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;

int A[100010];

int ans(int j, int count){
	if(j == 1) return count;
	if(count > 100010) return -1;
	ans(A[j], count+1);
}

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

	int N;
	cin >> N;
	rep(i,N){
		cin >> A[i];
		--A[i];
	}
	cout << ans(0, 0) << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<queue>
#include<utility>
#include<algorithm>
#include<cctype>
using namespace std;

int main(){
	int n;

	cin>>n;
	if(n%2==0){
	cout<<n<<endl;
	}else cout<<2*n<<endl;

	
	return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	char c; cin >> c;
	cout << (isupper(c)?'A':'a') << endl;

}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

#define INF 1e9

int main(void){
  while(true){
    int n, m;
    cin >> n >> m;
    if(n == 0 && m == 0){ break; }

    vector<int> s(n);
    vector<int> d(m);
    for(int i = 0; i < n; i++){ cin >> s[i]; }
    for(int i = 0; i < m; i++){ cin >> d[i]; }
    sort(d.begin(), d.end());
    
    vector<int> sum_s(1 << n, 0);
    for(int i = 0; i < (1 << n); i++)
      for(int j = 0; j < n; j++)
        if((i & (1 << j)) != 0)
          sum_s[i] += s[j];

    
    vector<vector<int> > dp(m, vector<int>(1 << n, INF));
    for(int i = 0; i < (1 << n); i++)
      dp[0][i] = abs(d[0] - sum_s[i]);
    
    for(int i = 1; i < m; i++){
      for(int j = 0; j < (1 << n); j++){
        dp[i][j] = dp[i - 1][j] + abs(d[i] - sum_s[j]);
        for(int k = 0; k < n; k++){
          if((j & (1 << k)) == 0){ continue; }
          int before = j & (~(1 << k));
          dp[i][j] = min(dp[i][j], dp[i][before] - abs(d[i] - sum_s[before]) + abs(d[i] - sum_s[j]));
        }
      }
    }
            
    int ans = INF;
    for(int i = 0; i < (1 << n); i++)
      ans = min(ans, dp[m - 1][i]);
    cout << ans << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 16264
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define vvi vector<vi >
#define str string
#define vs vector<str>
#define vb vector<bool>
#define slli set<lli>
#define mii map<int, int>
#define mlli map<int, lli>
#define msi map<str, int>
#define mp make_pair
#define pii pair<int, int>
#define pll pair<lli, lli>
#define vpii vector<pii >
#define vpll vector<pll >
#define pb push_back
#define loop(i, s, l, j) for(int i = s; i < l; i += j)
#define rloop(i, s, l, j) for(int i = s; i >= l; i -= j)
#define rep(i, n) loop(i,0,n,1)
#define rrep(i, n) rloop(i,n-1,0,1) 
#define fastio() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ft first
#define sd second   
#define mit mii::iterator
#define vit vi::iterator
#define all(a) a.begin(),a.end()
#define min3(a, b, c) min(a, min(b, c))
#define mod 998244353
#define inf 1000000000
#define limit 200005
/**********************************************************************************************************************************************/
int dx4[4] = {0, -1, 0, 1};
int dy4[4] = {1, 0, -1, 0};
int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int Power(int base,int exp){int ans=1;  while(exp > 0){if(exp&1)ans=(1LL*ans*base)%mod; exp=exp>>1; base=(1LL*base*base)%mod;}  return ans;}
/**********************************************************************************************************************************************/ 
void input()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	lli dp[c+1][d+1];
	rep(i,c+1)
		rep(j,d+1)
			dp[i][j] = 1;

	loop(i,a+1,c+1,1)
		dp[i][b] = (dp[i-1][b] * b)%mod;
	loop(j,b+1,d+1,1)
		dp[a][j] = (dp[a][j-1] * a)%mod;

	loop(i,a+1,c+1,1)
		loop(j,b+1,d+1,1)
		{
			lli ans0 = ((dp[i][j-1] * i)%mod + (dp[i-1][j] * j)%mod)%mod;
			lli ans1 = (dp[i-1][j-1] * (i-1) * (j-1))%mod;
			dp[i][j] = (ans0 + (mod - ans1))%mod;
		}
	cout << dp[c][d] << '\n';
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
 
    fastio();
    int q = 1;
    //cin >> q;
    while(q--)
        input();
}

Measured memory_bytes: 73780
#  =========     /\       /|    |====/|
#      |        /  \       |    |   / |
#      |       /____\      |    |  /  |
#      |      /      \     |    | /   |
#  ========= /        \  =====  |/====|  
#  code

def main():
    n , k = map(int , input().split())
    print(min(k - n % k , n % k))
    return

if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

vector <ll> ans;

int DFS(ll num, int dig){
  ans.push_back(num);
  if (dig == 12) return 0;

  ll now = num % 10;
  if (now > 0){
    DFS(num * 10 + now - 1, dig + 1);
  }
  DFS(num * 10 + now, dig + 1);
  if (now < 9){
    DFS(num * 10 + now + 1, dig + 1);
  }
  return 0;
}

int main(){
  ans.push_back(0);
  for (ll i = 1; i < 10; i++) DFS(i, 1);
  sort(ans.begin(), ans.end());

  int K; cin >> K;
  cout << ans[K] << endl;

  return 0;
}


Measured memory_bytes: 18792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int N; cin >> N;
  vector<int> P(N), Q(N);
  rep(i,N) cin >> P[i];
  rep(i,N) cin >> Q[i];

  vector<int> v(N);
  rep(i,N) v[i] = i+1;

  int index = 0;
  int p_i, q_i;
  do {
    if(v==P) p_i = index;
    if(v==Q) q_i = index;
    ++index;
  } while(next_permutation(ALL(v)));

  cout << abs(p_i - q_i) << endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int h,w,k; cin>>h>>w>>k;
  vector c(h,vector(w,'.'));
  int b{};
  for(auto &i:c){
    for(auto &j:i) {
      cin>>j;
      b += (j=='#');
    }
  }
  int ans{};
  for(int i=0; i<(1<<h); i++){
    for(int j=0; j<(1<<w); j++){
      int cnt{};
      auto c1 = c;
      for(int y=0; y<h; y++){
        if(i&(1<<y)){
          for(int l=0; l<w; l++){
            if(c1.at(y).at(l)=='#'){
              c1.at(y).at(l)='.';
              cnt++;
            }
          }
          
        }
      }
      for(int x=0; x<w; x++){
        if(j&(1<<x)){
          for(int l=0; l<h; l++){
            if(c1.at(l).at(x)=='#'){
              c1.at(l).at(x)='.';
              cnt++;
            }
          }
          
        }
      }
      if(b-cnt==k) {
        ans++;
      }
    }
  }
  cout << ans << endl;
  
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(){
    long long int a, b, k;
    scanf("%lld %lld %lld", &a, &b, &k);
    long long int x, y = b;
    x = a-k;
    if(x >= 0){
        k = 0;
    }else{
        k = -1 * x;
        x = 0;
    }
    y -= k;
    if(y < 0){
        y = 0;
    }
    printf("%lld %lld", x, y);

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n, t, a;
    cin >> n >> t >> a;
    vector<double> v;
    for (int i = 0; i < n; ++i) {
        double k;
        cin >> k;
        k = t - k * 0.006;
        v.push_back(abs(a - k));
    }
    cout << min_element(v.begin(), v.end()) - v.begin() + 1;
    return 0;
}

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

int32_t main(){
	ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> vs(n);
	for(auto &x:vs) 
		cin >> x;
	bool can = true;
	for(auto x:vs){
		if(x%2==1) continue;
		if(x%3!=0 and x%5!=0) can = false;
	}
	if(can)
		cout << "APPROVED" << endl;
	else
		cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;
int n,A[maxn],B[maxn],p = INT_MAX,flg = 0;
long long sum = 0;
inline int read(void)
{
	int x = 0,f = 1; char ch = getchar();
	while(!isdigit(ch)){f = ch == '-' ? -1 : 1; ch = getchar();}
	while(isdigit(ch)){x = (x << 3) + (x << 1) + ch - '0'; ch = getchar();}
	return x * f;
}
int main(int argc, char *argv[])
{
	n = read();
	for (int i = 1; i <= n; i++)
	A[i] = read(),B[i] = read(),p = (A[i] > B[i] && p > B[i]) ? B[i] : p,sum += A[i];
	sum -= p;
	for (int i = 1; i <= n; i++)
	if (A[i] != B[i]) {flg = 1; break;}
	if (!flg) puts("0");
	else printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int n, m, p;
int ans = 1000000000;
int d[10000];

int main(){
	scanf("%d%d%d",&n,&m,&p);
	for(int i = 0; i < m; i++){
		scanf("%d",d+i);
		d[i] = (d[i]-p+n)%n;
	}
	sort(d,d+m);
	for(int i = 0; i < m; i++){
		if(i == 0){
			ans = min(ans,n-d[i]);
		} else{
			ans = min(ans,2*(n-d[i])+d[i-1]);
		}
		if(i == m-1){
			ans = min(ans,d[i]);
		} else{
			ans = min(ans,2*d[i]+n-d[i+1]);
		}
	}
	printf("%d\n",ans*100);
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9;
using namespace std;
using ll = long long;
int main() {
    int x , y;
    cin >> x >> y;
    int t = abs(abs(x)-abs(y));
    if((x > 0 && y < 0) || (x < 0 && y > 0)){
        t++;
    }
    else if((x == 0 || y == 0) && y < x){
        t++;
    }
    else if (y < x){
        t+=2;
    }
    cout << t << endl; 
    return 0;
}

Measured memory_bytes: 3612
k = int(input())
a = [int(i) for i in input().split()]
a,flag = a[::-1],True
if a[0]!=2: flag = False
else:
	x,y = 2,3
	for i in range(1,k):
		x2 = x-x%a[i]+min(x%a[i],1)*a[i]
		if x2>y:
			flag = False
			break
		else: x,y = x2,y-y%a[i]+a[i]-1
if flag: print(x,y)
else: print(-1)

Measured memory_bytes: 14252
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    auto dp = new long[](N);
    fill(dp, 1L << 59);
    dp[0] = 0;
    dp[1] = abs(A[1] - A[0]);

    foreach (i; 2..N) {
        dp[i] = min(dp[i-2] + abs(A[i] - A[i-2]), dp[i-1] + abs(A[i] - A[i-1]));
    }

    dp[N-1].writeln;
}


Measured memory_bytes: 4252
import java.util.Scanner;

public class Main {

	static boolean[] primes;

	static void primeSet(final int MAX){
		primes = new boolean[MAX+1];

		primes[2] = true;
		for(int i=3;i<=MAX;i+=2){
			primes[i] = true;
		}
		int rt = (int) Math.sqrt(MAX);
		for(int i=3;i<=rt;i+=2){
			if(primes[i]){
				for(int j=i*2;j<=MAX;j+=i){
					primes[j] = false;
				}
			}
		}
	}

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(stdIn.hasNext()){
			int n = stdIn.nextInt();
			int cnt = 0;
			
			if(n<2){
				System.out.println("0");
				continue;
			}

			primeSet(n);
			for(int i=0;i<=n;i++){
				if(primes[i]){
					cnt++;
				}
			}
			System.out.println(cnt);
		}	
	}
}

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

int main() {
    
    int a;
    int b;
    int sum;
    int flag = 0;
    int count = 0;
    
    while(cin >> a >> b) {
        sum = a + b;
        while (!flag) {
            sum = sum / 10;
            count++;
            if(sum < 1) {
                flag = 1;
                cout << count << endl;
            }
        }
        flag = 0;
        count = 0;
    }
    return 0;
}

Measured memory_bytes: 1160
N = int(input())
nums = []
for i in range(N):
    nums.append(int(input()))

maxinum = max(nums)
maxinum2 = -1
for i in range(N):
    if nums[i] == maxinum:
        if maxinum2 == -1:
            maxinum2 = max(nums[0:i] + nums[i+1:])
        print(maxinum2)
    else:
        print(maxinum)

Measured memory_bytes: 15604
#C - HonestOrUnkind2
N = int(input())
A = []
X = []
Y = []
for _ in range(N):
    a = int(input())
    A.append(a)
    box_x = []
    box_y = []
    for _ in range(a):
        x,y = map(int,input().split())
        box_x.append(x)
        box_y.append(y)
    X.append(box_x)
    Y.append(box_y)

person = [2]*N

maxim = 0
for i in range(1<<N):
    c_person = person.copy()
    honest = 0
    for j in range(N):
        mask = 1<<j
        if mask&i != 0:
            c_person[j] = 1
        else:
            c_person[j] = 0
    #正直者かどうかの仮定
    for k,l in enumerate(c_person):
        #kが正直者のとき
        if l == 1:
            #kの証言を判定
            for m,n in zip(X[k],Y[k]):
                #矛盾があるなら honest = 0でbreak
                if c_person[m-1] != n:
                    honest = 0
                    break
            else:
                honest = sum(c_person)
                continue
            break
    maxim = max(maxim,honest)
                
print(maxim)     

Measured memory_bytes: 9168
(let* ((a (read))
       (b (read))
       (zp (or (and (minusp a) (plusp b))
               (zerop a)
               (zerop b)))
       (nm (if (minusp a)
               (if (minusp b)
                   (abs (- b a))
                   (abs a))
               0)))
  (format t "~A~%"
    (cond
      (zp "Zero")
      ((or (zerop nm)
           (and (minusp a) (oddp nm))
           (and (plusp a) (evenp nm)))
       "Positive")
      ((or (and (minusp a) (evenp nm))
           (and (plusp a) (oddp nm))) "Negative"))))

Measured memory_bytes: 13412
#include <cstdio>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=0;i<=n;i++)
	{
		if ((int)(i*1.08)==n)
		{
			printf("%d\n",i);
			return 0;
		}
	}
	printf(":(\n");
	return 0;
}

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

#define MOD 1000000007
typedef unsigned long long ull;

int main() {
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") {
        cout << "No";
    } else {
        cout << "Yes";
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i = 0;i < N;i++){
    cin >> vec[i];
  }
  int max =  *max_element(vec.begin(),vec.end());
  for(int i = 0;i < N;i++){
    vec[i] *= 2;
  }
  *max_element(vec.begin(),vec.end()) += 1;
  for(int i = 0;i < N;i++){
    vec[i] -= max;
  }
  int min = 1 << 30;
  for(int i = 0;i < N;i++){		    
    if(abs(min)> abs(vec[i]))	  min = vec[i];
  }
  cout << max << " " << (min + max) / 2 << endl;
  return 0;
}


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

using namespace std;

int main() {
 int a[200005]={},x,n;
 cin>>n;
 for(int i=2;i<=n;i++){
    cin>>x;
    a[x]++;
 }
 for(int i=1;i<=n;i++){
    cout<<a[i]<<" ";
 }
 return  0;
}


Measured memory_bytes: 4404
def main():
    n = int(input())
    strings = list(input())

    # pins = set()
    ans = 0
    for i in range(1000):
        flag = True
        temp_strings = strings[:]
        for j in range(3):
            i_str = '{:03d}'.format(i)
            number = str(list(i_str)[j])
            if number in temp_strings:
                idx = temp_strings.index(number)
                temp_strings = temp_strings[idx+1:]
            else:
                flag = False
        if flag:
            # print(i_str)
            ans += 1
        else:
            continue

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 133996
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 1e9+10;

int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0)
    {
		cout<<"Zero"<<nl;
	}
	else if(a>0)
	{
		cout<<"Positive"<<nl;
	}
	else
	{
		if(a==b)
		{
			cout<<"Positive"<<nl;
		}
		else if(abs(a-b)%2==0)
		{
			cout<<"Negative"<<nl;
		}
		else
		{
			cout<<"Positive"<<nl;
		}
	}
    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
// printf("%.10f\n" , ans);
 ll n, m;
 cin >> n >> m;
 vector<pair<ll, ll>> p(n);
 REP(i, n){
   ll a, b;
   cin >> a >> b;
   p[i].first = a;
   p[i].second = b;
 }
 sort(p.begin(), p.end());
 ll ans = 0;
 ll now = 0;
 while (now < m){
   for (auto v : p){
     ll val = v.second;
     val = min(m-now, val);
     ans += val * v.first;
     now += val;
   }
 }
 cout << ans << endl;
  return 0;
  return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
#include<cmath>
#define ll long long
#define MOD 924844033
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
int n,k;
ll dp[4010][2010][2],border[4010],f[2010],fac[2010];
int main(){
	n=read();k=read();int i,j,re=n%k;ll tmp=0,ans=0;
	fac[0]=fac[1]=1;
	for(i=2;i<=n;i++) fac[i]=fac[i-1]*i%MOD;
	for(i=1;i<=re;i++){
		tmp+=(n/k+1);border[tmp]=1;
		tmp+=(n/k+1);border[tmp]=1;
	}
	for(i=re+1;i<=k;i++){
		tmp+=n/k;border[tmp]=1;
		tmp+=n/k;border[tmp]=1;
	}
	dp[1][0][0]=1;
	for(i=2;i<=(n<<1);i++){
		for(j=0;j<=n;j++){
			dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%MOD;
			if(!border[i-1]) dp[i][j][1]=dp[i-1][j-1][0];
		}
	}
	for(i=0;i<=n;i++) f[i]=(dp[n<<1][i][0]+dp[n<<1][i][1])%MOD;
	tmp=1;
	for(i=0;i<=n;i++){
		ans+=tmp*f[i]*fac[n-i]%MOD;ans=(ans+MOD)%MOD;
		tmp=-tmp;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 125952
#include <iostream>

using namespace std;

int main(void)
{
	int n = 0;
	
	while(cin >> n){
		int cnt = 0;
		
		for(int i = 0; i <= 9; i++){
			for(int j = 0; j <= 9; j++){
				for(int k = 0; k <= 9; k++){
					for(int l = 0; l <= 9; l++){
						if(i + j + k + l == n){
							cnt++;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
R,G,B = map(int,input().split())
K = int(input())
ans = 'No'

while (K > 0):
  if R >= G:
    G *= 2
    K -= 1
  elif G >= B:
    B *= 2
    K -= 1
  else:
    K -= 1
      
if R < G < B:
  ans = 'Yes'
  
print(ans)

Measured memory_bytes: 8996
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define MAX 100010
#define aout(a) REP(i,sizeof(a)) cout << a[i] << " "; cout << endl;
#define vout(v) REP(i,v,size()) cout << v[i] << " "; cout << endl;
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(){
  ll X,K,D;
  cin>>X>>K>>D;
  ll ans;
  X = abs(X);
  ll a = X / D;
  ll b = X % D;
  K -= a;
  ans = b;
  if(K < 0){
    ans = b + abs(K) * D;
    cout<<ans;
    return 0;
  }
  if(K%2 == 0) ans = b;
  else ans = abs(D-b);
  cout<<ans;
}

Measured memory_bytes: 3592
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

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

n = 1
ans = 0
for i in A:
    if i == n:
        n += 1
    else:
        ans += 1
if n == 1:
    print(-1)
else:
    print(ans)


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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    long long A[100][100], B[100][100], C[100][100];

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < m; ++j){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; ++i){
        for(int j = 0; j < l; ++j){
            cin >> B[i][j];
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            C[i][j] = 0;
            for(int k = 0; k < m; ++k){
                C[i][j] += A[i][k] * B[k][j];
            }
        }
    }

    for(int i = 0; i < n; ++i){
        for(int j = 0; j < l; ++j){
            if(j != 0){
                cout << " " << flush;
            }
            cout << C[i][j] << flush;
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3320
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;


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

	ll N, Q;
	cin >> N >> Q;

	string S;
	cin >> S;

	vector<P> lr(Q);
	for (ll i = 0; i < Q; ++i)
	{
		ll l, r;
		cin >> l >> r;
		lr[i].first = l-1;
		lr[i].second = r-1;
	}

	vector<ll> v(N, 0);

	for (ll i = 1; i < (ll)S.size(); ++i)
	{
		v[i] = v[i - 1];
		if (S[i - 1] == 'A' && S[i] == 'C')
		{
			v[i]++;
		}
	}

	for (const auto& q : lr)
	{
		cout << v[q.second] - v[q.first] << endl;
	}

	//system("pause");
}


Measured memory_bytes: 3408
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n; ll mx=0,sum=0;
  for(int i=0; i<n; i++){
    ll x; cin >>x;
    mx=max(mx,x);
    sum+=mx-x;
  }
  cout <<sum;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  solve();
return 0;}

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

int main()
{

	int n;
	cin>>n;

	int k;
	cin>>k;
	int arr[10]={0},a;

	for(int i=0;i<k;i++)
	{
		cin>>a;
		arr[a]=1;
	}

	for(int i=n; ;i++)
	{
		int flag=0,
		num=i;
		while(num)
		{
			if(arr[num%10]==1)
				{
					flag=1; break;
				}
			num=num/10;
		}
		if(flag==0)
		{
			cout<<i;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int F[45];

void fibonacci(int n){
  int i;
  F[0]=1;
  F[1]=1;
  for(i=2;i<=n;i++){
    F[i]=F[i-2]+F[i-1];
  }
}

int main(){
  int n;

  scanf("%d",&n);
  fibonacci(n);
  printf("%d\n", F[n]);
  return 0;
}

Measured memory_bytes: 596
<?php

 list($n) = explode(" ", trim(fgets(STDIN)));
 $p = str_replace(" ", "", trim(fgets(STDIN)));
 $q = str_replace(" ", "", trim(fgets(STDIN)));

 $all = permutationAll(1, $n);
 sort($all);
   
 $p_c = array_search($p, $all);
 $q_c = array_search($q, $all);

 echo abs($p_c - $q_c);

 function permutationAll($start, $end)
  {
    if($end < $start){
      return [];
    }
    $n=[];
    for($i=$start;$i<=$end;$i++){
      $n[$i]=true;
    }

    $arr = appendCount($n, "");

    return $arr;
  }

  function appendCount($n, $str){
    if(count($n)===1){
      return [$str.key($n)];
    }
    $arr = [];
    foreach($n as $key => $value){
      unset($n[$key]);
      $childs = appendCount($n, $str.$key);
      foreach($childs as $child){
        $arr[] = $child;
      }
      $n[$key]=true;
    }
    return $arr;
  }

Measured memory_bytes: 8696
s= input()
dic={}
for i in s:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
flag=True
for i in dic:
    if dic[i]!=2:
        flag=False
if flag:
    if len(dic)==2:
        print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n = int(input())
A = list(map(int, input().split()))

mod = 10**9+7
X = [0]*62
for i in range(n):
    a = A[i]
    b = format(a, 'b')
    b = list(b)
    b.reverse()
    for j in range(len(b)):
        if b[j] == '1':
            X[j] += 1
ans = 0
for i in range(62):
    x = X[i]
    y = n-X[i]
    #print(i, x, y)
    ans += x*y*pow(2, i, mod)
ans %= mod
print(ans)


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

int main(){
  double x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  printf("%.8f\n", sqrt(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0)));
}

Measured memory_bytes: 3272
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll a, b, c; cin >> a >> b >> c;
    (b-a == c-b) ? YES() : NO();
}

Measured memory_bytes: 256
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n = sc.nextInt
  val as = List.fill(n)(sc.nextInt)
  val result = execute(as, 1, 0)
  println(if (result < n) result else -1)

  def execute(list: List[Int], next: Int, deleted: Int): Int = list match {
    case _ if list.isEmpty => deleted
    case _ if list.head == next => execute(list.tail, next + 1, deleted)
    case _ => execute(list.tail, next, deleted + 1)
  }
}


Measured memory_bytes: 79340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n, m;
  cin >> n >> m;
  vl p(m);
  vector<string> s(m);
  rep(i, m) {
    cin >> p[i] >> s[i];
  }

  vector<bool> ac(n);
  vector<ll> pena(n);
  rep(i, m) {
    if (s[i] == "AC") {
      ac[p[i]-1] = true;
    } else {
      if (ac[p[i]-1] == false) {
        pena[p[i]-1]++;
      }
    }
  }

  ll ans = 0;
  ll pp = 0;
  rep(i, n) {
    if (ac[i]) {
      ans++;
    }
  }
  rep(i, n) {
    if (ac[i]) {
      pp += pena[i];
    }
  }

  cout << ans << " " << pp << endl;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int>
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0);
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;
int inf=1e18;

struct DSU{
	int connected,par[maxn],sz[maxn];
 
	void init(int n){
		for(int i=1;i<=n;i++){
			par[i]=i;
			sz[i]=1;
		}
		connected=n;
	}
 
	int getPar(int k){
		while(k!=par[k]){
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}
 
	int getSize(int k){
		return sz[getPar(k)];
	}
 
	void unite(int u, int v){
		int par1=getPar(u), par2=getPar(v);
		if(par1==par2) return;
		connected--;
		if(sz[par1]>sz[par2]) swap(par1, par2);
		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
	}
};

int n;
DSU d;

void solve(){
    cin>>n;
    d.init(n);
    int m;cin>>m;
    int mx=1;
    while(m--){
        int x,y;cin>>x>>y;
        d.unite(x,y);
        mx=max({mx,d.getSize(x)});
    }
    cout<<mx;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int sum = 0, m = 0;
	while (sum < N) {
		++ m;
		sum += m;
	}
	sum = N;
	for (int i = m; sum > 0; -- i) {
		int x = min(i, sum);
		cout << x << endl;
		sum -= x;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		long ans = 1000;
		long s = 0;
		a[0] = sc.nextInt();
		for(int i = 1; i < n; i++) {
			a[i] = sc.nextInt();
			if(a[i-1] < a[i]) {
				s = ans/a[i-1];
				ans = ans%a[i-1];
				ans += a[i]*s;
				s = 0;
			}
		}
		System.out.println(ans);
	}
	
	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  ll a, b; cin >> a >> b;
  if((a+b)%2 == 0) cout << (a+b)/2 << endl;
  else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3604
let inputStr = '';

process.stdin.on('data', (input) => { inputStr += input; });

process.stdin.on('end', () => {
  proc(inputStr.split('\n'));
});

const proc = (arr) => {
  const dict = {};

  arr.forEach((row) => {
    const splitted = row.split(' ');
    if (splitted.length !== 2) return;
    const [cmd, val] = splitted;
    if (cmd === 'insert') {
      dict[val] = true;
      return;
    }

    console.log(dict[val] ? 'yes' : 'no');
  });
};


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

int main(){
    int he;
    int wi;
    
    while(1){
        cin >> he >> wi;
    if(he == 0 && wi == 0) break;
        for (int j = 0; j < he; j++){
            for (int i = 0; i < wi; i++){
                cout << "#" ;
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3020
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, X, sum;
	int data[120];
	int s[120];
	cin >> N >> X;
	for (int i = 0; i < N; i++) {
		cin >> data[i];
	}
	s[0] = 0;
	for (int i = 1; i < N + 1; i++) {
		s[i] = s[i-1] + data[i - 1];
	}
	for (int i = 0; i < N + 1; i++) {
		if (s[i] > X) {
			cout << i;
			break;
		}
		if (i == N) {
			cout << N + 1;
		}
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

int read() {
	char ch;
	for(ch=getchar();ch<'0'||ch>'9';ch=getchar());
	int x=ch-'0';
	for(ch=getchar();ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

const int N=2e5+5;

int n,k,p[N],mx[N],mn[N],Mx[N],Mn[N],h1,t1,h2,t2;

void push(int x) {
	while (h1<=t1&&p[mx[t1]]<p[x]) t1--;mx[++t1]=x;
	while (h2<=t2&&p[mn[t2]]>p[x]) t2--;mn[++t2]=x;
}

void pop(int x) {
	while (h1<=t1&&mx[h1]<x-k+1) h1++;
	while (h2<=t2&&mn[h2]<x-k+1) h2++;
}

int main() {
	n=read();k=read();
	fo(i,1,n) p[i]=read();
	h1=h2=1;t1=t2=0;
	fo(i,1,k-1) push(i);
	int ans=0;bool fir=1;
	fo(i,k,n) {
		push(i);pop(i);
		Mx[i]=p[mx[h1]];
		Mn[i]=p[mn[h2]];
		if (i>k&&Mx[i]==p[i]&&Mn[i-1]==p[i-k]) continue;
		if (t2-h2+1==k) {ans+=fir;fir=0;continue;}
		ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include<stdio.h>

int main(void){

int o,n,k,i,j;

int key;
int a[1100];

scanf("%d",&n);

for(i=1;i<=n;i++)
scanf("%d",&a[i]);

for(j=1;j<=n;j++){

key = a[j];
i = j-1;

while(i>0 && a[i]>key){

a[i+1]=a[i];
i = i-1;

}

a[i+1] = key;

for(k=1;k<=n;k++){

if(k == n){
printf("%d\n",a[k]);
}

else{
printf("%d ",a[k]);
}

}

}

return 0;
}

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

class dice {
private:
	int n[7];

public:
	dice(int, int, int, int, int, int);
	int getcur() { return n[1]; }
	int getnum(int i) { return n[i]; }
	void rotate(char);
};

dice::dice(int n1, int n2, int n3, int n4, int n5, int n6) {
	n[1] = n1;
	n[2] = n2;
	n[3] = n3;
	n[4] = n4;
	n[5] = n5;
	n[6] = n6;
}

void dice::rotate(char op) {
	dice copy(n[1], n[2], n[3], n[4], n[5], n[6]);
	switch (op) {
	case'W':
		n[1] = copy.n[3];
		n[3] = copy.n[6];
		n[6] = copy.n[4];
		n[4] = copy.n[1];
		break;
	case'E':
		n[1] = copy.n[4];
		n[3] = copy.n[1];
		n[6] = copy.n[3];
		n[4] = copy.n[6];
		break;
	case'S':
		n[1] = copy.n[5];
		n[2] = copy.n[1];
		n[6] = copy.n[2];
		n[5] = copy.n[6];
		break;
	case'N':
		n[1] = copy.n[2];
		n[2] = copy.n[6];
		n[6] = copy.n[5];
		n[5] = copy.n[1];
		break;
	case'C':
		n[2] = copy.n[3];
		n[3] = copy.n[5];
		n[5] = copy.n[4];
		n[4] = copy.n[2];
		break;
	}
}

int main() {
	int n[7];
	for (int i = 1; i <= 6; i++) {
		cin >> n[i];
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		dice a(n[1], n[2], n[3], n[4], n[5], n[6]);
		//dice copy = a;
		int x, y;
		cin >> x >> y;
		
		if(x == n[1]){}
		else if (x == n[2]) a.rotate('N');
		else if (x == n[3]) a.rotate('W');
		else if (x == n[4]) a.rotate('E');
		else if (x == n[5]) a.rotate('S');
		else if (x == n[6]) {
			a.rotate('N');
			a.rotate('N');
		}

		/*switch (x) {
		case n[1]:
			break;
		case n[2]:
			a.rotate('N');
			break;
		case n[3]:
			a.rotate('W');
			break;
		case n[4]:
			a.rotate('E');
			break;
		case n[5]:
			a.rotate('S');
			break;
		case n[6]:
			a.rotate('N');
			a.rotate('N');
			break;
		}
		*/
		while (a.getnum(2) != y) {
			a.rotate('C');
		}

		cout << a.getnum(3) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
N, u, v = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N - 1)]

u -= 1
v -= 1
G = [set() for _ in range(N)]
for a, b in AB:
    G[a - 1].add(b - 1)
    G[b - 1].add(a - 1)


du = [-1] * N
du[u] = 0
q = set([u])
while q:
    i = q.pop()
    for j in G[i]:
        if du[j] == -1:
            du[j] = du[i] + 1
            q.add(j)

dv = [-1] * N
dv[v] = 0
q = set([v])
while q:
    i = q.pop()
    for j in G[i]:
        if dv[j] == -1:
            dv[j] = dv[i] + 1
            q.add(j)

ans = 0
for i in range(N):
    if du[i] < dv[i]:
        ans = max(ans, dv[i])
ans -= 1

print(ans)


Measured memory_bytes: 64824
/// 15:52 20/09/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)

#include<bits/stdc++.h>

using namespace std;
#define endl '\n'
typedef int ll;

ll getFactors(ll n) {
    ll ans = 0;
    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ans += 2;
            if (i * i == n) {
                ans--;
            }
        }
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i < n; i++) {
        ll d = n - i;
        ans += getFactors(d);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636