akhauriyash/Code-Regression huggingface dataset:
IDENTIFICATION DIVISION.
PROGRAM-ID. 171B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(5000).
01 N          PIC 9(04).
01 K          PIC 9(04).
01 P1         PIC 9(08) COMP.
01 P2         PIC 9(08) COMP.
01 TBL.
   03 A       PIC 9(04) OCCURS 1000 DEPENDING ON N.
01 I          PIC 9(08) COMP.
01 CNT        PIC 9(09) COMP.
01 OUT        PIC Z(7)9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO N K.
*>
  ACCEPT INP.
  MOVE 1 TO P1.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    PERFORM VARYING P2 FROM P1 BY 1 UNTIL INP(P2:1) = ' '
    END-PERFORM
    MOVE INP(P1:P2 - P1) TO A(I)
    COMPUTE P1 = P2 + 1
  END-PERFORM.
*>
  SORT A ASCENDING KEY A.
  MOVE 0 TO CNT.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > K
    ADD A(I) TO CNT
  END-PERFORM.
*>
  MOVE CNT TO OUT.
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

ll n,a,b;
vl h;
bool able(ll k){
    ll kk=k;
    for(auto x:h)
        if(x>b*k)kk-=(x-(k*b)+a-1)/a;
    return kk>=0;
}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    cin>>n>>a>>b;
    a-=b;
    h.resize(n);
    cin>>h;
    ll l=0,r=INF;//何でも大きければいいってものじゃないのよ
    while(l+1<r){
        dprint(l,r);
        ll m=(l+r)/2;
        if(able(m))
            r=m;
        else
            l=m;
    }
    cout<<r<<endl;

}


Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10 ** 7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    n, a, b = map(int, input().split())
    den = n * a
    print(min(den, b))

solve()

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(x<0)putchar('-'),x=-x;
    if(x>9)write(x/10);
    putchar(x%10+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
struct node
{
	long long x,y;
}a[55];
bool cmp(node a,node b){return a.x<b.x;}
int n;
inline int check(long long x,long long y)
{
	int ans=-1;
	for(int i=1;i<=n;i++){if(a[i].x==x && a[i].y==y){ans=i;break;}}
	return ans;
}
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read();int ans=n;
	for(int i=1;i<=n;i++)a[i].x=read(),a[i].y=read();
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(i==j)continue;
			long long u1=a[j].x-a[i].x,u2=a[j].y-a[i].y;
			int sum=1;
			for(int k1=1;k1<=n;k1++)
			{
				if(k1==j)continue;
				for(int k2=1;k2<=n;k2++)if(a[k1].x-u1==a[k2].x && a[k1].y-u2==a[k2].y)sum++;
			}ans=min(ans,n-sum);
		}
	}pr2(ans);
    return 0;
}

Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

cnt = Counter(S)
if len(cnt) == 2 and cnt[S[0]] == 2:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5972
import java.util.Scanner;

public class Main {
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());

        int sum=0;
        int parts = 0;
        int ansP =0;

        for(int k =1 ; k<K+1 ; k++){
            for(int i =1 ; i<K+1 ; i++){
                for(int j =1 ; j<K+1 ; j++){
                    parts= uclid(i,j);
                    ansP = uclid(k,parts);
                    sum = sum + ansP;
                }
            }
        }
        System.out.println(sum);
    }


    public static  int uclid(int m,int n) {
        int r;        
        r = m % n;    
        while ( r > 0 )  {  
            m = n; n = r;    
            r = m % n;
        }
        return n;
    }
}

