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

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a;
    double b;
    cin >> a >> b;
    b *= 100;
    int x = round(b);
    cout << (a * x) / 100;
}


Measured memory_bytes: 3732
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())
T, A = 1, 1 
for loop in xrange(N):
    t, a = map(int, raw_input().split())
    n = max((T + t - 1)/t, (A + a - 1)/a)
    T, A = n*t, n*a
print T + A



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

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


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a[1000],b[1000],ans[1000];
    char c[1000];
    int i,max;
    
    for(i=0;i<1000;i++){
        scanf("%d %s %d",&a[i],&c[i],&b[i]);
        if(c[i]=='?'){
            max=i;
            break;
        }else if(c[i]=='+'){
            ans[i]=a[i]+b[i];
        }else if(c[i]=='-'){
            ans[i]=a[i]-b[i];
        }else if(c[i]=='*'){
            ans[i]=a[i]*b[i];
        }else{
            ans[i]=a[i]/b[i];
        }
    }
    
    if(max>0){
        for(i=0;i<max;i++){
            printf("%d\n",ans[i]);
        }
    }
    return 0;
    
}

Measured memory_bytes: 1840
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
vector<unordered_map<ll,ll>>dp;
ll n,m;
vector<vector<ll>> edge;
ll dfs0(ll par,ll node)
{
  if(dp[node].count(par))return dp[node][par];
  ll res=1;
  for(auto nn:edge[node])
  {
    if(nn==par)continue;
    res=(ll)res*(dfs0(node,nn)+1)%m;
  }
  dp[node][par]=res;
  return res;
}
ll dfs(ll par,ll node)
{
  //cout<<par<<" "<<node<<endl;
  if(dp[node].count(par))return dp[node][par];
  if(edge[node].size()==1&&par!=-1)return 1;
  ll mul=1;
  vector<ll>lmul(edge[node].size()),rmul(edge[node].size());
  unordered_map<ll,int>ma;
  int cnt=0;
  for(auto itr=edge[node].begin();itr!=edge[node].end();itr++)
  {
    ma[*itr]=cnt++;
    lmul[ma[*itr]]=mul;
    mul=mul*(dfs(node,*itr)+1)%m;
  }
  mul=1;
  for(auto itr=edge[node].rbegin();itr!=edge[node].rend();itr++)
  {
    rmul[ma[*itr]]=mul;
    mul=mul*(dfs(node,*itr)+1)%m;
  }
  for(ll nn:edge[node])
  {
    dp[node][nn]=lmul[ma[nn]]*rmul[ma[nn]]%m;
  }
  dp[node][-1]=mul;
  return dp[node][par];
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>n>>m;
  edge.resize(n);
  dp.resize(n);
  rep(i,n-1)
  {
    ll a,b;
    cin>>a>>b;
    a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs0(-1,0);
  rep(i,n)
  {
    cout<<dfs(-1,i)<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 34944
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();

    int counter = 0;
    boolean clearchecker = false;
    for(int i = 0; i < n; i++){
      int num1 = sc.nextInt();
      int num2 = sc.nextInt();
      if(num1 == num2){
        counter++;
      }else{
        counter = 0;
      }
      if(counter >= 3){
        clearchecker = true;
      }
    } 

    if(clearchecker){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 25308
#include <stdio.h>
int main(){
	int k,cnt,a;
	scanf("%d",&k);
	if(k%2==0||k%10==5){printf("-1\n");return 0;}//偶数找不到对应的777...7，个位是5的k找不到对应的777...7,需特判
	a=7,cnt=1;//cnt统计7出现的个数
	while(1){//特殊的高精度除
		if(a%k==0)break;
		a%=k,a=a*10+7,cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}
 

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

int main()
{
    int A,B;
    cin >> A >> B;
    if (A <= 5){
        B = 0;
    }
    else if (A <= 12){
        B /= 2;
    }
    cout << B<< endl;
    /*if (!B){
        cout << "Takahashi is " << A <<" years old, and he can ride the Ferris wheel for free.";
    }
    else {
        cout << "Takahashi is " << A <<" years old, and he can ride the Ferris wheel for "<< B <<" yen.";
    }*/
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

// gcd(a,b)
int gcd(int a,int b){
	int ret;
	ret = (b == 0) ? a : gcd(b, a % b);
	return ret;
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a + b > c + d)	puts("Left\n");
	else if(a + b == c + d)	puts("Balanced\n");
	else puts("Right");
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
/**
 *    author:  dattrinh
 *    created:    Problemset
**/
#define pb push_back
#define fi first
#define ss second
#define tp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using i64= int64_t;
const int N = 1e4+5;
ll read() {
    char c=getchar();while(!isdigit(c)) c=getchar();
    int num=0;while(isdigit(c)) num=num*10+c-'0',c=getchar();
    return num;
}
/**-----**-----*/
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int ans=0;
    for(int i=0;i<b;++i)
    {
        int x;cin>>x;
        ans+=x;
    }
    if(ans>a)cout<<-1;
    else cout<<a-ans;
    return 0;
}


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

int main()
{
    int A, B, C;
    int count = 0;
    cin >> A >> B >> C;
    if(A == B)
        count++;
    if(A == C)
        count++;
    if(B == C)
        count++;
    if(count == 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]): Unit = {
    val factors = io.StdIn.readLine.split(" ").map{_.toInt}
    val gcd = calcGcd(factors(0), factors(1))
    println(factors(0).toLong*factors(1)/gcd)
  }

  def calcGcd(num1: Int, num2: Int): Int = {
    var a = num1
    var b = num2
    if(a > b) {
      val tmp = a
      a = b
      b = tmp
    }
    var r = b%a

    while(r != 0) {
      b = a
      a = r
      r = b%a
    }
    return a
  }
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		Console.WriteLine(s.Replace(",", " "));
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
# ABC042C - こだわり者いろはちゃん / Iroha's Obsession (ARC058)
def main():
    N, K, *D = map(int, open(0).read().split())
    D = set(D)
    while any(int(i) in D for i in str(N)):
        N += 1
    print(N)


if __name__ == "__main__":
    main()

Measured memory_bytes: 2940
N = gets.chomp.to_i

def dfs(s)
  return 0 if s.to_i > N

  res = ['7', '5', '3'].all? { |x| s.include?(x) } ? 1 : 0

  ['7', '5', '3'].each do |i|
    res += dfs(s + i)
  end

  return res
end

puts dfs('0')


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define pb push_back
#define in(x) scanf("%d",&x)
#define inn(x,y) scanf("%d%d",&x,&y)
#define innn(x,y,z) scanf("%d%d%d",&x,&y,&z)

using namespace std;
const int N=1e5+5;
const ll MX=1e10;
const int mod=1e9+7;

int n,h,p[N],c[N];
ll dp[N];

int main(){
    cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
    cin>>h>>n;
    for(int i=0;i<n;i++){
        cin>>p[i]>>c[i];
    }

    fill(dp,dp+N,MX);
    dp[0]=0;
    
    for(int i=0;i<n;i++){
        for(int j=p[i];j<N;j++){
            dp[j]=min(dp[j],dp[j-p[i]]+c[i]);
        }
    }

    ll mn=MX;
    for(int i=h;i<N;i++) if(dp[i]!=MX){
        mn=min(mn,dp[i]);
    }
    cout<<mn;
     return 0;

    return 0;
}

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

int main() {
  int n; cin >> n;
  map<string,int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }
  int mx = 0;
  for (auto p : mp) mx = max(mx, p.second);
  for (auto p : mp) {
    if (p.second != mx) continue;
    cout << p.first << endl;
  }
  return 0;
}

Measured memory_bytes: 25216
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int  a, b, c, x, y, ans=100000000000000LL ; 
    cin >> a >> b >> c >> x >> y ;  
    for (int i=0;i<=max(x,y);i++){
        int cur=i*2*c + max(x-i,0LL)*a+max(y-i,0LL)*b;
        ans = min(cur,ans);
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  string s;
  cin>>s;
  vector<bool>c(26,false);
  rep(i,s.size()){
    c[s[i]-'a']=true;
  }
  rep(i,26){
    if(c[i]==false){
      cout<<(char)(i+'a')<<endl;
      return 0;
    }
  }
    cout<<"None"<<endl;
}

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

using namespace std;

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

    int s,w;
    cin>>s>>w;

    if(w>=s){
        cout<<"unsafe\n";
    }
    else{
        cout<<"safe\n";
    }


    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    if (a > b) {
        swap(a, b);
    }

    for (auto i : irange(0L, b)) {
        cout << a;
    }
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
public static void main(String args[])
{
Scanner scan=new Scanner(System.in);
while(true)
{
int l=scan.nextInt();
if(l==0)break;
int sum=0,x=0;
for(int i=1;i<=12;i++)
	{
	int m,n;
	m=scan.nextInt();
	n=scan.nextInt();
	sum+=m-n;
	
if(sum>=l && x==0)x=i;


	}
	if(sum>=l)System.out.println(x);
	else System.out.println("NA");
}
}
}

Measured memory_bytes: 34620
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		//System.out.println(N);
		int []n=new int[N];
		for(int i=0;i<n.length;i++){
			n[i]=sc.nextInt();
			//System.out.println(n[i]);
		}
		int M=sc.nextInt();
		for(int i=0;i<M;i++){
			int sum=0;
			int m=sc.nextInt();
			//System.out.println(m);
			//System.out.println(n[m-1]);
			int s=sc.nextInt();
			//System.out.println(s);
			int x=s-n[m-1];
			for(int j=0;j<N;j++){
				sum+=n[j];
			}
			sum+=x;
			System.out.println(sum);
		}
	}
}


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

namespace ABC099A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = int.Parse(Console.ReadLine());

            if (input < 1000)
            {
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("ABD");
            }
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,k,m,alt,r,p,q,ans=0;
	cin>>n>>k;
	int rabbit[n];
	bool check[n];
	rep(i,k){
		cin>>m;
		rep(j,m){
			cin>>alt;
			rabbit[alt-1]=i;
			check[alt-1]=true;
		}
	}
	cin>>r;
	rep(i,r){
		cin>>p>>q;
		if(rabbit[p-1]==rabbit[q-1]){
			if(check[p-1] && check[q-1]){
				ans+=2;
				check[p-1]=check[q-1]=false;
			}else if(check[p-1] || check[q-1]){
				ans++;
				check[p-1]=check[q-1]=false;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	while(cin>>n,n){
		int in[50][30]={0};
		rep(i,n){
			int a;
			cin>>a;
			rep(j,a){
				int b;
				cin>>b;
				in[i][b-1]=true;
			}
		}
		vvi dp(n,vi(31,0));
		rep(i,n)dp[i][0]=(ll)1<<i;
		int out=-1;
		rep(i,30){
			ll t=-1;
			rep(j,n)if(in[j][i]){
				if(t+1)dp[j][i+1]=t;
				else{
					t=0;
					rep(k,n)if(in[k][i])t|=dp[k][i];
					if(t==((ll)1<<n)-1){out=i+1;break;}
					dp[j][i+1]=t;
				}
			}else dp[j][i+1]=dp[j][i];
			if(out+1)break;
		}
		cout<<out<<endl;
		//rep(i,n){rep(j,5)cout<<" "<<dp[i][j];cout<<endl;}
	}
}

Measured memory_bytes: 1232
#include<cstdio>
#include<algorithm>
#include <vector>
#include <map> // pair
using namespace std;


int main()
{	
	long int N;
	scanf("%ld", &N);
	long int a[2*N][2];
	for(long int i=0;i<N;i++)
	{
		scanf("%ld %ld",&a[2*i][0],&a[2*i+1][0]);
	}
	
	for(long int i=0;i<2*N;i++)
	{
		a[i][1]=i;
	}

	vector<pair<long int, long int> > pairs(2*N);
	for (long int i = 0; i < 2*N; i++) {
	pairs[i] = make_pair(a[i][0], a[i][1]);
	}

	sort(pairs.begin(), pairs.end());

	long int b[N];
	long int c[N];
	for(long int i=0;i<N;i++)
	{
		b[i]=(pairs[i].second)/2;
		c[i]=pairs[i].second%2;
	}
	sort(b,b+N);
	long int hantei=0;
	for(long int i=0;i<N-1;i++)
	{
		if(b[i]==b[i+1])
		{
			hantei=1;
		}
	}
	int saigo=0;
	int memo=0;
	if(hantei==0){
	hantei=1;
	
	for(long int i=0;i<N-1;i++)
	{
		if(c[i]!=c[i+1])
		{	
			if(i!=N-2)
			{
				memo=1;
			}
			if(memo==0)
			{
			saigo=1;
			}
			hantei=0;
		}
	}
	}
	
	long int answer=0;
	
	for (long int i = 0; i < N; i++) {
	answer=answer+pairs[i].first;
	}
	if(hantei==0)
	{
		if( ((pairs[N-1].second)/2!=(pairs[N].second)/2) )
		{
		answer=answer-pairs[N-1].first+pairs[N].first;
		}
		else
		{
			if(saigo==1)
			{
			answer=answer-pairs[N-1].first+pairs[N].first;
			}
			else
			{
			answer=min(answer-pairs[N-1].first+pairs[N+1].first,answer-pairs[N-2].first+pairs[N].first);
			}
		}
				
		
	}
	printf("%ld",answer);
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

int N,M,K,X,Y;
string S,T;
vector<tuple<int,int,int>> A;
void input()
{
    cin>>N;
    A.resize(N);
    rep(i,0,N-1){
        int a,b,c;
        cin>>a>>b>>c;
        A[i] = make_tuple(a,b,c);
    }
}
int dp[555555][3];
int b[555555][3];
void solve()
{
    
    // n=1.
    // max8a,b,c

    rep(i,0,N-1){
        b[i][0] = get<0>(A[i]);
        b[i][1] = get<1>(A[i]);
        b[i][2] = get<2>(A[i]);
    }
    rep(i,0,2) {
        dp[0][i] = b[0][i];
    }
    rep(i,1,N-1){
        rep(j,0,2){
            rep(k,0,2){
                if (j==k)continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k]+b[i][j]);
            }
        }
    }

    cout<<max({dp[N-1][0], dp[N-1][1], dp[N-1][2]})<<endl;


}
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 10752
package main
import(
  "fmt"
)
func main(){
  var n, i, j int
  ans:=0
  fmt.Scan(&n,&j)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    if a[i]>=j{
      ans++
    }
  }
  fmt.Println(ans)
}


Measured memory_bytes: 5504
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int N = intRead();
        bool[] dp = new bool[10100];
        for (int i = 0; i < 10010; i++) dp[i] = false;
        dp[0] = true;
        int box;
        for (int i = 0; i < N; i++)
        {
            box = intRead();
            //逆順から取らないと加算され続ける
            for (int j = 10000; j != -1; j--) { if (dp[j]) dp[j + box] = true; }
        }
        for (int i = 10000; i != -1; i--)
        {
            if (i % 10 == 0) continue;
            else if (dp[i])
            {
                Console.WriteLine(i);
                return;
            }
        }
        Console.WriteLine(0);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  string s;
  cin >> n >> s;
  
  char c;
  for(int i = 0; i < s.size(); i++){
    c = s.at(i);
    c += n;
    if(c > 90) c -= 26;
    s.at(i) = c;
  }
  
  cout << s << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
   int a,b,c,x=0;
   scanf("%d", &a); scanf("%d", &b); scanf("%d", &c);

   if(a>b) {x=a;a=b;b=x;}
   if(b>c) {x=b;b=c;c=x;}
   if(a>b) {x=a;a=b;b=x;}
   
   printf("%d %d %d\n",a,b,c);
  
   return 0;
}

