akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,pair<int, int>>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

vector <int> v[N];
int sz[N];
int dfs(int s, int pr)
{
	for (auto g : v[s])
	{
		if(g != pr)
		{
			sz[s] += dfs(g, s);
		}
	}
	return (sz[s] + 1);
}

int main()
{
	int n, x, y;
	cin >> n;
	for (int i = 0; i < n - 1; ++i)
	{
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	int c[N];
	for (int i = 0; i < n; ++i)
	{
		cin >> c[i];
	}
	sort(c, c + n);
	memset(sz, 0, sizeof(sz));
	dfs(1, 0);
	pair <int, int> p[N];
	for (int i = 0; i < n; ++i)
	{
		p[i] = {sz[i + 1], i + 1};
	}
	sort(p, p + n);
	int id[N], ans = 0;
	for (int i = 0; i < n; ++i)
	{
		id[p[i].ss] = c[i];
		if(i != n - 1)
			ans += c[i];
	}
	cout << ans << "\n";
	for (int i = 1; i <= n; ++i)
	{
		cout << id[i] << " ";
	}
}

Measured memory_bytes: 4736
#include<stdio.h>
int main(){
    int A,B;
    scanf("%d %d", &A,&B);
    int a,b,c;
    a=A*B;
    b=A+B;
    c=A-B;
    if(a>=c){
        if(a>=b){
            printf("%d\n",a);
        }
        else{
            printf("%d\n",b);
        }
    }
    else{
        if(c>=b){
            printf("%d\n",c);
        }
        else{
            printf("%d\n",b);
        }
    }
    return 0;
}

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

using namespace std;

int main(){
  int N;
  string S;
  int K;
  cin >> N >> K >> S;
  for(int i=0;i<N;i++){
    if(i==K-1){
      if(S[i]=='A'){
        S[i]='a';
      }
      if(S[i]=='B'){
        S[i]='b';
      }
      if(S[i]=='C'){
        S[i]='c';
      }
    }
  }
  cout << S << endl;
  return 0;
}


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

ll N, A[2][105], dp[2][105];

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

	cin >> N;
	for (ll i = 0; i < 2; i++) {
		for (ll j = 0; j < N; j++) {
			cin >> A[i][j];
			if (i == 0 && j == 0) dp[i][j] = A[i][j];
			if (i > 0) dp[i][j] = max(dp[i][j], dp[i-1][j] + A[i][j]);
			if (j > 0) dp[i][j] = max(dp[i][j], dp[i][j-1] + A[i][j]);
		}
	}

	cout << dp[1][N-1] << "\n";

}

Measured memory_bytes: 256
n=gets.to_i
abc=n.times.map{gets.split.map(&:to_i)}
d=Array.new(n){Array.new(3,0)}
0.upto(2){|j| d[0][j]=abc[0][j]}
1.upto(n-1){|i|
  0.upto(2){|j|
    x=0
    0.upto(2){|k| x=d[i-1][k] if k!=j and x<d[i-1][k]}
    d[i][j]=x+abc[i][j] if d[i][j]<x+abc[i][j] 
}}
puts d[n-1].max

Measured memory_bytes: 13820
#include<stdio.h>
#include<string.h>
int main()
{
  char a[4];
  gets(a);
  if(strcmp(a,"BBB")==0)
  {
    printf("No\n");
  }
  else if(strcmp(a,"AAA")==0)
  {
    printf("No\n");
  }
  else
  {
    printf("Yes\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	const double ratio = 1.08;
	const double price = N / ratio;

	const int dN = floor(price) * ratio;
	const int uN = ceil(price) * ratio;
	if (dN == N) {
		cout << static_cast<int>(floor(price)) << endl;
	}
	else if (uN == N)
	{
		cout << static_cast<int>(ceil(price)) << endl;
	}
	else {
		cout << ":(" << endl;
	}


}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << std::fixed << std::setprecision(15);
	Main();

	return 0;
}


Measured memory_bytes: 256
// Crt. 2020-01-08  20:56:06
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define N 500005
typedef long long ll;

template <typename T> inline T abs(const T &x) { return x < 0 ? -x : x; }

int n, d;
ll dlt[N], a[N], b[N];

int main(){
#ifdef LOCAL_JUDGE
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif

    cin >> n >> d;

    for (int i = 1; i <= n; ++i)
        scanf("%lld", dlt + i);

    ll tmp;

    b[n + 1] = 1;
    for (int i = n; i >= 1; --i)
        if (abs(b[i + 1] - dlt[i]) >= b[i + 1]) b[i] = b[i + 1];
        else b[i] = b[i + 1] + dlt[i];

    a[0] = d;
    for (int i = 1; i <= n; ++i)
        if ((tmp = abs(a[i - 1] - dlt[i])) <= a[i - 1]) a[i] = tmp;
        else a[i] = a[i - 1];

//    for (int i = 1; i <= n; ++i)
//        cout << a[i] << " " << b[i] << endl; cout << endl;

    int Q; cin >> Q;
    while (Q--) {
        int x; scanf("%d", &x);
        puts(a[x - 1] >= b[x + 1] ? "YES" : "NO");
    }

    return 0;
}


Measured memory_bytes: 13696
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k; cin >> n >> k;
	map<int, int> cnt;
	rep(i, n){
		int a; cin >> a;
		cnt[a]++;
	}
	vi v;
	for(auto p : cnt) v.pb(p.second);
	sort(all(v));
	
	int ans = 0;
	rep(i, (int)v.size() - k) ans += v[i];
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 10744
N = int(input())
a = []
for i in range(N):
    a.append(int(input()))
b = sorted(a)

if a.count(b[-1]) > 1:
    for i in range(N):
        print(b[-1])
else:
    ind = a.index(b[-1])
    for i in range(N):
        if i == ind:
            print(b[-2])
        else:
            print(b[-1])


Measured memory_bytes: 14112
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))

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


