akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	VVI A;
    int N;
    VI b;
    rep(i,3){
        VI a;
        rep(j,3){
            int aa;
            cin >> aa;
            a.PB(aa);
        }
        A.PB(a);
    }
    cin >> N;
    rep(i,N){
        int bb;
        cin >> bb;
        b.PB(bb);
    }
    string ans = "No";
    rep(i,3){
        rep(j,3){
            rep(k,N){
                if(A[i][j] == b[k]) A[i][j] = 0;
            }
        }
    }
    rep(i,3){
        int sum1=0;
        rep(j,3){
            sum1+=A[i][j];
        }
        if(sum1 == 0) ans = "Yes";
    }
    rep(i,3){
        int sum2=0;
        rep(j,3){
            sum2+=A[j][i];
        }
        if(sum2 == 0) ans = "Yes";
    }
    int sum3 = 0;
    rep(i,3){
        sum3+=A[i][i];
    }
    if(sum3 == 0) ans = "Yes";
    int sum4 = 0;
    rep(i,3){
        sum4+=A[2-i][i];
    }
    if(sum4 == 0) ans = "Yes";
    cout << ans << endl;
    return 0;
}


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

namespace AtCoders {
	class Program {
		static void Main(string[] args) {
  			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];
			var K = inputArray[1];

			var hitPointList= retreiveLongArray().OrderByDescending(x =>x).ToList();

			long sum = 0;

			var hissatsuDamage = hitPointList.Take((int)K).Sum();
			var totalDamage = hitPointList.Sum();

			//答えの出力
			var ans = totalDamage - hissatsuDamage;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray =  Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

int main() {
  int a, b, n;
  cin >> n >> a >> b;
  
  int p1 = a * n;
  int p2 = b;

  if (p1 >= p2) {
    cout << p2 << endl;
  } else {
    cout << p1 << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main() {

    ll A,B;
    cin >> A >> B;
    ll out = 0;
    if(A>=13) out = B;
    else if(A>=6) out = B/2;
    else out = 0;
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
inf = float("inf")
d = [[inf] * (N+1) for _ in range(N+1)]
ans = inf
for _ in range(M): #隣接行列
    A,B,C = map(int, input().split())
    d[A][B] = C
    d[B][A] = C

def warshall_floyd(n):
    for i in range(1,n+1): #経由する点
        for j in range(1,n+1): #始点
            for k in range(1,n+1): #終点
                d[j][k] = min(d[j][k], d[j][i] + d[i][k])

warshall_floyd(N)

for p in permutations(r): #通る町の順列生成
    tmp = 0
    for r1,r2 in zip(p,p[1:]):
        tmp += d[r1][r2]
    ans = min(ans, tmp)
print(ans)

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec C(N-1), S(N-1), F(N-1);
    REP(i,0,N-1) cin >> C[i] >> S[i] >> F[i];

    REP(i,0,N) {
        ll t = 0;
        REP(j,i,N-1) t = S[j] + F[j] * MAX((t-S[j]+F[j]-1)/F[j],0) + C[j];
        PR(t);
    }

    return 0;
}

/*



*/

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point{
	public:
		double x, y;

		Point(double x = 0, double y = 0): x(x), y(y) {}

		Point operator + (Point p){ return Point(x + p.x, y + p.y);}
		Point operator - (Point p){ return Point(x - p.x, y - p.y);}
		Point operator * (double a){ return Point(a * x, a * y);}
		Point operator / (double a){ return Point(x / a, y / a);}

		double abs(){ return sqrt(norm());}
		double norm(){ return x * x + y * y;}

		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}

		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};

struct Segment {
	Point p1, p2;
};
typedef Segment Line;

class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef Point Vector;
typedef vector<Point> Polygon;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}
double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Line l1, Line l2){
	return equals(dot(l1.p2 - l1.p1, l2.p2 - l2.p1), 0.0);
}
bool isParallel(Line l1, Line l2){
	return equals(cross(l1.p2 - l1.p1, l2.p2 - l2.p1), 0.0);
}

int main(void){
	Line l1, l2;
	int q;
	cin >> q;
	for(int i=1;i<=q;i++){
		cin >> l1.p1.x >> l1.p1.y >> l1.p2.x >> l1.p2.y >> l2.p1.x >> l2.p1.y >> l2.p2.x >> l2.p2.y;
		if(isOrthogonal(l1, l2) == true) cout << "1" << endl;
		else if(isParallel(l1, l2) == true) cout << "2" << endl;
		else cout << "0" << endl;
	}
	return 0;
}

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

def divlist(n):
    if n < 1:
        return []
    elif n == 1:
        return [1]
    else:
        div = [1]
        for i in range(2, n + 1):
            if n % i == 0:
                div.append(i)
        return div


ans = []

for i in range(1,N+1):
    if i % 2 == 0:
        pass
    elif len(divlist(i)) == 8:
        ans.append(i)

print(len(ans))

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int X;
	scanf("%d",&X);
	if(X>=30){
		printf("Yes");
	}else{
		printf("No");
	}
}


