akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
    //入力
    int n; cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    //Ai+Aj=i-jより、i-Ai=j+Aj。左辺と右辺それぞれの値を全ての参加者についてもとめその値をkeyとした連想配列で求める

    //和と差を保管する連想配列
    map<long long, int>plus;
    map<long long, int>minus;

    
    for (int i = 0; i < n; i++)
    {
        plus[i + 1 + a[i]] += 1;
        minus[i + 1 - a[i]] += 1;
    }

    //ペアの数カウント変数
    long long count = 0;

    //i-Ai=j+Ajが成り立つ時の両辺の値の範囲は大体0〜nである
    for (int i = 0; i <= n+1; i++)
    {
        count += (long long)plus[i] * minus[i];
    }

    cout << count << endl;
    

    
}


Measured memory_bytes: 47888
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

struct UnionFind {
	vector<int> par;
	UnionFind(int x) : par(x, -1) {}
	void init(int x) { par.assign(x, -1); }
	int root(int x) {
		if (par[x] <= -1) return x;
		else return root(par[x]);
	}
	bool issame(int x, int y) {
		return root(x) == root(y);
	}
	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	int size(int x) {
		return -par[root(x)];
	}
};

int p[100010];
int main()
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> p[i];
		p[i]--;
	}
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		uf.merge(a, b);
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (uf.issame(i, p[i])) ans++;
	}
	cout << ans << endl;
}

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

int main() {
  long long N, sum = 0;
  cin >> N;

  vector<long long> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
    sum += vec[i];
  }

  long long lef = 0;
  int cut = 0;
  while (lef < sum / 2) {
    lef += vec[cut];
    cut++;
  }

  long long lef2 = lef - vec[cut - 1];

  long long ri = 0;
  for (int i = cut; i < N; i++) {
    ri += vec[i];
  }

  long long ri2 = ri + vec[cut - 1];

  cout << min(abs(lef - ri), abs(lef2 - ri2)) << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const int MAX = 310000;

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

