akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}


const int mod = 998244353;
struct mint {
    long long x;
    mint(long long 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    auto dp = make_vec<mint>(2, c-a+2, d-b+2);

    dp[0][0][0] = 1;
    rep(i, c-a+1) {
        rep(j, d-b+1) {
            dp[0][i+1][j] += mint(b + j) * dp[0][i][j];
            dp[0][i+1][j] += dp[1][i][j];
            dp[1][i][j+1] += mint(a + i) * dp[0][i][j];
            dp[1][i][j+1] += mint(a + i) * dp[1][i][j];
        }
    }

    mint ans = dp[0][c-a][d-b] + dp[1][c-a][d-b];
    cout << ans << endl;
}


Measured memory_bytes: 214484
import math
import itertools
import functools
import numpy as np



# a, b = map(float, input().split())

# b = int(b * 100)
# a = int(a)

# print(int(a * b / 100))

n = int(input())
v = [int(i) for i in input().split()]
v.sort()

if v[0] == 0:
  print(0)
  exit(0)
ans = 1
for l in v:
    ans *= l
    if ans > 1e18:
      print(-1)
      exit(0)
 
if ans > 1e18:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 40200
N = int(input())
D = list(map(int, input().split()))

if N >= 24:
    print(0)

elif N == 23:
    d = [0 for _ in range(13)]
    d[0] = 1
    for i in range(N):
        d[D[i]] += 1
    if d[0] > 1 or d[12] > 1:
        print(0)
    else:
        for i in range(1, 12):
            if d[i] > 2:
                print(0)
                break
        else:
            print(1)

else:
    res = 0
    for bit in range(2**N):
        d = [0 for _ in range(24)]
        d[0] = 1
        for i in range(N):
            if (bit >> i) & 1:
                d[D[i]] += 1
            else:
                d[(24 - D[i]) % 24] += 1
        s = 25
        tmp = 0
        if d[0] > 1:
            s = 0
        else:
            for i in range(1, 24):
                if d[i] > 1:
                    s = 0
                    break
                elif d[i] == 1:
                    s = min(s, i - tmp)
                    tmp = i
            s = min(s, (24 - tmp) % 24)
        res = max(res, s)
    print(res)

Measured memory_bytes: 74056
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int p[N];

template <class T>
void read(T &x) {
  char ch = getchar(); x = 0;
  for(; ch < '0' || ch > '9'; ch = getchar()) ;
  for(; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
}

void fail() {
  puts("-1");
  exit(0);
}

int main() {
  int n, A, B;
  read(n), read(A), read(B);
  int l = (n - 1) / A + 1, r = n - A + 1;
  if(B < l || B > r) fail();  
  int now = n;
  for(int i = B; i >= 1; --i) {
    p[i] = min(A, now - i + 1);
    now -= p[i];
  }
  now = n;
  for(int i = B; i >= 1; --i) {
    for(int j = now - p[i] + 1; j <= now; ++j)
      printf("%d ", j);
    now -= p[i];
  }
  return 0;
}

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

int main() {
    int k,n ;
    cin >>k >>n;

vector<int> A(n);
for (int i = 0; i < n; i++) {
  cin >> A[i];
}
    int ans= (k-A[n-1]+A[0]) ;
    for (int i=0 ;i<n-1 ; i++){
        if( ans<= A[i+1]-A[i]){
            ans = A[i+1]-A[i] ;
        }
    }


  cout << k-ans << endl;
}

Measured memory_bytes: 1024
A=int(input())
B=int(input())
if A==1 and B==2:
  print(3)
elif A==2 and B==3:
  print(1)
elif A==3 and B==1:
  print(2)
elif A==1 and B==3:
  print(2)
elif A==2 and B==1:
  print(3)
elif A==3 and B==2:
  print(1)

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

int main() {
  int N,sum=0,min=100000;
  cin >> N;
  int W[N];
  for(int i=0;i<N;i++){
  	cin >> W[i];
    sum+=W[i];
  }
  for(int T=0;T<N-1;T++){
    int sum1=0;
  	for(int i=0;i<=T;i++){
      sum1+=W[i];
    }
    int aaa=abs(2*sum1-sum);
    if(min>aaa) {
      min=aaa;
    }
  }
  cout << min << endl;
}


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

signed main(){
    int n,x; cin>>n>>x;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    int cnt=0;
    rep(i,n-1){
        if(a.at(i)+a.at(i+1)>x){
            if(a.at(i)>x){
                cnt+=a.at(i)-x;
                a.at(i)=x;
                cnt+=a.at(i+1);
                a.at(i+1)=0;
            }else{
                cnt+=a.at(i)+a.at(i+1)-x;
                a.at(i+1)=x-a.at(i);
            }
        }
    }
    cout<<cnt<<endl;
}

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

#define STRING_LIMIT 1001

void Input(vector<char> &);
int EditDistance(vector<char> &, vector<char> &);

int main()
{
  int e_dist; //編集距離
  vector<char> s_buf; //文字列S
  vector<char> t_buf; //文字列T
  
  /* 入力 */
  Input(s_buf);
  Input(t_buf);
  
  /* 編集距離計算 */
  e_dist = EditDistance(s_buf, t_buf);

  /* 出力 */
  cout << e_dist << endl;
  //cout << s_buf.size() << endl;
  //cout << t_buf.size() << endl;
  
  return 0;
}

void Input(vector<char> &buf)
{
  	char c;
    int i,ret;
  
	for(i=0 ; i < STRING_LIMIT ; i++)
    {
    	ret = scanf("%c",&c);
    	if( c == '\n' || ret == EOF ) break;
        else buf.push_back(c);
    }
}

int EditDistance(vector<char> &str1, vector<char> &str2)
{
    int i,j;
  	int e_dist = STRING_LIMIT; //編集距離
    int count = 0;
    int str1_len = str1.size();
    int str2_len = str2.size();
    
  	for(i=0 ; i < (str1_len-str2_len+1) ; i++)
    {
    	for(j=0 ; j < str2_len ; j++)
        {
        	if( str1[i+j] != str2[j] ) count++;
        }
        if( count < e_dist )
        {
        	e_dist = count;
        }
        count = 0;
    }
  	
    return e_dist;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool find = false;
  for (int a = 0; a < 100; a++) {
    for (int b = 0; b < 100; b++) {
        int total = 4*a + 7*b;
        if (total == N) find = true;
      }
    }
  if(find) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    map<int,int> m;
    rep(i,N){
        int a; cin >> a;
        m[a]++;
    }
    int cnt=0;
    for(auto p:m){
        if(p.second%2!=0) cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007

using namespace std;
using ll = long long int;

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

int main(void) {
    int n; cin >> n;
    vector<long double> p(n);
    REP(i, n) cin >> p[i];
    vector<vector<long double>> dp(n + 1, vector<long double>(n + 1, 0));
    dp[0][0] = 1;
    REP(i, n) {
        REP(j, n) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
        }
    }
    long double sum_p = 0;
    for (int i = n / 2 + 1; i < n + 1; i++) {
        sum_p += dp[n][i];
    }
    cout << fixed << setprecision(10) << sum_p << endl;
}

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

const int mo=1000000007;

int main() {
	int n;
	int64_t cnt=0,tmp1=0,tmp2=0,adj=0,k;
	cin >> n >> k;
	vector<int>a(n);
	vector<int>b(n);
	for(int i=0;i<n;i++) cin >> a.at(i);
  b=a;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++) if(a.at(i)>a.at(j)) tmp1++;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++) if(a.at(i)>b.at(j)) tmp2++;
	}
	cnt+=(k*tmp1)%mo;
	cnt+=(((k*(k-1)/2)%mo*tmp2))%mo;
  cnt%=mo;
  cout << cnt << endl;
}