Measured memory_bytes: 35700
while True:
    l = input().split()
    if l[1] == '?':
        break
    elif l[1] == '+':
        print(int(l[0])+int(l[2]))
    elif l[1] == '-':
        print(int(l[0])-int(l[2]))
    elif l[1] == '*':
        print(int(l[0])*int(l[2]))
    elif l[1] == '/':
        print(int(l[0])//int(l[2]))


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

int main() {
  int N, X;
  cin >> N >> X;
  int a = 0;
  int b = 1;
  vector<int> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  for(int i = 0; i < N; i++) {
    a = a + L.at(i);
    
    if(a > X) {
      cout << b << endl;
      break;
    }
    if(i == N-1) {
      cout << N+1 << endl;
    }
    b = b + 1;
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(br.readLine());

        long X = Long.parseLong(st.nextToken());
        long K = Long.parseLong(st.nextToken());
        long D = Long.parseLong(st.nextToken());

        if(X < 0) X = X*-1;

        long quotient = X / D;
        long mod = X % D;

        long result = 0;

        if(quotient > K) {
            result = mod + D * (quotient - K);
        } else {
            if((K - quotient) % 2 == 0) {
                result = mod;
            } else {
                result = mod - D;
            }
        }

        pw.println(Math.abs(result));
        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32628
package main

import (
	"fmt"
)

func main() {
	var k int
	var s string
	fmt.Scanf("%d", &k)
	fmt.Scanf("%s", &s)

	if len(s) <= k {
		fmt.Println(s)
		return
	}

	abbreviated := s[:k]
	fmt.Printf("%s...", abbreviated)
}


Measured memory_bytes: 1820
#include<stdio.h>
#include<string.h>

#define INF -1

void maxHeapInsert(int*,int);
void HeapIncreaseKey(int*,int,int);
int HeapExtractMax(int*);
void maxHeapify(int*,int);

int size=0;

int main(){

  int k=2000000,i,num,A[2000001],count=0,max;
  char order[8];

  for(i=0;i<k;i++){
    
    scanf("%s",order);

    if(strcmp(order,"insert")==0){

      scanf("%d",&num);

      maxHeapInsert(A,num);

    }

    else if (strcmp(order,"extract")==0){

      max=HeapExtractMax(A);
      printf("%d\n",max);
      
    }

    else if(strcmp(order,"end")==0){
      count+=1;
    }
    
    if(count==1) break;
   
  }
  
  return 0;
}

void maxHeapInsert(int A[],int key){

  size=size+1;
  A[size]=INF;
  HeapIncreaseKey(A,size,key);
  //printf("%d\n",A[size]);

}

void HeapIncreaseKey(int A[],int i,int key){

  int change;

  if(key < A[i]) printf("new key is smaller than current key\n");

  A[i]=key;
  
  while( i > 1 && A[i/2] < A[i] ){

    change=A[i];
    A[i]=A[i/2];
    A[i/2]=change;
    i=i/2;

  }

}

void maxHeapify(int A[],int i){

  int l,r,largest,change;

  //printf("i:%d\n",i);
  
  l=2*i;
  r=2*i+1;

  if(l<=size && A[l]>A[i]) largest = l;
  else largest = i;

  if(r<=size && A[r] > A[largest]) largest = r;
  
  if(largest !=i){

    change = A[i];
    A[i]=A[largest];
    A[largest]=change;
    maxHeapify(A,largest);
  }


}

int HeapExtractMax(int A[]){

  int max;
  
  if(size<1) printf("heap underflow\n");

  max = A[1];

  A[1]=A[size];
  size--;
  maxHeapify(A,1);
  return max;

}

Measured memory_bytes: 6540
n = int(input())
l = list(map(int,input().split()))

c = 0
s = []
l.sort()

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if (l[i] + l[j] > l[k]) and l[i] != l[j] and l[j] != l[k] and l[k] != l[i]:
                c = c + 1

print(c)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int x[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin>>K;
    K--;
    cout << x[K] << endl;

    



}


Measured memory_bytes: 3600
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define pii pair<int,int>
#define prec(n) fixed<<setprecision(n)
#define MOD 1000000007
#define eps 1e-8
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}
//ifstream cinn("input.txt");ofstream coutt("output.txt");

signed main(){
    FASTER;
    int k,x;cin>>k>>x;
    if(x+k-1<=100000 && x-k+1>=-100000){
        for(int i=x-k+1;i<=x+k-1;i++){
            cout<<i<<" ";
        }
    }else if(x+k-1<=100000){
        for(int i=-100000;i<=x+k-1;i++){
            cout<<i<<" ";
        }
    }else{
        for(int i=x-k+1;i<=100000;i++){
            cout<<i<<" ";
        }
    }
}


Measured memory_bytes: 256
s = input()

num = [0,0,0,0]
num[0], num[1], num[2], num[3] = map(int,(s[0], s[1], s[2], s[3]))

def ope(x):
	if x == 1:
		return '+'
	elif x == 0:
		return '-'
for i in range(8):
	tmp = num[0]
	for j in range(3):
		if (i>>j) & 1:
			tmp += num[j+1]
		else:
			tmp -= num[j+1]
	if tmp == 7:
		print(s[0]+ope(i&1)+s[1]+ope((i>>1)&1)+s[2]+ope((i>>2)&1)+s[3]+'=7')
		break

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    double A[N];
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }

    double ans = 1;
    double sum = 0;
    for(int i = 0; i < N; i++){
        sum += (1.0/A[i]);
    }
    ans /= sum;

    printf("%.12lf\n", ans);
    

    return 0;
}

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