Measured memory_bytes: 1720
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>

typedef long long ll;

using namespace std;

int main()
{
    ll nc = 0;
    ll zc = 0;

    ll n;
    cin >> n;

    vector<ll> as(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> as[i];
    }

    for (ll i = 0; i < n; i++)
    {
        if (as[i] == 0)
        {
            zc++;
        }
        else if (as[i] < 0)
        {
            as[i] *= -1;
            nc++;
        }
    }

    if (zc > 0 || nc % 2 == 0)
    {
        cout << accumulate(as.begin(), as.end(), 0LL) << endl;
    }
    else
    {
        cout << accumulate(as.begin(), as.end(), 0LL) - 2 * *min_element(as.begin(), as.end()) << endl;
    }

    return 0;
}


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

int main() {
	int h, n;
	cin>>h>>n;
	int total = 0;
	for(int i = 0;i < n;i++) {
		int x;
		cin>>x;
		total += x;
	}
	if(total >= h) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,j,n) for(int i=j;i<n;i++)
const int INF = 1000000009;


int main(){
    int N;
    cin >> N;
    int a[N],b[N],c[N];
    REP(i,N){
        cin>>a[i]>>b[i]>>c[i];
    }
    //dpは3*Nの配列，0→a,1→b,2→c
    int dp[N][3] ={INF};
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];
    REP2(j,1,N){
        dp[j][0] = max(dp[j-1][1],dp[j-1][2])+a[j];
        dp[j][1] = max(dp[j-1][0],dp[j-1][2])+b[j];
        dp[j][2] = max(dp[j-1][1],dp[j-1][0])+c[j];
    }
    int ans = (dp[N-1][0]>dp[N-1][1]) ? dp[N-1][0]:dp[N-1][1];
    ans = (ans > dp[N-1][2]) ? ans :dp[N-1][2];
    cout << ans << endl;
}

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

