akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#define LEN 100005
typedef struct pp{
 char name[100];
 int t;
}P;
P Q[LEN];
int head,tail,n;
void enqueue(P x){
 Q[tail]=x;
 tail=(tail+1)%LEN;
}
P dequeue(){
 P x=Q[head];
 head=(head+1)%LEN;
 return x;
}
int min(int a,int b){return a<b?a:b;}
int main(){
 int elaps=0,c;
 int i,q;
 P u;
 scanf("%d %d",&n,&q);
 for(i=1;i<=n;i++){
  scanf("%s",Q[i].name);
  scanf("%d",&Q[i].t);
 }
 head=1;tail=n+1;
 while(head!=tail){
  u=dequeue();
  c=min(q,u.t);
  u.t-=c;
  elaps+=c;
  if(u.t>0)enqueue(u);
  else printf("%s %d\n",u.name,elaps);
 }
 return 0;
}


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

int main()
{
    string s, p;
    int ok, done = 0;
    getline(cin, s);
    getline(cin, p);
    s += s;
    for (int i = 0; i < s.size() - p.size(); i++)
    {
        for (int j = 0; j < p.size(); j++)
        {
            if (s[i + j] == p[j])
            {
                ok = 1;
            }
            else
            {
                ok = 0;
                break;
            }
        }
        if (ok == 1)
        {
            done = 1;
            cout << "Yes" << endl;
            break;
        }
    }
    if (!done)
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int digitsum(int n){
    int tmp = 0;

    while(n >= 1){
        tmp += n % 10;
        n /= 10;
    }

    return tmp;
}

int main(){

    int n,a,b;
    cin >> n >> a >> b;
    int ans = 0;

    for(int i = 1; i <= n; i++){
        int tmp = digitsum(i);

        if(a <= tmp && tmp <= b) ans += i;

    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <math.h>
using namespace std;

const long long INF = 1LL << 60;  // どういう意味だろうか

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

int main() {
	int N;
	vector<int> h;
	int temp;
	vector<long long int> dp(100000, INF);

	cin >> N;

	// initilize
	for (int i = 0; i < N; i++) {
		cin >> temp;
		h.push_back(temp);
	}

	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	long long int temp1, temp2;

	for(int i = 2; i < N; i++){
		temp1 = abs(h[i]- h[i-2]) + dp[i-2];
		temp2 = abs(h[i]- h[i-1]) + dp[i-1];

		chmin(temp1, temp2);

		dp[i] = temp1;
	}

	cout << dp[N-1] << endl;
}


Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int h[11];
int main()
{
	int a[3],cnt=0;
	for(int i=0;i<3;i++)
	cin>>a[i];
	for(int i=0;i<3;i++)
	h[a[i]]++;
	
	// for(int i=0;i<=10;i++)
	// cout<<h[i]<<" ";
	for(int i=0;i<=10;i++)
	{
		if(h[i]==2)
		cnt++;
	}
	if(cnt==1)
	cout<<"Yes\n";
	else cout<<"No\n";
	
}

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

int main() { 	
  int  N,S;
  	cin >> N;
    vector<int> P(N);
  int p,m;

  p=0;
  
for(int i=0;i<N;i++){
	cin >>P.at(i);
  }
  sort(P.begin(), P.end());
  
  if(N%2==1){
 p=0;
  }else{
    S=N/2;
        if(P.at(S-1)<P.at(S)){
          p=P.at(S)-P.at(S-1);
          }
  }
cout << p<<endl;
  
  
}

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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    vector<int> ans(N);

    ans[0] = xs[0];
    ans[N - 1] = xs[N - 2];

    for (int i = 1; i < N - 1; ++i)
        ans[i] = min(xs[i - 1], xs[i]);

    ans[N - 1] = xs[N - 2];

    return accumulate(ans.begin(), ans.end(), 0);
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N - 1);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
    ll N,K;
    cin >> N >> K;
    ll sum = 0;
    vector<ll> A(N+1,0),B(N+1,0);
    for(int i=1;i<=N;i++){
        cin >> A[i];
        sum += A[i];
    }
    ll ans = 1;
    auto check = [&](ll mod){
        vector<ll> S(N+1);
        for(ll i=1;i<=N;i++){
            S[i] = A[i]%mod;
        }
        sort(S.begin()+1,S.end());
        ll cnt = 0;
        int l = 1, r = N;
        while(l<r){
            ll mi = min(S[l],mod-S[r]);
            cnt += mi;
            S[l] -= mi;
            (S[r] += mi)%=mod;
            if(S[l]==0) l++;
            if(S[r]==0) r--;
        }
        return cnt<=K;
    };
    for(ll i=1;i*i<=sum;i++){
        if(sum%i!=0) continue;
        if(check(i)) ans = max((ll) ans,i);
        if(check(sum/i)) ans = max((ll)ans,sum/i);
    }
    cout << ans << endl;
}

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

#define ll long long
const int mod = 1e9 + 7;

ll int dp[100005][3];

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

  int n, x;

  cin>>n;
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>x;
      for(int k=0;k<3;k++)
        if(j != k)
          dp[i][j] = max(dp[i][j], dp[i-1][k] + x);
    }
  }

  cout<<max(dp[n][0], max(dp[n][1], dp[n][2]))<<endl;

  return 0;
}