#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    int d,g,a,ans=114514;
    cin>>d>>g;
    ll p[d],c[d];
    for(int i=0;i<d;i++){
        cin>>p[i]>>c[i];
    }
    for(int bit=0;bit< (1<<d);bit++){
        map<int ,int>mp;
        ll sum=0;
        int num=0;
        for(int i=0;i<d;i++){
            if(bit&(1<<i)){
                sum+=(i+1)*100*p[i]+c[i];
                num+=p[i];
                mp[i]++;
            }
        }
        if(sum<g){
            for(int i=d-1;i>=0;i--){
                if(mp[i]==0){
                    a=(g-sum)/((i+1)*100);
                    if((g-sum)%((i+1)*100)!=0)a++;
                    if(a<=p[i]){
                        num+=a;
                        break;
                    }
                    else{
                        num=114514;
                        break;
                    }
                }
            }
        }
        ans=min(ans,num);
    }
    cout << ans<<endl;
    return 0;
}

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

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (K < N) cout << K * X + (N - K) * Y;
	else cout << N * X;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

K泊以上止まっているか否かで条件が分岐することだけ注意すれば難しくないね
*/

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

using namespace std;

int main(){
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int cnt = 0;
	for(int x = 0; x <= N/R; ++x){
		for(int y = 0; y <= N/G; ++y){
			int ans = N-x*R-y*G;
			if(ans >= 0 && ans % B == 0) cnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
	int num;

	cin >> num;

	int left = num/100, right = num%100;
	string ans = "AMBIGUOUS";
	if (left > 12 || left == 0) ans = "YYMM";
	if (right > 12 || right == 0) ans = "MMYY";
	if ((left > 12 || left == 0) 
		&&(right > 12 || right == 0)) ans = "NA";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a>0)
    {
        cout<<"Positive";  
    }
    else if(b>=0)
    {
        cout<<"Zero";  
    }
    else if((a&1)^(b&1))
    {
        cout<<"Positive";  
    }
    else 
    {
        cout<<"Negative";
    }
    return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    vector<int> nm(n + 1);//i以降の最大
    for(int i = 0; i < n; i++)cin >> a[i];

    for(int i = n - 1; i >= 0; i--){
        nm[i] = max(a[i], nm[i + 1]);
    }

    int nax = 0;
    for(int i = 0; i < n; i++){
        nax = max(nax, nm[i] - a[i]);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        if(nm[i] - a[i] == nax)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 1024
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdlib>  // abs() for integer
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    int n;
    cin >> n;
    vector<double> V(n);
    rep(i, n) cin >> V[i];
    sort(V.begin(), V.end());
    double v[2][1100];
    rep(i, n) v[0][i] = V[i];
    v[1][0] = (v[0][0] + v[0][1]) / 2;
    for(int i = 1;i < n- 1; i++) v[1][i] = (v[1][i - 1] + v[0][i + 1]) / 2;
    cout << v[1][n - 2] << endl;
}

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

int main(){
  int n,s; 
  cin >> n;
  
  int b[n-1];
  
  rep(i,n-1)cin >> b[i];
  
  rep(i,n){
    if(i == 0){
      s += b[i];
    }else if(i == n-1){
      s += b[i - 1];
    }else{
      s += min(b[i -1],b[i]);
    }
  }
  
  cout << s;
  
  return 0;
}




Measured memory_bytes: 256
c = str(input())
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'x', 'y', 'z']
print(a[a.index(c) + 1])

Measured memory_bytes: 9060
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<ll>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    double ans = 0.0;
    rep(i, N)
    {
        ans += 1.0 / double(A[i]);
    }
    ans = 1.0 / ans;
    printf("%.6f", ans);

#if 0
    if (A.size() == 1)
    {
        printf("%.6f", A[0]);
        return 0;
    }

    // 分母を求める
    ll tmp = lcm(A[0], A[1]);
    rep(i,N-2)
    {
        tmp = lcm(tmp, A[i+2]);
    }
    //
    ll denom = 0;
    rep(i, N)
    {
        denom += tmp/A[i];
    }
    double ans = double(tmp)/double(denom);
    printf("%.10f",ans);
#endif

    //
    return 0;
}

Measured memory_bytes: 3228
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
	ll N;
	cin >> N;
	vint A, B, C;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		B.push_back(tmp);
	}
	for (int i = 0; i < N-1; i++) {
		int tmp;
		cin >> tmp;
		C.push_back(tmp);
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ans += B[A[i]-1];
		if (i >= 1 and A[i-1] +1 == A[i]) {
			ans += C[A[i-1]-1];
		}
	}
	cout << ans << endl;
}

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

typedef pair<int, int> P;

int main() {

    int n;
    cin >> n;
    vector<ll> h(n);
    rep(i,n){
        cin >> h[i];
    }
    int i = 0;
    ll tmp = 0;
    int ans = 0;
    int times = 0;
    while(i<n){
        tmp = h[i];
        times = 0;
        i++;
        if(i==n)break;
        while(tmp>=h[i]){
            tmp = h[i];
            i++;
            times++;
            if(i==n)break;
        }
        ans = max(ans,times);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力値
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();
		sc.close();
		System.out.println((a1+a2+a3)<=21?"win":"bust");
	}
}

