akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int H=sc.nextInt();
		int W=sc.nextInt();
		int cnt=0;

		for(int i=0;i<N; i++) {
			int a=sc.nextInt();
			int b=sc.nextInt();
			if(a>=H && b>=W) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
ll inf = LLONG_MAX;
long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll a, b;
  cin >> a >> b;
  for (ll i = 0; i < 1000000000; i++) {
    if (max(a - i, i - a) == max(b - i, i - b)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>

using namespace std;

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

    vector<vector<int> > switches;
    for (int i = 0; i < M; ++i) {
        int sz;
        cin >> sz;
        vector<int> v(sz, 0);
        for (int j = 0; j < sz; ++j) {
            cin >> v[j];
        }
        switches.push_back(v);
    }
    vector<int> p(M, 0);
    for (int i = 0; i < M; ++i) {
        cin >> p[i];
    }

    int ans = 0;
    for (int i = 0; i < (1 << N); ++i) {
        bitset<10> bit(i);
        bool allOn = true;
        for (int m = 0; m < M; ++m) {
            const vector<int>& switch_m = switches[m];
            int countOn = 0;
            for (int n = 0; n < switch_m.size(); ++n) {
                if (bit[switch_m[n] - 1]) {
                    ++countOn;
                }
            }
            allOn &= (countOn % 2 == p[m]);
        }
        if (allOn) {
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
 
int exsum(int x){
    int ret=0;
    while(x>0){
        ret +=x%10;
        x/=10;
    }
    return ret;
}


signed main(){
    int N;
    cin >>N;
    N%exsum(N)==0 ? cout<<"Yes"<<endl : cout<<"No"<<endl;
}


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

int main() {
    int N,X, m, min = 10000, count=0;
    cin >> N >> X;
    for(int i = 0; i < N; i++) {
        cin >> m;
        X -= m;
        count++;
        if(min > m) min = m;
    }
    while(X>=min) {
        X -= min;
        count++;
    }
    cout << count << 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 n;
  cin >> n;
  
  bool ans = false;
  
  REP(i,9) {
    REP(j,9) {
      if (n == (i+1)*(j+1)) ans = true;
    }
  }
  
  cout << (ans ? "Yes" : "No") << endl;
    
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n, m, k;
  bool found = false;
  cin >> n >> m >> k;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= m; ++j) {
      if (i * (m - j) + j * (n - i) == k) {
        found = true;
      }
    }
  }
  cout << (found ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    a, b, c = list(map(int,input().split()))

    if a + b + c < 22:
        print('win')
    else:
        print('bust')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
  int n=0;
  int x=0;
  int i=0;
  int j=0;
  int k=0;
  int bound=0;
  scanf("%d%d",&n,&x);
  int array[n];
  int point[n+1];
  for(i;i<n;i++){
  scanf("%d",&array[i]);
  }
  for(j;j<n+1;j++)
  {
    point[j]=point[j-1]+array[j-1];
    if(j==0)
    {
      point[j]=0;
    }
  }
  for(k;k<n+1;k++)
  {
    if(point[k]<x||point[k]==x)
    {
      bound+=1;
    }
  }
  printf("%d",bound);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

int main(){
	
	int N, A, B;
	cin >> N >> A >> B;
	
	if((A - B) % 2 == 0){
		cout << "Alice" << endl;
	}else{
		cout << "Borys" << endl;
	}
	
	return 0;
}

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

	using namespace std;

	#define forn(i,n) for ( int i=0 ; i < n ; i++ )
	#define all(a) (a).begin(), (a).end()
	#define lb lower_bound
	#define ub upper_bound
	#define vi vector<int >
	#define pii pair<int, int>
	#define F first
	#define S second
	#define MP make_pair
	#define PB push_back
	#define SQ(a) (a)*(a)
	#define ll long long
	#define lli long long int
	#define ull unsigned long long
	#define endl '\n'
	#define Pi(a) printf("%d\n",a);
	#define debug2(a,b) printf("%d\t%d\n",a,b);
	#define debug1(a) printf("%d\n",a);
	#define Si(a) scanf("%d",&a);
	#define mod 1000000007
	#define w(n) while(n--)

	int d,p[12],c[12],g;
	int recurse(int place,bool visited[],int sum){
		int ans=-1;
		if(place>d) return 0;
		for(int i=1;i<=d;i++){
			//cout << i << " " << visited[i] << " ";
			if(!visited[i]){
				visited[i]=true;
				if(p[i]*i+c[i]+sum>g){
					int temp = g-sum;
					int req=temp/i + temp%i;
					int ht = req>=p[i]?p[i]:req;
					if(ans==-1) ans=ht;
					else ans=min(ans,ht);
				}
				else if(p[i]*i+c[i]+sum==g){
					if(ans==-1) ans=p[i];
					else ans=min(ans,p[i]);
				}
				else{
					int here=p[i]+recurse(place+1,visited,p[i]*i+c[i]+sum);
					if(ans==-1) ans=here;
					else ans=min(ans,here);
				}
				visited[i]=false;
				//cout << i << " " << ans << endl;
			}
		}
		return ans;
	}

	int main()
	{
		//ios::sync_with_stdio(0);
		//cin.tie(0);
		//code
		cin >> d >> g;
		g/=100;
		forn(i,d) cin >> p[i+1] >> c[i+1];
		forn(i,d) c[i+1]/=100;
		bool visited[d+1];
		memset(visited,false,sizeof(visited));
		cout << recurse(1,visited,0) << endl;
		return 0;

	}

Measured memory_bytes: 384
from fractions import gcd
def lcm(x,y):
    return (x * y) // gcd(x,y)

A,B,C,D = map(int,input().split())

cnt = 0
cnt += ((B // C) - ((A-1) // C))
cnt += ((B // D) - ((A-1) // D))

tmp = ((B//lcm(C,D)) - ((A-1)//lcm(C,D)))

ans = B-A+1-cnt+tmp
print(ans)


Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=5005;
const int INF=1e9;
int n,na,nb,ans=INF;
pii a[N],b[N];
char s[N],t[N];
void solve(){
	for(int i=0;i<=n;i++){
		if((a[1].second+b[1].second+i)&1)continue;
		int re=0,now=1;
		while(now<=na){
			int pos=a[now].first,pre=now+i<=nb?b[now+i].first:n+1;
			re+=abs(pos-pre);now++;
		}
		while(now+i<=nb)re+=n+1-b[now+i].first,now++;
		for(int j=1;j<=i;j++)re+=(j<=nb?b[j].first:n+1)-1;
		ans=min(ans,re);
	}
}
signed main(){
	n=read();scanf("%s%s",s+1,t+1);
	for(int i=1;i<=n;i++){
		if(s[i]!=s[i-1])a[++na]=pii(i,s[i]-'0');
		if(t[i]!=t[i-1])b[++nb]=pii(i,t[i]-'0');
	}solve(),swap(na,nb),swap(a,b),solve();
	return cout<<ans,signed();
}

Measured memory_bytes: 3856
a, b = map(int, input().split())
takahashi = 0
 
for x in range(1, a):
    for y in range(1, 31):
        if x == y:
            takahashi += 1
 
for x in range(1, b+1):
    if x == a:
        takahashi += 1
print(takahashi)

Measured memory_bytes: 3060
import java.util.Scanner;


class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);	
		double a[]=new double[10001];
		double min=1000000,max=-1000000,sum=0;
		int i=0;
		
		int n = kb.nextInt();
		while( 0<n-- ) {
			a[i]=kb.nextDouble();
			sum+=a[i];
			if( a[i] <= min ) {
				min=a[i];
			} 
			if( max <= a[i]  ) {
				max=a[i];
			} 
		}
		
		System.out.printf( "%.0f %.0f %.0f\n", min, max, sum );
		
	}
}

Measured memory_bytes: 54372
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
    // return *(int*)b - *(int*)a;
}

int main()
{
    int   ret_scanf;
    int   i, j, n, in_data;
    int   data1[50], data2[50];
    int   size;

    // フォーマットに従って標準入力から入力
    ret_scanf = scanf("%d", &n);
    if (ret_scanf == 0) return 0;
    // printf("number of count = %d \n", n);

	for (int i = 0; i < n; i++) {
		ret_scanf =  scanf("%d", &data1[i]);
	}
	int iDiff;
	iDiff = 0;
    for (int i = 0; i < n; i++) {
    	if (data1[i] != i + 1) {
    		iDiff++;
    	}
    }
    
    if (iDiff <= 2) {
    	printf("YES");
    } else {
    	printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    char a[11],d[11],c[11];
    int x , y, z;
    scanf("%s",a);
    scanf("%s",d);
    scanf("%s",c);
    x=strlen(a)-1;
    y=strlen(d)-1;
    z=strlen(c)-1;
        if((a[x]==d[0])&&(d[y]==c[0]))
        {
            printf("YES\n");
        }
        else
        {
            printf("NO\n");
        }
    return 0;
}

Measured memory_bytes: 1624
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
vector<int> es[200010];
int now = 0;
int p[200010];
int lp[200010];
int re[200010];
int n, k,l;
void init() {
	for (size_t i = 1; i <= n; i++)
	{
		p[i] = i;
		lp[i] = i;
		re[i] = 0;
	}
}
int pa(int x) {
	if (p[x] == x) return x;
	return p[x] = pa(p[x]);
}
void unite(int x, int y) {
	int xp = pa(x);
	int yp = pa(y);
	if (xp < yp) p[yp] = xp;
	if (yp < xp) p[xp] = yp;
}
int pa2(int x) {


	if (lp[x] == x) return x;


	lp[x] = pa2(lp[x]);
	return lp[x];
}
void unite2(int x, int y) {
	int xp = pa2(x);
	int yp = pa2(y);

	if (xp < yp) {
		lp[yp] = xp;
	}
	else if (yp < xp) {
		lp[xp] = yp;
	}
}

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

void solve() {
	cin >>n  >> k >> l;
	init();
	for (size_t i = 0; i < k; i++)
	{
		int a, b;
		cin >> a >> b;
		unite(a, b);
	}

	for (size_t i = 1; i <= n; i++)
	{
		pa(i);
	}

	for (size_t i = 0; i < l; i++)
	{
		int a, b;
		cin >> a >> b;
		unite2(a, b);
	}
	for (size_t i = 1; i <= n; i++)
	{
		pa2(i);
	}
	map<vector<int>, int> m;

	for (size_t i = 1; i <= n; i++)
	{
		m[{p[i], lp[i]}]++;
	}

	for (size_t i = 1; i <= n; i++)
	{
		if (i >= 2) cout << " ";
		cout << m[{p[i], lp[i]}];
	}
	cout << endl;
}

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



Measured memory_bytes: 27648
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	int ans = 0;
	for(int i = 0; i < k; i++){
		if(a>0){a--;ans++;}
		else if(b>0)b--;
		else if(c>0){c--;ans--;}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;

ll A[400000];
ll cnt[64];

ll mod = ll(1e9 + 7);

int main()
{
    int N;
    cin >> N;
    rep(i, N){
        cin >> A[i];
    }
    int target = 1;
    for (int i = 0; i < N; i++){
        if (A[i] == target){
            target++;
        }
    }
    if (target == 1){
        cout << -1;
    } else {
        cout << N - target + 1;
    }
    return 0;
}


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


int main(){

    int N,M;
    cin >> N >> M;

    int guu = N>1 ? N*(N-1)/2 : 0;
    int ki = M > 1 ? M*(M-1)/2: 0;

    cout << guu + ki << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],sum=0,ans= INT_MAX;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    int k=0;
    for(int i=0;i<n;i++)
    {    sum=sum-a[i];
         k=k+a[i];
       //  cout<<sum<<" "<<k<<endl;
      ans=min(abs(sum-k),ans);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define LEN(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
using ll = long long;
using llu = long long unsigned;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;
using vpii = vector<pii>;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod(ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

////////////////////////// Solution starts below. //////////////////////////////



int main () {
	// ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.precision(10);
	int n;
	cin >> n;
	if(n >= 30) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


Measured memory_bytes: 3632
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let s: Vec<Vec<char>> = (0..2)
        .map(|_| input::<String>().chars().collect())
        .collect();
    const MOD: i64 = 1000000007;

    let mut i = 0;
    let mut ans = 1;
    if s[0][0] == s[1][0] {
        ans *= 3;
        i += 1;
    } else {
        ans *= 6;
        i += 2;
    }

    while i < n {
        if s[0][i - 1] == s[1][i - 1] {
            if s[0][i] == s[1][i] {
                ans *= 2;
                ans %= MOD;
                i += 1;
            } else {
                ans *= 2;
                ans %= MOD;
                i += 2;
            }
        } else {
            if s[0][i] == s[1][i] {
                i += 1;
            } else {
                ans *= 3;
                ans %= MOD;
                i += 2;
            }
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import collections as cl
import math


def combinations_count(n, r):
    if n < r:
        return 0
    else:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


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

cnt = cl.Counter(A)
ans = 0
for v in cnt.values():
    ans += combinations_count(v, 2)

for a in A:
    print(ans - cnt[a]+1)


Measured memory_bytes: 26780
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

string S="";
void solve(int sx,int sy,int tx,int ty,string s){
  if(s=="ikiku"){
    rep(i,ty-sy) S=S+'U';
    rep(i,tx-sx) S=S+'R';
  }
  else{
    rep(i,ty-sy) S=S+'D';
    rep(i,tx-sx) S=S+'L';
  }
}

signed _main(){
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  solve(sx,sy,tx,ty,"ikiku");
  solve(sx,sy,tx,ty,"neri");
  S=S+'L';
  solve(sx-1,sy,tx,ty+1,"ikiku");
  S=S+'D';
  S=S+'R';
  solve(sx,sy-1,tx+1,ty,"kaeru");
  S=S+'U';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 384
/*2020/03/14 PanasonicProgrammingContest2020*/

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

int main() {
    long long int a, b, c;
    cin >> a >> b >> c;
    long double d = a*b;
    if(a+b+2*sqrt(d)<c) cout << "Yes" << endl;
    else cout << "No" << endl;  
}


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

typedef struct{
  int parent;
  int left;
  int right;
  int key;
}Tree;

Tree T[25];

void inorder(int x){
  if(x != -1){
    inorder(T[x].left);
    printf(" %d", T[x].key);
    inorder(T[x].right);
  }
}

void preorder(int x){
  if(x != -1){
    printf(" %d", T[x].key);
    preorder(T[x].left);
    preorder(T[x].right);
  }
}

void postorder(int x){
  if(x != -1){
    postorder(T[x].left);
    postorder(T[x].right);
    printf(" %d", T[x].key);
  }
}

int main(){
  int n, i, j, id, root, child;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d", &id);
    T[id].key = id;

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

      scanf("%d",&child);
      if(child != -1) T[child].parent = id;

      if(j == 0) T[id].left = child;
      else if(j == 1) T[id].right = child;
    }
  }

  for(i = 0; i < n; i++){
    if(T[i].parent == -1){
      root = i;
      break;
    }
  }

  printf("Preorder\n");
  preorder(root);
  printf("\n");

  printf("Inorder\n");
  inorder(root);
  printf("\n");

  printf("Postorder\n");
  postorder(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 616
import Foundation

func main(){
    let counter = Int(readLine()!)!
    var aryStr = [String]()
    var aryInts = [Int]()
    
    for _ in 1...counter {
        aryStr.append(readLine()!)
        aryInts.append(1)
    }
    let ziped = zip(aryStr,aryInts)
    let dicUniq = Dictionary(ziped, uniquingKeysWith: +)
    let max = dicUniq.values.max()
    var ans = [String]()
    
    for dic in dicUniq {
        if dic.value == max {
            ans.append(dic.key)
        }
    }
    ans.sort() { $0 < $1 }
    for a in ans {
        print(a)
    }
}

main()

Measured memory_bytes: 35816
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
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
#define int long long
vector<int> a[4];
signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, W;
    cin >> N >> W;
    int w[110], v[110];
    rep(i, N) cin >> w[i] >> v[i];
    rep(i, N) {
        a[w[i] - w[0]].push_back(v[i]);
    }
    rep(i, 4) sort(a[i].begin(), a[i].end(), greater<int>());
    int ans = 0;
    
    rep(i, a[0].size() + 1) {
        rep(j, a[1].size() + 1) {
            rep(k, a[2].size() + 1) {
                rep(s, a[3].size() + 1) {
                    int tmp_w = 0, tmp_v = 0;
                    rep(i1, i) {tmp_w += w[0] + 0; tmp_v += a[0][i1];}
                    rep(i1, j) {tmp_w += w[0] + 1; tmp_v += a[1][i1];}
                    rep(i1, k) {tmp_w += w[0] + 2; tmp_v += a[2][i1];}
                    rep(i1, s) {tmp_w += w[0] + 3; tmp_v += a[3][i1];}
                    if(tmp_w <= W) ans = max(ans, tmp_v);
                }
            }
        }
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3576
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
PriorityQueue<Integer> a = new PriorityQueue<>();
PriorityQueue<Integer> b = new PriorityQueue<>();
for(int i=0;i<n;++i)a.add(sc.nextInt());
for(int i=0;i<n;++i)b.add(sc.nextInt());
long mod = (long)1e9+7;
int ac=0, bc=0;
long ans =1;
a.add(Integer.MAX_VALUE);b.add(Integer.MAX_VALUE);
while(a.size()>1 || b.size()>1){
if(a.peek() < b.peek()){
a.poll();
if(bc==0)++ac;
else ans = ans * (long)(bc--)%mod;
}else{
b.poll();
if(ac==0)++bc;
else ans = ans * (long)(ac--)%mod;
}
}
System.out.println(ans);
}
}


Measured memory_bytes: 93616
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////

void solve() {
	int Q;
	cin >> Q;
	
	priority_queue<int, vector<int>, greater<int>> R;
	priority_queue<int> L;
	LL now = 0;
	LL B = 0;
	while (Q--) {
		int ter;
		cin >> ter;
		if (ter == 2) {
			cout << L.top() << " " << now + B << endl;
		}
		else {
			int a, b;
			cin >> a >> b;
			B += b;

			L.push(a);
			R.push(a);
			LL resL = L.top();
			LL resR = R.top();
			if (L.top() > R.top()) {
				LL AA = L.top(); L.pop();
				LL BB = R.top(); R.pop();
				now += AA - BB;
				L.push(BB);
				R.push(AA);
			}
		}
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main() {
  int n;
  cin >> n;
  int ans{};

  for (int i{1}; n > 0; i *= 10) {
    int d{n % 10 == 9 ? 1 : 9};
    ans += d * i;
    n /= 10;
  }

  cout << ans << endl;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

int32_t main() {
    IOS;
    int a, b, c, k;
    cin>>a>>b>>c>>k;

    if (k<=a) {
        cout<<k<<endl;
        return 0;
    }

    if (k<=a+b) {
       cout<<a<<endl;
    } else {
        cout<<a-(k-(a+b))<<endl;
    }

    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector < vector <int> > vv(n, vector <int> (m)), flag(n, vector <int> (m));
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            char x;
            cin >> x;
            if(x == '#')
                vv[i][j] = 1;
        }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            if(!vv[i][j])
                continue;
            if(i - 1 >= 0 && vv[i - 1][j] == 1)
                flag[i][j] = 1;
            if(i + 1 < n && vv[i + 1][j] == 1)
                flag[i][j] = 1;
            if(j - 1 >= 0 && vv[i][j - 1] == 1)
                flag[i][j] = 1;
            if(j + 1 < m && vv[i][j + 1] == 1)
                flag[i][j] = 1;
        }
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            if(vv[i][j] == 1 && !flag[i][j])
                return cout << "No", 0;
    cout << "Yes";
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for(int& x : a) cin >> x;
	reverse(a.begin(), a.end());
	vector<int> lis(n+1, INT_MAX);
	int ans = 1;
	lis[0] = -1;
	for(int i = 0; i < n; i++) {
		int x = a[i];
		
		int lo = 0, hi = n-1;
		while(lo < hi) {
			int mid = lo + (hi - lo + 1)/2;
			if(lis[mid] <= x) {
				lo = mid;
			} else {
				hi = mid-1;
			}
		}
		lis[lo+1] = min(lis[lo+1], x);
		ans = max(ans, lo+1);
	}
	
	cout << ans << endl;
}


Measured memory_bytes: 1024
//C++
#include<bits/stdc++.h>
using namespace std;
//N円の商品最小の1000円札で支払う時のおつり
int main() {
    int N;
    int pay;
    int back;
    
    //cout << "OK" << endl;

    cin >> N;
    //1000で割ったあまり
    pay = N % 1000;
    if(pay == 0){
        back = 0;
    }else{
        back = 1000-pay;
    }
    cout << back;
    return 0;
}

Measured memory_bytes: 3584
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::io::{self, BufRead};

#[allow(unused_mut)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
  input!{
    n: i64,
    a: [i64; n]
  }
  let mut a: Vec<_> = a
    .into_iter()
    .enumerate()
    .map(|(i, x)| i as i64 - x)
    .collect();
  a.sort();
  let ans: i64 = a.iter().map(|&x| (x - a[a.len() / 2]).abs()).sum();
  println!("{}", ans);
}


Measured memory_bytes: 10492
#include<bits/stdc++.h>
    #include <ext/pb_ds/tree_policy.hpp> 
    #include <functional> // for less 
    using namespace __gnu_pbds; 
    using namespace std;
    //typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;    
    #define ll            long long
    #define pb            push_back
    #define ppb           pop_back
    #define si            set <ll>
    #define endl          '\n'
    #define fr            first
    #define sc            second
    #define mii           map<ll ,ll >
    #define msi           map<string,ll >
    #define mis           map<ll , string>
    #define rep(i,a,b)    for(ll  i=a;i<b;i++)
    #define all(v)        v.begin(),v.end()
    #define sort(v)       sort(all(v))
    #define pii           pair<ll ,ll >
    #define vi            vector<ll >
    #define vii           vector<pair<ll , ll >>
    #define vs            vector<string>
    #define sz(x)         (ll)x.size()
    #define M             1000000007
    #define bs            binary_search
    #define rev(a)        reverse(all(a));
    #define sp(n)         setprecision(n)
    #define spl           " "
    #define arr(a,n)      rep(i,0,n) cin>>a[i]
    #define mod           998244353
    #define print_vector(a)  for(auto t:a) cout<<t<<" ";cout<<endl;
    #define print_arr(a,n)   rep(i,0,n) cout<<a[i]<<" "; cout<<endl;        
    #define show(a,n)     for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
    #define N             100000000
    #define debug(x)      cout << #x << " is " << x << endl;
    #define time          cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    #define INF           1ll<<31
    #define M_PI 3.14159265358979323846
    using namespace std;
    ll min(ll a,ll b)
    {
        return a>b?b:a;
    }
    ll max(ll a,ll b)
    {
        return a>b?a:b;
    }
    const ll maxn=2e5+500;
    void solve()
    {
      ll r;
      cin>>r;
      cout<<fixed<<sp(18);
      cout<<2*M_PI*r<<endl;

    }
    signed main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        ll t=1;
        //cin>>t;
        while(t--) solve();
    }


Measured memory_bytes: 3800
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = [list(input()) for _ in range(M)]

for s in range(N-M+1):
    for t in range(N-M+1):
        match = True
        for i in range(M):
            for j in range(M):
                if A[i+s][j+t] != B[i][j]:
                    match = False
                    break
            else:
                continue
            break
        if match:
            print('Yes')
            exit()
print('No')

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

int main(){
  int n, m, k; cin >> n >> m >> k;
  vector<ll> a(n), b(m);
  ll sum = 0;
  vector<ll> asum(n), bsum(m);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
    asum[i] = sum;
  }
  sum = 0;
  for(int i = 0; i < m; i++){
    cin >> b[i];
    sum += b[i];
    bsum[i] = sum;
  }

  //rep(i, n) cout << asum[i] << " "; cout << endl;
  //rep(i, m) cout << bsum[i] << " "; cout << endl;


  ll ans = upper_bound(bsum.begin(), bsum.end(), k) - bsum.begin();
  for(int i = 0; i < n; i++){
    ll remain = k - asum[i];
    if(remain < 0) break;
    auto itr = upper_bound(bsum.begin(), bsum.end(), remain);
    ll num = itr - bsum.begin();
    ans = max(ans, i + 1 + num);
  }
  cout << ans << endl;

  return 0;
}


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

int main()
{
	double q,x;
	while(scanf("%lf",&q), q!=-1)
	{
		x=q/2.0;
		while(abs(x*x*x-q) >= 0.00001*q)
		{
			x = x-(x*x*x-q)/(3*x*x);
		}
		printf("%.6lf\n",x);
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int n;
int a[101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	int res=0;
	for(int i=-100;i<=100;i++){
		int sum=0;
		for(int j=0;j<n;j++){
			sum+=(i-a[j])*(i-a[j]);
		}
		res=min(res,sum);
		if(i==-100)res=sum;
	}
	printf("%d\n",res);
	return 0;
}

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

const int M = 100+5;
const int N = 100000+5;

int n, k;
int a[M];
int memo[N];

int main() {
	cin >> n >> k;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	/*********************/
	for(int i=0; i<a[1]; i++) memo[i] = 0;
	for(int pila = a[1]; pila <= k; pila++){
		for(int i=1; i<=n and a[i] <= pila; i++){
			if(memo[pila - a[i]] == 0) memo[pila] = 1;
		}
	}
	puts(memo[k]?"First":"Second");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;



int main()
{
  ll N, C;
  cin >> N >> C;
  vector<vector<pll>> temp(C);//start end
  //connect time in same chanel
  for (ll i = 0; i < N; ++i)
  {
    ll s, t, c;
    cin >> s >> t >> c;
    temp.at(c - 1).push_back({s, t});
  }
  for (ll i = 0; i < C; ++i)
  {
    sort(temp.at(i).begin(), temp.at(i).end(), [] (pll a, pll b){
      return a.second < b.second;
    });
  }
  vector<pll> time_table;
  for (ll i = 0; i < C; ++i)
  {
    if (temp.at(i).size() == 0)
    {
      continue;
    }
    ll s = temp.at(i).at(0).first;
    ll e = temp.at(i).at(0).second;
    for (ll j = 1; j < temp.at(i).size(); ++j)
    {
      if (e == temp.at(i).at(j).first)
      {
        e = temp.at(i).at(j).second;
      }
      else
      {
        time_table.push_back({s, e});
        s = temp.at(i).at(j).first;
        e = temp.at(i).at(j).second;
      }
    }
    time_table.push_back({s, e});
  }
  sort(time_table.begin(), time_table.end(), [] (pll a, pll b){
    return a.second < b.second;
  });
  vector<ll> ans(100010, 0);
  for (ll i = 0; i < time_table.size(); ++i)
  {
    ans.at(time_table.at(i).first) += 1;
    ans.at(time_table.at(i).second + 1) -= 1;
  }
  for (ll i = 0; i < 100009; ++i)
  {
    ans.at(i + 1) += ans.at(i);
  }
  ll cnt = 0;
  for (ll i = 0; i < 100010; ++i)
  {
    cnt = max(cnt, ans.at(i));
  }
  cout << cnt << endl;

  // for (ll i = 0; i < time_table.size(); ++i)
  // {
  //   cout << time_table.at(i).first << " " << time_table.at(i).second << endl;
  // }
}


Measured memory_bytes: 5364
#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 FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  vector<ll> x(3);
  REP(i, 3) { cin >> x[i]; }
  sort(x.begin(), x.end());
  ll d1 = x[2] - x[0], d2 = x[2] - x[1];
  if (d1 == d2) {
    cout << d1 << endl;
    return 0;
  }
  ll ans = 0;
  ll diff = abs(d1 - d2);
  ans += min(d1, d2) + diff / 2;
  if (diff % 2 != 0) {
    ans += 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
char s[4005],t[4005];
int u[4005],m,i,n,j,c;
int main(){
	for(;~scanf(" %s %s",s+1,t+1);i=m=!printf("%d\n",m)){
		for(n=strlen(s+1)+1;!i|t[i];i++)
			for(j=n;--j;m<c?m=c:0)
				u[j+1]=c=s[j]-t[i]?0:u[j]+1;
	}
}

Measured memory_bytes: 432
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(void)
{
	int a,b;
	scanf("%d %d",&a,&b);
	int m = 1;
	int i = 0;
	while (m < b)
	{
		m--;
		m+=a;
		i++;
	}
	printf("%d\n",i);
	return(0);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    string tarou;
    string hanako;
    int cnttarou = 0;
    int cnthanako = 0;
    for (int i = 0; i < n; i++) {
        cin >> tarou >> hanako;
        if (tarou == hanako) {
            cnttarou += 1;
            cnthanako += 1;
        } else if (tarou < hanako) {
            cnthanako += 3;
        } else if (tarou > hanako) {
            cnttarou += 3;
        }
        tarou.clear();
        hanako.clear();
    }
    
    cout << cnttarou << " " << cnthanako << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>
int main(){
    int i;
    int n;
    int a;
    int min=10000000, max=-10000000;
    long long sum=0;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a);
        if(a < min){
            min = a;
        }
        if(a > max){
            max = a;
        }
        sum += a;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 2756
#include <stdio.h>

int main(void)
{
    int A,B,C;
    int max,quotient;
    int i;
    
    scanf("%d %d %d", &A, &B, &C);
    
    quotient = 100/A;//商
    
    if(quotient>=10){
        for(i=1;i<quotient+1;i++){
            if( (A*i) % B ==C ){
                printf("YES\n");
                break;
            }
            else if( i==quotient ){
                printf("NO\n");
            }
        }
    }
    else{
        for(i=1;i<100+1;i++){
            if( (A*i) % B ==C ){
                printf("YES\n");
                break;
            }
            else if( i==100 ){
                printf("NO\n");
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
using namespace std;
typedef long long ll;

int main() {
	ll i, j;
	ll N, A[nmax_def], B[nmax_def];
	ll ans = 0;
	cin >> N;
	for (i = 0; i <= N; i++)
		cin >> A[i];
	for (i = 0; i < N; i++)
		cin >> B[i];
	for (i = N - 1; i >= 0; i--)
	{
		if (A[i + 1] < B[i])
		{
			ans += A[i + 1];
			B[i] -= A[i + 1];
		}
		else
		{
			ans += B[i];
			B[i] = 0;
		}
		if (A[i] < B[i])
		{
			ans += A[i];
			A[i] = 0;
		}
		else
		{
			ans += B[i];
			A[i] -= B[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
using ll = long long int;

const ll MOD = 1000000007LL;
const ll S = 500000LL;
ll fact[S+10], finv[S+10];

ll mod_pow(ll X, ll N) {
    ll ret = 1;
    for(; N>0; N>>=1) {
        if(N & 1) (ret *= X) %= MOD;
        (X *= X) %= MOD;
    }
    return ret;
}

void init() {
    fact[0] = 1;

    for(ll i=1; i<=S; i++) {
        fact[i] = (fact[i-1] * i) % MOD;
    }

    finv[S] = mod_pow(fact[S], MOD-2);
    for(ll i=S; i>=1; i--) {
        finv[i-1] = (finv[i] * i) % MOD;
    }
}

ll nCr(int n, int r) {
    if(n < 0 || r < 0 || r > n) return 0;
    return (fact[n] * finv[n-r] % MOD) * finv[r] % MOD;
}

int main() {
    init();

    ll N, M, K; cin >> N >> M >> K;

    ll ans = 0;
    for(int d=0; d<=K; d++) {
        int l = K - d;

        int ud = N + 2*d, lr = M + 2*l;
        int u = ud - d, r = lr - l;

        ll mul = nCr(ud + lr, ud);
        ll sum_ud = nCr(ud, d);
        sum_ud = (sum_ud - nCr(ud, u+1) + MOD) % MOD;

        ll sum_lr = nCr(lr, r);
        sum_lr = (sum_lr - nCr(lr, r+1) + MOD) % MOD;

        (mul *= sum_ud) %= MOD;
        (mul *= sum_lr) %= MOD;
        (ans += mul) %= MOD;
        // printf("mul = %lld\n", mul);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10912
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
 
typedef long long ll;
typedef pair<int, int> P;
 
 
signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
 
    int N, M, T;
    cin >> N >> M >> T;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
 
    vector<bool> ok(T + 1, true);
    rep(i, N) {
        for (int j = max(0, a[i] - M + 1); j <= min(a[i] + M, T); j++) {
            ok[j] = false;
        }
    }
 
    int cnt = 0;
    rep2(i, 1, T + 1) {
        if (ok[i]) cnt++;
    }
 
    cout << cnt << endl;
}

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

bool is_prime(ll n)
{
	if(n==1)return false;
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		return false;
	}
	return true;
}

vector<ll>divisor(ll n)

{
	vector<ll>res;
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			res.push_back(i);
			if(i!=n/i)res.push_back(n/i);
		}
	}
	return res;
}

map<ll,int>prime_factor(ll n)
{
	map<ll,int>res;
	for(ll i=2;i*i<=n;i++)
	{
		while(n%i==0)
		{
			res[i]++;
			n/=i;
		}
	}
	if(n!=1)res[n]++;
	return res;
}
//左边long long存因数，右边int存因数的指数 


vector<ll>prime_enum(int n)
{
	vector<bool>is_prime(n+1,true);
	is_prime[0]=is_prime[1]=false;
	vector<ll>res;
	for(int i=2;i<=n;i++)
	{
		if(!is_prime[i])continue;
		res.push_back(i);
		for(int j=2*i;j<=n;j+=i)
		{
			is_prime[j]=false;
		}
	}
	return res;
}

set<long long>se;
 
void solve(ll N,ll n)
{
	auto v=divisor(N);
	for(ll k:v)
	{
		if(k==1)
			continue;
		ll d=n;
		while(d>=k)
		{
			if(d%k==0)d/=k;
			else break;
		}
		d%=k;
		if(d==1)
		{
			se.insert(k);
		}
	}
}
 
int main()
{
	ll n;
	cin>>n;
	solve(n,n);
	solve(n-1,n);
	cout<<se.size()<<endl;
}

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

long long culc_sum(char data[], int len, int last_i, int i, long long sum);
char* slice(char data[], char temp[], int n);

int main(void)
{
  char s[10 + 1];
  int len;
  long long sum;

  /*入力*/
  scanf("%s", s);
  /*sの長さを計測*/
  len = 0;
  while (s[len] != '\0') {
    len++;
  }
  /*処理*/
  sum = culc_sum(s, len, 0, 1, 0);

  /*出力*/
  printf("%lld\n", sum);
  return 0;
}

long long culc_sum(char data[], int len, int last_i, int i, long long sum)
{
  char *temp, *end;
  long long sum_1 = 0, sum_2 = 0, plus = 0;

  if (i == len) {
    temp = malloc(i - last_i + 1);
    plus = strtoll(slice(data+last_i, temp, i - last_i), &end, 10);
    free(temp);
    return sum + plus;
  }

  temp = malloc(i - last_i + 1);
  plus = strtoll(slice(data+last_i, temp, i - last_i), &end, 10);
  free(temp);
  /*+を入れないパターン*/
  sum_1 = culc_sum(data, len, last_i, i+1, sum);
  /*+を入れるパターン*/
  sum_2 = culc_sum(data, len, i, i+1, sum+plus);

  return sum_1 + sum_2;
}

char* slice(char data[], char temp[], int n)
{
  strncpy(temp, data, n);
  temp[n] = '\0';
  return temp;
}


Measured memory_bytes: 1732
package main

import "fmt"

func abs(x float64) float64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var n int
	var x1, y1, x2, y2, x3, y3, x4, y4 float64
	fmt.Scan(&n)
	for i := 0 ; i < n; i++ {
		fmt.Scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)
		if abs((x2-x1)*(y4-y3) - (y2-y1)*(x4-x3)) < 1e-10 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}


Measured memory_bytes: 1100
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

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

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

// 二項係数計算
long long 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;
}


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始
int main(){
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  string ans = s.substr(8);
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int N = 9;

int hand1[N];
int hand2[N];

main(){
  int n;
  cin >> n;
  while(n--){
    for(int i=0;i<9;i++){
      cin >> hand1[i];
    }
    for(int i=0;i<9;i++){
      cin >> hand2[i];
    }
    sort(hand1, hand1+N);
    int win1 = 0, win2 = 0;
    do{
      int sum1 = 0, sum2 = 0;
      for(int i=0;i<9;i++){
        if(hand1[i] > hand2[i]) sum1 += hand1[i] + hand2[i];
        else if(hand1[i] < hand2[i])sum2 += hand1[i] + hand2[i];
      }
      if(sum1 > sum2) win1++;
      else if(sum1 < sum2) win2++;
    }while(next_permutation(hand1, hand1+N));
    double ans = (double)win1/(win1+win2);
    printf("%.5f %.5f\n", ans, 1.0-ans);
  }
  return 0;
}

Measured memory_bytes: 904
N, K, C = map(int, input().split())
S = input().rstrip()
P = [0]*(N+1)
cl, l, cr, r = 0, 1, 0, 1
for i in range(N):
    if cl > C and S[i] != "x": cl = 0; l += 1
    cl += 1
    P[i+1] += l
    if cr > C and S[-1-i] != "x": cr = 0; r += 1
    cr += 1
    P[N-2-i] += r
for i in range(N):
    if P[i] < K and S[i] == "o":
        print(i+1)

Measured memory_bytes: 77016
S = list(str(input()))
N = len(S) + 1

a = [0]*N
#foward
for i, s in enumerate(S):
  if s=="<":
    a[i+1]=a[i]+1
#back
S_ = list(reversed(S))
j=0
for s in S_:
  if s==">":
    if a[N-1-(j+1)]<=a[N-1-j]:
      a[N-1-(j+1)]=a[N-1-j]+1
  j+=1
print(sum(a))

Measured memory_bytes: 31032
use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = String;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    // let contest_middle_name = input_vectors[0][1];
    let (contest_middle_name_initial, _contest_middle_name_rest) = input_vectors[0][1].split_at(1);
    println!("A{}C", contest_middle_name_initial);
}


Measured memory_bytes: 380