akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int INF = 1e9;
const int MAX_V = 16;

void dijkstra(const vector< vector<P> > &cost, int V, int s, int *closed){
  priority_queue<P, vector<P>, greater<P> > open;
  open.push(P(0, s));
  REP(i, V) closed[i] = INF;
  closed[s] = 0;
  while(!open.empty()){
    P tmp = open.top(); open.pop();
    int now = tmp.second, c = tmp.first;
    if(closed[now] < c) continue;
    closed[now] = c;
    REP(i, cost[now].size()){
      int next = cost[now][i].second, nc = cost[now][i].first;
      if(nc == INF || c + nc >= closed[next]) continue;
      closed[next] = c + nc;
      open.push(P(closed[next], next));
    }
  }
}

int chinesePostman(const int &V, const vector< vector<P> > &G) {
  int total = 0;
  vector<int> odds;
  REP(i, V) {
    REP(j, G[i].size())
      total += G[i][j].first;
    if ((int)(G[i].size()) % 2) odds.push_back(i);
  }
  total /= 2;
  int n = odds.size(), N = (1 << n);
  int w[n][n]; // make odd vertices graph
  REP(i, n) {
    int closed[V];
    dijkstra(G, V, odds[i], closed);
    REP(j, n) w[i][j] = closed[odds[j]];
  }
  int dp[N]; // DP for general matching 
  REP(S, N) dp[S] = INF;
  dp[0] = 0;
  for (int S = 0; S < N; ++S)
    REP(i, n)
      if (!(S & (1 << i)))
        FOR(j, i + 1, n)
          if (!(S & (1 << j)))
            dp[(S | (1 << i) | (1 << j))] = min(dp[(S | (1 << i) | (1 << j))], dp[S] + w[i][j]);
  return total + dp[N - 1];
}

int main() {
  int V, E; cin >>V >>E;
  vector< vector<P> > G(V);
  REP(i, E){
    int f, t, c; cin >>f >>t >>c;
    G[f].push_back(P(c, t));
    G[t].push_back(P(c, f));
  }
  cout <<chinesePostman(V, G) <<endl;
  return 0;
}

Measured memory_bytes: 1288
EPS = 1E-8
def solve(a, b, c, d, e, f):
    threshold = e / (100 + e) + EPS
    best = -1
    for x in range(0, f+1, 100*a):
        for y in range(x, f+1, 100*b):
            if y == 0:
                continue
            for z in range(y, f+1, c):
                for w in range(z, f+1, d):
                    p = w - y
                    cur = p / w
                    if best < cur <= threshold:
                        best = cur
                        solution = (w, p)
    return "%d %d" % solution

a, b, c, d, e, f = map(int, input().split())
print(solve(a, b, c, d, e, f))


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

int main(){
  ll a,b,k;
  cin >>a >>b >>k;
  rep(i,k){
    if(i%2==0){
      if(a%2!=0) a--;
      a/=2;
      b+=a;
    }
    else {
      if(b%2!=0) b--;
      b/=2;
      a+=b;
    }
  }
  cout << a<< " " << b << endl;
  return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  cin >> b >> a;
  if (b % 500 <= a)
    Yes();
  else
    No();
  return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct UnionFind {
	vector<int> d;
	UnionFind(int n) :d(n, -1) {}
	int find(int x) {
		if (d[x] < 0)return x;
		return d[x] = find(d[x]);

	}
	bool unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return false;
		if (d[x] > d[y])swap(x, y);
		d[x] += d[y];
		d[y] = x;
		return true;
	}
	bool same(int x, int y) { return find(x) == find(y); }
	int size(int x) { return -d[find(x)]; }


	
};

int deg[100005];
vector<int> to[100005];

int main() {

	int n, m, k;
	cin >> n >> m >> k;
	UnionFind uf(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		deg[a]++;
		deg[b]++;
		uf.unite(a, b);
	}
	rep(i, k) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	rep(i, n) {
		int ans = uf.size(i) - 1 - deg[i];
		for (int u : to[i]) {
			if (uf.same(i,u))--ans;
		}
		printf("%d%c", ans, i == n - 1 ? '\n' : ' ');
	}
	return 0;
}


Measured memory_bytes: 6784
R = []

n = int(input())
for i in range(n):
    R.append(int(input()))

maxv = 10**9 * (-1)
minv = R[0]


for j in range(1, n):
    maxv = max(maxv, R[j]-minv)
    minv = min(minv, R[j])

print(maxv)