Measured memory_bytes: 596
/*Whose woods these are I think I know.
His house is in the village though;
He will not see me stopping here
To watch his woods fill up with snow.

My little horse must think it queer
To stop without a farmhouse near
Between the woods and frozen lake
The darkest evening of the year.

He gives his harness bells a shake
To ask if there is some mistake.
The only other sound’s the sweep
Of easy wind and downy flake.

The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,sum=0;
    cin>>n;
    int i=1;
    while(true)
    {
        sum=(i*(i+1))/2;
        if(sum>=n)
            break;
        ++i;
    }
    while(i>0)
    {
        n-=i;
        if(n==0)
        {
            cout<<i<<endl;
            break;
        }
        else if(n>0)
        {
            cout<<i<<endl;
            --i;
        }
        else
        {
            n+=i;
            --i;
        }
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
static class Program
{
    static void Main(string[] args)
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);

        //入力
        var str = Console.ReadLine();
     

        for(var i = 0; i < str.Length; i++){
          Console.Write("x");
        }
        Console.WriteLine("");
        Console.Out.Flush();
    }
}

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

bool ascii[26] = {false};
int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    string w;
    cin >> w;
    for(char ch: w){
        ascii[ch-'a'] = !ascii[ch-'a'];
    }
    for(int i=0; i<26; i++){
        if(ascii[i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,K;
  cin>>N>>K;
  VL X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];
  ll ans=LLONG_MAX;
  rep(i,N) rep(j,N) rep(k,N) rep(l,N){
    int cnt=0;
    rep(m,N){
      if(X[m]>=X[i] and X[m]<=X[j] and Y[m]>=Y[k] and Y[m]<=Y[l]) cnt++;
    }
    if(cnt>=K) ans=min(ans,abs(X[i]-X[j])*abs(Y[k]-Y[l]));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int Q = sc.nextInt();
		int H = sc.nextInt();
		if(Q <= H) {
			System.out.println(0);
		} else {
			System.out.println(Q - H);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int i,j,k,count1=0,count2=0;

int main(void){
    int k;
    cin>>k;
    vector<int> vec={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};
    cout<<vec[k-1]<<endl;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int a, b, c;
    cin >> a >> b >> c;
    if(((b * 10 + c) % 4) == 0){
cout << "YES" <<endl;
} else {
cout << "NO" << endl;
}
    return 0;
}


Measured memory_bytes: 256
var n,k:longint;
    i:longint;
    x:longint;
    c:array[0..205000]of longint;
    max,num:longint;
procedure qs(l,r:longint);
var i,j,m,t:longint;
begin
  i:=l;
  j:=r;
  m:=c[(l+r)>>1];
  repeat
    while c[i]<m do inc(i);
    while c[j]>m do dec(j);
    if i<=j then
    begin
      t:=c[i];c[i]:=c[j];c[j]:=t;
      inc(i);
      dec(j);
    end;
  until i>j;
  if l<j then qs(l,j);
  if i<r then qs(i,r);
end;
begin
  read(n,k);
  for i:=1 to n do
  begin
    read(x);
    if c[x]=0 then dec(k);
    inc(c[x]);
    if x>max then max:=x;
  end;
  k:=-k;
  qs(1,max);
  num:=0;
  for i:=1 to max+1 do
  if c[i]>0 then
  begin
    if k<=0 then
    begin
      writeln(num);
      exit;
    end;
    dec(k);
    inc(num,c[i]);
  end;
end.

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

int main(){
  int n; cin >> n;
  int tc=0,fc=0,c=0;
  for(int i=0;i<n;i++){
  	int t; cin >> t; 
    if(t % 4 == 0) fc++;
    else if(t % 2 == 0) tc++;
    else c++;
  }
  if(fc==0&&c==0){cout << "Yes" << endl; return 0;}
  else if(tc==0){
    if(c <= fc+1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
  }
  else{
    if(c <= fc) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	char c;
	cin>>c;
	if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o') cout<<"vowel";
	else cout<<"consonant";
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define inf 99999999
using namespace std;
typedef double db;
typedef long long ll;
int b,a,n;
int main()
{
	cin>>n>>a>>b;
	if((b-a-1)%2==1)
		cout<<"Alice"<<endl;
	else
		cout<<"Borys"<<endl;
	return 0;
}


Measured memory_bytes: 256
let pow x y z =
  let mult x1 y1 = ((x1 mod z)*(y1 mod z)) mod z in
  let rec f m n odd b = match n with
      0 -> 1
    | 1 -> mult m odd
    | _ -> let t = if n mod 2 = 1 then mult odd b else odd
           in f (mult m m) (n/2) t (mult b b)
  in f x y 1 x;;

let () =
  let f x y = pow x y 1000000007 |> Printf.printf "%d\n"
  in Scanf.scanf "%d %d\n" f;;

Measured memory_bytes: 2348
from _datetime import datetime

def main():
    S = list(map(int, input().split('/')))
    year = S[0]
    month = S[1]
    day = S[2]
    converted_datetime = datetime(year, month, day).strftime('%s')
    flg_datetime = datetime(2019, 4, 30).strftime('%s')
    if converted_datetime <= flg_datetime:
        print('Heisei')
    else:
        print('TBD')
main()

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 

public class Main{
          
    static int n=0;
     
     public static void main(String args[]){
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         
         try{ String line;
             while((line=br.readLine())!=null){if(line.isEmpty())break;
                String spl[] = line.split(",");
               int q = Integer.parseInt(spl[0]); if(q==-1)break;
               double x=(double)q/2;
               while(true){
                   x=x-(x*x*x-q)/(3*x*x);
                   if(Math.abs(x*x*x-q)<0.00001*q)break;
               }
                 System.out.println(x);
               
             } br.close();
            
         }catch(Exception e){e.printStackTrace();}         
     }  
    
     
     
}
 

Measured memory_bytes: 16944
#include <bits/stdc++.h>
using namespace std;
int dp[100004];
int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	for(int i = 0; i < n; i++) {
		cin >> h[i];
	}
  	dp[0] = 0;
  	dp[1] = abs(h[1] - h[0]);
  	for(int i = 2; i < n; i++) {
    	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
    }
	cout << dp[n-1] << endl;
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
map<string, int> m;
int main() {
  int r;
  cin >> r;
  cout << r * r << endl;
}

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

#define MAX_N 200010
#define INF 1e14
typedef long long ll;

#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)

struct BIT{
  ll bit[MAX_N+1];

  void init(){
    memset(bit,0,sizeof(bit));
  }

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }

  void add(int i,ll v){
    while(i<=MAX_N){
      bit[i]+=v;
      i+=i&-i;
    }
  }
};

struct RangeSumQuery{
  //int size;
  BIT bit0, bit1;

  RangeSumQuery(){}

  void init() {
    //size = size_;
    bit0.init();
    bit1.init();
  }

  //[from, to)
  ll sum(int from, int to) {
    return (bit0.sum(to)+bit1.sum(to)*to) - (bit0.sum(from)+bit1.sum(from)*from);
  }

  //[from, to)
  void add(int from, int to, ll value) {
    bit0.add(to, to * value);
    bit0.add(from, - from * value);
    bit1.add(from, value);
    bit1.add(to, -value);
  }
};

ll N, Q;
vector<ll> A[26];
ll B[MAX_N];
char str[MAX_N];
RangeSumQuery bit;

int main() {
    scanf("%s", str);
    N = strlen(str);
    rep(i,26) A[i].clear();

    rep(i, N) {
      A[str[i]-'a'].push_back(i);
    }
    ll odd = 0;
    rep(i,26) {
      if((int)A[i].size() % 2 == 1) odd++;
    }
    if(odd >= 2) {
      printf("-1\n");
      return 0;
    }
    rep(i,26) {
      int n=(int)A[i].size();
      rep(j,(n+1)/2) {
        B[A[i][j]] = A[i][n - j - 1];
      }
    }
    ll res = 0;
    bit.init();
    rep(i,N)bit.add(i+1,i+2,i);
    ll n = N;
    rep(i, N) {
      if(bit.sum(i+1,i+2) == 0) {
        ll j = B[i] + 1;
        res += n - bit.sum(j,j+1) - 1;
        if(i + 1 != j) {
          bit.add(1,j,-1);
          bit.add(j,N+1,-2);
        }
        else {
          bit.add(j,N+1,-1);
        }
        bit.add(i+1,i+2,INF);
        bit.add(j,j+1,INF);
        n -= 2;
      }
    }
    printf("%lld\n", res);
    
  return 0;
}


Measured memory_bytes: 6772
S = list(input())
i = 0
while 'B' in S:
    if S[i] == 'B':
        if i == 0:
            del S[0]
            i = 0
            continue
        else:
            del S[i-1]
            del S[i-1]
            i = 0
            continue
    i += 1
for x in S:
    print(x, end='')
print()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  int cx1, cy1, r1;
  int cx2, cy2, r2;
  
  cin>>cx1>>cy1>>r1;
  cin>>cx2>>cy2>>r2;
  
  int X = cx1 - cx2, Y = cy1 - cy2;
  
  int d2 = X * X + Y * Y;
  
  int A = r1 + r2, B = r1 - r2;
  int A2 = A * A, B2 = B * B;
  
  if( A2 < d2 ) cout<<4<<endl;
  else if( A2 == d2 ) cout<<3<<endl;
  else if( d2 == B2 ) cout<<1<<endl;
  else if( d2 < B2 ) cout<<0<<endl;
  else cout<<2<<endl;
  
  return 0;
}



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

int main(void){
  char c;
  bool flag = false;

  cin >> c;

  switch(c){
    case 'a' :
    case 'e' :
    case 'i' :
    case 'o' :
    case 'u' : flag = true;
             break;
    default : break;
  }

  if (flag) cout << "vowel" << endl;
  else cout << "consonant" << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args)throws Exception{
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x;
        
        if(a>b){
            x = a;
            a = b;
            b = x;
        }
        if(a>c){
            x = a;
            a = c;
            c = x;
        }
        if(b>c){
            x = b;
            b = c;
            c = x;
        }
        System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 26184
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#include <vector>
using namespace std;
int main(){
    long long ans;
    long long N,K;cin>>N>>K;
    vector<int>A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        A[i]-=1;
    }
    vector<int>B;
    map<int,int> score;
    int m;
    int f=0;
    B.push_back(0);
    int i=0;
    score[0]=1;
    int mm;
    while(f==0){
        
        B.push_back(A[B[i]]);
        //cout<<A[B[i]]+1<<endl;
        i+=1;
        score[A[B[i]]]+=1;
        if(score[A[B[i]]]>1){
            f=1;
            m=i+1;
            mm=A[B[i]];
        }


    }
    
    int dd;
    for(int i=0;i<B.size();i++){
        if(B[i]==mm){
            dd=i;
        }


    }
    m-=dd;
    //cout<<m<<" "<<dd<<endl;

    
    long long nn=(K-dd)%m+dd;
    //cout<<nn<<endl;
    ans=B[nn];
    
    if(K>dd)cout<<ans+1<<endl;
    else cout<<B[K]+1<<endl;


}


Measured memory_bytes: 13872
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int main(void){
    int H1, M1, H2, M2, K;
    cin >> H1>> M1>> H2>> M2 >> K;
    int H, M, T;
    H = H2 -H1;
    M = M2 - M1;
    if(M<0){
        M += 60;
        H -= 1;
    }
    T = H*60 + M -K;
    cout << T << endl;
    return 0;
}

/*
7
nikoandsolstice
*/

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define puts(i) cout<<i<<endl
using ll = long long;
using P = pair<int,int>;