void combinit(){
    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 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    combinit();
    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    ll ans = 0ll;
    for(ll i = b; i < w; ++i){
        (ans += com(h-a-1+i, i)*com(a-1+w-1-i, w-1-i)%MOD) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7552
import java.io.*;
import java.util.*;

public class Main {
    static long mod = (int)Math.pow(10,9)+7;
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		long nm = 1;
		for(long i = 2; i < n; i++){
		    nm *= i;
		    nm %= mod;
		}
		long[] a = sc.nextLongArray(n);
		long dn = 0;
		long ans = 0;
		for(int i = 1; i < n; i++){
		    dn += rep2(i,mod-2);
		    dn %= mod;
		    ans += (a[i]-a[i-1]) * (nm*dn%mod);
		    ans %= mod;
		}
		pw.println(ans);
		pw.close();
	}
	
	private static long rep2(long b, long n){
        if(n == 0) return 1;
        if(n == 1) return b;
        long bn = rep2(b,n/2L)%mod;
        if(n % 2 == 0){
            return (long)(bn%mod*bn%mod)%mod;
        }else{
            return (long)(bn%mod*bn%mod)%mod*b%mod;
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }

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

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



Measured memory_bytes: 37852
n, m, l = map(int, input().split())
a = []
b = []
for i in range(n):
    a.append(list(map(int, input().split())))
for k in range(m): 
    b.append(list(map(int, input().split())))
for i in range(n):
    for s in range(l):
        c = 0
        for k in range(m):
            c = c + a[i][k] * b[k][s]
        if (s == l-1):
                print('{}'.format(c), end = '')
        else:
                print('{}'.format(c), end = ' ')
    print()
            
    


Measured memory_bytes: 6576
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int X;
    in1(X);

    if (X == 7 || X == 5 || X == 3)
    {
        outl("YES");
    }
    else
    {
        outl("NO");
    }

    return 0;
}


Measured memory_bytes: 3656
s = str(input())
n = len(s)

s_reverse = s[::-1]

s1 = s[::int((n-1)/2)]
s1_reverse = s1[::-1]

s2 = s[int((n+3)/2)-1::]
s2_reverse = s2[::-1]

if (s==s_reverse) and (s1==s1_reverse) and (s2==s2_reverse):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;

const int kMaxn = 2e5 + 5;
int N;
char str[kMaxn];

int main() {
  //
  scanf("%d%s", &N, str + 1);
  set<int> W;
  set<int, greater<int>> R;
  for (int i = 1; i <= N; i++) {
    if (str[i] == 'W')
      W.insert(i);
    else
      R.insert(i);
  }
  int ans = 0;
  while (!R.empty() && (*R.begin() != R.size())) {
    R.erase(R.begin());
    R.insert(*W.begin());
    W.erase(W.begin());
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 12764
#include<bits/stdc++.h>
using namespace std;int N,M,L,R,C,A,i,j;string S;char Q[4];
main(){scanf("%d",&N);scanf("%d",&M);cin>>S;
vector<vector<int> >F(N+1, vector<int>());
for(i=0;i<M;i++){
scanf("%s",Q);
if(Q[0]=='L'&&Q[1]=='+'){L++;}
if(Q[0]=='L'&&Q[1]=='-'){L--;}
if(Q[0]=='R'&&Q[1]=='+'){R++;}
if(Q[0]=='R'&&Q[1]=='-'){R--;}
F[R-L+1].push_back(L);
C=max(C,R-L+1);}
vector<vector<int> >D(N+1,vector<int>());
for(i=1;i<=N;i++){
sort(F[i].begin(),F[i].end());
if(F[i].size()){D[i].push_back(F[i][0]);}
for(j=1;j<F[i].size();j++){if(F[i][j-1]!=F[i][j]){
D[i].push_back(F[i][j]);}}}
for(i=1;i<=C;i++){
set<string> s;
for(j=0;j<D[i].size();j++){
s.insert(S.substr(D[i][j], i));}
A+=s.size();}
printf("%d\n",A);}

Measured memory_bytes: 36424
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A,B,T;
    cin>>A>>B>>T;
    
   cout<<T/A*B<<endl;
    
    return 0;
}


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

int main() {
    int N, D;
    std::cin >> N >> D;

    std::vector<int> candidates;
    for (int i = 1; i * i < 16000; i += 1) {
        candidates.push_back(i * i);
    }

    std::vector<std::vector<int>> X(N);
    for (int i = 0; i < N; i += 1) {
        X[i].resize(D);
        for (int j = 0; j < D; j += 1) {
            std::cin >> X[i][j];
        }
    }

    int count = 0;
    for (int i = 0; i < N; i += 1) {
        for (int j = i + 1; j < N; j += 1) {
            int sum = 0;
            for (int k = 0; k < D; k += 1) {
                sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            if (std::find(candidates.begin(), candidates.end(), sum) != candidates.end()) {
                count += 1;
            }
        }
    }

    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll X,Y;
    cin >> X >> Y;
    double a = (4*(double)X-(double)Y)/2;
    double b = ((double)Y-2*(double)X)/2;
    if(a >= 0 && b>=0 && ceil(a)==floor(a) && ceil(b)==floor(b)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No" << endl;
    }
    return 0;    
}


Measured memory_bytes: 3680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}",a*b,(a+b)*2);
            Console.ReadLine();

            
        }
    }
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define all(c) c.begin(),c.end()
#define si(x) int(x.size())
#define pb emplace_back
#define fs first
#define sc second
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<class T,class U> void chmax(T& x, U y){if(x<y) x=y;}
template<class T,class U> void chmin(T& x, U y){if(y<x) x=y;}
template<class T> void mkuni(V<T>& v){sort(all(v));v.erase(unique(all(v)),v.end());}
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
void dmpr(ostream& os){os<<endl;}
template<class T,class... Args>
void dmpr(ostream&os,const T&t,const Args&... args){
	os<<t<<" ~ ";
	dmpr(os,args...);
}
#define shows(...) cerr << "LINE" << __LINE__ << " : ";dmpr(cerr,##__VA_ARGS__)
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) void(0)
#define dump(x) void(0)
#define shows(...) void(0)
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N; cin >> N;
	V<int> A(N); rep(i,N) cin >> A[i], A[i]--;
	V<int> iA(N); rep(i,N) iA[A[i]] = i;
	set<int> st;
	st.insert(-1);st.insert(N);
	st.insert(-2);st.insert(N+1);
	ll ans = 0;
	per(v,N){
		int x = iA[v];
		int l=0,l2=0,r=0,r2=0;
		{
			auto it = st.lower_bound(x);
			r = *it;
			it++;
			r2 = *it;
			it--;
			it--;
			l = *it;
			it--;
			l2 = *it;
			it++;
		}
		ll num = 0;
		if(r != N) num += ll(x-l) * (r2-r);
		if(l != -1) num += ll(r-x) * (l-l2);
		ans += num * (v+1);
		st.insert(x);
	}
	cout << ans << endl;
}


