akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;

int main() {
	int Q;
	cin >> Q;
	for(int i=0; i<Q; i++) {
	 int N, D;
	 cin >> N >> D;
	 int even = N/2*2;
	 int odd = even+1;
	 if(odd > N)odd -= 2;
	 
	 int ans = 0;
	 for(int i=0; i<7; i++) {
	 	if( D & (1<<i)) {
	 		ans += (1<<i) * odd;
	 	}
	 	else ans += (1<<i) * even;
	 }
	 cout << ans << endl;
	 
	}
	return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
     
    using namespace std;
     
    int main(){
    	int a,b;
      	cin >> a >> b;
      	int cnt = 0;
      	while(a > 0){
          a = a - b;
      	  cnt++;
        }
     	cout << cnt << endl; 	
    	return 0;
    }

Measured memory_bytes: 764
/*  ex5_3
    takafumi_ueki*/
#include <stdio.h>
#define LIMIT 100
    int main(void){
    int i,j,length,width;
    int row[LIMIT]={0};
    int col[LIMIT]={0};
    char field[LIMIT][LIMIT];
    //縦と横の長さを受け取る
    scanf("%d %d",&length,&width);
    //マス目が'.'か'#'かを受け取る
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            scanf(" %c",&field[i][j]);
        }
    }
    //列ごとに'#'が含まれているかどうかを調べる
    //もし含まれていたらrow[i]が1になる
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            if(field[i][j]=='#'){
                row[i]=1;
                break;
            }
        }
    }
    //次に行ごとに'#'が含まれていないか調べる
    for(j=0;j<width;j++){
        for(i=0;i<length;i++){
            if(field[i][j]=='#'){
                col[j]=1;
                break;
            }
        }
    }
    //もし,'#'がひとつでも含まれていたらその行、列は書き出すようにする
    for(i=0;i<length;i++){
        for(j=0;j<width;j++){
            if(row[i]==1&&col[j]==1){
                printf("%c",field[i][j]);
            }
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;

  int isum = 0;
  double fsum = 0;

  cin >> N;
  for (int i = 0; i < N; ++i) {
    double x;
    string s;
    cin >> x >> s;

    if (s[0] == 'J') isum += (int)x;
    else fsum += 380000.0 * x;
  }

  cout << fixed << setprecision(9) << (double)isum + fsum << endl;

  return 0;
}



Measured memory_bytes: 256
n,k = map(int,input().split())

if k > (n-1)*(n-2)//2:
    print(-1)
    exit()

cnt = (n-1)*(n-2)//2
m = n-1+(n-1)*(n-2)//2-k

print(m)

for i in range(2,n+1):
    print(1,i)

for i in range(2,n):
    for j in range(i+1,n+1):
        if cnt == k:
            exit()
        print(i,j)
        cnt -= 1
        
        




Measured memory_bytes: 43120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e3+6;
const int mod = 1e9+7;
const ll inf = 1e18;
int a[N];
void solve(){
  int n;
  cin>>n;
  int ans = 0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    ans+=a[i];
  }
  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    cout<<ans-a[x]+y<<endl;
  }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * D : ???????¨??§? / Checkered Pattern
 */
public class Main {

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

		int T = sc.nextInt();

		for (int i = 0; i < T; i++) {
			long h = sc.nextLong();
			long w = sc.nextLong();
			long gcd = gcd(h, w);
			h /= gcd;
			w /= gcd;

			if (h == w) {
				System.out.println("1 0");
			} else if (h % 2 == 0 || w % 2 == 0) {
				System.out.println("1 1");
			} else {
				long a, b;
				a = (h * w) / 2 + 1;
				b = (h * w) / 2;
				System.out.println(a + " " + b);
			}
		}
	}

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

Measured memory_bytes: 35788
from collections import Counter

def main():
    N = int(input())
    A = list(map(int, input().split()))
    c = Counter(A)
    comb = 0
    for i in c.values():
        if i >= 2:
            comb += i*(i-1)//2
    for i in range(N):
        print(comb - (c[A[i]] - 1))

if __name__ == '__main__':
    main()

Measured memory_bytes: 26780
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
MOD = (10 ** 9) + 7  # operować sobie na typie int32_t


def 関数(n, a):
    res = 0
    for i, num in enumerate(a):
        index = i + 1 
        index %= MOD
        if index % 2 and num % 2:
            res += 1
    return res

def çözmek():
    N = input()
    a = list(iimr())
    res = []
    res.append(関数(N,a))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()


Measured memory_bytes: 9124
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
using namespace std;