int main(){
	int n;
	cin>>n;
	int a[2][n];
	rep(i,2)rep(j,n)cin>>a[i][j];
	int dp[2][n];
	dp[0][0]=a[0][0];
	dp[1][0]=dp[0][0]+a[1][0];
	for(int i=1;i<n;i++){
		dp[0][i]=dp[0][i-1]+a[0][i];
		dp[1][i]=max(dp[1][i-1]+a[1][i],dp[0][i]+a[1][i]);
	}
	puts(dp[1][n-1]);
}

Measured memory_bytes: 256
import numpy as np
words = lambda t : list(map(t, input().split()))

s = input()

bres = 0
wres = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            bres += 1
        else:
            wres += 1
    else:
        if s[i] == '0':
            wres += 1
        else:
            bres += 1

print(min(bres,wres))


Measured memory_bytes: 21512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    stack<char> st;
    
    REP(i,s.size()) {
        if (!st.empty() && st.top() == 'S' && s[i] == 'T') st.pop();
        else st.push(s[i]);
    }

    OUT(st.size())

    return 0;
}

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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector<int> z_func(string &s) {
  vector<int> z(len(s), 0);
  int l = 0, r = 1;
  rep(i, 1, sz(z) - 1) {
    if (i < r)
      z[i] = min(z[i - l], r - i);
    while (i + z[i] < len(s) && s[z[i]] == s[i + z[i]])
      z[i]++;
    if (i + z[i] > r)
      l = i, r = i + z[i]; 
  }
  return z;
}

