akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] x = new int[N+1];
		
		for(int i=2;i<=N;i++) {
			int a = sc.nextInt();
			x[a]++;
		}
		
		for(int i=1;i<=N;i++) {
			out.println(x[i]);
		}
		
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, int[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private String join(String delimiter, long[] a) {
		StringBuilder sb = new StringBuilder();

		for (int i = 0; i < a.length; i++) {
			sb.append(a[i]);
			sb.append(delimiter);
		}
		return sb.substring(0, Math.max(sb.length() - delimiter.length(), 0));
	}

	@SuppressWarnings("unused")
	private int max(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long max(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate > arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int min(int[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		int candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private long min(long[] arr) {
		if(arr == null || arr.length == 0) {
			throw new IllegalArgumentException(Arrays.toString(arr));
		}

		long candidate = arr[0];
		for(int i=1;i<arr.length;i++) {
			candidate = candidate < arr[i] ? candidate : arr[i];
		}
		return candidate;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private long[] nextLongArray(Scanner sc, int n) {
		long[] result = new long[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextLong();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 59864
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <math.h>
#define rep(i,ini,n) for(int i=ini;i<n;i++)
using namespace std;
typedef long long ll;

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

    string S;
    cin >> S;
    int n = 4;

    rep(bit,0,1<<4){ // decide place to put + or - in array S
        int sum = S[0] - '0';
        vector<string> vs(3);
        rep(i,0,3){ // decide + and -
            if(bit & (1<<i)){ // if there is i in bit
                sum += S[i+1] - '0';
                vs[i] = "+";
            }else{
                sum -= S[i+1] - '0';
                vs[i] = "-";
            }
        }

        if(sum==7){
            cout << S[0];
            rep(i, 1, 4) cout << vs[i - 1] << S[i];
            cout << "=7" << endl;
            break;
        }
    }
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string S, answer = "CODEFESTIVAL2016";
    int count = 0;
    cin >> S;
    list<char> lst;
    for (int i = 0; i < S.size(); ++i) {
        if (S[i] != answer[i]) ++count;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
    
	int N=0, K= 0, z= 1;
	scanf("%d\n%d", &N, &K);
	for (int i = 0; i < N; i++) {
		if (2 * z <= z + K) {
			z *= 2;
		} else {
			z += K;
		}
	}
 
	printf("%d\n", z);
    return 0;
}

Measured memory_bytes: 1732
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		int[] c = new int[m];
		int[] d = new int[m];
		for (int i = 0; i < m; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}

		for (int i = 0; i < n; i++) {
			int min = manh(a[i], b[i], c[0], d[0]), idx = 0;
			for (int j = 1; j < m; j++) {
				int dist = manh(a[i], b[i], c[j], d[j]);
				if (dist < min) {
					min = dist;
					idx = j;
				}
			}
			out.println(idx + 1);
		}

		out.flush();
	}

	static int manh(int x1, int y1, int x2, int y2) {
		return Math.abs(x1 - x2) + Math.abs(y1 - y2);
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) { return false; }
		}
		return true;
	}

	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}

	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public long nextLong() {
		if (!hasNext()) { throw new NoSuchElementException(); }
		long n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) { throw new NumberFormatException(); }
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

}

Measured memory_bytes: 23124
n, u, v = map(int, input().split())
tree = [[] for i in range(n+1)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

dist1 = [100005]*(n+1)

q = []
q.append(v)
dist1[v] = 0
while q:
    now = q.pop()
    for next in tree[now]:
        if dist1[next] == 100005:
            q.append(next)
            dist1[next] = dist1[now] + 1


dist2 = [100005]*(n+1)

q = []
q.append(u)
dist2[u] = 0
while q:
    now = q.pop()
    for next in tree[now]:
        if dist2[next] == 100005:
            q.append(next)
            dist2[next] = dist2[now] + 1

for i in range(1, n+1):
    if dist1[i] <= dist2[i]:
        dist2[i] = -1

for i in range(1, n+1):
    if dist2[i] != -1:
        dist2[i] = 100005

q = []
q.append(u)
dist2[u] = 0
while q:
    now = q.pop()
    for next in tree[now]:
        if dist2[next] == 100005:
            q.append(next)
            dist2[next] = dist2[now] + 1



ans = 0
for i in range(1, n+1):
    if dist2[i] != -1:
        ans = max(ans, dist1[i])

print(ans-1)


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

int main() {
    string a, b; cin >> a >> b;
    if(a.length() < b.length()) cout << "LESS" << endl;
    else if(a.length() > b.length()) cout << "GREATER" << endl;
    else {
        for(int i = 0; i < a.length(); i ++) {
            if(i==a.length()-1 && a[i]==b[i]) {
                cout << "EQUAL" << endl;
                return 0;
            }
            if(a[i]==b[i]) continue;
            else if(a[i]>b[i]) {
                cout << "GREATER" << endl;
                return 0;
            }
            else {
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  if(n%2==1){
    cout<<"No\n";
    return 0;
  }

  for(int i=0; i<n/2; i++){
    if(s[i]!=s[n/2+i]){
      cout<<"No\n";
      return 0;
    }
  }
  cout<<"Yes\n";
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
PY = []
for i in range(M):
    PY.append(list(map(int,input().split())))
    PY[-1].append(i)

PY_sorted = sorted(PY, key=lambda x: x[1])
PY_sorted2 = sorted(PY_sorted, key=lambda x: x[0])

PY = PY_sorted2
p = 0
y = 1
for i in range(M):
    if p != PY[i][0]:
        y = 1
    p = PY[i][0]
    identityString = str(PY[i][0]).zfill(6) + str(y).zfill(6)
    PY[i].append(identityString)
    y += 1

PY_sorted = sorted(PY, key=lambda x: x[2])

for i in range(M):
    print(PY_sorted[i][3])

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

int main() {
	int N;
	int T, A;
	cin >> N;
	cin >> T >> A;
	vector<float> H;
	vector<float> temp;
	H.resize(N);
	temp.resize(N);
	float k = 0;
	float basho;
	for (int n = 0; n < N; ++n) {
		cin >> H[n];
		temp[n] = T - H[n] * 0.006;
		float buf;
		buf = abs(temp[n] - float(A));
		if (n == 0) {
			k = abs(temp[n] - float(A));
			basho = n + 1;
		}
		else {
			if (k > buf) {
				k = buf;
				basho = n + 1;
			}
		}
	}
	cout << basho << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, n;
    cin >> a >> b >> n;
    ll flag = min(b - 1, n);
    ll i = flag;
    ll num = (a * i) / b - a * (i / b);
    cout << num << endl;


}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb   push_back
#define T int time;        scanf("%d", &time); while(time--)
    struct aray{
        ll a,b;
    };
//aray a[10000],b[100000];
int main(){
     //T{
      string s;
      cin>>s;
      if(s[s.length()-1] == 's')   s+="es";
    else if( s[s.length()-1] != 's' )    s+='s';

      cout<<s<<endl;


} 

Measured memory_bytes: 3596
import sys
import bisect
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N = int(input())
A = [0]*N
for i in range(N):
    A[i] = int(input())
C = []
for a in A:
    k = bisect.bisect_right(C,-a)
    if k >= len(C):
        C.append(-a)
    else:
        C[k] = -a
print(len(C))

Measured memory_bytes: 46172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
#define keta fixed<<setprecision
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	int n;
	std::cin >> n;
	vector<vector<vector<int> > > a(4, vector<vector<int> >(3, vector<int>(10,0)));
	rep(i,n){
		int b,f,r,v;
		std::cin >> b>>f>>r>>v;
		a[b-1][f-1][r-1]+=v;
	}
	rep(i,4){
		rep(j,3){
			rep(k,10)std::cout <<" "<< a[i][j][k] ;
		//	std::cout << a[i][j][9] << std::endl;
		    std::cout  << std::endl;
		}
		if(i!=3)std::cout << "####################" << std::endl;
	}
}


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

int main() {
  int N,G;
  scanf("%d %d", &N,&G);
  int p[N],c[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &p[i],&c[i]);
  }

  int maxcount = 1000000;

  for(int x=0;x<(1<<N);x++){
    int sum = 0;
    int count = 0;
    for(int i=0;i<N;i++){
      if(x&(1<<i)){
        sum += p[i]*(i+1)*100 + c[i];
        count += p[i];
        //cout << sum << endl;
      }
    }

    for(int i=N-1;i>=0;i--){
      if(!(x&(1<<i))){
        for(int j=0;j<(p[i]-1);j++){
          if(sum<G){
            sum += (i+1)*100;
            ++count;
            //cout << i << endl;
            //cout << j << endl;
            //cout << sum << endl;
          }
        }
        break;
      }
    }
    if(maxcount>count && sum>=G) {
      maxcount = count;
      //cout << sum << endl;
      //cout << count << endl;
      //cout << x << endl;
    }
    //else{
      //cout << sum << endl;
      //cout << count << endl;
    //}

    
  }

  cout << maxcount << endl;

}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int N, K;
long long int ans;

int main() {
	cin >> N;
	ans = N / 11;
	ans *= 2;
	if (N % 11)ans++;
	if (N % 11 > 6)ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]
const ll MOD = 1000000007;
signed main(){
    int h,w,k;
    cin >> h >> w >> k;
    k--;
    if(w==1){
        if(k==0) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    ll num[w-1],no[w];
    
    rep(i,w-1) num[i]=0;
    rep(i,w) no[i]=0;
    
    rep(i,(1<<(w-1))){
        bool kuji[w-1];
        rep(j,w-1){
            if(i&(1<<j)){
                kuji[j]=1;
            }else kuji[j]=0;
        }
        bool aa=0;
        rep(j,w-2) if(kuji[j]&&kuji[j+1]) aa=1;
        if(aa) continue;
        rep(j,w-1){
            if(kuji[j]) num[j]++;
            if(0<j&&!kuji[j]&&!kuji[j-1]) no[j]++;
        }
        if(!kuji[0]) no[0]++;
        if(!kuji[w-2]) no[w-1]++;
    }
    ll dp[h+1][w];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,h+1){
        if(i==0) continue;
        rep(j,w){
            if(j>0) dp[i][j]+=(dp[i-1][j-1]*num[j-1])%MOD;
            dp[i][j]%=MOD;
            if(j+1<w) dp[i][j]+=(dp[i-1][j+1]*num[j])%MOD;
            dp[i][j]%=MOD;
            dp[i][j]+=(dp[i-1][j]*no[j])%MOD;
            dp[i][j]%=MOD;
        }
    }
    cout << dp[h][k] << endl;
}


Measured memory_bytes: 256
loop_len = int(input())
import math
for i in range(loop_len):
    l=list(map(int,input().split()))
    if math.hypot(l[0],l[1])==l[2]:
        print('YES')
    elif math.hypot(l[1],l[2])==l[0]:
        print('YES')
    elif math.hypot(l[2],l[0])==l[1]:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 5668
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    map<string,long long> mp;
    map<string,long long> inc;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        sort(s.begin(),s.end());
        if(mp.find(s)==mp.end()){
            mp[s]=0;
            inc[s]=0;
        }
        else {
            inc[s]++;
            mp[s]+=inc[s];
        }
    }
    long long ans=0;
    for(auto itr = mp.begin();itr!=mp.end();itr++){
        ans+=itr->second;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 22144
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> p(m), y(m);
    vector<vector<pair<int, int> > > v(n);
    for(int i=0; i<m; ++i){
        cin >> p[i] >> y[i];
        v[p[i]-1].push_back(make_pair(y[i], i));
    }
    for(int i=0; i<n; ++i){
        sort(v[i].begin(), v[i].end());
        for(unsigned j=0; j<v[i].size(); ++j){
            y[v[i][j].second] = j + 1;
        }
    }

    for(int i=0; i<m; ++i){
        printf("%06d%06d\n", p[i], y[i]);
    }

    return 0;
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
#define MK make_pair 



int main(){
  while(1){




    
  pair<int,int> a[1000];
  int xmx=0,xmi=0,ymx=0,ymi=0;
  a[0]=MK(0,0);
  int n;
  cin>>n;
  if(n==0){break;}
  for(int i=1;i<n;i++){
    int w,t;
    cin>>w>>t;
    int p=0,q=0;
    if(t==0){q=-1;}
    if(t==1){p=-1;}
    if(t==2){q=1;}
    if(t==3){p=1;}
    a[i]=MK(a[w].first+p,a[w].second+q);
    xmx=max(xmx,a[i].first);
    xmi=min(xmi,a[i].first);
    ymx=max(ymx,a[i].second);
    ymi=min(ymi,a[i].second);
  }
  cout<<ymx-ymi+1<<" "<<xmx-xmi+1<<endl;









  }
  return 0;
}



Measured memory_bytes: 3084
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Extentions;

class IO
{
    int idx;
    string[] input = In.ReadToEnd().Split(new[] { " ", "\n", "\r" },
        StringSplitOptions.RemoveEmptyEntries);

    T Get<T>(Func<string, T> parser) => parser(input[idx++]);

    public string S => Get(s => s);
    public char C => Get(char.Parse);
    public int I => Get(int.Parse);
    public long L => Get(long.Parse);
    public double F => Get(double.Parse);
    public decimal D => Get(decimal.Parse);
    public BigInteger B => Get(BigInteger.Parse);

    T[] Gets<T>(int n, Func<string, T> parser)
        => input.Skip((idx += n) - n).Take(n).Select(parser).ToArray();

    public string[] Ss(int n) => Gets(n, s => s);
    public char[] Cs(int n) => Gets(n, char.Parse);
    public int[] Is(int n) => Gets(n, int.Parse);
    public long[] Ls(int n) => Gets(n, long.Parse);
    public double[] Fs(int n) => Gets(n, double.Parse);
    public decimal[] Ds(int n) => Gets(n, decimal.Parse);
    public BigInteger[] Bs(int n) => Gets(n, BigInteger.Parse);

    public void Write<T>(params T[] xs) => WriteLine(string.Join(" ", xs));
    public void Write(params object[] xs) => WriteLine(string.Join(" ", xs));
}

#region Library

static class Extentions
{
}

#endregion

static class Program
{
    public static void Main()
    {
        var sw = new StreamWriter(OpenStandardOutput()) { NewLine = "\n" };
#if DEBUG
        sw.AutoFlush = true;
#else
        sw.AutoFlush = false;
#endif
        SetOut(sw);
        Solve(new IO());
        Out.Flush();
    }

    static void Solve(IO io)
    {
        var a = io.I;
        var b = io.I;

        io.Write((a + b) % 24);
    }
}

Measured memory_bytes: 11220
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
#print(a,b,c)

sat = 0
prev = -1
for i in range(n):
  #print("i;",i)
  #print("a;",a[i])
  #print("b;",b[a[i]-1])
  sat += b[a[i]-1]
  if(prev == a[i]-1):
    sat += c[a[i]-2]
    #print('c;',c[a[i]-2])
  prev = a[i]
print(sat)

Measured memory_bytes: 3064
import itertools
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for i in range(q)]
A=[i for i in range(1,m+1)]
arr=list(itertools.combinations_with_replacement(A, n))

ans=0
for i in arr:
  p=0
  for j in range(q):
    a,b,c,d=abcd[j][0],abcd[j][1],abcd[j][2],abcd[j][3]
    if i[b-1]-i[a-1]==c:
      p+=d
  ans=max(ans,p)
print(ans)

Measured memory_bytes: 84716
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    sum_d = 0
    for num in num_list:
        sum_d ^= num

    ans_list = []
    for num in num_list:
        ans_list.append(sum_d ^ num)

    print(*ans_list)

if __name__ == '__main__':
    main()


Measured memory_bytes: 111608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const ll MOD = 1e9+7;

int N, K;
vector<vector<int>> G;

ll dfs(int cur, int pre) {
    int col = K - 1;
    if(pre != -1) col--;
    ll ret = 1;
    for(auto e : G[cur]) {
        if(e == pre) continue;
        ret = ret * col % MOD;
        ret = ret * dfs(e, cur) % MOD;
        col--;
        if(col < 0) return 0;
    }
    return ret;
}

int main() {
    cin >> N >> K;
    G.resize(N);
    rep(i, 0, N-1) {
      int a, b; cin >> a >> b;
      a--, b--;
      G[a].push_back(b); G[b].push_back(a);
    }
    ll ans = K * dfs(0, -1) % MOD;
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
#define MOD1 1000000007
#define MOD2 1000000009
#define FOR(a,b) for(int i=a;i<b;i++)
#define nl "\n"

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

  ll n;
  cin >> n;
  ll a[n];
  ll sum = 0;
  for (ll i = 0; i < n; i++)
  {
    cin >> a[i];
    sum += a[i];
  }
  ll ans = 0;
  for (ll i = 0; i < n - 1; i++)
  {
    sum -= a[i];
    ans = (ans % MOD1 + ((sum % MOD1) * (a[i] % MOD1)) % MOD1) % MOD1;
  }
  cout << ans;
  return 0;
}



Measured memory_bytes: 5168
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <utility>
#include <set>
#include <cmath>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define all(v) v.begin(),v.end()
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))
using namespace std;
typedef pair<int,int> point;
typedef complex<double> P;
typedef long long ll;

const double eps = 1e-8;
const double INF = 1e12;


double dot(P a,P b){
	return a.real()*b.real()+a.imag()*b.imag();
}
double cross(P a,P b){
	return a.real()*b.imag()-a.imag()*b.real();
}

bool is_orthogonal(P a1,P a2,P b1,P b2){
	return EQ(dot(a1-a2,b1-b2),0.0);
}
bool is_parallel(P a1,P a2,P b1,P b2){
	return EQ(cross(a1-a2,b1-b2),0.0);
}

bool is_point_on_line(P a,P b,P c){
	return EQ(cross(b-a,c-a),0.0);
}

bool is_point_on_linesegment3(P a,P b,P c){
	//|a-c| + |c-b|<=|a-b| ???????????????
	return (abs(a-c)+abs(c-b)<abs(a-b)+EPS);
}

double distance_l_p(P a,P b,P c){
	return abs(cross(b-a,c-a))/abs(b-a);
}


double distance_ls_p(P a,P b,P c){
	if(dot(b-a,c-a)<EPS)return abs(c-a);
	if(dot(a-b,c-b)<EPS)return abs(c-b);
	return abs(cross(b-a,c-a))/abs(b-a);
}

int main(){
	long long dt[50];
	rep(i,50)dt[i]=0;
	dt[1]=1;
	dt[2]=1;
	dt[3]=1;
	rep(i,30){
		dt[i+1]+=dt[i];
		dt[i+2]+=dt[i];
		dt[i+3]+=dt[i];
	}
	int n;
	while(cin>>n,n){
		if(dt[n]%3650!=0)cout<<dt[n]/3650+1<<endl;
		else cout<<dt[n]/3650<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        int[] best = {0, 0, 0};		// ??????????????????
        
        for(int i=0; i<10; i++){
            String line = br.readLine();			// ????????????
            int height = Integer.parseInt(line);	// ??°????????????
        	
            if(height > best[0]){	// ??\????????????????????´???
            	best[2] = best[1];
            	best[1] = best[0];
            	best[0] = height;
            }
            else if(height > best[1]){
            	best[2] = best[1];
            	best[1] = height;
            }
            else if(height > best[2]){
            	best[2] = height;
            }
        }
        
        for(int h: best){
        	System.out.println(h);
        }
	}

}

Measured memory_bytes: 24100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl "\n"

int main()
{
	
	ll n,m;
	cin>>n>>m;
	ll sum=0,x;
	for(int i=0;i<m;i++)
	{
		cin>>x;
		sum+=x;
	}
	if(sum>n)
		cout<<"-1\n";
	else
		cout<<(n-sum)<<endl;

    return 0;
}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<pair<int,int>>A(N);
    vector<pair<int,int>>B(N);
    
    for(int i=0;i<N;i++){
        cin>>A[i].second>>A[i].first;
    }
    for(int i=0;i<N;i++){
        cin>>B[i].first>>B[i].second;
    }
    
    sort(A.begin(),A.end(),greater<pair<int,int>>());
    sort(B.begin(),B.end());
    
    int ans=0;
    bool flag[100]={0};
    int tmp=0;
    int index=0;
    
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(A[j].second<B[i].first && A[j].first<B[i].second && !flag[j]){
                ans++;
                flag[j]=true;
                break;
            }
        }
    }
    
    cout<<ans<<endl;
    
}