Measured memory_bytes: 3640
import java.util.Scanner;


public class Main {

	public static void main(String [] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int[][][] room = new int[4][3][10];
		
		
		for(int i = 1;i <= n;i++) {
			
			int tou = sc.nextInt();
			int kai = sc.nextInt();
			int hidari = sc.nextInt();
			int addnum = sc.nextInt();
			
			room[tou-1][kai-1][hidari-1] = room[tou-1][kai-1][hidari-1] + addnum;
			
			
		}
		
		
		for(int j = 0;j < 4;j++) {
			for(int k = 0;k < 3;k++) {
				for(int l = 0;l < 10;l++) {
					System.out.print(" " + room[j][k][l]);
				}
				
				if(k != 2) {

				System.out.println("");
				}
				
				
				
			}
			
			if(j != 3) {
				

				System.out.println("");
				
				
				System.out.println("####################");

				
				
			}
			
		}


System.out.println("");

			
		}

		

}


Measured memory_bytes: 29872
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, _ := strconv.ParseFloat(sc.Text(), 64)
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	x := nextFloat() - nextFloat()
	minDiff := math.Inf(1)
	var ans int

	for i := 0; i < n; i++ {
		if diff := math.Abs(x - 0.006*nextFloat()); diff < minDiff {
			minDiff = diff
			ans = i
		}
	}

	fmt.Println(ans + 1)
}


Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  let [top, front, right, left, back, bottom] = lines[0].split(" ");
  let n = lines[1] - 0;
  let s1 = [top, front, bottom, back];
  let s2 = [top, right, bottom, left];
  let s3 = [front, right, back, left];
  for (let i = 2; i < n + 2; i++) {
    let [t, f] = lines[i].split(" ");
    let s = s1.includes(t) ? (s2.includes(t) ? s3 : s2) : s1;
    let ixf = s.indexOf(f);
    if (t === top || t === right || t === back) {
      ixf = ixf === 3 ? 0 : ixf + 1;
    } else {
      ixf = ixf === 0 ? 3 : ixf - 1;
    }
    console.log(s[ixf]);
  }
});



Measured memory_bytes: 16516
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)