Measured memory_bytes: 22228
N, K=map(int,input().split())
h=[int(i) for i in input().split()]
lim=10**9
cost = [-1]*N
cost[0]=0
cost[1]=abs(h[1]-h[0])
for i in range(2,N):
    min_cost = lim
    for j in range(1,K+1):
        if i-j<0:
            break
        min_cost = min(min_cost, cost[i-j]+abs(h[i]-h[i-j]))
    cost[i] = min_cost 
print(cost[-1])

Measured memory_bytes: 52448
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int

#define pb push_back
#define m <i> map<int>
#define v <i> vector<int>

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

int main()
{
  IOS;
  int n;
  cin >> n;
  if (n%2!=0)
    cout << (n/2)+1 << endl;
  else
    cout << n/2 << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[100011], B[100011];
VI G[100011];
LL S[100011];
LL C[100011];
LL dp[100011];

int par[100011];
int sz[100011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N-1) {
	scanf("%d%d", A+i, B+i);
	A[i]--;
	B[i]--;
	G[A[i]].push_back(i);
	G[B[i]].push_back(i);
    }
    REP (i, N) scanf("%lld", S+i);

    VI ord;
    ord.reserve(N);
    ord.push_back(0);
    REP (i, N) {
	int v = ord[i];
	EACH (e, G[v]) {
	    int w = A[*e]^B[*e]^v;
	    if (w != par[v]) {
		par[w] = v;
		ord.push_back(w);
	    }
	}
    }
    REP (i, N) {
	int v = ord[N-1-i];
	sz[v] = 1;
	dp[v] = 0;
	EACH (e, G[v]) {
	    int w = A[*e]^B[*e]^v;
	    if (w != par[v]) {
		sz[v] += sz[w];
		dp[v] += dp[w] + C[w] * sz[w];
	    }
	}

	if (sz[v] != N && sz[v]*2 != N) {
	    assert((S[v]-S[par[v]]) % (N-2*sz[v]) == 0);
	    C[v] = (S[v]-S[par[v]]) / (N-2*sz[v]);
	}
    }

    REP (i, N) {
	int v = ord[i];
	if (v && C[v] == 0) {
	    assert((S[0]-dp[0])%(N/2) == 0);
	    C[v] = (S[0]-dp[0])/(N/2);
	}
    }

    REP (i, N-1) {
	LL c;
	if (par[A[i]] == B[i]) c = C[A[i]];
	else c = C[B[i]];
	printf("%lld\n", c);
    }
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

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

    map<int, int> a;
    for(int i=0; i<n; i++){
        int now;
        cin>>now;
        a[now-1]=i;
    }

    for(int i=0; i<n; i++){
        cout<<a.at(i)+1<<" ";
    }

    cout<<endl;
}


Measured memory_bytes: 5504
N,K,Q=input().split()
n=int(N) #参加人数
k=int(K) #初期点数
q=int(Q) #正解数

seikaisha=[]
#今後は人間のナンバーは0~で管理します。

for j in range(q):
  x=int(input())-1
  seikaisha.append(x)


score=[]

for i in range(n):
  score.append(k-q)

for j in range(q):
  #正解者に点数を足していく
  score[seikaisha[j]]+=1
  #seikaisha[j]はj番目のクイズの正解者の名前。そのナンバーに該当する人間のscoreに1を足していく

for i in range(n):
  if score[i]>0:
    print("Yes")
  if score[i]<=0:
    print("No")

Measured memory_bytes: 11832
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
L = [LIST() for i in range(N-1)]
color = [0] * N
# color[]
graph = defaultdict(list)
for a, b in L:
    graph[a].append(b)
    graph[b].append(a)

ans = 1
# child, parent, kakerumono
q = deque([[1, 0, K]])
# color[0] = K
# visited = [False] * N
# visited[0] = True
while q:
    u, p, k_ = q.popleft()
    ans = (ans * k_) % mod
    if p == 0:
        # parentなし
        k_next = K - 1
    else:
        k_next = K - 2

    for v in graph[u]:
        if v == p:
            # 親と同じなら飛ばす
            continue
        q.append([v, u, k_next])
        # 子の数だけk_nextを減らしながら書けていく
        # K-2 P c_k
        k_next -= 1
print(ans)




Measured memory_bytes: 55624
#include<stdio.h>
#include<stdlib.h>
typedef long long int ll;
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(){
    static int n,a[200000];
    int flg=0;

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(a[i]!=0){
            flg=1;
        }
    }

    if(!flg){
        printf("Yes\n");
        return 0;
    }
    qsort(a,n,sizeof(int),asc);

    if(n%3!=0){
        printf("No\n");
        return 0;
    }

    
    if(a[0]!=a[n/3-1]||a[n/3]!=a[2*n/3-1]||a[2*n/3]!=a[n-1]){
        printf("No\n");
        return 0;
    }

    if((a[0]^a[2*n/3])==a[n/3]){
        printf("Yes\n");
        return 0;
    }
    printf("No\n");




    return 0;

}

