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

public class Main {
	static Scanner sc;
	static PrintWriter out;
	static char grid[][];
	static int h,w;
	static int memo[][];
	static final int uncal = -1,mod = 1_000_000_007;
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		h = sc.nextInt();
		w = sc.nextInt();
		grid = new char[h][w];
		memo = new int[h][w];
		clear();
		for (int i = 0; i < h; i++) {
			grid[i] = sc.nextLine().toCharArray();
		}
		out.println(dp(0, 0));
		out.flush();
		out.close();
	}
	static void clear() {
		for(int[]a:memo){
			Arrays.fill(a, uncal);
		}
	}
	static int dp(int i,int j) {
		if(i+1 == h && j+1 == w) return 1;
		if(memo[i][j] != uncal)
			return memo[i][j];
		int right = 0,down =0;
		if(j+1<w && grid[i][j+1]=='.')
			right = dp(i, j+1)%mod;
		if(i+1<h && grid[i+1][j]=='.')
			down = dp(i+1, j)%mod;
		return memo[i][j] = (right + down)%mod;
	}
	static class Scanner{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		private String next() throws Exception{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws Exception{
			return Integer.parseInt(next());
		}
		public long nextLong() throws Exception{
			return Long.parseLong(next());
		}
		public double nextDouble() throws Exception{
			return Double.parseDouble(next());
		}
		public String nextLine() throws Exception {
			return br.readLine();
		}

	}
}


Measured memory_bytes: 33984
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}

/* main */