int main() {
    int N;
    long double A[110], Arev[110];
    cin >> N;
    rep(i,N) cin >> A[i];
    rep(i,N) {
        Arev[i] = (long double)(1.0/A[i]);
    }
    long double sum = 0;
    rep(i,N) {
        sum+=Arev[i];
    }

    long double ans;
    ans = (long double)(1.0/sum);

    cout << fixed << setprecision(16) << ans << endl;
    return 0;
    




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define tc() long long int t; cin>>t; while(t--)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<long long>
#define mi map<int, int>
#define mll map<long long, long long>
#define mc map<char, int>
#define si set<int>
#define pb push_back
#define eb emplace_back
#define sz size()
#define fi first
#define se second
#define mk make_pair
#define MOD 1000000007
#define INF 1e9+1
#define FI ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// #define GCD(ll a,ll b) ll gcd(ll a,ll b){if(b==0){return a;} return gcd(b,b%a)}
// #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) 

void IO(){

	#ifndef OJ
	freopen("C:/Users/KIIT/GITHUB/input.txt","r",stdin);
	freopen("C:/Users/KIIT/GITHUB/output.txt","w",stdout);
	#endif
}

void solve(){

	map<string, int> ch;
	string na;
	int n;cin>>n;
	for(int i=0;i<n;i++){
		cin>>na;
		ch[na]++;
	}
	cout<<"AC"<<" "<<"x"<<" "<<ch["AC"]<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<ch["WA"]<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<ch["TLE"]<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<ch["RE"]<<endl;
	
}

int main(){

	FI;//IO();

	solve();
	// tc(){
		
	// 	solve();

	// }

	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    long int n;
    cin>>n;
    pair<long long int,long long int>p1[n],p2[n];
    long long int aa,bb,mx1=-1e10,mn1=1e10,mx2=-1e10,mn2=1e10;
    for(long int i=0;i<n;i++)
    {
        cin>>aa>>bb;
        p1[i]={aa,bb};
        p2[i]={bb,aa};
        mx1=max(mx1,aa+bb);
        mn1=min(mn1,aa+bb);
        mx2=max(mx2,aa-bb);
        mn2=min(mn2,aa-bb);
    }
    sort(p1,p1+n);
    sort(p2,p2+n);
    long long int ans=0;
    for(long int i=n-1;i>=0;i--)
    {
        long long int temp1=abs(p1[0].first-p1[i].first)+abs(p1[0].second-p1[i].second);
        long long int temp2=abs(p2[0].first-p2[i].first)+abs(p2[0].second-p2[i].second);
        ans=max({ans,temp2,temp1});
    }
    ans=max(ans,mx1-mn1);
    ans=max(ans,mx2-mn2);
    cout<<ans;
}
    

Measured memory_bytes: 9832
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  cin>>A;
  for(auto &I:A){I--;}
  ll cnt=0;
  if(A[0]!=0){cnt++; A[0]=0;}
  vector<ll> dp(N,-1);
  vector<vector<ll>> edge(N);
  for(int i=1;i<N;i++){edge[A[i]].push_back(i);}
  function<ll(ll)> dfs=
    [&](ll u){
      ll d=1;
      for(auto &I:edge[u]){d=max(d,dfs(I)+1);}
      if(d==K && A[u]!=0){cnt++; return (ll)0;}
      return d;
    };
  dfs(0);
  cout<<cnt<<endl;
  

  return 0;
}


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

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	Map<Integer, Boolean> map = new HashMap<>();
    	for(int i = 0; i < n; i++){
    		int a  = sc.nextInt();
    		if(null != map.get(a)){
    			System.out.println("NO");
    			sc.close();
    			return;
    		}else{
    			map.put(a, true);;
    		}
    	}
    	sc.close();
    	System.out.println("YES");
    }
}

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

multiset<int> LS, RS;
int L[100010], R[100010];
signed main(){
	int n, fl = 0, fr = 0, ans = 0;
	scanf("%lld", &n);
	for(int i = 0;i < n;i++)scanf("%lld%lld", &L[i], &R[i]);
	
	LS.insert(-1e17);
	RS.insert(1e17);
	for(int i = 0;i < n;i++){
		if(i){
			fl -= R[i]-L[i];
			fr += R[i-1]-L[i-1];
		}
		
		if(L[i] < *LS.rbegin()+fl){
			ans += *LS.rbegin()+fl-L[i];
			RS.insert(*LS.rbegin()+fl-fr);
			LS.erase(LS.find(*LS.rbegin()));
			LS.insert(L[i]-fl);
			LS.insert(L[i]-fl);
		}else if(*RS.begin()+fr < L[i]){
			ans += L[i]-(*RS.begin()+fr);
			LS.insert(*RS.begin()+fr-fl);
			RS.erase(RS.begin());
			RS.insert(L[i]-fr);
			RS.insert(L[i]-fr);
		}else{
			LS.insert(L[i]-fl);
			RS.insert(L[i]-fr);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = max((b - a) * (n - 2) + 1, 0LL);
    cout << ans;
    return 0;
}

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

int n;
string s;
int K;

  long long com(long long N, long long R) {
    if (R < 0 || R > N) return 0;
    if (R == 1) return N;
    else if (R == 2) return N * (N-1) / 2;
    else return N * (N-1) * (N-2) / 6;
}

long long pow(long long N, long long k) {
    long long res = 1;
    for (int i = 0; i < k; ++i) res *= N;
    return res;
}

long long dfs(int i, int k, int flag){
  if(i == n){
    if(k==0) return 1;
    else return 0;
  }
  if(k==0) return 1;
  
  if(flag)  return com(n-i,k)*pow(9,k);
          
  
  else{
    if(s[i] == '0') return dfs(i+1,k,0);
    
    else{
      long long int ans1 = dfs(i+1,k,1);
      long long int ans2 = dfs(i+1,k-1,1)*((s[i]-'0')-1);
      long long int ans3 = dfs(i+1,k-1,0);
    
      return ans1 + ans2 + ans3;
    }
  }
  }

  
int main(){
  cin >> s ;
  cin >> K;
  n=s.size();
  
  
  cout << dfs(0,K,0) << endl;
}


Measured memory_bytes: 256
import collections

n=int(input())
V=list(map(int,input().split()))
V1=collections.Counter(V[0::2])
V2=collections.Counter(V[1::2])
V1v,V1c = zip(*V1.most_common())
V2v,V2c = zip(*V2.most_common())
V1v=list(V1v)
V1c=list(V1c)
V2v=list(V2v)
V2c=list(V2c)
V1v.append(-1)
V2v.append(-2)
V1c.append(0)
V2c.append(0)

if V1v[0] != V2v[0]:
    print(n-V1c[0]-V2c[0])
else:
    if V1c[1] >= V2c[1]:
        print(n-V1c[1]-V2c[0])
    else:
        print(n-V1c[0]-V2c[1])

Measured memory_bytes: 21900
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            String strSplit[] = br.readLine().split(" ");
            long a = Integer.parseInt(strSplit[0]);
            long b = Integer.parseInt(strSplit[1]);
            long c = Integer.parseInt(strSplit[2]);
            
            if(c-a-b > 0 && 4*a*b < (c-a-b)*(c-a-b)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
            
            
        }catch(Exception e){
            System.out.println(e);
        }
    }
}