Measured memory_bytes: 892
n,k = map(int, input().split())
a = list(map(int, input().split()))
if k > max(a):
  print("IMPOSSIBLE")
  exit()
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
i = gcd_list(a)
if k%i == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> v(N);
  for(int i=0;i<K;i++){
    int d; cin >> d;
    for(int i=0;i<d;i++){
      int a; cin >> a; --a;
      v[a]=1;
    }
  }

  int r=0;
  for(int i=0;i<N;i++) r+=v[i];
  cout << N-r << endl;

  return 0;
}


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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long ;

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

   int X,Y,Z;
   cin>>X>>Y>>Z;

   int ans = 0;
   while(X>=Z+Y+Z){
      X -= Z+Y;
      ans++;
   }
   cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (long i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int i = 0, j = 1, count = 1, ans = 0;
    while (j <= N)
    {
        if (a[i] == a[j])
        {
            count++;
            j++;
        }
        else
        {
            if (count > a[i])
            {
                ans += (count - a[i]);
            }
            else if (count < a[i])
            {
                ans += count;
            }
            i = j;
            j = i + 1;
            count = 1;
        }
    }
    cout << ans << endl;
}


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

int main(){
    long long n, k;
    while( cin >> n >> k ){
        vector<long long>v(n);
        for( int i = 0; i < n; i++ ){
            cin >> v[i];
        }
        sort( v.begin(), v.end() );
        long long sum = 0;
        for( int i = 0; i < n-k; i++ ){
            sum+=v[i];
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
ll n;
string k;
string bo[4]={"AC","WA","TLE","RE"};
int main()
{
	cin>>n;
	map<string,ll>kor;
	while(n--){
		cin>>k,kor[k]++;
	}
	for(string ki:bo){
	   cout<<ki<<" x "<<kor[ki]<<"\n";	
	}
}

Measured memory_bytes: 3564
ans = [0 for i in range(4001)]

for i in range(2001):
    if i > 1000:
        a = a + 2*(i - 999)*(i - 1000)
    else:
        a = 0
    ans[i] = (i + 3)*(i + 2)*-~i//6 - a
    ans[4000 - i] = ans[i]

while True:
    try:
        n = int(input())
        print(ans[n])
    except:
        break



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int cnt[4];

int main(){
  REP(i,3){
    int a,b;
    cin>>a>>b;
    --a;--b;cnt[a]++;cnt[b]++;
  }
  puts(*max_element(cnt,cnt+4)==2 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	t := make([]int, n)
	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i], &x[i], &y[i])
	}

	t = append([]int{0}, t...)
	x = append([]int{0}, x...)
	y = append([]int{0}, y...)
	// fmt.Printf("%v %v %v", t, x, y)

	res := true
	for i := 0; i < n; i++ {
		// t[i] から t[i + 1] への移動が可能かを調べる
		time := t[i+1] - t[i]
		dist := int(math.Abs(float64(x[i+1]-x[i]))) + int(math.Abs(float64(y[i+1]-y[i])))
		// fmt.Println(time, dist)

		ok := false
		if time >= dist && (time-dist)%2 == 0 {
			ok = true
		}

		if !ok {
			res = false
			break
		}
	}

	if res {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M;cin>>N>>M;
    vector<int> L(M,0);
    for(int i=0;i<N;i++){
        int K;cin>>K;
        for(int j=0;j<K;j++){
            int a; cin>>a;
            L[a-1]++;
        }
    }
    int ans=0;
    for(int i=0;i<M;i++){
        if(L[i]==N){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long 
#define pii pair<int,int>
#define MP make_pair
#define F first
#define S second
using namespace std;
const int mx=2010;
int dis[mx];
bool mrk[mx];
vector <int> adj[mx];
vector <pii> vec;
void dfs(int v)
{
	mrk[v]=1;
	long unsigned int t=adj[v].size();
	for(long unsigned int i=0;i<t;i++)
	{
		int u=adj[v][i];
		if(!mrk[u])
		{
			dis[u]=dis[v]+1;
			dfs(u);
		}
	}
}
void dfs1(int v)
{
	mrk[v]=1;
	long unsigned int t=adj[v].size();
	for(long unsigned int i=0;i<t;i++)
	{
		int u=adj[v][i];
		if(!mrk[u])
		{
			dis[u]=min(dis[u],dis[v]+1);
			dfs(u);
		}
	}	
}
int main()
{
	int n,k,ans=3000;
	cin>>n>>k;
	for(int i=0;i<n-1;i++)
	{
		int u,v;
		cin>>u>>v;
		--u;
		--v;
		adj[v].pb(u);
		adj[u].pb(v);
		vec.pb(MP(u,v));
	}
	if(k%2==0)
	{
		for(int i=0;i<n;i++)
		{
			dis[i]=0;
			dfs(i);
			int cnt=0;
			for(int j=0;j<n;j++)
			{
				if(dis[j]>(k/2))
				{
					cnt++;
				}
				mrk[j]=0;
			}
			ans=min(ans,cnt);
		}
		cout<<ans;	
		return 0;	
	}
	for(int i=0;i<n-1;i++)
	{
		int cnt=0;
		dis[vec[i].F]=0;
		dfs(vec[i].F);
		for(int j=0;j<n;j++)
		{
			mrk[j]=0;
		}
		dis[vec[i].S]=0;
		dfs1(vec[i].S);
		for(int j=0;j<n;j++)
		{
			if(dis[j]>(k/2))
			{
				cnt++;
			}
			mrk[j]=0;
		}
		ans=min(ans,cnt);
	}
	cout<<ans;
}


Measured memory_bytes: 3840
def digit_sum(n):
    ans = 0
    while n > 0:
        ans += n % 10
        n //= 10
    return ans
n, a, b = map(int, input().split())
list1 = []
for i in range(n):
    if a <= digit_sum(i+1) <= b:
        list1.append(i + 1)
print(sum(list1))


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while((A > 0)&&(C > 0)){
        A -= D;
        C -= B;
    }
    if((A <= 0)&&(C > 0)){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3644
S = input()
if S == 'SSS':print(0)
if S == 'SSR':print(1)
if S == 'SRS':print(1)
if S == 'RSS':print(1)
if S == 'SRR':print(2)
if S == 'RRS':print(2)
if S == 'RSR':print(1)
if S == 'RRR':print(3)

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long LL;
typedef pair<int,int> PII;
#define X first
#define Y second
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}
const int maxn=200010;
int n,m,f[maxn],sz[maxn],ans,a,b;
int getf(int x){return f[x]==x ? x : f[x]=getf(f[x]);}
void merge(int x,int y)
{
	int a=getf(x),b=getf(y);
	if(a!=b)
	{
		f[a]=b;
		sz[b]+=sz[a];
	}
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)f[i]=i,sz[i]=1;
	while(m--)a=read(),b=read(),merge(a,b);
	for(int i=1;i<=n;i++)ans=max(ans,sz[getf(f[i])]);
	printf("%d\n",ans);
	return 0;
}
/*

*/


Measured memory_bytes: 11556
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n-- > 0){
            if(sc.next().charAt(0) == 'Y'){
                System.out.println("Four");
                break;
            }
            if(n == 0)
                System.out.println("Three");
        }
        
    }
}

Measured memory_bytes: 19668
#include <bits/stdc++.h>
using namespace std;
#define ll long long  int
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve()
{
       ll x;
       cin>>x;
       if(x>=400&&x<=599)
       	cout<<8;
       else if(x>=600&&x<=799)
       cout<<7;
     else if(x>=800&&x<=999)
       cout<<6;
   else if(x>=1000&&x<=1199)
       cout<<5;
   else if(x>=1200&&x<=1399)
       cout<<4;
   else if(x>=1400&&x<=1599)
       cout<<3;
   else if(x>=1600&&x<=1799)
       cout<<2;
   else if(x>=1800&&x<=1999)
       cout<<1;
}
int main()
{
    fast();
    {
      solve();
    }
    return 0;
}



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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> a(3);
  REP(i, 3) cin >> a[i];
  sort(a.begin(), a.end());
  if(a[0] + a[1] == a[2])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const int MAXM = 1e5 + 5;
const int MAXD = 1e5 + 5;
const int inf = 0x3f3f3f3f;

inline void chk_min(int &a,int b){ if(a>b) a=b;}

int a[MAXN],b[MAXN],c[MAXN],x[MAXN],y[MAXN];

int main(void)
{
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	for(int i=1; i<=m; ++i) scanf("%d",&b[i]);
	for(int i=1; i<=d; ++i)
		scanf("%d%d%d",&x[i],&y[i],&c[i]);
	
	int ans = inf;
	for(int i=1; i<=d; ++i)
		chk_min(ans, a[x[i]]+b[y[i]]-c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+m+1);
	chk_min(ans, a[1]+b[1]);
	
	printf("%d",ans);
	return 0;
}

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

using namespace std;

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

    int cnt = 0;
    for (int i = 0; i < n - 1; ++i) {
        if (s[i] != s[i + 1]) cnt++;
    }
    cout << n - 1 - max(0, cnt - k * 2) << endl;
    return 0;
}


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