Measured memory_bytes: 2560
function Main(input) {
	input += "ooooooooooooooo"
	input = input.split("");
	var sum = 0;
	for(var i=0;i<15;i++){
		if(input[i]=="o") sum++;
	}
	console.log(sum>=8?"YES":"NO")
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll LL;
vector<string> S;
vector<string> V;
ll nim;
string T;

ll hoge(ll x) {
	ll y=1;
	while(x%2==0) {
		y<<=1;
		x>>=1;
	}
	return y;
}

void dfs(int x,int L,int R) {
	//cout<<T<<" "<<x<<" "<<L<<" "<<R<<endl;
	if(L>=R) {
		//cout<<"nim"<<T<<endl;
		nim^=hoge(LL-x+1);
	}
	else if(V[L].size()<=x) {
		return;
	}
	else {
		int M=L-1;
		for(int i=18;i>=0;i--) {
			M+=1<<i;
			if(M<R && V[M][x]=='0') continue;
			M-=1<<i;
		}
		//T.push_back('0');
		dfs(x+1,L,M+1);
		//T.pop_back();
		//T.push_back('1');
		dfs(x+1,M+1,R);
		//T.pop_back();
	}
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>LL;
	FOR(i,N) {
		cin>>s;
		S.push_back(s);
	}
	sort(ALL(S));
	FORR(s,S) {
		while(s.size()&&V.size()) {
			string v=V.back();
			if(s.size()==v.size() && s.substr(0,s.size()-1)==v.substr(0,s.size()-1)) {
				V.pop_back();
				s.pop_back();
			}
			else {
				break;
			}
		}
		V.push_back(s);
	}
	
	if(V.size()==1 && V[0]=="") {
		cout<<"Bob"<<endl;
		return;
	}
	
	//FOR(i,V.size()) cout<<i<<" "<<V[i]<<endl;
	
	dfs(0,0,V.size());
	//cout<<"nim="<<nim<<endl;
	if(nim) cout<<"Alice"<<endl;
	else cout<<"Bob"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4432
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        boolean[] alp = new boolean[26];
        for (int i = 0; i < 26; i++) {
            alp[i] = false;
        }
        boolean f = true;
        String s = sc.next();
        for (int i = 0; i < s.length(); i++) {
            if(alp[s.charAt(i)-'a']){
                f = false;
                break;
            }
            alp[s.charAt(i)-'a'] = true;
        }
        io.yesno(f);
        sc.close();
    }
}

class io {
    public static void br() {
        System.out.println("");
    }

    public static void yesno(boolean f) {
        System.out.println(f ? "yes" : "no");
    }

    public static void YesNo(boolean f) {
        System.out.println(f ? "Yes" : "No");
    }

    public static void YESNO(boolean f) {
        System.out.println(f ? "YES" : "NO");
    }

}

class Algo {
    public static int nibutan(int target, int[] ar) {
        // ar[i] >= target なる最小のiを探す
        int res;
        int high = ar.length;
        int low = 0;
        while (high > low) {
            res = (high + low) / 2;
            if (ar[res] < target) {
                // ↑↓ここを変える
                low = res + 1;
            } else {
                // ↓ここを変える
                high = res;
            }
        }
        return low;
    }

    public static boolean isOdd(int n) {
        return n % 2 == 1;
    }

    public static boolean isEven(int n) {
        return n % 2 == 0;
    }


}



Measured memory_bytes: 22868
import math
n = input()

def kock(i, n, x1, y1, x2, y2):
    a = [0,0,0,0,0]
    b = [0,0,0,0,0]
    if i < n:
        a[0] = x1
        b[0] = y1
        a[1] = (2*x1+x2)/3.0
        b[1] = (2*y1+y2)/3.0
        a[2] = (x1+2*x2)/3.0
        b[2] = (y1+2*y2)/3.0
        a[3] = (a[2] - a[1])*math.cos(math.pi/3) - (b[2] - b[1])*math.sin(math.pi/3) + a[1]
        b[3] = (b[2] - b[1])*math.cos(math.pi/3) + (a[2] - a[1])*math.sin(math.pi/3) + b[1]
        a[4] = x2
        b[4] = y2
        kock(i+1, n, a[0], b[0], a[1], b[1])
        print a[1], b[1]
        kock(i+1, n, a[1], b[1], a[3], b[3])
        print a[3], b[3]
        kock(i+1, n, a[3], b[3], a[2], b[2])
        print a[2], b[2]
        kock(i+1, n, a[2], b[2], a[4], b[4])
 
print float(0), float(0)
kock(0, n, float(0), float(0), float(100), float(0))
print float(100), float (0)

