akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

  ll A[200010];
  ll L[200010], R[200010];

int main() {
  ll n; cin >> n;
  Rep(i, 1, n) cin >> A[i];
  Rep(i, 1, n){
    if(A[i]+i <= n) L[A[i]+i] ++;
    if(i - A[i] >= 1) R[i-A[i]] ++;
  }
  ll ans = 0;
  Rep(i, 1, n){
    ans += L[i]*R[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8284
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<int> v;
  int a;
  for(int i =0; i<3; i++)
  {
    cin>>a;
    v.push_back(a);
  }
  int sum = 0;
  sort(v.begin(), v.end());
  for(int i = 0; i<2; i++)
  {
    sum = sum + (v[i+1] - v[i]);
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N, A, B;
        N = scanner.nextInt();
        A = scanner.nextInt();
        B = scanner.nextInt();
        if (N == 1) {
            if (A == B) {
                System.out.println("1");
            } else {
                System.out.println("0");
            }
        } else {
            if (A > B) {
                System.out.println("0");
            } else {
                System.out.println((long)(B - A) * (N - 2) + 1);
            }
        }
    }
}

Measured memory_bytes: 21716
#include<stdio.h>

int main(void)
{
   int S,h,m,s,a;
   scanf("%d",&S);
   h=S/3600;
   a=S%3600;
   m=a/60;
   s=a%60;
   printf("%d:%d:%d\n",h,m,s);
  
   return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> box(n,10);
  int ans = 0;
  rep(i,m){
    int s;
    int c;
    cin >> s >>c;
    s--;
    if(s==0&&c==0&&n!=1) ans = -1;
    if(box[s]==c)continue;
    if(box[s]==10)box[s]=c;
    if(box[s]!=c)ans = -1;
  }
  if(n==1){
    if(ans==-1) cout << -1 << endl;
    else if(box[0]==10)cout << 0 << endl;
    else cout << box[0] << endl;
    return 0;
  }
  rep(i,n){
    if((i==0)&&box[i]==10)box[i]=1;
    if(box[i]==10)box[i]=0;
  }
  if(ans==-1)cout<<-1 <<endl;
  else {
    rep(i,n) cout << box[i];
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;int64_t N,P,p,i,r,v;string S;main(){cin>>N>>P>>S;if(P==2||P==5){for(i=0;i<N;i++)if(!((S[i]-8)%P))r+=i+1;cout<<r;exit(0);}map<int,int>m;m[0]=p=1;for(i=N;i--;)v=(v+(S[i]-48)*(p=(p*10)%P))%P,r+=m[v]++;cout<<r;}

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

int a,b,c,d,e,f;
int x;
int i,j;

using namespace std;

int main(void){
	char s[4];
	cin >> s;
	
	char c1 = '\0', c2 = '\0';
	int b1 = 0, b2 = 0;
	
	for(i = 0; i < 4; ++i){
		if(s[i] == c1){
			b1++;
		}else if(s[i] == c2){
			b2++;
		}else{
			if(c1 == '\0'){
				c1 = s[i];
				b1++;
			}else if(c2 == '\0'){
				c2 = s[i];
				b2++;
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
	}
	if(b1 == 2 && b2 == 2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
//typedef __int128_t Int;
#define DBG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define loop(n) rep(loop,(0),(n))
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);

  int A, B; cin >> A >> B;

  int x=B-A;
  cout<<x*(x+1)/2-B<<endl;


    return 0;
}


Measured memory_bytes: 256
import sys
import bisect

s = input()
t = input()

existing_alphabets = [[]for _ in range(26)]

for i in range(len(s)):
    existing_alphabets[ord(s[i])-97].append(i)

numbered_t = [0]*len(t)
for i in range(len(t)):
    numbered_t[i] = (ord(t[i])-97)

# confirmation each necessary alphabet exists
all_necessary_alphabets = set()
for i in range(len(t)):
    all_necessary_alphabets.add(numbered_t[i])

for necessary_alphabet in all_necessary_alphabets:
    if len(existing_alphabets[necessary_alphabet])==0:
        print(-1)
        sys.exit()

# counting order process
now = -1
cycled = 0
for i in range(len(numbered_t)):
    existing_alphabet = existing_alphabets[numbered_t[i]]
    can_insert = bisect.bisect_right(existing_alphabet,now)
    if can_insert == len(existing_alphabet):
        can_insert = 0
        cycled += 1
    now = existing_alphabet[can_insert]

ans = len(s) * cycled + now + 1
print(ans)

Measured memory_bytes: 46448
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;

int main() {
    double L;
    cin >> L;
    L /= 3.0;
    cout << fixed <<setprecision(10) << L * L * L << endl;
}


Measured memory_bytes: 256
using System.Linq;
using static System.Math;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G() => ReadLine().Split().Select(int.Parse).ToArray();
	int P(int x) => x * x;
	public K()
	{
		var N = int.Parse(ReadLine());
		var t = G();
		var v = G();
		var dp = new int[N + 1][];
		dp[0] = new[]{ 0 };
		for (var n = 0; n < N; n++)
		{
			dp[n + 1] = new int[Min(dp[n].Length + 2 * t[n], 2 * v[n] + 1)];
			for (var w = 0; w < dp[n + 1].Length; w++)
			{
				for (var u = 0; u < dp[n].Length; u++)
				{
					if (u > 2 * v[n] || u - 2 * t[n] > w || u + 2 * t[n] < w) continue;
					int x = 2 * t[n] + u + w, run;
					if (x >= 4 * v[n]) run = 2 * (8 * t[n] * v[n] - P(2 * v[n] - u) - P(2 * v[n] - w));
					else run = P(x) - 2 * (P(u) + P(w));
					dp[n + 1][w] = Max(dp[n + 1][w], dp[n][u] + run);
				}
			}
		}
		WriteLine(dp[N][0] / 16m);
	}
}


Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9, pi = acos(-1.0);
namespace std {
	bool operator<(const Point &lhs, const Point &rhs) {
		if (lhs.real() < rhs.real() - eps) return true;
		if (lhs.real() > rhs.real() + eps) return false;
		return lhs.imag() < rhs.imag();
	}
}
Point input_point() { ld x, y; cin >> x >> y; return Point(x, y); } // ????????\???
bool eq(ld a, ld b) { return (abs(a - b) < eps); } // ????????????????????????
ld dot(Point a, Point b) { return real(conj(a) * b); } // ??????
ld cross(Point a, Point b) { return imag(conj(a) * b); } // ??????

														 // ??´????????????
class Line {
public:
	Point a, b;
	Line() : a(Point(0, 0)), b(Point(0, 0)) {}
	Line(Point a, Point b) : a(a), b(b) {}
	Point operator[](const int _num) {
		if (_num == 0)return a;
		else if (_num == 1)return b;
		else assert(false);
	}
};

// ????????????
class Circle {
public:
	Point p;
	ld r;
	Circle() : p(Point(0, 0)), r(0) {}
	Circle(Point p, ld r) : p(p), r(r) {}
};

/* ??? */

// ?????¨????????\???
vector<Line> tangent_cp(Circle c, Point p) {
	vector<Line> ret;
	Point v = c.p - p;
	ld d = abs(v);
	ld l = sqrt(norm(v) - c.r * c.r);
	if (isnan(l)) { return ret; }
	Point v1 = v * Point(l / d, c.r / d);
	Point v2 = v * Point(l / d, -c.r / d);
	ret.push_back(Line(p, p + v1));
	if (l < eps) return ret;
	ret.push_back(Line(p, p + v2));
	return ret;
}

// ?????¨????????\???
vector<Line> tangent_cc(Circle c1, Circle c2) {
	vector<Line> ret;
	if (abs(c1.p - c2.p) - (c1.r + c2.r) > -eps) {
		Point center = (c1.p * c2.r + c2.p * c1.r) / (c1.r + c2.r);
		ret = tangent_cp(c1, center);
	}
	if (abs(c1.r - c2.r) > eps) {
		Point out = (-c1.p * c2.r + c2.p * c1.r) / (c1.r - c2.r);
		vector<Line> nret = tangent_cp(c1, out);
		ret.insert(ret.end(), nret.begin(), nret.end());
	}
	else {
		Point v = c2.p - c1.p;
		v /= abs(v);
		Point q1 = c1.p + v * Point(0, 1) * c1.r;
		Point q2 = c1.p + v * Point(0, -1) * c1.r;
		ret.push_back(Line(q1, q1 + v));
		ret.push_back(Line(q2, q2 + v));
	}
	return ret;
}

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	Point p = input_point(); ld r; cin >> r;
	Circle c1(p, r);
	p = input_point(); cin >> r;
	Circle c2(p, r);
	cout << tangent_cc(c1, c2).size() << endl;
	return 0;
}

Measured memory_bytes: 3472
#include<stdio.h>
#include<stdlib.h>

int main(void)
{

	int i,j,k,c;
	int n,m,m0;
	int **x,**y;
	int *tmp;
	
	while(1)
		{

			scanf("%d",&n);
			if(n==0)
				{
					break;
				}
			
			x = (int **)malloc(sizeof(int *)*(n+1));
			y = (int **)malloc(sizeof(int *)*(n+1));
			
			scanf("%d",&m0);
		
			x[0] = (int *)malloc(sizeof(int)*m0);
			y[0] = (int *)malloc(sizeof(int)*m0);
		
			for(i=0;i<m0;i++)
				{
					scanf("%d %d",&x[0][i],&y[0][i]);
				}
			for(i=0;i<m0;i++)
				{
					x[0][m0-1-i]-=x[0][0];
					y[0][m0-1-i]-=y[0][0];
				}

			for(i=1;i<=n;i++)
				{
					scanf("%d",&m);
					
					x[i] = (int *)malloc(sizeof(int)*m);
					y[i] = (int *)malloc(sizeof(int)*m);
					tmp = (int *)malloc(sizeof(int)*m);
					
					for(j=0;j<m;j++)
						{
							scanf("%d %d",&x[i][j],&y[i][j]);
						}
						
					if(m0 == m)
						{	
							c = 4;
						  while(c--)
								{  
									for(j=0;j<m;j++)
						        {
											x[i][m-1-j]-=x[i][0];
											y[i][m-1-j]-=y[i][0];
										}

									for(k=0;k<m;k++)
										{
											if(x[i][k] != x[0][k] || y[i][k] != y[0][k])
												{break;}
										}
									if(k == m){printf("%d\n",i);break;}
									
									for(j=0;j<m;j++)
						        {
											x[i][j]-=x[i][m-1];
											y[i][j]-=y[i][m-1];
										}

									for(k=0;k<m;k++)
										{
											if(x[i][m-1-k] != x[0][k] || y[i][m-1-k] != y[0][k])
												{break;}
										}

									if(k == m){printf("%d\n",i);break;}
									for(j=0;j<m;j++)
										{
											tmp[j] = x[i][j];
											x[i][j] = y[i][j];
											y[i][j] = -1*tmp[j];
										}
							  }
						}
				}
			printf("+++++\n");
		}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<iostream>
#define RI register int
#define CI const int&
using namespace std;
const int N=200;
int n,m,f[N][N][N],g[N][N][N]; char a[N][N];
int main()
{
	RI i,j,k,p,t; for (scanf("%d%d",&n,&m),i=1;i<=n;++i) scanf("%s",a[i]+1);
	for (i=1;i<=n;++i) for (j=i;j<=n;++j)
	for (f[i][j][m+1]=k=m;k;--k) if (i==j||(a[i][k]==a[j][k]&&f[i][j-1][k]>=k))
	f[i][j][k]=a[i][k]==a[i][k+1]?f[i][j][k+1]:k; else f[i][j][k]=k-1;
	for (i=1;i<=m;++i) for (j=i;j<=m;++j)
	for (g[i][j][n+1]=k=n;k;--k) if (i==j||(a[k][i]==a[k][j]&&g[i][j-1][k]>=k))
	g[i][j][k]=a[k][i]==a[k+1][i]?g[i][j][k+1]:k; else g[i][j][k]=k-1;
	if (f[1][n][1]==m) return puts("0"),0; for (t=1;;++t)
	{
		for (i=1;i<=n;++i) for (j=i;j<=n;++j) for (k=1;k<=m;++k)
		f[i][j][k]=f[i][j][f[i][j][k]+1];
		for (i=1;i<=m;++i) for (j=i;j<=m;++j) for (k=1;k<=n;++k)
		g[i][j][k]=g[i][j][g[i][j][k]+1];
		for (i=1;i<=n;++i) for (j=1;j<=m;++j)
		{
			for (f[i][n+1][j]=j-1,k=i;k<=n;++k)
			for (p=f[i][k][j];p>f[i][k+1][j];--p) g[j][p][i]=max(g[j][p][i],k);
			for (g[j][m+1][i]=i-1,k=j;k<=m;++k)
			for (p=g[j][k][i];p>g[j][k+1][i];--p) f[i][p][j]=max(f[i][p][j],k);
		}
		if (f[1][n][1]==m) return printf("%d",t),0;
	}
	return 0;
}

Measured memory_bytes: 32484
#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline LL gl()
{
	LL f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int INF = 0x3f3f3f3f, N = 3003, M = N << 2;
const string s = "RYGB";

int h, w, d;

int main()
{
	h = gi(), w = gi(), d = gi();
	for (int i = 1; i <= h; i+=1)
	{
		for (int j = 1; j <= w; j+=1)
		{
			int x = i + j + w, y = i - j + w;
			cout << s[((x / d) & 1) * 2 + ((y / d) & 1)];
		}
		puts("");
	}
	return 0;
}
//

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 998244353;
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}

long long moddiv(long long a, long long b) { return (a * modpow(b, mod - 2)) % mod; }

long long nCkmod(long long n, long long k) {
    long long denomi = 1;
    REP(i, n) {
        denomi *= (i + 1);
        denomi %= mod;
    }
    long long numera = 1;
    for (int i = n - k; i > 0; i--) {
        numera *= i;
        numera %= mod;
    }
    REP(i, k) {
        numera *= (i + 1);
        numera %= mod;
    }
    return moddiv(denomi, numera);
}

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}

signed main() {
    int h, n;
    cin >> h >> n;
    vector<int> as(n);
    vector<int> bs(n);
    vector<int> dp(h + 1, 1e8);
    dp[h] = 0;
    REP(i, n) { cin >> as[i] >> bs[i]; }
    int ans = 1e8;
    for (int i = h; i > 0; i--) {
        REP(j, n) {
            if (i - as[j] <= 0) {
                ans = min(ans, dp[i] + bs[j]);
                continue;
            }
            if (dp[i] + bs[j] < dp[i - as[j]]) {
                dp[i - as[j]] = dp[i] + bs[j];
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;

	if (a == b) {
		for (int i = 0; i < a; i++) {
			cout << a;
		}
	}
	else if(a != b) {
		int Q = min(a, b);
		int W = max(a, b);
		for (int j = 0; j < W; j++) {
			cout << Q;
		}
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[30];
		a[0] = 1;
		a[1] = 2;
		a[2] = 4;
		for (int i = 3; i < 30; i++) {
			a[i] = a[i - 1] + a[i - 2] + a[i - 3];
		}
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int y = a[n - 1] / 3650 + 1;
			System.out.println(y);
		}
		sc.close();
	}
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[n-1]-a[0] << endl;
  return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,q;
  cin>>a;
  int ans=0;
  for(int i=1;i<361;i++)
  {
  	ans+=a;
  	ans=ans%360;
  	if(ans==0)
  	{
  	q=i;
	  break;
  }
  }
  cout<<q;
   return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))
vector<int> children[108000];
int parent[108000];
int s[108000];
int u, v, w, n, k, c, q;
int group[108000];
int index[108000];
int order;
void dfs_size(int x){
  s[x] = 1;
  for(auto c:children[x]){
    dfs_size(c);
    s[x] += s[c];
  }
}

void dfs_hl(int x, int boss = -1){
  if(boss != -1)group[x] = boss;
  else{
    group[x] = x;
    index[x] = 0;
  }
  if(children[x].empty())return;
  for(int i = 1;i < children[x].size();i++){
    if(s[children[x][i]] > s[children[x][0]])
      swap(children[x][i], children[x][0]);
  }
  index[children[x][0]] = index[x] + 1;
  for(int i = 0;i < children[x].size();i++){
    dfs_hl(children[x][i], i==0?group[x]:-1);
  }  
}

vector<int> bit[108000];

void add(vector<int> &bit, int x, int val){
  x++;
  while(x < bit.size()){
    bit[x] += val;
    x += x & -x;
  }
}

Int sum(vector<int> &bit, int x){
  x++;
  Int res = 0;
  while(x){
    res += bit[x];
    x -= x & -x;
  }
  return res;
}

int main(){
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> k;
    for(int j = 0;j < k;j++){
      cin >> c;
      children[i].push_back(c);
      parent[c] = i;
    }
  }
  parent[0] = -1;
  dfs_size(0);
  dfs_hl(0);
  for(int i = 0;i < n;i++)bit[group[i]].push_back(0);
  for(int i = 0;i < 108000;i++)if(!bit[i].empty())bit[i].push_back(0);
  cin >> q;
  while(q--){
    cin >> order;
    if(order == 0){
      cin >> v >> w;
      int boss = group[v];
      add(bit[boss], index[v], w);
    }
    if(order == 1){
      cin >> u;
      Int res = 0;
      while(u != -1){
	int boss = group[u];
	res += sum(bit[boss], index[u]);
	u = parent[boss];
      }
      cout << res << endl;
    }
  }
  
  return 0;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  ll A = nextLong();
  ll B = nextLong();
  ll C = nextLong();
  int K = nextLong();

  REP(_, K) {
    if (A >= B) B *= 2;
    else if (B >= C) C *= 2;
    else C *= 2;
  }

  if (A < B && B < C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

double area(double a, double b);

double around(double a, double b);

int main(){
int a, b;
cin >> a >> b;

cout << area(a,b) << ' ' << around(a,b) << endl;

}

double area(double a, double b){
return a*b;
}

double around(double a, double b){
return 2*(a+b);
}

Measured memory_bytes: 1232
#include <stdio.h>
#define LL long long

int main()
{
    LL K, A, B;
    scanf("%lld%lld%lld", &K, &A, &B);
    LL max;

    if(B - A <= 2)
        max = K + 1;
    else if ((K - (A - 1)) % 2 == 0)
    {
        max = (K - (A - 1)) / 2 * (B - A) + A;
    }
    else
    {
        max = (K - 1 - (A - 1)) / 2 * (B - A) + A + 1;
    }
    printf("%lld\n", max);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
int main(){
    string a0,a1,a2,a3,b0,b1,b2,b3;
    while(cin>>a0>>a1>>a2>>a3>>b0>>b1>>b2>>b3){
        int h=0,bl=0;
        if(a0==b0)h++;
        if(a1==b1)h++;
        if(a2==b2)h++;
        if(a3==b3)h++;
        if(a0==b1||a0==b2||a0==b3) bl++;
        if(a1==b0||a1==b2||a1==b3) bl++;
        if(a2==b0||a2==b1||a2==b3) bl++;
        if(a3==b0||a3==b1||a3==b2) bl++;
        
        cout<<h<<" "<<bl<<endl;
    }
    return 0;
}

Measured memory_bytes: 3012
import heapq

n = int(input())
priority_list = []

student = 0
for priority in list(map(int, input().split())):
    student += 1
    priority_list.append((priority, str(student)))

heapq.heapify(priority_list)

print(' '.join([ heapq.heappop(priority_list)[1] for _ in range(n) ]))

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main(){
    ll n, k, s; cin >> n >> k;
    ll ans = 0;
    for(ll i=0; i<n;i++) cin >> s;
    n -= k; ans++;
    while(n > 0){
        n -= k-1; ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut ans = s.iter().map(|&x| x.to_digit(10).unwrap()).sum::<u32>();
    ans = max(
        ans,
        s[0].to_digit(10).unwrap() + 9 * (s.len() as u32 - 1) - 1,
    );
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k=1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u==p) continue;
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}
int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> v(100005);
    rep(i,n){
        int a, b; cin >> a >> b;
        v[a].push_back(b);
    }

    int ans = 0;
    priority_queue<int> pq;
    for (int i=1; i<=m; i++) {
        rep(j,v[i].size()) {
            pq.push(v[i][j]);
        }
        if (! pq.empty()) {
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

int main()
{
    boost;
    ll n,i,j,x,t,y,r;
    cin>>n>>r;
    if(n>=10LL) cout<<r;
    else cout<<r+(100*(10-n));
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    
    int n;
    string s;
    
    string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
    cin >> n;
    cin >> s;
    
    for(int i = 0; i < s.length(); ++i)
    {
        int changeIndex = -1;
        for(int j = 0; j < alphabet.length(); ++j)
        {
            if(s[i] == alphabet[j])
            {
                changeIndex = (j + n) % 26;
                break;
            }
        }
        
        if(changeIndex == -1)
        {
            continue;
        }
        
        s[i] = alphabet[changeIndex];
    }
    
    cout << s << endl;
    
    return 0;
    
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int n, k;
	int ans = 0;
	int block[1000005] = { 0 };
	string str;

	cin >> n >> k;
	cin >> str;

	int pattern = 1;
	int cnt = 0;
	int index = 0;
	for (int i = 0; i < (int)str.size(); i++) {
		switch (pattern) {
		case 1:
			if (str[i] == '0') {
				block[index] = cnt;
				index++;
				cnt = 1;
				pattern = 0;
			}
			else {
				cnt++;
			}
			break;
		case 0:
			if (str[i] == '1') {
				block[index] = cnt;
				index++;
				cnt = 1;
				pattern = 1;
			}
			else {
				cnt++;
			}
			break;
		}
	}
	block[index] = cnt;

	int black = 0;
	int white = 0;

	for (int i = 0; i < k + 1; i++) {
		black += block[i * 2];
	}
	for (int i = 0; i < k; i++) {
		white += block[i * 2 + 1];
	}

	int lblack = 0, rblack = k * 2;
	int lwhite = 1, rwhite = k * 2 - 1;
	ans = max(ans, black + white);

	while (rblack <= index) {
		black += block[rblack + 2]; black -= block[lblack];
		white += block[rwhite + 2]; white -= block[lwhite];
		ans = max(ans, black + white);
		rblack += 2; lblack += 2;
		rwhite += 2; lwhite += 2;
	}

	cout << ans << endl;

	return(0);
}

Measured memory_bytes: 4352
#include <stdio.h>
// s: a raw text, p: a pattern text
// p in s ? true:false
char s[101];
char p[101];
int main()
{
    int i, n, j, flag, pflag;
    scanf("%s", s);
    scanf("%s", p);
    for (i=0; s[i]!='\0'; ++i) {
        pflag = 0;
        for (n=i, flag=0; s[n==0?0:n-1]!='\0'&& pflag == 0;) {
            for (j=0; p[j]!='\0' && pflag == 0; ++j) {
                //printf("%d!!%d:%d, %c:%c\n",i, n, j, s[n], p[j]);
                if (s[n] == '\0') {
                    //printf("loop%d:%d, %c:%c\n", n, j, s[n], p[j]);
                    if (flag != 0) {
                        pflag = 1;
                    }
                    flag++;
                    n = 0;
                    j--;
                    continue;
                }
                if (s[n++] != p[j]) break;
                if (p[j+1] == '\0') {
                    printf("Yes\n");
                    return 0;
                }
            }
            if (j!=0) {
                --n;
            } else {
                
            }
        }
    }
    printf("No\n");
    return 0;
}



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

int FP( int a, int b )
{
	int ans = 1;
	for(; b; b >>= 1, a *= a)
		if(b & 1) ans *= a;
	return ans;
}

int main()
{
	int n, x, cnt = 0;
	cin >> n;
	for(int i = 1; i <= n; ++i)
	{
		scanf( "%d", &x );
		if(!(x & 1)) ++cnt;
	}
	cout << FP(3, n) - FP(2, cnt) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int N, W;
long long dp[100100];
int w[110], v[110];

long long min(long long a, long long b) {
    return (a < b ? a : b);
}

int main() {
    scanf("%d%d", &N, &W);
    for (int i = 1; i <= N; i++) scanf("%d%d", &w[i], &v[i]);
    for (int i = 0; i <= 100005; i++) dp[i] = (long long) 1e10;
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 100005; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + 1ll * w[i]);
        }
    }
    for (int i = 100005; i >= 0; i--) {
        if (dp[i] <= W) {
            printf("%d\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
 
using namespace std;
 
int func(int h[], int n, int k)
{
  if (n == 1)	return 0;
  
  int dp[n];
  dp[0] = 0;
  
  for (auto i = 1; i < n; i++) {
    dp[i] = INT_MAX;
    for (auto j = 1; j <= k; j++) {
      if (i >= j) {
    	dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
      } else {
        break;
      }
    }
  }
  
  return dp[n - 1];
}
 
int main()
{
  int n, k;
  cin >> n >> k;
  
  int h[n];
  for (auto i = 0; i < n; i++)
    cin >> h[i];
	
  cout << func(h, n, k) << endl;
  
  return 0;
}

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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

double dp[310][310][310];

int main(int argc, char* argv[]) {
  INFILE;

  ll n;
  cin >> n;

  vector<ll> sushis(n, 0);
  scan(sushis);

  int one = count(ALL(sushis), 1);
  int two = count(ALL(sushis), 2);
  int three = count(ALL(sushis), 3);

  REP(k, 0, n + 1) {
    REP(j, 0, n + 1) {
      REP(i, 0, n + 1) {
        if (i == 0 && j == 0 && k == 0) {
          dp[i][j][k] = 0.0;
          continue;
        }

        double res = 0.0;
        res += (i == 0 ? 0 : dp[i - 1][j][k] * i);
        res += (j == 0 ? 0 : dp[i + 1][j - 1][k] * j);
        res += (k == 0 ? 0 : dp[i][j + 1][k - 1] * k);
        res += n;

        res *= 1.0 / (i + j + k);
        dp[i][j][k] = res;
      }
    }
  }

  cout << fixed << setprecision(10) << dp[one][two][three] << endl;

  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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 <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 227584
#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, m;
    cin >> n >> m;
    vector<int> a(n);
    int total = 0;
    rep(i, n) {
        cin >> a[i];
        total += a[i];
    }
    double th = total / (4.0 * m);
    sort(a.begin(), a.end(), greater<int>());
    rep(i, m) {
        if (a[i] < th) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


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

using namespace std;

class SegTree{
public:
    int n;
    int defaultValue;
    vector<int> dat;

    SegTree(int m, int value){
        n = 1;
        while(n < m){
            n *= 2;
        }
        dat = vector<int>(2 * n - 1, value);
        defaultValue = value;
    }

    void update(int i, int value){
        i += n - 1;
        dat[i] += value;
        while(i > 0){
            i = (i - 1) / 2;
            dat[i] = ope(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }

    int query(int a, int b){
        return query(a, b, 0, 0, n);
    }
private:
    int query(int a, int b, int k, int l, int r){
        if(r <= a || b <= l){
            return defaultValue;
        }
        if(a <= l && r <= b){
            return dat[k];
        }
        else{
            int vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
            int vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
            return ope(vl, vr);
        }
    }

    int ope(int a, int b){
        return a + b;
    }
};

int main(){

    int n, q;
    cin >> n >> q;
    SegTree sg(n, 0);
    int com, x, y;
    for(int i = 0; i < q; i++){
        cin >> com >> x >> y;
        if(com == 0){
            sg.update(x - 1, y);
        }
        else{
            cout << sg.query(x - 1, y) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3844
$\=$/;
while($i++<9){$L=0,$|=$R=10;print("? ",($_*10+($%=$L+$R>>1))*1e9),<>=~Y?$R:$L=$%while$R-$L>1;$_.=$L}
print"? ",++$_+s/0*$//;
print"? ",($_.=0)+1while<>=~(/^9*$/?Y:N);
print"! ",$_

Measured memory_bytes: 976
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 62;
constexpr auto mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }

int main() {
    double w, h, x, y;
    cin >> w >> h >> x >> y;
    vector<double> a;
    if (x == w / 2 && y == h / 2) {
        printf("%.11f", h * w / 2);
        cout << " " << 1 << endl;
    }
    else {
        printf("%.11f", h * w / 2);
        cout << " " << 0 << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int a[3]={}; rep(i,3)cin>>a[i];
    sort(a,a+3);
    cout<< abs(a[0]-a[1])+abs(a[1]-a[2]) <<endl;
}


Measured memory_bytes: 256
def calc(i, w, h):
	fixed = w * h
	a = w * i
	v_b = (h-i) // 2 * w
	v_c = fixed - a - v_b
	v_d = max(a, v_b, v_c) - min(a, v_b, v_c)
	h_b = w // 2 * (h-i)
	h_c = fixed - a - h_b
	h_d = max(a, h_b, h_c) - min(a, h_b, h_c)
	return min(v_d, h_d)

def resolve():
	h, w = map(int, input().split())
	ans = float('inf')
	for i in range(1, h):
		ans = min(ans, calc(i, w, h))
	for i in range(1, w):
		ans = min(ans, calc(i, h, w))
	print(ans)
resolve()

Measured memory_bytes: 44656
package main

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

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	x := io.NextInt()
	var grade int
	switch {
	case x < 600:
		grade = 8
	case x < 800:
		grade = 7
	case x < 1000:
		grade = 6
	case x < 1200:
		grade = 5
	case x < 1400:
		grade = 4
	case x < 1600:
		grade = 3
	case x < 1800:
		grade = 2
	case x < 2000:
		grade = 1
	}
	io.Println(grade)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define U [100005]={}
typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;L D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];if(!H[a]|Z[H[a]]<Z[d])H[a]=d;}}}L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}L M(L i){for(r=0;i;r+=B[i],i-=i&-i);return r;}L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<100005;B[i]+=x,i+=i&-i);}main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;D(0);for(c=p=0;p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])O[a]=c++,X[a]=p,S(O[a],H[a]);for(cin>>a;cin>>s>>a>>b;)if(*s&2){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;}

Measured memory_bytes: 31996
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	
	int n;

	while(cin>>n){
		int s=0;
		if(n!=0){
			vector<int> a(n);
			for(int i=0;i<n;i++)
				cin>>a[i];
			sort(a.begin(),a.end());
			a[0]=0;
			a[n-1]=0;
			for(int i=0;i<n;i++)
				s+=a[i];
			cout<<s/(n-2)<<endl;
		}
		else
			break;
	}
	
}

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

int main(){
	int n;
	string s;
	cin >> n >> s;

	int ans = 0;
	rep(i, n-2){
		if(s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
    #include<string>
    #include<algorithm>
    #include<map>
    #include<vector>
    using namespace std;
    int main(void)
    {
        int d,n,z=1,ans;
        cin>>d>>n;
        for(int i=0;i<d;i++){
            z*=100;
        }
        if(n<100){
            ans=z*n;
        }
        else
        ans=z*101;
        cout<<ans<<endl;
    }

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int n, m, q;
vi a, b, c, d;
int ans = 0;
void dfs(vi al) {
    if (int(al.size()) == n+1) {
        int sum = 0;
        rep(i, q) {
            if (al[b[i]] - al[a[i]] == c[i]) sum += d[i];
        }
        ans = max(ans, sum);
        return;
    }
    al.pb(al.back());
    while (al.back() <= m) {
        dfs(al);
        al.back()++;
    }
}

int main(){
    cin >> n >> m >> q;
    a = b = c = d = vi(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    dfs(vi(1, 1));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).OrderByDescending(x => x).ToArray();
        var res = 0L;
        for (var i = 1; 2 * n > i; i += 2)
        {
            res += a[i];
        }
        Console.WriteLine(res);
    }
}


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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	string s; cin >> s;

	while (s != "ABC") {
		string buf;

		bool hasu = false;

		for (char c : s) {
			buf += c;
			if (buf.size() >= 3 && buf.substr(buf.size() - 3) == "ABC") {
				rep(i, 0, 3) buf.pop_back();
				buf += 'U';
				hasu = true;
			}
		}

		if (!hasu) break;

		bool noa = 1, nob = 1, noc = 1;
		for (char c : buf) {
			if (c == 'A') noa = 0;
			if (c == 'B') nob = 0;
			if (c == 'C') noc = 0;
		}

		for (char &c : buf) if (c == 'U') {
			c = noa ? 'A' : nob ? 'B' : noc ? 'C' : '?';
		}

		s = buf;
	}

	cout << (s == "ABC" ? "Yes" : "No") << endl;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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











int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<ll>> g(n);
    REP(i, m){
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> ans(n, -1);
    queue<tuple<ll, ll>> que;
    que.push({0, 0});
    while(!que.empty()){
        auto [now, pre] = que.front(); que.pop();
        if(ans[now] != -1) continue;
        ans[now] = pre;
        for(auto &next : g[now]){
            que.push({next, now});
        }
    }
    cout << "Yes" << endl;
    REP(i, n - 1){
        cout << ans[i + 1] + 1 << endl;
    }
}


Measured memory_bytes: 16968
PROGRAM ATCODER

implicit none
integer :: i,j,n,m,index=1,dp,dp2,check,count=0
integer,allocatable :: l(:),r(:)

read*, n,m 
allocate(l(m),r(m))
do i = 1, m, 1
  read*, l(i),r(i)
end do

dp = 1
dp2 = n
do i = 1, m, 1
  call chmax(dp,l(i))
  call chmin(dp2,r(i))
end do

if ( dp2 - dp < 0 ) then
  print'(i0)', 0
else
  print'(i0)', dp2 - dp + 1
end if

contains
  subroutine chmax(dp,x)
  implicit none
  integer :: dp, x

  if (dp < x) then
  	dp = x
  	return
  end if

  end subroutine

  subroutine chmin(dp,x)
  implicit none
  integer :: dp, x

  if (dp > x) then
  	dp = x
  	return
  end if

  end subroutine

END PROGRAM ATCODER

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

int n;
vector<int> p;

int main() {
    cin>>n;
    p.resize(n);
    for (int i=0; i<n; i++) cin>>p[i];
    int cnt=0;
    for (int i=1; i<n-1; i++) {
        if ((p[i+1]>p[i]&&p[i]>p[i-1])||
            (p[i-1]>p[i]&&p[i]>p[i+1])) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
def examB():
    O = S()
    E = S()
    E += " "
    ans = ""
    for i in range(len(O)):
        ans = ans + O[i] + E[i]
    if len(O)!=len(O):
        ans = ans[:len(E)+1]
    print(ans)



import sys
import copy
import bisect
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()


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

object Main {
  def fib(a:Int, b: => Int, n:Int):Int = {
    if (n ==  0)
      a
    else
      fib(a+b, a, n-1)
  }

  def main(args: Array[String]) = {
    val n = readInt()
    println(fib(1, 0, n))
  }
}

Measured memory_bytes: 43792
while gets
  arr = $_.chomp.split("").map{ |c| c.to_i }
  
  n = arr.length - 1
  
  n.times do |i|
    (n - i).times do |j|
      arr[j] = (arr[j] + arr[j + 1]) % 10
    end
  end
  
  puts arr[0]
end

Measured memory_bytes: 6108
#include <iostream>

using namespace std;

void trace(int n, int a[])
{
	for (int i = 0; i < n; ++i)
	{
		cout << a[i];
		if (i < n - 1)
		{
			cout << " ";
		}
	}
	cout << endl;
}

int bubbleSort(int n, int a[])
{
	int count = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = n - 1; j > i; j--)
		{
			if (a[j] < a[j - 1])
			{
				swap(a[j], a[j - 1]);
				count++;
			}
		}
	}
	return count;
}

int main(int argc, char const *argv[])
{
	int n = 0;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	int count = bubbleSort(n, a);
	trace(n, a);
	cout << count << endl;
	return 0;
}

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

int main()
{
	int n,k;
	cin >> n >> k;
	vector<int> h(n);
	for(int i = 0;i<n;i++)cin >> h[i];
	sort(h.begin(),h.end());
	int ans = INT_MAX;
	for(int i = 0;i<n-k+1;i++)
	{
		ans = min(h[i+k-1]-h[i],ans);
	}
	cout<<ans<<endl;
	return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

// #define DEBUG

ll solve(vector<ll> A, int sig)
{
    int N = A.size();
    ll sum = 0;
    ll res = 0;

#ifdef DEBUG
    DUMP(sig);
#endif

    rep(i, N) {
        sum += A[i];

#ifdef DEBUG
        DUMP2(sum, sig);
#endif

        if (sum == 0) {
            sum = sig;
            res++;
        } else {
            if (sig == 1 && sum < 0) {
                res += (1 - sum);
                sum = 1;
            } else if (sig == -1 && sum > 0) {
                res += -(-1 - sum);
                sum = -1;
            }
        }

#ifdef DEBUG
        DUMP(res);
#endif
        sig *= -1;
    }

    return res;
}

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

    int N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = min(solve(A, 1), solve(A, -1));
    cout << ans << endl;
}



Measured memory_bytes: 2688