Measured memory_bytes: 256
while True:
    n, x = map(int,input().split())
    if(n==0 and x==0):
        break
    nlist = []
    for i in range(1,n+1):
        nlist.append(i)
    count = 0
    for i1 in range(n-2):
        for i2 in range(i1+1,n-1):
            for i3 in range(i2+1,n):
                y = nlist[i1]+nlist[i2]+nlist[i3]
                if(y == x):
                    count += 1
            
    print(count) 
        
    
            


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ll long long 
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define setbit(x,k) (x |= (1 << k))
#define clearbit(x,k) (x &= ~(1ll << k))
#define checkbit(x,k) (x & (1ll << k))
#define mp make_pair
#define scl(x) scanf("%lld",&x)
#define sci(x) scanf("%d",&x)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define pii pair<int,int> 
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
#define nn printf("\n") 
#define mod 10000007
using namespace std;    

ll n;
ll h[100005];
ll dp[100005];
ll solve(int pos)
{
    if(pos>=n-1) return 0;
    if(dp[pos]!=-1) return dp[pos];
    ll res = LONG_LONG_MAX;
    if(pos+1<n) res = min(res, abs(h[pos]-h[pos+1]) + solve(pos+1));
    if(pos+2<n) res = min(res, abs(h[pos]-h[pos+2]) + solve(pos+2));
    return dp[pos] = res;
    
}

int main() 
{
   memset(dp, -1 , sizeof(dp));
   cin>>n;
   for(int i=0; i<n; i++) cin>>h[i];
   cout<<solve(0); nn;
}

Measured memory_bytes: 9820
#include <iostream>
#include <stdio.h>       // printf,scanf
#include <stdlib.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>  //sort,binarySearch
#include <functional> 
#include <iomanip>    // setprecision
#include <utility>    // c+11 Array
#include <set>
#include <sstream>
#include <map>
#include <bits/stdc++.h>
#define MOD (1e+9)+7
#define PI 3.141592653589793238462643383279
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define pb(x) push_back(x)
#define debug(x) cout << #x << " = " << x << endl;
#define debret(x) debug(x) ; return 0;