int main(){ 
  int a=0,b=0,c=0,n,x,y,m;
  cin>>n>>x>>y;
  rep(i,0,n){
    cin>>a>>b;
    if(a>=x && b>=y) c++;
  }
  co(c);
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<queue>
#include<cmath>
using namespace std;
int n,m;

int GCDi(int a,int b){
   if(b!=0)return GCDi(b,a%b);
    return a;
}
int LCMi(int a,int b){
    int t;
    t = GCDi(a,b);
    return a/t*b;
}
int main(){        int q[100],r[100],p = 0;

    while(~scanf("%d%d",&n,&m)){
        if(n > m){q[p] = GCDi(n,m);r[p] =LCMi(n,m);}
        else {q[p] = GCDi(m,n) ;r[p] =LCMi(m,n);}
        p++;
    }
    for(int i = 0;i < p;i ++) cout<<q[i]<<" "<<r[i]<<endl;
        return 0;
}



Measured memory_bytes: 3124
#!/usr/bin/env pypy3acc submit
import sys
from collections import deque
from itertools import *
 
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
 
x = LS()
 
for i,xx in enumerate(x):
    if xx == '0':
        print(i+1)
        exit() 

Measured memory_bytes: 9200
// B - Palindromic Numbers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b; cin>>a>>b;
	int count = 0;
	for(int i=1; i<=9; ++i){
		for(int j=0; j<=9; ++j){
			for(int k=0; k<=9; ++k){
				int s = i*10001 + j*1010 + k*100;
				if(a<=s && s<=b) count++;
			}
		}
	}
	cout<< count <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double ld;
template <typename T> inline void read(T &x){
    cin>>x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "E"
#define x first
#define y second
typedef pair <ld, ld> point;
struct circle{
    point o;
    ld r;
} c[1002];
vector <pair <int, ld> > g[1002];
point s, t;
int n;
inline ld dist(point A, point B){
    return sqrt((A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y));
}
void make_edge(int a, int b){
    ld d=dist(c[a].o, c[b].o);
    d=max(ld(0), d-c[a].r-c[b].r);
    g[a].pb(mp(b, d));
    g[b].pb(mp(a, d));
}
struct cmp{
    bool operator () (pair <int, ld> a, pair <int, ld> b){
        return a.second>b.second;
    }
};
priority_queue <pair <int, ld>, vector <pair <int, ld> >, cmp> q;
ld f[1002];
bool done[1002];
void dij(){
    q.push(mp(0, 0));
    int u;
    ld d;
    while(!q.empty()){
        u=q.top().first;
        d=q.top().second;
        q.pop();
        if(d>f[u]) continue;
        if(u==n) return;
        done[u]=1;
        for(pair <int, ld> p: g[u]){
            if(done[p.first]) continue;
            if(f[p.first]>d+p.second){
                f[p.first]=d+p.second;
                q.push(mp(p.first, f[p.first]));
            }
        }
    }
}
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(s.x);
    read(s.y);
    read(t.x);
    read(t.y);
    read(n);
    FOR(i, 1, n){
        read(c[i].o.x);
        read(c[i].o.y);
        read(c[i].r);
    }
    c[0].o=s;
    c[0].r=0;
    n++;
    c[n].o=t;
    c[n].r=0;
    FOR(i, 0, n) FOR(j, i+1, n) make_edge(i, j);
    FOR(i, 1, n) f[i]=1e20;
    dij();
    cout<<setprecision(15)<<fixed<<f[n];
}

Measured memory_bytes: 22292
A,B=map(int,input().split())

g=[["#"]*100 for _ in range(50)] +[['.']*100 for _ in range(50)]


for i in range(A-1):
    x=(i%50)*2
    y=(i//50)*2
    g[y][x]="."

for i in range(B-1):
    x=(i%50)*2
    y=51+(i//50)*2
    g[y][x]="#"

print(100,100)
for n in g:
    print("".join(n))

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

namespace CSharpSample01
{

    class Node
    {
        public List<Node> v;
        public int num;
        public int counter;
        public Node p;
        public int len;
        public bool find;
        public Node(int n)
        {
            num = n;
            counter = 0;
            v = new List<Node>();
            len = 0;
            find = false;
        }

        public void AddNode(Node s)
        {
            v.Add(s);
        }
    }

    class Program
    {

        static Node[] noder;
        static int[] c;
        static int N;

        //親pを設定する
        //深さを設定する
        static void DFS(int s, int d)
        {
            Stack<Node> st = new Stack<Node>();
            Node now = noder[s];
            st.Push(now);
            now.len = d;

            while(st.Count != 0)
            {
                now = st.Peek();
                bool flag = false;

                foreach(var son in now.v)
                {
                    if (!son.find)
                    {
                        son.len = now.len + 1;
                        son.p = now;
                        son.find = true;
                        st.Push(son);
                        flag = true;
                    }
                }

                if (!flag) st.Pop();
            }


        }

        //counter計算(N)
        static void CalCounter()
        {
            for(int i = 0; i <= N; i++)
            {
                if (noder[i].num == 0) continue;
                if(noder[i].num == 1)
                {
                    c[1] = noder[i].counter;
                    continue;
                }

                noder[i].counter += noder[i].p.counter;
                c[noder[i].num] = noder[i].counter;
            }
            
        }

        //表示
        static void Show()
        {
            for (int i = 1; i < N; i++) Console.Write($"{c[i]} ");
            Console.WriteLine(c[N]);
        }

        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            N = int.Parse(input[0]);
            int Q = int.Parse(input[1]);

            noder = new Node[N + 1];
            c = new int[N + 1];

            for (int i = 0; i <= N; i++) noder[i] = new Node(i);

            for(int i = 0; i < N - 1; i++)
            {
                input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
                noder[a].AddNode(noder[b]);
                noder[b].AddNode(noder[a]);
            }

            DFS(1, 1);

            for (int q = 0; q < Q; q++)
            {
                input = Console.ReadLine().Split(' ');
                int p = int.Parse(input[0]);
                int x = int.Parse(input[1]);
                noder[p].counter += x;
            }

            noder = noder.OrderBy(x => x.len).ToArray();            

            

            CalCounter();
            Show();

        }
    }
}

Measured memory_bytes: 71364
// AOJ 2686: Unfair Game
// 2018.2.27

#include <stdio.h>

int s[100002], N;
int a[5];

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

long long nim(long long x)
{
	long long t = 0;
	int i = N; while (i--) t ^= s[i] % x;
	return t;
}

int main()
{
	int A, B, i, j, f;
	long long t, x, y;

	N = in(), A = in(), B = in();
	for (i = 0; i < N; i++) s[i] = in();

	if (A >= B) {
		f = (nim(B+1) != 0);
		if (A > B && !f) for (i = 0; i < N; i++) if (s[i] > B) { f = 1; break; }
	} else {
		f = ((t = nim(A+1)) != 0);
		j = 0; for (i = 0; i < N && j < 2; i++) { if (s[i] > A) a[j++] = i; }
		if (f) {
			if (j > 1) f = 0;
			else if (j == 1) {
				x = (s[a[0]] % (A+1)) ^ t;
				y = s[a[0]] - x;
				if (y <= 0 || A < y || x > A) f = 0;
			}
		}
    }
    puts(f? "Hanako": "Jiro");
	return 0;
}


Measured memory_bytes: 2100
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
vector <int> v[100005];
int n, d[100005];
bool cmp(int x,int y)
{
    return d[x] > d[y];
}
void dfs(int x)
{
	for(int i = 0; i < v[x].size(); i++)
		dfs(v[x][i]);
	sort(v[x].begin(), v[x].end(), cmp);
	for(int i = 0; i < v[x].size(); i++)
		d[x] = max(d[x],  d[v[x][i]] + i + 1);
}
int main()
{
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++)
    {
        int a;
        cin >> a;
        v[a].push_back(i);
    }
	dfs(1);
	cout << d[1];
	return 0;
}


Measured memory_bytes: 10752
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

char x, y;

int main(int argc, char const* argv[])
{
    cin >> x >> y;
    if(x < y) puts("<");
    else if(x == y) puts("=");
    else puts(">");
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    white_list = set(
        [a * b for a in range(1, 10) for b in range(1, 10)]
        )
    if N in white_list:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >>s>>t;
    int c = 0;
    for(int i = 0; i< s.length(); i++){
        if(s[i] != t[i])
            c++;
    }
    cout << c <<endl;
    return 0;
}

Measured memory_bytes: 3780
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
long ans=1;
long mod=(int)pow(10,9)+7;
int n = Integer.parseInt(sc.next());
for (int i = 1; i <= n; i++) {
ans*=i;
ans=ans%mod;
}
    out.println(ans);
}}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

