akhauriyash/Code-Regression huggingface dataset:
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;



int n,a[10000],b[501010][52],c[505050],ans,k,sum[10000],cnt=1,t=1;

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

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

cin >> n >> k;
for(int i=1;i<=n;i++){
       cin >> a[i];
       sum[i]=sum[i-1]+a[i];
}
for(int i=1;i<n+1;i++){
       for(int j=i;j<n+1;j++){
              c[cnt++]=sum[j]-sum[i-1];
       }
}
//cout << cnt << endl;
for(int i=1;i<cnt;i++){
       for(int j=0;j<=50;j++){
              if(c[i]&(t<<j)){
                     b[i][j]=1;
              }
       }
}
for(int j=50;j>=0;j--){
       int cur=0;
       for(int i=1;i<cnt;i++){
              if(c[i])
              cur+=b[i][j];
       }
       if(cur>=k){
              ans+= (t<<j);
              //cout << j << endl;
              for(int i=1;i<cnt;i++){
                     if(c[i]){
                            if(!b[i][j])c[i]=0;
                     }
              }
       }
}

cout << ans << endl;

return 0;}
///....


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

long long power(long long a, long long b) {
    //a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
    }
   
    
   int binomial(int n, int k)  
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomial(n - 1, k - 1) + binomial(n - 1, k);  
}   

bool Sieve(ll int n) 
{ 
    
    bool prime[n+100000]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    return prime[n];
}
  
    
vector<long long> factor;  
vector<long long>prime(long long n) {
 for (long long d = 2; d * d <= n; d++) {
     while (n % d == 0) {
         factor.push_back(d);
            n /=d;
        }
    }
 if (n > 1)
    factor.push_back(n);
    return factor;
}




//It reurns Fn,Fn+1
pair<int, int> fib (int n) {
    if (n == 0)
        return {0, 1};

    auto p = fib(n >> 1);
    int c = p.first * (2 * p.second - p.first);
    int d = p.first * p.first + p.second * p.second;
    if (n & 1)
        return {d, c + d};
    else
        return {c, d};
}


  
int main() {
       string s;
       cin>>s;
       string p=s.substr(0,3);
       cout<<p<<endl;
}





Measured memory_bytes: 3600
use std::io;
use std::str::FromStr;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).ok();
    let mut it = buf.split_whitespace()
        .map(|n| i64::from_str(n).unwrap());
    let (a, b) = (it.next().unwrap(), it.next().unwrap());
    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible");
    } else {
        println!("Impossible");
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream> 
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;

#define assert_range(x,a,b) assert((a) <= (x) and (x) <= (b))
using ll = long long;
const int INF = 1e9;

int main() {
    ios_base::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<int> dp(n);
    for (int i = 1; i < n; ++i) {
        dp[i] = INF;
        for (int j = 1; j <= k and i-j >= 0; ++j) {
            dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
        }
    }
    cout << dp[n-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int n, r; cin >> n >> r;
	if (10 <= n)cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    Map<Character, Integer> map = new HashMap<>();
    map.put('r', sc.nextInt());
    map.put('s', sc.nextInt());
    map.put('p', sc.nextInt());
    char[] t = sc.next().toCharArray();
    sc.close();

    int count = 0;
    for (int i = 0; i < t.length; i++) {
      if (i >= k && t[i] == t[i - k]) {
        t[i] = '_';
      } else {
        count += win(t[i], map);
      }
    }
    System.out.println(count);
  }
  // 6 + 8 + 0 + 7 + 6 = 27

  private static int win(char c, Map<Character, Integer> map) {
    switch (c) {
      case 'r':
        return map.get('p');
      case 's':
        return map.get('r');
      case 'p':
        return map.get('s');
      default:
        return 0;
    }
  }
}

Measured memory_bytes: 28460
#include<stdio.h>
#define SIZE 2001

char resultTable[SIZE];
int n,q,elems[20];

void calc(int sum, int index){
    if(index == n){
        if(sum >= 1 && sum <= 2000){
            resultTable[sum] = 'y';
        }
    }else{
        calc(sum + elems[index], index + 1);
        calc(sum, index + 1);
    }
}

int main(){
    for(int i=0; i < SIZE; i++) resultTable[i] = 'n';
    
    scanf("%d", &n);
    for(int i=0; i < n; i++) scanf("%d", &elems[i]);
    calc(0,0);
    
    scanf("%d", &q);
    
    int temp;
    for(int i=0; i < q; i++){
        scanf("%d", &temp);
        if(resultTable[temp] == 'y'){
            printf("yes\n");
        }else{
            printf("no\n");
        }
    }
}


Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)   //test cases
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define error(x) fixed<<setprecision(x) //cout<<error(5)<<someDouble    -> example - 3.14159
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll i = 0; i < n; i++)    cin>>a[i];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
    boost;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

