akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, res;
string s;
map<pair<string,string>, int> a;

signed main() {
	cin >> n >> s;
	rep(i,1<<n) {
		string x, y;
		rep(j,n) (i>>j&1 ? x : y).pb(s[j]);
		a[{x,y}]++;
	}
	rep(i,1<<n) {
		string x, y;
		rep(j,n) (i>>j&1 ? x : y).pb(s[n+j]);
		string l = y, r = x;
		reverse(all(l)), reverse(all(r));
		res += a[{l,r}];
	}
	cout << res << ln;
}

Measured memory_bytes: 87040
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0;i < n; i ++) {
        	a[i] = sc.nextInt();
        }
        for(int j = n - 1;j >= 0;j --) {
        	System.out.print(a[j]);
        	if(j != 0) {
        		System.out.print(" ");
        	}
        	else {
        		System.out.println("");
        	}
        }
     }
}


Measured memory_bytes: 26340
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int n , cnt = 0 ;
    string s ;
    map <string,int> m ;
    cin >> n ;
    for(int i = 0 ; i < n ; i++ )
    {
        cin >> s ;
        if(m.count(s) == 0)
        {
            cnt++ ;
            m[s] = cnt ;
        }
    }
    cout << cnt << endl ;
}

Measured memory_bytes: 19248
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;

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

  string S;
  cin >> S;
  
  int passed_all = 0;
  int passed_foreign = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'a') {
      if (passed_all < A+B) {
        cout << "Yes" << endl;
        passed_all++;
      } else {
        cout << "No" << endl;
      }
    } else if (S.at(i) == 'b') {
      if (passed_all < A+B && passed_foreign < B) {
        cout << "Yes" << endl;
        passed_foreign++;
        passed_all++;
      } else {
        cout << "No" << endl;
      }
    } else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#include <cassert>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define Cout(x) cout << x << endl;