Measured memory_bytes: 32424
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		HashSet<Integer> set = new HashSet<>();

		for (int i = 0; i < N; i++) {
			set.add(sc.nextInt());
		}
		
		System.out.println(set.size() < N ? "NO" : "YES");
	}
}


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

using namespace std;

int main(void) {
	int noq,nmax,res;
	cin >> noq;
	string t1,t2,X,Y;
	for (int q = 0; q < noq; ++q) {
		cin >> t1 >> t2;
		if (t1.length() < t2.length()) {
			X = t2;
			Y = t1;
		}
		else {
			X = t1;
			Y = t2;
		}
		vector<int> dp(X.length(),0);
		for (int i = 0; i < Y.length(); ++i) {
			nmax = 0;
			for (int j = 0; j < X.length(); ++j) {
				if (Y[i] == X[j]) {
					if (nmax+1 > dp[j]) {
						dp[j] = nmax+1;
					}
					else {
						nmax = max(dp[j],nmax);
					}
				}
				else {
					if (dp[j] < nmax) {
						dp[j] = nmax;
					}
					else {
						nmax = dp[j];
					}
				}
			}
		}
		res = 0;
		for (int i = 0; i < X.length(); ++i) {
			res = max(dp[i],res);
		}
		cout << res << endl;
	}
	return 0;
}



Measured memory_bytes: 3224
n, q = list(map(int, input().split()))
que = []

for i in range(n):
    p, t = input().split()
    que.append([p, int(t)])

total = 0
while True:
    if q >= que[0][1]:
        total += que[0][1]
        print(que[0][0], total)
        que.pop(0)
    else:
        total += q
        que[0][1] -= q
        que.append(que[0])
        que.pop(0)
    if len(que) == 0:
        break



Measured memory_bytes: 13016
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  int tn;
  cin>>n;
  tn=n;
  int sn=0;
  while(tn>0)
  {
    sn+=tn%10;
    tn/=10;
  }
  if(n%sn==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}


