akhauriyash/Code-Regression huggingface dataset:
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 10e9+7LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(r);
    cout << 2 * M_PI * r << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3804
#include<stdio.h>

int main()
{
  int a,b;
  while(1)
{
  scanf("%d %d",&a,&b);
  if(a==0&&b==0)
  {
      break;
  }
  for(int i = 1; i <= a; i++)
    {
      for(int j = 1; j <= b; j++)
	{
	  if(i>1&&i<a&&j<b&&j>1)
	  {
	  printf(".");
	  }
	 else 
	 {
	 printf("#");
	 }
	 }
      printf("\n");
    }
  printf("\n");
}
  return 0;
}



Measured memory_bytes: 2020
#include<iostream>
#include <string>
#include<stack>
#include<cstdlib>

using namespace std;
int main(){  
  stack<int> st;
  string str;
  int a,b;
  while(cin>>str){
    if(str=="+"){
      a=st.top();
      st.pop();
      b=st.top();
      st.pop();
      st.push(a+b);
    }
    else if(str=="-"){
      a=st.top();
      st.pop();
      b=st.top();
      st.pop();
      st.push(b-a);
    }
    else if (str == "*") {
      a=st.top();
      st.pop();
      b=st.top();
      st.pop();
      st.push(a*b);
    }
    else{
      st.push(atoi(str.c_str()));
    }
  }
  cout<<st.top()<< endl;
  return 0;
}


Measured memory_bytes: 3176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,z,w;
  cin>>n>>z>>w;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<int> x(n);
  vector<int> y(n);
  for(int i=n-1;i>=0;i--){
    x[i]=abs((i>0?a.at(i-1):w)-a.at(n-1));
    y[i]=abs((i>0?a.at(i-1):z)-a.at(n-1));
    for(int j=i+1;j<n;j++){
      x[i]=max(x[i],y[j]);
      y[i]=min(y[i],x[j]);
    }
  }
  cout<<x[0]<<endl;
}

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

const int N = 5002 , M = 203;
typedef long long int64;

int n , m;
int64 dis[N];
int happy[N][M] , l[N][M] , r[N][M] , sta[N] , top;
int64 ans[N][N];

int main()
{
	scanf("%d %d" , &n , &m);
	for(int i = 2 ; i <= n ; i ++)
	{
		scanf("%lld" , dis + i);
		dis[i] += dis[i - 1];
	}
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= m ; j ++)
		{
			scanf("%d" , &happy[i][j]);
			l[i][j] = 1;
			r[i][j] = n;
		}
	for(int j = 1 ; j <= m ; j ++)
	{
		top = 0;
		for(int i = 1 ; i <= n ; i ++)
		{
			while(top && happy[sta[top]][j] < happy[i][j])
			{
				r[sta[top]][j] = i - 1;
				top --;
			}
			l[i][j] = sta[top] + 1;
			sta[++top] = i;
		}
	}
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= m ; j ++)
		{
			int &x1 = l[i][j] , &x2 = i;
			int &y1 = i , &y2 = r[i][j];
			int &w = happy[i][j];
			
			ans[x2 + 1][y2 + 1] += w;
			ans[x1][y2 + 1] -= w;
			ans[x2 + 1][y1] -= w;
			ans[x1][y1] += w;
		}
	int64 res = 0;
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= n ; j ++)
			ans[i][j] += ans[i - 1][j];
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= n ; j ++)
			ans[i][j] += ans[i][j - 1];
	for(int i = 1 ; i <= n ; i ++)
		for(int j = i ; j <= n ; j ++)
			res = max(res , ans[i][j] - dis[j] + dis[i]);

	cout << res << endl;
}

Measured memory_bytes: 207616
#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORE(i,a,b) for(i=a;i<=b;i++)
#define ll long long
#define f first
#define se second
#define pb push_back
using namespace std;
typedef vector<long long int> vec;
// ll md=1e9+7;
// ll MAX=1e18;
//strtobin(char *s,int *a){ int w; FORE(w,0,strlen(s)){a[w]=s[w]-'0'};}
// ll power(ll x,ll y,ll p)
// {   if (y == 0)
//         return 1;
//     else if (y % 2 == 0)
//         return ((power(x,y / 2,p)%p) * (power(x, y / 2,p)%p))%p;
//     else
//         return (x * ((power(x,y / 2,p)%p) * (power(x,y / 2,p))%p))%p;
// }
// ll ce(ll x,ll y)
// { if(x%y==0)
// 	{
//        return (x/y);
// 	}else{
// 		return (x/y)+1;
// 	}
 