void solve() {
  string s;
  cin >> s;
  
  auto z = z_func(s);
  bool can_divide = false;

  rep(i, 1, len(s) / 2) {
    can_divide = len(s) % i == 0 && z[i] == i * (len(s) / i - 1);
    if (!can_divide) continue;

    if (i == 1) {
      cout << len(s) << nl << 1;
      return;
    }

    break;
  }

  if (!can_divide) {
    cout << 1 << nl << 1;
    return;
  }

  string rev_s = s;
  reverse(all(rev_s));
  auto rev_z = z_func(rev_s);

  vector<bool> can_divide_left(sz(z), true);
  can_divide_left[0] = false;
  rep(j, 1, sz(z) - 1) {
    if (z[j] >= j) {
      for (int k = j; k < j + z[j]; k += j)
        if (k + j < sz(z) && z[k] >= j)
          can_divide_left[k + j] = false;
        else
          break;
    }
  }

  vector<bool> can_divide_right(sz(z), true);
  can_divide_right[sz(z) - 1] = false;
  per(j, sz(z) - 2, 0) {
    int l = len(s) - j - 1;
    if (rev_z[l] >= l) {
      for (int k = j; k > j - rev_z[l]; k -= l)
        if (k - l >= 0 && rev_z[len(s) - k - 1] >= l)
          can_divide_right[k - l] = false;
        else
          break;
    }
  }

  int res = 0;
  rep(j, 1, len(s) - 1) {
    if (can_divide_left[j] && can_divide_right[j - 1]) {
      res++;
    }
  }

  cout << 2 << nl << res;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

Measured memory_bytes: 8216
def main():
    N, x, *an = map(int, open(0).read().split())
    ans = 0
    for i in range(N - 1):
        if x < an[i] + an[i + 1]:
            cur = an[i] + an[i + 1] - x
            ans += cur
            if an[i + 1] <= cur:
                an[i + 1] = 0
            else:
                an[i + 1] -= cur
    print(ans)
    return


main()


Measured memory_bytes: 14092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    ll a,b;
    ll ans=0;
    cin >> a >>b;
    ll gd=gcd(a,b);
    vector<ll>div;
    for(ll i=1;i*i<=gd;i++){
        if(gd%i!=0) continue;
        div.push_back(i);
        if(i*i!=gd) div.push_back(gd/i);
    }
    for (ll x:div){
        int sosu=0;
        for(ll j=1;j*j<=x;j++){
            if(x%j==0) sosu++;
        }
        if(sosu==1) ans++;
    }
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 384
x=input()
x=list(x)
a=len(x)
ans=0
count=0
for i in range(a):
	if x[i]=='A' or x[i]=='C' or x[i]=='G' or x[i]=='T':
		count=count+1
	else:
		if ans<count:
			ans=count
		count=0
if count!=0 and ans<count:
	print(count)
else:
	print(ans)

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

using namespace std;

int N, M;
int K[100010];
vector<int> L[100010];
int lang[100010];
int par[100010];
int sz[100010];

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;
  par[y] = x;
  sz[x] += sz[y];
}