int main(){
	int H,W;
	cin>>H>>W;
	vector<string>S;
	string tmp;
	for(int i=0;i<H;++i){
		cin>>tmp;
		S.push_back(tmp);
	}
	vector< vector<int> > R,L,U,D;
	vector<int>tmpR,tmpL,tmpU,tmpD;

	for(int i=0;i<H;++i){
		tmpL.clear();
		for(int j=0;j<W;++j){
			if(j==0){
				if(S[i][j]=='.')tmpL.push_back(0);
				else tmpL.push_back(-1);
			}
			else{
				if(S[i][j]=='.')tmpL.push_back(tmpL[tmpL.size()-1]+1);
				else tmpL.push_back(-1);
			}
		}
		L.push_back(tmpL);
	}

	for(int i=0;i<H;++i){
		tmpR.clear();
		for(int j=W-1;j>=0;--j){
			if(j==W-1){
				if(S[i][j]=='.')tmpR.push_back(0);
				else tmpR.push_back(-1);
			}
			else{
				if(S[i][j]=='.')tmpR.push_back(tmpR[tmpR.size()-1]+1);
				else tmpR.push_back(-1);
			}
		}
		reverse(tmpR.begin(),tmpR.end());
		R.push_back(tmpR);
	}

	for(int i=0;i<H;++i){
		tmpU.clear();
		for(int j=0;j<W;++j){
			if(i==0){
				if(S[i][j]=='.')tmpU.push_back(0);
				else tmpU.push_back(-1);
			}
			else{
				if(S[i][j]=='.')tmpU.push_back(U[i-1][j]+1);
				else tmpU.push_back(-1);
			}
		}
		U.push_back(tmpU);
	}

	for(int i=H-1;i>=0;--i){
		tmpD.clear();
		for(int j=0;j<W;++j){
			if(i==H-1){
				if(S[i][j]=='.')tmpD.push_back(0);
				else tmpD.push_back(-1);
			}
			else{
				if(S[i][j]=='.')tmpD.push_back(D[D.size()-1][j]+1);
				else tmpD.push_back(-1);
			}
		}
		D.push_back(tmpD);
	}
	reverse(D.begin(),D.end());

	/*
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			cout<<U[i][j]<<" "<<L[i][j]<<" "<<D[i][j]<<" "<<R[i][j]<<"|";
		}
		cout<<endl;
	}
	cout<<endl;
	*/
	int ans = 0;
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			if(U[i][j]+L[i][j]+D[i][j]+R[i][j]+1>ans)ans=U[i][j]+L[i][j]+D[i][j]+R[i][j]+1;
		}
	}
	cout<<ans<<endl;
	/*
	for(int i=0;i<H;++i){
		for(int j=0;j<W;++j){
			cout<<S[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
	int ans = 0;
	int len,len1;
	for(int i=0;i<H;++i){
		vector< vector<int> >arr;
		vector<int> tmparr;
		for(int j=0;j<W;++j){
			if(S[i][j]=='.'){
				tmparr.push_back(j);
			}
			else{
				if(tmparr.size()>0)arr.push_back(tmparr);
				tmparr.clear();
			}
		}
		if(tmparr.size()>0)arr.push_back(tmparr);
		//cout<<arr.size()<<endl;
		for(int j=0;j<arr.size();++j){
			for(int k=0;k<arr[j].size();++k){
				cout<<arr[j][k]<<" ";	
			}
			cout<<endl;
		}
		cout<<endl;
		for(int j=0;j<arr.size();++j){
			len1 = arr[j].size();
			for(int k=0;k<arr[j].size();++k){
				len=0;
				for(int h=i;h>=0;--h){
					if(S[h][arr[j][k]]!='.')break;
					else len++;
				}
				for(int h=i;h<H;++h){
					if(S[h][arr[j][k]]!='.')break;
					else len++;
				}
				//cout<<i<<" "<<arr[j][k]<<endl;
				//cout<<len+arr[j].size()-2<<endl;
				if(len+len1-2>ans)ans=len+len1-2;
			}
		}
	}
	cout<<ans<<endl;
	*/
}


Measured memory_bytes: 67200
//
// Created by TakahiroYamaji on 2020/07/29.
//
#include<iostream>
#include<algorithm>
typedef long long ll;
int N;
typedef std::pair<ll, ll> P;
P p[100000];
ll x, l;
bool comp(P& x1, P& x2){
    return x1.second < x2.second;
}

int main(){
    std::cin >> N;
    for (ll i=0;i<N;i++){
        std::cin >> x >> l;
        //compute start and end position
        p[i].first = x - l;
        p[i].second = x + l;
    }
    std::sort(p, p+N, comp);
    ll res = 1;
    ll end = p[0].second;
    for (ll i=1;i<N;i++){
        if (end > p[i].first) continue;
        else{
            res++;
            end = p[i].second;
        }
    }
    std::cout << res << std::endl;
    return 0;
}



Measured memory_bytes: 4724
while line = gets
  dat = line.split(",").map(&:to_i)
  lengths, v1, v2 = dat[0..9], dat[10], dat[11]

  distances = [0]
  lengths.each.with_index(1) do |l, i|
    distances[i] = distances[i - 1] + l
  end

  x = v1.to_f / (v1 + v2) * distances.last

  distances.each_with_index do |d, i|
    if x <= d
      puts i
      break
    end
  end
end

Measured memory_bytes: 8644
def main():
    N = int(input())
    T,A = map(int, input().split())
    H = [int(s) for s in input().split()]

    palace_place = -1
    minimam_difference = 0
    for i, h in enumerate(H):
        temperature = T - (h*0.006)
        temperature_difference = abs(A-temperature)
        if i == 0 or minimam_difference > temperature_difference:
            minimam_difference = temperature_difference
            palace_place = i
    
    print(palace_place+1)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#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,M;