using namespace std;

int main(void){

    int N,K,X,Y;

    cin >> N >> K >> X >> Y;

    int ans;

    if(N - K >= 0){
        
        ans = K * X + (N-K) * Y;
        
    }else{

        ans = N * X;

    }

    cout << ans << endl;
    
}


Measured memory_bytes: 764
//According to all known laws of aviation, there is no way that a bee should be able to fly.
//Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyway.
//Because bees don't care what humans think is impossible.
#include <bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define mod 1000000007
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int main(){
    FAST_IO ;
    bigint N ; cin >> N ;
    string ans = "" ;
    while( N > 0 ){
        bigint K = N / 26 ;
        bigint Z = N % 26 ;
        if( Z == 0 ){
            K-- ;
            ans = ( char ) 'z' + ans ;
        }
        else
            ans = ( char ) ( 'a' + Z - 1 ) + ans ;
        N = K ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 3652
n,m=map(int,input().split())
rs=0
if(n>2):
    for i in range(1,n+1):
        for e in range(i+1,n+1):
            rs+=1
if(n==2):rs+=1
if(m>2):
    for i in range(1,m+1):
        for e in range(i+1,m+1):
            rs+=1
if(m==2):rs+=1
print(rs)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin >> n;
  int m = 10;
  MAT<int> f = MATINIT(int, n, 10, 0);
  MAT<LL> p = MATINIT(LL, n, m+1, 0);
  REP(i, 0, n) { REP(j, 0, m) cin >> f[i][j]; }
  REP(i, 0, n) { REP(j, 0, m+1) cin >> p[i][j]; }
  int ub = 1 << m;
  LL ans = LLONG_MIN / 2;
  DUMP(ans);
  DUMP(p);
  REP(bit, 1, ub) {
    LL sum = 0;
    REP(i, 0, n) {
      int num = 0;
      REP(j, 0, m) {
        bool open = (bit >> (m - j - 1)) & 1;
        if (open) {
          num += f[i][j];
        }
      }
      //DUMP("  ", num,p[i][num]);
      sum += p[i][num];
    }
    //DUMP(bit, ans, sum);
    ans = max(ans, sum);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PA;
const int MOD = 1000000007;
const ll INF=2e18;

ll K,X;
string s;
int main(){
    cin>>K>>X;
    for(ll i=X-K+1;i<K+X;i++){
        cout<<i<<" "; 
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static int n = 0;


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		n = sc.nextInt();
		int[] p = new int[n];
		for(int i  =0;i < n;i++){
			p[i] = sc.nextInt();
		}
		Arrays.sort(p);
		int ans = 0;
		ans += p[n-1]/2;
		for(int i = 0;i < n-1;i++){
			ans += p[i];
		}
		System.out.println(ans);
	}

}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


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



int main() {
    int n;
    cin >> n;
    
    vector<ll> a(n);
    ll sum = 0;
    rep(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    
    vector<ll> b(n);
    ll sum_a = 0;
    for(int i = 1; i <= n-2; i+=2) {
        sum_a += a[i];
    }
    b[0] = sum - 2 * sum_a;
    
    for(int i = 1; i < n; i++) {
        b[i] = 2*a[i-1] - b[i-1];
    }
    
    
    rep(i,n-1) cout << b[i] << " ";
    cout << b[n-1] << endl;
    
    
    
    return 0;
}


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

int main(){
  int N,M;
  cin>>N>>M;
  vector<vector<tuple<int64_t,int64_t,int64_t,int64_t>>> p(8,vector<tuple<int64_t,int64_t,int64_t,int64_t>>(N));
  vector<tuple<int64_t,int64_t,int64_t,int64_t>> q(8);
  for(int i=0;i<N;i++){
    int64_t a,b,c;
    cin>>a>>b>>c;
    for(int j=0;j<8;j++){
      int64_t A=a,B=b,C=c;
      if(j&(1<<0)){
        A*=-1;
      }
      if(j&(1<<1)){
        B*=-1;
      }
      if(j&(1<<2)){
        C*=-1;
      }
      p[j][i]=make_tuple(A+B+C,A,B,C);
    }
  }
  int64_t Z=0;
  for(int i=0;i<8;i++){
    sort(p[i].begin(),p[i].end());
    reverse(p[i].begin(),p[i].end());
    for(int j=0;j<M;j++){
      int64_t z,w,e,r;
      int64_t a,s,d,f;
      tie(z,w,e,r)=q[i];
      tie(a,s,d,f)=p[i][j];
      z+=a,w+=s,e+=d,r+=f;
      q[i]=make_tuple(z,w,e,r);
    }
    int64_t a,b,c,d;
    tie(a,b,c,d)=q[i];
    Z=max(Z,abs(b)+abs(c)+abs(d));
  }
  cout<<Z<<endl;       
}

Measured memory_bytes: 3728
def main():
    import sys
    input = lambda: sys.stdin.readline().rstrip()

    h1, m1, h2, m2, k = map(int, input().split())

    m = 60 - m1
    h1 += 1
    m += (h2 - h1)*60 + m2
    print(max(0, m - k))
main()

Measured memory_bytes: 61844
import java.io.*;
import java.util.*;


public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        int n = sc.nextInt();
        int n2 = sc.nextInt();
        System.out.println(n < 10 ? n2 + 100 * (10 - n) : n2);
    }


    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        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 long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    int A, B, C;
    string S;
    bool ans = false;
    cin >> C >> A >> B;
    for (int i = A; i <= B; i++) {
        if (i%C==0) {
            ans = true;
        }
    }
    if (ans) {
        cout << "OK" << endl;
    } else {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
  else if (s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<i64> a(100001);
    i64 s = 0;
    for (int i = 0; i < n; i++) {
        int in;
        std::cin >> in;
        a[in]++;
        s += in;
    }

    int q;
    std::cin >> q;
    while (q--) {
        i64 b, c;
        std::cin >> b >> c;
        s += a[b] * (c - b);
        a[c] += a[b];
        a[b] = 0;
        std::cout << s << '\n';
    }

    return 0;
}


Measured memory_bytes: 3916
while True:
    x = input().split()

    a = int(x[0])
    op = x[1]
    b = int(x[2])

    if op == '?':
        break

    if op == '+':
        print("%d"%(a+b))
    elif op == '-':
        print("%d"%(a-b))
    elif op == '/':
        print("%d"%(a/b))
    else:
        print("%d"%(a*b))


Measured memory_bytes: 5592
=begin
  －－－－－－－－－－－－－－
  n = 入力値
  ans = 最小桁数
  a = 'n % a == 0' が成り立つ整数
  b = 上記 a が成り立った時の 'n / a' の結果
  max = a と b を比べた時の大きい方の桁数
  －－－－－－－－－－－－－－
  －tips－－－－－－－－－－－
  ● n = a * b を満たす場合、a と b は共に n の約数になる
  ● n を a で割って割り切れる数値の桁数のカウントをする。しかし、a を全列挙すれば O(N)となりTLEするので
    ◯ N = a*b = b*a (例 10 = 2*5 = 5*2 (交換法則)) より、A は √N まで調べれば 解が導き出せる
    　(例題だと 2*5 まで調べれば 5*2 から一緒なので調べなくて良い)
  －－－－－－－－－－－－－－

  1: 桁数をカウントするメソッドを作成する
    メソッド(num)－－－－－－－
      num > 0 の場合
        桁数を +1 する
        num / 10 を返す
      num が 0 になったらカウントした桁数を返す
    －－－－－－－－－－－－－－
  2: n の桁数をカウントして ansに代入する
  3: a = 1 とし a*a <= n の限り a+1 で繰り返す
    3.1: n % a == 0 の場合
      3.1.1: b = n / a に代入
      3.1.2: a と b の桁数をカウントし、大きい方の値を max に代入
      3.1.3: ans > max なら ans = max に代入
    3.2 0 でない場合は3:に戻る
  4: ans を出力
=end

def cnt_dig(num)
  cnt = 0
  while (num > 0)
    cnt += 1
    num /= 10
  end
  return cnt
end

n = gets.to_i
ans = cnt_dig(n)
a = 1
while(a*a <= n)
  unless n % a == 0
    a += 1
    next
  end
  b = n / a
  max = [cnt_dig(a),cnt_dig(b)].max
  ans = max if ans > max
  a += 1
end

puts ans

Measured memory_bytes: 1916
//satyaki3794
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;

ll pwr(ll base, ll p, ll mod = MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}


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


int n, arr[100005];


int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin>>n;
    ll sum = 0;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        sum += arr[i];
    }

    ll temp = 1LL*n*(n+1)/2;
    if(sum % temp != 0){
        cout<<"NO";
        return 0;
    }

    sum /= temp;
    for(int i=1;i<=n;i++){
        ll diff = -arr[i];
        if(i == n)  diff += arr[1];
        else    diff += arr[i+1];
        if(sum < diff || (sum - diff) % n != 0){
            cout<<"NO";
            return 0;
        }
    }

    cout<<"YES";
    return 0;
}





Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SUN")
		cout<<"7";
	if(s=="MON")
		cout<<"6";
	if(s=="TUE")
		cout<<"5";
	if(s=="WED")
		cout<<"4";
	if(s=="THU")
		cout<<"3";
	if(s=="FRI")
		cout<<"2";
	if(s=="SAT")
		cout<<"1";
	return 0;
}

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

string s;
bool finished;

void dfs(int i, string t)
{
    if (finished)
        return;
    if (i == 3)
    {
        int sum = s[0] - '0';
        int cnt = 0;
        rep(j, 3)
        {
            if (t[j] == '+')
            {
                sum += s[++cnt] - '0';
            }
            else
            {
                sum -= s[++cnt] - '0';
            }
        }
        if (sum == 7)
        {
            string ans;
            rep(j, 3)
            {
                ans += s[j];
                ans += t[j];
            }
            ans += s.back();
            ans += "=7";
            cout << ans << endl;
            finished = true;
        }
        return;
    }
    dfs(i + 1, t + "+");
    dfs(i + 1, t + "-");
}

void solve()
{
    cin >> s;
    dfs(0, "");
}

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

Measured memory_bytes: 3600
object Main {
  def main(args: Array[String]): Unit = {
    val out = io.StdIn.readLine.map {
      case 'A' => "T"
      case 'T' => "A"
      case 'C' => "G"
      case 'G' => "C"
    }
    println(out.head)
  }
}



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

typedef struct  {
    int left;
    int right;

}robot_t;

int cmp(const void* p, const void* q) {
    return ((robot_t*)p)->right - ((robot_t*)q)->right;
}
int main() {
    int n,posi,length,ans=1,temp_left;
    robot_t robot[100000] = { 0 };
    int i, j;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &posi, &length);
        robot[i].left = posi - length;
        robot[i].right = posi + length;
    }
    qsort(robot, n, sizeof(robot_t), cmp);
    /*
    for(int i=0;i<n;i++)printf("robot[%d].right=%d\n", i, robot[i].right);
    printf("\n");
    for (int i = 0; i < n; i++)printf("robot[%d].left=%d\n", i, robot[i].left);
    printf("\n");
    */
    for (i = 0; i < n; i=j) {
       
        for (j = i+1; j < n ; j++) {
            if (robot[i].right <= robot[j].left) {
                ans++;
                break;
            }
        }
  
        //printf("robot[%d].right=%d\n", i, robot[i].right);
    }
    printf("%d", ans);
    return 0;
}






Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld long double
#define mod 1000000007 
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define forn(i,s, e) for (int i = s; i <= e; i++)
#define fornd(i,s, e) for (int i = s ; i >= e; i--)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define print(x) for(auto el: x) cout<<el<<" ";cout<<"\n"
#define PSET(x,y) fixed<<setprecision(y)<<x
// #define bits(x) __builtin_popcount(x)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
void fileio()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
 

 
template <typename T> 
void swap(T& a, T& b){
    T temp = a;
    a = b;
    b = temp;
}