#define pi 3.14159265358979323846

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


const int MAX = 42;




int main() {
  ll N;
  cin >> N;

  vector<ll> A(N);

  rep(i, 0, N){
    cin >> A[i];
  }
  
  ll stock = 0, money = 1000;
  for(ll i = 0; i < N-1; i++){
    stock = 0;
    if(A[i] < A[i+1]) stock = money / A[i];
    money += (A[i+1] - A[i]) * stock;
  }
  cout << money << endl;

  // cout << setprecision(8) << ans << endl;  // For double
}



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

int n,m;
char s[105][105];
int dp[105][105][2];
deque < int > q1,q2,q3;

int f(){
	q1.push_front(0), q2.push_front(0), q3.push_front(0);
	dp[0][0][0] = 0;
	while ( !q1.empty() ){
		int x = q1.front(); q1.pop_front();
		int y = q2.front(); q2.pop_front();
		int t = q3.front(); q3.pop_front();
		int z = dp[x][y][t];
		if ( t == 0 ){
			if ( dp[x][y][1] > z ){
				dp[x][y][1] = z ;
				q1.push_front(x);
				q2.push_front(y);
				q3.push_front(1);
			}
			if ( s[x][y] == '.' ){
				if ( x + 1 < n && dp[x+1][y][t] > z ){
					dp[x+1][y][t] = z ;
					q1.push_front(x+1);
					q2.push_front(y);
					q3.push_front(t);
				}
				if ( y + 1 < m && dp[x][y+1][t] > z ){
					dp[x][y+1][t] = z ;
					q1.push_front(x);
					q2.push_front(y+1);
					q3.push_front(t);
				}
			}
		} else {
			if ( dp[x][y][0] > z + 1 ){
				dp[x][y][0] = z + 1 ;
				q1.push_back(x);
				q2.push_back(y);
				q3.push_back(0);
			}
			if ( s[x][y] == '#' ){
				if ( x + 1 < n && dp[x+1][y][t] > z  ){
					dp[x+1][y][t] = z ;
					q1.push_front(x+1);
					q2.push_front(y);
					q3.push_front(t);
				}
				if ( y + 1 < m && dp[x][y+1][t] > z ){
					dp[x][y+1][t] = z ;
					q1.push_front(x);
					q2.push_front(y+1);
					q3.push_front(t);
				}
			}
		}
	}
	
	if ( s[n-1][m-1] == '#' ) return dp[n-1][m-1][1] + 1;
	return dp[n-1][m-1][0];
}