# (x + y) ** 2 = x2 + 2xy + y2
# (y + z) ** 2 = y2 + 2yz + z2
# (z + x) ** 2 = z2 + 2zx + x2
# 右辺 2(x2 + y2 + z2 + xy + yz + zx)
# よって (x + y) ** 2 + (y + z) ** 2 + (z + x) ** 2 = 2 * n

# x**2 + y**2 + z**2 + xy + yz + zx = n

# x = y = 1, N = 10**4の時のZは大きくて100なので100まで回せばよい
# 4 + 2(z**2 + 2z + 1) = 2 * 10**4
# 2 + z ** 2 + 2z + 1 = 10**4
# z(z + 2) = 10 ** 4 - 3
# 時間がかかりすぎるからx,y,zの値によって+1, +3, +6する 3C3, 3C2, 3C1


def f1(x, y, z):
    return (x + y)**2 + (y + z)**2 + (z + x)**2


# F = [0] * (10**4 + 1)
# F = [0] * (N + 1)
# for i in range(1, 10**4 + 1):
for i in range(1, N + 1):
    f = 0
    # for i in range(83, N + 1):
    right = 2 * i
    # print(f'{i=}')
    for x in range(1, 101):
        if f1(x, 1, 1) > right:
            break
        for y in range(x, 101):
            if f1(x, y, 1) > right:
                break

            for z in range(y, 101):
                # print(f'{i=}, {x=}, {y=}, {z=}')
                left = f1(x, y, z)
                if left > right:
                    break
                if left == right:
                    # print(f'{i=}, {x=}, {y=}, {z=}')
                    if x == y == z:
                        # F[i] += 1
                        f += 1
                    elif x == y or y == z or z == x:
                        # F[i] += 3
                        f += 3
                    else:
                        # F[i] += 6
                        f += 6
    print(f)
