akhauriyash/Code-Regression huggingface dataset:
/*
    Author: Arham_doshi
    @quote "Code like there's no tommorow!"
     ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
    */
    #include <bits/stdc++.h>
     
    #define int         long long
    #define double      long double
    #define pb          push_back
    #define pf          push_front
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define all(a)      (a).begin(),(a).end()
    #define rall(a)     (a).rbegin(),(a).rend()
    #define x           first
    #define y           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define hell        998244353
    #define PI          3.141592653589
    #define bs(v,n)     binary_search(all((v)),(n))
    #define lb(v,n)     lower_bound(all((v)),(n))
    #define ub(v,n)     upper_bound(all((v)),(n))
    #define fo(i,l,u)   for(i=l;i<u;i++)
    #define rfo(i,l,u)  for(i=l;i>=u;i--)
    #define allfo(s)    for(auto it=(s).begin();it!=(s).end();it++)
    #define _init(b)     memset(b,-1,sizeof(b))
    #define _init0(b)     memset(b,0,sizeof(b))
    #define MOD         1000000007
     
     
     
    using namespace std;
     
    int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
    bool mod(double a,double b) {return a/b - floor(a/b);}
    int ceil(int n,int k){if(k%n==0){return k/n;}else return (k/n)+1;}
    int occurs(vi v,int n){
    auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
     
    int logb(int base, int x) {
        return (log(x) / log(base));
    }
   int n,a[405],dp[405][405],ps[405];
     int slime(int l,int r){
         if(l==r)return 0;
         else if(dp[l][r]!=-1)return dp[l][r];
         else {
             int i;
             
             fo(i,l,r+1){
                 if(dp[l][r]==-1){
                     dp[l][r]=(slime(l,i)+slime(i+1,r)+ps[r]-ps[l-1]);
                 }
                 else{
                     dp[l][r]=min(dp[l][r],(slime(l,i)+slime(i+1,r)+ps[r]-ps[l-1]));
                 }
             }
             return dp[l][r];
             
         }
     }
     
     
     
    signed main()
    {
        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
        int i,j,x,t,k;
       cin>>n;
       a[0]=0;
       ps[0]=0;
       fo(i,1,n+1){
           cin>>x;
           a[i]=x;
           ps[i]=ps[i-1]+a[i];
           
       }
       
       
       _init(dp);
       fo(i,0,n+1){
           dp[i][i]=0;
       }
       
       cout<<slime(1,n);
       
       
        return 0;
    }

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

int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<int>>G(h,vector<int>(w,0));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin >> c;
            if(c=='#'){
                G[i][j]=1;
            }
        }
    }
    int ans=0;
    for(int bit_a=0;bit_a<(1<<h);bit_a++){
        for(int bit_b=0;bit_b<(1<<w);bit_b++){
            int black=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(((bit_a>>i)&1)==1 && ((bit_b>>j)&1)==1){
                        black+=G[i][j];
                    }
                }
            }
            if(black==k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}
  


Measured memory_bytes: 3644
N,M=map(int, input().split())
A,B=[],[]
for i in range(N):
    A.append(list(map(int, input().split())))
A.sort(key=lambda x:x[0])
R,S=M,0
for a in A:
    if a[1]>=R:
        S+=a[0]*R;R=0
    else:
        S+=a[0]*a[1];R-=a[1]
    if R==0: break
print(S)



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

int a[8][3] = { {0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8,},{2,4,6} };

bool judge(string s, char c) {
	for (int i = 0; i < 8; i++) {
		if (s[a[i][0]] == c && s[a[i][1]] == c && s[a[i][2]] == c)
			return true;
	}
	return false;
}