Measured memory_bytes: 5760
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function PriorityQueue(){
  this.heap=Array(2e5);
  this.size=0;
}
PriorityQueue.prototype = {
  push:function(x){
    var h=this.heap,i=this.size++,j;
    while(i){
      j=i-1>>1;
      if(h[j]<=x)break;
      h[i]=h[j],i=j;
    }
    h[i]=x;
  },
  pop:function(){
    var h=this.heap,s=this.size-1,x=h[s];h[s]=undefined;
    if(s<1)if(s)return;else return --this.size,x;
    var r=h[0],i=0,k=s>>1,j;--this.size;
    while(i<k){
      j=(i<<1)+1;
      if(h[j+1]<h[j])++j;
      if(x<=h[j])break;
      h[i]=h[j],i=j;
    }
    return h[i]=x,r;
  },
  top:function(){return this.heap[0];},
};
var b = 0;
var low = new PriorityQueue();
var hi = new PriorityQueue();
var cnt = 0;

console.log(main());
function main(){
  var q = o.a();
  var ans = [];
  for(var i = 0; i < q; i++){
    var t = o.l();
    if(t[0] === 2)ans.push((-low.top())+" "+b);
    else solve(t[1],t[2]);
  }
  return ans.join("\n");
}
function solve(u,v){
  b += v;
  var h = hi.top();
  var l = -low.top();
  if(cnt === 0){
    low.push(-u);
  }else if(cnt&1){
    if(l <= u){
      hi.push(u);
    }else{
      hi.push(-low.pop());
      low.push(-u);
    }
    b += Math.abs(u-l);
  }else{
    if(h < u){
      low.push(-hi.pop());
      hi.push(u);
    }else{
      low.push(-u);
    }
    if(u < l)b += l-u;
    else if(h < u)b += u-h;
  }
  cnt++;
}

Measured memory_bytes: 81068
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long h,k;
  cin>>h>>k;
  long long a[h],count=0;
  for(long long i=0;i<h;i++)
    cin>>a[i];
  sort(a,a+h);
  
if(k>h)
  cout<<0;
 else{
  	for(long long i=0;i<(h-k);i++)
    {
    	count+=a[i];
    }
  
  
  cout<<count;}
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b)
{
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}



int a,b,c;
int main(){
  cin >> a >> b >> c;
  cout << min(b/a,c) << endl;
}


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

int main() {
	long long a, b, n;
	cin >> a >> b >> n;
	if (n <= b-1)
	{
		cout << a*n/b << endl;
	}
	else
	{
		if(a%b == 0) cout << a - a/b << endl;
		else cout << a - a/b - 1 << endl;
	}
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-7;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif

    fast_io();

    cout.precision(6);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        --p[i];
    }
    vector<int> a(n);
    vector<int> b(n);
    vector<int> sum(n + 1);
    vector<int> pref_a(n + 1);
    vector<int> pref_b(n + 1);
    for (int i = 0; i < n; ++i) {
        a[i] = i + 1;
        b[i] = (n + 1 - a[i]);
    }
    for (int i = 0; i < n; ++i) {
        pref_a[p[i]] += i;
        pref_b[p[i] + 1] -= i;
    }
    int cur_a = 0;
    int cur_b = 0;
    for (int i = 0; i < n; ++i) {
        cur_a += pref_a[i];
        a[i] += cur_a;
        cur_b += pref_b[i];
        b[i] += cur_b;
    }
    int x = *min_element(b.begin(), b.end());
    if (x < 0) {
        x = abs(x);
        for (auto &el:b) {
            el += x + 1;
        }
    }

    for (int el:a) {
        cout << el << " ";

    }
    cout << endl;
    for (int el:b) {
        cout << el << " ";
    }
    for (int i = 1; i < n; ++i) {
        assert(a[p[i]] + b[p[i]] > a[p[i - 1]] + b[p[i - 1]]);
        assert(a[i] > a[i - 1]);
        assert(b[i] < b[i - 1]);
    }
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void chmin(int &a, int b) { if (a > b) a = b; }