Measured memory_bytes: 6668
//AtCoder ABC127 B - Algae  
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int r,D,x2k;
    cin>>r>>D>>x2k;
    lli x=x2k;
    for(int i=0;i<10;++i){
        x=r*x-D;
        cout<<x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int J, Y;
char pass[64];

void parse(int pos, int j, int y){
  if ( j == J && y == Y ){
    pass[pos] = '\0';
    printf("%s\n", pass); return;
  } else if ( j == 5 && y <= 3 || y == 5 && j <= 3){
    return;
  }
  if ( j > J || y > Y ) return;
  pass[pos] = 'A';
  parse(pos+1, j+1, y);
  pass[pos] = 'B';
  parse(pos+1, j, y+1);
}

int main(){
  scanf("%d %d", &J, &Y);
  parse(0, 0, 0);
  return 0;
}



Measured memory_bytes: 2064
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define rrep(i, n) for(int i=n;i>=0;i--)
#define MAX 100
#define INF 100000001
template<typename T>T chmin(T& a, T b){return a=(a<b)?a:b;}

using namespace std;
// Matrix chain
int matrixes[MAX+1];
int m[MAX+1][MAX+1];

int mco(int i, int j){
  if (m[i][j]!=INF) return m[i][j];
  for (int div=i;div<j;div++)
    chmin(m[i][j], mco(i, div)+mco(div+1, j)+ matrixes[i-1]*matrixes[div]*matrixes[j]);
  return m[i][j];
}

int main(){
  int n;
  scanf("%d", &n);
  rep(i, n)
    scanf("%d%d", matrixes+i,matrixes+i+1);

  for(int i=1;i<n+1;i++){
    for(int j=1;j<n+1;j++){
      m[i][j] = (i!=j)?INF:0;
    }
  }

  printf("%d\n", mco(1, n));
  return 0;
}



Measured memory_bytes: 3208
fun main(args: Array<String>) {
    var n = getInt()
    val a = getInts()
    val all = a.reduce { a, x -> a xor x}
    println(a.map { all xor it }.joinToString(" "))
}

fun getInt() = readLine()!!.toInt()
fun getInts() = readLine()!!.split(" ").map { it.toInt() }

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

void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v){
    ll dp[N+1][W+1] = {};
    for(int i=0;i<N;i++){
        for(ll j=1;j<=W;j++){
            if(j<w[i]){
                dp[i+1][j] = dp[i][j];
                continue;
            }
            dp[i+1][j] = max(dp[i][j],dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> w(N);
    std::vector<long long> v(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&w[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, W, std::move(w), std::move(v));
    return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()
//#define LN cerr<<__LINE__<<endl
#define LN 0
using pi=pair<int,int>;
int read(){
	int i;
	scanf("%d",&i);
	return i;
}
void chmin(int&a,int b){
	a=a<b?a:b;
}
void chmax(int&a,int b){
	a=a>b?a:b;
}
struct SegTree{
	vi buf;
	int s;
	SegTree(int n){
		s=1;
		while(s<n)s*=2;
		buf.resize(s*2,-1);
	}
	void Update(int i,int v){
		i+=s;
		buf[i]=v;
		while((i/=2)>=1)buf[i]=max(buf[i*2],buf[i*2+1]);
	}
	int GetIdx(int b,int e,int t,vi&dst,int l,int r,int i){
		if(buf[i]<=t||e<=l||r<=b)return t;
		if(b<=l&&r<=e){
			if(l+1==r){
				if(t<buf[i])dst.PB(l);
				return max(t,buf[i]);
			}else{
				if(t<buf[i*2])
					t=GetIdx(b,e,t,dst,l,(l+r)/2,i*2);
				if(t<buf[i*2+1])
					t=GetIdx(b,e,t,dst,(l+r)/2,r,i*2+1);
				return t;
			}
		}
		t=GetIdx(b,e,t,dst,l,(l+r)/2,i*2);
		t=GetIdx(b,e,t,dst,(l+r)/2,r,i*2+1);
		return t;
	}
	void GetIdx(int b,int e,vi& dst){
		GetIdx(b,e,-1,dst,0,s,1);
	}
	int get(int x){
		return buf[x+s];
	}
};
inline int xorshift(){
	static int w=1145141919;
	w=w^(w<<17);
	w=w^(w>>13);
	w=w^(w<<5);
	return w;
}
struct Node{
	Node *l,*r;
	int v,s;
} buf[200010];
Node* Merge(Node*a,Node*b){
	if(!a)return b;
	if(!b)return a;
	int s=a->s+b->s,x=xorshift()%s;
	if(x<a->s){
		a->r=Merge(a->r,b);
		a->s=s;
		return a;
	}else{
		b->l=Merge(a,b->l);
		b->s=s;
		return b;
	}
}
using pn=pair<Node*,Node*>;
pn Split(Node*x,int t){
	if(!x)return pn(0,0);
	if(t<=x->v){
		pn c=Split(x->l,t);
		if(c.first)x->s-=c.first->s;
		x->l=c.second;
		return pn(c.first,x);
	}else{
		pn c=Split(x->r,t);
		if(c.second)x->s-=c.second->s;
		x->r=c.first;
		return pn(x,c.second);
	}
}
int MaxValue(Node* x){
	while(x->r)x=x->r;
	return x->v;
}
void Show(Node* x){
	if(!x)return;
	Show(x->l);
	cerr<<x->v<<" ";
	Show(x->r);
}
int main(){
	int n=read();
	SegTree seg(n*2);
	vector<Node*> trs(n*2);
	vi mx(n*2,-1);
	REP(i,n){
		int x=read()-1;
		seg.Update(i,x);
		trs[i]=buf+i;
		trs[i]->v=x;
		trs[i]->s=1;
		mx[i]=x;
	}
	vi idx;
	int sum=0;
	FOR(i,n,n*2){
		idx.clear();
		seg.GetIdx(0,i,idx);
		int last=-1;
		Node*x=0;
		sum+=idx.size();
		for(auto j:idx){
			LN;
			pn c=Split(trs[j],last);
			LN;
			last=mx[j];
			LN;
			if(c.first)
				mx[j]=MaxValue(c.first);
			else
				mx[j]=-1;
			LN;
			seg.Update(j,mx[j]);
			LN;
			trs[j]=c.first;
			LN;
			x=Merge(x,c.second);
			LN;
		}
		if(x->s==n){
			cout<<i-n<<endl;
			return 0;
		}
		if(sum>=2e6)return 0;
		mx[i]=last;
		seg.Update(i,mx[i]);
		trs[i]=x;
		//Show(x);
	}
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

const string YES = "Yes";
const string NO  = "No";

struct Edge {
  int to,cost;
};

template<typename T>
bool visit(const T& G,int v,vector<int>& order,vector<int>& color){
  color[v] = 1;
  for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++){
      if(color[e->to] == 2)continue;//このvisit以外のvisitで訪れた
      if(color[e->to] == 1)return false;//このvisitで訪れた
      if(!visit(G,e->to,order,color))return false;
    }
  order.push_back(v);
  color[v] = 2;
  return true;
}

template<typename T>
bool topologicalSort(const T& G,vector<int>& order){
  int SizeG = G.size();
  vector<int> color(SizeG); 
  for(int u=0;u<SizeG;u++) if(!color[u] && !visit(G,u,order,color)) return false;
  reverse(order.begin(),order.end());
  return true;
}


#define MAX 210000
int V,E;
int L[MAX],R[MAX],D[MAX];
vector<vector<Edge>> G;
vector<int> order;

bool hasLoop() {
  if( !topologicalSort(G,order) ) return true;
  return false;
}

bool visited[MAX];
ll vs[MAX];

bool update_dfs(int cur) {
  rep(i,(int)G[cur].size()) {
    int nex = G[cur][i].to;
    ll cost = vs[cur] + (ll)G[cur][i].cost;
    if( !visited[nex] ) {
      visited[nex] = true;
      vs[nex] = cost;
      if( !update_dfs(nex) ) return false;
    } else {
      if( vs[nex] != cost ) return false;
    }
  }
  return true;
}

bool debug = false;
void compute() {
  G.resize(V,vector<Edge>());
  rep(i,E) G[L[i]-1].push_back((Edge){R[i]-1,D[i]});
  if( hasLoop() ) { puts(NO.c_str()); return; }
  rep(i,V) vs[i] = 0, visited[i] = false;
  rep(i,V) {
    int cur = order[i];
    if( !visited[cur] ) {
      if( !update_dfs(cur) ) { puts(NO.c_str()); return; }
    }
  }
  if( debug ) {
    puts("order = ");
    rep(i,V) cout << order[i] << " "; puts("");
    rep(i,V) {
      cout << i << "-th " << vs[i] << endl;
    }
  }
  rep(i,E) {
    ll cost = vs[R[i]-1] - vs[L[i]-1];
    if( cost != D[i] ) { puts(NO.c_str()); return; }
  }
  puts(YES.c_str());
}

int main() {
  cin >> V >> E;
  rep(i,E) cin >> L[i] >> R[i] >> D[i];
  compute();
  return 0;
}


Measured memory_bytes: 15344
use proconio::input;

fn main() {
    input! { n: usize, a: [u64; n]};

    const MOD: u64 = 1000000007;

    let mut x = 0;
    let mut ans = 0;

    for v in a {
        ans = (ans + v * x) % MOD;
        x = (x + v) % MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 5672
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

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

  int n;
  cin>>n;
  std::vector<int> gain;
  std::vector<int> v(n),c(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
  }
  for(int i=0;i<n;i++){
    cin>>c[i];
  }
  for(int i=0;i<n;i++){
    gain.push_back(v[i]-c[i]);
  }
  std::sort(gain.begin(),gain.end(),std::greater<int>());
  int result=0;
  for(auto i:gain){
    if(i>0) result+=i;
  }
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 888
import sys
from sys import stdin
input = stdin.readline

n = int(input())
NUM_LIST = list(map(int, input().split()))
result = [0]*n

count = [0]*10001 #(max(NUM_LIST)+1)

for num in NUM_LIST:
    count[num] += 1

for i in range(1, len(count)):
    count[i] += count[i-1]

for num in NUM_LIST:
    result[count[num]-1] = num
    count[num] -= 1

print(" ".join(list(map(str, result))))



Measured memory_bytes: 240580
N = int(input())
A = list(map(int, input().split()))
A_key = list()
for i in range(N):
  A_key.append(i+1)
ans_dict = dict(zip(A,A_key))
ans_dict = dict(sorted(ans_dict.items()))
ans_list = list(ans_dict.values())
for i in ans_list:
  print(i)

Measured memory_bytes: 36468
using System;
using System.Linq;
using System.Text.RegularExpressions;
public class Hello{
    public static void Main(){
      var str_len = Console.ReadLine();
      var str = Console.ReadLine();
      
         var mc = Regex.Matches(str,"ABC");
                  
         Console.WriteLine(mc.Count);
    }
}

Measured memory_bytes: 16032
#include<iostream>
#include<string>
#include<utility>
#include<queue>
using namespace std;
int main(){
  int n,q,time,cnt_time = 0;
  string name;
  queue<pair<string,int> > que;
  cin >> n >> q;
  for(int i=0;i<n;i++){
    cin >> name >> time;
    que.push(make_pair(name,time));
  }
  while(!que.empty()){
    pair<string,int> top = que.front();
    que.pop();
    if(top.second <= q){
      cnt_time += top.second;
      cout << top.first << " " << cnt_time << endl;
    }else{
      cnt_time += q;
      que.push(make_pair(top.first,top.second-q));
    }
  }
}


Measured memory_bytes: 6244
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>



using namespace std;




int main() {
	
	string s;
	int a=0;cin>>s;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1])a++;
	}

	cout<<a<<endl;
	return 0;
}

	

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

using namespace std;

int main() {

    int N;
    cin >> N;

vector<int> A(N);

for(int i = 0; i < N; i++){
cin >> A.at(i);
}

double d;
for(int i = 0; i < N; i++){
   
double g =  A.at(i);
double t = 1 / g;
d += t;
}
double c = 1 / d;
cout << c << endl;

}

Measured memory_bytes: 384
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc168
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc168A();
            Console.Out.Flush();
        }

        public static void solve_abc168B()
        {
        }

        public static void solve_abc168A()
        {
            string hon = "24579";
            string pon = "0168";
            string n = Console.ReadLine();
            if (hon.Contains(n.Substring(n.Length - 1, 1)))
            {
                Console.WriteLine("hon");
            }
            else if (pon.Contains(n.Substring(n.Length - 1, 1)))
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("bon");
            }
        }
        
        public static int binSearchLeft(int[] a, int x)
        {
            int l = 0;
            int r = a.Length - 1;
            while (r - l > 1)
            {
                int m = (r + l) / 2;
                if (a[m] < x)
                {
                    l = m + 1;
                }
                else
                {
                    r = m;
                }
            }
            return l;
        }        
    }
}