Measured memory_bytes: 256
# vim: fileencoding=utf-8


def main():
    n = int(input())
    li = list(map(int, input().split()))
    c = 0
    end = False
    while True:
        for i in range(n):
            if li[i] % 2:
                end = True
                break
            li[i] = li[i] / 2
        if end:
            break
        else:
            c += 1
    print(c)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63592
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
		cerr << (*i) << " ";
    }
    cerr << "\n";
}

ll cnk[510][510];
const ll INF = 1e14;

ll ch(int x) {
	ll ans = 0;
	for (int i = 2; i <= x; i += 2)
		ans = min(INF, ans + cnk[x][i]);
	return ans;
}


int main() {
	for (int i = 0; i < 500; ++i)
		for (int j = 0; j < 500; ++j) {
			if (i == j || j == 0)
				cnk[i][j] = 1;
			else if (j > i)
				cnk[i][j] = 0;
			else
				cnk[i][j] = min(INF, cnk[i - 1][j - 1] + cnk[i - 1][j]);
		}
	vector<int> vv;
	ll n;
	cin >> n;
	for (int i = 0; i < 100; ++i)
		vv.push_back(i + 1);
	vector<int> nn;
	vector<ll> go;

	for (int i = 1;n; ++i) {
		ll now = 1;
		int fl = 0;
		for (int j = 0; j < go.size(); ++j) {
			if (now + go[j] > n) {
				nn.insert(nn.begin() + j, i);
				go.insert(go.begin() + j, now);
				n -= now;
				fl = 1;
				break;
			}
			else {
				now += go[j];
			}
		}
		if (!fl) {
			nn.push_back(i);
			go.push_back(now);
			n -= now;
		}
	}
	cout << vv.size() + nn.size() << "\n";
	for (int i: vv)
		cout << i << " ";
	for (int i: nn)
		cout << i << " ";
	cout << "\n";
	return 0;

	int now = 1;
	while (n) {
		int cnt = 1;
		for (int i = 2;; ++i) {
			if (ch(i) <= n)
				cnt = i;
			else
				break;
		}
		for (int i = 0; i < cnt; ++i)
			vv.push_back(now);
		++now;
		n -= ch(cnt);
	}
	cout << vv.size() << "\n";
	for (int i: vv)
		cout << i << " ";
	cout << "\n";
	return 0;
}




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