int N, A, B, C;
vector<int> L;
int INF = 1 << 30;

// 再帰
int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
        return abs(a - A) + abs(b - B) + abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
    }

    // 今ある竹を採用しない場合
    int res = rec(i+1, a, b, c);
    
    // A, B, C を使う場合。
    // (a ? 10 : 0) とかは、最初の 1 本目は合体コストなし、2 本目からはコスト 10 かかることを意味する
    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}

int main() {
    // 入力
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];
    
    // 再帰する
    cout << rec(0, 0, 0, 0) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String line1 = sc.next();
        String line2 = sc.next();
        String line3 = sc.next();

        System.out.println(""+ line1.charAt(0)+line2.charAt(1)+line3.charAt(2));
    }
}


Measured memory_bytes: 23764
def main
  n = ARGF.gets.to_i

  buttons = []
  n.times do |i|
    buttons << ARGF.gets.to_i - 1
  end

  current = 0
  cnt = 1
  loop do
    next_num = buttons[current]
    if next_num == 1
      puts cnt
      return
    elsif next_num == -1
      puts "-1"
      return
    else
      buttons[current] = -1
      cnt += 1
      current = next_num
    end
  end

  puts "-1"
end

if __FILE__ == $0
  main
end


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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

ll cnt[11][11];

int firstl(int a)
{
    return to_string(a)[0] - '0';
}

int lastl(int a)
{
    return a % 10;
}

int main(void)
{
    int n; cin >> n;
    REP(i, 10) REP(j, 10) cnt[i][j] = 0;
    REP1(i, n) {
        cnt[firstl(i)][lastl(i)] ++;
    }
    ll res = 0;
    REP(i, 10) {
        REP(j, 10) {
            res += cnt[i][j] * cnt[j][i];
        }
    }
    cout << res << endl;
        
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,m;
  cin>>n>>m;
  if(n>=m){
    cout<<0<<endl;
    return 0;
  }
  vector<int> x;
  REP(i,m){
    int t;
    cin>>t;
    x.pb(t);
  }
  VSORT(x);

  vector<int> v;
  REP(i,m-1){
    v.pb(x[i+1] - x[i]);
  }
  sort(v.rbegin(), v.rend());

  int menjo = 0;
  REP(i,n-1){
    menjo += v[i];
  }

  int saSum = x[x.size()-1] - x[0];

  cout<<saSum - menjo;

  return 0;
}

Measured memory_bytes: 1400
/* ex9_1
   Graku */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef struct node {
    struct node *next;
    char binary;
}node;

int get_last(node *l);
node* pop(node *l);
node* push(node *l, char n);

int main() {
    node *list = NULL;
    int count = 0;
    char s[100000];
    scanf("%s", s);

    for (int i = 0; i < strlen(s); i++) {
        if (list == NULL) { //list is empty
            list = push(list, s[i]);
        }
        else if (list->binary != s[i]) {
            list = pop(list);
            count += 2;
        }
        else {
            list = push(list, s[i]);
        }
    }

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

node* pop(node *list) {
    if (list == NULL) { //list is empty
        printf("Error: list is NULL\n");
        exit(1);
    }
    if (list->next == NULL) { //list has one element
        return NULL; //list is empty
    }
    node *head = list->next;
    free(list);
    return head;
}

node* push(node *list, char c) {
    node *new = malloc(sizeof(node)); //new element
    new->next = list; //new is end of list
    new->binary = c;
    return new;
}

Measured memory_bytes: 4836
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;

int main(){
    ll N;
    cin >> N;
    vector<ll> W(N,0);
    vector<ll> sumuntil(N,0);
    for(ll i=0;i<N;i++){
        cin>>W[i];
    ;}
    sumuntil[0]=W[0];
    for(ll i=1;i<N;i++){
        sumuntil[i]=sumuntil[i-1]+W[i];
    ;}
    ll ans=INF; 
    for(ll i=1;i<N-1;i++){
        ans=min(ans,llabs(sumuntil[i]-sumuntil[N-1]+sumuntil[i]))
    ;}
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
m,d=map(int,input().split())
ans=0
if m>1 and d>1:
  for i in range(2,m+1):
    for j in range(2,d+1):
      if i==(j//10)*(j%10) and j//10!=1 and j%10!=1:
        ans+=1
        #print(i,j)
      
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define s second
#define f first
long long const mod = 1000000007; 
#define inf 1000000000000000000
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod)+mod)%mod;}
inline ll mul(ll a, ll b){ return (((a%mod)*(b%mod))%mod+mod)%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

ll power(ll x,ll y,ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
}

ll modInv(ll x)
{
    return power(x,mod-2,mod)%mod;
}

ll dp[1000][10001];
ll func(ll h,ll i,ll n,ll a[],ll b[])
{
    if(h<=0)
        return 0;
    
    if(i==n)
        return inf;
        
    if(dp[i][h]!=-1)
        return dp[i][h];
    
    ll ans1=func(h-a[i],i,n,a,b);
    if(ans1!=inf)
        ans1=ans1+b[i];
    ll ans2=func(h,i+1,n,a,b);
    dp[i][h]=min(ans1,ans2);
    return min(ans1,ans2);
}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll h,n;
    cin>>h>>n;
    ll ans=0;
    ll a[n],b[n];
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];
    
    memset(dp,-1,sizeof(dp));
    
    cout<<func(h,0,n,a,b)<<endl;
    
    return 0;
}

