akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int n;
    cin >> n;
    ll c = 0 , d = 0 , b = 1000000000000000000000000000000000 , a[n];
    for(int i = 0 ; i < n ; i++) {
        cin >> a[i];
        c += a[i];
    }
    for(int i = 0 ; i < n - 1 ; i++) {
        d += a[i];
        if(i < n) b = min(b , abs(c - d * 2));
    }
    cout << b << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
//const ll mod=1e9+7;
const ll mod=924844033;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

vl fact(2005);

ll Fact(ll n){
	if(fact[n]) return fact[n];
	if(!n) return fact[n]=1;
	return fact[n]=Fact(n-1)*n%mod;
}

int n,k;

int main(){
	cin>>n>>k;
	vpll dp(n+1);
	dp[0]={1,0};
	for(int i=0;i<2*k;i++){
		int I=i/2,K=(n-I-1)/k+1;
		vpll DP(n+1);
		for(int j=0;j<K;j++){
			vpll DP(n+1);
			DP[0]={1,0};
			for(int l=1;l<=n;l++){
				ll tmp=(dp[l].first+dp[l].second)%mod;
				if(j) DP[l]={tmp,(dp[l-1].first+(l?0:dp[l-1].second))%mod};
				else DP[l]={tmp,0};
			}
			dp=DP;
		}
	}
	ll res=0;
	for(int i=0;i<=n;i++){
		ll d=dp[i].first+dp[i].second;
		if(i%2==0) (res+=d*Fact(n-i))%=mod;
		else (res=res-d*Fact(n-i)%mod+mod)%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 384
while True:
    n,k = map(int, input().split())
    if n == k == 0:
        break
    s = [int(x) for x in input().split()]
    for _ in range(n):
        b = [int(x) for x in input().split()]
        for i in range(k):
            s[i] -= b[i]
    print("Yes" if min(s) >= 0 else "No")

Measured memory_bytes: 7784
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

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

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int sz[maxn] , par[maxn];
int n;
ll a[maxn];
vector < int > srt;

bool cmp(int i , int j){
    return(a[i] > a[j]);
}

ll ans = 0;

int getpar(int v){
    return((v == par[v]) ? v : par[v] = getpar(par[v]));
}

ll merge(int x , int y){
    if(a[y] < a[x])
        return(0);
    x = getpar(x) , y = getpar(y);
    ll ans = sz[y];
    if(sz[x] < sz[y])
        swap(x , y);
    sz[x] += sz[y];
    par[y] = x;
    return(ans);
}

int32_t main(){
    migmig
    cin >> n ;
    for(int i = 0 ; i < n ; i ++)
        cin >> a[i],srt.pb(i);
    sort(srt.begin() , srt.end() , cmp);
    for(int i : srt){
        sz[i] = 1;
        par[i] = i;
        ll val = 1;
        val += merge(i , i + 1);
        val *= (merge(i , i - 1)+1);
        ans += val*a[i];
    }
    cout << ans;
    return(0);
}

Measured memory_bytes: 7216
/**
*	  Name: Ajay Subhash Jadhav
*	  Institute: International Institute of Technology Hyderabad 
*/

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <deque>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <ctime>
#include <string.h>
#define LL long long
#define inf 0x7fffffff
#define mod 1000000007
#define pb push_back
#define ppi pair<int,int>
#define vi vector<int>
#define vii vector<ppi>
#define vll vector<LL>
#define mp make_pair
using namespace std;

void fastio()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
void inputread()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}

int main()
{
      
  fastio();
  int n,k,i,j,t;
  cin>>n>>k;
  vi x(n);

  for(i=0;i<n;i++)
  	cin>>x[i];
  
  int ans=inf;

  for(i=0;i<n-k+1;i++)
  {
  	if(abs(x[i])<abs(x[i+k-1]))
  		ans=min(ans,abs(x[i])+abs(x[i+k-1]-x[i]));
  	else
  		ans=min(ans,abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
  }

  cout<<ans;
  return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<ctime>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		return F?n:-n;
	}
}
struct edg
{
	int x,y,l;
}ed[2222];
int vis[2222];
bool operator <(const edg &x,const edg &y)
{
	return x.l<y.l;
}
struct edge
{
	int to;
	int val;
	int next;
}e[3333];
int pe=1111;
void insert(int a,int to,int val)
{
	e[pe]=(edge){to,val,e[a].next};
	e[a].next=pe++;
}
int fa[1111];
int gf(int u)
{
	if(fa[u]==u)return u;
	return fa[u]=gf(fa[u]);
}
const int M=1000000007;
int ex(int b,int e)
{
	int ans=1;
	for(;e;e>>=1,b=(long long)b*b%M)
		if(e&1)ans=(long long)ans*b%M;
	return ans;
}
int max[1111][1111];
void dfs(int o,int fa,int s)
{
	for(register int p=e[o].next;p;p=e[p].next)
		if(e[p].to!=fa)
		{
			max[s][e[p].to]=dmax(max[s][o],e[p].val);
			dfs(e[p].to,o,s);
		}
}
long long sec[2222];
int main()
{
	int n=io::F(),m=io::F();
	long long X=io::G();
	for(register int i=1;i<=m;++i)
		ed[i]=(edg){io::F(),io::F(),io::F()};
	for(register int i=1;i<=n;++i)fa[i]=i;
	std::sort(ed+1,ed+m+1);
	long long mst=0;
	for(register int i=1;i<=m;++i)
	{
		int t1=gf(ed[i].x),t2=gf(ed[i].y);
		if(t1!=t2)
		{
			mst+=ed[i].l;
			fa[t1]=t2;
			insert(ed[i].x,ed[i].y,ed[i].l);
			insert(ed[i].y,ed[i].x,ed[i].l);
			vis[i]=1;
		}
	}
	int ans=0;
	if(mst==X)ans=(long long)(ex(2,n-1)-2+M)*ex(2,m-n+1)%M;
	for(register int i=1;i<=n;++i)dfs(i,i,i);
	for(register int i=1;i<=m;++i)
		if(!vis[i])
			sec[i]=mst-max[ed[i].x][ed[i].y]+ed[i].l;
	int eq=0,ge=0;
	for(register int i=1;i<=m;++i)
	{
		if(sec[i]==X)++eq;
		if(sec[i]>X)++ge;
	}
	ans=(ans+(long long)ex(2,ge+1)*(ex(2,eq)-1+M))%M;
	printf("%d\n",ans);
	return 0;
}

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

bool check(vector<vector<int>> s, vector<int> p, int sw) {
    for(int i = 0; i < s.size(); i++) {
        vector<int> cons = s.at(i);
        int cnt = 0;
        for(int c : cons) {
            if((sw >> c) & 1) {
                cnt++;
            }
        }
        if(cnt % 2 != p.at(i)) {
            return false;
        }
    }
    return true;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M);
    int k, con;
    for(int i = 0; i < M; i++) {
        cin >> k;
        for(int j = 0; j < k; j++) {
            cin >> con;
            s.at(i).push_back(con - 1);
        }
    }
    vector<int> p(M);
    for(int i = 0; i < M; i++) {
        cin >> p.at(i);
    }

    int end = (1 << N);
    int cnt = 0;
    for(int sw = 0; sw < end; sw++) {
        if(check(s, p, sw)) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int M;

    cin >> N >> M;
    int from1[N] = {0};
    int toN[N] = {0};
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (a == 0) from1[b] = 1;
        if (b == N - 1) toN[a] = 1;
    }
    
    for (int i = 0; i < N; i++) {
        if (from1[i] && toN[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
  if A[i] % 2 == 0:
    if A[i] % 3 != 0 and A[i] % 5 != 0:
      print("DENIED")
      break
  else:
    pass
else:
  print("APPROVED")

Measured memory_bytes: 3060
import java.util.Scanner;
class Main{
    public static void main(String[] a){
        Scanner stdin = new Scanner(System.in);
        int lt = stdin.nextInt();
        int[] line = new int[lt + 1];
        for(int i = 1; i <= lt; i++){
            line[i] = i;
        }
        int n = stdin.nextInt();
        for(int i = 0; i < n; i++){
            String str = stdin.next();
            String[] spl = str.split(",");
            int num1 = Integer.parseInt(spl[0]);
            int num2 = Integer.parseInt(spl[1]);
            int sum = line[num1];
            line[num1] = line[num2];
            line[num2] = sum;
        }
        for(int i = 1; i <= lt; i++){
            System.out.println(line[i]);
        }
    }
}
 

Measured memory_bytes: 26076
//not acc
#include<bits/stdc++.h>
using namespace std;
#define OUT printf
#define IN scanf
#define FN(i,s,e,d) for(int i=s; i<e; i+=d)
#define FNE(i,s,e,d) for(int i=s; i<=e; i+=d)
#define RF(i,s,e,d) for(int i=s; i>=e; i-=d)//reverse loop
#define RT return
int main()
{
    string s;
    cin>>s;
    if(s[2] == s[3] && s[4] == s[5])
        OUT("Yes\n");
    else
        OUT("No\n");
    RT 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int MOD = 1e9+7;
const long long INF = 1LL << 60;
typedef long long ll;
int main(){
    int n; cin >> n;
    string s; cin >> s;
    map<char, int> count;
    int ans=0;
    for(int i = 0; i < s.size(); i++){
        count[s[i]]=1;
        map<char, bool> check;
        for(int j = i+1; j < s.size(); j++){
            if(count[s[j]]){ //key
                check[s[j]]=true;
            }
        }
        ans = max(ans, (int)check.size());
    }
    cout << ans << endl;
}

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

public class Main {
	FastScanner in;
	PrintWriter out;

	final String fest = "FESTIVAL";

	ArrayList<Long> generate(ArrayList<Long> need) {
		long[] a = new long[8];
		a[0] = 1;
		Random rnd = new Random(123);
		final long MAX = (long) 1e18;
		int fail = 0;
		int needIt = 0;
		ArrayList<Long> all = new ArrayList<Long>();
		for (int it = 0; it < 3333; it++) {
			int pos = 1 + rnd.nextInt(a.length - 1);
			if (it < 100) {
				pos = 1 + (it) % (a.length - 1);
			}
			if (fail > 100) {
				break;
			}
			if (a[pos] + a[pos - 1] > MAX) {
				fail++;
				it--;
				continue;
			} else {
				fail = 0;
			}
			a[pos] += a[pos - 1];
			if (need != null) {
				out.print(fest.charAt(pos - 1));
			}
			if (pos == a.length - 1) {
				all.add(a[pos]);
				while (need != null && need.get(needIt) - a[pos] == 0) {
					needIt++;
					out.print("L");
					if (needIt == need.size()) {
						return null;
					}
				}
			}
		}
		return all;
	}

	void solve() {
		long K = in.nextLong();
		ArrayList<Long> f = generate(null);
		ArrayList<Long> need = new ArrayList<Long>();
		for (int i = f.size() - 1; i >= 0; i--) {
			long val = f.get(i);
			while (K >= val) {
				need.add(val);
				K -= val;
			}
		}
		Collections.reverse(need);
		generate(need);

	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 8816
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int>vec(N);
  vector<int>v(N);
  for(int X=0;X<N;X++){
    cin>>vec[X];
    v[vec[X]-1]=X+1;
  }
  for(int X=0;X<N;X++){
    if(X==N-1){
      cout<<v[X]<<endl;
    }
    else{
      cout<<v[X]<<" ";
    }
  }
}

Measured memory_bytes: 4060
s = gets.chomp
x, y = gets.split.map(&:to_i)

s =~ /(F*)(.*)/
s1 = $1
s2 = $2
xf = []
yf = []

cnt = 0
t = true
(s2.chars + ["T"]).each do |c|
  if c == "T"
    if t
      xf << cnt
    else
      yf << cnt
    end
    cnt = 0
    t = !t
  else
    cnt += 1
  end
end

a = $1.size
xf.sort.reverse.each do |n|
  if x > a
    a += n
  else
    a -= n
  end
end

b = 0
yf.sort.reverse.each do |n|
  if y > b
    b += n
  else
    b -= n
  end
end

if a==x && b==y
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 4300
#include<stdio.h>

int main(){
  long int A,B,C;
  scanf("%ld %ld",&A,&B);

  if(A<B){
    C=A;
    A=B;
    B=C;
  }
  C=A;
  while(1){
    if(A%B==0)
      break;
    else
      A=A+C;
  }
  printf("%ld\n",A);
  return 0;
}

Measured memory_bytes: 128
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() []int {
	n := readInt()
	return readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func vi(n int, args ...int) []int {
	res := make([]int, n)
	if len(args) == 0 {
		return res
	}
	v := args[0]
	if v == 0 {
		return res
	}
	for i := 0; i < n; i++ {
		res[i] = v
	}
	return res
}

func vvi(n int, args ...int) [][]int {
	res := make([][]int, n)
	m := n
	if len(args) > 0 {
		m = args[0]
	}
	v := 0
	if len(args) > 1 {
		v = args[1]
	}
	for i := 0; i < n; i++ {
		res[i] = vi(m, v)
	}
	return res
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int
func main() {
	defer stdout.Flush()
	n := readInt()
	k := readInt()
	a := make([]int, n)
	oi := -1
	for i := 0; i < n; i++ {
		a[i] = readInt()
		if a[i] == 1 {
			oi = i
		}
	}

	if n == k {
		println(1)
		return
	}
	if k >= n/2+1 {
		println(2)
		return
	}
	if oi >= n/2 {
		oi = n - oi - 1
	}

	x := k - 1
	ln := oi/x + 1
	right := n - (ln*x + 1)
	rn := right / x
	if right > rn*x {
		rn++
	}
	println(ln + rn)
}


Measured memory_bytes: 2048
#include<stdio.h>

int main(void)
{
        int w = 0;
        int n = 0;
        int i = 0, j = 0;
        int val = 0;
        int maxval = 0;
        int maxg = 0;
        int g = 0;
        int count = 0;

        while(1)
        {
                scanf("%d", &w);
                if(w == 0)
                {
                        break;
                }
                scanf("%d",&n);

                int bag[w + 1];

                for(i = 0; i <= w; i++)
                {
                        bag[i] = 0;
                }

                for(i = 0; i < n; i++)
                {
                        scanf("%d,%d", &val, &g);
                        for(j = w; j >= 0; j--)
                        {
                                if(bag[j] != 0 && g + j <= w)
                                {
                                        if(bag[j] + val > bag[g + j] )
                                        {
                                                bag[g + j] = bag[j] + val;
                                        }
                                }
                                if(j == 0 && g <= w)
                                {
                                        if(val > bag[g])
                                        {
                                                bag[g] = val;
                                        }
                                }
                        }
                }
                for(i = 0; i <= w ;i++)
                {
                        if(bag[i] > maxval)
                        {
                                maxval = bag[i];
                                maxg = i;
                        }
                }
                count++;
                printf("Case %d:\n",count);
                printf("%d\n%d\n", maxval, maxg);
                g = 0;
                maxg = 0;
                maxval = 0;
        }
        return 0;
}

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

namespace ABC122
{
    class A
    {
        static void Main(string[] args)
        {
            string b = Console.ReadLine();
            string r = "";
            if (b == "A")
            {
                r = "T";
            }
            else if (b == "C")
            {
                r = "G";
            }
            else if (b == "G")
            {
                r = "C";
            }
            else
            {
                r = "A";
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <sstream>
#include <vector>
#include <cctype>
#include <algorithm>

int main()
{
    std::vector<std::string> s{};
    std::string line{}; std::getline(std::cin, line);
    std::stringstream ss{line}; for (std::string elm{}; ss >> elm; s.push_back(elm)) {}
    std::vector<long> num_stack{};
    for (const auto &elm : s)
    {
        if (std::all_of(elm.cbegin(), elm.cend(), isdigit))
        {
            num_stack.push_back(stoi(elm));
            continue;
        }
        long num2{num_stack.back()}; num_stack.pop_back();
        long num1{num_stack.back()}; num_stack.pop_back();
        const std::string ops{"+-*"};
        if (elm.length() == 1 && std::find(ops.cbegin(), ops.cend(), elm[0]) != ops.cend())
        {
            long num = (elm == "+") ? (num1 + num2) : (elm == "-") ? (num1 - num2) : (num1 * num2);
            num_stack.push_back(num);
            continue;
        }
        return -1;
    }
    std::cout << num_stack.back() << std::endl;
}



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

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


int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int a, p;
    cin >> a >> p;
    cout << (int) ((3 * a + p) / 2) << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
p = Counter(list(map(int, input().split())))
p = sorted((x, p[x]) for x in p)

cnt = 0

if n % 2 == 0:
    s = n // 2
    pre = None
    for x, y in p:
        if p is None:
            p = x
        if s == 0:
            cnt = x - pre
            break
        s -= y
        pre = x


print(cnt)


Measured memory_bytes: 15304
#include <iostream>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef pair<string, int> psi;

int n, v;
map<string, int> m;
vector<string> k;
string s;

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> s;
        if (m.find(s) == m.end()) m.emplace(s, 1);
        else m[s]++;
    }
    v = 0;
    for (auto iter=m.begin(); iter != m.end(); ++iter){
        if (v < iter->second){
            v = iter->second;
            k.clear();
            k.push_back(iter->first);
        }
        else if (v == iter->second) k.push_back(iter->first);
    }
    for (const auto& s: k){
        cout << s << endl;
    }
}

Measured memory_bytes: 26868
#pragma warning disable

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Numerics;
using System.Collections;
using System.Timers;

static class MainClass
{
    public static void Main(string[] args)
    {

        var str = Console.ReadLine().SplittedStringToInt32List();
        var A = str[0];
        var B = str[1];
        var C = str[2];


        if (C - 1 > A + B)
        {
            Console.WriteLine(2 * B + A + 1);
        }
        else
        {
            Console.WriteLine(B + C);
        }
        Console.ReadLine();

    }

    


    #region ライブラリ
    public static long ToInt64(this string str) => long.Parse(str);
    public static int ToInt32(this string str) => int.Parse(str);
    public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    public static List<string> SplittedStringToList(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
    public static List<int> SplittedStringToInt32List(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToList();
    public static List<BigInteger> SplittedStringToBigInteger(this string str) => str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(x => BigInteger.Parse(x)).ToList();

    public const int INF = int.MaxValue / 2;
    #endregion
}


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

using namespace std;

using ll = long long int;
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

ll N;
ll INF = 1e18;
struct P{ll x,y,p;};
vector<P> Ps;

void input(){
    fast_io();
    cin >> N;
    Ps.resize(N);
    for (int i = 0; i < N; i++)
    {
        ll x,y,p; cin >> x >> y >> p;
        Ps[i] = P{x,y,p};
    }
}

inline void chmin(ll &a, ll b){if(a > b) a = b;}

vector<ll> memo[1<<15][2];
vector<ll> xscore(int bit, bool isX = true){
    if(memo[bit][isX].size()>0) return memo[bit][isX];
    vector<int> xline;
    xline.push_back(0);
    for (int i = 0; i < N; i++)
    {
        if(bit>>i&1){
            if(isX) xline.push_back(Ps[i].x);
            else xline.push_back(Ps[i].y);
        }
    }
    vector<ll> ret(N,0);
    for (int i = 0; i < N; i++)
    {
        if(bit>>i&1) {
            ret[i] = 0;
            continue;
        };
        ll sc = INF;
        for(ll x:xline) {
            if(isX) chmin(sc, abs(x-Ps[i].x)*Ps[i].p);
            else chmin(sc, abs(x-Ps[i].y)*Ps[i].p);
        }
        ret[i] = sc;
    }
    return memo[bit][isX] = ret;
}

ll score(int K, int bit, int sign){
    ll ret = 0;
    int mask = 0;
    int k = 0;
    int cnt = 0;
    while(cnt < K){
        while((bit>>k&1) == 0) k++;
        if(sign>>cnt&1) mask |= (1<<k);
        k++;
        cnt++;
    }
    auto xcost = xscore(mask,true);
    auto ycost = xscore(bit&(~mask),false);
    for (int i = 0; i < N; i++) ret += min(xcost[i], ycost[i]);
    return ret;
}

int solve(){
    vector<ll> ans(N + 1, INF);

    // ザ・前処理
    int Kmax;
    set<int> Xs,Ys;
    for (int i = 0; i < N; i++)
    {
        Xs.insert(Ps[i].x);
        Ys.insert(Ps[i].y);
    }
    Kmax = min(Xs.size(), Ys.size());
    for (int bit = 0; bit < (1<<N); bit++)
    {
        xscore(bit, true);
        xscore(bit, false);
    }
    
    
    for (int bit = 0; bit < (1<<N); bit++)
    {
        int k = __builtin_popcount(bit);
        if(k > Kmax) continue;
        if(ans[k]==0) continue;
        // bitで線を通す点をきめて
        // signでx軸に平行かy軸に平行かきめる。
        for (int sign = 0; sign < (1<<k); sign++)
        {
            if(ans[k]==0) break;
            chmin(ans[k], score(k, bit, sign));
        }
        if(ans[k]==0) for(int i = k; i < N; i++) chmin(ans[i + 1], ans[i]); 
    }
    for (int i = 0; i <= N; i++) cout << ans[i] << "\n";
    return 0;
}   

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

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=1e6+500;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
pll t[maxn*4];
void build(int v,int l,int r){
    if(l==r){
        t[v].F=inf;
        if(l==1){
            t[v].F=0;
        }
        t[v].S=l;
        return;
    }
    int m=l+r>>1;
    build(v+v,l,m);
    build(v+v+1,m+1,r);
    t[v]=min(t[v+v],t[v+v+1]);
}
pll get(int v,int tl,int tr,int l,int r){
    if(tl>r || l>tr){
        return {inf,inf};
    }
    if(l<=tl && tr<=r){
        return t[v];
    }
    int tm=tl+tr>>1;
    return min(get(v+v,tl,tm,l,r),get(v+v+1,tm+1,tr,l,r));
}
void update(int v,int l,int r,int pos,int x){
    if(pos>r || pos<l){
        return;
    }
    if(l==r){
        t[v].F=x;
        return;
    }
    int m=l+r>>1;
    update(v+v,l,m,pos,x);
    update(v+v+1,m+1,r,pos,x);
    t[v]=min(t[v+v],t[v+v+1]);
}
int dp[maxn],p[maxn];
int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    s="#"+s;
    n++;
    build(1,1,n);
    for(int i=2;i<=n+1;i++){
        if(s[i]=='0'){
            dp[i]=get(1,1,n,max(i-k,1),i-1).F+1;
            p[i]=get(1,1,n,max(i-k,1),i-1).S;
            update(1,1,n,i,dp[i]);
        }
    }
    if(dp[n]>=inf){
        cout<<"-1";
        return 0;
    }
    int id=n;
    vector<int>v;
    while(id!=0){
        v.pb(id);
        id=p[id];
    }
    reverse(all(v));
    for(int i=1;i<v.size();i++){
        cout<<v[i]-v[i-1]<<" ";
    }
	exit(0);
}


Measured memory_bytes: 11640
#include<stdio.h>
int main(void)
{
    long int n;
    scanf("%ld",&n);
    long int a = n / 3;
    long int b = n / 5;
    long int c = n / 15;
    long int sum,sum3,sum5,sum15;
    sum = n*(n+1)/2;
    sum3 = 3*a*(a+1)/2;
    sum5 = 5*b*(b+1)/2;
    sum15 = 15*c*(c+1)/2;
    long int ans = sum -sum3 -sum5 + sum15;
    printf("%ld\n",ans);
    return 0;
}

Measured memory_bytes: 1736
fn main() {
	proconio::input!{
		n: usize,
		mut s: [usize; n],
	}

	let mut sum = 0;
	for i in 0..n {
		sum += s[i];
	}
	if sum % 10 != 0 {
		println!("{}", sum);
		return;
	}

	s.sort();
	for i in 0..n {
		if s[i] % 10 != 0 {
			println!("{}", sum-s[i]);
			return;	
		}
	}
	println!("0");
}



Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define X first
#define Y second
#define sps printf(" ")
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define all(v) v.begin(),v.end()
#define dis(it,it1) distance(it,it1)+1
#define MAX 200005
#define INF 9223372036854775807LL
#define MOD 1000000007
#define print(cs) printf("Case %lld: ",cs)
#define Yesno(ok) if(ok)puts("YES");else puts("NO")
#define yesno(ok) if(ok)puts("Yes");else puts("No")
ll lcm(ll a,ll b){return ((a*b)/__gcd(a,b));}
ll cnt=0;
ll binpow(ll a,ll b)
{
    if(b==0)return 1;
    ll res = binpow(a, b / 2);
    if (b&1)
        return (res%MOD * res%MOD * a%MOD)%MOD;
    else
        return (res%MOD * res%MOD)%MOD;
}
ll f[MAX],invf[MAX];
void init()
{
    ll i,j,k,l,r;
    f[0]=1;
    invf[0]=1;
    for(i=1;i<MAX;i++)
    {
        f[i]=(i*f[i-1])%MOD;
        invf[i]=binpow(f[i],MOD-2);
    }
}
ll ncr(ll n,ll r)
{
    ll res=(f[n]*invf[r])%MOD;
    res=(res*invf[n-r])%MOD;
    return res;
}
int main()
{
    init();
    ll i,h,q,w,j,k,l,r,n,m;
    in(h);in(w);
    ll a,b;
    in(a);in(b);
    ll ans=0;
    for(i=b+1,j=h-a;i<=w;i++)
    {
        ans+=((ncr(j+i-2,j-1)%MOD)*(ncr(a+w-i-1,w-i)%MOD))%MOD;
        ans%=MOD;
    }
    out(ans);
endl;
}



Measured memory_bytes: 3456
n = int(input())
ais = list(map(int, input().split()))

xs = [0] * n
s = sum(ais)
xs[0] = s - 2 *sum(ais[1::2])

for i in range(1,n):
    xs[i] = 2*ais[i-1] - xs[i-1]

print(*xs)


Measured memory_bytes: 14092
(defun solve (K)
  (defvar r (mod 7 K))
  (defvar ht (make-hash-table))

  (loop for i from 1
        
        if (zerop r) return i
        if #1=(gethash r ht) return -1
        do (setf #1# t
                 r (mod (+ (* 10 r) 7) K))))

(princ (solve (read)))

Measured memory_bytes: 122556
let s = stdin.ReadLine()
let t = stdin.ReadLine()

[for i in 0..s.Length - t.Length ->
    [for j in 1..t.Length do
        if s.[i + j - 1] <> t.[j - 1] then yield 1]]
|> List.map List.sum |> List.min |> printfn "%d"

Measured memory_bytes: 34140
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int sum_(ll i){
    ll sum = 0;
    while(i > 0){
        sum += i % 10;
        i /= 10;
    }
    return sum;
}

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ll sum = sum_(i);
        if(sum >= a && sum <= b){
            ans += i;
        }
    }
    cout << ans << endl;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++) 
#define fs first
#define sc second
#define PI (3.1415926535897932384)
#define _GLIBCXX_DEBUG

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }



// 1次元vectorの出力
template <class S>
void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){
		cerr << v[i] << ' ';
	}
	cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  	for (ll i = 0; i < (ll)v.size(); i++) {
    	for (ll j = 0; j < (ll)v[i].size(); j++) {
      		cerr << v[i][j] << ' ';
    	}
    	cerr << endl;
  	}
}

int main(void){
	//cout << fixed << setprecision(20);
	int n; cin >> n;
	vector<int> a(n,0);
	int t;
	Rep(n-1){
		cin >> t;
		a[t-1]++;
	}
	rep(i,n){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 4052
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

    if(A * B % 2 == 1) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int n;
int m;
pair<int,int> h[200];

int dp[2][200];

int solve(int pos, int size, int s2){
  if(pos == n+m) return 0;

  int a = 0, b = 0;

  //if(dp[0][pos] == -1)
  a = solve(pos+1, size, s2);

  if(size < h[pos].s && s2 < h[pos].f){
    if(dp[1][pos] == -1)
      b = dp[1][pos] = solve(pos+1, h[pos].s, h[pos].f) + 1;
    else
      b = dp[1][pos];
  }

  return max(a, b);
}

int main(){
  while(n = getInt()){
    REP(i,n){
      h[i].f = getInt();
      h[i].s = getInt();
    }

    m = getInt();
    REP(i,m){
      h[i+n].f = getInt();
      h[i+n].s = getInt();
    }

    sort(h, h+n+m);

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

    print(solve(0,-1,-1));

  }
  return 0;
}

Measured memory_bytes: 0
#import sys
#input = sys.stdin.readline
def main():
    Q = 2019
    L, R = map( int, input().split())
    if L%Q == 0:
        print(0)
        return
    if (L//Q+1)*Q <= R:
        print(0)
        return
    T = [0]*2019
    for i in range(L%Q, R%Q+1):
        T[i] = 1
    ans = 2018
    for i in range(Q-1):
        if T[i] == 0:
            continue
        for j in range(i+1,Q):
            if T[j] == 0:
                continue
            if i*j%Q < ans:
                ans = i*j%Q
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 40048
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
 
int left(int i){return i*2;}
int right(int i){return i*2+1;}
void maxHeapify(std::vector<int>& A, int i)
{
    int H = A.size();
    int l = left(i);
    int r = right(i);
    int largest;
    if(l <= H && A[l] > A[i]){
        largest = l;
    }else{
        largest = i;
    }
    if(r <= H && A[r] > A[largest]){
        largest = r;
    }
    if(largest != i){
        std::swap(A[i], A[largest]);
        maxHeapify(A, largest);
    }
}
 
void buildMaxHeap(std::vector<int>& A)
{
    int H = A.size() + 1;
    for(std::size_t i = H/2; i; --i){
        maxHeapify(A, i);
    }
}
 
int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int H;
    std::cin >> H;
    std::vector<int> A(H+1);
    for(std::size_t i = 1; i <= H; ++i){
        int Value;
        std::cin >> Value;
        A[i] = Value;
    }
    buildMaxHeap(A);
    for(std::size_t i = 1; i <= H; ++i){
        std::cout << " " << A[i];
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 4952
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

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


typedef struct node * Node;



Node root;


void insert(int k)
{
  Node x;
  Node y;
  Node z;
  y = NIL;
  x = root;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key)
      x = x->left;
    else
      x = x->right;
  }
  z->parent = y;

  if(y==NIL)
    root = z;
  else if(z->key<y->key)
    y->left = z;
  else
    y->right = z;

}

void inorderTreeWalk(Node x)
{
  if(x==NIL)
    return;
  
  inorderTreeWalk(x->left);
  printf(" %d",x->key);
  inorderTreeWalk(x->right);
}

void preorderTreeWalk(Node x)
{
  if(x==NIL)
    return;
  
    printf(" %d",x->key);
    preorderTreeWalk(x->left);
    preorderTreeWalk(x->right);
  
}

Node treeSearch(Node x,int k){
  if(x==NIL || k==x->key)
    return x;
  if(k<x->key)
    return treeSearch(x->left,k);
  else
    return treeSearch(x->right,k);
}


int main()
{
  char str[20];
  int x, m, i;
  Node T;

  scanf("%d",&m);
  for( i=0 ; i<m ; i++ ){
    scanf("%s",str);
    if(str[0]=='f'){
      scanf("%d",&x);
      T = treeSearch(root,x);
      if(T!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(str[0]=='p'){
      inorderTreeWalk(root);
      printf("\n");
      preorderTreeWalk(root);
      printf("\n");
    }
  }

  return 0;
  
}

Measured memory_bytes: 19364
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for(int i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
    sort(ret.begin(), ret.end(), greater<int>());
	return ret;
}

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

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

    sort(A.begin(), A.end());
    
    int result0 = A[0];
    vector <int> EA0 = enum_div(A[0]);
    int j = 0;

    while(result0 > 0){
        int count = 0;
        result0 = EA0[j];
        for(int i = 0; i < N; i++){
            if (A[i] % result0 != 0) {
                count += 1;
                if (count >= 2) {
                    break;
                }   
            }
        }
        if (count <= 1) {
            break;
        }else{
            j += 1;
        }
    }

    int result1 = A[1];
    vector <int> EA = enum_div(A[1]);
    j = 0;
    while(result1 > 0){
        int count = 0;
        result1 = EA[j];
        for(int i = 0; i < N; i++){
            if (A[i] % result1 != 0) {
                count += 1;
		if(count >= 2){
			break;
		}
            }
        }
        if (count <= 1) {
            break;
        }else{
            j += 1;
        }
    }

    if (result0 >= result1) {
        cout << result0 << endl;
    }else{
        cout << result1 << endl;
    }
    
    
    

    return 0;
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
	}

	sort.Ints(a)

	answer := a[n-1] - a[0]
	fmt.Println(answer)
}


Measured memory_bytes: 512
N=int(input())
A=list(map(int,input().split()))
L=[0 for i in range(100001)]
result=0

for i in range(N):
    L[A[i]]+=1

for i in range(100001-2):
    if L[i]+L[i+1]+L[i+2]>result:
        result=L[i]+L[i+1]+L[i+2]

print(result)

Measured memory_bytes: 13964
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>

using namespace std;



int main(){
    long n;
    cin >> n;
    for(long s=sqrt(n);s>=0;s--){
        if(n % s == 0){
            cout<< (n/s-1+s-1);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    int MOD = 1000000007;
    int n,m;
    cin >> n >> m;
    vp v[n];
    rep(i,m){
        int l,r,d;
        cin >> l >> r >> d;
        l--; r--;
        v[l].push_back(P(r,d));
        v[r].push_back(P(l,-d));
    }

    queue<int> que;
    int pos[n];
    rep(i,n)pos[i] = MOD;

    rep(i,n){
        if(pos[i]==MOD){
            pos[i] = 0;
            rep(j,v[i].size()){
                pos[v[i][j].first] = v[i][j].second;
                que.push(v[i][j].first);
            }
            while(que.size()>0){
                int x = que.front();
                que.pop();
                rep(j,v[x].size()){
                    if(pos[v[x][j].first]==MOD){
                        pos[v[x][j].first] = pos[x] + v[x][j].second;
                        que.push(v[x][j].first);
                    }else{
                        if(pos[x] + v[x][j].second != pos[v[x][j].first]){
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}
 
 


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

int n;

int main() {
    cin >> n;
    vector<pair<int, int>> V;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (j ^ (n + !(n & 1) - i)) V.push_back({i, j});
        }
    }
    printf("%d\n", V.size());
    for (auto p : V) printf("%d %d\n", p.first, p.second);
    return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))

box = [0] * 61
for i in range(n):
    s = bin (a[i])
    for j in range(len(s)-1):
        if s[-j] == '1':
            box[j] += 1
ans = 0
for i in range(1,61):
    ans += box[i] * (n - box[i]) * pow(2,i-1,10**9+7)
print(ans % (10**9+7))

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
ll a[maxn];
ll b[maxn];
void run_case()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i + 1];
        a[i + 1] += a[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i + 1];
        b[i + 1] += b[i];
    }
    int ans = 0;
    // for (int i = 1; i <= m; i++)
    // {
    //     DBG(b[i]);
    // }
    //DBG(b[m]);
    for (int i = 0, j = m; i <= n; i++)
    {
        //  DBG(ans);
        if (a[i] > k)
            break;
        while (a[i] + b[j] > k)
        {
            j--;
            //DBG(j);
        }
        ans = max(i + j, ans);
        //DBG(ans);
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 6760
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ignore ignore
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define inp(p) in2(p.F,p.S)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define prp(p) pr2(p.F,p.S)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define pinttwod(mat,i,j,n,m) rep(i,n){rep(j,m)pr(mat[i][j]);   lin;}
#define plltwod(mat,i,j,n,m)  rep(i,n){rep(j,m)llpr(mat[i][j]); lin;}
#define byes printf("YES\n")
#define bno printf("NO\n")
#define yes printf("Yes\n")
#define no printf("No\n")
#define lin printf("\n")
// Iterator
#define rep(i,n) for(i=0;i<n;++i)
#define rrep(i,n) for(i=n-1;i>=0;--i)
#define lp(i,a,b) for(i=a;i<b;++i)
#define rlp(i,a,b) for(i=a;i>=b;--i)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// function
#define sz(x) x.size()
#define inrange(i,a,b) (i>=a && i<=b)
#define FLUSH fflush(stdout)
#define precision(x) cout << setprecision(x) << fixed
#define remax(a,b) a=max(a,b)
#define remin(a,b) a=min(a,b)
#define bhardo(mat,i,j,n,m,t) rep(i,n){rep(j,m)mat[i][j]=t;}
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
// Constant
const double PI = acos(-1);
const double eps = (1e-9);
const ll INF = 1e18;
const int M = (1e9)+7;
const int N = (1e5)+5;  // check the limit, man
void solve()
{
    int k,r;
    in2(k,r);
    k=min(k,10);
    k=100*(10-k);
    out(k+r);
}
int main()
{
    int t;
    t=1;
    //in(t);
    while(t--)
        solve();
}






Measured memory_bytes: 256
import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

case class Robot(x: Int, l: Int) {
  val left: Int = x - l
  val right: Int = x + l
}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val n = in.readLine().toInt
    val robots = Array.fill(n) {
      in.readLine().split("\\s+").map(_.toInt) match {
        case Array(x, l) => Robot(x, l)
      }
    }

    val robotsByRightMost = robots.sortWith {
      case (r1, r2) => r1.right < r2.right
    }

    out.println(
      robotsByRightMost.foldLeft((0, -1000000000)) {
        case ((num, min), robot) =>
          if (min <= robot.left) {
            (num + 1, robot.right)
          } else {
            (num, min)
          }
      }._1
    )

    out.flush()
  }
}


Measured memory_bytes: 78696