# print(f'{F=}')


Measured memory_bytes: 70040
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int calc(int&a, int&b)
{
	int c=min(a, b);
	a-=c;
	b-=c;
	return c;
}


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi a(n+1), b(n);

		for(int i=0;i<n+1;i++) scanf("%d", &a[i]);
		for(int i=0;i<n;i++) scanf("%d", &b[i]);

		ll ans=0;
		for(int i=0;i<n;i++)
		{
			ans+=calc(a[i], b[i]);
			ans+=calc(a[i+1], b[i]);
		}

		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

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

Measured memory_bytes: 580
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,K;
char s[200005];
int ar[200005];

char ans[200005];
int main(){
  scanf("%d%d",&n,&K);
  scanf("%s",s);
  n=strlen(s);
  REP(i,n) ar[i]=(s[i]-'A');

  int off=0,flip=0;
  bool ok=false;
  REP(i,K){
    if(off>=n){
      REP(j,n) ans[j]='A'+((n-j-1)&1);
      if(n&1 && (K-1)&1){
        ans[0]='B';
      }
      ok=true;
      break;
    }
    if((ar[off]^flip)==0){
      ar[off]^=1;
    }else{
      ++off;
      flip^=1;
    }
  }
  if(!ok){
    REP(i,off) ans[n-1-i]='A'+(i&1);
    REP(i,n-off) ans[i]=(ar[off+i]^flip)+'A';
  }

  printf("%s\n",ans);
  return 0;
}





Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;
typedef vector<ll> vel;
typedef vector<string> ves;
typedef vector<int> vei;
typedef vector<vector<ll>> vvel;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    int a,b;cin >>a>>b;
    int h,m;cin >>h>>m;
    double pi =3.1415926535;
    double kari =abs((double)h*30+m*0.5-m*6);
    double kaku =(double) kari*pi/180;
    long double ans =sqrt(a*a+b*b-2*a*b*cos(kaku));
    cout << fixed << setprecision(10);
    cout <<ans<<endl;
}

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

bool pal(string s)
{
    bool yes=true;
    int n=s.size();
    int lo=0,hi=n-1;
    for(int i=0;i<n/2;++i){
        if(s[lo]!=s[hi]){
            yes=false;
            break;
        }
        lo++,hi--;
    }
    return yes;
}

void solve()
{
    string s,s1,s2;
    cin>>s;
    int n=s.size();
    for(int i=0;i<(n-1)/2;++i) s1+=s[i];
    for(int i=(n-1)/2+1;i<n;++i) s2+=s[i];
    if(pal(s) && pal(s1) && pal(s2)) cout<<"Yes";
    else cout<<"No";
    return;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}

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

int main(){long N, T;
cin >> N >> T;
vector<long> t(N + 1);
erep(i, N) cin >> t.at(i);
long ans = 0;
erep(i, N - 1){
    ans += min(t.at(i + 1) - t.at(i), T);
}
ans += T;
cout << ans << endl;
return 0;
}



Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