Measured memory_bytes: 79104
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	long long n, k, x, y;
	cin >> n >> k >> x >> y;
	cout << x * min(n, k) + y * max(0LL, n - k) << endl;
	return 0;
}


Measured memory_bytes: 256
a=input()
b=input()
c=input()
from collections import deque
da=deque(list(a))
db=deque(list(b))
dc=deque(list(c))
now=da.popleft()
while (1):
  if now=="a":
    if da:
      now=da.popleft()
    else:
      break
  elif now=="b":
    if db:
      now=db.popleft()
    else:
      break
  elif now=="c":
    if dc:
      now=dc.popleft()
    else:
      break
print(now.upper())

Measured memory_bytes: 9360
n = int(input())
a = list()
a.append(1)
a.append(6)
a.append(6*6)
a.append(6*6*6)
a.append(6*6*6*6)
a.append(6*6*6*6*6)
a.append(6*6*6*6*6*6)
a.append(9)
a.append(9*9)
a.append(9*9*9)
a.append(9*9*9*9)
a.append(9*9*9*9*9)
a.sort()
T = [0]+[float('inf')]*n
for i in range(len(a)):
    for j in range(a[i], n+1):
        T[j] = min(T[j], T[j-a[i]]+1)
print(T[-1])

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

string S;
void search(long ret, long pooled, int position, long &count){
  if (position == (S.size() - 1)){
    //cout << ret + pooled * 10 + S[position] - '0' << endl;
    count += ret + pooled * 10 + S[position] - '0';
    //cout << ret + pooled + S[position] - '0' << endl;;
    count += ret + pooled + S[position] - '0';
    return;
  }
  search(ret+pooled, S[position]-'0', position+1, count);
  search(ret, pooled * 10 + S[position] - '0', position+1, count);
  return;
}