vector<int> E[202020];
int P[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(P);
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	P[0]=0;
	queue<int> Q;
	Q.push(0);
	while(Q.size()) {
		x=Q.front();
		Q.pop();
		FORR(e,E[x]) if(P[e]==-1) {
			P[e]=x+1;
			Q.push(e);
		}
	}
	cout<<"Yes"<<endl;
	for(i=1;i<N;i++) cout<<P[i]<<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: 13316
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    n = int(input())
    a = [ list(map(int, input().split())) for _ in range(2) ]
    ans = float('-inf')
    for x1 in range(1,n+1):
        factor = sum(a[0][0:x1])
        for x2 in range(x1-1,n):
            ans = max(ans, factor+sum(a[1][x2:n+1]))
    print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>

using namespace std;

#define PI 3.14159265359

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  cout << fixed;
  double ans;
  if(x <= a*a*b/2.0){
    ans = atan(a*pow(b, 2)/((double)2.0*x));
  }
  else{
    x = x/pow(a, 2);
    ans = atan((double)2.0*(b-x)/a);
  }
  cout << setprecision(10) << ans*((double)180.0/PI) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

int binarySearch(vector<long long> vec, long long key) {
    // key: 検索対象の値
    int left = 0, right = vec.size(), mid;
 
    while (left < right) {
        mid = (left + right)/2;
        if (vec[mid] == key) {
            return mid;
        } else if (key < vec[mid]) {
            // 半分より下
            right = mid;
        } else if (vec[mid] < key) {
            // 半分より上
            // 必要ないが，分かりやすいように条件を記述してある．
            left = mid + 1;
        }
    }
    // key が配列の中に見つからない場合
    return -1;
}

int main()
{      
   
    long long n, q, b, c;
    
    cin >> n;
    unordered_map<long, long> hash;
    long long sum = 0;
    
    long long a;
    for(int i=0; i<n; i++){
        cin >> a;
        
        sum += a;
        
        if(!hash[a]){
            hash[a] = 1;
        }else{
            hash[a] ++;
        }
    }
    
    // mapを読み取る
    cin >> q;
    for(int i=0; i<q; i++){
        cin >> b >> c;
        
        // search
        if(!hash[b]){
            // not exist
            cout << sum << endl;
        }else{
            long long delta = (c-b) * hash[b];
            sum += delta;
            
            hash[c] += hash[b];
            hash[b] = 0;
            
            cout << sum << endl;
        }
            
    }
    
   
}


Measured memory_bytes: 6960
n,k = map(int,input().split())
a = list(map(int,input().split()))
imos = [0]*(2*10**5+1)
for j in range(min(k,700)):
    imos = [0]*(2*10**5+1)
    for i in range(n):
        imos[max(i-a[i],0)] += 1
        imos[min(i+a[i]+1,2*10**5)] -= 1
    for i in range(1,n):
        imos[i] += imos[i-1]
    a = imos
print(*imos[:n])

Measured memory_bytes: 170104
/*
  Warn - Don't change next line else you will get WA verdict. Online Judge is configured to give WA if next line is not present.
  Author - Aryan Choudhary (@aryanc403)
 
  const short DEBUG { 0 };
  #define debug(x) if (DEBUG) cout << #x << " = " << x << '\n'
*/

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"
#define PI 3.1415926535897932384626433832795
typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

//const lli [3] ={ 999119999L,1000000007L,1000992299L};
//const lli [3] ={ 97L,101L,103L};
//const lli  = chrono::high_resolution_clock::now().time_since_epoch().count();
clock_t time_p=clock();
void aryanc403()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

class CMP
{
public:
    bool operator()(lli a , lli b) //For min priority_queue .
    {
        return ! ( a <= b );
    }
};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt==m.end())         m.insert(mp(x,cnt));
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    map<lli,lli> ::iterator jt;
    jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}
const lli INF = 0xFFFFFFFFFFFFFFFL;
const lli mod = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,q,x,ans;
    lli m;
    string s;
    vi a,b;
    vi :: iterator it;
    //priority_queue < lli , vector < lli > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>m>>q;
    a.clear();a.reserve(n);
    b.clear();b.reserve(m);
    fo(i,n)
    {
        cin>>in;
        a.pb(in);
    }
    
    fo(i,m)
    {
        cin>>in;
        b.pb(in);
    }
    
    a.pb(-INF);a.pb(INF);
    b.pb(-INF);b.pb(INF);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    
    while(q--)
    {
        cin>>x;
        i=lower_bound(a.begin(),a.end(),x)-a.begin();
        j=lower_bound(b.begin(),b.end(),x)-b.begin();
        ans=INF;
        
        ans=min(ans,max(abs(a[i]-x),abs(b[j]-x)));
        ans=min(ans,max(abs(a[i-1]-x),abs(b[j-1]-x)));
        
        ans=min(ans,abs(a[i]-x)+abs(b[j-1]-x)+min(abs(a[i]-x),abs(b[j-1]-x)));
        ans=min(ans,abs(a[i-1]-x)+abs(b[j]-x)+min(abs(a[i-1]-x),abs(b[j]-x)));
        cout<<ans<<endl;
    }
    
}   aryanc403();
    return 0;
}