int main() {
	string s;
	while (cin >> s) {
		if (judge(s, 'o')) {
			cout << 'o';
		} else if (judge(s, 'x')) {
			cout << 'x';
		} else {
			cout << 'd';
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
const int N=75;
int n,m,fa[N],e[N][N],ans;
int getf(int x) {return fa[x]==x?x:fa[x]=getf(fa[x]);}
void work() {
	for(int i=1;i<=n;i++) fa[i]=i;
	for(int i=1;i<=n;i++)
	  for(int j=i+1;j<=n;j++)
	    if(e[i][j]) fa[getf(i)]=getf(j);
	for(int i=2;i<=n;i++) if(getf(i)!=getf(1)) {ans++;break;}
}
int main() {
	cin>>n>>m;
	for(int i=1;i<=m;i++) {
		int u,v; cin>>u>>v;
		e[u][v]=e[v][u]=1;
	}
	for(int i=1;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			if(!e[i][j]) continue;
			e[i][j]=0; work(); e[i][j]=1;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<25);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

string s[22];
bool mp[23][23];
int d[23][23][23][23];

int main(void){
	int h,w,i,j,sx,sy,gx,gy,ans=0;
	cin >> h >> w;
	fill(d[0][0][0],d[23][0][0],INF);
	for(i=0; i<h; ++i){
		cin >> s[i];
		for(j=0; j<w; ++j){
			if(s[i][j]=='.'){
				mp[i+1][j+1] = true;
			}
		}
	}
	for(i=1; i<=h; ++i){
		for(j=1; j<=w; ++j){
			d[i][j][i][j] = 0;
			if(!mp[i][j]){
				continue;
			}
			if(mp[i-1][j]){
				d[i][j][i-1][j] = 1;
			}
			if(mp[i][j-1]){
				d[i][j][i][j-1] = 1;
			}
			if(mp[i][j+1]){
				d[i][j][i][j+1] = 1;
			}
			if(mp[i+1][j]){
				d[i][j][i+1][j] = 1;
			}
		}
	}
	for(i=1; i<=h; ++i){
		for(j=1; j<=w; ++j){
			for(sx=1; sx<=h; ++sx){
				for(sy=1; sy<=w; ++sy){
					for(gx=1; gx<=h; ++gx){
						for(gy=1; gy<=w; ++gy){
							d[sx][sy][gx][gy] = min(d[sx][sy][gx][gy],d[sx][sy][i][j]+d[i][j][gx][gy]);
						}
					}
				}
			}
		}
	}
	for(sx=1; sx<=h; ++sx){
		for(sy=1; sy<=w; ++sy){
			for(gx=1; gx<=h; ++gx){
				for(gy=1; gy<=w; ++gy){
					if(mp[sx][sy] && mp[gx][gy]){
						ans = max(ans,d[sx][sy][gx][gy]);
					}	
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

int main()
{
  int N, A, B, C, D;
  int number_of_X, number_of_Y;
  
  cin >> N >> A >> B >> C >> D;

  N % A ? number_of_X = N / A + 1 : number_of_X = N / A;
  N % C ? number_of_Y = N / C + 1 : number_of_Y = N / C;

  number_of_X * B <= number_of_Y * D ?
    cout << number_of_X * B << endl : cout << number_of_Y * D << endl;
}



Measured memory_bytes: 3112
/*   --------------------
    |       LOSER        |
    |     ~NOOBOSS~      |
     --------------------
*/
#include <bits/stdc++.h>
using namespace std;

#define      inl(x)              scanf("%lld",&x)
#define      in(x)               scanf("%d",&x)
#define      mxx                 10000000000000
#define      mnn                 -10000000000000
#define      Y()                 cout<< "YES" <<endl
#define      N()                 cout << "NO"<<endl
#define      endl                "\n"
#define      max_3(a,b,c)        max(a, max(b,c))
#define      max_4(a,b,c,d)      max(a,max(b,max(c,d)))
#define      min_3(a,b,c)        min(a, min(b,c))
#define      min_4(a,b,c,d)      min(a,min(b,min(c,d)))
#define      gcd(a,b)            __gcd(a,b)
#define      lcm(a,b)           (a*b)/gcd(a,b)
#define      loser               return 0
#define      ll                  long long
#define      lf                  long float
#define      PI                  acos(-1)
#define      mem(a,v)            memset(a,v,sizeof(a))
#define      SORT(v)             sort(v.begin(),v.end())
#define      REV(v)              reverse(v.begin(),v.end())
#define      O(x)                cout<<x<<endl
#define      B                   begin()
#define      E                   end()
#define      V                   vector
#define      F                   first
#define      S                   second
#define      PSB                 push_back
#define      EMB                 emplace_back
#define      MP                  make_pair
#define      PII                 pair<int,int>
#define      MII                 map<int,int>
#define      InTheNameOfGod      ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
const ll MOD = 998244353;
//auto it=std:: unique(v.B,v.E);
//v.resize(std::distance(v.B,it));
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
/*-----*/
#define bug1(a)  cout<<a<<endl;
#define bug2(a,b)  cout<<a<<" "<<b<<endl;
#define bug3(a,b,c)  cout<<a<<" "<<b<<" "<<c<<endl;
/*----*/
ll power(ll n,ll p){if(p==0) return 1;if(p==1)return n;if(p%2)return power(n,p-1)*n;else{ll x=power(n,p/2);return x*x;}}
ll binpow(ll a, ll b){ll res = 1;while (b > 0) {if (b & 1)res*=a;a*=a;b>>=1;}return res;}
ll fact(ll num){ll fac=1;while(num!=1){fac=fac*num;num--;}return fac;}
string to_binary(int x) {string s;while(x > 0) {s += (x % 2 ? '1' : '0');x /= 2;}reverse(s.begin(), s.end());return s;}
ll nsum(ll num){return (num*(num+1))/2;}
/*-----*/
const int N=2e5+5;

/*-----*/
//vector<int> v[202];

/*-----*/
int main(){
   InTheNameOfGod

       ll test=1;
       //cin>>test;
       while(test--){
           ll n,i,j;
           cin>>n;
           ll divs[n+5]={0};
           ll ans=0;
           for(i=1;i<=n;i++){
            for(j=i;j<=n;j+=i){
                divs[j]++;
            }
           }
           for(i=1;i<=n;i++)
            ans+=i*divs[i];
           cout<<ans<<endl;
        }
	loser;
}
///////LeArN MoRe AnD Wait FoR ThE Result///////


Measured memory_bytes: 81744
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    cout<<"Christmas";
    n = 25-n;
    for(int i=0; i<n; i++) cout<<" Eve";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b;

    cin >> a >> b;

    if (a == 1) a = 14;
    if (b == 1) b = 14;

    if (a < b) {
        cout << "Bob";
    } else if (b < a) {
        cout << "Alice";
    } else {
        cout << "Draw";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n, m, k; rd(n, m, k);
  
  foreach(i; 0..n+1)foreach(j; 0..m+1){
    int s=0;
    s+=i*m;
    s-=j*i;
    s+=j*(n-i);
    if(s==k){writeln("Yes"); return;}
  }

  writeln("No");
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	m := getNextInt(scanner)
	if n == 1 && m == 1 {
		fmt.Fprintln(writer, 1)
		return
	}
	if n == 1 {
		fmt.Fprintln(writer, m-2)
		return
	}
	if m == 1 {
		fmt.Fprintln(writer, n-2)
		return
	}
	ans := int64(n-2) * int64(m-2)
	fmt.Fprintln(writer, ans)

}


Measured memory_bytes: 1816
#include<iostream>
using namespace std;
int main()
{
	int m[1024], f[1024], r[1024],me;
	char k[1024];
	for(int i=0;i<1024;i++){
		cin >> m[i] >> f[i] >> r[i];
		if (m[i] == -1 && f[i] == -1 && r[i] == -1){ 
			me = i;
			break; 
		}
	}
	for (int i = 0; i < me; i++){
		if (m[i] == -1 || f[i] == -1){
			k[i] = 'F';
		}
		else if (m[i] + f[i] >= 80){
			k[i] = 'A';
		}
		else if (m[i] + f[i] >= 65){
			k[i] = 'B';
		}
		else if (m[i] + f[i] >= 50){
			k[i] = 'C';
		}
		else if (m[i] + f[i] >= 30){
			if(r[i]>=50){
				k[i] = 'C';
			}
			else{
				k[i] = 'D';
			}
		}
		else{
			k[i] = 'F';
		}
		cout << k[i] << endl;;
	}

	return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
const int mx=5e5+10;
char s[mx];
int f[2][mx];
int main(){
   scanf("%s",s);
   int n=strlen(s);   
   bool ok=false;
   for(int i=0;i<n;i++)if(s[i]!=s[0])ok=true;
   if(!ok){
      printf("%d\n%d\n",n,1);
      return 0;
   }
   for(int it=0;it<2;it++){
      int fi=0;
      for(int i=1;i<n;i++){
         while(fi-1>=0 && s[fi]!=s[i])fi=f[it][fi-1];
         if(s[fi]==s[i])fi++;
         f[it][i]=fi;         
      }
      reverse(s,s+n);
   }   
   int x=n-f[0][n-1];
   if(x==n || n%x!=0 || f[0][n-1]%x!=0){
      puts("1");
      puts("1");
      return 0;
   }
   puts("2");
   int ans=0;
   for(int i=0;i+1<n;i++){
      int j=n-1-(i+1);
      x=i+1-f[0][i];            
      if(f[0][i]!=0 && (i+1)%x==0 && f[0][i]%x==0)continue;
      x=j+1-f[1][j];
      if(f[1][j]!=0 && (j+1)%x==0 && f[1][j]%x==0)continue;
      ans++;
   }
   printf("%d\n",ans);
   return 0;
}


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

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

    int a;
    string s;
    cin >> a;
    cin >> s;
    if (a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}

Measured memory_bytes: 256
MOD=10**9+7
N,M,K=map(int,input().split())

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD

def invmod(a):
  return powmod(a,MOD-2)

def comb_mod(n,r):
  nPr=1
  fact_r=1
  for i in range(r):
    nPr*=n-i
    nPr%=MOD
    fact_r*=r-i
    fact_r%=MOD  
  return (nPr*invmod(fact_r))%MOD

answer_tate=0
for d in range(1,N):
  answer_tate+=d*M**2*(N-d)
  answer_tate%=MOD
  
answer_yoko=0
for d in range(1,M):
  answer_yoko+=d*N**2*(M-d)
  answer_yoko%=MOD

comb=comb_mod(N*M-2,K-2)
print(comb*(answer_tate+answer_yoko)%MOD)

Measured memory_bytes: 3064
using namespace std;

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, j, n) for (int i = j; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define INF 1e+9+1
#define MAX_N 301
typedef long long ll;
typedef vector<int> vi;

int main()
{
    int n, m, l;
    cin >> n >> m >> l;
    vector<vi> dist(n, vi(n, INF));
    rep(i, n) dist[i][i] = 0;
    rep(i, m)
    {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        dist[a][b] = dist[b][a] = c;
    }
    //
    rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);
    vector<vi> dist2(n, vi(n, INF));
    rep(i, n) rep(j, n)
    {
        if (dist[i][j] <= l)
            dist2[i][j] = 1;
    }
    rep(k, n) rep(i, n) rep(j, n) chmin(dist2[i][j], dist2[i][k] + dist2[k][j]);
    int q;
    cin >> q;
    vi vs(q),vt(q);
    rep(qi, q){
        cin >> vs[qi] >> vt[qi];
    }
    rep(qi, q)
    {
        int s = vs[qi], t = vt[qi];
        --s;
        --t;
        int ans = dist2[s][t] - 1;
        if (dist2[s][t] == INF)
            ans = -1;
        cout << ans << endl;
    }
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define hell 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long 
#define pi 3.1415926536
using namespace std;
const ll N=1e5+5;
vector<ll> v;
void cal(ll a,ll b,ll n)
{
    queue<ll> q;
    q.push(n);
    while(!q.empty())
    {
        ll s=q.front();
        q.pop();
        if(s<=b&&s>=a&&s!=0)
        v.pb(s);
        if(s==0||s>b)
        continue;
        ll ld=s%10;
        ll p1=s*10+ld-1;
        ll p2=s*10+ld+1;
        ll p3=s*10+ld;
        if(ld==0)
        q.push(p2);
        else if(ld==9)
        q.push(p1);
        else
        {
            q.push(p1);
            q.push(p2);
        
        }
        q.push(p3);
    }
}
void solve()
{ll n,k,m,l,h,r,x,z,w,mini,maxi=INT_MAX,prev;
  cin>>k;
  cout<<v[k-1]<<endl;
}
  
int main()
{
  fast
  for(ll i=0;i<=9;i++)
  cal(1,3234566667,i);
  sort(v.begin(),v.end());
  //fact();
  //chk();
ll t=1;
//cin>>t;
//SieveOfEratosthenes();
//cout<<"ok";
while(t--)
{ //cout<<"ok";

solve();
 //cout<<ma<<endl;
}
return 0;}

Measured memory_bytes: 1636
#include<bits/stdc++.h>
using namespace std;
vector<long long>h;
long long mem[100001];
long long n,k;
long long dp(long long i)
{
    if(i==n-1)
        return 0;
    if(i>n-1)
        return 10000000000;
    if(mem[i]!=-1)
        return mem[i];
    mem[i]=10000000000;
    for(long long j=1;j<=k;j++)
    mem[i]=min(abs(h[i+j]-h[i])+dp(i+j),mem[i]);
    return mem[i];
}
int main()
{
    memset(mem,-1,sizeof(mem));
    long long i;
    cin>>n>>k;
    h.resize(n);
    for(i=0;i<n;i++)
        cin>>h[i];
    cout<<dp(0)<<endl;
    return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <queue>
#include <algorithm> // sort
#include <math.h>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll mod = 1000000007;
static const ll INF = 1000000000000000000LL;
                    //999999997000000003
                    //1000000000000000000

using namespace std;

int main(){
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin >> N;
    vector <int> a(N);
    REP(i,N)cin >> a[i];

    int res = 0;

    for(int i = 0; i < N - 1; ++i)
    {
        if(a[i] < a[i+1])++res;
    }

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3092
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if sum(A) < sum(B):
    print(-1)
    exit()
diff = [A[i]-B[i] for i in range(N)]
m = 0
cnt = 0
for d in diff:
    if d < 0:
        m += d
        cnt += 1
diff.sort(reverse = 1)
for d in diff:
    if m >= 0:
        break
    m += d
    cnt += 1  
print(cnt)


Measured memory_bytes: 19052
public class Main {

  private static void solve() {
    long n = nl();
    long a = nl();
    long b = nl();

    if ((b - a) % 2 == 0) {
      System.out.println((b - a) / 2);
    } else {
      long down = n - b;
      long up = a - 1;

      // down
      long a1 = a + down + 1;
      long b1 = n;

      // up
      long a2 = 1;
      long b2 = b - up - 1;
      System.out.println(Math.min((b2 - a2) / 2 + down + 1, (b1 - a1) / 2 + up + 1));
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22228
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int n;
string s;


long long mod(const long long &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
int mod(const int &a) {
	if (a >= 0)return a % 1000000007;
	return 1000000007 - (-a) % 1000000007;
}
int mem[3002][3001];//i番目までの文字列で最後がj以下のもの
int ans;

int main() {
	cin >> n >> s;
	mem[0][1] = 1;
	for (int i = 0; i < n-1; i++)
	{
		for (int j = 1; j <= i+2; j++)
		{
			
			if (s[i] == '<') {
				mem[i + 1][j] = mod(mem[i + 1][j-1] + mem[i][j - 1]);
			}
			else {
				mem[i + 1][j] = mod(mem[i + 1][j - 1] + mem[i][i + 1] - mem[i][j - 1]);
			}
		}
	}
	cout << mem[n-1][n] << endl;

}

Measured memory_bytes: 34176
import java.math.BigDecimal;
import java.util.Scanner;

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

        double L = scanner.nextInt();

        System.out.println(BigDecimal.valueOf(Math.pow(L / 3.0, 3)).toPlainString());
    }
}


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

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  vector<int64_t>dataA(N+1);
  vector<int64_t>dataB(M+1);
  dataA.at(0)=0;
  for(int i=1;i<N+1;i++){
    int x;
    cin >> x;
    dataA.at(i)=dataA.at(i-1)+x;
  }
  dataB.at(0)=0;
  for(int i=1;i<M+1;i++){
    int x;
    cin >> x;
    dataB.at(i)=dataB.at(i-1)+x;
  }
  int ans=0;
  int basyo=M;
  for(int i=0;i<N+1;i++){
    if(dataA.at(i)>K) break;
    while(dataA.at(i)+dataB.at(basyo)>K){
      basyo--;
    }
    ans=max(i+basyo,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 6360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define stop exit(0)
#define dd double
#define po pop_back
#define pb push_back
#define ub upper_bound
#define lb lower_bound
int main(){
    vector <long long> v;
    ll a,b,c=0,d=0,e=0,f=0,g=0,i,j,k=1,l=0,r=1,n,m[300001],z[400001],h[600001],p[600001];
    string s,t,x,y[1001];
    dd q,u,w;
    cin>>a>>b;
    if(b>=a){
        cout<<"unsafe";
    }
    else{
        cout<<"safe";
    }
}

Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    vi v(3);
    rep(i,3) {
        cin>>v[i];
    }
    sort(all(v));
    cout<<v[2]-v[0]<<endl;
}

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

using namespace std;

int maximum (vector<int> v) {

    int max_num = v[0];
    for (int i = 0; i < v.size(); i++) {
        max_num = max(v[i], max_num);
    }

    return max_num;
}

int main() {

    vector<int> v(3);
    for (int i = 0; i < v.size(); i++) {
        cin >> v[i];
    }

    int max_num = maximum(v);
    int diff = 0;
    for (int i = 0; i < v.size(); i++) {
        diff += (max_num - v[i]);
    }
    
    cout << ( (diff % 2 == 0)? (diff / 2) : ((diff + 3) / 2) ) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

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

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    if ( a[n-1] < k ) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    ll gcd_num = a[0];
    for ( int i = 1; i < n; ++i ) {
        gcd_num = gcd(a[i], gcd_num);
    }
    if ( k % gcd_num == 0 ) {
        cout << "POSSIBLE" << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=1605;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}
int N;

struct edge{
	int to,cap,rev;
	edge(int _,int __,int ___):to(_),cap(__),rev(___){}
};

vector<edge> G[maxn];

void add_edge(int u,int v,int c){
	G[u].pb(edge(v,c,SZ(G[v])));
	G[v].pb(edge(u,0,SZ(G[u])-1));
}

int lvl[maxn];
int iter[maxn];

vector<int> q;
int pt;
void bfs(int u){
	REP(i,N) lvl[i]=-1;
	lvl[u]=0;
	q.clear();
	q.pb(u);
	pt=0;
	while(pt<SZ(q)){
		int cur=q[pt++];
		for(edge &e:G[cur]){
			if(lvl[e.to]!=-1||e.cap<=0) continue;
			lvl[e.to]=lvl[cur]+1;
			q.pb(e.to);
		}	}
}
int dfs(int s,int t,int f){
	if(s==t) return f;
	for(int &i=iter[s];i<SZ(G[s]);i++){
		edge &e=G[s][i];
		if(e.cap>0&&lvl[e.to]>lvl[s]){
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}

int dinic(int s,int t){
	int flow=0;
	while(1){
		bfs(s);
		REP(i,N) iter[i]=0;
		if(lvl[t]==-1) return flow;
		int f;
		while((f=dfs(s,t,INF))>0) flow+=f;
	}
}

int n;
int a[maxn];
vector<pii> v;
int32_t main()
{
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) v.pb(MP(a[i],i));
	N=3*n+3;
	v.pb(MP(0,-1));
	v.pb(MP(n*n+1,-1));
	sort(ALL(v));
	REP(i,SZ(v)-1){
		add_edge(i,n*3+2,v[i+1].F-v[i].F-1);
	}
	for(int i=1;i<SZ(v)-1;i++){
		add_edge(3*n+1,n+i,v[i].S);
		for(int j=0;j<i;j++) add_edge(n+i,j,INF);
		add_edge(3*n+1,n+n+i,n-1-v[i].S);
		for(int j=i;j<=n;j++) add_edge(n+n+i,j,INF);
	}
	if(dinic(3*n+1,3*n+2)!=n*n-n){
		cout<<"No\n";
		return 0;
	}
	cout<<"Yes\n";
	for(int i=0;i<=n;i++){
		for(edge &e:G[i]){
			if(n<e.to&&e.to<=3*n){
				int tmp=e.to;
				while(tmp>n) tmp-=n;
				REP(I,e.cap) cout<<v[tmp].S+1<<' ';
			}
		}
		//cout<<'\n';
		if(i<n){
			cout<<v[i+1].S+1<<' ';
		}
	}
	cout<<'\n';
}




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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;

long long comb(int n, int r) {
  if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
  long long ans = 1;

  for(int i = 1; i <= r; i++) {
    ans *= n - r + i;
    ans /= i;
  }

  return ans;
}


int main(){
  ll n;
  string s;
  cin >> n >> s;
  map<char, ll> mp;
  for(char c : s){
    if(mp[c] == 0) mp[c] = 1;
    mp[c]++;
  }
  ll res = 1;
  for(auto a : mp){
    res *= a.second;
    res %= MOD;
  }

  cout << res-1 << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{


    int a,b,c; cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    ll a,b,k;
    cin >> a >> b >> k;
    if(a > k)cout << a-k << " " << b << endl;
    else if(a + b > k) cout << 0 << " " << a+b-k << endl;
    else cout << 0 << " " << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
def resolve():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        divisors.sort(reverse=True)
        return divisors

    n,m=map(int,input().split())
    c = make_divisors(m)
    for i in c:
        if n>m//i:
            continue
        else:
            print(i)
            break
        
if __name__ == '__main__':
    resolve()

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<int> pq;

int main()
{
    int n, m;
    cin >> n >> m;
    pq q;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        q.push(a);
    }

    for (int i = 0; i < m; i++)
    {
        int mx = q.top();
        q.pop();
        mx /= 2;
        q.push(mx);
    }

    long sum = 0;
    for (int i = 0; i < n; i++)
    {
        int mx = q.top();
        q.pop();
        sum += mx;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 892
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;
int n, k;     // n:荷物の数、k:トラックの数
llong T[MAX]; // T[i]:i番目の重さ

// 最大積載量Pのk台のトラックで何個の荷物を積めるか？
int check(llong P)
{
  int i = 0;
  for (int j = 0; j < k; j++)
  {
    llong s = 0;
    while (s + T[i] <= P)
    {
      s += T[i];
      i++;
      if (i == n)
        return n;
    }
  }
  return i;
}

int solve()
{
  llong left = 0;
  llong right = 100000 * 10000;
  llong mid;
  while (right - left > 1)
  {
    mid = (left + right) / 2;
    int v = check(mid);
    if (v >= n)
      right = mid;
    else
      left = mid;
  }
  return right;
}

int main()
{
  cin >> n >> k;
  for (int i = 0; i < n; i++)
    cin >> T[i];
  llong ans = solve();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3860
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
char s[200][200];
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m)){
        for(int i = 1; i <= n; i++)
            scanf("%s",&s[i]);
        for(int i = 1; i <= m+2; i++)
            printf("#");
        printf("\n");
        for(int i = 1; i <= n; i++){
            printf("#");
            printf("%s",s[i]);
            printf("#\n");
        }
        for(int i = 1; i <= m+2; i++)
            printf("#");
            printf("\n");
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, k;
    ll z = 0;
    cin >> n >> k;
    if (!k) {
        cout << (ll)n * n;
        return 0;
    }
    for (int i = k; i <= n; i++) {
        int y = -1;
        for (int j = 0; j * i <= n; j++) {
            if (j * i + k <= n) y += k;
            else y += n - j * i + 1;
        }
        z += n - y;
    }
    cout << z;
}


Measured memory_bytes: 256
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
import itertools
a = itertools.permutations(range(1,n+1))
count = 0
for i in a:
    if i == p:
        p_index = count
    if i == q:
        q_index = count
    count += 1
print(abs(p_index-q_index))

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main(void) {

	int a, b;

	cin >> a >> b;

	int k = abs(a - b);
	int n = 16 - k;
	int l = max(a, b);

	if (l<=n/2)cout << "Yay!\n";
	else cout << ":(\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<cstdlib>

using namespace std;

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


int main(){
    int x;
    cin >> x;
    int ans = (x / 500) * 1000;
    ans += ((x % 500) / 5) * 5;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A;
	int i;
	rep(i, N) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	
	make_heap(A.begin(), A.end());
	rep(i, M) {
		pop_heap(A.begin(), A.end());
		int tmp = *(A.end()-1);
		tmp /= 2;
		A.pop_back();
		A.push_back(tmp);
		push_heap(A.begin(), A.end());
	
	}
	long long ans=0;
	rep(i, N) {
		ans += A[i];
	}
	cout << ans;
	return 0;
}



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

int n;
vector<int> p_factor;

void pfd(void){
	int bk = n;
	for(int i = 2; bk != 1; i++){
		if(bk % i == 0){
			p_factor.push_back(i);
			while(bk % i == 0) bk /= i;
		}
	}
}

double epf(void){
	double ret = (double)n;
	for(int i = 0; i < p_factor.size(); i++){
		ret *= 1.0 * (p_factor[i] - 1) / p_factor[i];
	}
	return ret;
}

int main(void){
	cin >> n;
	pfd();
	cout << (int)epf() << endl;
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define inf 1e9
const int mxN = 1e6;
ll a[mxN + 10], b[mxN + 1];
int main()
{
	int n;
	cin >> n;
	vector<ll> h;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		h.push_back(x);
	}
	for (int i = 0; i < n - 1; i++) {
		if (h[i - 1] < h[i] or (i == 0)) {
			h[i]--;
		}
	}
	int flag = 0;
	for (int i = 0; i < n - 1; i++) {
		if (h[i] > h[i + 1]) {
			cout << "No"<<endl;
			flag = 1;
			break;
		}
	}
	if (flag == 0) {
		cout << "Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1400
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include<random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#include "atcoder/all"
using namespace atcoder;
using namespace std;
typedef long long ll;
#define pb push_back
#define rep(i, n) for(int i=0;i<(n);i++)
#define P pair<int,int>
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); }

namespace ori{
    template <typename T>
    void erase(std::vector<T> &v)
    {
        std::sort(v.begin(),v.end());
        v.erase(std::unique(v.begin(),v.end()),v.end());
        return;
    }

    template<typename T>
    int find_index(std::vector<T> v, T find, string key)
    {
        std::sort(v.begin(),v.end());
        if(key=="left")
        {
            return (std::distance(v.begin(),lower_bound(v.begin(),v.end(),find)));
        }
        if(key=="right")
        {
            return (std::distance(v.begin(),upper_bound(v.begin(),v.end(),find))-1);
        }
        else
        {
            return -1;
        }
    }
}

const int x8[] = {0, 0, 1, -1, -1, 1, -1, 1};
const int y8[] = {-1, 1, 0, 0, -1, -1, 1, 1};
const int x4[] = {1, -1, 0, 0};
const int y4[] = {0, 0, -1, 1};
const int MOD = 1000000007;

void task() {
    int n,m; cin >> n >> m;
    dsu d(n);
    rep(i,m){
        int a,b; cin >> a >> b;
        --a; --b;
        d.merge(a,b);
    }
    map<int,int> mp;
    rep(i,n){
        mp[d.leader(i)]++;
    }
    cout << mp.size() -1 << endl;
}




int main() {
    //ios::sync_with_stdio(false); cin.tie(nullptr);
    task();
    return 0;
}

Measured memory_bytes: 7544
import fractions
from functools import reduce
 
  
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm, numbers)
 
N = int(input())
 
t = []
for _ in range(N):
  t.append(int(input()))
 
print(lcm_list(t))

Measured memory_bytes: 5048
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd
from itertools import accumulate
from functools import reduce


def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n = int(sys.stdin.readline())
    h = list(map(int, sys.stdin.readline().split()))
    ans=h[0]
    for i in range(1,n):
        if h[i]>h[i-1]:
            ans +=h[i]-h[i-1]
    print(ans)


Measured memory_bytes: 5200
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;

  vector<long long> x,y;

  double noudo = 0;
  ll ans_ws = 100 * a; // 水無しはだめなので…　満たせばいいので、100 * bでもいい
  ll ans_s = 0;

  for(int i = 0;i < 30;i++)
  for(int j = 0;j < 30;j++)
  {
    ll w = (i * a + j * b) * 100;
    for(int k = 0;k < f - w;k++)
    for(int l = 0;l < f - w - k;l++)
    {
      ll w = (i * a + j * b) * 100;
      ll s = k * c + l * d;
      ll sw = w + s;
      if(!(0 < sw && sw <= f))continue;
      if(w == 0) continue;  // 水なし
      if(s > w / 100 * e) continue; // 溶け残り
      double buf = (double)s / sw;
      if(noudo < buf)
      {
        noudo = buf;
        ans_ws = sw;
        ans_s = s;
      }
    }
  }
  cout << ans_ws << " " << ans_s << endl;
  

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
N = int(input())
ana = {}
answer = 0

for i in range(N):
    s = sorted(input())
    new_str = ''.join(s)
    flag = 0

    if new_str in ana.keys():
        ana[new_str] += 1
        answer += ana[new_str]
        flag = 1

    if flag == 0:
        ana[new_str] = 0

print(answer)

Measured memory_bytes: 17852
import java.util.Scanner;

public class Main {

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

        int m1 = sc.nextInt();
        int d1 = sc.nextInt();
        int m2 = sc.nextInt();
        int d2 = sc.nextInt();

        System.out.println((m2 - m1 + 12) % 12);
    }
}

Measured memory_bytes: 23892
#include <iostream>

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, s, n) for (int i = s; i <= n; i++)

typedef long long ll;

ll gcd(ll a, ll b) {
	if (a < b) return gcd(b, a);
	ll r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}

int main()
{
	ll A, B;
	ll gcdAB;
	int count = 1;

	cin >> A >> B;

	gcdAB = gcd(A, B);

	for (ll i = 2; i * i <= gcdAB; i++) {
		if (gcdAB % i == 0) {
			count++;
			while (gcdAB % i == 0) gcdAB /= i;
		}
	}

	if (gcdAB > 1) count++;

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0]-0;
  var colors=[];
  var temp;
  var min,max,mid;
  for(var i=1;i<input.length;i++){
    temp=input[i]-0;
    if(colors.length===0){
      colors.push(temp);
      continue;
    }
    if(temp<=colors[0]){
      colors.unshift(temp);
      continue;
    }
    if(temp>colors[colors.length-1]){
      colors[colors.length-1]=temp;
      continue;
    }
    min=0;
    max=colors.length-1;
    while(max-min>1){
      mid=Math.floor((max+min)/2);
      if(colors[mid]<temp){
        min=mid;
      }else{
        max=mid;
      }
    }
    colors[min]=temp;
  }
  console.log(colors.length);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 41588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;  
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  int64_t M = 0, M2 = 0;
  int count = 0;
  for (int i = 0; i < N - 1; i++) {
    if (A.at(i) == A.at(i + 1)) {
      M2 = M;
      M = A.at(i);
      A.at(i + 1) = 1000000001;
      count++;
    }
    if (count == 2) {
      break;
    }
  }
  cout << M2 * M << endl;
}

Measured memory_bytes: 3916
def main():
    N = int(input())
    ans = []
    for i in range(N):
        s = input()
        if s[0] in ["M", "A", "R", "C", "H"]:
            ans.append(s[0])
    from collections import Counter
    c = Counter(ans)
    ret = 0
    from itertools import combinations
    for com in combinations(c.values(), 3):
        ret += com[0]*com[1]*com[2]
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 53976
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]

if len(set(a)) == 1:
    p = int(n/2)
else:
    b0 = set(a[::2])
    if len(b0)==1:
        q0 = 0
        mark00 = a[0]
        count00, count01 = int(n/2), 0
    else:
        c = Counter(a[::2])
        q0 =  int(n/2) - c.most_common(1)[0][1]
        mark00, mark01 = c.most_common(2)[0][0], c.most_common(2)[1][0]
        count00, count01 = c.most_common(2)[0][1], c.most_common(2)[1][1]

    b1 = set(a[1::2])
    if len(b1)==1:
        q1 = 0
        mark10 = a[1]
        count10, count11 = int(n/2), 0
    else:
        c = Counter(a[1::2])
        q1 =  int(n/2) - c.most_common(1)[0][1]
        mark10, mark11 = c.most_common(2)[0][0], c.most_common(2)[1][0]
        count10, count11 = c.most_common(2)[0][1], c.most_common(2)[1][1]
    if mark00==mark10:
        if count00+count01>count10+count11:
            p = n - (count00+count01)
        else:
            p = n - (count10+count11)
    else:
        p = n - (count00 + count10)

print(p)



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

int main(){
  int n, res = 0;
  cin >> n;
  string s, t;
  cin >> s >> t;
  for(int i = 0; i <= n; i++){
    if(s.substr(n - i, i) == t.substr(0, i)) res = i;
  }
  cout << 2 * n  - res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <climits>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <deque>
#include <vector>
#include <string>
#include <bitset>
#define y0 qvya13579
#define y1 qvyb24680
#define j0 qvja13579
#define j1 qvjb24680
#define next qvne13579xt
#define prev qvpr13579ev
#define INF 1000000007
#define PI acos(-1.0)
#define endl "\n"
#define IOS cin.tie(0);ios::sync_with_stdio(false)
#define MP_ make_pair
#define PB_ push_back
#define FIR first
#define SEC second
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP_R(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define SIZ(x) ((int)(x).size())
typedef long long int lli;
using namespace std;
int ctoi(char c){if(c>='0' and c<='9'){return (int)(c-'0');}return -1;}



int main()
{
  //IOS; /* making cin faster */
  int A,B;

  cin >> A >> B;

  if( ( A % 2 ) * ( B % 2 ) )
    {
      cout << "Yes" << endl;
      
    }
  else
    {
      cout << "No" << endl;
      
    }
  

}


Measured memory_bytes: 256