#define check(v) rep(i,v.size()) cout << v[i] << endl;
#define vint(x) vector<int> x
#define vll(x) vector<long long> x
#define vstr(x) vector<string> x
const long long LLINF = 1LL<<60;
const int INF = 1e9;
const long long MOD = 1000000007;
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; }
typedef long long ll;
#define pint pair<int,int>
#define pll pair<ll,ll>
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    rep(i,n) {
        if(v[i]%2==0) {
            if(v[i]%3!=0 && v[i]%5!=0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;

    return 0;
}

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

int main(){
    while(true){
        int a,b;
        std::string str;
        std::cin>>a>>str>>b;
        if(str=="?")break;
        if(str=="+")std::cout<<a+b<<std::endl;
        if(str=="-")std::cout<<a-b<<std::endl;
        if(str=="/")std::cout<<a/b<<std::endl;
        if(str=="*")std::cout<<a*b<<std::endl;
    }
    return 0;
}


Measured memory_bytes: 3152
N = int(input())

if N % 2 == 1:
    print(0)
    exit()

x = 1
num2 = 0
while x < N:
    x *= 2
    num2 += N//x

x = 1
num5 = 0
while x < N:
    x *= 5
    num5 += (N//x)//2

ans = min(num2, num5)
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>

int main(void){
  int n, dia, max=0, i;
  std::cin >> n;
  std::vector<int> d(101);
  for(i=0; i<n; i++){
    std::cin >> dia;
    d.at(dia) = 1;
    if(dia > max) max = dia;
  }
  for(i=0; i<max; i++) d.at(i+1) += d.at(i);
  std::cout << d.at(max);
  return 0;
}

Measured memory_bytes: 3628
fun main(args: Array<String>) {
    val n = readLine()?.toLong() ?: return
    val max = Math.sqrt(n.toDouble()).toInt()
    val min = 1.until(max + 1).mapNotNull {
        if (n % it == 0L) {
            it + n / it - 2
        } else {
            null
        }
    }.min()
    println(min.toString())
}

Measured memory_bytes: 33816
import collections
N = int(input())
A = list(map(int, input().split()))

table = collections.defaultdict(int)

for x in A:
    table[x] += 1

for x in table:
    if x != 0 and table[x] != 2:
        print(0)
        exit(0)

    elif N % 2 == 1:
        if x == 0 and table[x] != 1:
            print(0)
            exit(0)

    else:
        if x == 0:
            print(0)
            exit(0)

print(2**(N//2) % (10**9 + 7))


Measured memory_bytes: 14820
import java.util.*;


import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		String s = next();
		String result = "";
		if("Sunny".equals(s)) {
			result = "Cloudy";
		} else if("Cloudy".equals(s)) {
			result = "Rainy";
		} else {
			result = "Sunny";
		}
		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

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

using namespace std;

int main()
{
	int n,x;
	cin >> n >> x;
	for(int i=0;i<=n;i++)
	{
		int cur=i*2+(n-i)*4;
		if(cur==x)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int k,f,r=9,num=9;
long long q[200001]={0,1,2,3,4,5,6,7,8,9}; 
int main()
{
	cin>>k;
	if(k<10) cout<<q[k];
	while(f!=r)
	{
		f=(f+1)%200001;
		for(int i=-1;i<=1;++i)
		{
			if(q[f]%10+i<0||q[f]%10+i>9) continue;
			r=(r+1)%200001;
			q[r]=q[f]*10+q[f]%10+i;
			++num;
			if(num==k)
			{
				cout<<q[r];
				return 0;
			}
		}
	}
}

Measured memory_bytes: 1792
N, A = map(int, input().split())
X = [int(i)-A for i in input().split()]

dp = [[0 for j in range(100 * N + 1)] for i in range(N+1)]
dp[0][50 * N] = 1
#-50～50マデノ値ガ入ルカモ

for i in range(N):
    for j in range(100*N + 1):
        dp[i+1][j] = dp[i][j]
        if 0 <= j-X[i] <= 100*N:
            dp[i+1][j] += dp[i][j - X[i]]
        
print(dp[N][50 * N] -1)

Measured memory_bytes: 5744
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

char str[200005];

void solve()
{
    scanf("%s", str);
    int n=strlen(str);
    vector<int> v;
    int i;
    for(i=0; i<n; i++) {
        if(str[i]=='S') {
            v.push_back(0);
        }
        else {
            if(!v.empty() && v.back()==0) {
                v.pop_back();
            }
            else {
                v.push_back(1);
            }
        }
    }
    printf("%d\n", (int)v.size());

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1528
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	#define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int mod = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

int64_t extGcd(int64_t a, int64_t b, int64_t &x, int64_t &y) {
	if (a == 0) {
		x = 0; y = 1;
		return b;
	}
	int64_t x1, y1;
	int64_t g = extGcd(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return g;
}

inline int64_t inverse(int64_t a, int64_t m) {
	int64_t x, y;
	int64_t g = extGcd(a, m, x, y);
	assert(g == 1);
	return (x % m + m) % m;
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	
	int n, k; cin >> n >> k;
	vector< vector<int> > g(n);
	for (int i = 1; i < n; ++i) {
		int a, b; cin >> a >> b; --a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	vector<int64_t> f(500000), rf(500000);
	f[0] = 1;
	for (int i = 1; i < int(f.size()); ++i) {
		f[i] = (f[i-1] * i) % mod;
	}
	for (int i = 0; i < int(f.size()); ++i) {
		rf[i] = inverse(f[i], mod);
	}
	
	auto C = [&](int n, int k) -> int {
		if (k < 0 || k > n) {
			return 0;
		}
		return f[n] * rf[k] % mod * rf[n-k] % mod;
	};
	
	int64_t res = k;
	
	function<void(int, int)> dfs = [&](int v, int p) {
		int children = int(g[v].size()) - 1;
		if (p < 0) {
			++children;
			res *= C(k-1, children) * f[children] % mod;
			res %= mod;
		} else {
			res *= C(k-2, children) * f[children] % mod;
			res %= mod;
		}
		for (int to : g[v]) {
			if (to != p) {
				dfs(to, v);
			}
		}
	};
	dfs(0, -1);
	
	cout << res % mod << endl;
	
	return 0;
}


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debugF(ostream &os) {os << endl;}
template <typename Head, typename... Tail>
void debugF(ostream &os, Head H, Tail... T) { os << " " << H; debugF(os, T...); }
#define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debugF(cout, __VA_ARGS__)
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); os << (i>0 ? " ":"") << v[i++]); return os;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d,s,t;
    cin >> d >> s >> t;
    bool can = s*t >= d;
    cout << (can ? "Yes" : "No") << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define lli long long int 
int main()
{
    string s;
    cin>>s;
    lli n=s.length(),i,d=0,m=-1;
    for(i=0;i<n;i++)
    {
        if(s[i]=='R')
        d++;
        else 
        {
            m=max(m,d);
            d=0;
        }
    }
    m=max(m,d);
    cout<<m;
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

void Add(const vector<int> &prev, int cost, int points, vector<int> &curr)
{
    for (int i = prev.size() - 1; i >= points; i -= 1) {
        curr[i] = min(curr[i], prev[i - points] + cost);
    }
}

void AddObjects(int count, int points, int bonus, vector<int> &min_problems)
{
    vector<int> new_min(min_problems.begin(), min_problems.end());

    for (int i = 1; i < count; i += 1) {
        Add(min_problems, i, i * points, new_min);
    }
    Add(min_problems, count, count * points + bonus, new_min);

    min_problems = new_min;
}

int main()
{
    int types, score;
    cin >> types >> score;

    score /= 100;

    vector<int> min_problems(2 * score + 2, (1 << 30));
    min_problems[0] = 0;

    for (int i = 0; i < types; i += 1) {
        int count, bonus;
        cin >> count >> bonus;

        bonus /= 100;
        AddObjects(count, i + 1, bonus, min_problems);
    }

    int res = min_problems[score];
    for (size_t i = score; i < min_problems.size(); i += 1) {
        res = min(res, min_problems[i]);
    }
    cout << res << "\n";

    return 0;
}


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


int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n){
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
N=int(input())
cnt=0
ba=0
a=0
b=0

for i in range(N):
    chr=input()
    cnt+=chr.count('AB')
    if chr[0]=='B' and chr[-1]=='A':
        ba+=1
    elif chr[-1]=='A':
        a+=1
    elif chr[0]=='B':
        b+=1

if ba==0:
    cnt+=min(a,b)
elif a+b==0:
    cnt+=(ba-1)
else:
    cnt+=ba+min(a,b)
print(cnt)

Measured memory_bytes: 3444
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#define getchar getchar_unlocked
#define putchar putchar_unlocked
int32_t nextint(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); bool s=false; if(c=='-'){s=true;c=getchar();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar(); int s=0; if(c=='-'){s=1;c=getchar();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar(); } return s?-x:x; }
uint32_t nextstr(char *s){ char c=getchar(); while(c==' '||c=='\n') c=getchar(); uint32_t len=0; while(c!=' '&&c!='\n'){ *s++=c; len++; c=getchar(); } *s='\0'; return len; }
void rsorta_d32(void *base, const int count, const int size, const int index){
	typedef int32_t rsort_t;
	rsort_t (*a)[size] = (rsort_t(*)[size])base;
	rsort_t (*b)[size] = (rsort_t(*)[size])malloc(count*size*sizeof(rsort_t));
	int c[0x100];
	for(int k=0; k<4; k++){
		memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i][index]>>(k<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ int to=--c[(a[i][index]>>(k<<3))&0xFF]; for(int j=0; j<size; j++){ b[to][j]=a[i][j]; } }{rsort_t(*t)[size]=a; a=b; b=t;}
	}
	free(b);
}

int a[200000];
int main(void){
	int n=nextint();
	int k=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
	}
	for(int i=k; i<n; i++){
		puts(a[i]>a[i-k]?"Yes":"No");
	}
}


Measured memory_bytes: 2304
#include <cstring>
#include <cstdio>
#include <vector>
#define pb push_back
std::vector<int> adj[55]; 
int a[55], b[55], que[55]; 
bool vis[55], ans[55]; 
int main()
{
	// freopen("AGC022-C.in", "r", stdin); 
	int n; 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
		scanf("%d", a + i); 
	for (int i = 0; i < n; i++)
		scanf("%d", b + i); 
	for (int i = 51; i; i--)
	{
		for (int j = 0; j <= 50; j++)
			adj[j].clear(); 
		for (int j = 1; j <= 50; j++)
		{
			if (j >= i && !ans[j])
				continue; 
			for (int x = 0; x <= 50; x++)
				adj[x].pb(x % j); 
		}
		bool f = true; 
		for (int j = 0; j < n; j++)
		{
			memset(vis, false, sizeof(vis)); 
			int he = 0, ta = 0; 
			que[ta++] = a[j]; 
			vis[a[j]] = true; 
			while (he < ta)
			{
				int x = que[he++]; 
				for (int y : adj[x])
				{
					if (!vis[y])
					{
						vis[y] = true; 
						que[ta++] = y; 
					}
				}
			}
			f &= vis[b[j]]; 
		}
		ans[i] = !f; 
	}
	if (ans[51])
		puts("-1"); 
	else
	{
		long long x = 0; 
		for (int i = 0; i <= 50; i++)
			x |= (long long)ans[i] << i; 
		printf("%lld\n", x);
	}
	return 0; 
}


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

int main()
{
    int n;
    cin >> n;
    vector<int64_t> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    vector<int64_t> s(n);
    int64_t acc = 0;
    for (int i = 0; i < n; i++)
    {
        acc += a.at(i);
        s.at(i) = acc;
    }

    int64_t res_p = 0;
    int64_t acc_p = 0;
    for (int i = 0; i < n; i++)
    {
        int64_t si = s.at(i) + acc_p;
        if (i % 2 == 0)
        {
            if (si > 0)
                continue;
            res_p += 1 - si;
            acc_p += 1 - si;
        }
        else
        {
            if (si < 0)
                continue;
            res_p += si + 1;
            acc_p -= si + 1;
        }
    }

    int64_t res_n = 0;
    int64_t acc_n = 0;
    for (int i = 0; i < n; i++)
    {
        int64_t si = s.at(i) + acc_n;
        if (i % 2 == 0)
        {
            if (si < 0)
                continue;
            res_n += si + 1;
            acc_n -= si + 1;
        }
        else
        {
            if (si > 0)
                continue;
            res_n += 1 - si;
            acc_n += 1 - si;
        }
    }

    cout << min(res_p, res_n) << endl;
}

Measured memory_bytes: 1792
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut T = read![i64, i64; N];

    T.sort_by(|&(la, lb), &(ra, rb)| {
        if lb != rb {
            return lb.cmp(&rb);
        }

        ra.cmp(&la)
    });

    let mut t = 0;
    let mut fail = false;
    for (spend, dead) in T {
        t += spend;
        if t > dead {
            fail = true;
            break;
        }
    }

    println!("{}", if fail { "No" } else { "Yes" })
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int a,b;
		cin>>a>>b;
		cout<<max(0ll,a-2*b);
	}   
}     

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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
	string s;
	cin>>s;
	int a,b;
	a=7;
	if(s[0]=='M') b=1;
	if(s[0]=='W') b=3;
	if(s[0]=='F') b=5;
	if(s=="SUN") b=0;
	if(s=="TUE") b=2;
	if(s=="THU") b=4;
	if(s=="SAT") b=6;
	cout<<a-b<<endl;	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string x;
    cin >> x;
    //if(x[0] == '0'){cout << "Yes" << endl; return 0;}
    int sum = 0;
    for (int i = 0; i < x.length(); ++i){
        sum += x[i]-'0';
    }
    if(sum%9 == 0){cout << "Yes" << endl;}
    else{std::cout << "No" << std::endl;}
    return 0;
}


Measured memory_bytes: 3724
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int count[4][3][10];
    
    int iDataNum;
    int b,f,r,v;
    
    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for(int k = 0; k < 10; ++k)
            {
                count[i][j][k] = 0;
            }
        }
    }
    
    cin >> iDataNum;
    
    for (int i = 0; i < iDataNum; ++i)
    {
        cin >> b >> f >> r >> v;
        
        count[b - 1][f - 1][r - 1] += v;        
    }

    for (int i = 0; i < 4; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            for (int k = 0; k < 10; ++k)
            {
                cout << " " << count[i][j][k];
            }
            
            cout << endl;
        }
        
        if (i < 3)
        {
            cout  << "####################" << endl;
        }
    }


    return 0;
}



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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	if(n == 1) cout << "Hello World" << endl;
	else{
		int a, b; cin >> a >> b;
		cout << a + b << endl;
	}
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String line1 = sc.nextLine();
        String line2 = sc.nextLine();
        String[] linesp2 = line2.split(" ");
        for(int i = 0; i < n; i++) {
            int[] nums = new int[n];
            nums[i] = Integer.parseInt(linesp2[n - i - 1]);
            System.out.print(nums[i]);
            if(i < n - 1) {
                System.out.print(" ");
            }
        }
        System.out.println("");
    }
}