Measured memory_bytes: 2912
N = int(input())
W = [input() for _ in range(N)]

S = set([W[0]])

ans = "Yes"
for i in range(1,N):
    if W[i-1][len(W[i-1])-1] != W[i][0] or W[i] in S:
        ans = "No"
        break
    else:
        S.add(W[i])

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

bool isSame(string S) {
	char c = S[0];
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != c)
			return false;
	}
	return true;
}

int main() {
	int N;
	vector<int> A;
	cin >> N;
	int i;
	for (i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	long long ans = 1;
	long long Noans = 1;
	for (i = 0; i < A.size(); i++) {
		if (A[i] % 2 == 0) {
			Noans *= 2;
		}
	}
	cout << pow(3, N) - Noans;

	return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: u64 = read();
    let d: u64 = read();
    let mut count: u64 = 0;
    for i in 0..n {
        let x: i64 = read();
        let y: i64 = read();
        let tmp = x.pow(2) + y.pow(2);
        if (tmp as f64).sqrt() <= (d as f64) {
            count+=1
        }
    }
    println!("{}", count)
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 2116
s = int(input())
a = [s]

for i in range(1,10**9):
    if a[-1]%2 ==0:
        tmp = a[-1]//2
    else:
        tmp = a[-1]*3+1
    
    if tmp in a:
        print(i+1)
        exit()
    else:
        a.append(tmp)

Measured memory_bytes: 3060
#include<stdio.h>

#define MAX 100
static const int INFTY = (1<<21);
#define WHITE 0;
#define GRAY 1
#define BLACK 2

int prim();

int n, M[MAX][MAX];

int prim(){
  int u, minv, i=0, v=0;
  int d[MAX], p[MAX], color[MAX];

  for(i=0; i<n; i++){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for( i=0; i<n; i++){
      if(minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v] != BLACK && M[u][v] != INFTY){
        if(d[v] > M[u][v]){
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for(i=0; i<n; i++){
    if(p[i] != -1)sum += M[i][p[i]];
  }
  return sum;
}

int main(){

  int i=0, j=0;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      int e;
      scanf("%d",&e);

      M[i][j] = (e==-1) ? INFTY : e;
    }
  }
  printf("%d\n",prim());

  return 0;
}

Measured memory_bytes: 636
h,w,k = gets.split.map(&:to_i)
c = Array.new(w-1,0)
a = Array.new(w-1,0)
s = 0
for i in 0..2**(w-1)-1
    (w-1).times do |j|
        a[j] = i[j]
    end
    f = true
    for j in 0..w-3
        if a[j] == 1 && a[j+1] == 1
            f = false
            break
        end
    end
    if f
        s += 1
        (w-1).times do |j|
            c[j] += a[j]
        end
    end
end
ans = Array.new(h+1).map{Array.new(w,0)}
ans[0][0] = 1
$mod = 10**9+7
for i in 1..h
    for j in 0..w-1
        t = 0
        if j != 0
            t += c[j-1]
            ans[i][j-1] += ans[i-1][j]*c[j-1]
        end
        if j != w-1
            t += c[j]
            ans[i][j+1] += ans[i-1][j]*c[j]
        end
        ans[i][j] += ans[i-1][j]*(s-t)
        ans[i][j] %= $mod
    end
end
puts ans[h][k-1]%$mod

Measured memory_bytes: 1788
var
  n,m,i,j:longint;
  x,y:array[1..1000]of boolean;
  a:array[1..1000,1..1000]of char;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to m do
      read(a[i,j]);
    readln;
  end;
  for i:=1 to n do
  begin
    x[i]:=true;
    for j:=1 to m do
      if a[i,j]='#' then x[i]:=false;
  end;
  for j:=1 to m do
  begin
    y[j]:=true;
    for i:=1 to n do
      if a[i,j]='#' then y[j]:=false;
  end;
  for i:=1 to n do
  begin
    for j:=1 to m do
      if not(x[i] or y[j]) then write(a[i,j]);
    if not x[i] then writeln;
  end;
end.

Measured memory_bytes: 256
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

s = ir()
if int(math.sqrt(s))**2 == s:
    print(*[0,0,int(math.sqrt(s)),0,0,int(math.sqrt(s))], sep=' ')
else:
    x1 = int(math.sqrt(s))+1
    y2 = x1
    x2 = 0
    y1 = 0

    while y2 <= 10**9:
        pre = x1*y2 - s
        if 0<=pre<=10**9:
            x2 = 1
            y1 = pre
            break
        y2+=1
    print(*[0,0,x1,y1,x2,y2], sep=' ')

Measured memory_bytes: 77176
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define ld          long double
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }



void solve() {  
    int n, k; cin >> n >> k;
    n %= k;
    cout << min(n, k-n) << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);

    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
n, m, q = list(map(int, input().split()))
pairs = [list(map(int, input().split())) for _ in range(q)]

def amp(seqs):
    for seq in seqs:
        s = seq[-1]
        for i in range(s, m+1):
            yield seq + [i]

seed = [[i+1] for i in range(m)]
seq = seed
for _ in range(n-1):
    seq = amp(seq)

all_an = list(seq)
dn = max(sum(d for a,b,c,d in pairs if an[b-1] - an[a-1] == c) for an in all_an)
print(dn)



Measured memory_bytes: 22948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int main() {
	int a, b;
	int ans_1, ans_2, ans;

	cin >> a >> b;
	ans = -1;
	for(int i = 0; i < ((b + 1) * 10);i++) {
		if ((int)(i * 1.08)	- i == a &&
			(int)(i * 1.10) - i == b) {
				ans = i;
				break;
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[100][100];
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h >> w;
  rep(i, h) rep(j, w) cin >> s[i][j];

  ll min_cost[h + 10][w + 10];
  rep(i, h) rep(j, w) min_cost[i][j] = LINF;
  queue<P> qu;
  qu.push({0, 0});
  min_cost[0][0] = 0;

  while (!qu.empty()) {
    auto p = qu.front();
    qu.pop();
    rep(i, 4) {
      int nx = p.se + dx[i], ny = p.fi + dy[i];
      if (nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
      if (s[ny][nx] == '#') continue;
      if (min_cost[p.fi][p.se] + 1 >= min_cost[ny][nx]) continue;
      min_cost[ny][nx] = min_cost[p.fi][p.se] + 1;
      qu.push({ny, nx});
    }
  }
  ans = min_cost[h - 1][w - 1];
  if (ans == LINF)
    Cout(-1);
  else {
    // debug(ans);
    ans = h * w - ans;
    rep(i, h) {
      rep(j, w) {
        if (s[i][j] == '#') ans--;
      }
    }
    Cout(ans - 1);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
    int x, y;
    cin >> x >> y;
    
    long ans;
    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;

}



Measured memory_bytes: 256
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int h, w;
string fields[50];

int min_dist () {
    using node = tuple<int, int, int>;
    priority_queue<node, vector<node>, greater<node>> que;

    que.push(mt(0, 0, 0));

    bool is_used[50][50] = { false };
    while( !que.empty() ){
        node n = que.top(); que.pop();

        int& dist = get<0>(n);
        int& y = get<1>(n);
        int& x = get<2>(n);

        if( is_used[y][x] ) continue;
        is_used[y][x] = true;

        if( y == h-1 && x == w-1 ) return dist;
        
        rep(i, 4) {
            if( y + dy[i] < 0 || y + dy[i] >= h || x + dx[i] < 0 || x + dx[i] >= w ) continue;
            if( fields[y+dy[i]][x+dx[i]] == '#' ) continue;
            
            que.push(mt(dist+1, y+dy[i], x+dx[i]));
        }
    }

    return -1;
}

int main()
{
    cin >> h >> w;
    rep(i, h) cin >> fields[i];

    int black = 0, white = 0;
    rep(i, h) rep(j, w){
        if( fields[i][j] == '.' ) ++white;
        else ++black;
    }

    int dist = min_dist();
    cout << (dist == -1 ? -1 : white - (dist+1)) << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque

def main():
    input = sys.stdin.readline
    N = int(input())
    q = deque([[1, 1]])
    d = {1: 1}
    while q:
        n, c = q.popleft()
        a = (n * 10) % N
        if a not in d or d[a] > c:
            d[a] = c
            q.appendleft([a, c])

        b = (n + 1) % N
        if b not in d or d[b] > c+1:
            d[b] = c + 1
            q.append([b, c+1])

    print(d[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 19728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using node = tuple<int, int, int>;
const int MAX_N = 500000;
const double inf = numeric_limits<double>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int n,a,b;
  cin >> n >> a >> b;
  int diff = b - a - 1;
  cout << ((diff % 2 == 0) ? "Borys" : "Alice") << endl;
  return 0;
}


Measured memory_bytes: 256
gets.to_i.times do
  x1, y1, x2, y2, x3, y3 = gets.split.map(&:to_f)

  # http://www.h6.dion.ne.jp/~jpe02_tn/ki-5.html
  a1 = 2*(x2 - x1)
  b1 = 2*(y2 - y1)
  c1 = x1**2 - x2**2 + y1**2 - y2**2
  a2 = 2*(x3 - x1)
  b2 = 2*(y3 - y1)
  c2 = x1**2 - x3**2 + y1**2 - y3**2
  x = (b1*c2 - b2*c1) / (a1*b2 - a2*b1)
  y = (c1*a2 - c2*a1) / (a1*b2 - a2*b1)

  # http://keisan.casio.jp/exec/system/1161228797
  a = Math.sqrt((x2-x1)**2 + (y2-y1)**2)
  b = Math.sqrt((x3-x2)**2 + (y3-y2)**2)
  c = Math.sqrt((x1-x3)**2 + (y1-y3)**2)
  s = (a+b+c) / 2
  r = (a*b*c) / (4*Math.sqrt(s*(s-a)*(s-b)*(s-c)))

  puts "#{'%.3f'%x} #{'%.3f'%y} #{'%.3f'%r}"
end

Measured memory_bytes: 6196
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,t,s,d;
    while (cin>>n>>m) {
        if (n==0&&m==0) {
            break;
        } else {
            std::vector<tuple<int,int,int>> vec;
            for (int i=0;i<m;i++) {
                cin>>t>>s>>d;
                vec.emplace_back(t,s,d);
            }
            sort(vec.begin(),vec.end());
            std::deque<int> pc(n+1,0);
            pc[1]=1;
            for (int j=0;j<m;j++) {
                int& source=get<1>(vec[j]);
                int& dst=get<2>(vec[j]);
                if (pc[source]==1) {
                    pc[dst]=1;
                }
            }
            int count=0;
            for (int k=1;k<=n;k++) {
                if (pc[k]==1) {
                    count++;
                }
            }
            cout<<count<<endl;
        }
    }
}



Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    cout << *min_element(all(A)) << " " << *max_element(all(A)) << " " << accumulate(all(A), 0ll) << endl;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    bool flag = true;
    for(int i=0; i<n; i++){
        int a;cin>>a;
        if(a%2==0&&a%3!=0&&a%5!=0)flag=false;
    }
    cout<<(flag?"APPROVED":"DENIED");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    int cnt[M] = {};
    rep(i,0,N){
        int k;
        cin >> k;
        rep(j,0,k){
            int a;
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    rep(i,0,M)if(cnt[i] == N)ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = [0]*N

for n in range(N):
    h[n] = int(input())
    
h.sort()

tree = h[:K]
height = []
height.append(tree[-1]-tree[0])

for n in range(K,N):
    tree.pop(0)
    tree.append(h[n])
    height.append(tree[-1]-tree[0])  

print(min(height))

Measured memory_bytes: 11172
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n){
    int l,r;
    cin >> l >> r;
    ans += r-l+1;
  }
  
  cout << ans;
  
  return 0;
}

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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int N;
int A[100000];

void solve(){
	ll c=0;
	ll ans=0;
	rep(i,N){
		c+=A[i];
		if(A[i]==0){
			ans+=(c/2);
			c=0;
		}
	}
	ans+=c/2;
	cout<<ans<<endl;
}

int main(){
	cin>>N;
	rep(i,N) {
		cin>>A[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(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--)

int main(){
    ll N,ans1= 0;
    cin >> N;
    vector<ll> A(N+1),B(N+1);
    
    for(ll i = 0;i <= N;i++){
        cin >> A.at(i);
    }

    for(ll i = 0;i < N;i++)
        cin >> B.at(i);


    for(ll i = 0;i < N;i++){
        if(A.at(i) >= B.at(i)){
            ans1 += B.at(i);
        }
        else{
            ans1 += A.at(i);
            B.at(i) -= A.at(i);
            A.at(i) = 0;
            if(B.at(i) >= A.at(i+1)){
                ans1 += A.at(i+1);
                A.at(i+1) = 0; 
            }else{
                ans1 += B.at(i);
                A.at(i+1) -= B.at(i);
            }
        }
    }

    cout << ans1 << endl;

}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
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;
}
const int MOD = 1000000007;

int main() {
    int N;
    cin >> N;
    string res = "No";
    rep(i, 0, 10) {
        rep(r, 0, 10) {
            if(i * r == N) {
                res = "Yes";
                break;
            }
        }
    }
    cout << res << endl;
}

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

#define lpsbd(i, s, b, d) for(size_t i = (s); i < (b); i+=(d))
#define lpsb(i, s, b) for(size_t i = (s); i < (b); i++)
#define lpn(i, n) for(size_t i = 0; i < (n); i++)
#define fa(i, x) for(auto &i: x)
#define vcd(t, n, d) vector<t>(n, d)
#define vc(t, n) vector<t>(n)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main(void)
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    int count = 0;
    lpsb(i, 1, N) if (S[i-1] != S[i]) count++;
    cout << (N - 1 - max(0, count - K*2)) << endl;
    return 0;
}

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

typedef long long ll;

int main() {
    int N, M, A, B, ans = 0;
    cin >> N >> M;
    vector<int> H(N), C(N, 1);
    rep(i, N) cin >> H[i];
    rep(i, M) {
        cin >> A >> B;
        A--;
        B--;
        if (H[A] <= H[B]) C[A] = 0;
        if (H[A] >= H[B]) C[B] = 0;
    }
    rep(i, N) ans += C[i];
    cout << ans << "\n";
}

Measured memory_bytes: 4052
#include<iostream>
using namespace std;
int x[2015];
int main(void)
{
    int r,d,X;
    cin >> r >> d >> X;
    x[2000]=X;
    for(int i=2001;i<=2010;i++)
	x[i]=r*x[i-1]-d;
    for(int i=2001;i<=2010;i++)
	cout << x[i] << '\n';
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main{
	
	static Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int n=s.nextInt();
		int[] res = new int[26],resbuf=new int[26];
		Arrays.fill(res,114514);
		for(int i=0;i<n;i++) {
			Arrays.fill(resbuf,0);
			Counter<Character> counter = new Counter<>(26);
			for(char c:s.next().toCharArray()) {
				counter.add(c);
			}
			for(Entry<Character, Integer> e:counter.map.entrySet()) {
				resbuf[e.getKey().charValue()-'a']=e.getValue();
			}
			for(int j=0;j<26;j++)
				res[j]=Math.min(res[j],resbuf[j]);
		}
		StringBuilder sb=new StringBuilder();
		for(char c='a';c<='z';c++) if(res[c-'a']!=114514){
			for(int i=0;i<res[c-'a'];i++)
				sb.append(c);
		}
		System.out.println(sb.toString());
	}
}
class Counter<T>{
	
	public HashMap<T, Integer> map;
	
	public Counter(int initSize){
		map=new HashMap<>(initSize);
	}
	
	public Counter(){
		this(10);
	}
	
	public void add(T key, int v){
		if(!map.containsKey(key)){
			map.put(key,v);
		}else{
			map.merge(key,v,Math::addExact);
		}
	}
	
	public void add(T key){
		add(key,1);
	}
}


Measured memory_bytes: 26964
#include <iostream>
#include <queue>
#include <utility>
#include <set>
#include <unordered_map>
#define llint long long
#define inf 1e18
#define N(a, b) ((a)*3000+(b))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint c[25];
unordered_map<llint, llint> mp[25][25];

llint calc(llint l, llint r, llint a, llint b)
{
	if(l > r) return 0;
	if(mp[l][r].count(N(a, b))) return mp[l][r][N(a, b)];
	
	llint ret = inf;
	for(int i = l; i <= r; i++){
		ret = min(ret, calc(l, i-1, a, a+b) + calc(i+1, r, a+b, b) + (a+b)*c[i]);
	}
	return mp[l][r][N(a, b)] = ret;
}

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> c[i];
	
	cout << calc(2, n-1, 1, 1) + (c[1]+c[n]) << endl;
	
	return 0;
}

Measured memory_bytes: 11392