const int N = 100001; 

// int dp[101][N];


void solve(){
    int n,W;
    cin>>n>>W;
    pii * arr = new pii[n];
    forn(i,0,n-1)
        cin>>arr[i].F>>arr[i].S;

    int dp[2][N];
    // int** dp = new int*[n];

    for(int i=0;i<2;i++){
        // dp[i] = new int[N];
        for(int j=0;j<N;j++)
            dp[i][j] = mod;
    }
    // cout<<dp[N][0]<<" "<<dp[N][1]<<endl;
    
    for(int i=0;i<=arr[0].S;i++)
        dp[0][i] = arr[0].F;

    for(int i=1;i<n;i++){

        int k = i&1;
        
        for(int j=0;j<=arr[i].S;j++){
            dp[k][j] =min( arr[i].F, dp[k^1][j]);
        }

        for(int j = arr[i].S+1;j<N;j++){
            dp[k][j] = min(dp[k^1][j], dp[k^1][j-arr[i].S] + arr[i].F);
        }

        // for(int j)
    }

    // cout<<dp[W][0]<<" "<<dp[W][1]<<endl;

    int ans = 0;
    int l = (n%2==0 ? 1:0);
    for(int i=N-1;i>=0;i--){
        
        if(dp[l][i] <= W ){
            // cout<<dp[i][0]<<" "<<dp[i][1]<<endl;
            ans = i;
            break;
        }
    }

    cout<<(ans  )<<endl;


}
 