/*
    Author: 
                                                _/                      
       _/_/_/_/    _/_/    _/_/_/      _/_/    _/  _/    _/    _/_/_/   
          _/    _/_/_/_/  _/    _/  _/    _/  _/  _/    _/  _/_/        
       _/      _/        _/    _/  _/    _/  _/  _/    _/      _/_/     
    _/_/_/_/    _/_/_/  _/    _/    _/_/    _/    _/_/_/  _/_/_/        
                                                           
    National Institute of Technology, Rourkela (2018-2022, EE)
*/

ll n, a[MX];
int main(){
    cin>>n; for(ll i = 1; i <= n; i++)  cin>>a[i];
    ll dp[2][n+1];    fill(dp, 0);
    for(ll l = n; l > 0; l--){
        for(ll r = 1; r <= n; r++){
            if(l > r)   continue;
            bool taro = ((r-l+1)&1) == (n&1);
            ll op1 = a[l] * (taro?1:-1) + dp[(l+1)%2][r];
            ll op2 = a[r] * (taro?1:-1) + dp[l%2][r-1];
            dp[l%2][r] = taro ? max(op1, op2) : min(op1, op2);
        }
    }
    cout<<dp[1][n];
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(void){
    for(;;){
    int a;
    int b;
    int c;
    int n;
    int at,bt,ct;
    int i[1002]={0};
    int j[1002]={0};
    int k[1002]={0};
    int r[1002]={0};

    int ans[1002];
    for (int o=0;o<1002;o++)ans[o]=2;
    cin >> at;
    cin >> bt;
    cin >> ct;
    if(at==0&&bt==0&&ct==0)break;
    cin >>  n;
    for(int o=0;o<n;o++){
        cin >> i[o];
        cin >> j[o];
        cin >> k[o];
        cin >> r[o];
        if(r[o]==1)ans[i[o]]=1,ans[j[o]]=1,ans[k[o]]=1;
        else if(r[o]==0){
            if(ans[i[o]]==0)ans[i[o]]=2;
            if(ans[j[o]]==0)ans[j[o]]=2;
            if(ans[k[o]]==0)ans[k[o]]=2;

        }
    }
    for(int o=0;o<n;o++){
        if(r[o]==0){
            if(ans[i[o]]==1&&ans[j[o]]==1&&ans[k[o]]!=1)ans[k[o]]=0;
            else if(ans[j[o]]==1&&ans[k[o]]==1&&ans[i[o]]!=1)ans[i[o]]=0;
            else if(ans[k[o]]==1&&ans[i[o]]==1&&ans[j[o]]!=1)ans[j[o]]=0;
            }
        }
    for(int o=1;o<=at+bt+ct;o++){

    cout <<ans[o]<<endl;
    }

    }
	return 0;



}

Measured memory_bytes: 1176
N,K = map(int, input().split())
L = [0]*N
R = [0]*N
DP = [0]*(N+10)
DP[0] = 1
SDP = [0]*(N+10)
SDP[1] = 1
MOD=998244353
for i in range(K):
    L[i],R[i] = map(int, input().split())

for i in range(1,N):
    for j in range(K):
        l = max(0,i-R[j])
        r = max(0,i-L[j]+1)
        DP[i] += SDP[r] - SDP[l]
    SDP[i+1] = (SDP[i] + DP[i])%MOD
print(DP[N-1]%MOD)


Measured memory_bytes: 74692
#include <bits/stdc++.h>
using namespace std;
//解説AC
int main() {
  int n; cin >>n;
  vector<int>a(n),b(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int count=0;
  int x=n;
  while(x>0){
    for(int i=x-1;i>=0;i--){
      //cout<<i<<" "<<a[i]<<endl;
      if(a[i]==i+1){
        b[count]=a[i];
        count++;
        a.erase(a.begin()+i);
        break;
      }
    }
    if(count==n)break;
    x--;
  }
  if(count!=n){
    cout<<-1<<endl;
    return 0;
  }
  for(int i=count-1;i>=0;i--){
    cout<<b[i]<<endl;
  }
  return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int mknum = a*100 + b*10 + c;
    if (mknum%4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}

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

int main() {

  string A, B, C; cin >> A >> B >> C;
  int a, b;
  a = A.size() - 1;
  b = B.size() - 1;
  if (A.at(a) == B.at(0) && B.at(b) == C.at(0)) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
    
}


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

/*
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/



//************** StrAnge.R *********************

#define ll              long long int
#define ull             unsigned long long
#define ld              long double
#define lll             __int128
#define vi              vector<int>
#define vl              vector<ll>
#define vvi             vector<vector<int> >
#define pii             pair<int,int>
#define piii            pair<int,pair<int,int> >
#define pll             pair<ll,ll>
#define vii             vector<pii>

#define sz(v)           ((int)(v).size())
#define all(s)          s.begin(),s.end()
#define allr(s)         s.rbegin(),s.rend()
#define unq(c)          (sort(all(c)), c.resize(distance(c.begin(),unique(all(c)))))
#define get_pos(c,x)    (lower_bound(all(c),x)-c.begin())

#define MS0(v)          memset((v), 0, sizeof((v)))
#define MS1(v)          memset((v), -1, sizeof((v)))
#define LEN(v)          strlen(v)

#define MP              make_pair
#define pb              push_back
#define pob             pop_back
#define ff              first
#define ss              second
#define sc              scanf
#define pf              printf
#define endl            "\n"

#define TEST_CASE       int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define PRINT_CASE      printf("Case %d: ",cs)

#define vpf(v)          for(int i=0;i<v.size();i++){cout<<v[i];if(i!=v.size()-1)cout<<" ";else cout<<"\n";}
#define vsc(v)          for(int i=0;i<v.size();i++)cin>>v[i];

#define REP(i, n)       for (int i = 0; i < (n); i++)
#define REPP(i, a, b)   for (int i = (a); i < (b); i++)
#define FOR(i, a, b)    for (int i = (a); i <= (b); i++)
#define FORS(i, s)      for (int i = 0; s[i]; i++)

#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fileio          freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)

#define intlim          2147483648
#define infinity        (1LL<<50)
#define intmx           INT_MAX
#define PI              3.14159265358979323846264338327950L // acos(-1.0)

#define gcd(a, b)       __gcd(a, b)
#define lcm(a, b)       ((a)*((b)/gcd(a,b)))


int on_bit(int N,int pos){return N = N | (1<<pos);}
int off_bit(int N,int pos){return N = N & ~(1<<pos);}
bool check_bit(ll N,int pos){return (bool)(N & (1<<pos));}


#define start_clock     clock_t tStart = clock()
#define end_clock       printf("\n>>Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC)

template<class T>inline bool read(T &x){int c=getchar();int sgn=1;while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; x*=sgn; return ~c;}


//******************* my code starts here **********************************

bool cmp(pair<string, int> x, pair<string, int> y) {
    if(x.ss == y.ss) return x.ff < y.ff;
    return x.ss > y.ss;
}

int main(){

    int n; cin >> n; vi v(n); vsc(v); unq(v); if(v.size() != n) cout << "NO\n"; else cout << "YES\n";
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int ans = 1001001001;
    rep(i, n-k+1) {
        int l = x[i], r = x[i+k-1];
        ans = min(ans, min(abs(l-r)+abs(l), abs(l-r)+abs(r)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
ll C(ll k,ll n)
{
    ll pos=1;
    for(ll i=0;i<k;i++)
    {
        pos*=(n-i);
        pos/=(i+1);
    }
    /*for(ll i=0;i<k;i++)
        pos/=(i+1);*/
    return pos;
}
int main()
{
    ll n,m,ans=0,pos=0,x,cnt=0;
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2==0) ans++;
        else pos++;
    }
    if(m==0)
    {
        cnt=1;
        ll nn=0,mm=0;
        for(ll i=1;i<=ans;i++)
            nn+=C(i,ans);
        for(ll i=2;i<=pos;i+=2)
            mm+=C(i,pos);
        cnt+=nn+mm+(nn*mm);
    }
    else
    {
        ll nn=0,mm=0;
        for(ll i=1;i<=ans;i++)
            nn+=C(i,ans);
        for(ll i=1;i<=pos;i+=2)
            mm+=C(i,pos);
        cnt+=(mm+(mm*nn));
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

struct Point {
	i64 x, y;
	
	Point operator-(const Point r) const {
		return Point{x - r.x, y - r.y};
	}
	
	bool operator<(const Point r) const {
		if(x == r.x) return y < r.y;
		return x < r.x;
	}
};

double abs(const Point a) {
	return std::sqrt(a.x * a.x + a.y * a.y);
}

double cross(const Point a, const Point b) {
	return a.x * b.y - a.y * b.x;
}

double dot(const Point a, const Point b) {
	return a.x * b.x + a.y * b.y;
}

double angle(const Point a, const Point b) {
	return acos(-dot(a, b) / abs(a) / abs(b));
}

std::vector<Point> convexHull(std::vector<Point> p) {
	int n = p.size(), k = 0;
	if(n >= 3) {
		sort(begin(p), end(p));
		std::vector<Point> ch(2 * n);
		for(int i = 0; i < n; ch[k++] = p[i++]) {
			while(k >= 2 and cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
		}
		for(int i = n - 2, t = k + 1; i >= 0; ch[k++] = p[i--]) {
			while(k >= t and cross(ch[k - 1] - ch[k - 2], p[i] - ch[k - 1]) < 0) --k;
		}
		ch.resize(k - 1);
		return ch;
	} else {
		return p;
	}
}

int main() {
	int n; cin >> n;
	std::vector<Point> vec(n);
	std::map<Point, int> mp;
	for(int i = 0; i < n; i++) {
		i64 a, b; cin >> a >> b;
		
		vec[i] = Point{a, b};
		mp[vec[i]] = i;
	}
	
	auto ch = convexHull(vec);
	std::vector<double> ans(n, 0);
	const double Pi = std::acos(-1);
	for(int i = 0; i < ch.size(); i++) {
		Point u = ch[(i + ch.size() - 1) % ch.size()] - ch[i];
		Point v = ch[(i + 1) % ch.size()] - ch[i];
		ans[mp[ch[i]]] = angle(u, v) / 2.0 / Pi;
	}
	
	for(auto v : ans) cout << std::fixed << std::setprecision(10) << v << endl;
	return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
    ost<<"{"<<p.first<<","<<p.second<<"}";
    return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
    ost<<"{";
    for(int i=0;i<v.size();i++){
        if(i)ost<<",";
        ost<<v[i];
    }
    ost<<"}";
    return ost;
}

inline int topbit(unsigned long long x){
    return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
    return __builtin_parity(x);
}

signed main(){
    int N;cin>>N;
    int mi=1001001001;
    int ans=0;
    rep(i,N){
        int p;cin>>p;
        chmin(mi,p);
        if(mi==p)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 998244353;
const int N = 4e3 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

ll mul(ll a, ll b){
	return (a*b) % Mod;
}
ll p2[N], C[N][N];

ll Solve(ll n, ll s){
	if(n == 0 && s == 0) return 1;
	if(s < 0) return 0;
	if(n <= 0) return 0;
	return C[s + n - 1][s];
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	p2[0] = 1;
	for(int i = 1; i < N; i++) p2[i] = (p2[i - 1] << 1) % Mod;
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= i; j++) C[i][j] = (j ? C[i - 1][j] + C[i - 1][j - 1] : 1) % Mod;
	}
	ll n, k;
	cin >> k >> n;
	for(int i = 2; i <= k+k; i++){
		ll res = 0;
		if(i & 1){
			ll t = (i <= k + 1 ? i / 2 : (k + k + 2 - i) / 2);
			for(int y = 0; y <= t; y++){
				res += mul(mul(p2[y], C[t][y]), Solve(k - t - t + y, n - y));
			}
		} else {
			ll t = (i <= k + 1 ? i / 2 : (k + k + 2 - i) / 2) - 1;
			for(int y = 0; y <= t; y++){
				res += mul(mul(p2[y], C[t][y]), Solve(k - t - t - 1 + y, n - y - 1));
				res += mul(mul(p2[y], C[t][y]), Solve(k - t - t - 1 + y, n - y));	
			}
		}
		cout << res%Mod << '\n';
	}
	return 0;
}


Measured memory_bytes: 124288
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

double abs_d(double a) {
	if (a > 0)
		return a;
	else
		return -a;
}

int main(int argc, char *argv[])
{
	int i;
	int n, t, a;
	int ret;
	double diff;
	cin >> n >> t >> a;
    double h[n];

	for (i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (i = 0; i < n; i++) {
		h[i] = (double)t - h[i] * 0.006; 
	}

	diff = abs_d(h[0] - (double)a);
	ret = 1;

	for (i = 1; i < n; i++) {
		if (abs_d(h[i] - (double)a) < diff) {
			ret = i + 1;
			diff = abs_d(h[i] - (double)a);
		}
	}

	cout << ret << endl;
	
	return 0;
}


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

int main(){
  int k, a, b;
  
  cin >> k;
  cin >> a >> b;
  
  for(int i = a; i < b+1; i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  
  cout << "NG" << endl;
  
  return 0;
}

Measured memory_bytes: 3580
void main() {
    int[] tmp = readln.split.to!(int[]);
    int n = tmp[0], m = tmp[1], x = tmp[2];
    int[] a = readln.split.to!(int[]);
    a ~= x;
    a.sort!"a < b";
    int ind = a.countUntil(x).to!int;
    min(ind, m - ind).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
int N;
VPII G[MAX];
int color[MAX];

void dfs(int cur, int par, int cost) {
    if (cost) {
        color[cur] = color[par] ^ 1;
    } else {
        color[cur] = color[par];
    }

    FORE(e, G[cur]) if (e.first != par) {
        dfs(e.first, cur, e.second);
    }
}

int main(void) {
    memset(color, -1, sizeof(color));
    cin >> N;
    REP(i, N - 1) {
        int u, v, w;
        cin >> u >> v >> w;
        G[u - 1].EB(v - 1, w % 2);
        G[v - 1].EB(u - 1, w % 2);
    }

    color[0] = 0;
    FORE(e, G[0]) {
        dfs(e.first, 0, e.second);
    }

    REP(i, N) {
        cout << color[i] << "\n";
    }
}


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

using namespace std;

int main()
{
  int A, B;
  char op;
  
  cin >> A >> op >> B;
  
  if(op == '+'){
    cout << A + B << endl;
  }
  else if(op == '-'){
    cout << A - B << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

typedef struct{
	double x,y;
}Point;
 
int factorial(int n){
	int fact=1;
	for(int i=2; i<=n; i++){
		fact = fact * i;
	}
	return fact;
}

int main(void){
	int N;
	int i,j;
	double p2p,len;
	Point p[8];

	scanf("%d",&N); 
	for(i=0; i<N; i++)
		scanf("%lf %lf",&p[i].x,&p[i].y );
	int c = factorial(N-1)*2;
	p2p=0; len=0;
	for(i=0; i<N; i++){
		for(j=i+1; j<N; j++){
			double x=(p[i].x)-(p[j].x);
			double y=(p[i].y)-(p[j].y);
			double a=x*x, b=y*y; 
			p2p = sqrt(a+b);
			len += p2p*c;
		}
	}
	len = len / factorial(N);
	printf("%lf\n",len );
}

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

int main() {
  long long int N;
  cin >> N;
  long long int ans = 0;
  for (long long int X = 1; X * X < N; X++) {
    if (N % X != 0) continue;
    
    long long int M = N / X - 1;
    if (M >= 0 && X < M) ans += M;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=2e5+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
char ch[MAXN];
int cnt[MAXN];
int main()
{
	int n,p;
	cin>>n>>p;
	cin>>(ch+1);
	ll ans=0;
	if(p==2||p==5){
		for(int i=1;i<=n;i++){
			if((ch[i]-'0')%p==0)ans+=i;
		}
		cout<<ans<<endl;
		return 0;
	}
	int t=1,x=0;
	cnt[0]=1;
	for(int i=n;i>=1;i--){
		x=(x+(ch[i]-'0')*t)%p;
		
		ans+=cnt[x];
		cnt[x]++;

		t=t*10%p;
	}
	cout<<ans<<endl;
    return 0;
}
/*

*/


Measured memory_bytes: 512
void main() {
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], k = tmp[1];
    writeln(k * (k - 1) ^^ (n - 1));
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

#define ff first
#define ss second
#define endl '\n'

double d[301][301][301];

double func(int one, int two, int three, int n)
{
	double count = one+two+three;
	if (d[one][two][three] != -1)
		return d[one][two][three];
	else
	{
		if (count == 0)
			return 0;

		double ans = n/count, temp = 0;

		if (one > 0)
			temp += one*func(one-1, two, three, n);

		if (two > 0)
			temp += two*func(one+1, two-1, three, n);

		if (three > 0)
			temp += three*func(one, two+1, three-1, n);

		d[one][two][three] = ans+temp/count;
		return ans+temp/count;
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	for(int i = 0; i < 301; i++)
	{
		for(int j = 0; j < 301; j++)
		{
			for(int k = 0; k < 301; k++)
			{
				d[i][j][k] = -1;
			}
		}
	}
	int n = 0, f[4] = {0, 0, 0, 0}, in;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> in;
		f[in]++;
	}
	cout << fixed << setprecision(10) << func(f[1], f[2], f[3], n) << endl;


}

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

int A, B, C, K;

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

	for (int i = 0; i < K; ++i) {
		if (A >= B && A >= C) A *= 2;
		else if (B > A && B >= C) B *= 2;
		else C *= 2;
	}
	printf("%d\n", A+B+C);
}


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

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

    int N;
    cin >> N;

    vector<int> A(N);
    rep(i,0,N-1) {
        int tmp;
        cin >> tmp;
        A[tmp - 1]++;
    }

    for (auto &&a : A) {
        cout << a << endl;
    }
}


Measured memory_bytes: 3992
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    a, b, c, d = MAP()

    l = c * d // gcd(c, d)
    a -= 1

    kukan1 = b - b // c - b // d + b // l
    kukan2 = a - a // c - a // d + a // l

    print(kukan1 - kukan2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long long>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  
  long long B = 0;
  long long C = 0;
  for (int i = 0; i < N; i++) {
    if (B == 0 || C == 0){
      if (i != N-1){
        if (A.at(i) == A.at(i+1)){
          if (B == 0){
            B = A.at(i);
          }
          else {
            C = A.at(i);
          }
          A.at(i) = 0;
          A.at(i+1) = 0;
        }
      }
    }
    else {
      long long ans = B*C;
      cout << ans << endl;
      return 0;
    }
  }
  cout << 0 << endl;
}
          
          
        
  
      
      
 

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c, n, x, y;
  string s, t, u;
  cin >> t >> s >> u;
  cout << "A" << s[0] << "C";
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N;
    vector<ll> times(N);
    for (auto& t : times)
        cin >> t;

    sort(times.begin(), times.end());
    
    ll ans = times[times.size()-1];
    if (times.size() != 1) {
        for (int i = times.size()-2; i >= 0; --i) {
            if (ans % times[i] != 0)
                ans *= (times[i] / __gcd(ans, times[i]));
        }
    }

    cout << ans << endl;
    
    return 0;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI H(N); REP(i,N) cin >> H[i];
    H[0]--;
    REP(i,N-1){
        if(H[i] < H[i+1]){
            H[i+1]--;
        }
        if(H[i] > H[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

using namespace std;

int main(){
	ll x,y;
	cin >> x >> y;
	ll hoge = x;
	int cnt=0;
	while(hoge <= y){
		cnt++;
		hoge *= 2;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
object Main extends App {
	val N = scala.io.StdIn.readInt
	val A = scala.io.StdIn.readLine.split(" ").map(_.toLong).sorted

	var answer = 0
	var temp = 0L
	var flag = 0L

	for(i<- A){
		if(temp != i){
			if(flag > 0) answer = answer + (temp - flag).toInt
			temp = i
			flag = i - 1L
		}else{
			if(flag <= 0) answer = answer + 1
			else flag = flag - 1
		}

	}

	if(flag > 0){
		println(answer + (temp - flag).toInt)
	}else{
		println(answer)
	}

	
}


Measured memory_bytes: 49204
N = int(input())
ans = 1
if (N >= 64):
    ans = 64
elif (N >= 32):
    ans = 32
elif (N >= 16):
    ans = 16
elif (N >= 8):
    ans = 8
elif (N >= 4):
    ans = 4
elif (N >= 2):
    ans = 2
print(ans)


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


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


























































Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
N = int(input())
dic = {}
c = 0
for _ in range(N):
    s = input()
    if s not in dic.keys():
        dic[s] = 1
        c += 1
print(c)

Measured memory_bytes: 32756
// inputに入力データ全体が入る
function Main(input) {
  n = parseInt(input);
  var priArray = getPrimeFactors(n);
  var summary = [];
  var tmp = 0 ;
  for (let i=0;i<priArray.length;i++){
    if (priArray[i] == tmp){
      summary[summary.length - 1] ++;
    }else{
      summary.push(1);
      tmp = priArray[i];
    }
  }
  var sum = 0
  for (let i=0;i<summary.length;i++){
    var ok = 1;
    var cnt = 1;
    while (ok === 1){
      if (cnt * (cnt+1) / 2 > summary[i]){
        ok = 0;
        sum += cnt -1;
      }else{
        cnt ++;
      }
    }
  }
  console.log(sum);
}
  
const getPrimeFactors = n => {
  if (n < 2) return [];
  if (n === 2 || n === 3 || n === 5) return [n];
  if (n % 2 === 0) return [2, ...getPrimeFactors(n/2)];
  if (n % 3 === 0) return [3, ...getPrimeFactors(n/3)];
  if (n % 5 === 0) return [5, ...getPrimeFactors(n/5)];
  let prime = 7;
  let step = 4;
  const limit = Math.sqrt(n);
  while (prime <= limit) {
    if (n % prime === 0) return [prime, ...getPrimeFactors(n/prime)];
    prime += step;
    step = 6 - step;
  }
  return [n];
}

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


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

enum mod = 10L^^9 + 7;

void main() {
    int n;
    scan(n);
    auto h = readln.split.to!(int[]);

    auto dp = new long[](n + 1);
    dp[1] = abs(h[1] - h[0]);

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

    writeln(dp[n-1]);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 4256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
int main(){
    long long n,a,b,s1,s2;
    cin>>n>>a>>b;
    if(a>b){printf("0");return 0;}
    if(n==1){
        if(a==b) printf("1");
        else printf("0");
        return 0;
    }
    if(n==2){printf("1");return 0;}
    s1=(n-1)*a+b;
    s2=(n-1)*b+a;
    cout<<s2-s1+1;
    return 0;
}


Measured memory_bytes: 256
// AOJ 3057 First Kiss
// 2019.3.15 bal4u

#include <stdio.h>
#include <stdlib.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int main()
{
	int N, D, ans = 0;
	
	N = in(), D = in() + 1;
	while (N--) ans ^= (in() - 1) % D;
	puts(ans ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#define eol '\n';
using namespace std;

class Node {
public:
  int id;
  int p;
  int s;
  int c;
  int d;
  int h;
  string t;
  int l;
  int r;
  Node():id(-1),p(-1),s(-1),c(-1),d(-1),h(0){};
};

Node* tree;

void down(int id, int depth) {
  Node *node = &tree[id];
  node->d = depth;
  
  if (node->l != -1) down(node->l, depth+1);
  if (node->r != -1) down(node->r, depth+1);
}

void up(int id, int height) {
  Node *node = &tree[id];
  node->h = max(node->h, height);
  if (node->p != -1) up(node->p, height+1);
}

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

  int n,id,l,r;
  Node *node, *child;
  cin >> n;
  tree = new Node[n];

  for (int i = 0; i < n; i++) {
    cin >> id >> l >> r;

    node = &tree[id];
    node->id = id;
    node->l = l;
    node->r = r;
    
    // child
    int c = 0;
    if (l != -1) {
      c++;

      child = &tree[l];
      child->p = id;
      child->s = r;
    }
    if (r != -1) {
      c++;

      child = &tree[r];
      child->p = id;
      child->s = l;
    }
    node->c = c;
  }

  for (int i = 0; i < n; i++) {
    node = &tree[i];
    if (node->p == -1) {
      node->t = "root";
      down(i, 0);
    } else if (node->c == 0) {
      node->t = "leaf";
      up(i, 0);
    } else {
      node->t = "internal node";
    }
  }

  for (int i = 0; i < n; i++) {
    node = &tree[i];
    
    cout << "node " << node->id 
         << ": parent = " << node->p 
         << ", sibling = " << node->s 
         << ", degree = " << node->c
         << ", depth = " << node->d
         << ", height = " << node->h
         << ", " << node->t
         << eol;
  }

  return 0;
}

Measured memory_bytes: 1200
n=gets.to_i

s = gets.chomp.chars
t = gets.chomp.chars


k=0
0.upto(n-1){|i|
    if s==t
        p n+k;exit
    end
    if s[1..-1]==t[0..-2]
        p n+k+1;exit
    end
    s.shift
    t.pop
    k+=1
}
p k


Measured memory_bytes: 1788
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n = gets.to_i

# def f(n)
#   count = 0
  # 1.upto(n-2) do |x|
  #   1.upto(n-2) do |y|
  #     1.upto(n-2) do |z|
  #       if x*x+y*y+z*z+x*y+y*z+z*x == n
  #         count += 1
  #       end
  #     end
  #   end
  # end
#   hei = Math.sqrt(n).floor
#   1.upto(hei) do |x|
#     zan = n - x*x
#     don = Math.sqrt(zan).floor 
#     1.upto(don) do |y|
#       ban = zan - y*y
#       bin = Math.sqrt(ban).floor 
#       1.upto(bin) do |z|
#         if x*x+y*y+z*z+x*y+y*z+z*x == n
#           count += 1
#         end
#       end
#     end
#   end
#   return count 
# end

# n.times do |i|
#   puts "#{i} #{f(i+1)}"
# end

k = 100

dp = Array.new(n,0)

1.upto(100) do |x|
  1.upto(100) do |y|
    1.upto(100) do |z|
      bbb = x*x+y*y+z*z+x*y+y*z+z*x
      if bbb <= n
        dp[bbb-1] += 1
      end
    end
  end
end

dp.each do |d|
  puts d
end

Measured memory_bytes: 14240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		while(true) {
			boolean b =true;
			for (int i=2;i*i<x;i++) {
				if (x%i==0) {
					b = false;
					break;
				}
			}
			if (b==true) {
				System.out.println(x);
				return ;
			}
			x++;
		}
	}
}

Measured memory_bytes: 35380
N, W = [int(x) for x in input().split()]

dp = [[0] * (W + 1) for x in range(N + 1)]

for i in range(1, N + 1):
    v, w = [int(x) for x in input().split()]
    for j in range(W + 1):
        if j < w:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)

print(dp[N][W])



Measured memory_bytes: 25488
#include <bits/stdc++.h>
using namespace std;
int n,p[20009],a[20009],b[20009];
int main(){
    cin>>n;
    for(int i=0;i++<n;){
        cin>>p[i];
        a[i]+=i*30000;
        b[n-i+1]+=i*30000;
        b[p[i]]+=i;
    }
    for(int i=0;i++<n;){
        if(i!=1)cout<<" ";
        cout<<a[i];
    }cout<<endl;
    for(int i=0;i++<n;){
        if(i!=1)cout<<" ";
        cout<<b[i];
    }cout<<endl;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<long, long>> x;
    for(int i=0; i<n; i++) {
        int a, b;
        cin >> a >> b;
        x.push_back(make_pair(a, b));
    }
    sort(x.begin(), x.end(), 
        [](const pair<long, long> &x, const pair<long, long> &y) { return x.first < y.first; }
    );
     
    long price = 0;
    int i = 0;
    while(m > 0) {
        pair<long, long> current_shop = x[i];
        while(current_shop.second > 0 && m > 0) {
           price += current_shop.first;
           current_shop.second--;
           m--;
        }
        i++;
    }
    cout << price << endl;

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}
//int sum_digits(int num) {
//    int rtn = 0;
//    string num_str = to_string(num);
//    for(int i=0; i<num_str.size(); i++) {
//        rtn += num_str[i] - '0';
//    }   
//    return rtn;
//}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define mod 1000000007;
using namespace std;
vector<ll>adj[1000000];
bool v[1000000];
ll arr[1000000];
queue<ll>num;
void bfs(ll s,vector<ll>adj[])
{
    if(v[s]==true)
    return;
    v[s]=true;
    for(ll i=0;i<adj[s].size();i++)
    {
        if(v[adj[s][i]]==0 && arr[adj[s][i]]==0)
        {
            arr[adj[s][i]]=s;
            num.push(adj[s][i]);
        }
    }
    num.pop();
    if(num.size()==0)
    return;
    bfs(num.front(),adj);
}
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    ll x,y;
    for(ll i=1;i<=m;i++)
    {
        cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    num.push(1);
    bfs(1,adj);
    for(ll i=2;i<=n;i++)
    {
        if(v[i]==0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<"\n";
    for(ll i=2;i<=n;i++)
    cout<<arr[i]<<"\n";

    

    return 0;
}

Measured memory_bytes: 34296
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    // string s[2];
    // cin >> s[0] >> s[1];
    // cout << (s[0][0] == s[1][2] && s[0][1] == s[1][1] && s[0][2] == s[1][0] ? "YES" : "NO") << endl;

    int n;
    cin >> n;
    int x = sqrt(n);
    cout << x * x << endl;

    return 0;
}


Measured memory_bytes: 256