Measured memory_bytes: 256
/*
NAME: jinxiaoguang
LANG: C++
TASK:
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
//#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
const int inff=0x80000000;
const int infz=0x7fffffff;
const int mod=1e9+7;

int main()
{
int a;
	while(~scanf("%d",&a))
	puts((a/10==9||a%10==9)?"Yes":"No");
}


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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int n;
  int ans;
  
  cin >> n;
  
  if(n % 1000 == 0) cout << 0 << endl;
  else{
    ans =1000 - n % 1000;
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3536
inf = float("inf") 
n=int(input())
a=list(map(int ,input().split()))
dp=[inf]*n
k=2
dp[0]=0
for i in range(1,n):
   for j in range(i-1,max(0,i-k)-1,-1):
       dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]))
print(dp[n-1])
    

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


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

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

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

const int MAX = 1e6+1;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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

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

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

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始
int main(){
  int n;
  string s;
  cin>>n>>s;
  int a[26];
  for(int i = 0; i < 26; i++) a[i]=0;
  for(int i = 0; i < n; i++){
    a[s[i]-'a']++;
  }
  ll ans = 1;
  for(int i = 0; i < 26; i++){
    ans*=(a[i]+1);
    ans%=MOD;
  }
  cout<<ans-1<<endl;
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//#define ll long long
#define pb emplace_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=LONG_LONG_MAX;
const ll ms=(2e5)+5;

int n,m,q;
int ar[20]={0};
int qr[60][4]={0};
int br[20]={0};

int ans=0;

void go(int i)
{
    if(i==1)
    {
        int j;
        int p=ar[i+1];
        for(j=1;j<=p;j++)br[j]=0;
        int c=0;int d;
        for(i=1;i<=q;i++)
        {
            if(qr[i][0]==1)
            {
                d=ar[qr[i][1]]-qr[i][2];
              d=max(d,0);
                if(d<=p)br[d]+=qr[i][3];
            }
            else{
                if((ar[qr[i][1]]-ar[qr[i][0]])==qr[i][2])c+=qr[i][3];
            }
        }
        d=0;
        for(i=1;i<=p;i++)d=max(d,br[i]);
        c+=d;
     
      
        ans=max(ans,c);
        return ;
    }
    else{
        for(int j=ar[i+1];j>=1;j--)
        {
            ar[i]=j;
            go(i-1);
        }
    }
}

int main()
{
    idfc;
    cin>>n>>m>>q;
    ar[n]=m;
    int i;
    for(i=1;i<=q;i++)
    {
        cin>>qr[i][0]>>qr[i][1]>>qr[i][2]>>qr[i][3];
    }
    go(n-1);
    cout<<ans;
    return 0;
}

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

int main(){
    int n, cnt;
    cin >> n;
    int p[n];
    for(int i = 0; i < n; i++) cin >> p[i];
    cnt = 0;
    for(int i = 1; i < n-1; i++){
        if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main()
{
    string s,t;
    cin>>s;
    cin>>t;
    if(s.size()!=t.size())
    {
        cout<<"No"<<endl;
        return 0;
    }
    map<char,char>maps,mapt;
    rep(i,s.size())
    {
        if(maps.count(s[i])==0)
        {
            maps[s[i]]=t[i];
        }
        else if(maps[s[i]]!=t[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    rep(i,t.size())
    {
        if(mapt.count(t[i])==0)
        {
            mapt[t[i]]=s[i];
        }
        else if(mapt[t[i]]!=s[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    

}

Measured memory_bytes: 776
#include <bits/stdc++.h> 
using namespace std;
int main()
{
	string str;		cin>>str;
	string str2;	cin>>str2;
	int flag=1;
	for(int i=0;i<str.length();i++)
	{
		if(str[i]!=str2[i])
		{
				flag=0;
				break;
			}
	}
	if(flag==0)
		cout<<"No";
	else
		cout<<"Yes";
	
}
		

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

int main() {
  int a[5],b[5],rock=0,paper=0,scissors=0;
  while(cin >> a[0],a[0]) {
    cin >> a[1] >> a[2] >> a[3] >> a[4];
    rock=0;paper=0;scissors=0;
    for(int i=0;i<5;i++) {
      if(a[i] == 1) rock++;
      else if(a[i] == 2) scissors++;
      else if(a[i] == 3) paper++;
    }

    if(rock >= 1 && scissors >= 1 && paper >= 1) {
      for(int i=0;i<5;i++) {
	b[i] = 3;
      }
    }

    else if(rock == 5 || scissors == 5 || paper == 5) {
      for(int i=0;i<5;i++) {
	b[i] = 3;
      }
    }
    else if(paper == 0) {
      for(int i=0;i<5;i++) {
	if(a[i] == 1) {
	  b[i] = 1;
	}
	else {
	  b[i] = 2;
	}
      }
    }
    else if(rock == 0) {
      for(int i=0;i<5;i++) {
	if(a[i] == 2) {
	  b[i] = 1;
	}
	else {
	  b[i] = 2;
	}
      }
    }
    else if(scissors == 0) {
      for(int i=0;i<5;i++) {
	if(a[i] == 3) {
	  b[i] = 1;
	}
	else {
	  b[i] = 2;
	}
      }
    }

    for(int i=0;i<5;i++) {
      cout << b[i] << endl;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 5010;
int N,K;
ll v[N_MAX];

//v[index]を使わずにk-v[index]<= Sum < kとなる挿話が作れるならfalse
bool isNoNeed(int index){
  //i枚目まで使った時にjにできるか
  //trueできる，falseできない
  bool dp[2][K];
  bool *prev, *next;
  prev = dp[0];
  next = dp[1];
  rep(j,K){
    prev[j] = false;
    next[j] = false;
  }
  prev[0] = true;

  rep(i,N){
    if(i==index)continue;
    rep(j,K){
      next[j] = (prev[j]||next[j]);
      if(prev[j]){
        if(j+v[i]<K-v[index]) next[j+v[i]] = true;
        else if(j+v[i] < K) return false;
        else break;
      }
    }
    swap(prev,next);
  }
  return true;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int n;cin >> n >> K;
  N=0;
  rep(i,n){
    int x;cin >> x;
    if(x>=K)continue;
    else v[N++]=x;
  }
  sort(v,v+N);
  int l = 0, r=N;
  if(!isNoNeed(l)){
    cout << 0 << endl;
    return 0;
  }
  while(r-l>1){
    int m = (r+l)/2;
    bool isnoneed = isNoNeed(m);
    if(isnoneed) l = m;
    else r = m;
  }
  cout << r << endl;
  return 0;
}



Measured memory_bytes: 256
/* ex6_2 melo */
#include <stdio.h>
#include<string.h> //文字列関数
#define SIZE 101 //文字列の大きさを定義
int main(void){
    char sente[SIZE];
    int length;
    fgets(sente,SIZE,stdin);
    length=(int)strlen(sente);
    if (sente[length-1]=='\n') {
        sente[length-1]='\0';
    }
    length=(int)strlen(sente);
    printf("%c%d%c\n",sente[0],length-2,sente[length-1]);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		double dice=1/(double)N;
		double ans=0;

		for(int i=1;i<=N;i++) {
			int n=i;
			double m=dice;
			while(n<K) {
				n *= 2;
				m /= 2.0;
			}
			ans += m;
		}

		System.out.println(ans);

	}


}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 500;
int a[N+3][N+3];
int n;