signed main(){
    ll N,H,W;
    cin >> N >> H >> W;
    cout << (N-H+1)*(N-W+1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main(){
   int t=1;
   string S;
   while(cin >> S){
	if((S=="B,C")||(S=="C,B")){
		if(t==1){
			t=1;
		}else if(t==2){
			t=3;
		}else if(t==3){
			t=2;
		}
	}else if((S=="A,C")||(S=="C,A")){
		if(t==1){
			t=3;
		}else if(t==2){
			t=2;
		}else if(t==3){
			t=1;
		}
	}else if((S == "A,B")||(S == "B,A")){
		if(t==1){
			t=2;
		}else if(t==2){
			t=1;
		}else if(t==3){
			t=3;
		}
	}
   }

   if(t==1){
	 cout << "A" << endl;
   }else if(t==2){
	 cout << "B" << endl;
   }else if(t==3){
	 cout << "C" << endl;
   }
   return 0;
}


		

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
using namespace std;
int main()
{
	IOS;
     string s;
     cin>>s;
     ll i,sum=0;
     for(i=0;i<s.size();i++)
     {
     	sum=sum+s[i]-'0';
	 }
	 if(sum%9==0) cout<<"Yes"<<endl;
	 else cout<<"No"<<endl;
}


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

public class Main {

	static long INF=(long)1e18;;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt(),W=sc.nextInt();
		long [][]dp=new long [n+1][100001]; // dp[i][v] = min w such that I can get value v from items of weight w after consider the first i items
		for(long []x:dp)
			Arrays.fill(x, INF);
		dp[0][0]=0;
		for(int i=1;i<=n;i++) {
			int w=sc.nextInt(),v=sc.nextInt();
			for(int oldVal=0;oldVal<dp[0].length;oldVal++)
				if(dp[i-1][oldVal]!=INF)
				{
					dp[i][oldVal]=Math.min(dp[i][oldVal],dp[i-1][oldVal]); //leave
					int newVal=oldVal+v;
					
					dp[i][newVal]=Math.min(dp[i][newVal], dp[i-1][oldVal]+w); // take
				}
			
			
		}
		int ans=0;
		for(int v=0;v<dp[0].length;v++)
			if(dp[n][v]<=W)
				ans=v;
		out.println(ans);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

	}
}

Measured memory_bytes: 126312
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

    int n;
    int per[] = {1,2,3,4,5,6,7,8};
    int p[8], q[8];
    int p_num, q_num;

    cin >> n;

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

    int cnt = 0;
    do{
        int f_p = 1, f_q = 1;
        for(int i = 0; i < n; i++){
            if(per[i] != p[i]){
                f_p = 0;
            }
            if(per[i] != q[i]){
                f_q = 0;
            }
        }

        if(f_p){
            p_num = cnt;
        }
        if(f_q){
            q_num = cnt;
        }

        cnt++;

    }while(next_permutation(per, per+n));

    if(p_num < q_num){
        cout << q_num - p_num << endl;
    }
    else{
        cout << p_num - q_num << 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;

int main(){
    int N,A,B,C;
    cin >> N;
    A = N/100;
    B = (N - 100*A)/10;
    C = (N - 100*A - 10*B);
    if(A ==7 || B == 7 || C == 7){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
    string s, ans = "Yes";
    cin >> s;
    
    vector<int> cnt(26, 0);
    for (int i = 0; i < s.size(); i++) {
        cnt.at(s.at(i)-'a')++;
    }
    
    for (int c : cnt) {
        if (c % 2 != 0) ans = "No";
    }
    
    cout << ans << endl;
}


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

int main(){
  int N, K, x = 0;
  int sum = 0;
  cin >> N >> K;
  
  rep(i,N){
    cin >> x;
    if(x <= K/2)
      sum += 2*x;
    else if(x <= K)
      sum += 2*(K-x);
    else
      sum += 2*(x-K);
  }
  cout << sum << endl;

}

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

#define INF (1<<29)

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    for(int i=0; i<n; i++) cin >> S[i];
    
    int ch[55][155];
    for(int i=0; i<55; i++){
        for(int j=0; j<155; j++){
            ch[i][j] = 0;
        }
    }
    
    
    for(int i=0; i<n; i++){
        for(int j=0; j<S[i].size(); j++){
            ch[i][S[i][j]]++;
        }
    }
    vector<int> c(155,INF);
    for(int cha='a'; cha<='z'; cha++){
        for(int i=0; i<n; i++){
            c[cha] = min(c[cha], ch[i][cha]);
        }
    }
    
    vector<char> s;
    for(char cha='a'; cha<='z'; cha++){
        if(c[cha]>0){
            while(c[cha]!=0){
                s.push_back(cha);
                c[cha]--;
            }
        }
    }
    sort(s.begin(),s.end());
    for(int i=0; i<s.size(); i++){
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
// Bismillahir Rahmanir Rahim
// AtCoder-

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

int main(){
 int n; cin>>n;
 long long cnt = 0;
 for(int i = 1; i <= n; ++i){
 	if((i%3==0)&&(i%5==0)){
 		continue;
	 }
	 else if(i%3==0){
	 continue;
}
	 else if(i%5==0){
	 	continue;
	 }
	 else cnt += i;
 }
 cout<<cnt<<endl;
 return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H,W,M; cin>>H>>W>>M;
    unordered_map<int,int> xmp,ymp;
    vector<pi> vec;
    int mx=0,my=0;
    rep(i,M){
        int y,x; cin>>y>>x;
        xmp[x]++;
        chmax(mx,xmp[x]);
        ymp[y]++;
        chmax(my,ymp[y]);
        vec.pb({y,x});
    }
    sort(all(vec));
    vi vx,vy;
    for(auto e:xmp){
        if (e.se==mx) vx.pb(e.fi);
    }
    for(auto e:ymp){
        if (e.se==my) vy.pb(e.fi);
    }
    int A = vx.size();
    int B = vy.size();
    // rep(i,A) cout<<vx[i]<<" "; cout<<endl;
    // rep(i,B) cout<<vy[i]<<" "; cout<<endl;
    if ((ll)A*B>M){
        cout<<mx+my<<endl;
        return 0;
    }
    bool exist=false;
    rep(i,A)rep(j,B){
        if (!binary_search(all(vec),pi(vy[j],vx[i]))){
            exist=true;
            break;
        }
    }
    if (exist){
        cout<<mx+my<<endl;
    }else{
        cout<<mx+my-1<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    ll res=0;
    vector<int> dp(2019,0);
    for(char c:s)
    {
        vector<int> nxt(2019,0);
        for(int i=0;i<2019;i++) nxt[(10*i+(c-'0'))%2019]+=dp[i];
        nxt[c-'0']++;
        dp=nxt;
        res+=dp[0];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1<<28
#define MAX 200005
#define PI 2*acos(0.0)
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n;
    cin>>n;
    cout<<(n-2)*180<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char s[11];
  int i;
  for(i=0;i<10;i++){
    scanf("%s",&s[i]);
    if(i==3) s[i]='8';
  }
  s[11]='\0';
  printf("%s\n",s);
  return 0;
}

Measured memory_bytes: 128
void main() {
	auto N = ri;
	fact(N).writeln;
}

ulong fact(ulong n) {
	if(n<=1) return 1;
	else return n*fact(n-1)%(10UL^^9 + 7);
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 3324
#include<stdio.h>
#define MAX 100000
int P[MAX],F[MAX]={0},i,j,N,x,p=0,r=0;


int main()
{
	for(i=2;i<MAX;i++)
		if(!F[i])
		{
			P[p++]=i;
			for(j=i*2;j<MAX;j+=i)
				F[j]=1;
		}
	for(scanf("%d",&N);N--;)
	{
		scanf("%d",&x);
		for(i=0;i<p;i++)
			if(x!=P[i]&&!(x%P[i]))break;
		if(i==p)r++;
	}
	printf("%d\n",r);
	return 0;
}

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

using namespace std;

int main()
{
  long long int N,ans,mod;
  cin >> N;
  mod = 10;
  for(int i=0; i < 8; i++)
    mod = mod * 10;
  mod = mod + 7;
  ans = 1;
  for(int i=0; i < N; i++)
    ans = (ans * (i+1)) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define LL long long
using namespace std;
const LL Maxn = 1000010;
const LL Mod = 1e9+7;
LL jc[Maxn<<1], inv[Maxn<<1];
LL x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
struct Point {
	LL x, y;
}a[4], b[4];
LL C(LL x, LL y) { return jc[x]*inv[y]%Mod*inv[x-y]%Mod; }
LL solve(Point x, Point y) {
	LL i, j, k;
	LL ret = 0;
	for(i = x3; i <= x4; i++) ret = (ret+C(i-x.x+y3-1-x.y,i-x.x)*C(y.x-i+y.y-y3,y.x-i)%Mod*(Mod-i-y3))%Mod; //(i,y3)
	for(i = x3; i <= x4; i++) ret = (ret+C(i-x.x+y4-x.y,i-x.x)*C(y.x-i+y.y-y4-1,y.x-i)%Mod*(i+y4+1))%Mod; //(i,y4)
	for(i = y3; i <= y4; i++) ret = (ret+C(x3-1-x.x+i-x.y,x3-1-x.x)*C(y.x-x3+y.y-i,y.x-x3)%Mod*(Mod-x3-i))%Mod; //(x3,i)
	for(i = y3; i <= y4; i++) ret = (ret+C(x4-x.x+i-x.y,x4-x.x)*C(y.x-x4-1+y.y-i,y.x-x4-1)%Mod*(x4+i+1))%Mod; //(x4,i)
	return ret;
}
int main() {
	LL i, j, k;
	jc[0] = 1;
	for(i = 1; i <= 2000000; i++) jc[i] = jc[i-1]*i%Mod;
	inv[0] = inv[1] = 1;
	for(i = 2; i <= 2000000; i++) inv[i] = inv[Mod%i]*(Mod-Mod/i)%Mod;
	for(i = 2; i <= 2000000; i++) inv[i] = inv[i-1]*inv[i]%Mod;
	scanf("%lld%lld%lld%lld%lld%lld", &x1, &x2, &x3, &x4, &x5, &x6);
	scanf("%lld%lld%lld%lld%lld%lld", &y1, &y2, &y3, &y4, &y5, &y6);
	a[0].x = x1-1; a[0].y = y1-1; a[1].x = x2; a[1].y = y1-1; a[2].x = x2; a[2].y = y2; a[3].x = x1-1; a[3].y = y2;
	b[0].x = x6+1; b[0].y = y6+1; b[1].x = x5; b[1].y = y6+1; b[2].x = x5; b[2].y = y5; b[3].x = x6+1; b[3].y = y5;
	LL ans = 0;
	for(i = 0; i < 4; i++){
		for(j = 0; j < 4; j++){
			if((i+j)&1) ans = (ans+(Mod-1)*solve(a[i],b[j]))%Mod;
			else ans = (ans+solve(a[i],b[j]))%Mod;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31360
#include <stdio.h>

int main()
{
	int n,b,f,r,v,i,j,k;
	int heya[4][3][10]={0};
	
	scanf("%d\n",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		heya[b-1][f-1][r-1]+=v;
	}
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++) {
			for(k=0;k<10;k++) {
				printf(" %d",heya[i][j][k]);
			}
			putchar('\n');
		}
		if(i < 3)
		printf("####################\n");
	}

	return 0;
	
}


Measured memory_bytes: 2024
#include <stdio.h>
#define MAX 100005
#define NIL -1
typedef struct {
  int p;
  int l;
  int r;
}info;
info tree[MAX];
int n,D[MAX];

int rec(int u,int p){
  D[u]=p;
  if(tree[u].r != NIL )rec(tree[u].r,p);
  if(tree[u].l != NIL )rec(tree[u].l,p+1);
  
}
void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",tree[u].p);
  printf("depth = %d, ",D[u]);
  if(tree[u].p == NIL) printf("root, ");
  else if(tree[u].l ==NIL)printf("leaf, ");
  else printf("internal node, ");
  i=0;
  c=tree[u].l;
  printf("[");
  
   while(c!=NIL){
    if(i>0)printf(", ");
    printf("%d",c);
    i++;
    c=tree[c].r;
  }
  printf("]\n");
}

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
  for(i=0;i<n;i++)tree[i].p = tree[i].l = tree[i].r = NIL;
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)tree[v].l = c;
      else tree[l].r=c;
      l = c;
      tree[c].p = v;
    }
  }

  for(i=0;i<n;i++){
    if(tree[i].p ==NIL)r=i;
  }
  rec(r,0);
  for(i=0;i<n;i++)print(i);
   
  
  return 0;
}



Measured memory_bytes: 6424
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

ll l,r;
ll dp[65][2][2][2];

ll go(ll i,bool okl,bool okr,bool valid,ll A,ll B){
	if(i==-1) return valid;
	ll& res=dp[i][okl][okr][valid];
	if(~res) return res;
	res=0;
	bool bitl=getbit(l,i);
	bool bitr=getbit(r,i);
	//case: 0/0
	if(!bitl||(bitl&&okl))
		res=go(i-1,okl,okr||bitr,valid,A,B);
	//case: (0/1) and (1/1)
	REP(a,2){
		int b=1;
		if(!bitr&&!okr&&b) continue;
		if(bitl&&!okl&&!a) continue;
		if(!valid&&!a) continue;
		bool newokl=okl||(a==1&&!bitl);
		bool newvalid=valid||(a==1);
		int newA=A;
		int newB=B;
		if(a) newA+=1LL<<i;
		if(b) newB+=1LL<<i;
		(res+=go(i-1,newokl,okr,newvalid,newA,newB))%=MOD;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>l>>r;
	memset(dp,-1,sizeof dp);
	cout<<go(60,false,false,false,0,0)<<'\n';
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
int n , l , t;
int x[N] , w[N];
int v[N];
int ans[N];
int main(){
	scanf("%d %d %d" , &n , &l , &t);
	for(int i = 0 ; i < n ; ++i){
		scanf("%d %d" , x + i , w + i);
		if(w[i] == 1){	
			v[i] = (x[i] + t) % l;
		}
		else{
			v[i] = (((x[i] - t) % l) + l) % l;
		}
	}
	int pos = v[0];
	sort(v , v + n);
	t *= 2;
	int who = 0;
	for(int i = 1 ; i < n ; ++i){
		if(w[i] != w[0]){
			if(w[0] == 1){
				if(x[i] - x[0] > t){
					continue;
				}
				who += ((t - (x[i] - x[0])) / l) + 1;
			}
			else{
				if(x[0] + l - x[i] > t){
					continue;
				}
				who -= ((t - (x[0] + l - x[i])) / l) + 1;
			}
		}
		who = ((who % n) + n) % n;
	}
	int zero;
	for(int i = 0 ; i < n ; ++i){
		if(v[i] == pos){
			zero = i;
			break;
		}
	}
	if(v[(zero  + 1) % n] == v[zero] && w[0] == 1){
		zero = (zero + 1) % n;
	}
	for(int i = who ; i < n ; ++i){
		ans[i] = zero;
		zero = (zero + 1) % n;
	}
	for(int i = 0 ; i < who ; ++i){
		ans[i] = zero;
		zero = (zero + 1) % n;
	}
	for(int i = 0 ; i < n ; ++i){
		printf("%d\n" , v[ans[i]]);
	}
}

Measured memory_bytes: 2816
#include <cstring>
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
int main(){
long long counter;
counter=0;
long long N,x;
cin>>N>>x;
vector<long long>a(N+10);
vector<long long>b(N+10);
cin>>a.at(0);
for (int i=1;i<N;i++){
cin>>a.at(i);
b.at(i-1)=a.at(i-1)+a.at(i);}
if(a.at(0)-x>=0){counter+=a.at(0)-x;
b.at(0)=x+a.at(1);}
for (int i=0;i<N;i++){
if(b.at(i)-x>=0){
counter+=b.at(i)-x;
b.at(i+1)-=b.at(i)-x;}}
cout<<counter<<endl;}


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

int main()
{
    double xp1, yp1, xp2, yp2, xp, yp;
    int q;

    cin >> xp1 >> yp1 >> xp2 >> yp2;
    cin >> q;

    for( int i = 0; i < q; i++ )
    {
        cin >> xp >> yp;

        double a, b, x, y;
        a = xp2 - xp1;
        b = yp2 - yp1;

        if( a == 0 )
            cout << fixed << setprecision(10) << xp1 << " " << yp << endl;
        else if( b == 0 )
            cout << fixed << setprecision(10) << xp << " " << yp1 << endl;
        else
        {
            x = ( yp - yp1 + a * xp / b + b * xp1 / a ) / ( b / a + a / b );
            y = -1 * a * x / b + yp + a * xp / b;
            cout << fixed << setprecision(10) << x << " " << y << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3288
#include<stdio.h>

int main(){
	int n;
	scanf("%d",&n);
	int s = n % 10;
	if(s ==3){
		printf("bon");
	}
	else if(s == 1 || s == 6 || s ==8 ||s == 0){
		printf("pon");
	}
	else{
		printf("hon");
	}
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

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;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int  N; cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    int out=-10000000;
    for(int i=0;i<(1<<N);i++){
        int X=0;
        int Y=0;
        for(int j=0;j<N;j++){
            if(i&(1<<j)){
                X+=V[j];
                Y+=C[j];
            }
        }
        if(out<X-Y) out = X-Y;
    }
    cout << out << endl;
    return 0;
}


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

class union_find {
private:
	vector<int> uf;
public:
	union_find(int n):uf(n, -1) {}

	int find(int x) {
		return uf[x] < 0 ? x : uf[x] = find(uf[x]);
	}

	bool unite(int a, int b) {
		a = find(a);
		b = find(b);

		if(a == b) return false;

		if(uf[a] > uf[b]) {
			swap(a, b);
		}
		else if(uf[a] == uf[b]) {
			--uf[a];
		}

		uf[b] = a;
		return true;
	}
};

struct edge {
	int u, v;
	int cost;
	edge(int u, int v, int c):u(u), v(v), cost(c){}
	bool operator<(const edge &e) const {
		return cost < e.cost;
	}
};

int calc(int n, vector<edge> &edges) {
	sort(edges.begin(), edges.end());

	int cnt = 0;
	union_find uf(n);
	for(const auto &e : edges) {
		if(uf.unite(e.u, e.v) && ++cnt == n / 2) return e.cost;
	}
}

int main() {
	for(int n, m; cin >> n >> m && n;) {
		vector<edge> edges;
		edges.reserve(m);
		for(int i = 0; i < m; ++i) {
			int s, t, c;
			cin >> s >> t >> c;
			edges.emplace_back(s - 1, t - 1, c);
		}
		cout << calc(n, edges) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1320
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int r,d,x;
  cin >> r >> d >> x;
  rep(i, 10){
    x = r * x - d;
    cout << x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) { // 奇数
            if (s[i] == 'L') {
                puts("No");
                return 0;
            }
        } else {
            if (s[i] == 'R') {
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int c[505],s[505],f[505];
int main()
{
	int n;scanf("%d",&n);n--;
	for(int i=1;i<=n;i++) scanf("%d%d%d",&c[i],&s[i],&f[i]);
	for(int st=1;st<=n;st++)
	{
		int ans=0;
		for(int i=st;i<=n;i++)
		{
			if(ans<s[i]) ans=s[i];
			else ans=f[i]*(ans/f[i]+(ans%f[i]?1:0));
			ans+=c[i];
		} 
		printf("%d\n",ans);
	}
	printf("0\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int get_rand(int a, int b) {  // [a, b]
    return uniform_int_distribution<int>(a, b)(rng);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d = 365, n = 26;
    vector<int> c(n);
    vector<vector<int>> s(d, vector<int>(n));
    if (true) {
        cin >> d;
        for (int i = 0; i < n; i++) {
            cin >> c[i];
        }
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n; j++) {
                cin >> s[i][j];
            }
        }
    } else {
        for (int i = 0; i < n; i++) {
            c[i] = get_rand(0, 100);
        }
        for (int i = 0; i < d; i++) {
            for (int j = 0; j < n; j++) {
                s[i][j] = get_rand(0, 20000);
            }
        }
    }
    auto beg = clock();
    int cnt = 0;
    int wid = 7;
    int lrand = 17;
    vector<vector<int>> que(wid, vector<int>(d));
    for (int i = 0; i < wid; i++) {
        for (int j = 0; j < d; j++) {
            que[i][j] = get_rand(0, n - 1);
        }
    }
    auto get = [&](int id) {
        int res = 0;
        vector<int> last(n, -1);
        for (int i = 0; i < d; i++) {
            res += s[i][que[id][i]];
            int x = i - last[que[id][i]] - 1;
            res -= c[que[id][i]] * x * (x + 1) / 2;
            last[que[id][i]] = i;
        }
        for (int i = 0; i < n; i++) {
            int x = d - last[i] - 1;
            res -= c[i] * x * (x + 1) / 2;
        }
        return res;
    };
    while (true) {
        cnt++;
        if (clock() - beg > 1919191) {
            break;
        }
        vector<pair<int, vector<int>>> nxt(wid + 1);
        for (int i = 0; i < wid; i++) {
            nxt[i].first = -1e9;
        }
        for (int i = 0; i < wid; i++) {
            for (int j = 0; j < lrand; j++) {
                int p = get_rand(0, n - 1);
                int q = get_rand(0, d - 1);
                swap(p, que[i][q]);
                nxt[wid] = make_pair(get(i), que[i]);
                for (int k = wid - 1; k >= 0; k--) {
                    if (nxt[k].first < nxt[k + 1].first) {
                        swap(nxt[k], nxt[k + 1]);
                    } else {
                        break;
                    }
                }
                swap(p, que[i][q]);
            }
        }
        for (int i = 0; i < wid; i++) {
            que[i] = nxt[i].second;
        }
    }
    for (int i = 0; i < d; i++) {
        cout << que[0][i] + 1 << '\n';
    }
  	cerr << get(0) << '\n';
  	cerr << cnt << '\n';
    return 0;
}

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

int main() { 
  int a,b,c;

  cin >> a >> b >> c;
  
  int d = a-b;

  if(d>=c) {
    cout << 0 << endl;
  } else {
    cout << c-d << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int d=999;
    for(int i=0;i<s.size()-2;i++){
        int x=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
        d = min(d,abs(x-753));
    }
    cout<<d<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define rd(a) cin>>(a)
#define RD(a,b) cin>>(a)>>(b)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int main() {
  int n;
  while(cin >> n && n) {
    int a[100000];
    memset(a,0,sizeof(a));
    P p[n];
    rep(i,n) {
      int h,m,s;
      scanf("%d%*c%d%*c%d",&h,&m,&s);
      p[i].F=h*60*60+m*60+s;
      scanf("%d%*c%d%*c%d",&h,&m,&s);
      p[i].S=h*60*60+m*60+s;
    }
    sort(p,p+n);
    int j=0,ans=0;
    rep(i,90000) {
      while(p[j].F==i && j<n) {
	if(a[i]) {
	  a[i]--;
	}// else ans++;
	a[p[j].S]++;
	j++;
      }
      a[i+1]+=a[i];
    }
    pr(a[89000]);
  }
  return 0;
}


Measured memory_bytes: 1724
#abc159 c

import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7

#ここから書き始める
l = float(input())
a1 = a2 = a3 = l / 3
print(a1 * a2 * a3)


Measured memory_bytes: 5692
n, p, *a = map(int, open(0).read().split())
even = odd = 0
for i in a:
    if i%2: odd += 1
    else: even += 1
ecr = [1] * (even+1)
for i in range(1, even): ecr[i] = ecr[i-1]*(even-i+1)//i
ocr = [1] * (odd+1)
for i in range(1, odd): ocr[i] = ocr[i-1]*(odd-i+1)//i
print(sum(ecr) * sum(ocr[p::2]))

Measured memory_bytes: 3064
atcoder = input()
ACGT = list('ACGT')

s = ''
sub_list = []
for i, l in enumerate(list(atcoder)):
    if l in ACGT:
        s += l
        if i == len(atcoder)-1:
            sub_list.append(len(s))
    else:
        sub_list.append(len(s))
        s = ''
print(max(sub_list))

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

int calc_sum(int i) {
	int val=0;
	do {
		val += i % 10;
		i /= 10;
	} while (i != 0);
		return val;
}

int main() {
	int N, A, B,ans=0;
	cin >> N >> A >> B;
	for (int i = 1; i <= N; i++) {
		int val = calc_sum(i);
		if (A <= val&&val <= B) {
			ans += i;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(void){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << max((h2*60+m2) - (h1*60+m1) - k, 0) << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
 
using namespace std;
typedef long long ll;
 
const ll MAXN = 1e5+10;
 
ll n, k;
ll arr[MAXN];
 
ll gcd(ll x, ll y) {
  if (x < y) {
    swap(x, y);
  }
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}
 
void solve() {
  ll d = arr[0];
  for (int i=0;i<n;i++) {
    d = gcd(d, arr[i]);
  }
  for (int i=0;i<n;i++) {
    if (k <= arr[i] && (k - arr[i]) % d == 0) {
      cout<<"POSSIBLE";
      return;
    }
  }
  cout<<"IMPOSSIBLE";
}
 
int main() {
  cin >> n >> k;
  for (int i=0;i<n;i++) {
    cin >> arr[i];
  }
  solve();
  return 0;
  
}

Measured memory_bytes: 4324
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
using namespace std;

string a;
int len;

int main()
{
	cin>>a;
	int o,p;
	len=a.length();
	for(int i=0;i<len;i++){
		if(a[i]=='A'){
			o=i;
			break;
		}
	}
	for(int j=len-1;j>=0;j--){
		if(a[j]=='Z'){
			p=j;
			break;
		}
	}
	printf("%d\n",p-o+1);
	return 0;
}


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

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

    string s;
    cin >> s;
    int result = 0;
    for(auto itr = s.begin(); itr != s.end(); ++itr) {
        if (*itr == '1') {
            ++result;
        }
    }
    
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define MMOD(i) ((i%MOD)+MOD)%MOD;
#define all(v) v.begin() , v.end()
#define vec(i,j) vector<vector<ll>>(i,vector<ll>(j,0))
const ll INF=99999999999999;
const ll MOD=1000000007;
const ll MAX_N=100010;
ll a,b,c,d,e,f,x,y,z,k,m,n,l,h,w,t,ans=0,sum;
vp p;
string s;
ll solve(){
    if(s[0]==s[1])return 1;
    if(s[1]==s[2])return 1;
    if(s[2]==s[3])return 1;
    return 0;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>s;
    if(solve()==1){
        cout<<"Bad"<<endl;
    }
    else{
        cout<<"Good"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int A, B, C, D;
const int N = 6050;
const LL MOD = 998244353;
LL dp[N][N / 2];
void add(LL &x, LL y) {
	(x += y) %= MOD;
}
int main() {
	cin >> A >> B >> C >> D;
	dp[C][D] = 1;
	for (int i = C; i >= A; i --) {
		for (int j = D; j >= B; j --) {
			if (i == C && j == D) continue;
			dp[i][j] = dp[i+1][j] * j % MOD + dp[i][j+1] * i % MOD - i * j % MOD * dp[i+1][j+1] % MOD;
			dp[i][j] = (dp[i][j] % MOD + MOD) % MOD;
		}
	}
	cout << dp[A][B] << endl;
}

Measured memory_bytes: 74500
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

struct UnionFind {
    vll par;
    vll size;

    UnionFind(ll N) : par(N), size(N) {
        rep(i, N) par[i] = i, size[i] = 1;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
        size[ry] += size[rx];
        size[rx] = 0;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main()
{
    ll n, m, k; cin >> n >> m >> k;
    UnionFind uf(n);
    map<ll, vll> fr;
    map<ll, vll> bl;
    rep(i, m) {
        ll a, b; cin >> a >> b; a--, b--;
        fr[a].push_back(b);
        fr[b].push_back(a);
        uf.unite(a, b);
    }

    rep(i, k) {
        ll c, d; cin >> c >> d; c--, d--;
        bl[c].push_back(d);
        bl[d].push_back(c);
    }

    //for (auto elem : uf.par) cout << elem << " "; cout << endl;
    //for (auto elem : uf.size) cout << elem << " "; cout << endl;
    rep(i, n) {
        ll sum = uf.size[uf.root(i)] - fr[i].size() - 1;
        rep(j, bl[i].size()) {
            if (uf.same(i, bl[i][j])) sum--;
        }
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 25844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

struct node
{
	int key;
	node *left;
	node *right;
};

node nil;
node *root = &nil;

void init()
{
	nil.left = &nil;
	nil.right = &nil;
}

void insert(int key)
{
	node *newNode = (node *)malloc(sizeof(node));
	newNode->key = key;
	newNode->left = &nil;
	newNode->right = &nil;

	node *tmp = &nil;
	node *iter = root;
	while(iter != &nil)
	{
		tmp = iter;

		if (newNode->key < iter->key)
		{
			iter = iter->left;
		}
		else
		{
			iter = iter->right;
		}
	}
	//empty tree
	if (tmp == &nil)
		root = newNode;
	else if (newNode->key < tmp->key)
		tmp->left = newNode;
	else
		tmp->right = newNode;
}

bool findExe(int key, node *t){
	if(t==&nil)
		return false;
	if (t->key == key)
		return true;
	else if(t->key > key)
		return findExe(key, t->left);
	else
		return findExe(key, t->right);
}

void findResult(int key)
{
	if(findExe(key, root))
		cout << "yes" << endl;
	else
		cout << "no" << endl;
}

void inorder(node *t)
{
	if (t == &nil)
		return;
	inorder(t->left);
	cout << " " << t->key;
	inorder(t->right);
}

void preorder(node *t)
{
	if (t == &nil)
		return;
	cout << " " << t->key;
	preorder(t->left);
	preorder(t->right);
}

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

	for (int i = 0; i < n; i++)
	{
		string cmd;
		cin >> cmd;
		if (cmd == "insert")
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if(cmd == "find"){
			int key;
			cin >> key;
			findResult(key);
		}
		else if (cmd == "print")
		{
			inorder(root);
			cout << endl;

			preorder(root);
			cout << endl;
		}
	}
}


Measured memory_bytes: 15556
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define inf 0x7f7f7f7f
#define maxn 100006
#define N 1
#define P 2


typedef long long ll;
typedef struct {
    int u, v, next, w;
} Edge;
Edge e[200006];
int cnt, head[100006];

inline void add(int u, int v,int w) {
    e[cnt].u = u;
    e[cnt].v = v;
    e[cnt].w = w;
    // e[cnt].f=f;
    e[cnt].next = head[u];
    head[u] = cnt++;
    e[cnt].u = v;
    e[cnt].v = u;
    e[cnt].w = w;
    //    e[cnt].f=-f;
    e[cnt].next = head[v];
    head[v] = cnt++;
}

inline void write(int x) {
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}
inline ll read() {
    ll x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
int n,k,vis[20],flag;
vector<int>v;
int main(){
    n=read();
    k=read();
    int x;
    for(int i=1;i<=k;i++){
        x=read();
        vis[x]=1;
    }
    for(int i=n;i<=100000;i++){
        x=i;
        flag=0;
        while(x){
            if(vis[x%10]){
                flag=1;
                break;
            }
            x/=10;
        }
        if(!flag){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100012
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

int n;
set<string> st;
string s;

int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(0);
    cin >> n;
    while(n--){
        cin >> s;
        st.insert(s);
    }
    cout << sz(st) << '\n';
    return 0;
}


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

int n, m, a[100010], b[100010], c[100010];

int main() {
    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        ++c[a[i]], ++c[b[i]];
    }

    for(int i = 0; i < m; ++i) {
        if(c[a[i]]&1 || c[b[i]]&1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    vvll dp(n, vll(n));
    rep(i, n) rep(j, n) cin >> dp[i][j];

    vvll backup = dp;

    rep(k, n) rep(i, n) rep(j, n)
    {
        chmin(dp[i][j], dp[i][k] + dp[k][j]);
    }

    bool ok = true;
    rep(i, n) rep(j, n)
    {
        if (backup[i][j] != dp[i][j])
        {
            ok = false;
            break;
        }
    }

    if (!ok)
    {
        cout << -1 << endl;
        return 0;
    }

    rep(k, n) rep(i, n) rep(j, n)
    {
        if (i == j || i == k || j == k)
            continue;

        if (dp[i][j] == dp[i][k] + dp[k][j])
        {
            backup[i][j] = 0;
        }
    }
    ll ans = 0;
    rep(i, n) for (int j = i; j < n; j++)
    {
        ans += backup[i][j];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;


int main ()
{
  prep();
  int n;
  cin >> n;
  int arr[n];
  int place[200001];
  for (int i=0; i<n; i++){
      cin >> arr[i];
      place[arr[i]] = i;
  }
  long long res = 0;
  set<int> indexs;
  for (int i=1; i<=n; i++){
      int myind = place[i];
      int bottom = 0;
      int top = n-1;
      auto lower = indexs.lower_bound(myind);
      if (lower != indexs.begin()){
          lower--;
          bottom = *lower+1;
      }
      auto upper = indexs.upper_bound(myind);
      if (upper != indexs.end()){
          top = *upper-1;
      }
      long long diff1 = myind-bottom+1;
      long long diff2 = top-myind+1;
      //cout << bottom << " " << top << endl;
      res += i*diff1*diff2;
      indexs.insert(place[i]);
  }
  cout << res;
  return 0; 
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstdlib>

using namespace std;

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

  long sum = 0; 
  for(int i=1; i<N; i++)
    {
      sum+= i;
    }
 
  cout << sum << endl;
  

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[105];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int res=0;
	int high=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='I')
			high++;
		if(s[i]=='D')
			high--;
		res=max(res,high);
	}
	printf("%d\n",res);
	return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool check = true;
    while (a > 0 && c > 0) {
        if (check) {
            c -= b;
            check = false;
        } else {
            a -= d;
            check = true;
        }
    }
    if (c <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#define debug(x) cout<<"#x "<<":"<<x<<endl
#define lowbit(x) ((-x)&(x))

using namespace std;
typedef long long ll;
typedef pair<int,int>pi;

const int maxn=1e6+7;
const int mod=998244353;


ll n,m;

ll work(ll a,ll b)
{
    if(a<b)swap(a,b);
    if(a==0 and b==0)return 0;
    if(a==1 and b==0)return 0;
    if(a==2 and b==0)return 1;
    if(a==3 and b==0)return 1;
    if(a==1 and b==0)return 0;
    if(a==1 and b==1)return 0;
    if(a==2 and b==1)return 0;
    if(a==3 and b==1)return 1;
    if(a==2 and b==0)return 1;
    if(a==2 and b==1)return 0;
    if(a==2 and b==2)return 0;
    if(a-b<=1)return 0;
    //if(a&1) return 0;
    return 1;
}

int main()
{
#ifdef LOCAL
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    cin>>n>>m;
    if(work(n,m))
        puts("Alice");
    else
        puts("Brown");
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n = int(input())
A = [int(input()) for _ in range(n)]

B = {}
for a in A:
    if a not in B:
        B[a] = 1
    else:
        B[a] += 1

ans = 0
for b in B.keys():
    if B[b] % 2:
        ans += 1

print(ans)


Measured memory_bytes: 16272
#include<bits/stdc++.h>
#include<cstring>
//#define Mfc_Tanzim
#define ll long long
#define ull unsigned long long
#define pb push_back
#define ff first
#define ss second
#define all(v) (v.begin(), v.end())
#define pi acos(-1.0)
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define bug(a) cerr << #a << " : " << a << endl
using namespace std;

ll posx[] = {1,-1, 0, 0};
ll posy[] = {0, 0, 1,-1};

int main()
{
    FastRead

#ifdef Mfc_Tanzim
    freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
#endif // Mfc_Tanzim

    ll a, b;
    bool ok = false;
    cin >> a >> b;
    if(b%2==0 && b<=a*4 && b>=a*2)
        ok = true;

    cout << (ok? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 3628