int32_t main()
{
    fast;
    // int t;
    // cin>>t;
    // for(int y=1;y<=t;y++)
    {
        // cout<<"Case #"<<y<<": ";
        solve();
    }
    return 0;
} 

Measured memory_bytes: 1792
# ABC126D - Even Relation
def dfs(r: int) -> None:
    stack = [r]
    while stack:
        v = stack.pop()
        for u, w in T[v]:
            if D[u] == -1:
                D[u] = (D[v] + w) % 2
                stack += [u]


def main():
    global T, D
    N, *A = map(int, open(0).read().split())
    T = [[] for _ in range(N + 1)]
    for i in range(0, (N - 1) * 3, 3):
        v, u, w = A[i : i + 3]
        T[v] += [(u, w)]
        T[u] += [(v, w)]
    D = [-1] * (N + 1)  # D[i] := parity of distance from vertex 1 (root)
    D[1] = 0
    dfs(1)
    print(*D[1:], sep="\n")


if __name__ == "__main__":
    main()


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

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    const int inf = 1e9+7;
    vector<int> dp(n + 2, inf);
    dp[0] = 0;
    rep(i, n) {
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }
    cout << dp[n-1] << endl;
}

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


int main() {

    int N;
    std::cin >> N;
    std::vector<std::pair<int64_t, int64_t>> BA(N);
    for (auto& v : BA)std::cin >> v.second >> v.first;
    std::sort(BA.begin(), BA.end());
    int64_t sum = 0;
    bool ans = true;
    for (auto& v : BA) {
        sum += v.second;
        if (sum <= v.first)continue;
        ans = false;
        break;
    }
    std::cout << (ans ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 3328
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        for i in range(h):
            for ii in range(w):
                if (i+ii)%2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()


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

#ifndef ONLINE_JUDGE
#define debarr(a,x,y)cerr<<#a<<":";for(int i=x;i<=y;i++)cerr<<a[i]<<" ";cerr<<endl;
#define debmat(mat,row,col)cerr<<#mat<<":\n";for(int i=0;i<row;i++){for(int j=0;j<col;j++)cerr<<mat[i][j]<<" ";cerr<<endl;}
#define deb(...)dbs(#__VA_ARGS__,__VA_ARGS__)
template<class S, class T>ostream &operator<<(ostream &os, const pair<S, T> &p) {return os << "(" << p.first << "," << p.second << ")";}
template<class T>ostream &operator<<(ostream &os, const vector<T> &p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const set<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>ostream &operator<<(ostream &os, const multiset<T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class S, class T>ostream &operator<<(ostream &os, const map<S, T>&p) {os << "["; for (auto&it : p)os << it << " "; return os << "]";}
template<class T>void dbs(string str, T t) {cerr << str << ":" << t << "\n";}
template<class T, class...S>void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << ":" << t << ","; dbs(str.substr(idx + 1), s...);}
#else
#define deb(...){}
#define debarr(a,x,y){}
#define debmat(mat,row,col){}
#endif
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define pr(x) {cout << x << "\n"; return;}

#define int              long long
#define ll               long long
#define ld               long double
#define fi               first
#define se               second
#define mp               make_pair
#define pb               push_back
#define sz(x)            (int)x.size()
#define all(x)           x.begin(),x.end()
#define ini(x,y)         memset(x,y,sizeof(x))
#define rep(i,n)         for(int i=0;i<n;i++)
#define re(i,n)          for(int i=1;i<=n;i++)
#define fr(i,a,b)        for(int i=a;i<=b;i++)
#define fb(i,a,b)        for(int i=a;i>=b;i--)
typedef pair<int, int>   pii;
typedef vector<int>      vi;
typedef vector<pii>      vii;
typedef map<int, int>    mii;
typedef set<int>         si;
const int N = 2e5 + 10;

void solve(int tc)
{
	int n;
	cin >> n;
	int ans = 0;
	int mx;
	rep(i, n)
	{
		int x; cin >> x;
		if (i == 0) mx = x;
		else {
			if (x < mx) ans += (mx - x);
			else mx = x;
		}
	}
	cout << ans << endl;
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) solve(i);
	return 0;
}

Measured memory_bytes: 3652
a,b,c,d=map(float,input().split())
a=complex(a,b)
b=complex(c,d)
for _ in [0]*int(input()):
    c=complex(*map(float,input().split()))
    q=b-a;c-=a
    p=a+q*(c/q).conjugate()
    print(p.real,p.imag)

Measured memory_bytes: 7656
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;
using ll = long long;
int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  if(abs(a-b)%2==0) cout << abs(a-b)/2;
  else{
    cout << min(min(a-1,b-1),min(n-a,n-b)) + abs(a-b-1)/2;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<float> A(N);
  float B=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    B+=1/A[i];
  }
  cout<<1/B;
}

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

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;i++){
        cin >> h.at(i);
    }
    int count=0;
    for(int i=0;i<n;i++){
        if(h.at(i)>=k) count++;
    }
    cout << count << endl;
    }

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