Measured memory_bytes: 13592
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
signed main() {
	int n; cin >> n;
	if (n % 2 == 1)cout << "0\n";
	else {
		int ans = 0, p = 5;
		while (p <= n) {
			ans += n / p / 2; p *= 5;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
    int n, a, wrong = 0;
    
    scanf("%d", &n);
    
    int i = 0;
    
    while(i < n) {
        scanf("%d", &a);
        
        if (a % 2 == 0) {
            if (a % 3 != 0 && a % 5 != 0) {
                wrong = 1;
                break;
            }
        }
        
        ++i;
    }
    
    if (wrong) {
        printf("DENIED\n");
    } else {
        printf("APPROVED\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
#define test ll t; cin>>t;
 
int main(){
    IOS
    int k = 3 , n = 0 , input;
    int a[k][k];
    bool bingo[k][k]; 
    for(int i = 0 ; i<k ; i++){
        for(int j = 0 ; j<k; j++){
            cin>>a[i][j];
            
        }
    }
    cin>>n;
    int b[n];
    for(int i = 0 ; i<n; i++){
        cin>>b[i];
    }
    for(int i =0 ; i<k; i++){
        for(int j = 0 ; j<k; j++){
            bingo[i][j] = false;
            for(int m = 0 ; m<n; m++){
                if(b[m] == a[i][j])bingo[i][j] = true;
            }
        }
        
    }
    
    string ans = "No";
    f(0,3){
        if(bingo[i][0] && bingo[i][1] && bingo[i][2]) ans = "Yes";
    }
    f(0,3){if(bingo[0][i] && bingo[1][i] && bingo[2][i]) ans = "Yes";}
    if(bingo[0][0] && bingo[1][1] && bingo[2][2]) ans = "Yes";
    if(bingo[2][0] && bingo[1][1] && bingo[0][2]) ans = "Yes";
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
from sys import stdin
field = []
bque = []
for i in range(H):
    st = stdin.readline()[:-1]
    ls = []
    for j,ss in enumerate(st):
        ls.append(ss)
        if ss=='#':
            bque.append([i,j])

    field.append(ls)

from collections import deque

que = deque([])
que.append(bque)
count = 0
while len(que)>0:
    ll = que.popleft()
    nls = []
    for item in ll:
        x = item[0]
        y = item[1]
        for dx in [-1,1]:
            for dy in [-1,1]:
                if 0<=x+dx<=H-1:
                    if field[x+dx][y]=='.':
                        field[x+dx][y]='#'
                        nls.append([x+dx,y])
                if 0<=y+dy<=W-1:
                    if field[x][y+dy]=='.':
                        field[x][y+dy]='#'
                        nls.append([x,y+dy])
    if len(nls) != 0:
        que.append(nls)
        count += 1
print(count)
"""微妙に遅かった60msぐらい　"""


Measured memory_bytes: 171656
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

typedef long long LL;
int n,m,x,y;
LL sum[100100],ans;

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

int main()
{
    scanf("%d%d%d",&n,&m,&y),ans=1LL<<60;
    while (--n)
    {
        x=y,y=getint();
        if (x<=y)
        {
            ++sum[y],--sum[x];
            sum[m]+=y-x,sum[m-1]-=y-x,sum[y]-=y-x,sum[y-1]+=y-x;
        }
        else
        {
            ++sum[y],++sum[m],--sum[x];
            sum[m]+=y,sum[m-1]-=y;
            sum[y]-=y+m-x,sum[y-1]+=y+m-x;
        }
    }
    repd(i,m,1)
        sum[i]+=sum[i+1];
    repd(i,m,1)
        ans=min(ans,sum[i]+=sum[i+1]);
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 896
n=int(input())
 
result=[]
for i in range(1,n+1):
    if i %3==0:
        result.append(i)
    else:
        k=i
        for j in range(1,5):
            if k%10==3:
                result.append(i)
                break
            else:
                k=k//10
        else:
            continue
 
print("",*result)

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

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

long long tt(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
 
int main() {
int a,b;
  cin >> a >> b;
  if((a+b)%3 != 0){cout << 0 << endl;}
  else{int p = (a+b)/3;
       a -= p;
       b -= p;
       if(a < 0 || b < 0){
         cout << 0 << endl;}
       else{
         long long f=1;
         for(int i = a+1;i < a+b+1;i++){
           f = f*i%1000000007;}
         for(int i = 1;i < b+1;i++){
           f = f*tt(i,1000000007)%1000000007;
       }
  cout << f << endl;
       }
      }
       
      
}

Measured memory_bytes: 256
import math
import numpy as np

N = int(input())
list_p = list(map(int, input().split(" ")))
list_q = list(map(int, input().split(" ")))
a = 0
b = 0
for i in range(N) :
  a += math.factorial(N-i-1) * list(np.argsort(list_p)).index(0)
  b += math.factorial(N-i-1) * list(np.argsort(list_q)).index(0)
  list_p = list_p[1:]
  list_q = list_q[1:]
  
  
print(abs(a-b))

Measured memory_bytes: 21096
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
//#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

#define BIG_NUM 9999999999999

struct Info{
	Info(){
		row = col = move_cost = sum_cost = 0;
	}

	Info(int arg_row,int arg_col,ll arg_move_cost,ll arg_sum_cost){
		row = arg_row;
		col = arg_col;
		move_cost = arg_move_cost;
		sum_cost = arg_sum_cost;
	}
	bool operator<(const struct Info &arg) const{ //総コストの昇順(PQ)
		return sum_cost > arg.sum_cost;
	}
	int row,col;
	ll move_cost,sum_cost;
};

int H,W;
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
ll min_cost[30][30][901],base_map[30][30];



bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1){
		return true;
	}else{
		return false;
	}
}


int main(){

	scanf("%d %d",&H,&W);

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++)scanf("%lld",&base_map[row][col]);
	}

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			for(int i = 0; i <= H*W; i++)min_cost[row][col][i] = BIG_NUM;
		}
	}

	priority_queue<Info> Q;
	min_cost[0][0][0] = 0;
	Q.push(Info(0,0,0,0));

	int adj_row,adj_col,next_move_cost,next_sum_cost;
	ll ans = BIG_NUM;

	Info info;

	while(!Q.empty()){

		//printf("row:%d col:%d sum_cost:%d\n",Q.top().row,Q.top().col,Q.top().sum_cost);

		if(Q.top().row == H-1 && Q.top().col == W-1){
			//printf("%lld\n",Q.top().sum_cost);
			ans = min(ans,Q.top().sum_cost);
			Q.pop();
			//return 0;
		}else if(Q.top().sum_cost > min_cost[Q.top().row][Q.top().col][Q.top().move_cost]){
			Q.pop();
		}else if(Q.top().move_cost == H*W+1){
			Q.pop();
		}else{

			info = Q.top();
			Q.pop();

			for(int i = 0; i < 4; i++){
				adj_row = info.row+diff_row[i];
				adj_col = info.col+diff_col[i];

				if(!rangeCheck(adj_row,adj_col))continue;

				next_move_cost = info.move_cost+1; //(0,0)から出発してそのマスに辿り着くまでにかかるコスト==そのマスから(0,0)に戻る際の移動コスト

				next_sum_cost = info.sum_cost+(base_map[adj_row][adj_col]*(2*info.move_cost+1))+1;

				if(adj_row == H-1 && adj_col == W-1){
					next_sum_cost -= info.move_cost+1;
				}

				if(min_cost[adj_row][adj_col][next_move_cost] > next_sum_cost){ //移動コスト別に、総コストの最小値を持つ
					min_cost[adj_row][adj_col][next_move_cost] = next_sum_cost;
					Q.push(Info(adj_row,adj_col,next_move_cost,next_sum_cost));
				}
			}

		}
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 15280
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 083 C "Multiple Gift"
 *   https://abc083.contest.atcoder.jp/tasks/arc088_a/
 */
public class Main {

	public static void main(String[] args) {

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

		long X = in.nextLong();
		long Y = in.nextLong();

		int ans = 0;
		for (long i = X; i <= Y; ) {
			ans++;
			i *= 2;
		}
		
		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 21972
def comb(a, b)
  res = 1
  for i in 1..b do
    res = res * (a-i+1) / i
  end
  res
end

nab = gets.chomp.split.map { |s| s.to_i }
v = gets.chomp.split.map { |s| s.to_i }.sort{|a, b| b <=> a }
s = v[0...nab[1]]
sum = s.reduce(:+)
avg = sum.to_f / s.length
puts avg

as = s.count(s.last)
mx = v.count(s.last)
if s.uniq.length == 1
  u = nab[2]
else
  u = nab[1]
end
ad = [u-s.length+as, mx].min
res = 0
for i in as..ad do
  res += comb(mx, i)
end

puts res

Measured memory_bytes: 1788
H,W=gets.split.map &:to_i
S=$<.map &:chop

Vis=(0...H).map{[false]*W}

def find(si,sj)
  cnt={?#=>0,?.=>0}
  que=[[si,sj]]
  Vis[si][sj]=true
  until que.empty?
    ti,tj=que.shift
    cnt[S[ti][tj]]+=1
    [[0,1],[0,-1],[1,0],[-1,0]].map{|di,dj|
      if 0<=ti+di&&ti+di<H&&0<=tj+dj&&tj+dj<W
        if S[ti+di][tj+dj]!=S[ti][tj]
          if not Vis[ti+di][tj+dj]
            Vis[ti+di][tj+dj]=true
            que.push([ti+di,tj+dj])
          end
        end
      end
    }
  end
  return cnt[?#]*cnt[?.]
end

res=0
H.times{|i|
  W.times{|j|
    if S[i][j]==?#
      res+=find(i,j)
    end
  }
}
p res


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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif*/
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;

    long long a,b,c,d;cin>>a>>b>>c>>d;
    long long di=b-a+1;
    long long cd=b/c-((a-1)/c),dd=b/d-((a-1)/d),bd=b/(c*d/__gcd(c,d))-((a-1)/(c*d/__gcd(c,d)));
    cout<<di-(cd+dd)+bd<<endl;
    
    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f
int main()
{
	int num[3];
	while(~scanf("%d%d%d", &num[0], &num[1], &num[2]))
	{
		int maxn;
		sort(num, num+3);
		maxn = num[2]*10+num[1]+num[0];
		printf("%d\n", maxn);
	}
	return 0;
}

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

using namespace std;

const long long MAXN = 3e5+5;
long long seg[4*MAXN];
long long arr[MAXN];
long long cnt = 0;
long long ans[MAXN];
void build(long long curr,long long l,long long r){
    if(l==r){
        seg[curr] = arr[l];
        return;
    }
    long long mid = (l+r)/2;
    build(2*curr,l,mid);
    build(2*curr+1,mid+1,r);
    seg[curr] = max(seg[2*curr],seg[2*curr+1]);
}
long long query(long long curr,long long l,long long r){
    if(l==r){
        return l;
    }
    long long mid = (l+r)/2;
    if(seg[2*curr+1] == seg[curr]){
        return query(2*curr+1,mid+1,r);
    }else{
        return query(2*curr,l,mid);
    }
}
void update(long long curr,long long l,long long r,long long ind){
    if(l==r){
        seg[curr] = 0;
        return;
    }
    long long mid = (l+r)/2;
    if(ind<=mid){
        update(2*curr,l,mid,ind);
    }else{
        update(2*curr+1,mid+1,r,ind);
    }
    seg[curr] = max(seg[2*curr],seg[2*curr+1]);
}
int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=n;i++){
        cin>>arr[i];
    }
    build(1,1,n);
    long long ind2 = n;
    while(true){
        long long mx = seg[1];
      
        long long ind = query(1,1,n);
        ind2 = min(ind2,ind);
        update(1,1,n,ind);
        if(mx == 0){
            break;
        }
        cnt++;
        //cout<<seg[1]<<endl;
        while(seg[1] == mx){
            ind = query(1,1,n);
            ind2 = min(ind2,ind);
            update(1,1,n,ind);
            cnt++;
        }
        long long next = seg[1];
       // cout<<ind2<<endl;
        ans[ind2] += 1LL*cnt*(mx-next);
    }
    for(long long i=1;i<=n;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

ll int power(ll int x, ll int y, ll int p)  
{  
   ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
int n,m;
bool isval(int x,int y)
{
  if(x<0||x>n-1||y<0||y>m-1)
    return false;
  return true;
}

int main()
{
  fastio();
ll int T;
T=1;


while(T--)
{
ll int a,b,c,k;
cin>>a>>b>>c>>k;
ll int ans=0;
ans+=min(a,k);
k-=min(a,k);
if(k!=0)
{
  k-=min(b,k);
}
if(k!=0)
{
  ans-=k;
}
cout<<ans<<endl;
}
    return 0;
}

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

int main() {
  long N; cin >> N;
  long A[N]; for (long i = 0; i < N; i++) cin >> A[i];
  long numSign = 1, sum = 0, leftActNum = 0;
  for (long i = 0; i < N; i++) {
    sum += A[i];
    if (numSign == 1) {
      if (sum <= 0) {
        leftActNum += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        leftActNum += sum - -1;
        sum = -1;
      }
    }
    numSign *= -1;
  }
  numSign = -1; sum = 0; long rightActNum = 0;
  for (long i = 0; i < N; i++) {
    sum += A[i];
    if (numSign == 1) {
      if (sum <= 0) {
        rightActNum += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        rightActNum += sum - -1;
        sum = -1;
      }
    }
    numSign *= -1;
  }
  cout << min(leftActNum, rightActNum) << endl;
}

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

using namespace std;
int main(){
	long long a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k>=a)sum+=a;
	else sum+=k;
	k-=(a+b);
	if(k<=0)cout<<sum;
	else cout<<sum-k;
	return 0;
}

Measured memory_bytes: 3636
import scala.io.StdIn.readInt

object Main {
  def pow(x:Long, y:Long):Long = {
    def pow2(m:Long, n:Long, odd:Long, b:Long):Long = {
      n match {
        case 0 => 1
        case 1 => m*odd
        case _ =>
          pow2(m*m, n/2, (if(n%2==1) odd*b else odd), b*b)
      }
    }
    pow2(x, y, 1, x)
  }

  def getZeros(n:Long,ct:Long,i:Long):Long = {
    val d = n/pow(5,i)
    if(d>0) getZeros(n,d+ct,i+1) else ct
  }

  def main(args:Array[String]) = {
    var n = 0;
    while( {n=readInt;n}!= 0 )
      println(getZeros(n,0,1))
  }
}

Measured memory_bytes: 43608
#include<iostream>
using namespace std;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int x,y;
	cin>>x>>y;
	int ans=0;
	if(x==1){
		ans+=300000;
	}
	else if(x==2){
		ans+=200000;
	}
	else if(x==3){
		ans+=100000;
	}
	
	if(y==1){
		ans+=300000;
	}
	else if(y==2){
		ans+=200000;
	}
	else if(y==3){
		ans+=100000;
	}
	
	if(x==1 && y==1){
		ans+=400000;
	}
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = []
for i in range(n):
    x = int(input())
    A.append(x-1)
k = 0
for i in range(n-1):
    k = A[k]
    if(k == 1):
        print(i+1)

        break
    if(i == n-2):
        print(-1)

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

int main(){
	long long a,b,x;
	cin>>a>>b>>x;
	long long k1 = a/x*x + (a%x?x:0);
	long long k2 = b/x*x;
	cout<<(k2-k1)/x+1;
}

Measured memory_bytes: 3580
#include <iostream>
#define MAX 10005
using namespace std;

int main() {
    int n; cin >> n;
    int a[MAX];
    for(int i=1;i<=n;i++) cin >> a[i];
    int t; cin >> t;
    int ans = 0;
    while(t--) {
        int x; cin >>x;
        a[0] = x;
        int i = n;
        while(a[i]!=x) i--;
        if(i!=0) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int mod = 1000000007;
typedef long long ll;


int main(){
    int X;
    cin >> X;
    int ans = 0;
    int fh = X / 500;
    ans += (fh) * 1000;
    ans += ((X - (fh * 500)) / 5) * 5;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = str(input())
white_count = 0
black_count = 0
count = 0
white = []
black = []
for i in range(N):
    if S[i] == ".":
        white_count += 1
    else:
        black_count += 1
    white.append(white_count)
    black.append(black_count)

ans = []
for i in range(N):
    ans.append(white_count-white[i]+black[i])
ans_min = min(ans)

print(min(white_count,black_count,ans_min))

Measured memory_bytes: 20928
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int main(){
	int a,b,c,s1,s2;
	cin>>a>>b>>c;
	s1=a;
	a=b;
	b=s1;
	s2=a;
	a=c;
	c=s2;
	cout<<a<<" "<<b<<" "<<c;
	return 0; 
}

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

using namespace std;

int main() {
	string s, t;

	cin >> s >> t;
	int T = t.size(), S = s.size();

	vector<string> ans;
	for (int i = 0; i + T - 1 < S; i++) {
		int j;
		for (j = 0; j < T; j++) {
			if (s[i + j] == t[j] || s[i+ j] == '?') continue;
			else break;
		}
		if (j == T) {
			string m = "";
			for (int k = 0; k < S; k++) {
				if (k < i || k >= i + T) {
					if (s[k] == '?') m += 'a';
					else m += s[k];
				}
				else {
					m += t[k - i];
				}
			}
			ans.push_back(m);
		}
	}

	if (ans.size() == 0) {
		ans.push_back("UNRESTORABLE");
	}

	sort(ans.begin(), ans.end());

	cout << ans[0] << endl;

	return 0;
}

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

int main()
{
    long long n, k;
    vector<long long> h;
    cin >> n >> k;
    h.resize(n);
    for(auto& e : h) cin >> e;
    if(h.size()) ::sort(h.begin(), h.end());
    long int sum = 0;
    for(long long i = 0; i < (int)h.size() - k; i++) sum += h[i];
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1792
import sys


def main():
    n, a, b = map(int, sys.stdin.readline().split())
    s = sys.stdin.readline().rstrip()

    ans = ["No"] * n
    success = 0
    foreigner = 0

    for i in range(n):
        if s[i] == "a":
            ans[i] = "Yes"
            success += 1
        elif s[i] == "b" and foreigner < b:
            ans[i] = "Yes"
            success += 1
            foreigner += 1
        if success == a + b:
            break

    print("\n".join(ans))
    return


if __name__ == "__main__":
    main()

Measured memory_bytes: 5108
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

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

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

int main(){
    int n;
    cin>>n;
    double p[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    double dp[n+1]={};
    dp[0]=1-p[0];
    dp[1]=p[0];
    
    for(int i=1;i<n;i++){
        for(int j=i+1;j>=1;j--){
            dp[j]=dp[j-1]*p[i]+dp[j]*(1-p[i]);
        }
        dp[0]*=1-p[i];
    }
    double ans=0;
    for(int i=n/2+1;i<=n;i++){
        ans+=dp[i];
        cerr<<i<<" "<<dp[i]<<endl;
    }
    printf("%.10f",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n, m;
  cin >> n >> m;
  vi a(n);
  vi b(n);
  vi c(m);
  vi d(m);
  rep(i, n){
    cin >> a[i] >> b[i];
  }
  rep(i,m){
    cin >> c[i] >> d[i];
  }
  rep(i, n){
    ll mini = MOD;
    ll ans = 0;
    rep(j, m){
      ll x = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(x<mini){
        ans = j + 1;
        mini = x;
      }
    }
    print(ans);
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
void dfs(int i, int g, int cost, vector<int> &seq, vector<P> &ret) {
  if (i == seq.size()) {
    ret.pb(P(g, cost));
    return;
  }
  dfs(i+1, g, cost, seq, ret);
  dfs(i+1, g^seq[i], cost+1, seq, ret);
}
vector<P> enumerate(vector<int> &seq) {
  vector<P> ret;
  dfs(0, 0, 0, seq, ret);
  sort(all(ret));
  return ret;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  int g = 0;
  vector<int> vs;
  rep(i, N) {
    int a;
    cin >> a;
    g ^= a;
    vs.pb(((a&-a)<<1)-1);
  }
  sort(all(vs)); uniq(vs);
  //cout<<"{"; for (int x:vs)cout<<x<<",";cout<<"} -> "<<g<<"\n";
  vector<int> left, right;
  rep(i, vs.size()) {
    if (i%2 == 0) left.pb(vs[i]);
    else right.pb(vs[i]);
  }
  vector<P> ls = enumerate(left);
  vector<P> rs = enumerate(right);
  int m = INF;
  for (P l : ls) {
    int f = g^l._1;
    auto it = lower_bound(all(rs), P(f, -1));
    if (it == rs.end() || it->_1 != f) continue;
    m = min(m, l._2 + it->_2);
  }
  if (m == INF) m = -1;
  cout << m << "\n";
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
long long n, m;
int main() {
    cin >> n >> m;
    long long ans = 0;
    long long x = 1900*m + 100*(n-m);
    long long p = pow(2, m);
    ans = x*p;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> l(k),r(k);
  for(int i=0;i<k;i++){
    cin>>l[i]>>r[i];
  }
  sort(l.begin(),l.end());
  sort(r.begin(),r.end());
  vector<int64_t> a(n+1,0);
  a[1]=1;
  a[2]=-1;
  int64_t dpsum=0;
  for(int i=1;i<n;i++){
    dpsum+=a[i];
    dpsum%=998244353;
    for(int j=0;j<k;j++){
      if(i+l[j]<=n){
        a[i+l[j]]+=dpsum;
        a[i+l[j]]%=998244353;
      }
      if(i+r[j]+1<=n){
        a[i+r[j]+1]-=dpsum;
        a[i+r[j]+1]%=998244353;
      }
    }
  }
  uint64_t sum=accumulate(a.begin(),a.end(),0LL)%998244353;
  cout<<sum<<endl;
}
  

Measured memory_bytes: 4852
#include<stdio.h>
int main(void)
{
  int n, i, ans=0, j;
  scanf("%d", &n);
  int a[n], x;
  for(i=0;i<n;i++){
    scanf("%d", &a[i]);
  }
  x=a[0];
  for(j=1;j<n;j++){
    if(a[j]>=x){
      ans+=1;
      x=a[j];
    }
  }
  printf("%d", ans+1);
  return 0;
}


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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 1e4 + 5, inf = 2e9, mod = 1e9 + 7;

// Base case:
// states:
// transitions:

string s;
int d, dp[N][2][2][102];

int solve(int idx, bool less, bool notZero, int sum)
{
    if (idx == s.size())
        return notZero && sum % d == 0? 1: 0;
    if (dp[idx][less][notZero][sum] != -1)
        return dp[idx][less][notZero][sum];
    int ans = 0;
    for (int i = 0; i <= 9; i++)
    {
        bool newNotZero = notZero;
        if (i > 0)
            newNotZero = true;
        if (less)
            ans += solve(idx + 1, less, newNotZero, (sum + i) % d);
        else
        {
            if (i < s[idx] - '0')
                ans += solve(idx + 1, true, newNotZero, (sum + i) % d);
            else if (i == s[idx] - '0')
                ans += solve(idx + 1, false, newNotZero, (sum + i) % d);
        }
        ans %= mod;
    }
    return dp[idx][less][notZero][sum] = ans;
}

int main()
{
    VIC
    memset(dp, -1, sizeof dp);
    cin >> s >> d;
    cout << solve(0, false, false, 0);
    return 0;
}


Measured memory_bytes: 17280
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <stack>
#include <numeric>
#include <ctime>
#include <algorithm>
#include <set>
#include <map>
#include <stdio.h>

using namespace std;
typedef long long int lint;

void solve(string &str)
{
	map<char, string> encode;
	map<string, string> decode;
	
	char alpha[32] = {
		' ', '\'', ',', '-', '.', '?', 'A', 'B',
		'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
		'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
		'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
	};
	string code1[32] = {
		"101", "000000", "000011", "10010001",
		"010001", "000001", "100101", "10011010",
		"0101", "0001", "110", "01001",
		"10011011", "010000", "0111", "10011000",
		"0110", "00100", "10011001", "10011110",
		"00101", "111", "10011111", "1000",
		"00110", "00111", "10011100", "10011101",
		"000010", "10010010", "10010011", "10010000",
	};

	string beta[32] = {
		"A", "B", "C", "D", "E", "F", "G", "H",
		"I", "J", "K", "L", "M", "N", "O", "P",
		"Q", "R", "S", "T", "U", "V", "W", "X",
		"Y", "Z", " ", ".", ",", "-", "\'", "?"
	};
	string code2[32] = {
		"00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111",
		"01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111",
		"10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111",
		"11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111"
	};

	string bin;

	for(int i = 0; i < 32; i++){
		encode.insert( map<char, string>::value_type(alpha[i], code1[i]) );
		decode.insert( map<string, string>::value_type(code2[i], beta[i]) );
	}

	for(int i = 0; i < str.size(); i++){
		bin += encode[str[i]];
	}

	if(bin.size() % 5 != 0){
		int r = bin.size() % 5;
		for(int i = 0; i < 5 - r; i++){
			bin += "0";
		}
	}

	int nblock = bin.size() / 5;
	string result;
	for(int i = 0; i < nblock; i++){
		result += decode[bin.substr(i * 5, 5)];
	}
	cout << result << endl;
}

int main()
{
	string str;
	while(getline(cin, str)){
		solve(str);
	}

	return 0;
}

Measured memory_bytes: 1204
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);


  int a,b;
  cin >> a >> b;
  cout << (a*b) << endl;  


return 0;
}
///....


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

int main(void)
{
	ios_base::sync_with_stdio(false);    
	cin.tie(NULL);
	cout.tie(NULL);
	
	int r;
	cin>>r;
	double pi=3.141592653589793;
	
	cout<<fixed<<setprecision(15)<<2*pi*r<<"\n";
	
	return 0;
}

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

static const int INFTY = 50000;

int main() {
	int n, m;
	cin >> n >> m;
	int T[n + 1] ,C[m + 1];
	for (int i = 1; i <= n; i++) {
		T[i] = INFTY;
	}
	T[0] = 0;

	for (int i = 1; i <= m; i++) {
		cin >> C[i];
	}

	for (int i = 1; i <= m; i++) {
		for (int j = 0; j + C[i] <= n; j++) { //????????¨???????????§
			T[j + C[i]] = min(T[j + C[i]], T[j] + 1); //C[i]???????????????????????????
		}
	}
	
	cout << T[n] << endl;

	return 0;
}

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

int main() {
  int n,x;
  cin >> x >> n;
  vector<bool>seen(101,false);
  rep(i,0,n){
    int a;
    cin >> a;
    seen[a] = true;
  }
  int sa = x;
  int ans = 0;
  rep(i,0,101){
    if(!seen[i]){
      if(abs(x-i) < sa){
        sa = abs(x-i);
        ans = i;
      }
    }
  }
  if(abs(x-101) < sa) ans = 101;
  cout << ans << endl;
}

Measured memory_bytes: 3624
n = int(input())
a = [int(input()) for _ in range(n)]
m = max(a)
if a.count(m) > 1:
    for i in range(n):
        print(m)
else:
    for i in range(n):
        if a[i] == m:
            b = a.copy()
            b.remove(m)
            print(max(b))
        else:
            print(m)



Measured memory_bytes: 14060
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
if (A[0]-A[1]==B[0]-B[1]==C[0]-C[1])and(A[1]-A[2]==B[1]-B[2]==C[1]-C[2]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
import Data.List

putListLn :: Show a => [a] -> IO ()
putListLn = putStrLn . unwords . map show
getList :: Read a => IO [a]
getList = fmap (map read . words) getLine

insertionSortWith :: Ord a => (([a], [a]) -> IO b) -> ([a], [a]) -> IO ([a], [a])
insertionSortWith _ (sorted, []) = do
  return (sorted, [])
insertionSortWith f (sorted, n:ns) = do
  let inserted = insert n sorted
  f (inserted, ns)
  insertionSortWith f (inserted, ns)

main :: IO ()
main = do
  _ <- getLine
  ns <- getList :: IO [Int]
  insertionSortWithPrint ns
  return ()
  where
    insertionSortWithPrint ns = insertionSortWith (putListLn . concat') ([], ns)
    concat' (l1, l2) = l1++l2

Measured memory_bytes: 3908
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

int main(){
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	vector<pair<ll, ll>> x;
	ll i, n, k;
	cin >> n >> k;
	for (i = 0; i < n; i++){
		ll a, b;
		cin >> a >> b;
		x.push_back({ a, b });
	}
	sort(full(x));
	i = 0;
	while (1){
		k -= x[i].second;
		if (k <= 0){
			cout << x[i].first << endl;
			break;
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 2420
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
#print(A)

ans = 0
if N % 2 == 0:
  for i in range(N//2-1):
    ans -= A[i]*2
  ans += -A[N//2-1] + A[N//2]
  for i in range(N//2+1,N):
    ans += A[i]*2
else:
  ans1 = 0
  for i in range(N//2-1):
    ans1 -= A[i]*2
  ans1 += -A[N//2-1]-A[N//2]
  for i in range(N//2+1,N):
    ans1 += A[i]*2
  ans2 = 0
  for i in range(N//2):
    ans2 -= A[i]*2
  ans2 += A[N//2] + A[N//2+1]
  for i in range(N//2+2,N):
    ans2 += A[i]*2
  #print(ans1,ans2)
  ans = max(ans1,ans2)
print(ans)


Measured memory_bytes: 50776
public class Hello{
    public static void Main(){
        
        var line = System.Console.ReadLine();
        string[] array = line.Split(' ');
        int a = int.Parse(array[0]);
        int b = int.Parse(array[1]);
        int c = int.Parse(array[2]);
        
        int i = 0;
        int sum = 0;
        while(sum < c)
        {
            i++;
            if(i % 7 == 0)
            {
                sum += b;
            }
            sum += a;
        }
        
        System.Console.WriteLine(i);
        
        
    }
}



Measured memory_bytes: 18020
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
	vector<int> v;
	int n;
	cin>>n;
	for(int i = 0;i < n; ++i)
	{
		int cur;
		cin>>cur;
		if(i < n - 2)
		{
			//printf("hi2\n");
			int cur2;
			cin>>cur2;
			v.push_back(cur);
			v.insert(v.begin(),cur2);
			++i;
		}
		else
		{
			//printf("hi1\n");
			v.push_back(cur);
			reverse(v.begin(),v.end());
		}
	}
	for(int i = 0;i < n; ++i)
	{
		cout<<v[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
 string S;
  cin >>S;
  int x=S.size();
  int y=753;
  vector<int>vec(x-2);
  rep(i,x-2) {
    vec.at(i)=abs(((S.at(i)-'0')*100+(S.at(i+1)-'0')*10+(S.at(i+2)-'0')*1)-y);
  
  
  }
  sort(all(vec));
  cout <<vec.at(0)<< endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    int n,m;
    string s,t;
    cin >> n;
    map<string, int> Smp;
    set<string> st;
    rep(i,n) {
        cin >> s;
        st.insert(s);
        Smp[s]++;
    }
    cin >> m;
    map<string, int> Tmp;
    rep(i,m) {
        cin >> t;
        Tmp[t]++;
    }
    int c = 0;
    for(auto x: st) {
        int _c = 0;
        _c = Smp[x]-Tmp[x];
        c = max(c,_c);
    }
    cout << c << "\n";
}

Measured memory_bytes: 256
import collections
def main():
    N = int(input())
    B = [0] + [int(_) for _ in input().split()]

    for i in range(1, N+1):
        if i < B[i]:
            print(-1)
            return
    dic = collections.defaultdict(int)
    for i in range(1, N+1):
        x = B[i]
        c = 0
        for j in range(i+1, N+1):
            if B[j] <= x:
                x += 1
                c += 1
        dic[B[i]+c] = B[i]
    out = [dic[key] for key in sorted(dic.keys())]
    print(*out, sep = '\n')
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
using System;

namespace agc019a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] read = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            int divByOne = Math.Min(2*read[0],read[1]);
            divByOne = Math.Min(2*divByOne,read[2]);
            int divByTwo = read[3];
            long N = long.Parse(Console.ReadLine());
            if(2*divByOne <= divByTwo){
                Console.WriteLine(N*divByOne);
            }else{
                Console.WriteLine(N/2*divByTwo+N%2*divByOne);

            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N,Q; string S; vi l,r;
void input()
{
    cin>>N>>Q;
    cin>>S;
    for(int i=0;i<Q;++i){
        int a,b; cin>>a>>b; 
        l.emplace_back(a); r.emplace_back(b);
    }
}

void solve()
{
    vi rui(N+1,0);
    for(int i=2;i<N+1;++i){
        rui[i]=rui[i-1];
        if(S[i-2]=='A' && S[i-1]=='C') ++rui[i];
    }
    for(int i=0;i<Q;++i){
        int ans=rui[r[i]]-rui[l[i]-1];
        if(l[i]>1 && S[l[i]-2]=='A' && S[l[i]-1]=='C') --ans;
        cout<<ans<<endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4820
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    bool correct = true;
    string S[n];
    rep(i, n) cin >> S[i];
    for(int i = 1; i < n; i ++){
        //string S[i];
        rep(j, i) if(S[i] == S[j]) correct = false;
        int jj = S[i - 1].size();
        if(S[i][0] != S[i - 1][jj - 1]) correct = false;

    }
    if(correct) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n, i;
int x, d, l;
int main(void){
	scanf("%d%d", &n, &x);
	for(i=0; i<n; i++){
		scanf("%d", &l);
		d += l;
		if(d>x){break;}
	}
	printf("%d\n", i+1);
}


Measured memory_bytes: 128