int main()
{
	scanf("%d",&n);
	if(n<=N)
	{
		printf("%d\n",n);
		for(int i=1; i<=n; i++) {for(int j=1; j<=n; j++) printf("%d ",i); puts("");}
	}
	else
	{
		for(int i=0; i<N; i++)
		{
			for(int j=0; j<N; j++)
			{
				if(i+N+1>n) {a[j][(i+j)%N] = i+1;}
				else {a[j][(i+j)%N] = j&1?i+1+N:i+1;}
			}
		}
		printf("%d\n",N);
		for(int i=0; i<N; i++) {for(int j=0; j<N; j++) printf("%d ",a[i][j]); puts("");}
	}
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll n,k;
  cin >> n >>k;
  string s;
  cin >> s;

  vector<ll> v;

  if(s[0]=='0')v.push_back(0);

  ll b=s[0]-'0';
  for(int i=0;i<n;i++){
    ll a=0;
    while(s[i]-'0'==b){
      i++;
      a++;
    }
    i--;
    v.push_back(a);
    b=1-(s[i]-'0');
  }

  if(s[n-1]=='0')v.push_back(0);

  ll t=0;
  ll m=v.size();

  if(2*k>=m)cout << n << endl;
  else{
    ll S[m+1]={};
    for(int i=0;i<m;i++)S[i+1]=S[i]+v[i];
    for(int i=0;2*k+1+2*i<=m;i++){
      t=max(t,S[2*k+1+2*i]-S[2*i]);
    }
    cout << t << endl;
  }
  


  


}

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