Measured memory_bytes: 26820
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
ll x, k, d;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> k >> d;

  x = abs(x);
  ll t = x / d;
  ll ans;
  if(t + 1 > k) {
    ans =  x - (d * k);
  } else {
    ll p = t + ((k - t) % 2);
    ans =  abs(x - (d * p));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

int main(void){
	int len,i;
	char str[21];
	char *a;
	a=str;

	scanf("%s",str);

	len=(int)strlen(str);

	for(i=len-1;i>=0;i--)
		printf("%c",*(a+i));
	printf("\n");

	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int,int>
#define pb push_back
typedef long long ll;
const int N = 3107;
using namespace std;
vector<int> adj[N];
bool dp[N]; int e[N];

void dfs(int v , int p = 0){
    for(auto u : adj[v]){
        if(u == p)continue;
        dfs(u , v);
        if(e[u] < e[v] && !dp[u])dp[v] = true;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; cin >> n;
    for(int i=1;i<=n;i++)cin >> e[i];
    for(int i=0;i<n-1;i++){
        int u , v; cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1;i<=n;i++){
        memset(dp , 0 , sizeof dp);
        dfs(i);
        if(dp[i])cout << i << ' ';
    }cout << '\n';
}


Measured memory_bytes: 768
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

def printd(str)
  print str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if true
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

# body
if $debugFlag
end

str = inputs[0][0]
ans = ""
if str == "SUN"
  ans = 7
elsif str == "MON"
  ans = 6
elsif str == "TUE"
    ans = 5
elsif str == "WED"
    ans = 4
elsif str == "THU"
    ans = 3
elsif str == "FRI"
    ans = 2
elsif str == "SAT"
  ans = 1
end

puts ans


Measured memory_bytes: 1788
/**************************************************************
 Problem: 3224
 User: suda1230705082
 Language: C++
 Result: Runtime_Error
 ****************************************************************/

#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<map>
#include<deque>
#include<vector>
#include<set>
//#include<bits/stdc++.h>
//#include<tr1/unordered_map>
using namespace std;
long long MODA = 100000909770901ll;
long long MODB = 100000002135407ll;
const int MAXN = 200050;

inline void print(char pt) {
	printf("%c\n", pt);
}
inline void print(int pt) {
	printf("%d\n", pt);
}
inline void print(long long pt) {
	printf("%I64d\n", pt);
}
inline void print(double pt) {
	printf("%.20f\n", pt);
}
inline void print(char pt[]) {
	printf("%s\n", pt);
}
inline void print() {
	printf("\n");
}

inline void scan(int &pt) {
	scanf("%d", &pt);
}
inline void scan(char &pt) {
	scanf("%c", &pt);
}
inline void scan(long long &pt) {
	scanf("%I64d", &pt);
}
inline void scan(double &pt) {
	scanf("%lf", &pt);
}
inline void scan(char pt[]) {
	scanf("%s", pt);
}

struct str {
	char val[108];
	str() {
		memset(val, 0, sizeof(val));
	}
	friend int operator<(str a, str b) {
		return strcmp(a.val, b.val) < 0;
	}
};

//int gcd(int x, int y) {
//    return y ? gcd(y, x % y) : x;
//}
//int lcm(int x, int y) {
//    return x * (y / gcd(x, y));
//}
long long gcd(long long x, long long y) {
	return y ? gcd(y, x % y) : x;
}
long long lcm(long long x, long long y) {
	return x * (y / gcd(x, y));
}

int bits[50];
void getbits() {
	for (int i = 0; i < 30; i++) {
		bits[i] = 1 << i;
	}
}

long long Q_pow(long long x, long long y) {
	long long res = 1;
	while (y) {
		if (y % 2 == 1) {
			res *= x;
			res %= MODA;
		}
		x = x * x;
		x %= MODA;
//        if(x<=1e-5){
//            return 0;
//        }
		y /= 2;
	}
	return res;
}

struct pii {
	int x;
	int y;
	int i;
	friend int operator<(pii a, pii b) {
		if (a.x != b.x)
			return a.x < b.x;
		return a.y < b.y;
	}
};

int T;
int n, m;
int a[1010];

int main() {

	scan(n);
	for (int i = 0; i < n; i++) {
		scan(a[i]);
	}

	int suma = 0;
	for (int i = 0; i < n; i++) {
		suma += a[i];
	}
	double se = ((double) suma) / n;
	int se2 = int(se);

	double haha = fabs(se - se2);
	if (haha > 0.5) {
		if (se2 > 0)
			se2++;
		else
			se2--;
	}

	int ansa = 0;

	for (int i = 0; i < n; i++) {
		ansa += (a[i] - se2) * (a[i] - se2);
	}
	print(ansa);
	return 0;
}


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

int main(){
  int N,count;
  string str;
  cin>>N;
  cin>>str;
  count=1;
  for(int i=0;i<N-1;i++){
    if(str.at(i)!=str.at(i+1)){
      count++;
    }
  }
  cout<<count<<endl;
    return 0;
}

  

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

int a[2][200001];

int main(void) {
  int n,k;
  cin >> n >> k;
  for(int i = 0;i < n;++i){
    cin >> a[0][i];
  }
  int now = 0;
  for (int i = 0;i < k;++i) {
    now = !now;
    fill(a[now], a[now] + 200001, 0);
    for (int j = 0;j < n;++j) {
      int l = max(j - a[!now][j], 0);
      int r = min(j + a[!now][j], n-1);
      a[now][l] += 1;
      a[now][r+1] -= 1;
    }

    for(int j = 1;j < n;++j) {
      a[now][j] += a[now][j-1];
    }

    bool is_end = true;
    for(int j = 0; j < n;++j) {
      if(a[now][j] != n) {
        is_end = false;
        break;
      }
    }
    if(is_end) {
      break;
    }
  }
  for(int j = 0;j < n;++j) {
    if(j != 0) {
      cout << " ";
    }
    cout << a[now][j];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 5152
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define min3(a,b,c)     min(a,min(b,c))


int main(){ FastIO;

int i,n,p=0,q=0,m;cin>>n>>m;
int a[n+1]={0},w[n+1]={0};
for(i=0;i<m;i++)
{
	int k;string s;cin>>k>>s;
	if(s=="WA" && a[k]==0) w[k]++;
	else if(s=="AC" && a[k]==0){
		p++;a[k]=1;q+=w[k];
	}
}
cout<<p<<" "<<q;



return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a[100],b[100],c[100];
int main() {

	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++)cin>>b[i];
	for(int i=0;i<n-1;i++)cin>>c[i];
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=b[i];
		if(i&&a[i-1]+1==a[i])ans+=c[a[i-1]-1];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int wei[40],a[N];
void add(int x,int f){
	for(int i=1;x;i++,x>>=1) wei[i]+=f*(x&1);
}
bool  judge(int x){
	for(int i=1;x;i++,x>>=1)
		if(wei[i]&(x&1)) return 0;
	return 1;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int l=1;
	long long ans=0;
	for(int i=1;i<=n;i++){
		while(!judge(a[i])) {add(a[l],-1);l++;}
		add(a[i],1);
		ans+=i-l+1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int,int> PP;

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

struct node {
	int x;
	int t;
};

bool operator < (node a, node b) {
	return a.t < b.t;
}

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<node> R;
    for (int i = 1;i <= N;i++) {
    	int m;
    	cin >> m;
    	node p;
    	p.x = i;
    	p.t = m - 1;
    	R.push_back(p);
    }
    sort(R.begin(), R.end());
    vector<int> T(N * N, 0);
    vector<int> G(N * N, 0);
    int pos = 0;
    queue<int> M;
    for (int i = 0;i < R.size();i++) {
    	int x = R[i].x;
    	int y = R[i].t;
    	int rem = x - 1;
    	T[y] = x;
    	G[y] = x;
    	while (rem > 0 && pos < y) {
    		if (T[pos] == 0) {
    			T[pos] = x;
    			rem--;
    		}
    		pos++;
    	}
    	if (rem > 0) {
    		cout << "No" << endl;
    		return 0;
    	}
    }
    for (int i = 0;i < N * N;i++) {
    	if (T[i] == 0) {
    		if (M.size() == 0) {
    			cout << "No" << endl;
    			return 0;
    		}
    		else {
    			T[i] = M.front();
    			M.pop();
    		}
    	}
    	if (G[i] != 0) {
    		for (int j = 0;j < N - G[i];j++) {
    			M.push(G[i]);
    		}
    	}
    }
    cout << "Yes" << endl;
    for (int i = 0;i < N * N;i++) {
    	if (i != 0) cout << ' ';
    	cout << T[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;
import java.util.Set;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt();
            Set<Integer> first = new HashSet<>();
            Set<Integer> second = new HashSet<>();
            for (int i = 0; i < m; ++i) {
                int a = in.nextInt();
                int b = in.nextInt();
                if (a == 1 && b != n) first.add(b);
                if (b == n && a != 1) second.add(a);
            }
            for (int x : second) {
                if (first.contains(x)) {
                    out.println("POSSIBLE");
                    return;
                }
            }
            out.println("IMPOSSIBLE");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 58944
#include <stdio.h>

int main(){
	int a, b, c, d;
	int K;
	scanf("%d %d %d %d %d", &a, &b, &c, &d, &K);
	int diff1 = c - a;
	int diff2 = d - b;
	int min = (diff1 * 60) + diff2;
	printf("%d", min - K);
	
	
	
	return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

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

	vector<ll> A(N), B(N), C(N);

	rep(i, N) {
		cin >> A[i];
		A[i]--;
	}
	rep(i, N) cin >> B[i];
	rep(i, N-1) cin >> C[i];

	ll ans = 0;
	rep(i, N) {
		ans += B[A[i]];
		if(i != N - 1 && A[i] + 1 == A[i+1]) {
			ans += C[A[i]];
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 3512
W_MAX = 10000
K_MAX = 100000


def main():
    n, k = map(int, input().split(' '))
    ws = [int(input()) for _ in range(n)]
    start = 1
    end = n*K_MAX
    target = int((start + end) / 2)
    while end > start:
        if number(target, ws) <= k:
                end = target
        elif number(target, ws) > k:
            start = target + 1
        target = int((start + end) / 2)
    print(target)


def number(p, ws):
    _p = p
    num_track = 1
    for w in ws:
        if w > p:
            return K_MAX+1
        if w > _p:
            _p = p
            num_track += 1
        if w <= _p:
            _p -= w
    return num_track


if __name__ == '__main__':
    main()



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

void test()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    int ans = INT_MIN;
    for (int i = 0; i < n; i++)
    {
        for (int j = i; j < n; j++)
        {
            ans = max(ans, abs(v[i] - v[j]));
        }
    }
    cout << ans << endl;
}
int32_t main()
{

    int t = 1;
    // cin >> t;
    while (t--)
    {
        test();
    }

    return 0;
}

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



int main()
{   
    int n;
    string s;
    cin>>n>>s;
    int ans  = 0;
    vector<vector<int>> dp(n+1,vector<int>(n+1,0));
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = i+1 ; j<=n ; j++)
        {
            if(s[i-1] == s[j-1] && (j-i) > dp[i-1][j-1])
            {
                dp[i][j] = 1  + dp[i-1][j-1];
            }
            ans = max(ans, dp[i][j]);
        }
        
    }
    cout<<ans<<endl;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N, M, Q, sum[510][510], lr[510][510];

int main(int argc, char **argv)
{
	cin >> N >> M >> Q;
	REP(i, M)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		++lr[l][r];
	}

	REP(i, N)REP(j, N)
	{
		sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + lr[i][j];
	}

	REP(_, Q)
	{
		ll l, r; cin >> l >> r;
		--l, --r;
		std::cout << sum[r+1][r+1] - sum[r+1][l] - sum[l][r+1] + sum[l][l] << std::endl;
	}
}


Measured memory_bytes: 4864
#include <cstdio>

int main(int argc, char const* argv[])
{
	int m, f, r;
	scanf("%d %d %d", &m, &f, &r);
	while(!(m == -1 && (f == -1 && r == -1))){
			if(m == -1 || f == -1)printf("F\n");
			else if(m + f >= 80)printf("A\n");
			else if(m + f >= 65)printf("B\n");
			else if(m + f >= 50)printf("C\n");
			else if(m + f >= 30 && r >= 50)printf("C\n");
			else if(m + f >= 30)printf("D\n");
			else printf("F\n");
			scanf("%d %d %d", &m, &f, &r);
	}
	return 0;
}



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

int main()
{
  char a[1010],b[1010];
  int mi=1000000000,mx=-1;
  cin>>a>>b;
  for(int i=0; a[i]; i++)
  {
    mi=min(mi,(int)a[i]);
  }
  for(int i=0; b[i]; i++)
  {
    mx=max(mx,(int)b[i]);
  }
  if(mi<mx)cout<<"Yes";
  if(mi>mx)cout<<"No";
  if(mi==mx)
  {
    int i=0;
    for(; a[i]&&b[i]&&a[i]==b[i]; i++);
    if(a[i]||b[i]=='\0')
    {
      cout<<"No";
    }
    else
    {
      cout<<"Yes";
    }
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())

    if N == 1:
        return print(1)

    X = [0 for _ in range(N)]
    Y = [0 for _ in range(N)]
    for i in range(N):
        x, y = map(int, input().split())
        X[i] = x
        Y[i] = y

    cnt = {}
    for i in range(N):
        for j in range(N):
            if i == j:
                continue
            rx = X[i] - X[j]
            ry = Y[i] - Y[j]
            if (rx, ry) not in cnt:
                cnt[(rx, ry)] = 1
            else:
                cnt[(rx, ry)] += 1
            if (-rx, -ry) not in cnt:
                cnt[(-rx, -ry)] = 1
            else:
                cnt[(-rx, -ry)] += 1

    cnt = [[v, k] for k, v in cnt.items()]
    cnt.sort(reverse=True)
    res = N - cnt[0][0] // 2
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40044
# def makelist(n, m):
# 	return [[0 for i in range(m)] for j in range(n)]

A,B,C,D,E,F = map(int, input().split())
A *= 100
B *= 100
E = round(E/(100+E), 8)

# binary search
def check(i, total, sugar):
	exp = (sugar + D*i) / (total + D*i)
	return total + D*i <= F and round(exp, 8) <= E
	

def binarySearch(small, big, total, sugar):
	mid = (big + small) // 2
	if big - small <= 1:
		if check(big, total, sugar): return big
		else:          return small
	else:
		if check(mid, total, sugar):
			return binarySearch(mid, big, total, sugar)
		else:
			return binarySearch(small, mid, total, sugar)

noudo = 0
ans = (0, 0)
for a in range(31):
	for b in range(31):
		for c in range(3001):
			water = a*A + b*B
			sugar = c * C
			total = water + sugar
			if not (a, b) == (0, 0):
				if total <= F and round(sugar / total, 8) <= E:
					d = binarySearch(0, 3000, total, sugar)
					tmp = (sugar + D*d) / (total + D*d)
					if round(tmp, 8) > noudo:
						noudo = round(tmp, 8)
						ans = (total+D*d, sugar+D*d)

if ans[0] == 0:
	print(A, 0)
else:
	print(ans[0], ans[1])


Measured memory_bytes: 59120
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    int n;
    int a[200010];
    int ball[200010] = {};
    int cnt, ans = 0;

    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> a[i+1];
    }
    
    for (int i = n; i >= 1; i--) {
        cnt = 0;
        for (int j = i; j <= n; j += i) {
            if (ball[j] == 1) cnt++;
        }
        if (cnt%2 != a[i]) {
            ball[i] = 1;
            ans++;
        }
    }

    cout << ans << endl;

    for (int i = 1; i <= n; i++) {
        if (ball[i] == 1) {
            cout << i << " ";
         }
    }
    if (ans != 0) {
        cout << endl;
    }
}


Measured memory_bytes: 2560
let () =
  let soc = fun n -> Char.escaped (char_of_int (97+n)) in (* 0 -> a 25 -> z *)
  let rec check n m l = if n <= m then (n, l) else check (n-m) (m*26) (l+1) in
  let rec make n k =
    if k = 0 && n = 0 then soc n
    else if k = 0 then soc n
    else
      let y = int_of_float (26. ** (float_of_int k)) in
      let x, m = n / y, n mod y in soc x ^ make m (k-1) in
  Scanf.scanf "%d\n" @@ fun n ->
  let (n,k) = (check n 26 1) in
  Printf.printf "%s\n" (make (n-1) (k-1))

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

uint64_t mygcd(uint64_t x, uint64_t y){
  
  uint64_t u = max(x,y), v = min(x,y), t;
  
  while(max(u,v) % min(u,v) != 0){
    t = v;
    v = u % v; 
    u = t;
  }
  return v;
}

uint64_t mylcm(uint64_t x, uint64_t y){

  uint64_t ans = (max(x,y) / mygcd(x,y)) * min(x,y);
  return ans;

}

int main(){
  ll n;
  cin >> n;
  
  uint64_t a,b;
  cin >> a;
  
  for(int i=1; i<n; i++){
    cin >> b;
    a = mylcm(a,b);
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            var line = Input.ReadIntArray();
            int A = line[0];
            int B = line[1];
            int K = line[2];

            List<int> lst = new List<int>();
            for (int i = 1; i <= 100; i++)
            {
                if (A % i == 0 && B % i == 0)
                {
                 lst.Add(i);
                }
            }

            lst.Reverse();
            Console.WriteLine(lst[K-1]);
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13396