int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	scanf("%d%d",&n,&m);
	for ( int i = 0; i < n; i++ ) scanf("%s",&s[i]);
	
	for ( int i = 0; i < n; i++ )
		for ( int j = 0; j < m; j++ )
			for ( int k = 0; k < 2; k++ )
				dp[i][j][k] = 1e9;
	int ans = f();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports, dead_code, non_camel_case_types)]

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// お約束
use std::collections::{HashMap, BinaryHeap, BTreeMap};
const MOD : usize = 1_000_000_007;
macro_rules! Print {($t:expr) => {println!("{}", $t);};}
macro_rules! Debug {($t:expr) => {println!("{:?}", $t);};}

// エントリーポイント
fn main() {
    input! {
        N : isize,
        V : [f64; N]
    }
    V.sort_by(|a, b| a.partial_cmp(b).unwrap());
    // Debug!(V);
    Print!(V[1..].iter().fold(V[0], |sum, v| (sum + v) / 2.0));
}


Measured memory_bytes: 4352
def dig_check(i,d):
    for k in [int(j) for j in str(i)]:
        if k in d:
            return False
    return True


N,K = input().split()
N = int(N)

d = [int(i) for i in input().split()]

for i in range(100001):
    if i >= N :
        if dig_check(i,d):
            print(i)
            break



Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
  int n,cnt = 0;
  cin >> n; 
  string s;
  cin >> s;
  for (int i = 0; i < n-2; i++){
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C'){
      cnt ++;
    }
  }
  cout << cnt << '\n';
  return 0;   
}

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

int main(){
    int w,h;
    cin >> w >> h;
    vector<pair<long long,bool>> v;
    for(int i=0; i<w; i++){
        long long t;
        cin >> t;
        v.push_back(make_pair(t,true));
    }
    for(int i=0; i<h; i++){
        long long t;
        cin >> t;
        v.push_back(make_pair(t,false));
    }
    sort(v.begin(),v.end());
    long long ans = 0;
    for(auto p = v.begin(); p != v.end(); p++){
        if((*p).second){
            ans += (*p).first * (h+1);
            w--;
        }
        else{
            ans += (*p).first * (w+1);
            h--;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
            int D = in.nextInt();
            int E = in.nextInt();
            int F = in.nextInt();

            int[][] dp = new int[3001][3001];
            dp[0][0] = 1;
            for (int water = 0; water < 3001; water++) {
                for (int sugar = 0; sugar < 3001; sugar++) {
                    if (dp[water][sugar] == 0) {
                        continue;
                    }

                    if (water + 100 * A + sugar <= F) {
                        dp[water + 100 * A][sugar] = dp[water][sugar];
                    }
                    if (water + 100 * B + sugar <= F) {
                        dp[water + 100 * B][sugar] = dp[water][sugar];
                    }
                    if (water + sugar + C <= F) {
                        if ((sugar + C) <= E * water / 100) {
                            dp[water][sugar + C] = dp[water][sugar];
                        }
                    }
                    if (water + sugar + D <= F) {
                        if ((sugar + D) <= E * water / 100) {
                            dp[water][sugar + D] = dp[water][sugar];
                        }
                    }
                }
            }

            int maxWater = 100;
            int maxSugar = -1;
            for (int water = 100; water < 3001; water += 100) {
                for (int sugar = 0; sugar < 3001; sugar++) {
                    if (dp[water][sugar] == 0) {
                        continue;
                    }
                    if ((double) sugar / (water + sugar) > (double) maxSugar / (maxWater + maxSugar)) {
                        maxWater = water;
                        maxSugar = sugar;
                    }
                }
            }

            System.out.println((maxWater + maxSugar) + " " + maxSugar);
        }
    }
}


Measured memory_bytes: 77720
# 理解する時間がなかったので、とりあえず写経
from bisect import bisect_left
from operator import itemgetter

N, Q = [int(i) for i in input().split()]
Construction = [tuple(int(i) for i in input().split()) for j in range(N)]
D = [int(input()) for _ in range(Q)]

ans = [-1] * Q
skip = [-1] * Q

Construction.sort(key=itemgetter(2))

for s, t, x in Construction:
    l = bisect_left(D, s - x)
    r = bisect_left(D, t - x)
    t = l
    while t < r:
        if skip[t] == -1:
            ans[t] = x  # lからr-1の時刻に出発した人は座標xの工事に引っかかる
            skip[t] = r  # lからr-1の時刻に出発した人はもう調べないようにする
            t += 1
        else:
            t = skip[t]  # tが指定する人はもう調べ終わっているので飛ばす