int main(){
  cin >> S;
  int val = 0;
  long count = 0;
  search(0, 0, 0, count);
  cout << count / 2 << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <random>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef complex<ld> compd;
#define rep(i,n)	for(int i=0;i<n;i++)
#define srep(i,a,n)	for(int i=a;i<n;i++)
#define REP(i,n)	for(int i=0;i<=n;i++)
#define SREP(i,a,n)	for(int i=a;i<=n;i++)
#define rrep(i,n)	for(int i=n-1;i>=0;i--)
#define RREP(i,n)	for(int i=n;i>=0;i--)
#define all(a)	(a).begin(),(a).end()
#define mp(a,b)	make_pair(a,b)
#define mt	make_tuple
#define pb	push_back
#define fst	first
#define scn second
#define bicnt(x)	__buildin__popcount(x)
#define gcd(a,b)	__gcd__(a,b)
#define debug(x)	cout<<"debug: "<<x<<endl
#define DEBUG 0
const ll inf = (ll)1e18;
const ll mod = 1e9 + 7;
const ld eps = 1e-9;
const int dx[] = { 0,1,0,-1 };
const int dy[] = { 1,0,-1,0 };

ll dp[2010][2];
bool visited[2010][2];
vector<ll> a;
int n, z, w;

ll solve(int cur, ll diff, bool turn) {
	// cout << cur << " " << diff << " " << turn << endl;
	if (cur == n)	return dp[cur][turn] = diff;
	if (visited[cur][turn])	return dp[cur][turn];
	visited[cur][turn] = true;
	int next = cur;
	dp[cur][turn] = (turn ? inf : 0);
	while (next < n) {
		ll newval = solve(next + 1, labs(a[next] - a[cur-1]), turn ^ 1);
	// 	cout << newval << endl;
		if (turn) {
			dp[cur][turn] = min(dp[cur][turn], newval);
		}
		else {
			dp[cur][turn] = max(dp[cur][turn], newval);
		}
		next++;
	}
	return dp[cur][turn];
}

int main() {
	cin >> n >> z >> w;
	a.resize(n + 2);
	a[0] = z;	a[1] = w;
	rep(i, n)	cin >> a[i + 2];
	n += 2;
	cout << solve(2, labs(z-w), false) << endl;
	return 0;
}

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

int main(){
  int n;
  cin >>n;
  string s;
  cin >>s;
  int p=300010;
  vector<int>vec(n);
  int a=0;
  for(int i=0;i<n;i++){
    if(s[i]=='E'){
      a++;
    }
    vec.at(i)=a;
  }
  for(int i=0;i<n;i++){
    int sum=0;
    if(i>=1){
      sum=i-vec.at(i-1)+vec.at(n-1)-vec.at(i);
    }
    else{
      sum=vec.at(n-1)-vec.at(0);
    }
    p=min(sum,p);
      
  }
  cout << p <<endl;
}
      


Measured memory_bytes: 4764
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

int main(){
    int x,a;
    cin>>x>>a;
    if(x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
    return 0;
}


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

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

	for(int i=0;i<n;i++){
		cin>>a>>b;
		if(a%b==0){
			cout<<b<<endl;
		}else{
			cout<<a%b<<endl;
		}
	}	
}

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


int main(){
  int N;
  cin >> N;
  vector<int>H(N);
  for(int i=0;i<N;i++){
    cin >> H[i];
  }
  int Max=0;
  int current=0;
  for(int i=0;i<N;i++){
    if(H[i]<Max)continue;
    for(int j=i;j<N-1;j++){
      i=j;
      if(H[j]<H[j+1]){
        break;
      }
      current++;
    }
    if(Max<current){
      Max=current;
    }
    current=0;
  }

  cout << Max<<endl;

  return 0;
}

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

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if((0 <= a) && (a <= 100)){
        if((0 <= b) && (b <= 100)){
            if((0 <= c) && (c <= 100)){
                if((a<b)&&(b<c)){
                    cout << "Yes" << endl;
                }
                else{
                    cout << "No" << endl;
                }
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e5 + 100;
const LL INF = 1e9;

void print_a(VL v)
{
    if(v.size()) cout<<v[0];
    loop(i,1,v.size()) cout<<' '<<v[i];
    cout<<'\n';
}

VVI init_vvi(int n, int m, int val)
{
    return VVI(n,VI(m,val));
}

VVL init_vvl(int n, int m, LL val)
{
    return VVL(n,VL(m,val));
}

void inv_mod(LL a, LL b, LL &x, LL &y)
{
    if(a == 0)
    {
        x = 0; y = 1;
        return;
    }

    LL x1, y1;
    inv_mod(b%a,a,x1,y1);
    y = x1;
    x = y1 - (b/a)*x1;
}

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int k;
    string s;
    cin>>k>>s;
    int n = s.length();

    LL num[k], dv, inv[k+1], p25[k+1], p26[k+1];
    num[0] = n;
    loop(i,1,k) num[i] = (num[i-1] * (n + i)) % MOD;

    inv[0] = inv[1] = 1;
    dv = 1;
    loop(i,2,k+1)
    {
        dv = (dv * i) % MOD;
        if(dv != 1)
        {
            LL x, y;
            inv_mod(dv,MOD,x,y);
            inv[i] = (x + MOD) % MOD;
        }
    }

    p25[0] = p26[0] = 1;
    loop(i,1,k+1)
    {
        p25[i] = (p25[i-1] * 25) % MOD;
        p26[i] = (p26[i-1] * 26) % MOD;
    }

    LL ans = 0, ans1;
    loop(i,0,k+1)
    {
        if(i < k) ans1 = num[k-1-i];
        else ans1 = 1;
        ans1 = (ans1 * inv[k-i]) % MOD;
        ans1 = (ans1 * p25[k-i]) % MOD;
        ans1 = (ans1 * p26[i]) % MOD;
        ans = (ans + ans1) % MOD;

        //watch(i);
        //if(i < k) watch(num[k-i-1]);
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n) cin>>a[i];
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n) cin>>a[i];
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


Measured memory_bytes: 35680
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include <typeinfo>
#include <stdlib.h>
#define ll long long
const int MOD = 1000000007;
using namespace std;

int main() {
	int n, m, a[51][51] = {};
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int tmp1, tmp2;
		cin >> tmp1 >> tmp2;
		a[tmp1][tmp2]++; 
		a[tmp2][tmp1]++;
	}
	for (int i = 1; i <= n; i++) {
		int sum = 0;
		for (int j = 1; j <= 50 ; j++) {
			sum += a[i][j];
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		int N = GetInt();
		long[] A = new long[N];
		for(int i = 0; i < N; i++)
			A[i] = GetLong();

		long ans = 0;
		long tmp = 0;
		for(int i = 0; i < N; i++)
		{
			if(A[i] != 0)
			{
				tmp += A[i];
			}
			else
			{
				ans += tmp / 2;
				tmp = 0;
			}
		}
		if(tmp != 0)
			ans += tmp / 2;

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 17872
while True:
    try:
        A = list(input())
    except:
        break

    A2 = []
    for i in range(9):
        n = int(A[i]) + int(A[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A2.append(n_2)
    A3 = []
    for i in range(8):
        n = int(A2[i]) + int(A2[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A3.append(n_2)
    A4 = []
    for i in range(7):
        n = int(A3[i]) + int(A3[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A4.append(n_2)
    A5 = []
    for i in range(6):
        n = int(A4[i]) + int(A4[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A5.append(n_2)
    A6 = []
    for i in range(5):
        n = int(A5[i]) + int(A5[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A6.append(n_2)
    A7 = []
    for i in range(4):
        n = int(A6[i]) + int(A6[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A7.append(n_2)
    A8 = []
    for i in range(3):
        n = int(A7[i]) + int(A7[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A8.append(n_2)
    A9 = []
    for i in range(2):
        n = int(A8[i]) + int(A8[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A9.append(n_2)
    A10 = []
    for i in range(1):
        n = int(A9[i]) + int(A9[i+1])
        n_str = str(n)
        n_2 = n_str[len(n_str)-1]
        A10.append(n_2)
    print(int(A10[0]))


Measured memory_bytes: 5620
N, K = map(int, input().split())
h = []
for i in range(N):
	h.append(int(input()))
h.sort()
ans = max(h) - min(h)
for i in range(N - K + 1):
	k = h[i + K - 1] - h[i]
	if k < ans:
		ans = k
print(ans)

Measured memory_bytes: 7384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    array<int, 4> a;
    rep(i, 4) cin >> a[i];
    int sum = accumulate(all(a), 0);
    int ans = INF;
    rep(i, 1, 4) {
        int s = a[0] + a[i];
        ans = min(ans, abs(s - (sum - s)));
    }
    write(ans);
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void){
    int n, m;
    scanf("%d %d", &n, &m);
    int a[n];
    for(int i = 0;i < n;i++){
        a[i] = 1;
    }
    int l = 1;
    int r = n;
    for(int i = 0;i < m;i++){
        int li, ri;
        scanf("%d %d", &li, &ri);
        if(li > l)l = li;
        if(ri < r)r = ri;
    }
    if(r-l < 0)printf("0\n");
    else printf("%d\n", r-l+1);
    return 0;
}

Measured memory_bytes: 512
dic = {}
l = []
n = int(input())
for i in range(n):
    s = input()

#sが新規キーか否かで操作を変える
    if s in dic:
        dic[s] += 1
#新規ではないならvalueを1増やす
    else:
        dic[s] = 1
          
m = max(dic.values())

for i in dic:
    if dic[i] == m:
        l += [i]

print(*sorted(l))

Measured memory_bytes: 36496
#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>;

void Main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i,N) {cin >> a[i];}
  int cnt[9] = {0};
  rep(i,N) {
    if (a[i] < 3200) cnt[a[i]/400]++;
    else cnt[8]++;
  }
  int kind = 0;
  rep(i,8) {
    if (cnt[i] > 0) kind++;
  }
  if(cnt[8] > 0) cout << max(kind,1) << " " << kind + cnt[8] << endl;
  else cout << kind << " " << kind << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


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

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define RREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define RFOR(i, a, b) for (ll i = a; i >= (ll)(b); i--)
#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[ ";
    for (auto a : v) os << a << " ";
    os << "]";
    return os;
}

int main() {
    int X, Y;
    cin >> X >> Y;
    double a = (Y - 2 * X) / 2;
    double b = X - a;

    if ((Y - 2 * X) % 2 == 0 && a >= 0 && b >= 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

// a + b = x
// 2a + 4b = y
// 2a + 2b = 2x
// 2b = y-2x
// b = (y-2x)/2

Measured memory_bytes: 3632
#include<stdio.h>

int main(void)

{

int a,b,d,r;


double f;


scanf("%d",&a);


scanf("%d",&b);


d=a/b;


r=a%b;


f=(double)a/(double)b;


printf("%d %d %lf\n",d,r,f);


return 0;


}

Measured memory_bytes: 636
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	min := a*x + b*y

	xyMin := int(math.Min(float64(x), float64(y)))
	if ab := xyMin*2*c + (x-xyMin)*a + (y-xyMin)*b; ab < min {
		min = ab
	}
	xyMax := int(math.Max(float64(x), float64(y)))
	if abAll := xyMax * 2 * c; abAll < min {
		min = abAll
	}

	fmt.Println(min)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int r, g, b;
    cin >> r >> g >> b;

    if ((g * 10 + b) % 4 == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		Console.WriteLine(A.Contains(A.Sum() / 2) && A.Sum() % 2 == 0 ? "Yes" : "No");
	}
	int[] A;
	public Sol(){
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main()
{
  ll n,k;
  cin>>n>>k;
  vector<pair<ll,ll>> sections;
  for (int i = 0; i < k; ++i)
  {
    ll l,r;
    cin>>l>>r;
    sections.push_back({l,r});
  }
  vector<ll> f(2*n+100,0),a(2*n+100,0);
  f[1]=1;
  for (int i = 1; i < n; ++i)
  {
    for (int j = 0; j < k; ++j)
    {
      ll l=sections[j].first;
      ll r=sections[j].second;
      a[i+l]+=f[i];
      a[i+r+1]+=(mod-f[i]);
      a[i+l]%=mod;
      a[i+r+1]%=mod;
    }
    if (i==1) f[i+1]=a[i+1];
    else f[i+1]=f[i]+a[i+1];
    f[i+1]%=mod;
  }
  cout<<f[n]<<endl;
}

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

using namespace std;

const int maxN = 100000;

int N;
int A[maxN];
int B[maxN];
int av[maxN];
int bv[maxN];
int p[maxN];
bool vis[maxN];

bool answer() {
	memcpy(av, A, sizeof A[0] * N);
	sort(av, av + N);
	memcpy(bv, B, sizeof B[0] * N);
	sort(bv, bv + N);
	for (int i = 0; i < N; i++) {
		if (av[i] > bv[i])
			return false;
	}
	for (int i = 1; i < N; i++) {
		if (av[i] <= bv[i - 1])
			return true;
	}
	for (int i = 0; i < N; i++) {
		int u = lower_bound(av, av + N, A[i]) - av;
		int v = lower_bound(bv, bv + N, B[i]) - bv;
		p[u] = v;
	}
	int c = 0;
	for (int i = 0; i < N; i++) {
		if (vis[i])
			continue;
		for (int u = i; !vis[u]; u = p[u])
			vis[u] = true;
		c++;
	}
	return c > 1;
}

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

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

	cout << (answer() ? "Yes" : "No") << '\n';

	return 0;
}


Measured memory_bytes: 2304
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m,r=map(int,input().split())
    R=list(map(lambda x:int(x)-1,input().split()))
    A=[[INF]*n for _ in range(n)]
    for _ in range(m):
        a,b,c=map(int,input().split())
        a-=1; b-=1
        A[a][b]=A[b][a]=c

    from itertools import product
    for k,i,j in product(range(n),repeat=3):
        A[i][j]=min(A[i][j],A[i][k]+A[k][j])

    from itertools import permutations
    ans=INF
    for p in permutations(R):
        score=0
        for i in range(r-1):
            score+=A[p[i+1]][p[i]]
        ans=min(ans,score)
    print(ans)
resolve()

Measured memory_bytes: 59612