akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

using namespace std;
int main(int argc, const char * argv[]) {
    
    double w, h;
    double x, y;
    cin >> w >> h >> x >> y;

    printf("%lf ", double(double(w) * double(h) / double(2.0)));
    if (w - x*double(2.0) == 0.0 && h - y*double(2.0) == 0.0) {
        cout << "1" << endl;
    }
    else {
        cout << "0" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h1,h2,k1,k2,a,b,c,d,x,y;
	scanf("%d %d",&h1,&h2);
	scanf("%d %d",&k1,&k2);
	scanf("%d %d %d %d",&a,&b,&c,&d);
	x=h1*a+h2*b;
	y=k1*a+k2*b;
	if(h1>=10||k1>=10){
		x=x+h1/10*c;
		y=y+k1/10*c;
	}
	if(h2>=20||k2>=20){
		x=x+h2/20*d;
		y=y+k2/20*d;
	}
	if(x>y){
		printf("hiroshi\n");
	}
	else if(y>x){
		printf("kenjiro\n");
	}
	else{
		printf("even\n");
	}
	return 0;
}




Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

int main() {
  int a,b;
  cin >> a >> b;
  if(a<b) rep(i,b) cout << a;
  else rep(i,a) cout << b;
  cout << endl;

  return 0;
}


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

int main(){
  string s; cin>>s;
  for(int i=s.size()-2;i>0;i-=2){
    s.erase(i,2);
    int l=s.size()/2;
    if(s.substr(0,l)==s.substr(l,s.size()-l)){
      cout<<s.size()<<endl;
      break;
    }
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
#def input():
#    return sys.stdin.readline()[:-1]

'''
n=int(input())
for i in range(n):
    a[i]=int(input())
    a[i],b[i]=map(int,input().split())
a=[int(x) for x in input().split()]
n,m=map(int,input.split())
from operator import itemgetter
a = [(1, "c", 1), (1, "b", 3), (2, "a", 0), (1, "a", 2)]
print(sorted(a))  # 0 番目の要素でソート、先頭の要素が同じなら 1 番目以降の要素も見る
print(sorted(a, key=itemgetter(0)))  # 0 番目の要素だけでソート
print(sorted(a, key=itemgetter(0, 2)))  # 0 番目と 2 番目の要素でソート
print(sorted(a, key=lambda x: x[0] * x[2]))  # 0 番目の要素 * 2 番目の要素でソート
print(sorted(a, reverse=True))  # 降順にソート
a.sort()  # 破壊的にソート、sorted() よりも高速
try: # エラーキャッチ list index out of range
    for i in range():
        k=b[i]
except IndexError as e:
    print(i)
'''

test_data1 = '''\
1
1 1 0 1 0 0 0 1 0 1
3 4 5 6 7 8 9 -2 -3 4 -2
'''

test_data2 = '''\
2
1 1 1 1 1 0 0 0 0 0
0 0 0 0 0 1 1 1 1 1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1
'''

test_data3 = '''\

'''
td_num=1

def GetTestData(index):
    if index==1:
        return test_data1
    if index==2:
        return test_data2
    if index==3:
        return test_data3

if False:
    with open("../test.txt", mode='w') as f:
        f.write(GetTestData(td_num))
    with open("../test.txt") as f:
        # Start Input code ---------------------------------------
        n=int(f.readline())
        g=[[] for x in range(n)]
        p=[[] for x in range(n)]
        for i in range(n):
            g[i]=[int(x) for x in f.readline().split()]
        for i in range(n):
            p[i]=[int(x) for x in f.readline().split()]
        # End Input code ---------------------------------------
else:
    for i in range(1):
        # Start Input code ---------------------------------------
        n=int(input())
        g=[[] for x in range(n)]
        p=[[] for x in range(n)]
        for i in range(n):
            g[i]=[int(x) for x in input().split()]
        for i in range(n):
            p[i]=[int(x) for x in input().split()]
        # End Input code ---------------------------------------
#print('n,g,p=',n,g,p)
o=[0]*10
ans=-10**17
try: # エラーキャッチ list index out of range

    for i in range(1,2**10):
        e=0
        for shop in range(n):
            cnt=0
            for t in range(10):
                o[t]=(i%(2**(t+1))) // (2**t)
                cnt+=g[shop][t]*o[t]
            e+=p[shop][cnt]
        ans=max(ans,e)
        #if e==8: print(o,g[shop],cnt,e)
    print(ans)
except IndexError as e:
    print(i,shop,cnt)

Measured memory_bytes: 41836
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ALL(n) n.begin(),n.end()
const ll MOD=1000000007;
const long double PI=3.14159265358979;

int main() {
  ll N,A;
  cin>>N;
  for(int i=0;i<N;i++){
    ll a;
    cin>>a;
    A=A|a;
  }
  ll ans=0;
  while(!(A&1)){
    ans++;
    A>>=1;
  }
  cout<<ans;
}


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

string func(ll n,ll count)
{
	if(n<0 || count<0)
	{
		return "";
	}
	if(n<=26 && count==0)
	{
		string temp(1,(char)(n-1+'a')),ans="";
		
		ans += temp;
		
		return temp;
	}
	string ans = "";
	ll subsum,pre;

	subsum = (ll)pow(26,count);
	int i=0;
	pre = subsum;
	//cout<<"#"<<n<<" "<<count<<endl<<subsum<<" "<<pre<<endl;
	while(i<25 && n>subsum)
	{
		i++;
		subsum+=pre;
	}
		
	string temp(1,(char)(i+'a'));
		
	ans += temp;
	n = n-(subsum-pre);
	//cout<<n<<endl;
	return ans + func(n,count-1);
}
	
int32_t main()
{
	ll n;
	cin>>n;
	ll count =0 ,subsum = 26,pre = 26;

	while(n>subsum)
	{
		count++;
		pre = pre*26;
		n = n-subsum;
		subsum = pre;
	}
	cout<<func(n,count);
	
	return 0;
	
}


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

using namespace std;

int n, s;
int dp[1024][1000][10];

int solve(int stat, int sum, int cnt) {

    if(dp[stat][sum][cnt] != -1) return dp[stat][sum][cnt];

    if(cnt == n) {
        if(sum == s) return 1;
        else return 0;
    }

    int ret = 0;

    for(int i = 0; i <= 9; ++i) {
        if(!(stat & 1 << i)) {
            ret += solve(stat | 1 << i, sum + i * (cnt + 1), cnt + 1);
        }
    }

    return dp[stat][sum][cnt] = ret;

}

int main() {

    while(cin >> n >> s) {

        memset(dp, -1, sizeof(dp));
        cout << solve(0, 0, 0) << endl;

    }

}

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

const int N = 1e5 + 100;

int n, W;
long long w[N], v[N], dp[200][N];


int main(){
    # ifdef FILEs
        freopen( "input.txt", "r" ,stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    cin >> n >> W;
    for( int i = 1; i <= n; i ++ ){
        cin >> w[i] >> v[i];
    }
    for( int i = 1; i <= n; i ++ ){
        for( int j = 1; j <= W; j ++ ){
            dp[i][j] = dp[i-1][j];
            if( j >= w[i] ){
                dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
            }
        }
    }
    long long mx = 0;
    for( int i = 0; i <= W; i ++ ){
        mx = max( mx, dp[n][i] );
    }   
    cout << mx;

}   

Measured memory_bytes: 81408
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9+7; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool cond) {
	if (cond)print("Yes");
	else print("No");
}
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}
int cnt[26];
void solve() {
	int N; cin >> N;
	string S; cin >> S;
	REP(i, N) {
		cnt[S[i] - 'a']++;
	}
	int ans = 1;
	REP(i, 26) {
		if (!cnt[i])continue;
		ans = mult(ans, cnt[i] + 1);
	}
	ans = sub(ans, 1);
	print(ans);
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 640
N = int(input())
if N < 10**1:
    print(N)
elif N < 10**2:
    print(9)
elif N < 10**3:
    print(N-99+9)
elif N < 10**4:
    print(909)
elif N < 10**5:
    print(N-9999+909)
else:
    print(90909)

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

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

  vector<vector<pair<int, int>>> v(100000);
  vector<string> ans(m);

  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    v.at(p - 1).emplace_back(y, i);
  }

  for (int i = 0; i < n; i++) {
    sort(begin(v.at(i)), end(v.at(i)));
    for (size_t j = 0; j < v.at(i).size(); j++) {
      char buf[22];
      sprintf(buf, "%06d%06ld", i + 1, j + 1);
      ans.at(v.at(i).at(j).second) = buf;
    }
  }

  for (const auto& e : ans) {
    cout << e << endl;
  }
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N,unradi = 0,ans = 0;
  cin >> N;
  vector<int> radi(N);
  for(int i = 0; i < N; i++){
    cin >> radi[i];
  } 
  sort(radi.begin(),radi.end());
  reverse(radi.begin(),radi.end());
  unradi = radi[0];
  ans++;
  for(int i = 0; i < N; i++){
    if(unradi > radi[i]){
  	  unradi = radi[i];
      ans++;
    }
  }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 1000001;
const int MOD = 1000000007;
   
        signed main() {
          string s,t;
          cin>>s;
          for(int i=0;i<s.size();i++)cout<<'x';

        }


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll lcm(ll a, ll b){
	return a/__gcd(a, b) * b;
}

int main(){
	int n;
	cin >> n;
	ll ans = 1LL;
	rep(i, n) {
		ll a;
		cin >> a;
		ans = lcm(ans, a);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}


const int N=2e5+5;



void solve()
{
        string s;
        cin>>s;
        int ans=0;
        int c=0;
        for(int i=0;i<s.size();i++)
        {
            c++;
            if(i+1<s.size()&&s[i]==s[i+1])
                continue;
            if(s[i]=='R')
                ans=max(ans,c);
            c=0;
        }
        cout<<ans;


}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t;
 t=1;
 for(int i=1;i<=t;i++)
 {
   solve();
 }


}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(ll i=0;i<n;++i)
#define FOR(i,j,n) for(ll i=j;i<n;++i)
#define MOD (1e9 + 7)

int main(void){
    ll N, M, X;
    cin >> N >> M >> X;
    ll C[N], A[N][M];
    REP(i,N){
        cin >> C[i];
        REP(j,M){
            cin >> A[i][j];
        }
    }
    ll cost, count, skill[M];
    bool is_skilled;
    ll min_cost = 10000000;
    REP(i,(1<<N)){
        cost = 0;
        count = i;
        REP(j,M){
            skill[j] = 0;
        }
        REP(j,N){
            if(count % 2==1){
                cost += C[j];
                REP(k,M){
                    skill[k] += A[j][k];
                }
            }
            count /= 2;
        }
        is_skilled = true;
        REP(j,M){
            if(skill[j]<X){
                is_skilled = false;
            }
        }
        if(is_skilled && min_cost > cost){
            min_cost = cost;
        }
    }
    if(min_cost==10000000){
        min_cost = -1;
    }
    cout << min_cost << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define N (1<<18)
#define INF (1e9)
using namespace std;
struct po{
  int l,r,x;
  po(){};
  po(int l,int r,int x):l(l),r(r),x(x){}
};
const int base=1e5+2;
int segMin[2][2*N-1], segAdd[2][2*N-1];
int w,h,m,x[N],y[N];
vector <po> mp[2][N];
po LR[N];

//starry sky tree
void add(int a,int b,int x,int k,int l,int r,int idx){
  if(r<=a||b<=l) return;
  if(a<=l&&r<=b){segAdd[idx][k]+=x;return;} 
  add(a,b,x,2*k+1,l,(l+r)/2,idx);
  add(a,b,x,2*k+2,(l+r)/2,r,idx);
  int L=segMin[idx][2*k+1]+segAdd[idx][2*k+1];
  int R=segMin[idx][2*k+2]+segAdd[idx][2*k+2];
  segMin[idx][k]=min(L,R);
}

int getMin(int a,int b,int k,int l,int r,int idx){
  if (r<=a||b<=l) return INF;
  if (a<=l&&r<=b) return segMin[idx][k]+segAdd[idx][k];
  int L=getMin(a,b,2*k+1,l,(l+r)/2,idx);
  int R=getMin(a,b,2*k+2,(l+r)/2,r,idx);
  return min(L,R)+segAdd[idx][k];
}

void mk_LR(){
  for(int i=0;i<h&&w==1;i++)LR[base+i]=po(base,base,i%2);
  if(w==1)return;

  LR[base]=po(base,base,0),LR[base+1]=po(base,base+1,1);
  int mn=min(w,h),S,cnt=0;
  for(int i=1;i<mn;i++) cnt+=2*i;
  S=(w*h-cnt)/mn;
  if(w==2)S--;
  for(int i=base+2;;i++){
    int l=LR[i-2].l-1,r=LR[i-2].r+1,x=LR[i-2].x;

    if(S==0&&!x)l=LR[i-1].l,r=l+mn-2,S--;
    else if(S==0&&x)l=LR[i-1].l+1,r=LR[i-1].r,S--;
    else if(S<0) l+=2,r-=2;
    if(l>r)break;
    if(r-l+1>mn) l=LR[i-2].l,r=l+mn-1;
    if(S>0&&LR[i-2].r-LR[i-2].l+1==mn)l=LR[i-2].l+1,r=l+mn-1;
    if(r-l+1==mn)S--;
    LR[i]=po(l,r,x);
  }
}

void mk_mp(int d){
  for(int i=0;i<N;i++) mp[0][i].clear(),mp[1][i].clear();
  
  for(int i=0;i<m;i++){
    int idx=y[i]+(w-x[i]-1)+base;
    int c=LR[idx].l+min(y[i],x[i]);
    int a=idx%2,l=c-d/2,r=c+d/2;
    if(d%2==0){
      mp[a][idx-d].push_back(po(l,r,1));
      mp[a][idx+d+1].push_back(po(l,r,-1));

      mp[!a][idx-d+1].push_back(po(l+!a,r-a,1));
      mp[!a][idx+d].push_back(po(l+!a,r-a,-1));
    }
    else {
      mp[!a][idx-d].push_back(po(l-a,r+!a,1));
      mp[!a][idx+d+1].push_back(po(l-a,r+!a,-1));
      
      mp[a][idx-d+1].push_back(po(l,r,1));
      mp[a][idx+d].push_back(po(l,r,-1));
    }
  }
}


bool check(int d){
  mk_mp(d);
  memset(segMin,0,sizeof(segMin));
  memset(segAdd,0,sizeof(segAdd));
  for(int i=0;i<N;i++){

    for(int k=0;k<2;k++)
      for(int j=0;j<mp[k][i].size();j++)
	add(mp[k][i][j].l,mp[k][i][j].r+1,mp[k][i][j].x,0,0,N,k);
    
    if(LR[i].l&&!getMin(LR[i].l,LR[i].r+1,0,0,N,i%2))return 1;
  }
  return 0; 
}

int search(){
  int L=0,M,R=100001;
  while(L<R){
    M=(L+R)/2;
    if(!check(M)) R=M;
    else L=M+1;
  }
  return L;
}

int main(){
  cin>>w>>h>>m;
  for(int i=0;i<m;i++)cin>>x[i]>>y[i];
  if(w>h){
    swap(w,h);
    for(int i=0;i<m;i++)swap(x[i],y[i]); 
  }
  mk_LR();
 
  cout <<search()<<endl;
  return 0;
}

Measured memory_bytes: 72148
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod=10**9+7

n=I()
nums=LI()
print(sum(nums)-n)

Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

struct Bipartite_Matching
{
    // グラフ表現のベクトル　a->b,a->c etc...
    vector< vector< int> > graph;
    //
    vector<int> match, alive, used;
    int timestamp;

    Bipartite_Matching(int n)
    {
        timestamp = 0;
        // 要素数の変更
        graph.resize(n);
        // n個に1,0,-1を代入する
        alive.assign(n, 1);
        used.assign(n, 0);
        match.assign(n, -1);
    }

    // 枝を加えて二部グラフを作成
    void add_edge(int u, int v)
    {
        graph[u].push_back(v);
        graph[v].push_back(u);
    }

    // 深さ優先探索
    bool dfs(int v)
    {
        used[v] = timestamp;
        for (int i = 0; i < graph[v].size(); i++)
        {
            int u = graph[v][i], w = match[u];
            if (alive[u] == 0)
                continue;
            if (w == -1 || (used[w] != timestamp && dfs(w)))
            {
                match[v] = u;
                match[u] = v;
                return (true);
            }
        }
        return (false);
    }

    // 最大マッチングを求める問題
    int bipartite_matching()
    {
        int ret = 0;
        for (int i = 0; i < graph.size(); i++)
        {
            if (alive[i] == 0)
                continue;
            if (match[i] == -1)
            {
                ++timestamp;
                ret += dfs(i);
            }
        }
        return (ret);
    }
};

int main()
{
    int n;
    cin >> n;
    struct Bipartite_Matching bm(2*n);
    int a[n], b[n], c[n], d[n];
    // 代入
    REP(i, 2 * n)
    {
        if (i % 2 == 0)
        {
            cin >> a[i / 2];
        }
        else
        {
            cin >> b[i / 2];
        }
    }
    REP(i, 2 * n)
    {
        if (i % 2 == 0)
        {
            cin >> c[i / 2];
        }
        else
        {
            cin >> d[i / 2];
        }
    }

    REP(i, n)
    {
        REP(j, n)
        {
            if (a[i] < c[j] && b[i] < d[j])
            {
                bm.add_edge(i, j+n);
            }
        }
    }

    int x = bm.bipartite_matching();

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

cnt = [0]*(10**5+2)
for a in A:
    cnt[a] += 1
ans = []
for a in A:
    if a == 0:
        ans.append(cnt[a] +cnt[a+1])
    else:
        ans.append(cnt[a-1] + cnt[a] +cnt[a+1])
print(max(ans))

Measured memory_bytes: 13964
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int h,w,a,b;
	cin >> h >> w >> a >> b;

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if((i<b and j<a) or (i>=b and j>=a))
				cout << 1;
			else
				cout << 0;
		}
		cout << endl;
	}




}

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

int solve(int n) {
    vector<int> dp = {1, 1, 2};
    for(int i = 3; i <= n; i++) {
        dp.push_back(dp[i - 3] + dp[i - 2] + dp[i - 1]);
    }
    int day = (dp[n] + 9) / 10;
    return (day + 364) / 365;
}

int main() {
    vector<int> n;
    int tmp = 100000;
    while(true) {
        cin >> tmp;
        if(tmp == 0) break;
        n.push_back(tmp);
    }
    REP(i, n.size()) cout << solve(n[i]) << endl;
}



Measured memory_bytes: 3048
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    res = 0
    for i in range(n-1, -1, -1):
        a = (ab[i][0]+res) % ab[i][1]
        if a == 0:
            continue
        res += ab[i][1] - a
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 56540
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <array>
#include <queue>

using namespace std;

int main()
{
    int n;
    cin >> n;
    string a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i=0; i<n; ++i){
        if(a[i] == b[i] && b[i] == c[i]){
            continue;
        }
        else if ((a[i] != b[i] && a[i] == c[i]) || (b[i] != c[i] && a[i] == b[i]) ||
        (a[i] != b[i] && b[i] == c[i])){
            ans++;
        }
        else if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
            ans+=2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define tam 505

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <ll, ll> dl;
typedef pair <int, int> ii;
typedef vector <ii> vii;
typedef vector <vii> graph;

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

	int n, k;
	string s;
	cin >> n >> s >> k;
	char a = s[k - 1];
	for (int i = 0; i < n; ++i)
	{
		if (s[i] != a) {
			cout << "*";
		} else cout << a;
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    long long n,num;
    cin>>n;
    vector <long long> v,pre(200001),suf(200001);
    for(long long i =0;i<n;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    pre[0]=0;
    for(long long i =1;i<n;i++)
    {
        pre[i]=pre[i-1]^v[i-1];
    }
    suf[n-1]=0;
    for(long long i = n-2;i>=0;i--)
    {
        suf[i]=suf[i+1]^v[i+1];
    }
    for(long long i =0;i<n;i++)
    {
        cout<<(pre[i]^suf[i])<<" ";
    }
}

Measured memory_bytes: 8480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000
typedef long long ll;
 
int main(){
    string s;
    cin>>s;
    ll o=0;
    ll z=0;
    rep(i,0,s.size()){
        if(s[i]=='0')z++;
        else if(s[i]=='1')o++;
    }
    cout<<min(o,z)*2<<endl;
}

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

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

int main(){
	int n,i;
	long long a[100000];
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	qsort(a,n,sizeof(long long),compare_int);
	int c=1;
	long long num[5][2]={{a[0],1}};
	for(i=1;i<n;i++){
		if(a[i]!=a[i-1]){
			num[c][0]=a[i];
			num[c][1]=1;
			c++;
			if(c==4){
				puts("No");
				return 0;
			}
		}else num[c-1][1]++;
	}
	if(c==2){
		if(num[0][0]==0){
			if(2*num[0][1]==num[1][1])puts("Yes");
			else puts("No");
		}else puts("No");
		return 0;
	}
	if(c==1){
		if(num[0][0]==0)puts("Yes");
		else puts("No");
		return 0;
	}
	if(c==3){
		if(((num[0][0]^num[1][0])^num[2][0])!=0)puts("No");
		else{
			if(num[0][1]==num[1][1]&&num[0][1]==num[2][1])puts("Yes");
			else puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 1532
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a + b < 10) {
			System.out.print(a + b);
		} else {
			System.out.print("error");
		}

	}
}

Measured memory_bytes: 21972
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

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

#############
# Main Code #
#############
ans = 0
for i in range(1,int(input())+1):
  if len(str(i)) %2:
    ans += 1
print(ans)


Measured memory_bytes: 64620
alpha = [[], list(".,!? "), list("abc"), list("def"), list("ghi"),
         list("jkl"), list("mno"), list("pqrs"), list("tuv"), list("wxyz")]

n = int(input())
for _ in range(n):
    button = list(input())
    button = [int(b) for b in button]

    while 1:
        if button[0] == 0:
            button.pop(0)
        else:
            break

    ans = ""
    cnt = 0
    for i, b in enumerate(button):
        if b == 0 and button[i-1] != 0:
            ans += alpha[button[i-1]][(cnt-1) % len(alpha[button[i-1]])]
            cnt = 0
        elif b == 0:
            pass
        else:
            cnt += 1

    print(ans)


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

int getYakusu(int n) {
	int rtn = 0;
	for(int i = 1; i <= sqrt(n)+1; i++) {
		if(n % i == 0) rtn++;
	}
	return rtn * 2;
}
int main() {
	const int max_n = 201;
	vector<int> a(max_n, 0);
	for(int i = 9; i < max_n; i+=2) {
		a[i] = getYakusu(i);
	}

	int n; cin >> n;
	int sum = 0;
	for(int i = 9; i <= n; i+=2) {
//		cout << "i=" << i << "   a[i]=" << a[i] << endl;
		if(a[i] == 8)  {
			sum++;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
	int X,Y,Z; cin >> X >> Y >> Z;
	X -= Z;
	int ans = X/(Y+Z);
	cout << ans << endl;
}



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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mpi map<int,int>
#define mpl map<ll,ll>
#define umpi unordered_map<int,int>
#define umpl unordered_map<ll,ll>
#define si set<int>
#define sl set<ll>
#define msi multi_set<int>
#define msl multi_set<ll>

#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)


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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}


int par[200005],r[200005];
int mx=1;
int find(int a){
    if(par[a]<0)
    return a;
    return par[a]=find(par[a]);
}
void merge(int a,int b){
    if(r[a]>r[b]){
        par[b]=a;
        r[a]+=r[b];
        mx=max(mx,r[a]);
    }
    else{
        par[a]=b;
        r[b]+=r[a];
        mx=max(mx,r[b]);
    }
}
int main()
{   
    
    fast
    int n,m;
    cin>>n>>m;
    rep(i,n+1){
        par[i]=-1;
        r[i]=1;
    }
    rep(i,m){
        int x,y;
        cin>>x>>y;
        int a=find(x),b=find(y);
        if(a!=b)
        merge(a,b);
    }
    cout<<mx<<nl;
    
    return 0;
}

Measured memory_bytes: 5152
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

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

	ll sum1 = 0;
	rep(i, 0, n)sum1 += l + i;

	int dif = 505050;
	int ans = 0;
	rep(i, 0, n) {
		int temp = abs(sum1 - (sum1-(l + i)));
		if (temp < dif) {
			dif = temp;
			ans = sum1 - (l + i);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
using namespace std;
int main()
{
 	ll a,p;
 	cin>>a>>p;
 	cout<<(3*a+p)/2;
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
using System;

namespace ITP1_7_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] strs = Console.ReadLine().Split(' ');
                int n = int.Parse(strs[0]);
                int s = int.Parse(strs[1]);
                if (n == 0 && s == 0) break;
                int w = 0;
                for (int i = 1; i <= n-2; i++)
                {
                    for (int j = i + 1; j <= n - 1; j++)
                    {
                        if (s - i - j > j && s - i - j <= n) w++;
                    }
                }
                Console.WriteLine(w);
            }
        }
    }
}

Measured memory_bytes: 9000
A, B, C ,D = map(int, input().split())

if A >= D or B <= C:
    print(0)
elif A >= C:
    if B <= D:
        print(B-A)
    else:
        print(D-A)
else:
    if B <= D:
        print(B-C)
    else:
        print(D-C)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdbool.h> 
 
int main(void)
{
  char s[200];
  char t[100];
  int i, j, k;
  int len;
  bool flag;
  
  scanf("%s", s);
  
  len = strlen(s) - 2;
  while (0 < len) {
    k = i = len / 2;
    j = 0;
    flag = true;
    while (j < k) {
      if (s[i] != s[j]) {
        flag = false;
        break;
      }
      i++, j++;
    }
    if (flag)
      break;
    len -= 2;
  }
  
  printf("%d\n", len);
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
	int n, m, l, i, j, k,A[100][100],B[100][100];
	long long int C[100][100] = { 0 };

	scanf("%d %d %d", &n, &m, &l);
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &A[i][j]);
		}
	}
	for ( i = 0; i < m; i++){
		for (j = 0; j < l; j++) {
			scanf("%d", &B[i][j]);
		}
	}
	for (i = 0; i < n; i++) {
		for ( j = 0; j < l; j++){
			for (k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	for (i = 0; i < n; i++) {
		for ( j = 0; j < l; j++){
			printf("%lld", C[i][j]);
			if (j != l-1) {
				printf(" ");
			}
			
		}
		printf("\n");
	}
	
}

Measured memory_bytes: 2004
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
const double eps = 1e-8;

int n, hx, hy, dx, dy;
vector<int> cx, cy;
vector<double> dd;
vector<vector<double> > d;

bool check(int vis, int k, double t){
    rep(i, n)if(!(vis >> i & 1) && dd[i] <= d[k][i] + t + eps)return false;
    return true;
}

bool dfs(int vis, int k, double t){
    if(vis == (1 << n) - 1)return true;
    if(!check(vis, k, t))return false;
    rep(i, n)if(!(vis >> i & 1) && dfs(vis | 1 << i, i, t + d[k][i]))return true;
    return false;
}

int main(){
    while(cin >> n >> hx >> hy >> dx >> dy, n|hx|hy|dx|dy){
        cx.assign(n, 0); cy.assign(n, 0); dd.assign(n, 0);
        d.assign(n + 1, vector<double>(n + 1, 0));
        rep(i, n){
            cin >> cx[i] >> cy[i];
            dd[i] = hypot(cx[i] - dx, cy[i] - dy);
            d[i][n] = d[n][i] = hypot(cx[i] - hx, cy[i] - hy);
            rep(j, i)d[i][j] = d[j][i] = hypot(cx[i] - cx[j], cy[i] - cy[j]);
        }
        cout << (dfs(0, n, 0.)? "YES\n": "NO\n");
    }
    return 0;
}

Measured memory_bytes: 1196
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;

bool check(long long a,long long b,long long c){
    if(c<a+b){
        return true;
    }else{
        return false;
    }
}

int main(){
    long long N;
    long long element;
    long long ans=0;
    long long right,left;
    long long mid;
    vector<long long> L;
    cin >> N;
    for(int i=0; i < N; i++){
        cin >> element;
        L.push_back(element);
    }
    sort(L.begin(), L.end());

    for(int a=0; a<N-2; a++){
        for(int b=a+1; b<N-1; b++){
            right = N;
            left  = b;
            while((right-left)>1){
                mid = (right+left)/2;
                if(check(L[a], L[b], L[mid])){
                    left = mid;
                }else{
                    right = mid;
                }
            }
            if(left!=b){
                ans = ans + left-b;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;





int main(){
    LL k,X,Y;cin >> k >> X >> Y;
    if(k%2==0&&(X+Y)%2){
        puts("-1");
        return 0;
    }
    if(abs(X)+abs(Y)==k){
        cout << 1 << endl;
        cout << X << " " << Y << endl;
        return 0;
    }
    bool fx=false,fy=false,fr=false;
    if(X<0){
        X *= -1;
        fx = true;
    }
    if(Y<0){
        Y *= -1;
        fy = true;
    }
    if(X>Y){
        swap(X,Y);
        fr = true;
    }
    vector<P> ans;
    LL n = max(2LL,(X + Y + k - 1) / k);
    if((n * k - X - Y) % 2) n++;
    LL t = (n * k - X - Y) / 2;
    LL x = 0, y = 0;
    if(Y<k&&n==3){
        ans.pb(make_pair(X,X-k));
        ans.pb(make_pair(X+(k+X-Y)/2,Y-k+(k+X-Y)/2));
        ans.pb(make_pair(X,Y));
    }
    else{
        bool f = false, ff = false;
        for (int i = 0; i < n; i++) {
            int u = 0, v = 0;
            if(!f) u = k, v = 0;
            else if(!ff) u = 0, v = k;
            else u = -k, v = 0;
            if(!f){
                if(x + u >= X + t){
                    f = true;
                    u = X + t - x;
                    v = k - u;
                }
            }
            else{
                if(y + v >= Y){
                    ff = true;
                    v = Y - y;
                    u = -(k - v);
                }
            }
            x += u;
            y += v;
            ans.pb(make_pair(x,y));
        }
    }
    cout << n << endl;
    for (int i = 0; i < ans.size(); i++) {
        if(fr) swap(ans[i].fs,ans[i].sc);
        cout << (fx?-1:1)*ans[i].fs << " " << (fy?-1:1)*ans[i].sc << endl;
    }
    return 0;
}


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


int main() {
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    sort(l.begin(),l.end());
    reverse(l.begin(),l.end());
    ll ans = 0;
    rep(i,n-2){
        int lmax = l[i];
        for(int j=i+1; j<n-1;j++){
            if(lmax == l[j]){
                ans += n-1-j;
            } else {
                int lmin = lmax - l[j];
                for(int k=j+1; k<n; k++){
                    if(l[k] > lmin) ans++;
                    else break;
                }
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    int b[N+1];
    for(int i=1;i<=N;i++) cin >> b[i];
    vector<int> ans(N);
    for(int i=1;i<=N;i++){
        if(b[i]>i){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i=1;i<=N;i++){
        ans.insert(ans.begin()+b[i],b[i]);
    }
    for(int i=1;i<=N;i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))

x = 0
y = 0
candies = []
for i in range(N):
  candy=0
  for n in range(N):
    candy += A[x][y]
    if y == i:
      x = 1
      candy += A[x][y]
    y += 1
  x = 0
  y = 0
  candies.append(candy)
print(max(candies))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(int (i) = 1; (i) < (n); ++(i))
#define rrep1(i,n) for(int (i) = (n) - 1; (i) >= 1; --(i))
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    ll n,m,cnt = 0;
    cin >> n >> m;
    vector<ll> dp(n + 1,0),a(m + 1,0);
    rep0(i, m)cin >> a[i];
    dp[0] = 1;
    if (a[cnt] == 1) {
        dp[1] = 0;
        ++cnt;
    }else{
        dp[1] = 1;
    }
    nfor(i, 2, n + 1){
        if (a[cnt] == i) {
            dp[i] = 0;
            ++cnt;
        }else{
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= mod;
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main{

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();

        int unhide = A - B * 2;

        if(unhide < 0) {
            unhide = 0;
        }
        
        System.out.println(unhide);

        scanner.close();
    }
}

Measured memory_bytes: 21716
//by yjz
#include<bits/stdc++.h>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
typedef long long ll;
using namespace std;
const int mod = 998244353;
typedef pair<vector<int>, vector<int> > dp_t;
int n, a[411];
int C[411][411];
int pw2[1000111];
void upd(int &x, ll v)
{
	x = (x+v)%mod;
}
dp_t solve(int l, int r, int lst)
{
	if (l>r)
	{
		dp_t ret = MP(vector<int>(401, 1), vector<int>(401, 0));
		return ret;
	}
	int mn = a[l], x = l;
	for (int i=l; i<=r; i++)
	{
		if (a[i]<mn)
		{
			mn = a[i];
			x = i;
		}
	}
	int h = a[x], dh = h-lst;
	dp_t dpl = solve(l, x-1, mn), dpr = solve(x+1, r, mn);
	dp_t dp = MP(vector<int>(lst+1, 0), vector<int>(lst+1, 0));
	for (int c=0; c<2; c++)
	{
		for (int fl=0; fl<2; fl++)
		{
			for (int fr=0; fr<2; fr++)
			{
				for (int i=0; i<=lst; i++)
				{
					if (c==0&&fl==0&&fr==0)
					{
						int w = 1ll*dpl.FF[i]*dpr.FF[i]%mod;
						if (c==0) w = 1ll*w*(pw2[h-i]-1)%mod;
						upd(dp.FF[i], w);
					}
					else
					{
						for (int j=0; j<=dh; j++)
						{
							int w = 1ll*C[dh][j]*(j&1?-1:1)*(fl?dpl.SS[i+j]:dpl.FF[i+j])%mod*(fr?dpr.SS[i+j]:dpr.FF[i+j])%mod;
							if (c==0) w = 1ll*w*(pw2[h-i-j]-1)%mod;
							upd(dp.SS[i], w);
						}
					}
				}
			}
		}
	}
	return dp;
}
int main()
{
	for (int i=0; i<=400; i++)
	{
		C[i][0] = C[i][i] = 1;
		for (int j=1; j<i; j++) C[i][j] = (C[i-1][j-1]+C[i-1][j])%mod;
	}
	pw2[0] = 1;
	for (int i=1; i<=1000000; i++) pw2[i] = pw2[i-1]*2ll%mod;
	cin>>n;
	for (int i=1; i<=n; i++) cin>>a[i];
	dp_t dp = solve(1, n, 0);
	cout<<((dp.FF[0]+dp.SS[0])%mod+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 6144
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        int n = readInt();
        ArrayList<BigInteger> list = new ArrayList<>(n);
        BigInteger sum = BigInteger.ZERO;

        for (int i = 0; i < n; i++) {
            BigInteger a = readBigInteger();
            sum = sum.add(a);
            list.add(a);
        }

        long ans = 0;
        BigInteger mod = BigInteger.valueOf(1000000007);
        for (int i = 0; i < n - 1; i++) {
            BigInteger a = list.get(i);
            sum = sum.subtract(a);
            ans += (a.multiply(sum)).mod(mod).longValue();
        }

        System.out.print(ans % mod.longValue());
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


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

import numpy as np

a=np.arange(N)
a=np.delete(a,0)

b=N-a

num_arr=[]

for i in range(len(a)):
	factor_a=[int(x) for x in list(str(a[i]))]
	factor_b=[int(x) for x in list(str(b[i]))]
	num_arr.append(sum(factor_a)+sum(factor_b))

print(min(num_arr))


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

string S, T;

int main() {
  cin >> S >> T;
  bool ok = 1;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] != T[i]) ok = 0;
  }
  if(ok) puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;
/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
*/
int main()
{
    vector<int> c(5);
    cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4];
    vector<int> P = {0, 1, 2, 3, 4};
    int time = INF;
    do {
        int tmp = 0;
        REP(i, 5) {
            while(tmp % 10 != 0)
                tmp += 1;
            tmp += c[P[i]];
        }
        time = min(time, tmp);
    } while (next_permutation(ALL(P)));
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
from decimal import Decimal
def main():
    n = int(input())
    xu = [input().split() for _ in range(n)]
    c = Decimal("0")
    for x,u in xu:
        if u == "JPY":
            c += Decimal(x)
        else:
            c += Decimal(x)*Decimal("380000.0")
    print(c)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 10004