Measured memory_bytes: 26228
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int H = scn.nextInt();
		int W = scn.nextInt();
		int N = 0;
		int[][] coin = new int[H + 1][W + 1];
		int[][] ncoin = new int[H + 1][W + 1];
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				int a = scn.nextInt();
				coin[i][j] = a;
				ncoin[i][j] = a;
			}
		}
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				int c = coin[i][j];
				if (c % 2 != 0) {
					if (j == W) {
						if (i == H) {
							break;
						} else {
							N++;
							coin[i + 1][j]++;
						}
					} else {
						N++;
						coin[i][j+1]++;
					}
				}
			}
		}
		System.out.println(N);
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				int c = ncoin[i][j];
				if (c % 2 != 0) {
					if (j == W) {
						if (i == H) {
							break;
						} else {
							System.out.println(i + " " + j + " " + (i+1) + " " + (j));
							ncoin[i + 1][j]++;
						}
					} else {
						System.out.println(i + " " + j + " " + (i) + " " + (j+1));
						ncoin[i][j+1]++;
					}
				}
			}
		}
		scn.close();
	}
}


Measured memory_bytes: 102288
#include <iostream>

using namespace std;

int main()
{
    while(1)
    {
        int n;
        cin>>n;if(!n)return 0;
        long long a[5010];
        for(int i=0;i<n;++i){
            cin>>a[i];
        }
        long long ans=-20000000000;
        long long buf;
        for(int i=0;i<n;++i){
            buf=0;
            for(int j=i;j<n;++j){
                buf+=a[j];
                if(buf>ans)ans=buf;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1192
import java.util.Arrays
import java.util.ArrayList

const val MOD: Long = (1e9+7).toLong()
fun Double.format(digits: Int) = String.format("%.${digits}f", this)

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map{it.toInt()}

    println(n-k+1)
}


Measured memory_bytes: 35908
#include<cstdio>
using namespace std;
#define N 10050
int n,k,tp;
char s[N],t[N],as[N],as1[N];
void solve()
{
	int le=0,st=n;
	while(t[st]==t[n])le++,st--;
	le<<=(k-1);
	if(le>n)le=n;
	for(int i=1;i<=le;i++)as1[i]=t[n];
	for(int i=le+1,k=st;i<=n;i++,k--)as1[i]=t[k];
	for(int i=1;i<=n;i++)if(as[i]>as1[i]){for(int j=1;j<=n;j++)as[j]=as1[j];return;}
	else if(as[i]<as1[i])return;
}
int main()
{
	scanf("%d%d%s",&n,&k,s+1);
	if(k>=14){char as='z';for(int i=1;i<=n;i++)if(s[i]<as)as=s[i];for(int i=1;i<=n;i++)printf("%c",as);return 0;}
	tp=1<<k-1;
	for(int i=1;i<=n;i++)s[n*2-i+1]=s[i];
	as[1]='z'+1;
	for(int i=n+1;i<=n*2;i++)
	{
		for(int j=i-n+1;j<=i;j++)t[j-i+n]=s[j];
		solve();
	}
	printf("%s",as+1);
}//

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

int main(){
 	int n,maxi;
	cin >>n;
	maxi = 1;
  	int t;
  	for(int i = 2; i*i <= n; i++) {
    	
      	for(int p = 2; p < n; p++) {
        	t = (int)pow(i,p);
          	if(t>n)
              	break;
          	if(maxi < t)
              	maxi = t;
        }
      
    }
  	cout << maxi << endl;
	
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static long solve(int n, int m, Set<Integer> broken) {
        long[] cnt = new long[n + 1];

        cnt[0] = 1;
        if (broken.contains(1)) {
            cnt[1] = 0;
        } else {
            cnt[1] = 1;
        }
        for (int i = 2; i <= n; ++i) {
//            System.out.println(String.format("%d, %d", i, cnt[i-1]));
            if (broken.contains(i)) {
                cnt[i] = 0;
            } else {
                cnt[i] = (cnt[i - 1] + cnt[i - 2]) % 1000000007L;
            }
        }
        return cnt[n];
    }


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

        int n = sc.nextInt();
        int m = sc.nextInt();
        Set<Integer> broken = new HashSet<Integer>();
        for (int i = 0; i < m; ++i) {
            broken.add(sc.nextInt());
        }

        System.out.println(solve(n, m, broken));
    }
}


Measured memory_bytes: 66268
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <ctime>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
 
long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}
 
long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int x[2], y[2];
int dx, dy, t_x, t_y;

int main(){
	REP(i,2) cin >> x[i] >> y[i];
	
	dx = y[0] - y[1];
	dy = x[1] - x[0];
	
	REP(i,2){
		if (i) cout << " ";
		cout << x[1-i]+dx << " " << y[1-i]+dy;
	}
	
	return 0;
}

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

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		boolean[] rate = new boolean[8];
		int free =0;
		int a;
		for(int i=0; i<N; i++){
			a  = in.nextInt();
			if(a<=399){
				rate[0]=true;
			}else if(a<=799){
				rate[1]=true;
			}else if(a<=1199){
				rate[2]=true;
			}else if(a<=1599){
				rate[3]=true;
			}else if(a<=1999){
				rate[4]=true;
			}else if(a<=2399){
				rate[5]=true;
			}else if(a<=2799){
				rate[6]=true;
			}else if(a<=3199){
				rate[7]=true;
			}else{
				free++;
			}
		}
		int ans=0;
		for(int i=0; i<rate.length; i++){
			if(rate[i]==true){
				ans++;
			}
		}
		int max = ans+free;
		if(ans == 0){
			ans = 1;
		}
		System.out.println(ans + " " + max);
	}
}

