akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int ans = 0;
        int min = N;
        for(int i = 0; i < N; i++){
            int a = in.nextInt();
            if(a <= min){
                min = a;
                ans++;
            }
        }
        println(ans);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 47356
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string S,T;
    ll N,ans=INF,A[201];
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        cin>>A[i];
        ll cnt=0;
        while(A[i]%2==0){
            A[i]/=2;
            cnt++;
        }
        DEB(cnt)END
        ans=min(ans,cnt);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String T = sc.nextLine();

        int[] R1 = new int[26];
        int[] R2 = new int[26];

        Arrays.fill(R1, -1);
        Arrays.fill(R2, -1);

        int c1 = -1;
        int c2 = -1;
        for (int i = 0; i < S.length(); i++) {
            c1 = S.charAt(i) - 'a';
            c2 = T.charAt(i) - 'a';

            if (R1[c1] != -1 || R2[c2] != -1) {
                if (R1[c1] != c2 || R2[c2] != c1) {
                    System.out.println("No");
                    return;
                }
            } else {
                R1[c1] = c2;
                R2[c2] = c1;
            }
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 30156
#include<math.h>
#include<iostream>
using std::cin;
using std::cout;
using std::endl;
 
#include<map>
using std::map;
 
#include<string>
using std::string;
 
#include<stdlib.h>
long long int P=1000000007;
const int L=100000;

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void){
	int N;
	int A[L];
	int B[L];
	scanf("%d",&N);
	for(int m=0;m<N;m++){
		scanf("%d",&A[m]);
	}
	for(int m=0;m<N;m++){
		scanf("%d",&B[m]);
	}
	//合計<0なら不可能
	long long int sum=0;
	//A-B;
	int A_B[L];
	//A-B<0の数
	int count=0;
	//A-Bの総和
	long long int S=0;
	for(int m=0;m<N;m++){
		A_B[m]=A[m]-B[m];
		sum+=A_B[m];
		if(A_B[m]<0)count++,S+=A_B[m];
	}
	if(sum<0){printf("-1");return 0;}
	qsort(A_B,N,sizeof(int),compare_int);
	int k=0;
	while(S<0){
		S+=A_B[k];
		k++;
	}
	printf("%d",count+k);
}

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  vector<vector<int>> data(3, vector<int>(3));
  rep(i,3){
    rep(j,3){
      cin >> data.at(i).at(j);
    }
  }
  int N = 0;
  cin >> N;
  vector<int>A(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,3){
    rep(j,3){
      rep(k,N){
        if(data.at(i).at(j) == A[k]){
          data.at(i).at(j) = 0;
          break;
        }
      }
    }
  }
  if(data.at(0).at(0) == 0 && data.at(0).at(1) == 0 && data.at(0).at(2) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(1).at(0) == 0 && data.at(1).at(1) == 0 && data.at(1).at(2) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(2).at(0) == 0 && data.at(2).at(1) == 0 && data.at(2).at(2) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(0).at(0) == 0 && data.at(1).at(0) == 0 && data.at(2).at(0) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(0).at(1) == 0 && data.at(1).at(1) == 0 && data.at(2).at(1) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(0).at(2) == 0 && data.at(1).at(2) == 0 && data.at(2).at(2) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(0).at(0) == 0 && data.at(1).at(1) == 0 && data.at(2).at(2) == 0){
    cout << "Yes";
    return 0;
  }
  if(data.at(2).at(0) == 0 && data.at(1).at(1) == 0 && data.at(2).at(0) == 0){
    cout << "Yes";
    return 0;
  }
  cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,a,i;
  int f[3];
  fill(f,f+3,0);
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    if(a%4==0)
      f[2]++;
    else if(a%2==0)
      f[1]++;
    else
      f[0]++;
  }
  if(f[2]>=f[0] || f[2]==f[0]-1&&f[1]==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
//??´??°???????????????????????????????????´??°??¨??????????°???°?????\??????????????¨???????????????

#include <stdio.h>

int main(void){

  int a,b;
  int d,r;
  double f;
  scanf("%d%d",&a,&b);
  d = a/b;
  r = a%b;
  f = (double)a/b;
  printf("%d %d %f\n",d,r,f);
  return 0;
}

Measured memory_bytes: 636
import numpy as np

if __name__ == "__main__":
  _n, _m = map(int, input().split())
  results = []
  flag = set()
  ans_ac = 0
  ans_wa = 0
  for i in range(_m):
    _p, _s = input().split()
    _p = int(_p)
    if _s == 'AC':
      flag.add(_p)
    results.append((_p, _s))

  ans_ac = int(len(flag))

  for p, s in results:
    if s == 'WA' and p in flag:
      ans_wa += 1
    else:
      flag.discard(p)

  print(ans_ac, int(ans_wa))


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

typedef long long ll;

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

int main(){
    int K;
    ll sum=0;
    cin>>K;
    for(int i=1; i<=K;i++)
        for(int j=1; j<=K;j++)
            for(int k=1;k<=K; k++){
                int x = gcd(i, j);
                sum += gcd(x, k);
            }
    cout << sum<<endl;        
                
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int

signed main(){
    
    int n, s, t; cin >> n >> s >> t;
    swap(s, t);
    vector<int> a(n);   
    vector<int> b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];

    vector<vector<int> > dp(n + 1, vector<int> (t + 1, -1));
    dp[0][0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= t; j++){
            if(dp[i][j] == -1) continue;

            // 遊ばない
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);

            // 普通に遊ぶ, (遊べるなら)
            int nj = j + b[i];
            if(!(j < s && s < nj) && nj <= t) dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + a[i]);

            // s まで休んで遊ぶ
            if(j < s){
                int nj = s + b[i];
                if(nj <= t) dp[i + 1][nj] = max(dp[i + 1][nj], dp[i][j] + a[i]);
            }
        }
    }
    
    
    /*for(int i = 0; i <= n; i++){
        for(int j = 0; j <= t; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    int ans = 0;
    for(int j = 0; j <= t; j++) ans = max(ans, dp[n][j]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 73384
s=int(input())
arr=[s]
tmp=0
for i in range(10**6+1):
  if arr[i]%2==0:
    tmp=int(arr[i]/2)
  else:
    tmp=arr[i]*3+1
  if tmp in arr:
    print(i+2)
    break
  arr.append(tmp)

Measured memory_bytes: 3060
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=998244353;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
map<string,int>mem;
void add(int &x,int y){
	x+=y;x%=mod;
}
int dfs(string s){
	if(s=="")return 1;
	if(mem.count(s))return mem[s];
	int ret=dfs(getstr(s,1,(int)s.size()-1))*(1+(s[0]=='1'));
	for(int i=0;i<1;i++){
		for(int len=1;i+len<=s.size();len++){
			string S=getstr(s,i,i+len-1);
			for(int times=2;i+len*times<=s.size();times++){
				for(int j=i+(times-1)*len;j<i+times*len;j++)if(S[(j-i)%len]=='1'&&s[j]=='0')S[(j-i)%len]='0';
				add(ret,dfs(S)*(i+len*times==s.size()?1ll:dfs(getstr(s,i+len*times,(int)s.size()-1))%mod));
			}
		}
	}
	return mem[s]=ret;
}
signed main(){
	string s;
	cin>>s;
	cout<<dfs(s)<<endl;
	return 0;
}

Measured memory_bytes: 6144
words = ("dream","dreamer","erase","eraser")
import sys
readline = sys.stdin.readline

S = readline().rstrip()

stack = [0]
while stack:
  ind = stack.pop()
  if ind == len(S):
    print("YES")
    break
  for w in words:
    if S[ind:ind + len(w)] == w:
      stack.append(ind + len(w))
else:
  print("NO")

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

int main(){
   int n,i,j;
   char w[100][11],c;

   scanf("%d",&n);
   for (i=0;i<n;i++) {
      scanf("%s",w[i]);
      if (i==0) c=w[i][strlen(w[i])-1];
      else if (c==w[i][0]) c=w[i][strlen(w[i])-1];
      else break;
      for (j=0;j<i;j++)
         if (strcmp(w[i],w[j])==0) break;
      if (j<i) break;
   }
   if (i<n) puts("No");
   else     puts("Yes");
   return 0;
}


Measured memory_bytes: 128
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    ArrayList<Integer> list = new ArrayList<>();
    for (int i = 0; i < 5; i++) {
      list.add(Integer.parseInt(scanner.nextLine()));
    }
    int a = list.get(0);
    int e = list.get(4);
    int k = Integer.parseInt(scanner.nextLine());
    if (e -a > k) {
      System.out.println(":(");
    }
    else {
      System.out.println("Yay!");
    }
  }
}

Measured memory_bytes: 23764
#include<iostream>
#include<cstdio>
#include<iomanip>
#include <math.h>
#include<algorithm>
#include<vector>
using namespace std;

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

Measured memory_bytes: 256
from collections import deque
h,w=map(int,input().split())
a=[input() for _ in range(h)]
ans=0
for y in range(h):
    for x in range(w):
        b=[[0]*w for _ in range(h)]
        if a[y][x]==".":
            now=deque([(y,x)])
            while len(now)!=0:
                Y,X=now.popleft()
                for i,j in [[0,1],[0,-1],[1,0],[-1,0]]:
                    if 0<=Y+i<=h-1 and 0<=X+j<=w-1:
                        if a[Y+i][X+j]=="." and b[Y+i][X+j]==0 and (Y+i!=y or X+j!=x):
                            b[Y+i][X+j]=b[Y][X]+1
                            now.append((Y+i,X+j))
            c=0                
            for i in b:
                d=max(i)
                c=max(d,c)
            ans=max(ans,c)     
            # print(b)
print(ans)  

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,N;
  cin >>a >> b;
  if(a>12)a=b;
  else if(a<6)a=0;
  else a=b/2;
  //vector<int> S(N);
  //for(int i=0;i<N;i++){
  
  //}
  //if(){
  //}
  //else if(){
  //}
  cout << a << endl;
}  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <ctime>
#include <fstream>
#include <cmath>
#include <set>

using namespace std;

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

	int n;
	cin >> n;

	int prev;
	cin >> prev;
	int cnt = 1;

	bool increase = false;
	bool decrease = false;
	for (int i = 1; i < n; i++) {
		int a;
		cin >> a;
		if (!increase && !decrease) {
			if (a == prev) {
				continue;
			}
			else if (a > prev) {
				increase = true;
			}
			else {
				decrease = true;
			}
		}
		else if (increase) {
			if (a < prev) {
				increase = false;
				cnt++;
			}
		}
		else {
			if (a > prev) {
				decrease = false;
				cnt++;
			}
		}
		prev = a;
	}

	cout << cnt;
}

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

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

using Graph = vector<vector<int>>;

ll kzyou(ll a,ll k){//aのk乗を返す
    ll zyou = 1;
    for(ll i = 1;i<=k;i++){
        zyou *= a;
    }
    return zyou;
}
typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

int main(){
   ll N;
   cin >> N;
   if(N%2) cout << 0 << endl;
   else{
     int p = 0;
     ll k = 1;
     while(k < N){
       k *= 5;
       p++;
     }
     p--;
     //cout << p << endl;
     ll ans = 0;
     for(ll i = 1;i<=p;i++){
       ans += N/(kzyou(5,i)*2);
     }
     cout << ans << endl;
   }
   
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int q = 0; q < n; q++){
        cin >> a[q];
    }
    map<int, int> s;
    for (int q = 0; q < n; q++){
        s[q-a[q]-a[0]]++;
    }
    int ans = 0;
    for (int q = 0; q < n; q++){
        s[q-a[q]-a[0]]--;
        ans += s[a[q]+q-a[0]];
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
	int A,B,C;

	cin >> A >> B >> C;

	if (B / A >= C) {
		cout << C << endl;
	}

	else if (B / A <= C) {
		cout << B / A << endl;
	}

	return 0;
}

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

int main() {

    int S,h,m,s;

    cin >> S;
    h = S / 3600;
    S -= h * 3600;
    m = S / 60; 
    S -= 60 * m;
    s = S;
    
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3080
#include <stdio.h>

int main()
{
	long long int card[3];
	long long int k;
	long long int sum = 0;
	int i = 1,j = 0;
	
	scanf("%lld %lld %lld %lld",&card[0],&card[1],&card[2],&k);
	
	while(k > 0 && j < 3)
	{
		if(k - card[j] < 0)
		{
			sum += k * i;
			k -= card[j];
		}
		else 
		{
			k -= card[j];
			sum += card[j] * i;
		}
		
		j++;
		i--;
	}
	
	printf("%lld\n",sum);
	
	return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
const int MAX=100001;

typedef pair<int,int> pii;
vector<pii> edge[MAX];
bool visited[100001];
int dist[100001];

bool dfs(int v)
{
    visited[v]=true;
    for(int j=0;j<edge[v].size();j++)
    {
        int next=edge[v][j].first;
        int cost=edge[v][j].second;
        if(!visited[next])
        {
            dist[next]=dist[v]+cost;
            if(!dfs(next))
                return false;

        }
        else
        {
            if(dist[next]!=dist[v]+cost)
                return false;
        }



    }
    return true;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    if(m==0)
    {
        printf("Yes");
        return 0;
    }
    while(m--)
    {
        int l,r,val;
        scanf("%d %d %d",&l,&r,&val);
        edge[l].push_back(make_pair(r,val));
        edge[r].push_back(make_pair(l,-val));
    }
    memset(visited,false,sizeof(visited));
    for(int i=1;i<=n;i++)
    {
        if(!visited[i])
        {
            dist[i]=0;
            if(!dfs(i))
            {
                printf("No");
                return 0;
            }

        }
    }
    printf("Yes");
    return  0;
}

Measured memory_bytes: 12032
#include <stdio.h>
typedef long long ll;
ll arr[300001];
int cnt[300001][60];
ll M = 1000000007;
int main(){
	int N;scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%lld",arr+i);
		for(int j=0;j<60;j++) cnt[i][j]=cnt[i-1][j]+(arr[i]&(1LL<<j)?1:0);
	}
	ll sum = 0;
	for(int i=1;i<N;i++){
		for(int j=0;j<60;j++){
			if(arr[i]&(1LL<<j)){
				sum+=((N-i)-cnt[N][j]+cnt[i][j])*((1LL<<j)%M);
			}
			else{
				sum+=(cnt[N][j]-cnt[i][j])*((1LL<<j)%M);
			}
			sum%=M;
		}
	}
	printf("%lld",sum);
}

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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    int a[n];
    int ans=0;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        if(i%2==0 && a[i]%2==1)
        {
            ++ans;
        }
    }
    cout<<ans;
    return 0;
}


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


int Par[200010],Size[200010];

void init()
{
	for(int i = 0;i<200010;i++)
	{
		Par[i]=i;
		Size[i]=1;
	}
}
int find(int x)
{
	if(Par[x]==x)return x;
	return Par[x] = find(Par[x]);
}

void unite(int x,int y)
{
	x = find(x);y = find(y);
	if(x==y)return;
	Size[x] += Size[y];
	Par[y] = x;
}
int main()
{
	int n,m;
	cin >> n >> m;
	init();
	int ans = 1;
	for(int i = 0;i<m;i++)
	{
		int x,y;cin >> x >> y;
		unite(x,y);
		ans = max(ans,Size[find(x)]);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5180
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        long a[] = new long[n];
        long sum[] = new long[n + 1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            sum[i + 1] = sum[i] + a[i];
        }
        long sum_n = sum[n];

        long min = Long.MAX_VALUE;
        int lp = 0;
        int rp = 2;
        for (int i = 1; i < n - 2; i++) {
            long sum_i = sum[i + 1];
            for (; lp < i; lp++) {
                if (Math.abs(sum_i - 2 * sum[lp + 1]) < Math.abs(sum_i - 2 * sum[lp + 2])) {
                    break;
                }
            }
            for (rp = ((rp == i) ? i + 1 : rp); rp < n - 1; rp++) {
                if (Math.abs(sum_n - 2 * sum[rp + 1] + sum_i) < Math.abs(sum_n - 2 * sum[rp + 2]
                    + sum_i)) {
                    break;
                }
            }

            min = Math.min(min, calc(lp, i, rp, n, sum));
        }

        System.out.println(min);
    }

    private long calc(int l, int c, int r, int n, long sum[]) {
        long s1 = sum[l + 1];
        long s2 = sum[c + 1] - sum[l + 1];
        long s3 = sum[r + 1] - sum[c + 1];
        long s4 = sum[n] - sum[r + 1];

        long min = Math.min(s1, Math.min(s2, Math.min(s3, s4)));
        long max = Math.max(s1, Math.max(s2, Math.max(s3, s4)));

        return Math.abs(max - min);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 88316
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include<tuple>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll mod=1000000007;
    int n;
    ll k;
    int a[2005]={};
    scanf("%d%lld",&n,&k);
    REP(i,n)scanf("%d",&a[i]);
    ll alpha=0;
    ll beta=0;
    REP(i,n){
        for(int j=i+1;j<n;j++){
            if(a[i]>a[j])alpha++;
        }
    }
    REP(i,n)REP(j,n){
        if(a[i]>a[j])beta++;
    }
    ll kk=k*(k-1)/2%mod;
    ll ans=(k*alpha%mod+(beta*kk)%mod)%mod;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a,b,c,d,n;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<=c && d<=b)
      printf("%d",(d-c));
    else if(c<=a && b<=d)
      printf("%d",(b-a));
    else if(a<=c)
    {
        n=b-c;
        if(n<1)
          printf("0");
        else
          printf("%d",n);
    }
    else
    {
        n=d-a;
        if(n<1)
          printf("0");
        else
          printf("%d",n);
    }
}


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

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t n,k;
  cin >> n >> k;
  vector<int64_t> p(n);
  rep(i,n){
    cin >> p.at(i);
  }
  vector<int64_t> r(n+1);
  rep(i,n+1){
    if(i == 0){
      r.at(i) = 0;
    }else{
      r.at(i) = r.at(i-1) + p.at(i-1);
    }
    //cout << r.at(i) << ',';
  }
  //cout << endl;
  int64_t maxpk = 0;
  rep(i,n-k+1){
    maxpk=max(maxpk,r.at(i+k)-r.at(i));
    //cout << r.at(i+k)-r.at(i) << ',';
  }
  double gg = (maxpk+k);
  printf("%.12lf",(gg/2));
    
    
    
    
    
  
}
        
    
      
    
      
  
  

Measured memory_bytes: 3328
N = int(input())
A = list(map(int, input().split()))
FLG = True

for num in A:
    if num % 2 == 0:
        if num % 3 != 0 and num % 5 != 0:
            FLG = False
            break

if FLG:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int main(){
	string S[3];
	cin>>S[0]>>S[1]>>S[2];
        int a=0,b=0,c=0;
        string p="a";
        while(1){
           bool check=false;
           //cout<<p<<endl;
           if(p=="a"){
              a++;
              if(a>S[0].size()){
                 cout<<"A"<<endl;
                 check=true;
              }else{
                 p=S[0][a-1];
              }
            }else if(p=="b"){
              b++;
              if(b>S[1].size()){
                 cout<<"B"<<endl;
                 check=true;
              }else{
                 p=S[1][b-1];
              }
            }else{
              c++;
              if(c>S[2].size()){
                 cout<<"C"<<endl;
                 check=true;
              }else{
                 p=S[2][c-1];
              }
           }
           if(check==true){
              break;
           }
        }
        //cout<<a<<b<<c<<endl;
	return(0);
}

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

using namespace std;

int main(){
	int A, B, K, count = 0;
	cin >> A >> B >> K;
	for(int i = min(A, B); 0 < i; i--){
		if(A % i == 0 && B % i == 0) count++;
		if(count == K) {
			cout << i;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

# nowは今見てる深さに存在しうる最大の頂点数
# max[i] := 深さiに存在しうる最大の頂点数
# maxが2*10^18超えたら無視してる
now, max = 1, [None] * (n + 1)
for i in range(n + 1):
  if a[i] > now:
    print(-1)
    exit(0)
  max[i] = now
  now = min((now - a[i]) * 2, 2000000000000000000)

# 次にボトムアップ
# upは今見ている深さに対して登ってくる辺数
# 当然だけど、up + a[i]がその深さに存在しうる最大の頂点数
# だから、min(max[i], up + a[i])が深さiに存在しうる最大の頂点数になる
# あとはその和を取る
ans, up = 0, 0
for i in range(n, -1, -1):
  count = min(max[i], up + a[i])
  ans += count
  up = count
print(ans)

Measured memory_bytes: 83636
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int main(){
	string s;
	cin >> s;
	if(s[s.length()-1]=='s')
		cout << s << "es" << endl;
	else
		cout << s << "s" << endl;
}

Measured memory_bytes: 3600
N = int(input())
a = [int(input()) for _ in range(N)]
a.insert(0,0)
count = 0
hold = 1
while hold != 2:
    count += 1
    if a[hold] != 2:
        hold = a[hold]
    elif a[hold] == 2:
        break
    if count > (len(a)-1):
        count = -1
        break
print(count)

Measured memory_bytes: 7188
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			Map<Integer, Integer> countMap = new HashMap<>();
			IntStream.range(0, n).forEach(i -> {
				int number = scanner.nextInt();
				countMap.put(number, countMap.getOrDefault(number, 0) + 1);
			});
			System.out.println(countMap.entrySet().stream()
					.mapToInt(entry -> (entry.getValue() >= entry.getKey()) ? entry.getValue() - entry.getKey()
							: entry.getValue())
					.sum());
		}
	}
}


Measured memory_bytes: 63200
#include<stdio.h>
static const int N = 501;

int main(){
  int Ma[N][N];
  int num,x,h,d;
  int i,j;

  scanf("%d",&num);

  for(i=0;i<num;i++){
    for(j=0;j<num;j++){
      Ma[i][j]=0;
    }
    }

    for(i=0;i<num;i++){
      scanf("%d %d",&x,&h);
      x--;
      for(j=0;j<h;j++){
	scanf("%d",&d);
	d--;
	Ma[x][d] = 1;
      }
    }

    for(i=0;i<num;i++){
      for(j=0;j<num;j++){
	if(j){
	  printf(" ");
	}
	printf("%d",Ma[i][j]);
      }
      printf("\n");
    }
    return 0;
  }



Measured memory_bytes: 2088
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    ll x,y;
    cin >> x >> y;
    int cnt = 1;
    while(1)
    {
        x *= 2;
        if (x<=y) cnt ++;
        else
        {
            break;
        }         
    }

    cout << cnt << endl; 

    return 0;
}

Measured memory_bytes: 256
n = int(input())
cnt = dict()
xy = [tuple(map(int, input().split())) for _ in range(n)]
if n == 1:
    print(1)
    exit()
for x1, y1 in xy:
    for x2, y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x1 - x2
        dy = y1 - y2
        if (dx, dy) not in cnt:
            cnt[(dx, dy)] = 1
        else:
            cnt[(dx,dy)] += 1
print(n - max(cnt.values()))


Measured memory_bytes: 39536
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    ll N, A, B; cin >> N >> A >> B;

    ll D = N / (A + B), M = N % (A + B);
    cout << D * A + min(A, M) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n, m;
priority_queue<int, vector<int>> que;

int main() {
    cin >> n >> m;
    rep(i,n) {
        int a; cin >> a;
        que.push(a);
    }
    rep(j,m) {
        int x = que.top(); que.pop();
        x /= 2;
        que.push(x);
    }
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top(); que.pop();
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int a, b, c;
  cin >> a >> b >> c;

  int ret = abs(a-b) + abs(b-c);
  chmin(ret, abs(a-c) + abs(c-b));
  chmin(ret, abs(b-a) + abs(a-c));
  chmin(ret, abs(b-c) + abs(c-a));
  chmin(ret, abs(c-a) + abs(a-b));
  chmin(ret, abs(c-b) + abs(b-a));

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 256
# D - Banned K
from collections import Counter


def main():
    N, *A = map(int, open(0).read().split())
    counter = Counter(A)
    total = 0
    dif = {}
    for k, v in counter.items():
        total += v * (v - 1) // 2
        dif[k] = v - 1
    ans = [total - dif[a] for a in A]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 48276
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main()
{
  int n;
  cin >> n;
  map<string, int> memo;
  for (int i = 0; i < n; i++)
  {
    string s;
    cin >> s;
    
    memo[s] += 1;
  }
  
  int maxv = 0;
  for (auto x:memo)
  {
    int v = x.second;
    if (v > maxv)
      maxv = v;
  }
  for (auto it = memo.begin(); it != memo.end(); it++)//mapはキーが昇順になるようソートされる
  {
    if (it -> second == maxv)
      cout << it -> first << endl;
  }
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int ctoi(char c){
    switch (c){
        case '0': return 0;
        case '1': return 1;
        case '2': return 2;
        case '3': return 3;
        case '4': return 4;
        case '5': return 5;
        case '6': return 6;
        case '7': return 7;
        case '8': return 8;
        case '9': return 9;
        default: return 0;
    }
}

int main(){
    string S;
    cin >> S;
    int len = S.size();
    int ans = 0;
    rep(i,len){
        ans += ctoi(S[i]);
    }
    if (ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K, X; cin >> K >> X;
  if(500 * K >= X) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vll a(5);
  ll n;
  cin >> n;
  for (int i = 0; i < 5; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  cout << 4 + ((n + a[0] - 1) / a[0]) << endl;
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(lambda x:int(x),input().split()))
memo=[[0 for _ in [0]*(50*i)] for i in range(1,N+1)]
for i in range(N):
    a=A[i]
    for j in range(i,0,-1):
        for k in range(50*j):
            memo[j][k+a]+=memo[j-1][k]
    memo[0][a-1]+=1
cnt=0
for i in range(N):
    cnt+=memo[i][(i+1)*K-1]
print(cnt)

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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}

const int inf = 1e18;
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n,w;
    cin >> n >> w;

    vi wt(n),v(n);
    for(int i = 0; i < n; ++i) cin >> wt[i] >> v[i];
    int max_val = accumulate(all(v),0LL);
    vvi dp(max_val + 1,vi(n + 1,inf));

    // dp[i][j] -> min weight i can have to acheive val i
    for(int i = 0; i <= n; ++i){
        dp[0][i] = 0;
    }

    for(int i = 0; i <= max_val; ++i){
        for(int j = 1; j <= n; ++j){
                dp[i][j] = dp[i][j - 1];
                if(i - v[j - 1] >= 0){
                if(dp[i - v[j - 1]][j - 1] != inf){
                    dp[i][j] = min(dp[i][j],dp[i - v[j - 1]][j - 1] + wt[j - 1]);
                }
                }
        }
    }
    
    
    int ans = 0;
    for(int i = 0; i <= max_val; ++i){
        for(int j = 1; j <= n; ++j){
            if(dp[i][j] <= w){
                ans = max(ans,i);
            }
        }
    }

    cout << ans;
}

Measured memory_bytes: 82304
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 幹線道路
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] hw = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[][] a = new int[hw[0]][];
            int length = int.MaxValue;
            int sum = 0;
            for (int i = 0; i < hw[0]; i++)
            {
                a[i] = Console.ReadLine().Split().Select(int.Parse).ToArray();
            }
            for (int i = 0; i < hw[0]; i++)
            {
                for (int j = 0; j < hw[1]; j++)
                {
                    for (int k = 0; k < hw[0]; k++)
                    {
                        for (int l = 0; l < hw[1]; l++)
                        {
                            sum += (Math.Min(Math.Max(k - i, i - k), Math.Max(l - j, j - l))) * a[k][l];
                        }
                    }
                    length = Math.Min(length, sum);
                    sum = 0;
                }
            }
            Console.WriteLine(length);
        }
    }
}



Measured memory_bytes: 20344
fun main(args: Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map { ij -> ij.toInt() }
    val a = readLine()!!.split(" ").map { ij -> ij.toInt() }
    
    val left = a.filter { ij -> ij < x }.size
    val right = a.filter { ij -> x < ij }.size
    println(Math.min(left, right))
}

Measured memory_bytes: 35956
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main() {

  string S;
  cin>>S;

  int cnt = 0, ans = 0;
  bool flag = false;
  for(int i = 0; i<S.size(); i++){
    if(!flag && S[i] == 'A') flag = true;
    if(flag) cnt++;
    if(flag && S[i] == 'Z') ans = cnt;
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
fun main(args:Array<String>) {
	val (x,y) = readLine()!!.split(" ").map {it.toInt()}
	val g1= listOf(1,3,5,7,8,10,12)
	val g2= listOf(4,6,9,11)
	val g3= listOf(2)
	
	when{
	    x in g1 && y in g1 -> println("Yes")
	    x in g2 && y in g2 -> println("Yes")
	    x in g3 && y in g3 -> println("Yes")
		else -> println("No")
	}
	
}

Measured memory_bytes: 37660
#include<bits/stdc++.h>
#define rint register int 
#define ll long long 
using namespace std;
int n,T,A[1010000];

int main(){
	cin>>n>>T;
	for(rint i=1;i<=n;++i) cin>>A[i];
	int Min=2e9,Max=0,ans=0;
	for(rint i=1;i<=n;++i) {
		if(A[i]-Min>Max) {
			Max=A[i]-Min;
			ans=1;
		}
		else if(A[i]-Min==Max) ans++;
		Min=min(Min,A[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3960
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        a: i32,
        b: i32,
        c: i32,
        d: i32,
    }
    let mut a_tmp = a;
    let mut c_tmp = c;

    loop {
        c_tmp = c_tmp - b;
        if c_tmp <= 0 {
            println!("Yes");
            break;
        }
        a_tmp = a_tmp - d;
        if a_tmp <= 0{
            println!("No");
            break;
        }

    }

}

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

typedef long long ll;

string S, T;
ll N, M;
string S2;
const ll BASE = 34567, MOD = 1e9 + 7;
ll BASE_POW_N;
vector<bool> Ok;
bool OkSome;
vector<ll> Seen;
vector<ll> Order;
vector<ll> Dp;
ll R;

void make_graph() {
  while (S2.size() < M + N) S2 += S;
  BASE_POW_N = 1;
  for (ll i = 0; i < M; ++i) (BASE_POW_N *= BASE) %= MOD;
  ll t_hash = 0;
  for (ll i = 0; i < M; ++i) {
    (t_hash = t_hash * BASE + (T[i] - 'a')) %= MOD;
  }
  Ok.resize(N);
  ll hash = 0;
  for (ll i = 0; i < M; ++i) {
    (hash = hash * BASE + (S2[i] - 'a')) %= MOD;
  }
  for (ll i = 0; i < N; ++i) {
    if (hash == t_hash) {
      Ok[i] = true;
      OkSome = true;
    }
    (hash = hash * BASE + (S2[i + M] - 'a')) %= MOD;
    (hash += MOD - BASE_POW_N * (S2[i] - 'a') % MOD) %= MOD;
  }
}
ll solve() {
  for (ll i = 0; i < N; ++i) {
    if (!Ok[(i + (N - 1) * M) % N]) {
      ll r = 0;
      for (ll k = i; Ok[k]; k = (k + M) % N) ++r;
      R = max(R, r);
    }
  }
  return R == 0 ? (OkSome ? -1 : 0) : R;
}
int main() {
  cin >> S >> T;
  N = S.size();
  M = T.size();
  make_graph();
  cout << solve() << endl;
  return 0;
}


Measured memory_bytes: 3356
import sys
# input = sys.stdin.readline
 
n, m = map(int, input().split())
s = set(map(int, [input() for _ in range(m)]))
MOD = 10 ** 9 + 7
a = 1 if not 0 in s else 0
b = 1 if not 1 in s else 0
for i in range(2, n + 1):
    if i in s:
        a, b = b, 0
    else:
        a, b = b, (a + b) % MOD
print(b)

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

int main() {
  string S;
  cin >> S;
if (S =="ABC"){
  cout << "ARC" << endl;
}
else{
  cout << "ABC" << endl;
}
  // ここにプログラムを追記
  // (ここで"試合結果の表"の2次元配列を宣言)
}


Measured memory_bytes: 3592
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;




int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll b;
        cin>>b;
        a.push_back(b);
    }
    map<ll,ll> M;
    ll ans=0;
    M[0]=1;
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=a[i];
        sum%=m;
        if(M.find(sum)==M.end()){
            M[sum]=1;
        }
        else{
            ans+=M[sum];
            M[sum]++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}



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

const int N = 100010;

int n;
int a[N], dp[N][2];

int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i){
		scanf("%d", &a[i]);
	}
	dp[0][0] = dp[0][1] = 1;
	for (int i = 1; i < n; ++ i){
		dp[i][0] = dp[i][1] = 1 + std::min(dp[i - 1][0], dp[i - 1][1]);
		if (a[i] >= a[i - 1]){
			dp[i][0] = std::min(dp[i][0], dp[i - 1][0]);
		}
		if (a[i] <= a[i - 1]){
			dp[i][1] = std::min(dp[i][1], dp[i - 1][1]);
		}
	}
	return printf("%d\n", std::min(dp[n - 1][0], dp[n - 1][1])), 0;
}

Measured memory_bytes: 1408
a, b, c = map(int, input().split())
ans = []
ans.append(10* a + b + c)
ans.append(10* a + c + b)
ans.append(10* b+ a + c)
ans.append(10* b + c + a)
ans.append(10* c + a + b)
ans.append(10* c + b + a)
print(max(ans))

Measured memory_bytes: 3060
n,m = map(int, input().split())
ab = []
for i in range(n):
    a,b = list(map(int, input().split()))
    ab.append((a,b))
ab.sort()
num = 0
money = 0
for h in range(n):
    num += ab[h][1]
    if num < m:
        money += ab[h][0]*ab[h][1]
    elif num == m:
        money += ab[h][0]*ab[h][1]
        break
    else:
        money += (ab[h][0]*ab[h][1] - (num-m)*ab[h][0])
        break
print(money)

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

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

  long long n, a, b;
  cin >> n >> a >> b;
  long long c = a + b;
  long long cnt = 0;
  if (c) {
    long long q, r;
    q = n / c;
    cnt += q * a;
    r = n % c;
    cnt += min(a, r);
  } 
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256