akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   /* string in;
    cin>>in;
    v32 ans;
    int iter=0;
    unordered_map<string, int> umap;
    forn(i,in.size()){
    	string buffer(1,in[i]);
    	string curr =buffer;
    	while(umap.find(buffer)!=umap.end()){
    		curr=buffer;
    		buffer += in[++i];
    		
    	}
       	umap[buffer]= ++iter;
    	ans.pb(umap[curr]);
    }
    forn(i,ans.size()){
    	cout<<ans[i]<<" ";
    }
    cout<<ln;*/
    //LZW encoder
     cin>>n;
     m= n/100;
     if(n > 111*m){
     	cout<<111*(m+1);
     }else{
     	cout<<111*m;
     }
}

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

int main()
{
    int x;
    cin >> x;
    if((x%10)==7||((x/10)%10)==7||(x/100)==7)
        cout << "Yes" <<endl;
    else
        cout << "No" <<endl;
    
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,a,b,c,d;
    scanf("%d%d%d%d%d",&n,&a,&b,&c,&d);
    char s[n+5];
    scanf("%s",s);
    s[n]='#';
    s[n+1]='#';
    s[a-1]='A';
    s[b-1]='B';
    bool ac=false,bd=false,change=false;
    while(1){
        change=false;
        if (s[a]=='.' && ac==false){
            s[a-1]='.';
            a++;
            s[a-1]='A';
            change=true;
        } else if (s[a+1]=='.' && ac==false){
            s[a-1]='.';
            a+=2;
            s[a-1]='A';
            change=true;
        } else if (s[b]=='.' && bd==false){
            s[b-1]='.';
            b++;
            s[b-1]='B';
            change=true;
        } else if (s[b+1]=='.' && bd==false){
            s[b-1]='.';
            b+=2;
            s[b-1]='B';
            change=true;
            
        }
        if (a==c){
            ac=true;
        }
        if (b==d){
            bd=true;
        }
        if (ac==true && bd==true){
            printf("Yes\n");
            break;
        }
        if (change==false){
            printf("No\n");
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
#  = int(input())
a, b, c  = map(int, input().split())
#  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
# c = collections.Counter()

print(max(c - (a - b), 0))


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

int main() {
	string s;
	cin >> s;
	int counter=count(s.begin(), s.end(), 'o');
	cout << 700+counter*100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF (1<<26)
int n,m,size;
string str,a,b;
map<string,int> mp;
int G[201][201];
int g[201][201];
int T[201][201];


void init(){
  mp.clear();
  size=0;
  for(int i=1;i<=200;i++){
    for(int j=1;j<=200;j++){
      G[i][j]=(i==j?0:INF);
      T[i][j]=(i==j?0:INF);
      g[i][j]=0;
    }
  }
}

int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    init();

    for(int i=0;i<n;i++){
      cin>>str;
      for(int j=0;j<(int)str.size();j++){
        if(str[j]=='-'){
          a=str.substr(0,j);
          b=str.substr(j+1);
          break;
        }
      }
      if(mp[a]==0)mp[a]=++size;
      if(mp[b]==0)mp[b]=++size;
      G[mp[a]][mp[b]]=1;
      G[mp[b]][mp[a]]=1;
      T[mp[a]][mp[b]]=1;
      g[mp[a]][mp[b]]=1;
    }
    
    
    for(int i=1;i<=size;i++){
      for(int j=1;j<=size;j++){
        if(i==j)continue;

        bool flg=false;

        for(int k=1;k<=size;k++){
          if((g[i][k]||g[k][i])&&(g[j][k]||g[k][j])){
            flg=true;
          }
        }
              
        for(int k=1;k<=size;k++){
          if(g[k][i]&&g[j][k])flg=false;
          if(g[i][k]&&g[k][j])flg=false;
        }
        if(flg){
          T[i][j]=1;
        }
      }
    }
    
    for(int k=1;k<=size;k++){
      for(int i=1;i<=size;i++){
        for(int j=1;j<=size;j++){
          G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
          T[i][j]=min(T[i][j],T[i][k]+T[k][j]);
        }
      }
    }

    cout<<size<<endl;
    cin>>m;
    for(int i=0;i<m;i++){
      cin>>str;
      for(int j=0;j<(int)str.size();j++){
        if(str[j]=='-'){
          a=str.substr(0,j);
          b=str.substr(j+1);
          break;
        }
      }
      int A=mp[a],B=mp[b];
      
      if(G[A][B]%2==0&&G[A][B]!=INF){
        cout<<"NO"<<endl;
      }else if(T[A][B]==INF){
        cout<<"NO"<<endl;
      }else{
        cout<<"YES"<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1712
#include<iostream>
using namespace std;
long sumt=1,suma=1;
main()
{
	int n;cin>>n;
	for(int i=0;i<n;i++)
	{
		long t,a;cin>>t>>a;
		long b=max((sumt+t-1)/t,(suma+a-1)/a);
		sumt=t*b;
		suma=a*b;
	}
	cout<<sumt+suma<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 300005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define pii pair<int,int>
const int mod = 1e9 + 7;
set<int>st;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    st.insert(0);
    st.insert(n+1);
    vector<pair<int,int>>v;
    f1(n) {
        int x;
        cin >> x;
        v.pb({x,i});
    }
    sort(all(v));
    ll ans = 0;
    for (auto &i : v) {
        int x = *st.lower_bound(i.S);
        int y = *prev(st.lower_bound(i.S));
        ans += (ll)(x - i.S) * (i.S - y) * i.F;
        st.insert(i.S);
    }
    cout << ans << '\n';
}


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

typedef long long ll;
#define PB push_back

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	multiset<map<char, int>> fs;
	set<map<char, int>> unq;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		map<char, int> f;
		for (auto j: s) f[j]++;
		fs.insert(f);
		unq.insert(f);
	}
	ll ans = 0;
	for (auto i : unq) {
		ll c = fs.count(i);
		ans += c * (c - 1) / 2;
	}
	cout << ans << "\n";
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {\
return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;
using ll = int64_t;

const ll INF = 1000000000000001;

// 10進数の各桁の和
int getSum(ll N)
{
    int sm = 0;
    while (0 < N)
    {
        ll tmp = N % 10;
        sm += (int)tmp;
        N /= 10;
    }
    return sm;
}

// 末尾 9 を試す
// 123 なら 129 と 199
// S / S(n) の 商(整数) が同じなら
// 大きい数字を sunuke数 とする
ll getAll9(ll N)
{
    // 最小
    // n
    ll num = INF;

    // 最小
    // S / S(n)
    ll val = INF;

    ll tmp = N;
    ll digits = 0;
    while (0 < tmp)
    {
        digits++;
        tmp /= 10;
    }

    // 10進数での桁数
    digits--;

    tmp = N;
    int t = 0;
    ll all9 = 0;
    while (0 < tmp)
    {
        // 123 → 12
        tmp /= 10;

        t++;
        all9 = all9 * 10 + 9;

        // 最上位桁 そのまま
        // 0 ならば 最上位
        if (0 < tmp)
        {
            // 12 → 120 → 129
            ll now = tmp * pow(10, t) + all9;
            ll cal = now / (ll)getSum(now);

            if (cal <= val)
            {
                val = cal;
                num = now;
            }
        }
    }
    return num;
}

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

    ll N = 1;
    REP(i, K)
    {
        ll self = N;
        ll cal = self / (ll)getSum(N);

        ll a9 = getAll9(N);
        ll cal9 = a9 / (ll)getSum(a9);

        ll sunuke = self;
        if (cal9 < cal)
        {
            sunuke = a9;
            N = a9;
        }

        cout << sunuke << endl;

        N = sunuke;
        N++;
    }

    return 0;
}


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

#define go first
#define ct second

int cost[100 + 10] , cost_ps[100 + 10];
int n,vf,k,v,c;

int v_k[100];

vector< pair<int, int> > went[100];

pair<int, int> p_tmp;

int  check_go(int st)
{
	int i;
	int ret=0;

	for (i = 0; i < v_k[st]; i++)
	{
		if (cost_ps[went[st][i].go] > cost[st] + went[st][i].ct || cost_ps[went[st][i].go] == -1)
		{
			cost_ps[went[st][i].go] = cost[st] + went[st][i].ct;
		}
	}

	for (i = 1; i < n; i++)
	{
		//cout << "Z" << i << endl;
		if ( (cost_ps[ret] > cost_ps[i] && cost[i]==-1 || cost[ret] != -1 ) && cost_ps[i]!=-1 )
		{
			//cout << "B" << cost[ret] << endl;
			ret = i;
			//printf("ret=%d\n", ret);
		}
	}
	//cout << cost_ps[ret] << endl;

	cost[ret] = cost_ps[ret];
	//cout << "A" << cost[ret] << endl;

	return ret;

}

int main()
{
	int i,j;
	int st_num=0;

	cin >> n;

	for (i = 0; i < n; i++)
	{
		cost[i] = cost_ps[i] = -1;

		cin >> vf ;
		cin >> v_k[vf];
		for (j = 0; j < v_k[vf] ; j++)
		{
			cin >> p_tmp.go >> p_tmp.ct;

			went[vf].push_back(p_tmp);
		}
	}

	cost[0] = cost_ps[0] = 0;

	for (i = 1; i < n; i++)
	{
		st_num = check_go(st_num);
	}

	for (i = 0; i < n; i++)
	{
		cout << i << " " << cost_ps[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
const int mod=998244353;
const int MAXN=1e5+50;
char a[1000],b[1000];
int main()
{
    //freopen("in.txt","r",stdin);
   int n;
   while(scanf("%d",&n)!=-1){
       scanf("%s%s",a,b);
       for(int i=0;i<n;i++){
           printf("%c%c",a[i],b[i]);
       }
       cout<<endl;
   }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a[]={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};
  cin>>n;
  cout<<a[n-1]<<endl;}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF = 10**20
def main():
    N=ii()

    ans = 0
    for i in range(1,N+1):
        m = N//i
        sum_of_m = m*(m+1)//2
        ans += i * sum_of_m
        
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 63044
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const ll LINF = (ll)1 << 60;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int w;
  cin>>w;
  cout<<32*w<<'\n';
  return(0);
}


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

typedef long long ll;
typedef long double ld;
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h.at(i);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int n = N;
        while (h.at(i) != 0) {
            int m = inf;
            for (int j = i; j < N; j++) {
                if (h.at(j) == 0) {
                    n = j;
                    break;
                }
                m = min(m, h.at(j));
            }
            for (int k = i; k < n; k++) h.at(k) -= m;
            ans += m;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long i,j,t,a,b,n,temp;
    t=1;
    // cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        n=s.length();
        while(1)
        {
            s=s.substr(0,n-2);
            n-=2;
            if(s.substr(0,n/2)==s.substr(n/2,n/2))
            break;
            if(n<=0)break;
        }
       cout<<n;
        
        
    }
}

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

int main() {
    long long n, k;
    cin >> n >> k;
    
    vector<pair<int, int>> v(n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        v.at(i) = make_pair(a, b);
    }

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

    for (int i = 0; i < n; i++) {
        k -= v.at(i).second;
        if (k <= 0) {
            cout << v.at(i).first << endl;
            return 0;
        }
    }
}   

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let mut s: Vec<u8> = scan!(sc; String)
    .chars()
    .map(|c| c as u8)
    .collect();
  s.sort();

  let c = {
    let mut s = s.clone();
    s.dedup();
    if s.len() == 2 { Some(s[0]) } else { None }
  };
  if let Some(c) = c {
    if s.iter().filter(|&&x| x == c).count() == 2 {
      println!("Yes");
      return;
    }
  }
  println!("No");
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

vector<int> v[200000];
int visited[200000] = {0};
int ans[200000] = {0};

void dfs(int x) {
  visited[x] += 1;
  for(int i = 0; i < v[x].size(); i++) {
    int nx = v[x][i];
    if(visited[nx] == 0) {
      ans[nx] += ans[x];
      dfs(nx);
    }
  }
}

int main() {
  int N, Q;
  cin >> N >> Q;
  rep(i, N-1) {
    int x, y;
    cin >> x >> y;
    x--;y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  rep(i, Q) {
    int s, t;
    cin >> s >> t;
    s--;
    ans[s] += t;
  }
  dfs(0);
  rep(i, N) {
    cout << ans[i];
    if(i != N-1) cout << " ";
    else cout << endl;
  }
  return 0;
}

Measured memory_bytes: 25512
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int N = 1e6+3;
#define LL long long
const LL mod = 998244353;

struct node
{
	int n,m;
	int id;
	int a,b;
}a[N];


bool cmp(node a,node b)
{
	if(a.n!=b.n){
		return a.n<b.n;
	}
	return a.m<b.m;
}
bool cmp1(node a,node b)
{
	return a.id<b.id;
}

int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int k,f;
		scanf("%d%d",&k,&f);
		a[i].n=k;
		a[i].m=f;
		a[i].id=i;
	}
	sort(a+1,a+1+m,cmp);
	int p;
	for(int i=1;i<=m;i++){
		if(a[i].n==a[i-1].n){
			p++;
		}else{
			p=1;
		}
		a[i].a=a[i].n;
		a[i].b=p;
	}
	sort(a+1,a+1+m,cmp1);
	for(int i=1;i<=m;i++)
		printf("%06d%06d\n",a[i].a,a[i].b);

	return 0;
}


Measured memory_bytes: 3456
d = {}
for _ in range(int(input())):
    op, key, x = (input().split() + [''])[:3]
    if op == '0':
        d[key] = x
    elif op == '1':
        if d.get(key) == None:
            print(0)
        else:
            print(d[key])
    elif op == '2':
        if d.get(key) != None:
            del d[key]


Measured memory_bytes: 41636
def solve(v_list, c_list):
    ans = 0
    for key, value in enumerate(v_list):
        if value > c_list[key]:
            ans += value - c_list[key]
        continue
    return ans


def main():
    n = int(input())
    v_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))

    ans = solve(v_list, c_list)
    print(ans)


main()


Measured memory_bytes: 2940
/*
Writer: SPD_9X2
https://atcoder.jp/contests/arc081/tasks/arc081_d

長方形にできる必要十分条件は、
内側にある四つ角の周り全てに関して、周りにある黒が偶数個
→そのような条件を満たす四つ角グリッドを考えると最大長方形になる

幅1の長方形に関しては全て作れるので、ans初期値はmax(H,W)
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrep(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
using ll = long long;
const ll mod = 1000000007;
const ll half = 500000004;

int LRIH(vector<int>& lis){

    vector<vector<int>> stk(0);

    int ans = 0;
    int N = lis.size();

    rep(i,0,N){

        if (stk.size() == 0){
            stk.push_back({lis[i],i});
        }else if (stk[stk.size()-1][0] < lis[i]){
            stk.push_back({lis[i],i});
        }else if (stk[stk.size()-1][0] > lis[i]){

            int lastpos = -1;

            while ( (stk.size()>0) && (stk[stk.size()-1][0] > lis[i])){

                int nh = stk[stk.size()-1][0];
                int np = stk[stk.size()-1][1];
                lastpos = np;
                stk.pop_back();

                ans = max(ans , (nh+1)*(i-np+1));
            }

            stk.push_back({lis[i] , lastpos});
        }
    }

    return ans;
}

int main(){

    int H,W;
    cin >> H >> W;

    vector<vector<char>> S(H,vector<char> (W));
    rep(i,0,H){
        rep(j,0,W){
            cin >> S[i][j];
        }
    }

    vector<vector<int>> lis(H-1,vector<int> (W-1,0));

    rep(i,0,H-1){
        rep(j,0,W-1){
            if (S[i][j] == '#') lis[i][j] += 1;
            if (S[i+1][j] == '#') lis[i][j] += 1;
            if (S[i][j+1] == '#') lis[i][j] += 1;
            if (S[i+1][j+1] == '#') lis[i][j] += 1;
            lis[i][j] %= 2;
        }
    }

    vector<vector<int>> hist(H-1,vector<int> (W,0));

    rep(i,0,H-1){
        rep(j,0,W-1){

            if (lis[i][j] == 0){
                if (i==0){
                    hist[i][j] = 1;
                }else{
                    hist[i][j] = hist[i-1][j] + 1;
                }
            }

        }
    }

    int ans = max(H,W);
    rep(i,0,H-1){
        ans = max(ans , LRIH(hist[i]));
    }

    cout << ans << endl;
}

Measured memory_bytes: 35712
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
class Grid
{
private:
  int h,w;
  vector<vector<char>> c;
  vector<vector<int>> d;
  vector<int> dx={1,0,-1,0};
  vector<int> dy={0,1,0,-1};  
public:  
  Grid(int _h,int _w,vector<vector<char>> _c):h(_h),w(_w),c(_c){}

  void bfs(int sx,int sy)
  {
    d.assign(h,vector<int>(w,-1));
    queue<pair<int,int>> q;
    d[sx][sy] = 0;
    q.push({sx,sy});
    while(!q.empty()){
      int x = q.front().first;
      int y = q.front().second;
      q.pop();
      rep(i,4){
	int nx=x+dx[i],ny=y+dy[i];
	if(nx>=0&&nx<h&&ny>=0&&ny<w){
	  if(c[nx][ny]!='#'&&d[nx][ny]<0){
	    d[nx][ny] = d[x][y]+1;
	    q.push({nx,ny});
	  }
	}
      }
    }
  }

  void solve(){
    bfs(0,0);
    int b=1;
    rep(i,h) rep(j,w){
      if(c[i][j]=='#') b++;
    }
    if(d[h-1][w-1]<0) cout << -1 << "\n";
    else cout << h*w-b-d[h-1][w-1] << "\n";
  }

  void show(){
    rep(i,h){
      rep(j,w) cout << d[i][j] << " ";
      cout  << "\n";
    }
  }
  
  
};

int main()
{
  int h,w;
  cin >> h >> w;
  vector<vector<char>> c(h,vector<char>(w));
  rep(i,h) rep(j,w) cin >> c[i][j];
  Grid gr(h,w,c);
  gr.solve();
  return 0;
}


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

using namespace std;

const int N = 1e5 + 3;

long long h[N], dp[N];                  

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    for (int i = 2; i <= n; ++i) {
        dp[i] = dp[i-1] + abs(h[i]-h[i-1]);
        for (int j = max(1, i - k); j < i; j++)
            dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
inf = 1000
inf5 = 10**10
n, m, l = map(int, input().split())
graph = [[inf5] * (n+1) for _ in range(n+1)]
for _ in range(m):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][a] = c

inf = 1000


def warshall_floyd(d):
    for k in range(1, n+1):
        for i in range(1, n+1):
            for j in range(1, n+1):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])


warshall_floyd(graph)

ans = [[inf] * (n+1) for _ in range(n+1)]
for i in range(1, n+1):
    for j in range(1, n+1):
        if graph[i][j] <= l:
            ans[i][j] = 1

warshall_floyd(ans)
q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    if ans[s][t] == inf:
        print(-1)
        continue
    print(ans[s][t] - 1)




Measured memory_bytes: 79124
fun main(args: Array<String>) {
  val n = readLine()!!.toInt()
  val x1s = readLine()!!.split(" ").map(String::toInt)
  val x2s = readLine()!!.split(" ").map(String::toInt)
  val ans = (1..n).map { x1s.subList(0, it).sum() + x2s.subList(it - 1, n).sum() }.max()
  println(ans)
}


Measured memory_bytes: 38000
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int main(){
    int n, z, w;
    cin >> n >> z >> w;
    vector<ll> X(n + 1), Y(n + 1), a(n);
    rep(i, n){
        cin >> a[n - i - 1];
    }

    X[0] = abs(w - a[0]);
    X[1] = abs(a[1] - a[0]);
    Y[1] = X[1];

    REP(i, 2, n - 1){
        X[i] = abs(a[i] - a[0]);
        REP(j, 1, i - 1){
            X[i] = min(X[i], Y[j]);
        }

        Y[i] = abs(a[i] - a[0]);
        REP(j, 1, i - 1){
            Y[i] = max(Y[i], X[j]);
        }
    }
    ll res = 0;
    rep(i, n){
        res = max(res, X[i]);
    }
    cout << res << endl;
}



Measured memory_bytes: 256
input_number = int(input())
input_str = input()
abc_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
abc_list = abc_list + abc_list
output_str = ""
for i in range(len(input_str)):
    output_str += abc_list[abc_list.index(input_str[i]) + input_number]
print(output_str)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    int a;
    cin >> a;
    if (a < 1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 764
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int arr[MAXN];
int main(){
    //~ freopen("file.in", "r", stdin);
    int n,ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
		scanf("%d",arr+i);
	sort(arr+1,arr+n+1);
	for(int i=n;i>=1;i--){
		if((n-i)&1)
			ans-=arr[i];
		else
			ans+=arr[i];
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin >> n;
  string x;
  if(n%10==3){
  x="bon";
  }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
  x="pon";
  }else{
  x="hon";
  }
  
  cout << x;
}


Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
import numpy as np
N,W=map(int,input().split())
dp=np.zeros(W+1, dtype='int64')
for i in range(N):
  wi,vi=map(int,input().split())
  dp[wi:]=np.maximum(dp[wi:],dp[0:W-wi+1]+vi)
print(dp[W])

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

int main() {
string s;
cin >> s;
string guusuu,kisuu;
for(int i=1;i<s.size()+1;i++){
    if(i%2==1){
        kisuu+=s.at(i-1);
    }
    else{
        guusuu+=s.at(i-1);
    }
}
int ans =0;
for(int i=0;i<guusuu.size();i++){
    if(guusuu.at(i)=='L'||guusuu.at(i)=='U'||guusuu.at(i)=='D')ans++;
}
for(int i=0;i<kisuu.size();i++){
    if(kisuu.at(i)=='R'||kisuu.at(i)=='U'||kisuu.at(i)=='D')ans++;
}
if(ans ==s.size()){
    cout <<"Yes"<<endl;
}
else {
    cout <<"No"<<endl;
}
}





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

int main()
{
    int N;
    cin >> N;
    for (int i = 1; i < 10; i++)
    {
        if (N / i < 10 && (N % i == 0))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>                                                                              
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
int main(void) {
    ll n;
    ll ans = 1;
    cin >> n;
    ll p=2, q=1;
    ll count;
    bool prime;
    while(p<=n) {
        prime = true;
        FOR(i,2,p) {
            if(p%i == 0) {
                prime = false;
                break;
            }
        }
        if(!prime) {
            p++;
            continue;
        }
        q=p;
        count = 0;
        while(n/q != 0) {
            count += n/q;
            q = q * p;
        }
        ans = ans * (count+1) % 1000000007;
        p++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int n,k,x;
vector<int>v[100002];
int d[100002],ans;
bool b[100002],c[100002];
bool t[100002];
int main(){
	r(i,100002)d[i]=1e8;
	cin>>n>>k;
	r(i,n){
		scanf("%d",&x);
		if(x){
			v[i].push_back(x-1);
			b[i]=1;
			t[x-1]=1;
		}
	}
	queue<P>q;
	r(i,n){
		if(!t[i]){
			q.push(P(i,0));
			c[i]=1;
		}
	}
	while(!q.empty()){
		P p=q.front();q.pop();
		x=p.fi;
		int dis=p.se;
		if(dis>=k-1)continue;
		r(i,v[x].size()){
			if(!c[v[x][i]]){
				c[v[x][i]]=1;
				q.push(P(v[x][i],dis+1));
			}
		}
	}
	r(i,n){
		if(c[i]||!b[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

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

int main() {
    string s; cin >> s;
    ll sum = 0;
    for (char c : s) sum += c - '0';
    if (sum % 9 == 0) cout << "Yes\n";
    else cout << "No\n";
}

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

using namespace std;

typedef long long int lint;

const int NMAX = 300 + 5;

int N, A[NMAX][NMAX];

int main()
{
    ios_base :: sync_with_stdio(false);
    cin >> N;
    for (int i = 1; i <= N; ++ i)
        for (int j = 1; j <= N; ++ j)
            cin >> A[i][j];

    long long int sum = 0;
    for (int i = 1; i <= N; ++ i)
        for (int j = 1; j <= N; ++ j) {
            bool found = false;
            for (int k = 1; k <= N; ++ k)
                if (A[i][k] + A[k][j] < A[i][j]) {
                    cout << "-1\n";
                    return 0;
                }
                else if (k != i && k != j && A[i][k] + A[k][j] == A[i][j])
                    found = true;
            if (!found)
                sum += A[i][j];
        }

    cout << sum / 2 << '\n';
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

template <int mod>
struct ModInt {
  int x;
  ModInt(): x(0) {}
  ModInt(long long a) { x = a % mod; if (x < 0) x += mod; }
  ModInt &operator+=(ModInt that) { x = (x + that.x) % mod; return *this; }
  ModInt &operator-=(ModInt that) { x = (x + mod - that.x) % mod; return *this; }
  ModInt &operator*=(ModInt that) { x = (long long) x * that.x % mod; return *this; }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) { int t = a / b; a -= t * b; u -= t * v; swap(a, b); swap(u, v); }
    return ModInt(u);
  }
  #define op(o, p) ModInt operator o(ModInt that) { return ModInt(*this) p that; }
    op(+, +=) op(-, -=) op(*, *=) op(/, /=)
  #undef op
  friend ostream& operator<<(ostream &os, ModInt m) { return os << m.x; }
};

using mint = ModInt<1000000007>;

void solve() {
  int n, m;
  cin >> n >> m;
  vi32 x(n), y(m);
  cin >> x >> y;
  mint xsum = 0;
  mint ysum = 0;
  rep(i, n) {
    xsum += (mint) x[i] * (i - (n - (i + 1)));
  }
  rep(i, m) {
    ysum += (mint) y[i] * (i - (m - (i + 1)));
  }
  cout << xsum * ysum << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		int[] month = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		String[] week = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday"};
		
		while (true) {
			int m = scan.nextInt();
			int d = scan.nextInt();
			if ((m | d) == 0) break;
			
			int sum = d;
			for (int i = 0; i < m - 1; i++) sum += month[i];
			
			System.out.println(week[sum % 7]);
		}
	}
	
	private void debug() {
		System.out.println();
	}
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    REP(i, n+1) cin >> a[i];
    REP(i, n) cin >> b[i];
    ll defeated = 0;
    REP(i, n) {
        int m = min(a[i], b[i]);
        a[i] -= m; b[i] -= m;
        defeated += m;
        m = min(a[i+1], b[i]);
        a[i+1] -= m; b[i] -= m;
        defeated += m;
    }
    printf("%lld\n", defeated);
    return 0;
}



Measured memory_bytes: 1024
//赤ペン先生

/*
while を使用する時は、）条件式を’（）に書く方がかっこいい
 
*/


#include<bits/stdc++.h>

using namespace std;

signed main(){

    int A,B;
    cin >> A;
    cin >> B;
    
    int outlet = 1;
    int ans =0 ;
    while (outlet < B) {
        --outlet;
        outlet += A;
        ans++;
    }
    
    cout << ans;
/*
    while (true) {
        if(B <= (A-1)*(i-1)+A){
            break;
        }
        i++;
    }
*/

    return 0;

 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int h, w; cin >> h >> w;
	ll ans = 1e18;
	rep(it, 2){
		for(int i = 1; i < h; i++){
			ll a = i * (ll)w;
			ll b = (ll)(h - i) * (w / 2);
			ll c = (ll)(h - i) * ((w + 1) / 2);
			ans = min(ans, max({a, b, c}) - min({a, b, c}));
			
			ll x = (ll)(h - i) / 2 * w;
			ll y = (ll)(h - i + 1) / 2 * w;
			ans = min(ans, max({a, x, y}) - min({a, x, y}));
		}
		swap(h, w);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int s=S.size()-1;
  int cnt=0;
  if(S[0]=='k'){
    cnt++;
    if(S[1]=='e'){
      cnt++;
      if(S[2]=='y'){
        cnt++;
        if(S[3]=='e'){
          cnt++;
          if(S[4]=='n'){
            cnt++;
            if(S[5]=='c'){
              cnt++;
              if(S[6]=='e')cnt++;
            }
          }
        }
      }
    }
  }
  if(S[s]=='e'){
    cnt++;
    if(S[s-1]=='c'){
      cnt++;
      if(S[s-2]=='n'){
        cnt++;
        if(S[s-3]=='e'){
          cnt++;
          if(S[s-4]=='y'){
            cnt++;
            if(S[s-5]=='e'){
              cnt++;
              if(S[s-6]=='k')cnt++;
            }
          }
        }
      }
    }
  }
  if(cnt>=7){cout << "YES" << endl;}
  else{cout << "NO" << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int ans;

void merge(vector<int> &a, int left, int mid, int right)
{
    int n1 = mid - left;
    int n2 = right - mid;
    vector<int> l(n1 + 1);
    vector<int> r(n2 + 1);
    for (int i = 0; i < n1; i++)
    {
        l[i] = a[left + i];
    }
    for (int i = 0; i < n2; i++)
    {
        r[i] = a[mid + i];
    }
    l[n1] = INF;
    r[n2] = INF;
    int i, j;
    i = 0;
    j = 0;
    for (int k = left; k < right; k++)
    {
        ans++;
        if (l[i] <= r[j])
        {
            a[k] = l[i];
            i++;
        }
        else
        {
            a[k] = r[j];
            j++;
        }
    }
}

void mergeSort(vector<int> &a, int left, int right)
{
    if (left + 1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    mergeSort(a, 0, n);
    for (int i = 0; i < n; i++)
    {
        if (i == n - 1)
        {
            cout << a[i];
        }
        else
        {
            cout << a[i] << ' ';
        }
    }
    cout << endl;
    cout << ans << endl;
}


Measured memory_bytes: 6768
import sys

N = int(input())
A = list(map(int, input().split()))
cnt = flg = 0

while flg == 0:
  for i in range(N):
    if A[i]%2 == 0:
      A[i] = int(A[i]/2)
    elif A[i]%2 ==1 or A[i] == 1:
      print(cnt)
      sys.exit()
  cnt += 1
print(max(0,cnt-1))

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

int main(){
  int n;cin>>n;
 map<int,int> arr;
bool dis = 1;
  for(int i = 0; i < n ; i++){
    int t; cin>>t;
    if(arr[t]){
   dis = 0;
  }
 arr[t] = 1;
 }
if(dis) cout<<"YES";
else cout<<"NO";
}


Measured memory_bytes: 9600
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	
	long long int N, K, res = -1000000009;
	vector<long long int> P, C;
	vector<vector<long long int>> loopLS;
	vector<vector <long long int>> DP;
	cin >> N >> K ;
 
	P.resize(N+1);
	C.resize(N+1);
	loopLS.resize(N+1);	
 
	for(int i = 1; i<N+1; i++){
		long long int tmp;
		cin >> tmp;
		P[i] = tmp;
	}
	for(int i = 1; i<N+1; i++){
		long long int tmp;
		cin >> tmp;
		C[i] = tmp;
	}
 
	for(int i = 1; i<N+1; i++){
		loopLS[i].resize(2);
		int tmpIdx = i;
		long long int tmpSum = 0;
		for(int j = 1; ; j++){
			tmpIdx = P[tmpIdx];
			tmpSum += C[tmpIdx];
			if(tmpIdx == i){
				loopLS[i][0] = j;
				loopLS[i][1] = tmpSum;
				break;		
			}
			
		}
	}
 
	DP.resize(N+1);
 
	for(int i = 1; i<N+1; i++){
		DP[i].resize(N+1);
		DP[i][0] = 0;
		DP[i][1] = C[P[i]];
	}
	
	for(int j=2; j<N+1; j++){
		for(int i = 1; i<N+1; i++){
			DP[i][j] = DP[P[i]][j-1] + C[P[i]];
		}
	}
 
	for(int i = 1; i<N+1; i++){
		for(int j = 1; j<N+1; j++){
			if(j > K){
				break;
			}
			res = max(res, max(DP[i][j], DP[i][j] + loopLS[i][1]*((K-j)/loopLS[i][0])));
		}
		
	}
 
	
	cout << res;
 
	return 0;
}

Measured memory_bytes: 199400
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main() {
  ll n,ans = 0;
  cin >> n;
  for (int i = 1; i <= n ;i++) {
    ans+=i;
  }
  cout << ans;
}

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

using namespace std;
#define rep(i,n) for (int i =0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;

int main () {
    int N;
    cin >>N;
    vector<ll> A(N);
    rep(i,N)cin >>A[i];
    ll b=0;
    ll ans =0;
    rep(i,N-1){
        if(A[i+1]<=A[i]+b){
        b=A[i]-A[i+1]+b;
        ans+=b;}
        else b=0;

    }
    cout <<ans ;
    return 0;
}

Measured memory_bytes: 4812
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char * argv[]){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a+b==c || a+c==b || b+c==a) {  
        printf("Yes\n");
    }else{
        printf("No\n");
    } 
    return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int n, i, a[10000], max, min;
	long int sum;

	scanf("%d", &n);

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

	max = a[1];
	min = a[1];
	sum = 0;

	for ( i = 1; i <= n; i++ ) {
		sum = sum + a[i];
		if ( a[i] > max ) {
			max = a[i];
		}
		if ( a[i] < min ) {
			min = a[i];
		}
	}
	printf("%d %d %ld\n", min, max, sum);

	return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0; i<n; i++)
    cin>>h[i];

  int sum=1;
  int max=h[0];

  for(int i=1; i<h.size(); i++){
    if(max<=h[i]){
      sum++;
      max=h[i];
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] intArray = new int[n];
        int count = 0;

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

        double curMin = 1e9;

        for (int value : intArray) {
            curMin = Math.min(curMin, value);
            if (curMin == value) {
                count++;
            }
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 86220
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int val = ceil(1.0*a/d);
    int val2=ceil(1.0*c/b);
    if(val<val2)
    {
        cout<<"No\n";
    }
    else
    {
        cout<<"Yes\n";
    }
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  long long n,W;
  cin >> n >> W;
  long long w[n],v[n];
  for(int i=0;i<n;i++){
    cin >> w[i] >> v[i];
  }
  long long dp[n+5][W+5]={};
  for(int i=0;i<n;i++){
    for(int j=0;j<=W;j++){
      if(j+w[i]<=W){
        dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]], dp[i][j]+v[i]);
      }
      dp[i+1][j]=max(dp[i+1][j], dp[i][j]);
    }
  }
  cout << dp[n][W] << endl;
  return 0;
}

Measured memory_bytes: 82304
def main():
    N = int(input())
    A = list(map(int,input().split()))
    money = 1000
    kabu = 0
    
    flag = ''
    for n in range(N):
        if A[0] > A[n]:
            flag = 'down'
            break
        elif A[0] < A[n]:
            flag = 'up'
            kabu = money//A[0]
            money -= A[0]*kabu
            break
        
    if flag == '':
        print(money)
    else:
        limit = 0
        for n in reversed(range(1,N)):
            if A[n-1] < A[n]:
                limit = n
                break
                
        if limit == 0:
            print(money)
        else:
            for n in range(1,N+1):
                if n == limit+1:
                    money += A[n-1]*kabu
                    break
                else:
                    if flag == 'down':
                        if A[n-1] < A[n]:
                            kabu = money//A[n-1]
                            money -= A[n-1]*kabu
                            flag = 'up'
                    elif flag == 'up':
                        if A[n-1] > A[n]:
                            money += A[n-1]*kabu
                            flag = 'down'
            print(money)
        
if __name__ == '__main__':
    main()

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

using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define gcda(x,y) gcd(abs(x),abs(y))

#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;

#define sz(x) (int)(x).size()
#define HOGE cout << "hoge" << endl;
using P = pair<ll,ll>;

template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}

const int INF = 1e9;

int main(){
    ll n;
    cin >> n;
    vector<char> ans;
    char al[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
    while(n!=0){
      	n--;
        ans.push_back(al[n%26]);
        n /= 26;
    }

    REP(i,ans.size()){
        cout << ans[ans.size()-1-i];
    }
    cout << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);

  long long a,str;
  cin >> a;
 
  str = a;
  while(str*str > a){
    str--;
  }
   
  cout << str*str << endl;
  return 0;
}
 

Measured memory_bytes: 256