print(*ans, sep='\n')


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

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

    int k=0, l=0;
    bool flag=false;

    for(k=0;k<100;k++)
    {
        for(l=0;l<100;l++)
        {
            if(4*k+7*l == n)
            {
                flag = true;
            }
        }
    }

    if(flag)
    {
        cout << "Yes" << endl;
    }
    
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

#define ll long long
#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()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string  s; cin >> s;
    int n = s.size();
    int r=0,l=0;
    int cnt=0;
    int ans[n] = {};
    int i = 0;
    while(i<n){
        cnt=0,r=0,l=0;
        while(s[i]=='R'){
            i++;cnt++;
            if(cnt%2==0) l++;
            if(cnt%2==1) r++;
        }
        int rlocate = i-1;
        int llocate = i;
        cnt=0;
        while(s[i]=='L'){
            i++;cnt++;
            if(cnt%2==0) r++;
            if(cnt%2==1) l++;
            if(i==n) break;
        }
        ans[rlocate] += r;
        ans[llocate] += l;
    }
    rep(i,0,n) cout << ans[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1104
import java.util.*;

public class Main {

// global
static long fact[];
static long inverse[];
static int mod = 1_000_000_007;

static long pow(long a,int n) {
    long res=1;
    while (n>0) {
        if ((n-n/2*2)==1) {
            res=res*a%mod;
        }
        a=a*a%mod;
        n>>=1;
    }
    return res;
}

static long modinv(long n) {
    return pow(n, mod-2);
}

static long comb(int n,int k){
    if(n<0 || k<0 || n<k)return 0;
    return fact[n]*(inverse[k]*inverse[n-k]%mod) %mod;
}


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // main method
        fact=new long[2400005];
        fact[0]=1;
        inverse=new long[2400005];
        inverse[0]=1;
        for(int i=1;i<2400005;i++){
            fact[i]=(fact[i-1]*(long)i)%mod;
            inverse[i]=modinv(fact[i]);
        }

        int r1 = sc.nextInt();
        int c1 = sc.nextInt();
        int r2 = sc.nextInt();
        int c2 = sc.nextInt();
        long ans = 0L;
        for (int i=r1;i<r2+1;i++) {
            ans = (ans+comb(i+c2+1, c2)-comb(i+c1, c1-1))%mod;
        }
        ans = (ans+mod)%mod;
        System.out.println(ans);
    }
}


Measured memory_bytes: 62164
#include <bits/stdc++.h>
using namespace std;
#define mod 1e9+7
typedef long long ll; 
typedef vector<long long> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef set<int> si; 
typedef map<string, int> msi; 
 
int main(){
  ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
   ll n,i;
  cin>>n;string z;
  vector<string> a;
  for(i=0;i<n;i++){
    cin>>z;
    a.push_back(z);
  }
  set<string> s;
  for(i=0;i<n;i++){
  s.insert(a[i]);
  }
   cout<<s.size();
  return 0;
}

Measured memory_bytes: 24972
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	int d;
	cin >> d;
	if (d == 25) cout << "Christmas" << endl;
	else if (d == 24) cout << "Christmas Eve" << endl;
	else if (d == 23) cout << "Christmas Eve Eve" << endl;
	else if (d == 22) cout << "Christmas Eve Eve Eve" << endl;

	return 0;
}

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

typedef long double ld;

int n, m, d, a;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> d;
	a = max(0, n - d);
	ld ans = 2 * (m - 1);
	ans /= n;
	ans /= n;
	ans *= a;
	if(d == 0)
		ans /= 2;
	cout << fixed << setprecision(20) << ans;
	return 0;
}
//1000000000 180707 0

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;
    long long H;
    cin >> H;

    vector<int> A(n);
    vector<int> B(n);

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

    vector<int> ord(n);
    iota(ord.begin(), ord.end(), 0);
    sort(ord.begin(), ord.end(),
        [&](int l, int r) { return B[l] > B[r];});

    vector<int> ord2(n);
    iota(ord2.begin(), ord2.end(), 0);
    sort(ord2.begin(), ord2.end(),
        [&](int l, int r) { return A[l] > A[r];});

    long long res = 1LL << 50;
    long long sum = 0;

    for (int i = 0, j = 0; i < n; ++i) {
        while (j < n && B[ord[j]] >= A[ord2[i]]) {
            sum += B[ord[j]];
            if (sum >= H) {
                res = min(res, j + 1LL);
            }
            ++j;
        }
        long long cnt = j;
        long long rem = max(0LL, H - sum);
        cnt += (rem + A[ord2[i]] - 1) / A[ord2[i]];
        res = min(res, cnt);
    }

    cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
        int n,a,b,p,one=0,two=0,three=0;
        cin >> n;
        cin >> a >> b;
        for(int i=0;i<n;i++){
                    cin >> p;
                    if(p<=a) one++;
                    else if(a<p&&p<=b)  two++;
                    else three++;
        }
        cout << min(one,min(two,three)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, m, q;
    cin >> n >> m >> q;

    vvll res(n, vll(n));
    ll l, r;
    REP(i, m){
        cin >> l >> r;
        l--, r--;
        res[l][r]++;
    }
    vvll sum(n, vll(n + 1));
    REP(i, n){
        REP(j, n){
            sum[i][j + 1] = sum[i][j] + res[i][j];
        }
    }
    ll s, t;
    REP(i, q){
        cin >> s >> t;
        s--;
        t--;
        ll tmp = 0;
        FOR(j, s, t){
            tmp += (sum[j][t + 1] - sum[j][s]);
        }
        cout << tmp << endl;
    }
    return 0;
}


