akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    string s;
    cin >> s;
    cout << char(s[0]+1) << endl;
}


Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTG(c) sort((c).begin(),(c).end(),greater<auto>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<char>> a(n,vector<char> (n)), b(m, vector<char>(m));
  REP(i,n){
    REP(j, n){
      cin >> a[i][j];
    }
  }
  REP(i,m){
    REP(j,m){
      cin >> b[i][j];
    }
  }
  bool ans = false;
  REP(i, n-m+1){
    REP(j, n-m+1){
      bool flg = true;
      REP(k, m){
        REP(l, m){
          if(a[i+k][j+l]!=b[k][l]){
            flg=false;
            break;
          }
        }
        if(flg==false) break;
      }
      if(flg){
        ans = true;
        break;
      }
    }
    if(ans) break;
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    static int[] a;

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        a = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        int q = Integer.parseInt(sc.next());
        
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < q; i++){
            int m = Integer.parseInt(sc.next());
            if(solve(0, m)){
                sb.append("yes");
            }else{
                sb.append("no");
            }
            sb.append(System.lineSeparator());
        }
        
        System.out.print(sb);
    }
    
    static boolean solve(int i, int m){
        
        if(m == 0) return true;
        if(i >= a.length) return false;
        return solve(i+1, m) || solve(i+1, m-a[i]);
    }
}


Measured memory_bytes: 26432
#include<iostream>
#include<algorithm>
#include<vector>
#include <iomanip>
#include <cmath>
#include <string.h>
#include <stdio.h>

using namespace std;
 

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

  double S, L, h;
  double PI = acos(-1);
  double rad = C * PI / 180;
  double c = sqrt(a*a + b*b -2*a*b*cos(rad));
  
  S = a * b * sin(rad) /2;
  L = a + b + c;  
  h = 2*S/a;
  
  cout.precision(8);
  cout << fixed;
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;

  return 0;
  
}


Measured memory_bytes: 3476
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int n, x;
  cin >> n >> x;
  int minN = INF;
  int tmp;
  int ans = n;
  rep (i, n) {
    cin >> tmp;
    x -= tmp;
    minN = min(tmp, minN);
  }
  P(ans + x / minN);

  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;

    return 0;
}


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

#define all(x)  x.begin(), x.end()
#define mp      make_pair
#define pii     pair<int, int>
#define pll     pair<long long, long long>
#define ll      long long