const int MAXN = 100001;
typedef long long ll;
#define f first
#define s second
const ll mod = 1e9+7;


int main(){
	int N,M;
	scanf("%d %d",&N,&M);
	char c;
	int chk[N][M], moves[4][2] = {{0,-1},{0,1},{1,0},{-1,0}};
	memset(chk,0,sizeof chk);
	queue<pair<int,int>> q;
	for (int i=0;i<N;i++){
		for (int j=0;j<M;j++){
			scanf(" %c",&c);
			if (c=='#'){
				chk[i][j] = 1;
				q.push({i,j});
			}
		}
	}
	pair<int,int> cur;
	int ans = 0, y, x;
	while (!q.empty()){
		cur = q.front();
		q.pop();
		for (int i=0;i<4;i++){
			y = cur.f+moves[i][0];
			x = cur.s+moves[i][1];
			if (x<0||y<0||y>=N||x>=M) continue;
			if (chk[y][x]) continue;
			chk[y][x] = chk[cur.f][cur.s]+1;
			q.push({y,x});
			ans = max(ans,chk[y][x]-1);
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 12304
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,a[252525],b[252525],ans=0,c[252525],d[252525];
#define int long long
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,29){
		rep(j,n)c[j]=a[j]%(1<<(i+1));
		rep(j,n)d[j]=b[j]%(1<<(i+1));
		int cnt=0;
		sort(d,d+n);
		rep(j,n){
			cnt+=lower_bound(d,d+n,(1<<i)*2-c[j])-lower_bound(d,d+n,(1<<i)-c[j]);
			cnt+=lower_bound(d,d+n,(1<<i)*4-c[j])-lower_bound(d,d+n,(1<<i)*3-c[j]);
		}
		if(cnt%2)ans+=(1<<i);
	}
	cout<<ans<<endl;		
	return 0;
}

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

#define rep1(i,n) for (decay_t <decltype (n)> i = 1, i ## __len = (n); i <= i ## __len; ++ i)

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

  string s, t;
  cin >> s >> t;

  vector <vector <int>> dp (s.length () + 1, vector <int> (t.length () + 1, 0));
  rep1 (i, s.length ())
  {
    rep1 (j, t.length ())
    {
      if (s[i - 1] == t[j - 1])
      {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
      else
      {
        dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }

  // 復元
  list <char> ans;
  auto i = s.length ();
  auto j = t.length ();
  while (i != 0 && j != 0)
  {
    //cerr << "(" << i << ", " << j << ")" << endl;
    auto next_i = i;
    auto next_j = j;
    if (s[i - 1] == t[j - 1])
    {
      ans.push_front (s[i - 1]);
      -- next_i;
      -- next_j;
    }
    else
    {
      if (dp[i][j - 1] < dp[i - 1][j])
      {
        -- next_i;
      }
      else
      {
        -- next_j;
      }
    }
    i = next_i;
    j = next_j;
  }

  for (auto && elem : ans) cout << elem;
  cout << endl;
}


Measured memory_bytes: 35712
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int ans = 1;
  for (int i = 0; i < n; i++) {
    if (ans * 2 > ans + k) {
      ans += k;
    } else {
      ans *= 2;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int i,j,k,n,x;
	int ans;
while(true){
	ans=0;
	cin >> n >> x;
	if(n==0 && x==0){
		break;
	}
	else{
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				if(i!=j && j!=k && i!=k){
					if(i+j+k==x){
						ans=ans+1;
					}
				}
			}
		}
	}
	}
	cout << ans/6 << endl; /*6通り*/
}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    int k, x;
    cin >> k >> x;

    if (500 * k >= x)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;


public class Main {
	
	public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException {
		new Main().exec();
	}
	
	public void exec() throws IOException, InstantiationException, IllegalAccessException {
		InputUtil in = new InputUtil();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int[] preOrder = in.nextInt(new int[n]);
		int[] inOrder = in.nextInt(new int[n]);
		int[] inOrderId = new int[n];
		for(int i=0; i<n; i++) inOrderId[inOrder[i]-1] = i;
		outputPostOrder(true,out,preOrder,0,n,inOrder,0,n,inOrderId);
		out.println("");
		out.flush();
	}
	
	private boolean outputPostOrder(boolean isFirst, PrintWriter out, int[] pre, int preS, int preE, int[] in, int inS, int inE, int[] inOrderId){
		if(preS==preE) return isFirst;
		
		int inOrderRootId = inOrderId[pre[preS]-1];
		int leftTreeSize = inOrderRootId - inS;

		isFirst = outputPostOrder(isFirst,out,
				pre,preS+1,preS+leftTreeSize+1,
				in,inS,inOrderRootId,
				inOrderId);
		isFirst = outputPostOrder(isFirst,out,
				pre,preS+leftTreeSize+1,preE,
				in,inOrderRootId+1,inE,
				inOrderId);
		if(!isFirst) out.print(' ');
		out.print(pre[preS]);
		return false;
	}
}


class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 100000;
	
	//Fields
	protected InputStream in;
	private byte[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private DataInputStream dis = null;
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {dis = new DataInputStream(this.in = in);}
	protected void initBuf(int bufsiz) {buf = new byte[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && dis.available()>0) {
			if(max>0) Arrays.fill(buf,0,max,(byte)0);
			max = dis.read(buf);
			ptr = 0;
		}
	}
	
	//Number Input Reader/Parser
	private boolean isNum(byte b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(byte b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		byte c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

Measured memory_bytes: 24564
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>A;
	map<int, int>mp;
	int cnt = 0;
	rep(i, 0, N) {
		int a; cin >> a;
		if (a == 1)++cnt;
		mp[a]++;
	}
	if (cnt == 1) {
		cout << 1 << "\n";
		return 0;
	}
	else if (cnt > 1) {
		cout << 0 << "\n";
		return 0;
	}
	int ans = N;
	for (auto p : mp) {
		if (p.second > 1)ans -= p.second;
		A.push_back(p.first);
	}
	rep(i, 0, (int)A.size()) {
		if (mp[A[i]] > 1)continue;
		for (int j = 2;j * j <= A[i];++j) {
			if (A[i] % j == 0) {
				if (mp.count(j) || mp.count(A[i] / j)) {
					--ans;
					break;
				}
			}
		}
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 13496
#include<stdio.h>
#include<string.h>
int main()
{
	int i,j,x,y;
	char s[10],a[10],u[10];
	scanf("%s %s",s,a);
	scanf("%d%d",&x,&y);
	scanf("%s",u);
	if(strcmp(s,u)==0)
	x--;
	else
	y--;
	printf("%d %d",x,y);
 } 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int sz = 1 << 17;
vector< int > seg[2 * sz + 1];
int data[100000], n;

int query(int a, int b, int lower, int upper, int k, int l, int r)  // [a,b)でlower以上upper以下の数を求める
{
  if(a >= r || b <= l) {
    return(0);
  } else if(a <= l && r <= b) {
    return(upper_bound(seg[k].begin(), seg[k].end(), upper) - lower_bound(seg[k].begin(), seg[k].end(), lower));
  } else {
    return(query(a, b, lower, upper, 2 * k + 1, l, (l + r) >> 1) + query(a, b, lower, upper, 2 * k + 2, (l + r) >> 1, r));
  }
}
void init(int k, int l, int r)
{
  if(l + 1 == r) {
    if(l >= 0 && l < n) seg[k].push_back(data[l]);
  } else {
    init(2 * k + 1, l, (l + r) >> 1);
    init(2 * k + 2, (l + r) >> 1, r);
    seg[k].resize(seg[2 * k + 1].size() + seg[2 * k + 2].size());
    merge(seg[2 * k + 1].begin(), seg[2 * k + 1].end(), seg[2 * k + 2].begin(), seg[2 * k + 2].end(), seg[k].begin());
  }
}


int main()
{
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> data[i];
  }
  init(0, 0, sz);

  int Q;
  cin >> Q;
  while(Q--) {
    int l, r, e;
    cin >> l >> r >> e;
    --l, --r;
    int lower = min(data[l], data[r]) - e;
    int upper = max(data[l], data[r]) + e;
    cout << r - l + 1 - query(l, r + 1, lower, upper, 0, 0, sz) << endl;
  }
  return(0);
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    cout <<(a-1)*(b-1)<<endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var H = input[0];
            var W = input[1];
            var ans = long.MaxValue;            
            for (long i = 1; i < W; i++)
            {
                long tmpMax = Math.Max(i * H, Math.Max((W - i) * (H / 2), (W - i) * (H - H / 2)));
                long tmpMin = Math.Min(i * H, Math.Min((W - i) * (H / 2), (W - i) * (H - H / 2)));
                if (tmpMax - tmpMin < ans) ans = tmpMax - tmpMin;
            }
            for (long i = 1; i < H; i++)
            {
                long tmpMax = Math.Max(i * W, Math.Max((H - i) * (W / 2), (H - i) * (W - W / 2)));
                long tmpMin = Math.Min(i * W, Math.Min((H - i) * (W / 2), (H - i) * (W - W / 2)));
                if (tmpMax - tmpMin < ans) ans = tmpMax - tmpMin;
            }
            for (long i = 1; i < W - 1; i++)
            {
                long tmpMax = Math.Max(i * H, Math.Max((W - i) / 2 * H, ((W - i) - (W - i) / 2) * H));
                long tmpMin = Math.Min(i * H, Math.Min((W - i) / 2 * H, ((W - i) - (W - i) / 2) * H));
                if (tmpMax - tmpMin < ans) ans = tmpMax - tmpMin;
            }
            for (long i = 1; i < H - 1; i++)
            {
                long tmpMax = Math.Max(i * W, Math.Max((H - i) / 2 * W, ((H - i) - (H - i) / 2) * W));
                long tmpMin = Math.Min(i * W, Math.Min((H - i) / 2 * W, ((H - i) - (H - i) / 2) * W));
                if (tmpMax - tmpMin < ans) ans = tmpMax - tmpMin;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

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

    vector<int> town;
    vector<int> ord(n+1, -1);

    int v =1;
    while (ord[v] == -1) {
        ord[v] = town.size();
        town.push_back(v);
        v = a[v-1];
    }

    int c, l;
    c = town.size() - ord[v];
    l = ord[v];

    if (k < l) cout << town[k] << endl;
    else {
        k -=l;
        k %= c;
        cout << town[k+l] << endl;
    }
    return 0;
}

Measured memory_bytes: 5888