int main(void) {
	int i;
	char s[21];
	char *p;
	int cnt;

	scanf("%s", s);

	p = s;
	cnt = 0;
	while (1) {
		p = strchr(p, 'A');
		if (p == NULL)
			break;
		p = strchr(p, 'Z');
		if (p == NULL)
			break;
		cnt++;
	}

	if (!cnt)
		puts("-1");
	else {
		for (i = 0; i < cnt; i++)
			printf("AZ");
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 528
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 205;
const int mod = 1e9 + 7;

lint fact(int x){
	lint ret = 1;
	for(int i=1; i<=x; i++) ret = ret * i % mod;
	return ret;
}

lint ipow(int x, int p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

int solve(){
	int x, y; cin >> x >> y;
	if((x + y) % 3) return 0;
	int pl = (x + y) / 3;
	int mn = x - y;
	if(abs(pl) % 2 != abs(mn) % 2) return 0;
	int p = (pl + mn) / 2;
	int q = (pl - mn) / 2;
	if(p < 0 || q < 0) return 0;
	return fact(p + q) * ipow(fact(p) * fact(q) % mod, mod - 2) % mod;
}

int main(){
//	freopen("input.txt", "rb", stdin);
//	freopen("output.txt", "wb", stdout);
//	int tc; scanf("%d",&tc);
int tc = 1;
	while(tc--) cout << solve() << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim 1e5
using namespace std;

const lld mod=MAX;


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

	lld n,w;
	cin>>n>>w;

	std::vector<lld> val(n);
	std::vector<lld> weight(n);

	for(lld i=0;i<n;i++)
	{
		cin>>weight[i];
		cin>>val[i];
	}

	lld sum_val=0;

	for(lld i=0;i<n;i++)
		sum_val+=val[i];

	std::vector<lld> dp(sum_val+1);

	dp[0]=0;

	for(lld i=1;i<=sum_val;i++)
		dp[i]=MAX;

	for(lld i=0;i<n;i++)
	{
		std::vector<lld> temp(sum_val+1);
		temp=dp;
		for(lld j=val[i];j<=sum_val;j++)
		{	

			temp[j] = min(dp[j],dp[j-val[i]]+weight[i]);
		}

		dp=temp;
	}

	for(lld i=sum_val;i>=0;i--)
	{
		if(dp[i]<=w)
		{
			cout<<i<<endl;

			break;
		}
	}
}

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

int main(void){
    // Your code here!
    long long field[3][3];
    
    for(int i = 0; i < 3; i++){
        long long a, b, c;
        cin >> a >> b >> c;
        field[i][0] = a;
        field[i][1] = b;
        field[i][2] = c;
    }
    
    bool correct = true;
    int combination[3][2] = {{0, 1}, {0, 2}, {1, 2}};
    for(int i = 0; i < 3; i++){
        if(field[combination[i][0]][0] - field[combination[i][0]][1] != field[combination[i][1]][0] - field[combination[i][1]][1])
            correct = false;
        if(field[combination[i][0]][0] - field[combination[i][0]][2] != field[combination[i][1]][0] - field[combination[i][1]][2])
            correct = false;
        if(field[combination[i][0]][1] - field[combination[i][0]][2] != field[combination[i][1]][1] - field[combination[i][1]][2])
            correct = false;
    }
    for(int i = 0; i < 3; i++){
        if(field[0][combination[i][0]] - field[1][combination[i][0]] != field[0][combination[i][1]] - field[1][combination[i][1]])
            correct = false;
        if(field[0][combination[i][0]] - field[2][combination[i][0]] != field[0][combination[i][1]] - field[2][combination[i][1]])
            correct = false;
        if(field[1][combination[i][0]] - field[2][combination[i][0]] != field[1][combination[i][1]] - field[2][combination[i][1]])
            correct = false;
    }
    
    if(correct == false)
        cout << "No";
    else
        cout << "Yes";
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a[60];
    int c,d,n,j,k,m,i;
    scanf("%d%d",&n,&m);
    for(i=0;i<=n+3;i++)
    {
        a[i]=0;
    }
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&c,&d);
        a[c]=a[c]+1;
        a[d]=a[d]+1;
    }
    for(i=1;i<=n;i++)
    {
        printf("%d\n",a[i]);
    }

    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf 0x3f3f3f3f
#define mod 1000000009
using namespace std;

struct s{
	string s;
	int a, i;
};

bool operator<(s a, s b){
	if (a.s != b.s)
		return a.s < b.s;
	return a.a > b.a;
}

int main() {
	speed;
	int n;
	cin >> n;
	vector
v(n);
	for (int i = 0; i < n; ++i){
		cin >> v[i].s >> v[i].a;
		v[i].i = i + 1;
	}
	sort(v.begin(),v.end());
	for (auto i : v)
		cout << i.i << '\n';
	return 0;
}

Measured memory_bytes: 256