int main() {
        string s;
        cin >> s;
        string t;
        for (int i = 0; i < s.size(); i ++) {
                if (s[i] != 'x') t += s[i];
        }
        string tt = t;
        reverse(all(tt));
        if (t != tt) {
                printf("%d\n", -1);
                return 0;
        }
        int bg = 0, ed = s.size() - 1;
        int ans = 0;
        while (bg < ed) {
                if (s[bg] == s[ed]) { 
                        bg ++, ed --;
                        continue;
                }
                if (s[bg] == 'x') {
                        bg ++;
                } else {
                        ed --;
                }
                ans ++;
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main()
{
    int n; cin >> n;

    bool answer = false;

    while(n)
    {
        int y = n%10;
        if(y==7)
        {
            answer = true;
            break;
        }
        n/=10;
    }
    if(answer) cout << " Yes ";
    else cout << " No ";

    return 0;
}


Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define SORT(v) sort((v).begin(), (v).end())
#define REV(v) sort((v).begin(), (v).end(), greater<int>())
#define INF 1000000007
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(c > a - b) cout << c - (a - b) << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

const M: usize = 998244353;

#[fastout()]
fn main() {
    input! {
        a: usize, b: usize, c: usize, d: usize,
    }

    let mut dp = vec![vec![0; d+1]; c+1];
    dp[c][d] = 1;
    for i in (0..d).rev() {
        dp[c][i] = dp[c][i+1] * c % M;
    }
    for i in (0..c).rev() {
        let mut x = 0;
        for j in (0..=d).rev() {
            dp[i][j] = (j*dp[i+1][j] + x) % M;
            x += dp[i+1][j];
            x *= i;
            x %= M;
        }
    }
    println!("{}", dp[a][b]);
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

template <typename T>
static inline T ArraySum(vector<T>& A) {
  T res = 0;
  for (auto itr = A.begin(); itr < A.end(); ++itr) res += *itr;
  return res;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(18);
  string S;
  cin >> S;
  if (S[1] == 'B')
    cout << "ARC" << endl;
  else
    cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
using namespace std;

int main(){
  int K, A, B; scanf("%d%d%d", &K, &A, &B);

  long long ans = 1 + K;

  if(B - A > 1){
    K -= A - 1;

    if(K > 0){
      long long v = A + 1LL * K / 2 * (B - A);
      if(K & 1) v++;

      if(v > ans) ans = v;
    }
  }

  printf("%lld\n", ans);
  return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n];
	long long ans = 0,max=0;
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	    
	}
	max = arr[0];
	for(int i=1;i<n;i++){
	    if(arr[i]<max){
	        ans =ans + max - arr[i];
	    }
	    else{
	        max = arr[i];
	    }
	}
	cout<<ans;

	return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int a, b, c;
  a = A - B;
  b = B - C;
  c = C - A;
  if (a == 0){
    if (b == 0){
      cout << "No" << endl;
    }
    else {
      cout << "Yes" << endl;
    }
  }
  else {
    if (b == 0){
      cout << "Yes" << endl;
    }
    else if (c == 0){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}



Measured memory_bytes: 256
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  string s; cin>>s;
  int cnt=0;
  for(int i=0;i<s.size()/2;i++){
    if(s[i]!=s[s.size()-1-i]) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main() {
    int k;
    string s;
    cin >> k;
    cin >> s;

    if(k < s.size()) {
        cout << s.substr(0, k);
        cout << "..." << endl;
    } else {
        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 3596
n=int(input())
a=list(map(int,input().split()))
p=0
ans_1=ans_2=0
for i in range(n):
	p+=a[i]
	if p>=0 and i%2==0:
		ans_1+=p+1
		p=-1
	elif p<=0 and i%2!=0:
		ans_1+=-p+1
		p=1
p=0
for i in range(n):
	p+=a[i]
	if p>=0 and i%2!=0:
		ans_2+=p+1
		p=-1
	elif p<=0 and i%2==0:
		ans_2+=-p+1
		p=1
print(min(ans_1,ans_2))






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

using namespace std;

int main()
{
  string s,t;
  cin>> s>> t;

  string ret="No";
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<int>());
  if(s<t)ret="Yes";
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	char day[][16] = {"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
	int month[12] = {30,28,30,29,30,29,30,30,29,30,29,30};
	int m,d,i,n;
	while(1){
		n=0;
		scanf("%d%d",&m,&d);
		if(!m&&!d) break;
		for(i=0;i<m-1;i++) n += month[i]+1;
		n+=d-1;
		n = n%7;
		printf("%s\n",day[n]);
	}
	return 0;
}

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

using namespace std;

string s;

int main()
{
    cin >> s;
    int x = 0;
    int ans = s.size();
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'S')
            x++;
        if(s[i] == 'T')
        {
            if(x > 0)
            {
                ans -= 2;
                x--;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static final long MOD = 1_000_000_000 + 7;

	public static void main(String[] args) {
		// input
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		long[] x = new long[n];
		long[] y = new long[m];

		for (int i = 0; i < n; i++) {
			x[i] = sc.nextLong();
		}
		for (int i = 0; i < m; i++) {
			y[i] = sc.nextLong();
		}

		long xsum = 0;
		for (int i = 0; i < n; i++) {
			long tmp = ((2 * i - n + 1) * x[i]) % MOD;
			xsum += tmp;
			xsum %= MOD;
		}

		long ysum = 0;
		for (int i = 0; i < m; i++) {
			long tmp = ((2 * i - m + 1) * y[i]) % MOD;
			ysum += tmp;
			ysum %= MOD;
		}

		long ans = (xsum * ysum) % MOD;

		// output
		System.out.println(ans);
	}
}


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


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

	vector<int> hp(n);
	for (int i = 0; i < n; i++) cin >> hp.at(i);
	sort(hp.begin(), hp.end());
	int64_t cnt = 0;
	for (int i = 0; i < n - k; i++) cnt += hp.at(i);
	cout << cnt << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int vis[N];
signed main(){
 	// #ifndef ONLINE_JUDGE
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// #endif
	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		int n ;
		cin >> n;
		fn1{
			cin >> ar[i];
		}
		int ans =0;
		fn1{
				if(ar[ar[i]]==i && i < ar[i] )ans++;
			
		}
		cout << ans << endl;
		
	}
	
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 a, b;
int main() {
  cin >> a >> b;
  if (((a ^ b) & 1) == 1) cout << "IMPOSSIBLE\n";
  else cout << (b + a) / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#ABC121-B
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(n)]

cnt = 0

for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += a[i][j] * b[j]
        
    tmp += c
    if tmp > 0:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 3064
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = long.Parse(nm[0]);
        var m = long.Parse(nm[1]);

        var d = new Tuple<int, int>[n];
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split(' ');
            d[i] = Tuple.Create(int.Parse(ab[0]), int.Parse(ab[1]));
        }

        Array.Sort(d, (x, y) => x.Item1 - y.Item1);

        var sum = 0L;
        for (int i = 0; i < n; i++)
        {
            sum += d[i].Item2;
            if (m <= sum)
            {
                Console.WriteLine(d[i].Item1);
                return;
            }
        }
    }
}


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

using namespace std;
typedef long long ll;
const ll N= 1e5+7;
ll l, n , k , x , a, b, c ,d,sum;
vector<int>v;
ll GCD( ll num1 , ll num2)
{
    if(min(num1 , num2)==0)
    {
        return max(num1, num2);
    }
    return GCD(max(num1,num2)%min(num1,num2) , min(num1 , num2));
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> a>>b>>c>>d;
    x=((c*d)/GCD(c,d));
    sum=0;
    sum+=(b/c);
    //cout << sum <<"\n";
    sum-=((a-1)/c);
    //cout << sum <<"\n";
    sum+=(b/d);
    //cout << sum <<"\n";
    sum-=((a-1)/d);
    //cout << sum <<"\n";
    sum-=(b/(x));
    //cout << sum <<"\n";
    sum+=((a-1)/x);
    //cout << sum <<"\n";
    cout << b-a+1 - sum << "\n";
    return 0;
}


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

const int maxn = 2e3 + 5;
LL a[maxn];
LL b[maxn][maxn];

int main(){
    int n;
    LL x,sum = 1LL << 60LL;
    cin >> n >> x;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= n;i++){
        b[i][0] = a[i];
        for(int k = 1;k <= n - 1;k++){
            int pos = i - k;
            if(pos <= 0) pos = n - abs(pos);
            b[i][k] = min(b[i][k - 1],a[pos]);
        }
    }
    for(int k = 0;k <= n - 1;k++){
        LL ans = 0;
        for(int i = 1;i <= n;i++){
            ans += b[i][k];
        }
        sum = min(sum,ans + x * k);//取最小值.
    }
    cout << sum << endl;
}


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

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right; 
};

typedef struct Node * NodePointer;

void insert( NodePointer t , int z){
	NodePointer x;
	if ( t -> key <= z){
		if  ( t -> right  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> right = x;
		}else {
			insert ( t -> right , z);
		}
	
	}else {
		if  ( t -> left  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> left = x;
		}else {
			insert ( t -> left , z);
		}
	}
};

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};	

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


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

	NodePointer tree = (NodePointer) malloc (sizeof(struct Node));
	
	char input [8];
	int k;
	
	for ( int i = 0; i  < n; i++){
		scanf("%s" ,&input);
		
		if ( strcmp( input , "insert") == 0 ){
			scanf("%d\n",&k);
	
			if ( i == 0)
			{
			tree -> key = k;
			tree -> right = NULL;
			tree -> left = NULL;
			}

			else {insert(tree , k);
			}
		}else {
			inorder(tree);
			printf("\n");
			
			preorder(tree);
			printf("\n");
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 25220
#include <iostream>

using namespace std;
#define NIL -1;

struct Node{int parent, left, right;};
Node T[10000];
int D[10000];
int H[10000];



void setDepth(int u, int d){
    if(u==-1) return;
    D[u]=d;
    setDepth(T[u].right,d+1);
    setDepth(T[u].left,d+1);
}

int setHeight(int u){
    int h1,h2; h1=h2=0;
    if(T[u].right!=-1) h1=setHeight(T[u].right)+1;
    if(T[u].left!=-1) h2=setHeight(T[u].left)+1;

    return H[u] = max(h1,h2);

}

int getSibling(int u){
    if(T[u].parent==-1) return -1;
    if(T[T[u].parent].left!=u and T[T[u].parent].left!=-1) return  T[T[u].parent].left;
    if(T[T[u].parent].right!=u and T[T[u].parent].right!=-1) return  T[T[u].parent].right;
    return -1;

}

void print(int u){
    cout<<"node "<<u<<": ";
    cout<<"parent = "<<T[u].parent<<", ";
    cout<<"sibling = "<<getSibling(u)<<", ";
    int deg=0;
    if(T[u].left!=-1) deg++;
    if(T[u].right!=-1) deg++;
    cout<<"degree = "<<deg<<", ";
    cout<<"depth = "<<D[u]<<", ";
    cout<<"height = "<<H[u]<<", ";

    if(T[u].parent==-1)cout<<"root";
    else if(T[u].left==-1 and T[u].right==-1)cout<<"leaf";
    else cout<<"internal node";
    cout<<endl;


}



int main()
{
    int n,i,l,r,v;
    cin>>n;
    for(i=0;i<n;i++)T[i].parent=T[i].left=T[i].right=-1;
    for(i=0;i<n;i++){
        cin>>v;
        cin>>l>>r;
        if (l!=-1){
            T[v].left=l;
            T[l].parent=v;
        }
        if (r!=-1){
            T[v].right=r;
            T[r].parent=v;
        }
    }

    for(i=0;i<n;i++){
        if(T[i].parent==-1) r=i;
    }
    setDepth(r,0);
    setHeight(r);

    for(i=0;i<n;i++)print(i);

    return 0;
}


Measured memory_bytes: 3120
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  var k = 0
  for (i in 1..n) {
    k = i
    if (i * (i + 1) / 2 >= n) break
  }
  var r = n
  for (i in k downTo 1) {
    if (r - i < 0) continue
    println(i)
    r -= i
  }
}


Measured memory_bytes: 33808
n=int(input())

xy=[tuple(map(int,input().split())) for i in range(n)]
pq=[]
for i in range(n):
  for j in range(n):
    if i==j:continue
    x1,y1=xy[i]
    x2,y2=xy[j]
    pq.append((x2-x1,y2-y1))

ans=n
for p,q in pq:
  t=0
  for x,y in xy:
    if (x+p,y+q) not in xy:t+=1
  ans=min(ans,t)
print(ans)


Measured memory_bytes: 3316
#include<iostream>
#include<math.h>

#define PI 3.14159265359
using namespace std;

int main(){
	int n,r;
	char c;
	double nx=0,ny=0;
	int nr=90;
	while(cin>>n>>c>>r &&n+r){
		nx+=cos(nr*PI/180.0)*n;
		ny+=sin(nr*PI/180.0)*n;
		nr+=-1*r;
	}
	
	cout<<(int)nx<<endl<<(int)ny<<endl;
}

Measured memory_bytes: 1164
def main():
    from collections import deque
    n, m, *ab = map(int, open(0).read().split())

    l = {i: [] for i in range(n + 1)}
    for i, j in zip(*[iter(ab)] * 2):
        l[i] += [j]
        l[j] += [i]

    ll = [None] * (n + 1)
    vis = [False] * (n + 1)
    que = deque([1])
    vis[1] = True
    while que:
        now = que.popleft()
        nx = l[now]
        for i in nx:
            if vis[i]:
                continue
            vis[i] = True
            ll[i] = now
            que.append(i)
    if all(vis[1:]):
        print("Yes")
        s = "\n".join(map(str, ll[2:]))
        print(s)
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 56540
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
  String s = sc.next();
  char[] c = s.toCharArray();
  int first;
  int last;
  for(int i = 0;;i++){
    if(c[i] == 'A'){
      first = i;
      break;
    }
  }
  for(int i = s.length()-1;;i--){
    if(c[i] == 'Z'){
      last = i;
      break;
    }
  }
  System.out.println(last - first + 1);
}}


Measured memory_bytes: 26424
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  int dp[100010] = {};
  dp[0] = 1;
  REP(i, N)
  {
    if (dp[i] == 0)
      continue;
    if (i + 5 <= N && S.substr(i, 5) == "dream")
      dp[i + 5] = 1;
    if (i + 7 <= N && S.substr(i, 7) == "dreamer")
      dp[i + 7] = 1;
    if (i + 5 <= N && S.substr(i, 5) == "erase")
      dp[i + 5] = 1;
    if (i + 6 <= N && S.substr(i, 6) == "eraser")
      dp[i + 6] = 1;
  }
  cout << (dp[N] ? "YES" : "NO") << endl;
  return 0;
}


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