int main() {
  string s;
  cin >> s;
  int result = 0;
  int i;
  for (i = 0; i < s.length() / 2; i++) {
    if (s.at(i) != s.at(s.length() - 1 - i)) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll inf = 1LL<<59;

int main(){
    int N, M; cin >> N >> M;
    vector<ll> a(M), b(M), c(M);
    for(int i=0; i<M; ++i){
        cin >> a[i] >> b[i] >> c[i];
        --a[i]; --b[i]; c[i] = -c[i];
    }

    vector<ll> d(N, inf);

    d[0] = 0;
    for(int loop=0; loop<N; ++loop){
        for(int i=0; i<M; ++i){
            if(d[a[i]] == inf) continue;
            d[b[i]] = min(d[b[i]], d[a[i]]+c[i]);
        }
    }

    ll ans = -d[N-1];

    vector<bool> nega(N, false);

    for(int loop=0; loop<N; ++loop){
        for(int i=0; i<M; ++i){
            if(d[a[i]] == inf) continue;
            if(d[b[i]] > d[a[i]]+c[i]){
                d[b[i]] = d[a[i]]+c[i];
                nega[b[i]] = true;
            }
        }
    }

    if(nega[N-1] == true) cout << "inf" << endl;
    else cout << ans << endl;
}

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

n3 = n * 3
dp = [[0] * int(i * 1.5 + 5) for i in range(n3 + 1)]
dp[0][0] = dp[1][1] = dp[2][2] = dp[2][-1] = 1

for i in range(3, n3 + 1):
    i12 = (i - 1) * (i - 2)
    dpi3, dpi2, dpi1, dpi = dp[i - 3:i + 1]
    for j in range(-(i // 2), i + 1):
        tmp = dpi3[j] * i12
        tmp += dpi2[j + 1] * (i - 1)
        tmp += dpi1[j - 1]
        dpi[j] = tmp % MOD

print(sum(dp[-1][:n3 + 1]) % MOD)


Measured memory_bytes: 246152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main() {
    ll N, M;
    cin >> N >> M;
    priority_queue<ll> A;
    rep(i, N) {
        ll a;
        cin >> a;
        A.push(a);
    }
    rep(i, M) {
        ll t = A.top();
        A.pop();
        t /= 2;
        A.push(t);
    }
    ll total=0;
    rep(i, N) {
        total += A.top();
        A.pop();
    }
    out(total);
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
 
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define fori(i, n) for (int i = 0; i < (int)(n); ++i)
#define forn(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n); i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define RETURN(x) do{cout << x << '\n'; return 0;}while(0)
#define FIRSTWIN do{cout << "Monocarp\n"; return 0;}while(0)
#define SECONDWIN do{cout << "Bicarp\n"; return 0;}while(0)
 
const int MAXN = 2e6+4;
const int MOD = 1e9+7;
const int INF = 1e9+1;

int x,y;
int fact[MAXN], inv[MAXN], ifact[MAXN];

template<typename T, typename T1>
T mod(T x, T1 p) {
	x %= p;
	if (x < 0)
		x += p;
	return x;
}

template<typename T>
T inverse(T x, T p) {
	x = mod(x, p);
	if (x == 1)
		return x;
	return mod((1LL * (-p / x) * (inv[p % x] % p)) , p); 
	// Since inverse of p % x is already calculated.
}

int NcR(int n, int r) {
	int ret = (1LL * ifact[n - r] * ifact[r]) % MOD ;
	ret = (1LL * ret * fact[n]) % MOD;
	return ret;
}

int main() {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);

	fact[0] = 1;
	for(int i = 1; i < MAXN; i++) {
		fact[i] = 1LL * fact[i - 1] * i % MOD;
	}

	ifact[0] = 1;
	for(int i = 1; i < MAXN; i++) {
		inv[i] = inverse(i, MOD);
		ifact[i] = 1LL * ifact[i - 1] * inv[i] % MOD;
	}

    cin >> x >> y;
    if((2*x-y)%3) RETURN(0);
    if((2*y-x)%3) RETURN(0);

    int a = (2*x-y)/3;
    int b = (2*y-x)/3;

    if(a < 0 || b < 0) RETURN(0);
    cout << NcR(a+b,a) << endl;
    return 0;
}



Measured memory_bytes: 23680
from math import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


a, b, c, d = map(int, input().split())
e = lcm(c, d)
num_e = b // e - (a - 1) // e
num_c = b // c - (a - 1) // c
num_d = b // d - (a - 1) // d
num_can_div = num_c + num_d - num_e

print((b - a) - num_can_div + 1)


Measured memory_bytes: 9176
#include<iostream>
#include<vector>
#include<unordered_map>
#include<tuple>
#include<algorithm>
#include<stack>
using namespace std;

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

  vector<vector<int>> adj(N);
  vector<vector<int>> adj_rev(N);
  vector<tuple<int, int, int>> edges(M);
  for(int i = 0; i < M; i++){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    c = -(c - P);
    edges[i] = make_tuple(a, b, c);
    adj[a].push_back(b);
    adj_rev[b].push_back(a);
  }

  vector<bool> reachable_from_0(N, false);
  stack<int> st;
  reachable_from_0[0] = true;
  st.push(0);
  while(!st.empty()){
    int now = st.top();
    st.pop();
    for(auto next: adj[now]){
      if(reachable_from_0[next] == false){
        reachable_from_0[next] = true;
        st.push(next);
      }
    }
  }

  vector<bool> reachable_to_last(N, false);
  reachable_to_last[N - 1] = true;
  st.push(N - 1);
  while(!st.empty()){
    int now = st.top();
    st.pop();
    for(auto prev: adj_rev[now]){
      if(reachable_to_last[prev] == false){
        reachable_to_last[prev] = true;
        st.push(prev);
      }
    }
  }

  // Bellman-Ford
  vector<long long> distance(N, 1e12);
  distance[0] = 0;
  for(int i = 0; i < N - 1; i++){
    for(auto edge: edges){
      int from, to, dist;
      tie(from, to, dist) = edge;
      distance[to] = min(distance[to], distance[from] + dist);
    }
  }

  long long ans = max(0LL, -distance[N - 1]);
  for(auto edge: edges){
    int from, to, dist;
    tie(from, to, dist) = edge;
    if(distance[to] > distance[from] + dist && reachable_from_0[from] && reachable_to_last[to]){
      ans = -1;
    }
  }
  cout << ans << endl;
  
}



Measured memory_bytes: 640
n,m=map(int,input().split())

dic = {}
for i in range(0,n):
    k = list(map(int,input().split()))
    for j in range(1,len(k)):
        if k[j] in dic:
            dic[k[j]] += 1
        else:
            dic[k[j]] = 1
        
res = 0
for key,value in dic.items():
    if value == n:
        res+=1
print(res)

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

# initial
p_t, p_a = 1, 1

for i in range(N) :
    t, a = map(int, input().split())
    t_up, a_up = t, a
    
    if t >= p_t and a >= p_a : 
        p_t, p_a = t, a
    else :
        f = max(
            p_t // t if p_t % t == 0 else p_t // t + 1,  
            p_a // a if p_a % a == 0 else p_a // a + 1
        )
        
        p_t, p_a = t*f, a*f

print(p_t + p_a)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <fstream>


using namespace std;

int startNo = 0;
int endNo = 0;

void getsolve(string str) {
	int len = str.length() - 1;

	for (int i = 0; i <= len; i++) {
		if (len - i >= 2) {
			if (str[i] == str[i + 2]) {
				startNo = i + 1;
				endNo = i + 3;
				return;
			}

		}

		if (len - i >= 1) {
			if (str[i] == str[i + 1]) {
				startNo = i + 1;
				endNo = i + 2;
				return;
			}
		}



	}

	startNo = -1;
	endNo = -1;

	return;
}

int main() {
	string str;
	cin >> str;

	int len = str.length();

	getsolve(str);

	printf("%d %d\n", startNo, endNo);









	return 0;
}

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

int main(){
  // string s, t;
  // cin >> s >> t;
  // int count = 0;

  // for (int i = 0; i < 3; i++){
  //   if (s[i] == t[i]){
  //     count += 1;
  //   }
  // }
  // cout << count << endl;
  // for (int i = 2; i <= 20; i++){
  //   int a = i;
  //   for (int v = 1; v <= 20; v++){
  //     int b = v;
  //     int count = 0;
  //     while (true){
  //       // if (count == 0){
  //       //   if (a >= b){
  //       //     count += 1;
  //       //     break;
  //       //   }
  //       //   count += 1;
  //       // }else{
  //         if ((a-1)*count >= b - a){
  //           count += 1;
  //           break;
  //         }else{
  //           count += 1;
  //         }
  //       // }
  //     }
  //     cout << "a: " << a << " b: " << b << endl;

  //     if (b == 1){
  //       cout << 0 << endl;
  //     }else{
  //       cout << count << endl;
  //     }
  //   }
  // }
  
  int a, b;
  cin >> a >> b;

  int count = 0;
  while (true){
    // if (count == 0){
    //   if (a >= b){
    //     count += 1;
    //     break;
    //   }
    //   count += 1;
    // }else{
      if ((a-1)*count >= b - a){
        count += 1;
        break;
      }else{
        count += 1;
      }
    // }
  }

  if (b == 1){
    cout << 0 << endl;
  }else{
    cout << count << endl;
  }
  
}

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

using namespace std;

int main() {
  int a,b;
  cin >> a >> b;
  if(a % 2 == 1 && b % 2 == 1) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n, A[50], q, M;

int solve(int i, int m) {
  if ( m == 0 ) return 1;
  if ( i >= n ) return 0;
  int result = solve(i + 1, m) || solve(i + 1, m - A[i]);
  return result;
}

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

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> M;
    if ( solve(0, M) ) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Node struct {
	key  int
	next *Node
	prev *Node
}

var nilNode = &Node{-1, nil, nil}

func (l *Node) PrintList() {
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()
	isf := 1
	for cur := l.prev; cur != nilNode; cur = cur.prev {
		if isf == 0 {
			fmt.Fprint(w, " ")
		}
		fmt.Fprint(w, cur.key)
		isf = 0
	}
	fmt.Fprintln(w, "")
}

func (l *Node) Insert(key int) {
	newNode := &Node{key, nilNode, nilNode}
	if l.prev == nil {
		l.next = newNode
		l.prev = newNode
		return
	}
	newNode.next = l
	newNode.prev = l.prev
	l.prev.next = newNode
	l.prev = newNode
}

func (l *Node) ListSearch(key int) (*Node, bool) {
	for p := l.prev; p != nilNode; p = p.prev {
		if p.key == key {
			return p, true
		}
	}
	return nil, false
}

func (l *Node) Delete(node *Node) {

	if node.prev != nilNode {
		node.prev.next = node.next
	} else {
		l.next = node.next
	}

	if node.next != nilNode {
		node.next.prev = node.prev
	} else {
		l.prev = node.prev
	}
}

func (l *Node) DeleteFirst() {
	// if l.head == nil {
	// 	return
	// }
	l.Delete(l.prev)
}

func (l *Node) DeleteLast() {
	// if l.head == nil {
	// 	return
	// }
	l.Delete(l.next)
}

func (l *Node) RemoveItem(key int) {
	node, ok := l.ListSearch(key)
	if !ok {
		return
	}
	l.Delete(node)
}

const (
	initialBufSize = 3e7
	maxBufSize     = 3e7
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func readInt() (read int) {
	scanner.Scan()
	read, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return
}

func readRunes() (read []rune) {
	scanner.Scan()
	for _, v := range scanner.Text() {
		read = append(read, v)
	}
	return
}

func main() {
	buf := make([]byte, initialBufSize)
	scanner.Buffer(buf, maxBufSize)
	scanner.Split(bufio.ScanWords)

	n := readInt()

	for i := 0; i < n; i++ {
		com := readRunes()
		if com[0] == 'i' {
			key := readInt()
			nilNode.Insert(key)
		} else if com[0] == 'd' {
			if len(com) > 6 {
				if com[6] == 'F' {
					nilNode.DeleteFirst()
				} else if com[6] == 'L' {
					nilNode.DeleteLast()
				}
			} else {
				key := readInt()
				nilNode.RemoveItem(key)
			}
		}
	}

	nilNode.PrintList()
}



Measured memory_bytes: 119464