int main(){
    long N,A,B;
    cin >> N >> A >> B;
    long x = N / (A+B);
    long r = N % (A+B);
    long ans = A * x;
    if(A <= r){
        ans += A;
    }else{
        ans += r;
    }
    cout << ans << endl;
}

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

int main()
{
    int N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    int li, ri;
    vector<int> L, R;
    for(int i=0;i<Q;i++){
        cin >> li >> ri;
        L.push_back(li-1);
        R.push_back(ri-1);
    }
    vector<int> count(N, 0);
    for(int i=1;i<N;i++){
        count[i] = count[i-1];
        if(S[i-1]=='A' && S[i]=='C') count[i]++;
    }

    for(int i=0;i<Q;i++){
        cout<<count[R[i]]-count[L[i]]<<endl;
    }


    return 0;
}

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

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (int i = (l); i < (r); i++)
#define reper(i, l, r) for (int i = (r)-1; i >= (l); i--)

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

int main() {
    init();
    ll N;
    cin >> N;
    vl P(N);
    rep(i, N) cin >> P[i];
    ll m = P[0];
    ll ans = 1;
    rep(i, N) {
        if (P[i] < m) {
            ans++;
            m = P[i];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long int;

ll gcd(ll N, ll M) {
    if(M == 0) return N;
    return gcd(M, N%M);
}

ll lcm(ll N, ll M) {
    return N / gcd(N, M) * M;
}

ll get_prod(ll N) {
    ll res = 1;
    for(int k=2; k*k<=N; k++) {
        int cnt = 0;
        while(N % k == 0) {
            cnt++; N /= k;
        }
        if(cnt > 1) return -1;
        else if(cnt == 1) res = lcm(res, k - 1);
    }
    if(N > 1) res = lcm(res, N - 1);
    return res;
}

// オイラーの φ 関数 (n 以下の自然数のうち n と互いに素なものの個数)
// \phi(n) = n \times \prod_{i=1}^{k} (1 - \frac{1}{p_i}) を使おう
// (ただし、 p_i は n の素因数)
// Complexity: O(sqrt n)
// Vefiried: AOJ NTL_1_D: Euler's Phi Function

ll Euler_phi(ll n) {
    ll ret = n;
    for(int i=2; i*i <= n; i++) {
        if(n % i == 0) {
            ret -= ret / i;
            while(n % i == 0) n /= i;
        }
    }
    if(n != 1) ret -= ret / n;
    return ret;
}

ll mod_pow(ll N, ll K, ll mod) {
    ll res = 1;
    for(; K>0; K>>=1) {
        if(K & 1) (res *= N) %= mod;
        (N *= N) %= mod;
    }
    return res;
}

int main() {
    ll N; cin >> N;
    ll prod = get_prod(N);
    if(prod < 0 or gcd(N, prod) > 1) {
        cout << -1 << endl;
    }
    else {
        ll euler = Euler_phi(prod);

        ll ans = euler;
        for(ll k=1; k*k<=euler; k++) {
            if(mod_pow(N, k, prod) == 1) {
                ans = min(ans, k);
            }
            if(mod_pow(N, euler/k, prod) == 1) {
                ans = min(ans, euler/k);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define upd(a,b) a=add(a+b)
using namespace std;
inline char nc() {
//	return getchar();
	static char buf[100000],*l=buf,*r=buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x=0; int f=1,ch=nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x*=f;
}
typedef long long ll;
const int mod=1e9+7;
const int maxn=5000+5;
int n,A,B;
int f[maxn][2],g[maxn][2];
int dp[maxn][2][2];
inline int add(int x) {return x>=mod?x-mod:x;}
void DP(int dp[maxn][2]) {
	for(int i=0;i<n;++i) {
		upd(dp[i+1][1],dp[i][0]);
		upd(dp[i+1][1],dp[i][1]);
		for(int k=A;i+k<=n;++k) upd(dp[i+k][0],dp[i][1]);
	}
}
int main() {
	read(n),read(A),read(B);
	if(A>B) swap(A,B);
	f[0][0]=1,DP(f);
	g[0][0]=1;
	for(int i=A;i<=n;++i) g[i][0]=1;
	DP(g);
	dp[n][1][0]=g[n][0];
	for(int i=1;i<=n;++i) dp[i][i>=B][1]=g[i][1];
	for(int i=1;i<A;++i) dp[i][0][0]=1;
	for(int i=1;i<=n;++i) for(int k=0;k<2;++k) {
		for(int j=1;j<A&&i+j<=n;++j) upd(dp[i+j][k][0],dp[i][k][1]);
		for(int j=1;i+j<=n;++j) {
			int r=f[j][1]; if(i+j==n) upd(r,f[j][0]);
			upd(dp[i+j][k||j>=B][1],(ll)dp[i][k][0]*r%mod);
		}
	}
	printf("%d\n",add(dp[n][1][0]+dp[n][1][1]));
	return 0;
}

Measured memory_bytes: 3352
n,a,b,*v=map(int,open(0).read().split())
v=[0]+v
dp=[[[0,1]]+[[0,0]for j in range(b)]for i in range(n+1)]
for i in range(1,n+1):
  for j in range(1,b+1):
    if dp[i-1][j-1][0]+v[i]>dp[i-1][j][0]:
      dp[i][j]=[dp[i-1][j-1][0]+v[i],dp[i-1][j-1][1]]
    elif dp[i-1][j-1][0]+v[i]==dp[i-1][j][0]:
      dp[i][j]=[dp[i-1][j][0],dp[i-1][j][1]+dp[i-1][j-1][1]]
    else:
      dp[i][j]=[dp[i-1][j][0],dp[i-1][j][1]]
m=0
for i in range(a,b+1):
  m=max(m,dp[-1][i][0]/i)
print(m,sum(dp[-1][i][1]*(dp[-1][i][0]/i==m)for i in range(a,b+1)),sep='\n')

Measured memory_bytes: 3316
#include<stdio.h>
int main(void)
{
    int n, r;
    scanf("%d%d", &n, &r);
    if(n>=10)
    {
        printf("%d", r);
    }
    else
    {
        printf("%d", r + 100 * (10 - n));
    }
    return 0;
}





Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	for(int i=1;i<=3;i++)
	{
		if(i!=a&&i!=b)
		{
			printf("%d",i);
		}
	}
	return 0;
}

Measured memory_bytes: 256
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    sc.intarr()[0]
    h = sc.intarr()
    before = 0
    flag = False
    for i in h:
        if before - i >= 2:
            print('No')
            exit()
        if before - i >= 1:
            if flag:
                print('No')
                exit()
            flag = True
        if before - i < 0:
            flag = False
        before = i
    print('Yes')


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 15816
#include<bits/stdc++.h>
#define ll long long
#define lu long unsigned
#define ull unsigned long long

using namespace std;
bool sortbysec(const pair<string,int> &a,
              const pair<string,int> &b)
{
    return (a.second < b.second);
}
bool sortpair(const pair<int,int> &a,
              const pair<int,int> &b)
{
    if(a.first==b.first)
        return (a.second<b.second);
    else
        return(a.first>b.first);
}
bool s(const string &a, const string &b){
    bool ans;
    return (a.size()<b.size());
}
bool isPrime(int val){
    for(int i=2;i*i<=val;i++){
        if(val%i==0)
            return false;
    }
    return true;
}
ll int conc(ll int a,ll int b){
   stringstream ss;
   ss<<a<<b;
   ll int ans;
   ss>>ans;
   ss.clear();
   return ans;
}
ll int binexp(int a,int b){
    ll int res=1;
    while(b!=0){
        if(b&1){
            res*=a;
            b--;
        }else{
            a*=a;
            b/=2;
        }
    }
    return res;
}
int gcd(int a,int b){
    if(a%b==0){
        return b;
    }else{
        return gcd(a%b,b);
    }
}

void solve(){
    int n,sum=0;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        sum+=v[i];
    }
    sort(v.begin(),v.end());
    if(sum%10==0){
        for(int i=0;i<n;i++){
            if(v[i]%10!=0){
                sum-=v[i];
                break;
            }
        }
    }
    if(sum%10!=0)
    cout<<sum;
    else
    cout<<0;
}


int main(){
    /*int t;
    cin>>t;
    while(t--)*/
        solve();


    return 0;
}



































































//1-(3+5-2+(3+19-(3-1-4+(9-4-(4-(1+(3)-2)-5)+8-(3-5)-1)-4)-5)-4+3-9)-4-(3+2-5)-10




















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

int main(){
    int N,M,K;
    cin >> N >> M >> K;
    vector<int> A(N), B(M);
    for (int i=0; i<N; i++){
        cin >> A.at(i);
    }
    for (int i=0; i<M; i++){
        cin >> B.at(i);
    }
    vector<int64_t> A_sum(N+1), B_sum(M+1);
    for (int i=0; i<N+1; i++){
        if(i==0){
            A_sum.at(i)=0;
        }else{
            A_sum.at(i) = A.at(i-1) + A_sum.at(i-1);
        }
    }
    for (int i=0; i<M+1; i++){
        if(i==0){
            B_sum.at(i)=0;
        }else{
            B_sum.at(i) = B.at(i-1) + B_sum.at(i-1);
        }
    }

    int ans = 0;
    int j_max = M;
    for (int i=0; i<N+1; i++){
        if (A_sum.at(i)>K){
            break;
        }
        while (B_sum.at(j_max)>K-A_sum.at(i)){
            j_max--;
        }
        ans = max(ans, i+j_max);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<int> cnt(128, 0);
    for(int i=0; i<n; ++i)
        ++ cnt[s[i]];

    bool ans = true;
    for(char c='a'; c<='z'; ++c){
        if(cnt[c] % 2 != 0){
            ans = false;
            break;
        }
    }

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int i = n;
    if(n % 2 != 0){
        i++;
    }
    while(1){
        if(i % n == 0){
            break;
        }
        i += 2;
    }
    cout << i;
}




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

using namespace std;

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

    int a_last = a.length() - 1;
    int b_last = b.length() - 1;

    if (a[a_last] == b[0] && b[b_last] == c[0])
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 256
// 0-1 ナップサック その2
// 蟻本p60と同じ
// 重さに対する価値の値が小さいので、価値に対する最小の重さをDPで計算する

#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <cassert>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair

// N: 品物の個数
// W: ナップサックの容量
// MAX_V: 品物の最大の価値
// Vs: 品物の価値
// Ws: 品物の重さ
ll knapsack(ll N, ll W, ll MAX_V, vector<ll>& Vs, vector<ll>& Ws) {
    ll INF = 1e18;
    // dp[i+1][j] := i番目までの品物から価値の総和がjとなるように選んだときの
    //               重みの総和の最小値
    vector<vector<ll>> dp(N + 1, vector<ll>(N * MAX_V + 1, INF));
    dp[0][0] = 0;

    REP(i, N) {
        REP(j, N * MAX_V + 1) {
            if (j < Vs[i]) dp[i + 1][j] = dp[i][j];
            else dp[i + 1][j] = min(dp[i][j], dp[i][j - Vs[i]] + Ws[i]);
        }
    }
    ll ans = 0;
    REP(i, N * MAX_V + 1) {
        if (dp[N][i] <= W) ans = i;
    }
    return ans;
}

int main(){
    ll N, W;
    cin >> N >> W;
    vector<ll> Vs(N);
    vector<ll> Ws(N);
    REP(n, N) cin >> Vs[n] >> Ws[n];
    auto ans = knapsack(N, W, 100, Vs, Ws);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 10812
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#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;

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

  	Int N, i; cin >> N >> i;
    cout << N-i+1 << endl;
}


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


int main(){
    #ifdef LOCAL_MACHINE
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    
    double r;
    cin>>r;

    printf("%lf\n",2.0*acos(-1.0)*r);


    
    return 0;
}


Measured memory_bytes: 3788
// https://atcoder.jp/contests/abc155/tasks/abc155_c

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define ITR(c,it)  for(auto it = c.begin(); it != c.end(); it++)
#if 1
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(a) if (DEBUG) REP(_i, a.size()) DUMP(a[_i]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(a)
#endif

const int N_MAX = 2*1e5;

int N;
vector<string> S;

map<string, int> mp;
int cx = 0;

int main() {
  cin >> N;
  S = vector<string>(N);
  REP(i, N) cin >> S[i];

  REP(i, N) cx = max(cx, ++mp[S[i]]);

  ITR(mp, it) if (it-> second == cx) cout << it->first << endl;
}


Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
const ll num = 1e18;
int main() {
    ll a;
    double b;
    cin>>a>>b;
    ll nb=round(b*100);
    cout<<(ll)((a*nb)/100);
}

Measured memory_bytes: 3772
def f(l, n)
  ans = 0
  mod = 10**9 + 7
  dp = [0]
  l.reverse.each do |li|
  	dp.push((li+dp.last)%mod)
  end
  dp.pop
  dp.shift
  dp.reverse!
  
  dp.length.times do |i|
    ans += (l[i] % mod) * dp[i]
    ans %= mod
  end
  ans
end

n = gets.chomp.to_i
l = gets.chomp.split.map(&:to_i)
p f(l, l.length)

Measured memory_bytes: 34060
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   vector<int> a(3,0);

   rep(i,3){
      cin>>a[i];
   }
  


   int count=0;
   bool f=false;
   do{
       sort(a.begin(),a.end());
       if(a[0]==a[1] && a[1]==a[2]) f=true;
       else if (a[2]-a[0]>=2) {
          count++;
          a[0]+=2;
       }
       else {
          a[0]++;
          a[1]++;
          count++;
       }

   }while(f==false);

   cout<<count;
   
return 0;
}



Measured memory_bytes: 256
import sys
import math
import bisect
from collections import defaultdict,deque

# input = sys.stdin.readline
def inar():
    return [int(el) for el in input().split()]
# def find(a,b,c):
#     gc=math.gcd(a,b)
#     return math.gcd(gc,c)
def main():
    n=int(input())
    string=input()
    r=[]
    g=[]
    b=[]
    for i in range(n):
        if string[i]=="R":
            r.append(i)
        elif string[i]=="G":
            g.append(i)
        else:
            b.append(i)
    ans=0
    r.sort()
    g.sort()
    b.sort()
    # print(r)
    # print(g)
    # print(b)
    # print(len(b))
    # ans1=0
    # fir=[]
    # for i in range(len(r)):
    #     for j in range(len(g)):
    #         for k in range(len(b)):
    #             ls=[r[i],g[j],b[k]]
    #             ls.sort()
    #             if ls[1]-ls[0]!=ls[2]-ls[1]:
    #                 ans1+=1
    #         fir.append(ans1)
    # # print(ans1)

    # print("-------------------check---------------")
    # are=[]
    for i in range(len(r)):
        for j in range(len(g)):
            ans+=len(b)
            chota=min(g[j],r[i])
            bada=max(g[j],r[i])
            diff=bada-chota

            left=bisect.bisect_left(b,bada+diff)
            right=bisect.bisect_left(b,chota-diff)

            lol=(bada+chota)
            if lol%2==0:
                beech=lol//2
                ind=bisect.bisect_left(b,beech)
                if ind<len(b) and b[ind]==beech:
                    ans-=1
            if (left<len(b) and b[left]==bada+diff):
                ans-=1
            if (right<len(b) and b[right]==chota-diff):
                ans-=1

            # are.append(ans)
    print(ans)
    # for i in range(len(are)):
    #     print(are[i],fir[i])


if __name__ == '__main__':
    main()





Measured memory_bytes: 78728
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<bitset>
using namespace std;
int p = 1000000007;
#define vel vector<int>
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int n; cin >> n;
	vel a(n);
	int sum = 0;
	rep(i, n) { cin >> a[i]; sum += a[i]; }
	const int bit_sz = 2000001;
	bitset<bit_sz> bs;
	bs[0] = 1;
	rep(i, n) {
		bs |=bs << a[i];
	}
	int ans = 0;
	for(int i=0;i*2<=sum;i++) {
		if (bs[i]) { ans = i; }
	}
	cout << sum-ans << endl;
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
int n;
int a[100],t;
int main(){
	scanf("%d",&n);
	if (!n){
		printf("0\n");
		return 0;
	}
	while (n){
		//n%2//a[++t]=n%-2  n/=-2
		if (n%2){
			a[++t]=1;
			n=(n-1)/-2;
		}else{
			a[++t]=0;
			n/=-2;
		}
	}
	fd(i,t,1) printf("%d",a[i]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 128