Measured memory_bytes: 21076
n, m, l = [int(_) for _ in input().split()]
A = [[int(_) for _ in input().split()] for _ in range(n)]
B = [[int(_) for _ in input().split()] for _ in range(m)]

for i in range(n):
    C = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k] * B[k][j]
        C.append(str(c))
    print(" ".join(C))



Measured memory_bytes: 6248
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
ll n;
vector<vector<ll>> to(10005);
vector<ll> d(10005,-1);
void dfs(ll v){
    for(ll u:to[v]){
        if (d[u] != -1) continue;
        d[u] = d[v]+1;
        dfs(u);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll a,b;
    rep(i,n-1){
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<ll> c(n),ans(n);
    cins(all(c));
    RSORT(c);
    ll cnt = 0;
    rep(i,1,n) cnt += c[i];
    d[0] = 0;
    dfs(0);
    vector<P> p;
    rep(i,n){
        p.push_back(P(d[i],i));
    }
    SORT(p);
    rep(i,n){
        tie(a,b) = p[i];
        ans[b] = c[i];
    }
    PRINT(cnt);
    array_output(all(ans));
}


Measured memory_bytes: 1792
def main():
    n = int(input())
    h = [int(h) for h in input().split(' ')]
    for i in range(n):
        index = n - 1 - i
        if i == n - 1:
            print("Yes")
            break
        if h[index] + 1 < h[index - 1]:
            print("No")
            break
        elif h[index - 1] - 1 == h[index]:
            h[index - 1] -= 1


if __name__ == '__main__':
    """
    左右一列に N 個のマスが並んでおり、左から i 番目のマスの高さは H_i です。
    あなたは各マスについて 1 度ずつ次のいずれかの操作を行います。

    マスの高さを 1
    - 低くする。
    - 何もしない。
    操作をうまく行うことでマスの高さを左から右に向かって単調非減少にできるか求めてください。

    制約
    入力は全て整数である。
    1 ≤ N ≤ 10^5
    1 ≤ H_i ≤ 10^9
    """
    main()


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

//ABC157C
int main(void) {
  int n, m, k, i;
  scanf(" %d %d", &n, &m);
  int s[m], c[m], num[n];
  for(i=0; i<m; i++)
    scanf(" %d %d", &s[i], &c[i]);
  for(i=0; i<n; i++)
    num[i]=-1;

  for(i=0; i<m; i++){
    if(num[s[i]-1]==-1)
      num[s[i]-1]=c[i];
    else if(num[s[i]-1]!=c[i]){
      printf("-1");
      return 0;
    }
  }

  if(num[0]==0&&n>1){
    printf("-1");
    return 0;
  }else if((num[0]==0&&n==1)||(num[0]==-1&&n==1)){
     printf("0");
    return 0;
  }

  for(i=0; i<n; i++){
    if(num[i]==-1&&i==0) printf("1");
    else if(num[i]>=0) printf("%d", num[i]);
    else printf("0");
  }
  return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;long long int k;cin>>n>>k;
    map<int,int>mp;
    vector<int > index;
    for(int i=0;i<n;i++)
    {
        int a,b;//scanf("%d %d",&a,&b);
        cin>>a>>b;
        mp[a]+=b;
        index.push_back(a);
    }
    
    sort(index.begin(),index.end());
    unique(index.begin(),index.end());
    for(auto x: index)
    {
        k-=mp[x];
        if(k<1)
        {
            cout<<x;
            return 0;
        }
    }
    
    
    
}


Measured memory_bytes: 3576
#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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#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;

int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    VI a(n);
    REP(i,n)cin>>a[i];
    VSORT(a);
    REP(i,n-1){
        if(a[i]==a[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc101c
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split();
            var n = int.Parse(nk[0]); var k = int.Parse(nk[1]);
            var sequenceA = Console.ReadLine().Split().ToList().ConvertAll(int.Parse);
            var turn = 0;
            for (; turn * k - (turn - 1) < sequenceA.Count; ++turn)
                ;
            Console.WriteLine(turn);
        }
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int n;
	cin>>n;
	vector<long long int> p;
	while(n--){
		long long int x;
		cin>>x;
		p.push_back(x);
	}
	long long int c=0;
	for(long long int i=1;i<p.size()-1;i++){
		if(p[i]<max(p[i],max(p[i-1],p[i+1]))&&p[i]>min(p[i],min(p[i+1],p[i-1]))){
			c++;
		}
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3628
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


l, r, d = inpl()
ans = r // d - (l - 1) // d
print(ans)


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

//dp[桁][0でない数字をいくつ使ったか][n未満か]
int dp[105][4][2] = {};

int main() {

    string s; cin >> s;
    int n = s.length();
    int K; cin >> K;

    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 2; ++k) {
                int nd = s[i] - '0'; //次に見る桁の数字

                for (int d = 0; d < 10; ++d) {
                    int ni = i + 1;
                    int nj = j;
                    int nk = k;

                    if (d != 0) nj++; //次の数字が0以外ならnjをインクリメント
                    if (nj > K) continue; //0以外を使った回数が求めるものより大きい場合は不要
                    if (k == 0) {
                        if (d > nd) continue; //次に設定しようとする桁の数字が、ndより大きい場合は条件を満たさない
                        if (d < nd) nk = 1; //次に設定しようとする桁の数字が、ndより小さい場合はn未満かが1になる
                    }

                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }

    int ans = dp[n][K][0] + dp[n][K][1];

    cout << ans << endl;
}

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

using namespace std;

int main()
{
	int n, l[201] = {}, i, sum = 0;

	scanf("%d", &n);
	for (i = 0; i < n * 2; i++) {
		scanf("%d", &l[i]);
	}

	sort(l, l + n * 2);

	for (i = 0; i < n * 2; i += 2) {
		sum += l[i];
	}

	printf("%d\n", sum);

	return 0;
}

Measured memory_bytes: 128
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


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

//     ll AB = B-A;
    
//     ll ans=0;
//     if(AB % 2 == 0){
//         ans = AB/2;
//     }else{
//         ans = min(A-1,N-B) + 1 + ((AB-1)/2);
//     }
//     cout << ans << endl;
// }

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

    ll AB = B-A;
    
    ll ans=0;
    if(AB % 2 == 0){
        ans = AB/2;
    }else{
        ll x = A - 1;
        ll y = N - B;
        if(x < y){
            ans = x + 1 + ((AB-1)/2);
        }else{
            ans = y + 1 + ((AB-1)/2);
        }   
    }
    cout << ans << endl;
}

Measured memory_bytes: 3588
import java.util.Scanner;

public class Main {

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

        int input1 = Integer.parseInt(sc.nextLine());
        String input2 = sc.nextLine();
        String result = "No";
        int K = input1/2;

        if (input1 % 2 == 0) {
            if (input2.substring(0, K).equals(input2.substring(K))) {
                result = "Yes";
            }
        }
        System.out.println(result);
    }

}


Measured memory_bytes: 21972
n,m=map(int,input().split())
h=list(map(int,input().split()))
ans=[1]*n
for i in range(m):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if h[a]>h[b]:ans[b]=0
    elif h[a]<h[b]:ans[a]=0
    if h[a]==h[b]:ans[a]=ans[b]=0
print(ans.count(1))

Measured memory_bytes: 19964
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


i64 n, a[202020], d[202020];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		d[i+1] = d[i] + a[i];
	}
	
	i64 ans = LINF;
	for(int i = 0; i < n; i++){
		ans = min(ans, abs(d[i] - (d[n] - d[i])));
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a, b) ((a < b) ? a : b)
#define _max(a, b) ((a < b) ? b : a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a) ? 1 : -1)
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

int main() {
    cout << fixed << setprecision(10);
    int a;
    string s;
    cin >>a>> s;
    if(a<3200){
        cout<<"red";
    }else{
        cout<<s;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, q, i, j, k, x, s, t, top;
	cin >> n >> q;
	vector<tuple<long long, long long, long long>> plist;
	for (i = 0; i < n; i++) {
		cin >> s >> t >> x;
		plist.push_back(make_tuple( s - x, t - x, x ));
	}
	sort(plist.begin(), plist.end());

	vector<long long> d(q), ans(q);
	
	top = 0;
	set<pair<long long, long long>> blocked;
	priority_queue<pair<long long, long long>> pq;
	for (i = 0; i < q; i++) {
		cin >> d[i];
		
		while ((top < plist.size()) && (get<0>(plist[top]) <= d[i])) {
			blocked.insert({ get<2>(plist[top]), get<1>(plist[top]) });
			pq.push({ -get<1>(plist[top]), get<2>(plist[top]) });
			top++;
		}

		while (!pq.empty() && (-pq.top().first <= d[i])) {
			blocked.erase({ pq.top().second, -pq.top().first });
			pq.pop();
		}

		if (pq.empty()) ans[i] = -1;
		else ans[i] = blocked.begin()->first;
	}

	for (i = 0; i < q; i++) cout << ans[i] << "\n";

	return 0;
}


Measured memory_bytes: 24940
import java.util.Scanner;
class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String line=sc.nextLine();
    for(int i=line.length()-1; i>=0; i--){
    System.out.print(line.charAt(i));
    }
    System.out.println();
   }
   }
    

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

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  vector<long long> B(N);
  
  for(int i=N-1; i>=0; i--){
    cin >> A.at(i) >> B.at(i); 
  }
  long long ans=0;
  for(int i=0; i<N; i++){
    A.at(i)+= ans;
    if(A.at(i)%B.at(i)!=0) ans+=B.at(i)-A.at(i)%B.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
lists = [[".",",","!","?"," "],["a","b","c"],["d","e","f"],["g","h","i"],["j","k","l"],["m","n","o"],["p","q","r","s"],["t","u","v"],["w","x","y","z"]]
cnt = 0
moji = []
ans = []
n = int(input())
for k in range(n):
    s = str(input())
    for i in range(len(s)):
        if s[i] != "0":
            cnt += 1
            tmp = int(s[i])
            if cnt > len(lists[tmp-1]):
                cnt = cnt - len(lists[tmp-1]) 
            
        elif s[i] == "0" and cnt != 0:
                moji.append(lists[tmp - 1][int(cnt)-1])
                cnt = 0
    mojimoji = "".join(moji)
    ans.append(mojimoji)
    moji = []
for i in ans:
    print(i)


Measured memory_bytes: 5636