// }
int main()
{

	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
vector<ll>v(10);
ll a[10]={0};ll i,n,x;v[0]=-1;
for(i=1;i<=9;i++)
{ 
  cin>>v[i];
}
cin>>n;
vector<ll>b(n);
for(i=0;i<n;i++)
{ cin>>b[i];
  
}ll y;
for(i=0;i<n;i++)
{
  y=find(v.begin(),v.end(),b[i])-v.begin();
 if(y==10){continue;}else{
  a[y]=1;
 }
}
for(i=1;i<=3;i++)
{
  if(a[i]==1&&a[i+3]==1&&a[i+6]==1)
  {
    cout<<"Yes"<<endl;
return 0;  
}

}
for(i=1;i<=7;i+=3)
{
  if(a[i]==1&&a[i+1]==1&&a[i+2]==1)
  {
    cout<<"Yes"<<endl;
return 0;  
}

}
if((a[1]==1&&a[5]==1&&a[9]==1)||(a[7]==1&&a[5]==1&&a[3]==1))
{cout<<"Yes"<<endl;return 0;

}
cout<<"No"<<endl;





return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n;
	cin >> n;
	Array a(3 * n, 0);
	REP(i, 3*n)cin >> a[i];

	Array max(n+1, 0), min(n+1, 0);
	priority_queue<ll> que;
	
	REP(i, n) {
		max[0] += a[i];
		que.push(-a[i]);
	}

	REP(i, n) {
		
		que.push(-a[n+i]);
		ll aa = que.top();
		que.pop();
		max[i + 1] = max[i] + a[n+i] + aa;
	}

	priority_queue<ll> que2;

	REP(i, n) {
		
		min[n] += a[2*n+i];
		que2.push(a[2*n+i]);
	}

	REP(i, n) {
		//cout << i << " ok" << endl;
		que2.push(a[2 * n - 1 - i]);
		ll aa = que2.top();
		que2.pop();
		min[n - 1 - i] = min[n - i] + a[2 * n - 1 - i] - aa;
	}

	ll ans = -INF;
	REP(i, n + 1) {
		chmax(ans, max[i] - min[i]);
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
	int N;
	scanf("%d",&N);
	
	int L[2*N];
	for(int i=0;i<2*N;i++){
		scanf("%d",&L[i]);
	}
	
	sort(L,L+2*N);

	
	int count=0;
	for(int i=0;i<2*N;i+=2){
		count+=L[i];
	}
	
	printf("%d",count);
	
	return 0;
}

Measured memory_bytes: 256
if __name__=='__main__':
  sums=0
  num=[x for x in range(1,4)]
  S=list(map(int,input()))
  answer=[S[0],'a',S[1],'b',S[2],'c',S[3]]
  for i in range(1<<3):
    output=[]
    for j in range(3):
      if ((i>>j)&1)==1:
        output.append(num[j])
    plus=[S[o] for o in output]
    sabun=list(filter(lambda x: x not in output, num))
    mins=[S[m] for m in sabun]
    if sum(plus)-sum(mins)+S[0]==7:
      for o in output:
        answer[2*o-1]='+'
      for m in sabun:
        answer[2*m-1]='-'
      answer=map(str, answer)
      print(''.join(answer)+'=7')
      break

    

Measured memory_bytes: 3064
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict
from fractions import gcd
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	if N % 2 == 0:
		D = defaultdict(int)
		n = int(N // 2)
		D[2] += n
		for i in range(1, 42):
			D[2] += int(n // (2 ** i))
		for i in range(1, 42):
			D[5] += int(n // (5 ** i))
		print(min(D[2], D[5]))

	else:
		print(0)

if __name__ == '__main__':
	main()

Measured memory_bytes: 63980
N, K = map(int, input().split())

ans = max(N-K+1, 0) / N

up_bound = K-1
low_bound = up_bound // 2
now_zoom = 1/2
while up_bound != 0:
    if up_bound <= N:
        ans += now_zoom * (up_bound - low_bound) / N
    elif low_bound <= N:
        ans += (N-low_bound)*now_zoom/N
    up_bound = low_bound
    low_bound = up_bound // 2
    now_zoom *= 1/2
print(ans)


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

int main() {
  int N,count=2;
  cin>>N;
  vector<char> S(N);
  rep(i,N) cin>>S.at(i);
  sort(S.begin(),S.end());
  S.push_back(10);
  vector<int> num;
  S.push_back(10);
  for(int i=1;i<N+1;i++){
    if(S.at(i)==S.at(i-1)) count++;
    else{
      num.push_back(count);
      count=2;
    }
  }
  int64_t ans=1;
  rep(i,num.size()){
    ans*=num.at(i);
    ans%=MOD;
  }
  cout<<ans-1;
}



Measured memory_bytes: 3688
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

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




// ***************************************


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

    if (N % 1000 == 0) cout << 0 << endl; 
    else{
        int x = N / 1000 + 1;
        cout << 1000 * (x ) - N << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n;
    while (T--){
        cin >> n;
        cout << 1 - n << "\n";
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
signed main(){
	int n,ans=0;
  	char c[55];
  	cin>>n;
  	for(int i=0;i<n;i++)
      cin>>c[i];
  	for(int i=0;i<n-2;i++){
      if(c[i] == 'A' && c[i+1] == 'B' && c[i+2] == 'C')
        ans++;
    }
  	cout<<ans;
  	return(0);
}

Measured memory_bytes: 256
void main() {
  auto ip = readAs!(int[]), X = ip[0], A = ip[1];
  if(X < A) writeln(0);
  else writeln(10);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long int i32;
typedef unsigned long int u32;
typedef long long int i64;
typedef unsigned long long int  u64;
typedef pair<i32, i32> PII;
typedef vector<i32> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<i32, i32> MPII;
typedef set<i32> SETI;
typedef multiset<i32> MSETI;
#define IN(x) cin >> x;
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define BTW(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define PF push_front
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
// }}}

int main() {
    int N, K;
    IN(N);IN(K);
    auto xys = vector<PII>(N);;
    REP(i, N) {
        IN(xys[i].first);IN(xys[i].second);
    }
    u64 ans = (u64)-1;
    REP(i, N)REP(j, N)REP(k, N)REP(l, N) {
        i32 x1, x2, y1, y2;
        x1 = x2 = xys[i].first;
        y1 = y2 = xys[i].second;
        amax(x1, xys[j].first);
        amax(x1, xys[k].first);
        amax(x1, xys[l].first);
        amin(x2, xys[j].first);
        amin(x2, xys[k].first);
        amin(x2, xys[l].first);
        amax(y1, xys[j].second);
        amax(y1, xys[k].second);
        amax(y1, xys[l].second);
        amin(y2, xys[j].second);
        amin(y2, xys[k].second);
        amin(y2, xys[l].second);
        u32 counter = 0;
        REP(m, N) {
            auto x = xys[m].first;
            auto y = xys[m].second;
            if((x1-x)*(x2-x) <= 0 && (y1-y)*(y2-y) <= 0) {
                counter++;
            }
        }
        if(counter >= K) {
            u64 area = (x1-x2) * (y1-y2);
            amin(ans, area);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
count = 0
while True:
    for i in range(n):
        fin = True
        if a[i] % 2 == 0:
            a[i] = (a[i] / 2)
        else:
            fin = False
            break
    if fin:
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int total = 0;
		double intaverage,doubleaverage;
		int finalaverage;
		int minvalue = 0;
		for(int i = 0;i < n;i++) {
			x[i] = sc.nextInt();
			total += x[i];
		}
		intaverage = total / n;
		doubleaverage = (double)total/n;

		if(intaverage + 0.5 < doubleaverage) {
			finalaverage = (int)intaverage + 1;
		}else {
			finalaverage = (int)intaverage;
		}
		for(int i = 0;i < n;i++) {
			if(minvalue > x[i]) {
				minvalue += (int)Math.pow(finalaverage-x[i], 2);
			}else {
				minvalue += (int)Math.pow(x[i]-finalaverage, 2);
			}
		}
		System.out.println(minvalue);
	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String price = sc.next();
		int pricenum = Integer.parseInt(price);
		int num = sc.nextInt();
		String[] ng = new String[num];
		for(int i = 0; i < num; i++) {
			ng[i] = sc.next();
		}
		boolean isOk = true;

		for(int i = pricenum; i < 100000; i++) {
			for(int j = 0; j < num; j++) {
				if(Integer.toString(i).contains(ng[j])) {
					isOk = false;
					break;
				}
			}
			if(isOk) {
				System.out.println(i);
				return;
			}
			isOk = true;
		}
	}
}

Measured memory_bytes: 32196
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		  try(Scanner sc = new Scanner(System.in)) {
			  int count=0;
			  while(sc.hasNext()) {
				  String str=sc.nextLine();
				  boolean tf=true;
				  for(int i=0; i<str.length(); i++) {
					  if(str.charAt(i)!=str.charAt(str.length()-1-i)) {
						  tf=false;
					  }
				  }
				  if(tf) count++;
			  }
			  System.out.println(count);
		  }
	}
}


Measured memory_bytes: 26132
#include <iostream>
using namespace std;
using ll=long long;
ll n,d,a[200000],b[200000],m=1LL<<60,loc,ans;
int main(void){
  cin>>n>>d;
  for(int i=0;i<n;i++){
    cin>>a[i];
    if(m>a[i]){m=a[i];loc=i;}
    if(i)b[i]=min(a[i],b[i-1]+d);
    if(i==0)b[i]=a[i];
  }
  for(int i=n-1;i;i--){
    b[i-1]=min(b[i-1],b[i]+d);
  }
  for(int i=loc-1;i>=0;i--){
    ans+=a[i]+b[i+1]+d;
  }
  for(int i=loc+1;i<n;i++){
    ans+=a[i]+b[i-1]+d;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
complex<double> P;

struct SAComp{
	const int h;
	const vector<int> &g;
	SAComp(int h,vector<int> &g) : h(h), g(g) {}
	bool operator ()( int a,int b){
		return a == b ? false : g[a] != g[b] ? g[a] < g[b] : g[a+h] < g[b+h];
	}
};

vector<int> buildSA(string &t){
	const int n = t.size();
	vector<int> g(n+1),b(n+1),v(n+1);
	for(int i = 0 ; i < n + 1 ; i++)
		v[i] = i, g[i] = t[i];
	b[0] = 0;
	b[n] = 0;
	sort(v.begin(),v.end(),SAComp(0,g));
	for(int h = 1 ; b[n] != n ; h *= 2 ){
		SAComp comp(h,g);
		sort(v.begin(),v.end(),comp);
		for(int i = 0 ; i < n ; i++) b[i+1] = b[i] + comp(v[i],v[i+1]);
		for(int i = 0 ; i < n + 1 ; i++ ) g[v[i]] = b[i];
	}
	return v;
}

vector<int> seg[100010];

// v??\???
int get(int x,int v){
	x+=2;
	int ans = 0;
	for(int i = x ; i > 0 ; i -= i & -i ){
		ans += upper_bound(seg[i].begin(),seg[i].end(),v) - seg[i].begin();
	}
	return ans;
}
void add(int x,int v){
	x+=2;
	for(int i = x ; i < 100010 ; i += i & -i ){
		seg[i].push_back(v);
	}
}


int N;

bool bad(string &s,int p,string &t){
	return s.substr(p,t.size()) < t;
}
bool good(string &s,int p,string &t){
	return s.substr(p,t.size()) == t;
}
pair<int,int> getSeg(string &s,const vector<int> &sa,string &t){
	int l = 0 , r = sa.size() - 1;
	while( l != r ){
		int m = (l+r) / 2;
		if( bad(s,sa[m],t) ) l = m+1;
		else r = m;
	}
	if( !good(s,sa[l],t) ) return {-1,-1};
	int startPos = l;
	r = sa.size() - 1;
	while( l != r ){
		int m = (l+r+1) / 2;
		if( good(s,sa[m],t) ) l = m;
		else r = m - 1;
	}
	int endPos = r;
	return {startPos,endPos};
}

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

	string S;
	cin >> S;
	auto sa = buildSA(S);
	for(int i = 0 ; i < sa.size() ; i++){
		add(i,sa[i]);
	}
	for(int i = 0 ; i < 100010 ; i++)
		sort(seg[i].begin(),seg[i].end());
	//for(int i = 0 ; i < sa.size() ; i++){
	//	cout << i << ": " << S.substr(sa[i]) << endl;
	//}
	int Q;
	cin >> Q;
	for(int i = 0 ; i < Q ; i++){
		int l,r;
		string m;
		cin >> l >> r >> m;
		--l;
		r -= m.size() - 1;
		auto seg = getSeg(S,sa,m);
		//cerr << "[" << seg.first << " " << seg.second << "]" << "|" << l << " " << r << endl;
		if( l > r || seg.first == -1 ) cout << 0 << endl;
		else{
			cout << get(seg.second,r) - get(seg.first-1,r) - get(seg.second,l) + get(seg.first-1,l) << endl;
		}
	}

}

Measured memory_bytes: 11492
#A

#デバッグ
debug=1
def pront(*n):
    if debug==1:
        print(n)
        
#10**9+7を底とした処理

base=10**9+7

def add(a,b):#a+b
    return (a+b)%base

def sub(a,b):#a-b
    return (a-b)%base

def multi(a,b):#a*b
    return (a*b)%base

def exp(a,b):#a**b
    x=1
    c=a
    d=b
    while d!=0:
        if d%2==1:
            x=multi(x,c)
        c=(c**2)%base
        d=d//2
    return x

def div(a,b):#a/b
    return(multi(a,exp(b,base-2)))

#入力

S,W=map(int,input().split())


#処理


if S<=W:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 9224
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    set<double> swtr, ssgr;
    int i, j;
    double ans_wtr=0, ans_sgr=0;
    double a, b, c, d, e, f, ans=0;
    cin >> a >> b >> c >> d >> e >> f;
    
    for(i=0; i<=f/(100*a); i++) {
        for(j=0; 100*a*i+100*b*j<=f; j++)
            swtr.insert(100*a*i+100*b*j);
    }
    
    for(i=0; i<=f/c; i++) {
        for(j=0; c*i+d*j<=f; j++) {
            ssgr.insert(c*i+d*j);
        }
    }
    
    vector<double>wtr = vector<double>(swtr.begin(), swtr.end());
    vector<double>sgr = vector<double>(ssgr.begin(), ssgr.end());
    
    
    
    for(i=0; i<wtr.size(); i++) {
        for(j=0; j<sgr.size(); j++) {
            if(i==0 && j==0)
                continue;
            if(wtr[i]+sgr[j]<=f && e*wtr[i]>=100*sgr[j]) {
                if(sgr[j]/(wtr[i]+sgr[j])>=ans) {
                    ans=sgr[j]/(wtr[i]+sgr[j]);
                    ans_wtr=wtr[i];
                    ans_sgr=sgr[j];
                }
            }
        }
    }
    cout << ans_wtr+ans_sgr << " " << ans_sgr << endl;
}

Measured memory_bytes: 384
S = list(input())
key = 'keyence'
ans = 'NO'
if len(S) == 7:
    if ''.join(S) == key:
        print('YES')
        exit()
    else:
        print('NO')
        exit()
for i in range(len(S)):
    tmp = S[0: i] + S[i + len(S) - 7:]
    if key == ''.join(tmp):
        ans = 'YES'
        break
print(ans)

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    for (int i = K; i < N; i++)
    {
        if (A[i - K] < A[i])
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

int main() {

    char a[11];
    char b[11];
    char c[11];

    scanf("%s %s %s", a, b, c);

    int l1 = strlen(a);
    int l2 = strlen(b);

    if(a[l1-1]==b[0] && b[l2-1]==c[0]){
        printf("YES");
    }else{
        printf("NO");
    }



    return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=60;
int n;
ll a[N],x[N],y[N];

bool ok() {
	for (int i=0;i<n;i++) {
		if (x[i]!=0) return false;
	}
	return true;
}

int main() {
	scanf("%d",&n);
	for (int i=0;i<n;i++) {
		scanf("%lld",a+i);
		y[i]=a[i]%n;
		x[i]=(a[i]-y[i])/n;
	}
	ll ans=0;
	while (!ok()) {
		ll sum=0;
		for (int i=0;i<n;i++) sum+=x[i];
		ans+=sum;
		for (int i=0;i<n;i++) {
			a[i]=y[i]+sum-x[i];
			y[i]=a[i]%n;
			x[i]=(a[i]-y[i])/n;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int a[51][51], b[51][51];
    int n,m;
    char c;

    scanf("%d%d\n",&n,&m);

    for (int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            c = getchar();
            if (c == '#')
                a[i][j] = 1;
            else
                a[i][j] = 0;
        }
        c = getchar();
    }
    for (int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            c = getchar();
            if (c == '#')
                b[i][j] = 1;
            else
                b[i][j] = 0;
        }
        c = getchar();
    }

    for (int i = 0; i <= n-m; i++) {
        for (int j = 0; j <= n-m; j++) {
            if (a[i][j] == b[0][0]) {
                int flag = 1;
                for (int y = 0; y < m; y++) {
                    for (int x = 0; x < m; x++) {
                        if (a[i+y][j+x] != b[y][x]) {
                            flag = 0;
                        }
                        if (flag == 0) break;
                    }
                    if (flag == 0) break;
                }
                if (flag == 1) {
                    puts("Yes");
                    return 0;
                }
            }
        }
    }

    puts("No");

    return 0;
}


Measured memory_bytes: 128
package main

import(
    "fmt"
    "sort"
    "strings"
    "math"
)



func main() {
    var n int
    var t,a float64
    fmt.Scan(&n,&t,&a)
    ans := 0
    k := 100000.0
    for i:=0; i<n; i++{
        var b float64
        fmt.Scan(&b)
        if math.Abs(a-(t-b*0.006)) < k{
            k = math.Abs(a-(t-b*0.006))
            ans = i+1
        }
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
#include <stdio.h>

typedef struct node_t {
	int val;
	struct node_t *lch, *rch;
} node;

node* new_node(int val) {
	static int it = 0;
	static node pool[200000];
	pool[it] = (node) { val, NULL, NULL };
	return &pool[it++];
}

node* meld(node* a, node* b) {
	node* tmp;
	if (!a) return b;
	if (!b) return a;
	if (a->val < b->val) {
		tmp = a;
		a = b;
		b = tmp;
	}
	a->rch = meld(a->rch, b);
	tmp = a->lch;
	a->lch = a->rch;
	a->rch = tmp;
	return a;
}

node* pq[1000];

int main(void)
{
	int n, q, com, t, x;
	scanf("%d%d", &n, &q);
	while (q--) {
		scanf("%d%d", &com, &t);
		if (com == 0) {
			scanf("%d", &x);
			pq[t] = meld(pq[t], new_node(x));
		}
		else if (com == 1) {
			if (pq[t]) printf("%d\n", pq[t]->val);
		}
		else {
			if (pq[t]) pq[t] = meld(pq[t]->lch, pq[t]->rch);
		}
	}
	return 0;
}



Measured memory_bytes: 6204
n=int(input())
l=list(map(int, input().split()))
import collections

c = collections.Counter(l)

# Counter({'a': 4, 'c': 2, 'b': 1})
for i in range(1, n+1):
  if i in c:
    print(c[i])
  else:
    print(0)

Measured memory_bytes: 114728
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    LL x,y,a,b,c;cin >> x >> y >> a >> b >> c;
    vector<LL> p(a),q(b),r(c);
    for (int i = 0; i < a; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> q[i];
    }
    for (int i = 0; i < c; i++) {
        cin >> r[i];
    }
    sort(RALL(p));
    sort(RALL(q));
    sort(RALL(r));
    priority_queue<LL,vector<LL>,greater<LL>> pq;
    LL ans = 0;
    for (int i = 0; i < x; i++) {
        pq.push(p[i]);
        ans += p[i];
    }
    for (int i = 0; i < y; i++) {
        pq.push(q[i]);
        ans += q[i];
    }
    for (int i = 0; i < c; i++) {
        if(pq.top() < r[i]){
            ans += r[i] - pq.top();
            pq.push(r[i]);
            pq.pop();
        }
        else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4724
#!/usr/bin/env python3
import sys
input = sys.stdin.readline


s = [int(item) for item in list(input().rstrip())]
s.reverse()

mod2019 = []
base = 1
for item in s:
    mod2019.append(base * item % 2019)
    base = base * 10 % 2019

cumsum = [0]
for item in mod2019:
    cumsum.append((cumsum[-1] + item) % 2019)

count = [0] * 2020
for item in cumsum:
    count[item] += 1
ans = 0
for cnt in count:
    ans += cnt * (cnt - 1) // 2
print(ans)

Measured memory_bytes: 113584
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 1;


    if (A[0] == 0) {
        cout << 0 << endl;
        return 0;
    }
    ll X = 1000000000000000000;
    rep(i, N) {
        if (A[i] > X / ans) {
            cout << -1 << endl;
            return 0;
        }
        ans *= A[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3992
n, k = map(int, input().split())
arr = [0 for _ in range(n)]

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for v in a:
        arr[v-1] += 1
ans = 0
for i in arr:
    if i == 0:
        ans += 1
print(ans)


Measured memory_bytes: 67672
#include<stdio.h>

int main()
{
	int a,b,c,d,e,f;
	scanf("%d %d %d",&a,&b,&c);
	d=a+b;e=a+c;f=b+c;
	if(d<=e&&d<=f)
	{
		printf("%d\n",d);
	}
	else if(e<=d&&e<=f)
	{
		printf("%d\n",e);
	}
	else if(f<=d&&f<=e)
	{
		printf("%d\n",f);
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int N = input.nextInt();
        int left;
        int start = -1;
        int result = 0;

        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            list.add(input.nextInt());
        }
        left = 1;

        for (int i = 0; i < N; i++) {
            if (list.get(i) == 1){
                start = i;
                result = i;
                break;
            }
        }

        if (start == list.size() - 1){
            result = 0;
        }else if (start != -1){
            for (int i = start + 1; i < N; i++){
                if (left + 1 != list.get(i)){
                    result ++;
                }else {
                    left++;
                }
            }
        }else {
            result = -1;
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 84408
#include <iostream>
#include <algorithm>
#include <vector>
#include <string.h>
#include <queue>
#include <iomanip>
using namespace std;
#define mod (long)(100000)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl(long(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr start, itr goal){ for(auto i = start; i != goal; i++){ cin >> (*i); } }
template<class T> T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }} template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<long> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } long C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };


int main(){
    int A, B;
    cin >> A >> B;
    if(B % A == 0){
        cout << A + B << endl;
    }else{
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
#include <numeric>
#include <utility>
#include<math.h>
#include<functional>
#include<queue>
#include<sstream>
#include<stack>
#include<algorithm>

int solve(int a,int b,int h){
    std::cout<<(a+b)*h/2;
    return 0;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    int a,b,h;
    std::cin>>a>>b>>h;
    return solve(a,b,h);
}


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

using namespace std;

int
main(void){
	vector<int> vec(5);
	for(int i = 0; i < 5; i++) cin >>vec[i];
	for(int i = 0; i < 5; i++){
		if(vec[i] == 0) cout << i + 1;
	}
}

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

using namespace std;

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;

#define INF (1e9)

// テンプレート関数
#define REP(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

/*
この問題の概要
ボールが二次元配列にある。
任意のp,qを決めて、ボールの座標(a,b)に対して、(a-p, b-q)が連続するときコストがかからないとする。
その場合の最小コストを求める。最初に絶対1かかる。

考え方
p,qをベクトルと考える。
ボールの座標に対して、設定したベクトルを割り当てる。
そのベクトルの数を数えて、Nから引く。
ansの最大数はＮ。

または
すべてのボール座標の差分を求めて、その数を元に全探索を行い、最小になるコストを求める。
*/

int main()
{
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    int ans = N;

    rep(i, N) cin >> x[i] >> y[i];

    rep(i, N) {
        rep(j, N) {
            if(i == j) continue;
            // すべてのボールの差分を求める。
            // 基本的にボールの差分しかp,qになりうる値はない。
            int p = x[i] - x[j];
            int q = y[i] - y[j];
            int cnt = 0;

            rep(k, N) {
                rep(l, N) {
                    // 差分とあっているか確かめる
                    if (x[l] - x[k] == p && y[l] - y[k] == q) {
                        ++cnt;
                    }
                }
            }
            ans = min(ans, N - cnt);
        }
    }

    if (N == 1)
    {
        cout << "1";
    }
    else
    {
        cout << ans;
    }
}

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

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define FS first
#define SE second

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal var
//------------------------------------------
int N,M;
bool visited[100];
bool world[100][100];



int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int A,B;
  cin >> A >> B;
  int ans;
  REP(i,2){
    ans += max(A,B);
    A>B?A--:B--;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    int a=111;
    for(int i=1;i<=9;i++){
        if(a*(i-1)<n && n<=a*i){
            cout<<a*i<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>

using namespace std;

int main(){
  int N,W[1000],x=0,y=0,w,a=1000;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> W[i];
  }
  for(int i=N;i<1001;i++){
    W[i]=0;
  }
  for(int i = 1;i < N;i++){
    for(int j=0;j<i;j++){
      x = x + W[j];
    }
    for(int j = i;j<N;j++){
      y = y + W[j];
    }
    if(0 <= (x-y)){
      w = x-y;
    }else{
      w = y-x;
    }


  a = min(a,w);

  x=0;
  y=0;
  }

      cout << a <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
    int n,x,a[110];
    scanf("%d%d",&n,&x);
    int i,sum=0;
    for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            sum=sum+a[i];
        }
        int remains,cont=0;
        if(x>=sum)
        cont=n;
        remains=x-sum;
        int mi=a[0];
        for(i=0;i<n;i++)
        {
           if(a[i]<mi)
                mi=a[i];
        }

   cont=cont+remains/mi;
   printf("%d",cont);

    return 0;
}


Measured memory_bytes: 256
a = gets.to_i

x=gets.chomp.split(" ").map(&:to_i);

answer=nil

min=x.min
max=x.max

min.upto(max) do |p|
  sum=0
  x.each do |x1|
    sum+=(x1 - p)**2
  end
  if answer==nil || answer > sum
    answer = sum
  end
end

print answer


Measured memory_bytes: 14276
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <queue>
using namespace std;
int main()
{
    long long n;
    long long max;
    while(~scanf("%lld",&n))
    {
        max=1;
        while(max* max<=n)
            max=max+1;
    printf("%lld\n",(max-1)*(max-1));
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
#define For(i,n) for(int i=1;i<=n;i++)
#define Fork(i,k,n) for(int i=k;i<=n;i++)
#define ForkD(i,k,n) for(int i=n;i>=k;i--)
#define Rep(i,n) for(int i=0;i<n;i++)
#define ForD(i,n) for(int i=n;i;i--)
#define RepD(i,n) for(int i=n;i>=0;i--)
#define Forp(x) for(int p=pre[x];p;p=next[p])
#define Forpiter(x) for(int &p=iter[x];p;p=next[p])  
#define Lson (o<<1)
#define Rson ((o<<1)+1)
#define MEM(a) memset(a,0,sizeof(a));
#define MEMI(a) memset(a,0x3f,sizeof(a));
#define MEMi(a) memset(a,128,sizeof(a));
#define MEMx(a,b) memset(a,b,sizeof(a));
#define INF (0x3f3f3f3f)
#define F (1000000007)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int> 
#define pi pair<int,int>
#define SI(a) ((a).size())
#define Pr(kcase,ans) printf("Case #%d: %lld\n",kcase,ans);
#define PRi(a,n) For(i,n-1) cout<<a[i]<<' '; cout<<a[n]<<endl;
#define PRi2D(a,n,m) For(i,n) { \
						For(j,m-1) cout<<a[i][j]<<' ';\
						cout<<a[i][m]<<endl; \
						} 
#pragma comment(linker, "/STACK:102400000,102400000")
#define ALL(x) (x).begin(),(x).end()
#define gmax(a,b) a=max(a,b);
#define gmin(a,b) a=min(a,b);
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
ll mul(ll a,ll b){return (a*b)%F;}
ll add(ll a,ll b){return (a+b)%F;}
ll sub(ll a,ll b){return ((a-b)%F+F)%F;}
void upd(ll &a,ll b){a=(a%F+b%F)%F;}
inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
	while(isdigit(ch)) { x=x*10+ch-'0'; ch=getchar();}
	return x*f;
} 
int main()
{
//	freopen("A.in","r",stdin);
//	freopen(".out","w",stdout);
	char s[1000];
	cin>>s;
	int n=strlen(s);
	Rep(i,n-8) cout<<s[i];cout<<endl;
	
	return 0;
}


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

int main() {
    //100以下で2をk乗を満たす数は1,2,4,8,16,32,64の7種類のみ
    //よって、この7種類のうち、N以下で最も大きいものを出力すれば良い
    int N;
    cin >> N;
    int ans;
    for (int i=0; i<8; i++) {
        if (pow(2, i) == N) {
            ans = pow(2, i);
            break;
        } else if (pow(2, i) > N) {
            ans = pow(2, i-1);
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && b == c) cout << "Yes" << endl;
  else cout << "No" << endl;  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++) a[i] = sc.nextInt();
		Arrays.sort(a);
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}
}



Measured memory_bytes: 26292
s = str(input())

if set(list(s)) <= {'A', 'T', 'G', 'C'}:
  print(len(s))
  exit()

ans = 0

for i in range(len(s)):
  for j in range(i, len(s)+1):
    sp = s[i:j]
    sp = list(sp) 
    if set(sp) <= {'A', 'T', 'G', 'C'}:
      ans = max(ans, len(sp))
print(ans)
      

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.141592653289793;
using namespace std;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
#define lld long double
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> vp;
typedef vector<tuple<ll, ll, ll>> vt;
//vector<vector<ll>> vv(n, vector<ll>(n));

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	x -= (y + 2 * z);
	if (x < 0) cout << 0 << endl;
	else cout << x / (y + z) + 1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



int main() {
	int n, q;
	cin >> n >> q;
	vector<ll> p(q), x(q);
	vector<vector<int>> to(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}
	rep(i, q) {
		cin >> p[i] >> x[i];
	}
	vector<ll> plus(n);
	rep(i, q) {
		plus[p[i] - 1] += x[i];
	}


	vector<int> al(n);

	stack<int> st;
	st.push(0);
	al[0] = 1;
	while (st.size()) {
		int t = st.top();
		st.pop();
		rep(i, to[t].size()) {
			int next = to[t][i];
			if (al[next] == 1) {
				continue;
			}
			st.push(next);
			plus[next] += plus[t];
			al[next] = 1;
		}
	}
	rep(i, n - 1)
	{
		cout << plus[i] << " ";
	}
	cout << plus[n - 1] << endl;
}



Measured memory_bytes: 20212