Measured memory_bytes: 4864
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int a=in.nextInt();
		int b=in.nextInt();
		int c=in.nextInt();
		if((c-b)%2==0)
                    System.out.println("Alice");
                else
                    System.out.println("Borys");
	}
}


Measured memory_bytes: 23764
#include <vector>
#include <cassert>
#include <iostream>
using namespace std;
const int mod = 1000000007;
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int> > dp(H + 1, vector<int>(W, 0)); dp[0][0] = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < 1 << (W - 1); ++k) {
				// Check if two horizontal lines are connecting
				bool ok = true;
				for (int l = 0; l < W - 2; ++l) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						// The case which goes left
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mod;
					}
					else if (j <= W - 2 && ((k >> j) & 1)) {
						// The case which goes right
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mod;
					}
					else {
						// The case which goes straight
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
			}
		}
	}
	cout << dp[H][K - 1] << '\n';
	return 0;
}

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

using namespace std ;

const int MAX = 3000 + 10 ;

int arr[MAX][MAX] ;
int n , m , k ;

long long dp[MAX][MAX][4] ;

long long solve(int i , int j , int cnt)
{
	if(i == n || j == m)
		return 0 ;
	long long &ret = dp[i][j][cnt] ;
	if(ret != -1)
		return ret ;
	ret = 0 ;
	ret = max(ret , solve(i+1 , j , 0)) ;
	ret = max(ret , solve(i , j+1 , cnt)) ;
	if(cnt != 3)
	{
		ret = max(ret , solve(i+1 , j , 0) + arr[i][j]) ;
		ret = max(ret , solve(i , j+1 , cnt+1) + arr[i][j]) ;
	}
	return ret ;
}

int main()
{
	memset(dp , -1 , sizeof(dp)) ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n>>m>>k ;
	while(k--)
	{
		int i , j ;
		cin>>i>>j ;
		i-- , j-- ;
		cin>>arr[i][j] ;
	}
	return cout<<solve(0 , 0 , 0)<<"\n" , 0 ;
}		

Measured memory_bytes: 322372
#include "bits/stdc++.h"
using namespace std;
const int maxn = 1e5 + 100;
typedef long long ll;
vector<int> e[maxn];
int n, m;
int ans[maxn];
int v[maxn], d[maxn], c[maxn];
int maxx[maxn];

struct node
{
    int vec, d;
};
queue<node> q;

void bfs(int v, int d, int c)
{
    node temp;
    temp.vec = v;
    temp.d = 0;
    if(maxx[v]<d-temp.d)
    {
        maxx[v]=d-temp.d;
        if(ans[temp.vec]==0)
        {
            ans[temp.vec]=c;
        }
        q.push(temp);
    }
    while (!q.empty())
    {
        temp = q.front();
        q.pop();
        int to = e[temp.vec].size();
        for (int i = 0; i < to; i++)
        {
            if(maxx[e[temp.vec][i]]<d-temp.d-1)
            {
                node te;
                te.vec=e[temp.vec][i];
                te.d=temp.d+1;
                maxx[te.vec]=d-te.d;
                if(ans[te.vec]==0)
                {
                    ans[te.vec]=c;
                }
                q.push(te);
            }

        }
    }
}
void init()
{
    for(int i=0; i<=n; i++)
    {
        maxx[i]=-1;
    }
}
int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d %d", &n, &m);
    init();
    int a, b;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &a, &b);
        e[a].push_back(b);
        e[b].push_back(a);
    }
    int _;
    scanf("%d", &_);
    for (int i = 0; i < _; i++)
    {
        scanf("%d %d %d", &v[i], &d[i], &c[i]);
    }
    for (int i = _ - 1; i >= 0; i--)
    {
        bfs(v[i], d[i], c[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 8952
fun main(args: Array<String>) = abc156d()

fun abc156d() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toInt() }

    var answer = modPow(2, n.toLong())
    answer -= 1
    answer = (answer + MOD) % MOD
    answer -= comb(n, a)
    answer = (answer + MOD) % MOD
    answer -= comb(n, b)
    answer = (answer + MOD) % MOD

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

private fun modPow(n: Long, p: Long): Long {
    var x = n
    var y = p
    var result = 1L
    x %= MOD
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x) % MOD
        y = y shr 1
        x = (x * x) % MOD
    }
    return result
}