int main()
{
    int n,leg;
    int b, t;
    cin >> n >> leg;

    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (i + j == n && 2 * i + 4 * j == leg) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
   

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for (int i=0,_n=(int)(n); i < _n; i++)
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
 
typedef long long ll;

const int M = 100000 + 10;
int B[M];

int main2() {
  memset(B, 0, sizeof(B));

  int N; cin >> N;
  REP(i, N) {
    int A;
    cin >> A;
    B[A]++;
  }

  int on = 0;
  REP(i, M) {
    if (B[i] >= 1) {
      on++;
    }
  }
  if (on % 2 == 1) cout << on << endl; else cout << (on-1) << endl;

  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
ll COM(int n, int k) {
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin >> n >> k;
  COMinit();
  FOR(i,1,k+1){
    cout << COM(n-k+1, i) * COM(k-1, i-1) % MOD << '\n';
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define X first;
#define Y second;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 3e5 + 10;
const int maxK = 1e4+10;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 998244353;


int H,W,m;


int main()
{
	string s;
	cin>>s;
	if(s.back() == 's')
	{
		s = s + "es";	
	} 
	else
	{
		s = s + "s";
	}
	cout<<s<<endl;
	return 0;
}

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

int main() {
    int n;
    int m;
   
    
    cin >> n >> m;
    
    string a[n];
  
    vector<string> v;
    v.resize(n);
  
    string l;
    int k = 0;
  
    while(cin>>l){
        
        v[k]=l;
        
        k++;
    }
  
   sort(v.begin(), v.end());
  
  
   for(int i = 0;i<n;i++){
   
   
    //  if(i != m-1){ 
        
         cout << v[i];
        
     // }else{
       // cout << v[i] << endl;
     // }
       
     }
     
     
    
   
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
#include<string>
#define REP(i,a) for(int  i=0;i<a;i++)
int A[100000];
int main(){

	string k;
	int a,b=0,c=0,n,j,x,y,p,N,M,BA=0,fuda[101];	
	cin>>n;
	while(n!=0){
	REP(i,n){
	fuda[i]=0;
	}
	cin>>k;
	REP(i,100){
	if(k[i]=='M'){
	fuda[c]++;
	}
	else if(k[i]=='L'){
	fuda[c]=fuda[c]+BA+1;
	BA=0;
	}
	else if(k[i]=='S'){
	BA=BA+fuda[c]+1;
	fuda[c]=0;
	}
	c++;
	if(c==n){
	c=0;
	}
	}
	sort(fuda,fuda+n);
	cout<<fuda[0];
	REP(i,n-1){
	cout<<" "<<fuda[i+1];
	}
	c=0;
	cout<<" "<<BA;
	cout<<endl;
	cin>>n;
	BA=0;
	}
	return 0;
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a,b,c,d,n;
signed main(){
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&d,&n);
	b=min(b,a*2);c=min(c,b*2);d=min(d,c*2);
	printf("%lld\n",n/2*d+(n%2)*c);
} 

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

using namespace std;

int main()
{
    int x = 0;
    int max_x = 0;

    int N;
    cin >> N;

    string S;
    cin >> S;

    for (char c : S) {
        if (c == 'I') {
            x++;
            if (x > max_x) {
                max_x = x;
            }
        } else {
            x--;
        }
    }

    cout << max_x << endl;

    return 0;
}

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

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

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

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

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

mt19937 mrand(random_device{} ()); 

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

void precalc() {
}

const int maxn = (int) 1e5 + 5;
const int maxd = 11;
int n, m, q;
vector<int> g[maxn];
int dp[maxd][maxd][maxn];
int c[maxn];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < m; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  scanf("%d", &q);
  for (int i = 0; i < maxd; i++) {
    for (int j = 0; j <= i; j++) {
      for (int v = 0; v < n; v++) {
        dp[i][j][v] = -1;
      }
    }
  }
  for (int i = 0; i < q; i++) {
    int s, d;
    scanf("%d%d%d", &s, &d, &c[i]);
    s--;
    dp[d][0][s] = max(dp[d][0][s], i);
  }
  return true;
}

void solve() {
  for (int d = 0; d < maxd; d++) {
    for (int curd = 0; curd + 1 <= d; curd++) {
      for (int v = 0; v < n; v++) {
        int cur = dp[d][curd][v];
        if (cur == -1) {
          continue;
        }
        for (int i = 0; i < sz(g[v]); i++) {
          int u = g[v][i];
          dp[d][curd + 1][u] = max(dp[d][curd + 1][u], cur);
        }
      }
    }
  }
  for (int v = 0; v < n; v++) {
    int id = -1;
    for (int d = 0; d < maxd; d++) {
      for (int curd = 0; curd <= d; curd++) {
        id = max(id, dp[d][curd][v]);
      }
    }
    int res = (id == -1 ? 0 : c[id]);
    printf("%d\n", res);
  }
}

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


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main() 
{
	int R; cin >> R;
	if (R < 1200) cout << "ABC" << endl;
	else if (R < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int

	fmt.Scan(&n, &k)

	getUser := make(map[int]struct{})
	delDup := make([]int, 0)

	var tmpArr []int

	for i := 0; i < k; i++ {
		var d int
		fmt.Scan(&d)

		for j := 0; j < d; j++ {
			var tmp int
			fmt.Scan(&tmp)

			tmpArr = append(tmpArr, tmp)
		}
	}

	for _, e := range tmpArr {
		_, ok := getUser[e]
		if !ok {
			getUser[e] = struct{}{}
			delDup = append(delDup, e)
		}
	}

	fmt.Println(n - len(delDup))
}


Measured memory_bytes: 2944
/// إِنَّ مَعَ الْعُسْرِ يُسْرًا
/// لَا أَبْرَحُ حَتَّىٰ أَبْلُغَ

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

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define LL unsigned long long
#define ll long long
#define LD double
#define HabdModeActive ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define S second
#define F first
#define PI acos(-1)
#define MAX 5000005
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);


int main() {
    HabdModeActive
   string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy";
    else if(s=="Cloudy")
        cout<<"Rainy";
    else
        cout<<"Sunny";


    return 0;
}


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

int main(){
  string str;
  cin >> str;
  set<char> st;
  for(int i=0;i<str.size();i++){
    st.insert(str[i]);
  }
  if(str.size()==st.size()){
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}

Measured memory_bytes: 256
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 1/12/2019, 8:52:56 PM
# Powered by Visual Studio Code
#

n = gets.to_i
h = gets.to_i
w = gets.to_i

puts (n - h + 1) * (n - w + 1)


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int a,b,q;
    cin>>a>>b>>q;
    vector<ll> s(a+2),t(b+2),x(q);
    reps(i,a) cin>>s.at(i);
    reps(i,b) cin>>t.at(i);
    rep(i,q) cin>>x.at(i);
    
    s.at(0)=-10000000000; s.at(a+1)=100000000000;
    t.at(0)=-10000000000; t.at(b+1)=100000000000;
    
    rep(i,q){
        auto itrs=lower_bound(all(s),x.at(i));
        int sh=itrs-s.begin();
        auto itrt=lower_bound(all(t),x.at(i));
        int tm=itrt-t.begin();
        
        ll  ans=1000000000000;
        rep(j,2){
            rep(k,2){
                ans=min(ans,abs(x.at(i)-s.at(sh-j))+abs(s.at(sh-j)-t.at(tm-k)));
                ans=min(ans,abs(x.at(i)-t.at(tm-k))+abs(s.at(sh-j)-t.at(tm-k)));
            }
        }
        
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3712
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> b(n+1);
  b[0] = b[n] = 100000;
  rep(i,n-1) cin >> b[i+1];

  ll ans = 0;
  rep(i,n) {
    ans += min(b[i],b[i+1]);
  }
  cout << ans << endl;
}


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

using namespace std;

#define int long long
#define ar array
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

#define F_OR(i, a, b, s) for (int i=(a); (s)>0?i<(b):i>(b); i+=(s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...) F_ORC(__VA_ARGS__)(__VA_ARGS__)
#define EACH(x, a) for (auto& x: a)

template<class T>
bool umin(T &a, const T &b) {
    return b < a ? a = b, 1 : 0;
}

template<class T>
bool umax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

template<class A>
void read(vt<A> &v);

template<class A, size_t S>
void read(ar<A, S> &a);

template<class T>
void read(T &x) {
    cin >> x;
}

void read(double &d) {
    string t;
    read(t);
    d = stod(t);
}

void read(long double &d) {
    string t;
    read(t);
    d = stold(t);
}

template<class H, class... T>
void read(H &h, T &... t) {
    read(h);
    read(t...);
}

template<class A>
void read(vt<A> &x) {
    EACH(a, x)read(a);
}

template<class A, size_t S>
void read(array<A, S> &x) {
    EACH(a, x)read(a);
}

string to_string(char c) {
    return string(1, c);
}

string to_string(bool b) {
    return b ? "true" : "false";
}

string to_string(const char *s) {
    return string(s);
}

string to_string(string s) {
    return s;
}

string to_string(vt<bool> v) {
    string res;
    FOR(sz(v))res += char('0' + v[i]);
    return res;
}

template<size_t S>
string to_string(bitset<S> b) {
    string res;
    FOR(S)res += char('0' + b[i]);
    return res;
}

template<class T>
string to_string(T v) {
    bool f = 1;
    string res;
    EACH(x, v) {
        if (!f)
            res += ' ';
        f = 0;
        res += to_string(x);
    }
    return res;
}

template<class A>
void write(A x) {
    cout << to_string(x);
}

template<class H, class... T>
void write(const H &h, const T &... t) {
    write(h);
    write(t...);
}

void print() {
    write("\n");
}

template<class H, class... T>
void print(const H &h, const T &... t) {
    write(h);
    if (sizeof...(t))
        write(' ');
    print(t...);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n) {
    v = vt<T>(n, x);
}

template<class T, class U>
void vti(vt<T> &v, U x, size_t n, size_t m...) {
    v = vt<T>(n);
    EACH(a, v)vti(a, x, m);
}

void solve() {
    int n;
    read(n);
    vt<int> a(n);
    read(a);
    
    int ans = 0;
    int val = 0;
    FOR(n) {
        val = a[val] - 1;
        ans++;
        if (val == 1) {
            print(ans);
            return;
        }
    }
    print(-1);
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int tt = 1;
    //read(tt);
    FOR(tt) {
        //write("Case #", i + 1, ": ");
        solve();
        
    }
    
}



Measured memory_bytes: 3980
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007


int main(){
	long hit;
	scanf("%ld", &hit);
	long attack = 0;
	long count1 =0, count2;
	while(hit > 1){
		hit = (long)hit/2;
		count1++;
	}
	if(count1 == 0)  printf("1\n");
	else{
		attack = (long)powl(2, count1+1) -1;
		printf("%ld\n", attack);
	}

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
#define vs             v.size()
#define ss             s.size()
#define sot(v)       sort(v.begin(),v.end())
#define rev(v)       reverse(v.begin(),v.end())
#define pii             pair<int,int>
#define ll               long long
#define ull             unsigned long long
#define pb             push_back
#define mpp          make_pair
#define Okay         0

const int m = 10+10e7;
static ll int inf = 1e18;
using namespace std;


void  solve(){
      ll int k,n;
      int a,b,c;
      cin>>n>>k;
      vector<ull int>v(n),ans;

      for(int i=0;i<n;i++){
        cin>>v[i];
      }
      ull int an = 1;
      for(int i=0;i<k;i++){
        an += v[i];
      }
      ans.pb(an);
      for(int i = k;i<n;i++){
        an += v[i];
        an -= v[i-k];
        ans.pb(an);
      }
      for(int i =1;i<ans.size();i++){
        if(ans[i-1]<ans[i])cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
      }


}


int main() {
    Fast;

           solve();

    return Okay ;
}


Measured memory_bytes: 6872
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

int main(int argc, char *arv[]) {
  int h1, m1, h2, m2, k;
  struct tm tm1, tm2;
  time_t t1, t2;
  int r = 0;
  scanf("%d %d %d %d %d\n", &h1, &m1, &h2, &m2, &k);
  
  memset(&tm1, 0x00, sizeof(tm1));
  memset(&tm2, 0x00, sizeof(tm2));
  
  tm1.tm_year = 2000 - 1900;
  tm1.tm_mon = 0;
  tm1.tm_mday = 1;
  memcpy((void *)&tm2, (void *)&tm1, sizeof(tm1));
  
  tm1.tm_hour = h1;
  tm1.tm_min = m1;
  tm1.tm_sec = 0;
  t1 = mktime(&tm1);
  tm2.tm_hour = h2;
  tm2.tm_min = m2;
  tm2.tm_sec = 0;
  t2 = mktime(&tm2);
  
  t2 -= k * 60;
  
  if (t2 > t1) {
    r = (t2 - t1) / 60;
  }
  
  printf("%d\n", r);
  return(0);
}


Measured memory_bytes: 1776
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	c1 := count(as, 1)
	c2 := count(as, -1)
	fmt.Println(min(c1, c2))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func count(as []int, t int) int {
	cnt := 0
	sum := 0
	for i := 0; i < len(as); i++ {
		sum += as[i]
		if t == 1 && sum < 1 {
			cnt += 1 - sum
			sum = 1
		} else if t == -1 && sum > -1 {
			cnt += sum + 1
			sum = -1
		}
		t *= -1
	}

	return cnt
}


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

int N;
pair<int, int> workstime[100000];

int main() {

	int A, B;
	cin >> A >> B;
	int in_to = 1;
	int ans = 0;

	while (in_to < B) {
		in_to += A - 1;
		ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
    int n,k,x,y;
    cin >> n >> k >> x >> y;
  
  	int dif = max((n-k),0);
  	int k2 = min(n,k);

    cout << (k2*x)+(n-k2)*y;

    return 0;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split(' '))
A_ls = [0] + list(map(int, input().split(' ')))
for i in range(N):
    A_ls[i + 1] += A_ls[i]
B_ls = [0] + list(map(int, input().split(' ')))
for i in range(M):
    B_ls[i + 1] += B_ls[i]

a_cnt, b_cnt, rst = 0, M, 0
for a_cnt in range(N + 1):
    if A_ls[a_cnt] > K:
        break
    while A_ls[a_cnt] + B_ls[b_cnt] > K:
        b_cnt -=1
    rst = max(rst, a_cnt + b_cnt)
print(rst)

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

int main(void){
    int a, b, c, x, y, ans = 0;
    cin >> a >> b >> c >> x >> y;
    ans = min(x*a+y*b, min(max(x, y)*2*c, min(x*2*c+max(0, y-x)*b, y*2*c+max(0, x-y)*a)));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string S;

	cin >> S;
	
	int f = stoi(S.substr(0, 2));
	int l = stoi(S.substr(2, 2));
	string ans = "NA";

	if (1 <= f && f <= 12) {
		if (1 <= l && l <= 12) {
			ans = "AMBIGUOUS";
		} else {
			ans = "MMYY";
		}
	} else {
		if (1 <= l && l <= 12) {
			ans = "YYMM";
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 764
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N, A, B;
    cin >> N;

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        cin >> A >> B;
        cout << A + B << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	vector<int> primes;
	bool flag[50000];
	int ans[50001];
	fill(flag,flag+50000,0);
	fill(ans,ans+50001,0);
	for(int i = 2; i < 50000; ++i)
	{
		if(!flag[i])
		{
			primes.push_back(i);
			for(int j = 0; j < primes.size(); ++j)
			{
				int tmp=primes[j]+primes[primes.size()-1];
				if(tmp<50001) ans[tmp]++;
			}
			for(int j = i*2; j < 50000; j+=i)
			{
				flag[j]=true;
			}
		}
	}

	int n;
	while(cin>>n,n)
	{
		/*if(n%2==1)
		{
			cout<<0<<endl;
			continue;
		}
		int ans=0;
		for(int i = 0; i < primes.size(); ++i)
		{
			if(n<primes[i]) break;
			for(int j = i; j < primes.size(); ++j)
			{
				if(n<primes[j]) break;
				if(primes[i]+primes[j]==n) ans++;
			}
		}*/
		cout<<ans[n]<<endl;
	}
  return 0;
}

Measured memory_bytes: 1512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> x(N, 0);

  rep(i, K) {
    int d;
    cin >> d;
    rep(j, d) {
      int a;
      cin >> a;
      a--;
      x[a] = 1;
    }
  }

  int ans = 0;
  rep(i, N) {
    if (x[i] == 0) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int mod=1000000007;
int jc[200005]={1},ny[200005]={1};
int n,k; 
int Power(int x,int y,int mod) {
	int ret=1;
	while(y) {
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod,y>>=1;
	}
	return ret;
}
int C(int n,int m){
	return 1ll*jc[n]*ny[m]%mod*ny[n-m]%mod;
}
int F(int k){
	for(int i=1;i<=n;i++)jc[i]=1ll*jc[i-1]*i%mod,ny[i]=Power(jc[i],mod-2,mod);
	int ans=1;
	for(int i=1;i<=k;i++)ans=(ans+1ll*C(n,i)*C(n-1,i))%mod;
	return ans;
}
int main(){
	cin>>n>>k;
	if(k>=n-1)k=n-1;
	if(k==1)cout<<1ll*n*(n-1)%mod;
	else cout<<F(k)<<endl;
}


Measured memory_bytes: 1792