int main(void) {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> K[i];
    for (int j = 0; j < K[i]; j++) {
      int l;
      cin >> l;
      L[i].push_back(l);
    }
  }

  for (int i = 0; i < N; i++) {
    par[i] = i;
    sz[i] = 1;
  }

  fill(lang, lang + 100010, -1);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < K[i]; j++) {
      if (lang[L[i][j]] < 0) {
        lang[L[i][j]] = i;
      } else {
        unite(lang[L[i][j]], i);
      }
    }
  }
  cout << (sz[find(0)] == N ? "YES" : "NO") << endl;

  return 0;
}

Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		sc.close();

		long ans = x / 11 * 2;
		long r = x % 11;
		if (0 < r) {
			if (r <= 6) {
				ans++;
			} else {
				ans += 2;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include <set>
#include<cmath>
using namespace std;
typedef long long ll;
int main()
{
	char str[1005];
	cin >> str;
	int len = strlen(str);
	if (str[len-1] == 's')
	{
		cout << str << "es"<<endl;
	}
	else
	{
		cout << str << "s"<<endl;
	}	
	return 0;
}

Measured memory_bytes: 3632
a, b, c, x = map(int, open(0).read().split())
ans = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      if 500 * i + 100 * j + 50 * k == x:
        ans += 1
print(ans)

Measured memory_bytes: 9180
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define ARR_MAX 2000
#define BUF_SIZE (ARR_MAX*11+50)

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

struct pair {
    uint64_t elem;
    int idx;
};

int desc_by_elem(const void *a1, const void *a2) {
    struct pair *pa1 =(struct pair*)a1;
    struct pair *pa2 =(struct pair*)a2;
    int e1 = pa1->elem;
    int e2 = pa2->elem;
    return e2 - e1;
}


int main(void) {
    int num = get_int();
    int arr[ARR_MAX];
    static uint64_t dp[ARR_MAX+1][ARR_MAX+1];
    fget_array(arr, num);
    struct pair brr[ARR_MAX];
    int i, j;
    // brr: 1-indexed
    for(i = 0; i < num; i++) brr[i] = (struct pair){arr[i], i};

    qsort(brr, num, sizeof(struct pair), desc_by_elem);

    for(i = 1; i <= num; i++) {
        struct pair p = brr[i-1];
        for(j = 0; j < i; j++) {
            int head = j;
            int tail = num - (i-j);
#ifdef DEBUG
            printf("%d, %d -> %d %d\n", i, j, head, tail);
#endif
            dp[i][j+1] = max(
                dp[i][j+1],
                dp[i-1][j] + p.elem * abs(p.idx - head)
            );
            dp[i][j] = max(
                dp[i][j],
                dp[i-1][j] + p.elem * abs(tail - p.idx)
            );
        }
    }

    uint64_t ans = 0;
    for(i = 0; i <= num; i++) {
        ans = max(ans, dp[num][i]);
    }
    printf("%llu\n", ans);
    return 0;
}


Measured memory_bytes: 24440
#include <stdio.h>
int length(int x, int y){
  if(x>=y) return x-y;
  else return y-x;
}
int main(){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(length(a,c) <= d) printf("Yes\n");
  else if(length(a,b) <= d && length(b,c) <= d) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

LL LCM(LL x,LL y)
{
	int i;
	for(i=1;i<=y;i++)
	{
		if((x*i)%y==0)
			return x*i;
	}
	return x*y;
}

int main()
{
	int a[3],m[3],i,j,x;
	for(;~scanf("%d%d",&a[0],&m[0]),a[0];)
	{
		LL p[3]={0};
		for(i=1;i<3;i++)
			scanf("%d%d",&a[i],&m[i]);
		for(i=0;i<3;i++)
		{
			j=p[i];
			x=1;
			do{
				x=x*a[i]%m[i];
				p[i]++;
			}while(x!=1);
		}
		printf("%lld\n",LCM(LCM(p[0],p[1]),p[2]));
	}
}

Measured memory_bytes: 600