private fun comb(n: Int, k: Int): Long {
    if (n < k) return 0
    val min = Math.min(k, n - k)
    var numerator = 1L
    var denominator = 1L
    for (i in 1L..min) {
        numerator *= n - i + 1
        numerator %= MOD
        denominator *= i
        denominator %= MOD
    }
    return numerator * modPow(denominator, MOD - 2) % MOD
}


Measured memory_bytes: 38180
#include<bits/stdc++.h>
#define int long long int
#define mod 1000000007
#define inf 1e18
#define fo(i,y,n,inc)	for(int i=y;i<n+y;i+=inc)
#define cin(t) int t;cin>>t
#define w(t) while(t--)
#define nl cout<<endl;
#define pb push_back
#define ft(i) (i&(-1*i))
#define arrIn(arr,size)		for(int i=0;i<size;i++){cin>>arr[i];}
#define arrOut(arr,size,seperater)	for(int i=0;i<size;i++){cout<<arr[i]<<seperater;}
using namespace std;

int max(int a, int b) {
	if (a > b)
		return a;
	return b;
}

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

int powmd(int a, int b) {
	if (b == 1)	return a;
	if (b == 0)	return 1;

	int half = powmd(a, b / 2);
	int ans = half * half;
	ans %= mod;
	if (b & 1) {
		ans *= a;
	}
	ans %= mod;
	return ans;
}

void fastIO() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}

int n, k;
int arr[105];
int dp[105][100005];

int solve(int currPos, int rem) {

	if (rem < 0) {
		// cout << "return 1" << endl;
		return 0;
	}

	if (currPos < 0) {
		return 0;
	}

	if (currPos == 0) {
		if (rem <= arr[0]) {
			return 1;
		}
		return 0;
	}

	if (dp[currPos][rem] != -1)	return dp[currPos][rem];

	dp[currPos][rem] = solve(currPos, rem - 1) + solve(currPos - 1, rem) - solve(currPos - 1, rem - 1 - arr[currPos]);
	dp[currPos][rem] += mod;
	dp[currPos][rem] %= mod;

	return dp[currPos][rem];

}

int32_t main() {

	memset(dp, -1, sizeof(dp));

	cin >> n >> k;
	fo(i, 0, n, 1)	cin >> arr[i];

	cout << solve(n - 1, k); nl;

	return 0;
}

// cout << "Case #" << i << ": " << answer << endl;

Measured memory_bytes: 88576
#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 vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#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 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)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<63;
const long long MOD = 1000000007;

#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;
    FOR(i,N,1000){
        if(i%10 == i/100 && i%10 == (i/10)%10){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <fstream>
#include <map>
#include <set>

using namespace std;


#define ll long long int


int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll x, k;
    
    cin>>x>>k;
    
    ll mini = x%k;
    
    mini = k-mini < mini?k-mini : mini;
    
    cout<<mini<<endl;
    
    
    return 0;
    
}


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

#define ll long long
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define M 1000000007

vector<ll> v[100005];
ll final=LLONG_MAX;

void printSubsequences(vector<ll> arr, ll index,  vector<ll> subarr, vector<ll> v[],ll x) 
{  
	if (index == arr.size()) 
	{
		ll l = subarr.size(); 
		if (l != 0) 
		{
			vector<ll> t1(v[subarr[0]].size()+5);
			ll f=0,yash=0;
			for(ll i=0;i<l;i++)
			{
				yash+=v[subarr[i]][0];
				for(ll j=1;j<v[subarr[i]].size();j++)
				{
					t1[j]+=v[subarr[i]][j];
				}
			}
			for(ll i=1;i<v[subarr[0]].size();i++)
			{
				if(t1[i]<x) f=1;
			}
			if(f==0)
			{
				final=min(final,yash);
			}
		}
	}
	else
	{
		printSubsequences(arr, index + 1, subarr,v,x); 
		subarr.push_back(arr[index]); 
		printSubsequences(arr, index + 1, subarr,v,x); 
	} 
	return; 
}

void solve()
{	
	ll n,m,x;
	cin>>n>>m>>x;
	vector<ll> b,v1;
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<m+1;j++)
		{
			ll x;
			cin>>x;
			v[i].push_back(x);
		}
	}
	for(ll i=0;i<n;i++) v1.push_back(i);
	printSubsequences(v1,0,b,v,x);
	if(final==LLONG_MAX) cout<<"-1";
	else cout<<final;
}

int main()
{
	FAST
	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++) solve();
	return 0;
}

Measured memory_bytes: 5984
#include<stdio.h>
#include <unistd.h>
#include <stdlib.h>
typedef struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
}node;
typedef struct node * Node;

int pre(Node);

int sch(int,Node);
int mid(Node);

Node nose(int);

int in(Node,int);

void freedom(Node);

int main(){
  int j,n,i,ndnm;
  char b[7];
  Node first,now;
  scanf("%d",&n);
  scanf("%s %d",b,&ndnm);
  first = nose(ndnm);
  for(i=0;i<n-1;i++){
    scanf("%s",b);
    if(b[0]=='i'){
      scanf("%d",&ndnm);
      in(first,ndnm);
    }else if(b[0]=='p'){
      mid(first);
      printf("\n");
      pre(first);
      printf("\n");
    }else{
      scanf("%d",&ndnm);
      if(sch(ndnm,first)==1){
	printf("yes\n");
      }else{
	printf("no\n");

      }
    }
  }
freedom(first);

}
int in(Node now,int ndnm){
  while(1){
//printf("now =%d ",now->key);
    if(ndnm >= now->key){
      if(now->r != NULL)
	now = now->r;
      else{
	now->r=nose(ndnm);
	break;
      }
    }else{
      if(now->l != NULL)
	now = now->l;
      else{
	now->l=nose(ndnm);
	break;
      }
    }
  }
return 0;
}
Node nose(int key){

Node set;
set =(Node)malloc(sizeof(node));
  set->key=key;
  set->r=NULL;
  set->l=NULL;
  return set;
}

int mid(Node a){
  if(a->l != NULL)
    mid(a->l);
  printf(" ");
  printf("%d",a->key);
  if(a->r !=NULL)
    mid(a->r);
  return 0;
}

int sch(int key,Node a){
  if(key == a->key)
    return 1;
  if(key<a->key){
    if(a->l != NULL)
      return sch(key,a->l);
    else
      return 0;
  }else{
    if(a->r !=NULL)
      return sch(key,a->r);
    else
      return 0;
  }
  return 0;
}

int pre(Node a){
  printf(" ");
  printf("%d",a->key);
  if(a->l != NULL)
    pre(a->l);
  if(a->r !=NULL)
    pre(a->r);
  return 0;
}

void freedom(Node a){
  if(a->l != NULL)
    freedom(a->l);
  if(a->r !=NULL)
    freedom(a->r);
free(a);
}




Measured memory_bytes: 20448
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(ll i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(ll i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	ll t;
	cin>>t;
	string s;
	cin>>s;
	ll e=0;
	if(t%2==0)
	{
		forin(i,0,t/2 -1)
		{
			if(s[i]!=s[i+t/2])
			{
				e++;
				break;
			}
		}
	}
	else
	{
		e++;
	}
	if(e)
	cout<<"No"<<endl;
	else
	cout<<"Yes"<<endl;
}



Measured memory_bytes: 256
import Foundation

let input = readLine()!.components(separatedBy: " ").map { Int($0)! }
let x = input[0]
let k = input[1]
let d = input[2]

let res: Int
if (x > 0) {
  let c = Int(ceil(Double(x) / Double(d)))
  if c > k {
    res = x - k * d
  } else {
    let r = k - c
    if (r % 2 == 0) {
      res = x - c * d
    } else {
      res = x - c * d + d
    }
  }
} else {
  let c = Int(ceil(abs(Double(x)) / Double(d)))
  if c > k {
    res = x + k * d
  } else {
    let r = k - c
    if (r % 2 == 0) {
      res = x + c * d
    } else {
      res = x + c * d - d
    }
  }
}

print(abs(res))


Measured memory_bytes: 13920
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#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()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) for(auto&& x : v){cerr << x << " ";} cerr << endl
#define printVV(vv) for(auto&& v : vv){for(auto&& x : v){cerr << x << " ";}cerr << endl;}
#define printP(p) cerr << p.first << " " << p.second << endl
#define printVP(vp) for(auto&& p : vp) printP(p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    int a, b;
    cin >> a >> b;
    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else if (a > 0 || (b - a + 1) % 2 == 0) {
        cout << "Positive" << endl;
    } else {
        cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256
let () = Scanf.scanf "%d %d\n" @@ fun m k ->
  if 0 < k then
    if 1 lsl m <= k || ((1 lsl m) - 1) mod 4 <> 3 then print_endline "-1"
    else begin
      Printf.printf "%d " k;
      for i = 0 to (1 lsl m) - 1 do
        if i <> k then
          Printf.printf "%d " i
      done;
      Printf.printf "%d " k;
      for i = (1 lsl m) - 1 downto 0 do
        if i <> k then
          Printf.printf "%d " i
      done;
    end
  else begin
    for i = 0 to (1 lsl m) - 1 do
      Printf.printf "%d " i
    done;
    for i = (1 lsl m) - 1 downto 0 do
      Printf.printf "%d " i
    done;
  end

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

int main() {
    int m, nmin, nmax;
    while(cin >> m >> nmin >> nmax, m) {
        vector<int> p(m);
        for(int i=0; i<m; ++i) {
            cin >> p[i];
        }
        int gap = 0;
        int res = 0;
        for(int i=nmax-1; i>=nmin-1 && i+1<m; --i) {
            if(gap < p[i] - p[i+1]) {
                gap = p[i] - p[i+1];
                res = i+1;
            }
        }
        cout << res << endl;
    }
}


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

int main() {
  int a, b, c;
  int prod;
  
  cin >> a >> b >> c;
  prod = a * b * c;
  if (prod == (5*7*5)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256