akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
typedef long long int ll;
 
using namespace std;
 
#define MOD (ll)1000000007
 
ll arr[1000000];
 
int main(){
 
    ll n;
    cin >> n;
    for(ll i = 0; i < n; i++){
        cin >> arr[i];
    }
    ll sum = 0;
    for(ll i = 0; i < 60; i++){
        ll oc = 0, zc = 0;
        for(ll j = 0; j < n; j++){
            if(arr[j]%2 == 0){
                zc++;
            }
            else{
                oc++;
            }
            arr[j] /= 2;
        }
        sum = (sum + ((zc * oc) % MOD * ((1ll << i) % MOD)) % MOD) % MOD;


    }
    cout << sum;
}

Measured memory_bytes: 5948
#include<iostream>

int main(){
  int x;
  int a[3];
  int i=0;
  int cnt=0;

  while(std::cin>>x){
    for(int j=0;j<i;j++){ 
      if(a[j]==x){
        cnt++;
      }
    }
    if(cnt==0){
      a[i]=x;
      i++;
    }
    cnt=0;

  }


  std::cout<<i<<std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


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


Measured memory_bytes: 256
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;

int main()
{
	sync;
	ll n;
	string s;
	cin>>n>>s;
	ll b=0,r=0;
	for(ll i=0;i<n;i++)
	if(s[i]=='R')r++;
	else b++;
	if(r>b)
	cout<<"Yes";
	else
	cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define ll long long 
const int N = 5000001; 
using namespace std; 
int n;
int solve(int row,int index,vector< vector<int> > &v,vector< vector<int> > &dp)
{
    int cost=0;
    if(row>=(n))
    {
        return 0;
    }
    if(dp[row][index]!=-1)
    return dp[row][index];
    for(int i=0;i<3;i++)
    {
        if(i!=index)
        {
            cost=max(cost,v[row][i]+solve(row+1,i,v,dp));
        }
    }
    
    return dp[row][index]=cost;
    
}
int main()
{
    cin>>n;
    vector<vector<int> > v( n , vector<int> (3,0));
    vector<vector<int> > dp( n , vector<int> (4,-1));
    int x;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>x;
            v[i][j]=x;
        }
    }
    int row=0;
    int index=3;
    cout<<solve(row,index,v,dp);
}


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

int main() {
    int N;
    cin >> N;
    vector <int> V(N);
    vector <int> C(N);
    for (int i=0; i<N; i++) cin >> V.at(i);
    for (int i=0; i<N; i++) cin >> C.at(i);
    int ans;
    for (int i=0; i<N; i++) {
        if (V.at(i)>=C.at(i)) ans += (V.at(i)-C.at(i));
    }
    cout << ans;
}

Measured memory_bytes: 256
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();

		int area = a * b;
		int length = 2 * (a + b);

		System.out.println(area + " " + length);

		sc.close();
	}
}



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0;i < n;++i) cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    bool ans;
    for (int i = 0;i < n;++i) {
        if (i == n-1 || a[i+1] <= i+1) {
            int cnt = 0;
            for (int j = i+1;j < n;++j) if (a[j] > i) cnt++;
            if (cnt%2 == 0 && (a[i]-i-1)%2 == 0) ans = false;
            else ans = true;
            break;
        }
    }
    cout << (ans ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <cmath>
#define inf 999999999
using namespace std;
int num;
int main()
{
    int a,b;
    int temp;
    vector<int> cost(1e5+1);
    vector<int> dp(1e5+1);
    while(cin>>a>>b){
        fill(cost.begin(),cost.end(),0);
        fill(dp.begin(),dp.end(),inf);
        for(int i=0;i<a;i++){
            cin>>cost[i];
        }
        dp[0]=0;
        dp[1]=abs(cost[1]-cost[0]);
        for(int i=1;i<a;i++){
            for(int j=1;j<=i && j<=b;j++){
                 dp[i]=min(dp[i],dp[i-j]+abs(cost[i-j]-cost[i]));
            }
        }
        cout<<dp[a-1]<<endl;
    }
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  string s; cin>>s;
  int n=s.size();
  int ans=inf;
  for(int i=0; i<n-2; i++){
    int cur=(s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0');
    ans = min(ans,abs(753-cur));
  }

  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	int a[3001][2], i, I, n;
	for(i = 0 ;  ; i++)
	{
		scanf("%d %d", &a[i][0], &a[i][1]);
		if(a[i][0] > a[i][1])
		{
			n = a[i][0];
			a[i][0] = a[i][1];
			a[i][1] = n;
		}
		if(a[i][0] == 0 && a[i][1] == 0)
		{
			for(I = 0 ; I<i ; I++)
			{
				printf("%d %d\n", a[I][0], a[I][1]);
			}
			exit(0);
		}
	}
	return 0;
}


Measured memory_bytes: 1980
#include<iostream>
#include<cmath>

using namespace std;

int main() {
    int a, b;

    cin >> a >> b;

    int tmpa = 0, tmpb = 0; 

    for(int i = 0; i < a; i++) {
        tmpa = tmpa + pow(10, i) * b;
    }
    for(int i = 0; i < b; i++) {
        tmpb = pow(10, i) * a + tmpb;
    }
    cout << ((tmpa > tmpb) ? tmpa : tmpb) << endl;

    return 0;
}
        


Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int MAX = 9;
const int HP = 7;
const int INF = (1<<25);
int T[HP][MAX][MAX];
int M[MAX][MAX];
int W,H;
int sx,sy,gx,gy;
int dx[] ={0,0,1,-1};
int dy[] ={1,-1,0,0};

void init(){

  for(int i = 0; i < HP; i++)
    for(int j = 0; j < MAX; j++)
      for(int k = 0; k < MAX; k++) T[i][j][k] = INF;
   
}

void input(){
  for(int i = 0; i < H; i++)
    for(int j = 0; j < W; j++){
      cin >> M[i][j];
      if(M[i][j] == 2){
	sx = i;
	sy = j;
      }
      if(M[i][j] == 3){
	gx = i;
	gy = j;
      }
    }
}

void solve(int h, int x, int y, int n){
  if(T[h][x][y] <= n) return;
  T[h][x][y] = n;
  if(M[x][y] == 3 || h == 1) return;

  for(int i = 0; i < 4; i++){
    int nx = x+dx[i];
    int ny = y+dy[i];
    if(0 <= nx && nx < H && 0 <= ny && ny < W && M[nx][ny] != 0){
      if(M[nx][ny] == 4) solve(6,nx,ny,n+1);
      else solve(h-1,nx,ny,n+1);
    }
  }
}

void getans(){
  int ans = INF;

  for(int i = 1; i < HP; i++) ans = min(ans,T[i][gx][gy]);

  if(ans == INF) cout << "-1" << endl;
  else cout << ans << endl;
}

int main(){

  while(cin >> W >> H && W+H){
    init();
    input();
    solve(6,sx,sy,0);
    getans();
  }
  return 0;
}

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

vector<int> solve(int n, int a, int b) {
    if(n == 1) {
        return vector<int> {a, b};
    } else {
        int d = 0;
        for( ; d < n; ++d) {
            if(((a >> d) & 1) != ((b >> d) & 1)) break;
        }
        int na = ((a & ~((1 << (d + 1)) - 1)) >> 1) | (a % (1 << d));
        int nb = ((b & ~((1 << (d + 1)) - 1)) >> 1) | (b % (1 << d));
        int c = na ^ 1;
        vector<int> reta = move(solve(n - 1, na, c));
        vector<int> retb = move(solve(n - 1, c, nb));

        vector<int> ret(1 << n);
        for(int i = 0; i < (1 << (n - 1)); ++i) {
            ret[i] = ((reta[i] << 1) & ~((1 << (d + 1)) - 1))
            | (((a >> d) & 1) << d) | (reta[i] % (1 << d));
        }
        for(int i = 0; i < (1 << (n - 1)); ++i) {
            ret[i + (1 << (n - 1))] = ((retb[i] << 1) & ~((1 << (d + 1)) - 1))
            | (((b >> d) & 1) << d) | (retb[i] % (1 << d));
        }
        return ret;
    }
}


int main() {
    int N;
    long long A,B;
    cin >> N >> A >> B;
    if(__builtin_parity(A ^ B) == 0) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;
    vector<int> ret = move(solve(N, A, B));
    for(int i=0; i < (1 << N); ++i) cout << ret[i] << (i + 1 == (1 << N) ? '\n' : ' ');
}

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

signed main(void)
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,k;
  cin >> n >> k;
  cout << k*2-n << endl;
}

Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));

for($i=0; $i<$n; $i++){
    $arr[] = trim(fgets(STDIN));
}

$max_key = array_keys($arr, max($arr));
rsort($arr);

for($s=0; $s<$n; $s++){
    if($s == $max_key[0]){
        echo $arr[1];
        echo "\n";
    }else{
        echo $arr[0];
        echo "\n";
    }
}

Measured memory_bytes: 69620
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>

using namespace std;


int main(int argc, const char * argv[]) {
    
    int n, m, wa = 0, ac = 0;
    
    cin >> n >> m;
    
    int p;
    string s;
    int flag[1050000];
    int w[105000];
    
    for(int i=0; i<n+1; i++)
    {
        flag[i] = 0;
        w[i] = 0;
    }
    
    while(m--)
    {
        cin >> p >> s;
        
        //cout << flag[p[i]] << endl;

        if(flag[p] == 1) continue;
        
        if(s == "AC")
        {
            flag[p] = 1;
            ac++;
            wa += w[p];
        } else if (s == "WA")
        {
            //wa++;
            w[p]++;
        }
        
    }
    
    cout << ac << " " << wa << endl;
    
    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int >h(100000,0);
vector<int >memo(100000,-1);
int calc(int n){
	if(n==0)return 0;
  	if(memo[n]!=-1)return memo[n];
  else{
    int mini = abs(h[n]-h[n-1])+calc(n-1);
    if(n-2>=0)mini = min(mini,abs(h[n]-h[n-2])+calc(n-2));
    memo[n] = mini;
    return memo[n];
  }
}
int main(){
	cin>>n;
  for(int i=0;i<n;i++){
  	cin>>h[i];
  }
  cout<<calc(n-1);
}

Measured memory_bytes: 8648
/*
* @Author: kabbo
* @Date:   2020-05-19 18:59:11
* @Last Modified by:   kabbo
* @Last Modified time: 2020-05-19 19:20:10
*/
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define endl '\n'
#define ull unsigned long long
#define ll long long
const int mod = 1e9 + 7;
using u64 = uint64_t;
using u128 = __uint128_t;
const int mx = 100 * 1000;
ll dp[110][mx + 10];
struct item {
	ll wt, val;
};
void solve() {
	ll n, w;
	cin >> n >> w;
	vector<item>arr(n + 1);
	for (int i(1); i <= n; ++i) {
		cin >> arr[i].wt >> arr[i].val;
	}

	for (int v(0); v <= mx; ++v)
		dp[1][v] = 1e9 + 1;

	dp[1][arr[1].val] = arr[1].wt;
	dp[1][0] = 0;
	for (int i(2); i <= n; ++i) {
		for (int j(0); j <= mx; ++j) {
			dp[i][j] = dp[i - 1][j];
			if (arr[i].val > j)
				continue;
			dp[i][j] = min(dp[i][j], arr[i].wt + dp[i - 1][j - arr[i].val]);
		}
	}

	ll ans = 0;
	for (int j(0); j <= mx; ++j) {
		if (dp[n][j] <= w) {
			ans = j;
		}
	}
	cout << ans << endl;

}
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*int t;
	cin >> t;
	for (int i(1); i <= t; ++i) {
		printf("Case %d: ", i);*/
	solve();
	//}
#ifndef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
#endif
	return 0;
}

Measured memory_bytes: 79360
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        ArrayList<String> ans = new ArrayList<String>();
        for(String c : s.split("")){
            if(c.equals("0")){
                ans.add("0");
            }
            if(c.equals("1")){
                ans.add("1");
            }
            if(c.equals("B") && ans.size() > 0){
                ans.remove(ans.size()-1);
            }
        }
        
        for(int i=0; i<ans.size(); i++){
            System.out.print(ans.get(i));
        }
    }
}

Measured memory_bytes: 21716
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f;
const int N=15;
int n,m;
int tb[N][N];
int sum[1<<N];
int tmp[1<<N][N],dp[1<<N][N];
void prt_bitmsk(int x){
	for(int i=0;i<n;i++)cout<<!!(x&1<<i);
}
int main(){
	cin>>n>>m;
	int tot=0;
	while(m--){
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		tb[x][y]=tb[y][x]=z;
		tot+=z;
	}
	for(int i=0;i<1<<n;i++){
		for(int j=0;j<n;j++)if(i&1<<j)for(int k=j+1;k<n;k++)if(i&1<<k)
			sum[i]+=tb[j][k];
//		printf("sum[");prt_bitmsk(i);printf("]=%d\n",sum[i]);
	}
	for(int i=0;i<1<<n;i++)for(int j=0;j<n;j++)dp[i][j]=tmp[i][j]=-inf;
	int mx=-inf;
	for(int i=0;i<1<<n;i++)if(i&1)for(int j=0;j<n;j++)if(i&1<<j){
		if(j)
			for(int k=i^1<<j^1;;k=k-1&(i^1<<j^1)){
				dp[i][j]=max(dp[i][j],sum[k|1<<j]+tmp[i^k^1<<j][j]);
				if(!k)break;
			}
		else
			dp[i][j]=sum[i];
//		printf("dp[");prt_bitmsk(i);printf("][%d]=%d\n",j,dp[i][j]);
		if(j==n-1)mx=max(mx,dp[i][j]);
		for(int k=0;k<n;k++)if(!(i&1<<k))
			if(tb[j][k])
				tmp[i][k]=max(tmp[i][k],dp[i][j]+tb[j][k]);
	}
	cout<<tot-mx;
	return 0;
}
/*1
4 6
1 2 100
3 1 100
2 4 100
4 3 100
1 4 100
3 2 100
*/
/*2
2 1
1 2 1
*/
/*3
15 22
8 13 33418
14 15 55849
7 10 15207
4 6 64328
6 9 86902
15 7 46978
8 14 53526
1 2 8720
14 12 37748
8 3 61543
6 5 32425
4 11 20932
3 12 55123
8 2 45333
9 12 77796
3 9 71922
12 15 70793
2 4 25485
11 6 1436
2 7 81563
7 11 97843
3 1 40491
*/

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  
  int ans = 0, h = 0;
  for(int i = 0; i < n; i++){
    if(h > a[i]){
      ans += h - a[i];
    }
    h = max(h, a[i]);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4808
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

const long long M = 1000000007;

//x^n mod M
typedef long long ull;
ull power(ull x, ull n){
	ull res = 1;
	if(n > 0){
		res = power(x, n / 2);
		if(n % 2 == 0) res = (res * res) % M;
		else res = (((res * res) % M) * x ) %M;
	}
	return res;
}

int main(){
	int n;
	string s;
	cin >> n >> s;

	vector<long long> dp(n + 1, 0);
	dp[0] = 1;
	rep(i,n){
		vector<long long> _dp(n + 2, 0);
		rep(j,n + 1){
			if(j == 0) (_dp[j] += dp[j]) %= M;
			else (_dp[j - 1] += dp[j]) %= M;
			(_dp[j + 1] += dp[j] * 2LL) %= M;
		}
		dp = _dp;
		//for(auto j : dp){ for(auto k : j){ cout << k <<  ' '; } cout << endl; } cout << endl;
	}
	cout << dp[s.size()] * power(power(2,s.size()), M - 2) % M  << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint32_t;
using s64 = int32_t;

// A = B * C <-> A % N = (B % N) * (C % N) % N 
// A = B + C <-> A % N = (B % N) + (C % N) % N

int main(void) {
    u64 N;
    cin >> N;

    boost::dynamic_bitset<> X;
    //string X;
    cin >> X;
    
    // pre cal
    u64 bcnt = X.count();
    u64 bcnt_p = bcnt + 1;
    u64 bcnt_m = (bcnt > 1) ? bcnt - 1 : 1;
    vector<u64> mod_p(N, 1);
    vector<u64> mod_m(N, 1);

    mod_p[0] = 1 % bcnt_p;
    mod_m[0] = 1 % bcnt_m;
    for(u64 i=1; i<N; i++) {
        mod_p[i] = mod_p[i-1] * 2 % bcnt_p;
        mod_m[i] = mod_m[i-1] * 2 % bcnt_m;
    }

    u64 pre_ans_p = 0;
    u64 pre_ans_m = 0;
    for(u64 i=0; i<N; i++) {
        if(X[i]) {
            pre_ans_p = (pre_ans_p + mod_p[i]) % bcnt_p;
            pre_ans_m = (pre_ans_m + mod_m[i]) % bcnt_m;
        }
    }

    for(s64 i=N-1; i>=0; i--) {
        boost::dynamic_bitset<> Xi = X;
        Xi.flip(i);

        // all 0
        if(Xi.none()) {
            cout << 0 << endl;
            continue;
        }

        // firstly
        u64 val;
        if(Xi[i]) {
            val = (pre_ans_p + mod_p[i]) % bcnt_p;
        } else {
            val = (pre_ans_m >= mod_m[i]) ? (pre_ans_m - mod_m[i]) % bcnt_m : (pre_ans_m + bcnt_m - mod_m[i]);;
        }

        // secondly
        u64 ans = 1;
        while(val > 0) {
            ans++;
            u64 nxt = val;
            u64 mod = 0;
            while(val > 0) {
                mod += val & 1;
                val /= 2;
            }
            val = nxt % mod;
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 4780
#include "bits/stdc++.h"

using namespace std;

const long long MOD = 1e9 + 7;

void Main() {
    int H, W;
    cin >> H >> W;
    vector<vector<bool> > a(H, vector<bool>(W, false));
    for (int i = 0; i < H; ++i) {
        string temp;
        cin >> temp;
        for (int j = 0; j < W; ++j) {
            a[i][j] = (temp.substr(j, 1) == ".") ? true : false;
        }
    }

    vector<vector<long long> > ans(H + 1, vector<long long>(W + 1, 0));
    if (a[H - 1][W - 2]) {
        ans[H - 1][W - 2] = 1;
    }
    if (a[H - 2][W - 1]) {
        ans[H - 2][W - 1] = 1;
    }
    for (int i = H - 1; i >= 0; --i) {
        for (int j = W - 1; j >= 0; --j) {
            if (ans[i][j] != 0) {
                continue; // skip initialized
            }
            if (a[i][j]) {
                ans[i][j] = ans[i + 1][j] + ans[i][j + 1];
                ans[i][j] %= MOD;
            }
            else {
                ans[i][j] = 0;
            }
        }
    }
    cout << ans[0][0] << endl;

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mx = 1e5+5;
vector<int>edge[mx];
bool visit[mx];
int dis[mx],node,ed;
void dfs(int u)
{
    visit[u] = true;
    for(auto it:edge[u])
    {
        if(!visit[it])
            dfs(it);
        dis[u] = max(dis[u],1+dis[it]);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>node>>ed;
    for(int i=1;i<=ed;i++)
    {
        int u,v;
        cin>>u>>v;
        edge[u].push_back(v);
    }
    for(int i=1;i<=node;i++)
        dis[i] = 0;

    for(int i=1;i<=node;i++)
        if(!visit[i])
        dfs(i);
    int ans = 0;
    for(int i=1;i<=node;i++)
        ans = max(ans,dis[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8320
from collections import deque

def check(reverse_cnt, t):

    if reverse_cnt%2 == 0 and t == 1:
        return True
    elif reverse_cnt%2 == 0 and t == 2:
        return False
    elif reverse_cnt%2 == 1 and t == 1:
        return False
    elif reverse_cnt%2 == 1 and t == 2:
        return True

def solve(s, q, qs):
    reverse_cnt = 0

    for item in qs:

        if len(item) == 1:
            # T = 1 文字列を反転
            reverse_cnt += 1
        else:
            # T = 2

            if check(reverse_cnt, int(item[1])):
                # 先頭に追加
                s.appendleft(item[2])

            else:
                # 末尾に追加
                s.append(item[2])


    if reverse_cnt%2 == 1:
        ans = "".join(s)
        ans = ans[::-1]
    else:
        ans = "".join(s)

    return ans

if __name__ == '__main__':

    s = deque() # queue

    str = input()
    q = int(input())
    qs = [list(input().split()) for i in range(q)]

    s.append(str)

    ans = solve(s, q, qs)
    print(ans)


Measured memory_bytes: 34776
import collections

n = int(input())
a = list(map(int, input().split()))
b = collections.deque()

for i, num in enumerate(a):
    if i % 2 != 0:
        b.append(num)
    else:
        b.appendleft(num)

if n % 2 == 0:
    b.reverse()

print(*b)

Measured memory_bytes: 25412
#include <iostream>
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
using namespace std;



int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,n,k,m;
     ll t;
     cin>>n;
     map<ll,ll> m1;
     for(i=0;i<n-1;i++)
     {
         cin>>m;
         m1[m]++;
     }
     for(i=1;i<=n;i++)
         cout<<m1[i]<<"\n";
}


Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std;
#define R(a,b,c) for(a=b;a<=c;a++)
int H,W;
void print(vector<int>& a){
  int i,j;
  R(i,0,H+1){
    R(j,0,W+1){
      cout<<a[i*(W+2)+j];
    }
    cout<<endl;
  }
}

int main(){
  int i,j,cnt=0;
  cin>>H>>W;
  vector<int> smp((H+2)*(W+2),2);
  string ss;
  R(i,1,H){
    cin>>ss;
    R(j,1,W){
      if(ss[j-1]=='#'){
        smp[i*(W+2)+j]=1;
      }else{
        smp[i*(W+2)+j]=0;
        cnt++;
      }
    }
  }
  //print(smp);
  queue<int> que;
  que.push(W+3);
  smp[W+3]=1;
  smp[(W+2)*(H+1)-1]=4;
  int p,N,d[4]={1,-1,-2-W,W+2};
  cnt--;
  while(1){
    N=que.size();
    if(N==0){
      cout<<"-1";
      return 0;
    }
    while(N--){
      p=que.front();que.pop();
      R(i,0,3){
        if(smp[p+d[i]]==0){
          smp[p+d[i]]++;
          que.push(p+d[i]);
        }
        if(smp[p+d[i]]==4){
          cout<<cnt;
          return 0;
        }
      }
    }
    cnt--;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(void){
  int n,y;

  std::cin >> n >> y;

  for(int i=0; i<=n; i++){
    for(int j=0; j<=n-i; j++){
      int k = n-i-j;
      if(i*10000 + j*5000 + k*1000 == y){
        std::cout << i << " " << j << " " << k << std::endl;
        return 0;
      }
    }
  }
  std::cout << "-1 -1 -1" << std::endl;
  return 0;
}










Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 100000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0281 : Formation **/
int main()
{
	int Q;
	cin>>Q;
	rep(k, Q) {
		int c, a, n;
		cin>>c>>a>>n;
		int d = min(c, min(a, n)), ans=d;
		c -= d;
		a -= d;
		
		ans += min(c/2, a);
		c -= 2*min(c/2, a);
		
		ans += c/3;
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main()
{
    int64_t N;
    cin >> N;
    map<string, int64_t>d;
    d["west"] = 0;
    d["east"] = 0;
    d["okizari_west"] = 0;
    string S;
    cin >> S;
    for (int64_t i=0; i<N; i++) {
        if (S[i] == 'W') {
            d["west"] = d["west"] + 1;
        } else {
            d["east"] = d["east"] + 1;
        }
    }

    int64_t min_ = INT64_MAX;
    for (int64_t i=0; i<N; i++) {
        char c = S[i];
        int64_t n_c = 0;
        if (c == 'E') {
            n_c = 1;
        }

        int64_t num = d["east"] + d["okizari_west"] - n_c;
        if (min_ > num) {
            min_ = num;
        }

        if (c == 'W') {
            d["okizari_west"] += 1;
        } else if (c == 'E') {
            d["east"] -= 1;
        }
    }

    cout << min_ << endl;
    return 0;
}

Measured memory_bytes: 3928
#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 < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
typedef long long ll;


int main(){
  string s,t;
  cin >> s;
  cin >> t;
  map<char,char> StoT;
  map<char,char> TtoS;
  rep(i,26){
    StoT[(char)('a'+i)] = (char)('a'+i);
    TtoS[(char)('a'+i)] = (char)('a'+i);
  }
  char tmp;
  rep(i,s.size()){
    if(StoT[s[i]] != t[i]){
      rep(j,26){
        if(StoT[(char)('a'+j)] == t[i]){
          tmp = (char)('a'+j);
        }
      }
      StoT[tmp] = StoT[s[i]];
      StoT[s[i]] = t[i];
    }
  }
  // rep(i,26){
  //   cout << (char)('a'+i) << ' ';
  // }
  // cout << endl;
  // rep(i,26){
  //   cout << StoT[(char)('a'+i)] << ' ';
  // }
  // cout << endl;
  rep(i,s.size()){
    if(StoT[s[i]] != t[i] ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <limits>
#include <time.h>
#define inf 998244353

using namespace std;

int main(void){
    int a, b, c;
    scanf("%d%d%d",&a,&b,&c);
    if(c%(max(a,b))==0)
    {
        printf("%d\n",c/(max(a,b)));
    }
    else
    printf("%d\n",c/(max(a,b))+1);
	return 0;
}


Measured memory_bytes: 256
N, Q = map(int, input().split())
S = " " + input()
l = []
r = []
for _ in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
dp = [0] * (N + 2) #i文字目から何個ACがあるか
cnt = 0
for i in range(1, N):
    if S[-i] == "C" and S[-i-1] == "A":
            cnt += 1
    dp[N-i] = cnt
#print(dp)
ans = 0
for q in range(Q):
    ans = dp[l[q]] - dp[r[q] + 1]
    if r[q] < N:
        if S[r[q]] == "A" and S[r[q] + 1] == "C":
            ans -= 1
    print(ans)

Measured memory_bytes: 19228
#include <iostream>

using namespace std;

const int MAXN = 2e5+10;

int n;
string s;
int white[MAXN], black[MAXN];

void solve() {
  s = 'x' + s + 'x';
  for (int i=0;i<n+1;i++) {
    black[i+1] = black[i] + (s[i] == '#');
  }
  for (int i=n+1;i>0;i--) {
    white[i-1] = white[i] + (s[i] == '.');
  }
  int ans = MAXN;
  for (int i=1;i<=n;i++) {
    ans = min(ans, black[i] + white[i]);
  }
  cout << ans << endl;
}

int main() {
  cin >> n >> s;
  solve();
}


Measured memory_bytes: 2620
#include<iostream>
#include<stdlib.h>
using namespace std;
int compare(const void *a,const void *b);
int main(void){
    int data[3],i;
    for(i=0;i<3;i++){
        cin>>data[i];
    }
    qsort(data,3,sizeof(int),compare);
    cout<<data[0]<<" "<<data[1]<<" "<<data[2]<<endl;
    return 0;
}
    
int compare(const void *a,const void *b){
    return *(int *)a-*(int *)b;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const int mxN = 1e5 + 8;
vector<bool> seen(mxN, false);
vector<int> G[mxN];

void dfs(int u) {
	seen[u] = true;
	for (auto e : G[u]) {
		if (!seen[e]) dfs(e);
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y, z;
		cin >> x >> y >> z;
		x--, y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (!seen[i]) {
			ans++;
			dfs(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 8832
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int m, d;
    while (cin>>m>>d){
        if (m == 0) break;
        int dow = 3, num[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        vector<string> str;
        str.push_back("Monday");
        str.push_back("Tuesday");
        str.push_back("Wednesday");
        str.push_back("Thursday");
        str.push_back("Friday");
        str.push_back("Saturday");
        str.push_back("Sunday");

        int sum = 0;
        for (int i=0; i < m-1; i++)
            sum += num[i];
        sum += d+2;
        cout << str[sum%7] << endl;
    }
}


Measured memory_bytes: 3068
# encoding: utf-8
N = int(input())
A = list(map(int, input().split()))

A.sort()

ans = 0
for i, Ai in enumerate(A):
    # 0
    if i == 0:
        if Ai == 0: mode = 0
        elif Ai == 1: mode = 1
        else: break
        continue
    # > 1
    if mode == 0 and Ai != ((i + 1) // 2) * 2: break
    elif mode == 1 and Ai != 1 + (i // 2) * 2: break
    else: continue
else:
    ans = (2 ** (N // 2)) % (10 ** 9 + 7)

print(ans)
    

Measured memory_bytes: 13880
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
a=t1*a1+t2*a2
b=t1*b1+t2*b2
if a==b:
    print('infinity')
    exit()
if a>b:
    if a1>b1:
        print(0)
    else:
        m=b1-a1
        k=m*t1
        p=a-b
        q=1+(k//p)*2
        if k%p==0:
            q-=1
        print(q)
        
if a<b:
    if a1<b1:
        print(0)
    else:
        m=a1-b1
        k=m*t1
        p=b-a
        q=1+(k//p)*2
        if k%p==0:
            q-=1
        print(q)
        


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<ll,ll>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define iof  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define pi acos(-1)
const int mxn=1e9+5;
int main()
{
    fast;
    int n,m;
    cin>>n>>m;
    vector<int>vec(n),a(n);
    for(auto &i:vec)
    {
        cin>>i;
    }
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        a[u]=max(a[u],vec[v]);
        a[v]=max(a[v],vec[u]);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        if(vec[i]>a[i])ans++;
    }
    cout<<ans<<endl;
}



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;

// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max({b*d, a*c , a*d , b*c});
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

ll r[111111];
pair<ii,ii> func[111111]; //[l, r] => mn + l, < l mn, > r, mx
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll x; cin>>x;
	int n; cin>>n;
	vi V;
	V.pb(0);
	r[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>r[i];
		V.pb(r[i]);
	}
	for(int i=n;i>=1;i--)
	{
		r[i]-=r[i-1];
	}
	func[0] = mp(mp(0,x),mp(0,x));
	for(int i = 1; i <= n; i++)
	{
		func[i]=func[i-1];
		if(i&1)
		{
			//-r[i]
			if(func[i].se.fi>=r[i])
			{
				func[i].se.fi-=r[i];
				func[i].se.se-=r[i];
			}
			else
			{
				func[i].fi.fi = min(func[i].fi.fi+r[i]-func[i].se.fi,x);
				func[i].fi.se = max(func[i].fi.se,func[i].fi.fi);
				func[i].se.se = max(0LL, func[i].se.se - r[i]);
				func[i].se.fi=0;
			}
		}
		else
		{
			//+r[i]
			if(func[i].se.se+r[i]<=x)
			{
				func[i].se.fi+=r[i];
				func[i].se.se+=r[i];
			}
			else
			{
				func[i].fi.se = max(0LL, func[i].fi.se - func[i].se.se + x - r[i]);
				func[i].fi.fi = min(func[i].fi.fi,func[i].fi.se);
				func[i].se.se = x;
				func[i].se.fi = min(x, func[i].se.fi + r[i]);
			}
		}
	}
	int q; cin>>q;
	while(q--)
	{
		ll t, v; cin>>t>>v;
		int z = upper_bound(V.begin(),V.end(),t) - V.begin();
		z--;
		//V[z] <= t
		ll l = func[z].fi.fi;
		ll r = func[z].fi.se;
		ll mn = func[z].se.fi;
		ll mx = func[z].se.se;
		ll cur = 0;
		if(v<l)
		{
			cur = mn;
		}
		else if(v>r)
		{
			cur = mx;
		}
		else
		{
			cur = mn + v - l;
		}
		t -= V[z];
		if(z&1) //add t
		{
			cur+=t;
			if(cur>x) cur=x;
		}
		else
		{
			cur-=t;
			if(cur<0) cur=0;
		}
		cout<<cur<<'\n';
	}
}


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

int main(){
    int S, s, m, h;
    cin >> S;
    h = S / 3600;
    m = (S % 3600) / 60;
    s = ((S % 3600) % 60);
    cout << h << ":" << m << ":" << s << endl;
}



Measured memory_bytes: 3088
#include<stdio.h>

   int main(void){
   int a,b,c;
   scanf("%d %d %d", &a, &b , &c);
   int max = a;
   if (b > max) max = b;
   if (c > max) max = c;
   printf("%d\n", a + b + c - max);
   return (0);
}




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

using namespace std;

#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

ll modpow(ll a, ll b){

    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%mod;
        }
        a=(a*a)%mod;
        b=b/2;
    }
    return ans;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin>>n;

    map<string, int> mp;

    int tot = 0;

    for(int i = 0; i < n; i++) {
        string s;
        cin>>s;
        int t;
        cin>>t;
        tot += t;
        mp[s] = tot;
    }

    string x;
    cin>>x;

    cout<<tot - mp[x]<<endl;

    


}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

As = [0] * (n + 1)
Bs = [0] * (m + 1)
for i in range(n):
  As[i + 1] = A[i] + As[i]
for i in range(m):
  Bs[i + 1] = B[i] + Bs[i]

l = 0
r = n + m + 1
while r - l > 1:
  p = (l + r) // 2
  best = k + 1
  for i in range(p + 1):
    if min(i, n) + min(p - i, m) < p:
      continue
    best = min(best, As[i] + Bs[p - i])
  if best <= k:
    l = p
  else:
    r = p
print(l)

Measured memory_bytes: 118124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
 while(A>0 && C>0){
    C=C-B;
   if(C<=0)break;
    A=A-D;
   if(A<=0)break;
  }
  if(A<=0){cout << "No" << endl;}
  else{cout << "Yes" << endl;}
}

Measured memory_bytes: 3624
def answer_143b(): 
    n = int(input())

    # mapでintに変換したものをさらにlist化する
    dl = list(map(int,input().split()))

    sum = 0

    for i in range(n):
        for j in range(n):
            if i == j :
                break
            sum = sum + (dl[i] * dl[j])
    print(sum)

if __name__ == '__main__':
    answer_143b()

Measured memory_bytes: 3060
N = int(input())
A = list(map(int, input().split()))
a =[[] for i in range(N)]
for i in range(N):
    a[i] =[A[i], i+1]
a.sort()
ans = [0 for i in range(N)]
for i in range(N):
    ans[i] = a[i][1]
print(*ans)

Measured memory_bytes: 23628
import math

n = int(input())

dig_max = math.floor(math.log10(n))

num = 0
for i in range(0, dig_max, 2):
    num += 9 * (10**i)

if dig_max % 2 == 0:
    num += n - 10**dig_max + 1

print(num)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
	char a,b;
  	cin>>a>>b;
  	if(a>b){
		cout<<'>'<<endl;
    }else if(a<b){
		cout<<'<'<<endl;
    }else{
		cout<<'='<<endl;
    }
}


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

int main() {
  int x,y;
  cin >> x >> y;
  if(x==2||y==2)
    cout << "No" << endl;
  else{
    long long s,t;
    s=(x-4)*(x-6)*(x-9)*(x-11);
    t=(y-4)*(y-6)*(y-9)*(y-11);
    if((s==0&&t==0)||(s!=0&&t!=0))
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#define swap(x, y) (x += y,y = x - y,x -= y)

int gcd(int,int);

int main(){
    int x, y;
    scanf("%d %d",&x ,&y);
    printf("%d\n",gcd(x, y));
    
    return 0;
}

int gcd(int x, int y){
    int r;
    // always must be x > y
    if (x < y) {
        swap(x,y);
    }
    // Euclidean Algorithm
    while (y > 0) {
        r = x % y;
        x = y;
        y = r;
    }
    
    return x;
}



Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define ull unsigned long long
#define eps (1e-6)
using namespace std;
const int N = 1e5;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a>8||b>8)
    {
        puts(":(");
    }
    else
    {
        puts("Yay!");
    }
    return 0;
}


Measured memory_bytes: 256
import math
a=[]
a1=[]
f=0
for i in range(5):
    a.append(int(input()))
    a1.append(math.ceil(a[i]/10)*10)
    if 10-a[i]%10>=f and a[i]%10!=0:
        f=10-a[i]%10
        
print(sum(a1)-f)


Measured memory_bytes: 3060
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String[] hiki = scan.nextLine().split(" ");
    int n = Integer.parseInt(hiki[0]);
    int w = Integer.parseInt(hiki[1]);
    int[] weight = new int[n];
    int[] value = new int[n];
    int maxV = 0;
    for(int i = 0;i < n;i ++){
      hiki = scan.nextLine().split(" ");
      weight[i] = Integer.parseInt(hiki[0]);
      value[i] = Integer.parseInt(hiki[1]);
      maxV += value[i];
    }
    long[][] dp = new long[n][maxV + 1];
    dp[0][value[0]]=weight[0];
    for(int i = 1;i < n;i ++){
      for(int j = 0;j < maxV;j ++){
        if(dp[i-1][j] > 0){
          if(dp[i][j] > 0)dp[i][j] = Math.min(dp[i-1][j], dp[i][j]);
          else dp[i][j] = dp[i-1][j];
          if(dp[i-1][j]+weight[i] <= w){
            if(dp[i][j+value[i]] > 0)
          	dp[i][j+value[i]] = Math.min(dp[i-1][j] + weight[i],dp[i][j+value[i]]);
            else dp[i][j+value[i]] = dp[i-1][j] + weight[i];
          }
        }
      }
      if(dp[i][value[i]] > 0)
        dp[i][value[i]] = Math.min(weight[i], dp[i][value[i]]);
      else dp[i][value[i]] = weight[i];
    }
    long max = 0;
    for(int i = 0;i < maxV + 1;i ++){
      if(dp[n-1][i] > 0 && dp[n-1][i] <= w) max = i;
    }
    System.out.println(max);
  }
}


Measured memory_bytes: 125804
#include <iostream>
using namespace std;
int n;
int q;

struct Node {
    Node *p;
    int val;
};

Node nodes[10000];

Node *find_root(int x) {
   Node *nd = nodes;
   while(nd->val != x) nd++;

   while(nd->p != nd) nd = nd->p;
   return nd;
}

void unite(int x, int y) {
    Node *xr = find_root(x);
    Node *yr = find_root(y);
    xr->p = yr;
}

bool same(int x, int y) {
    int xr = find_root(x)->val;
    int yr = find_root(y)->val;
    if(xr == yr) return true;
    else return false;
}
int main() {
    cin >> n >> q;
    for (int i = 0; i < n; ++i) {
        nodes[i].p = &nodes[i];
        nodes[i].val = i;
    }
    for (int j = 0; j < q; ++j) {
        int cmd, x, y;
        cin >> cmd >> x >> y;
        if (cmd == 0) {
            unite(x, y);
        } else {
            if(same(x, y)) {
                cout << 1 << endl;
            } else {
                cout << 0 << endl;
            }
        }
    }


    return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

int counter = 0;

int get(int i){
    ++counter;
    if (20 < counter) exit(1);

    cout << i << '\n';
    fflush(stdout);
    string res;
    cin >> res;
    fflush(stdout);
    if (res == "Vacant") exit(0);
    if (res == "Male") return 0;
    else return 1;
}

void solve(int l, int r, int lc, int rc){
    if (l == r) return;

    if (l + 2 == r){
        get(l);
        get(l + 1);
        get(l + 2);
    }

    int m = (l + r) / 2;
    if ((r - m + 1) % 2 == 0) ++m;

    int mc = get(m);
    if (lc != mc){
        solve(l, m, lc, mc);
    }
    else{
        solve(m, r, mc, rc);
    }
}

signed main(){
    int n;
    cin >> n;
    
    int lc = get(0);
    int rc = get(n - 1);

    solve(0, n - 1, lc, rc);

    return 0;
}

Measured memory_bytes: 852
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int a,b;
  cin>>a>>b;
  if(b%a==0){
    cout<<-1<<endl;
    return 0;
  }
  Int ans=a*b+1;
  for(Int y=0;y<=a;y++){
    // Ax = By + k
    {
      Int k=(a-(b*y)%a)%a;
      Int x=(b*y+k)/a;
      if(x<y+k) chmin(ans,a*x);
    }
    // Ax + k = By
    if(y){
      Int k=(b*y)%a;
      Int x=(b*y-k)/a;
      if(x+k<y) chmin(ans,a*x);
    }
  }
  if(ans>a*b) ans=-1;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3104
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io"
	"math/big"
	"os"
)

var reader *bufio.Reader
var writer *bufio.Writer

var inputFile = flag.String("input", "", "")

func init() {
	flag.Parse()
	var i io.Reader
	if *inputFile != "" {
		i, _ = os.Open(*inputFile)
	} else {
		i = os.Stdin
	}
	reader = bufio.NewReaderSize(i, 1<<20)
	writer = bufio.NewWriterSize(os.Stdout, 1<<20)
}

func println(a ...interface{}) {
	_, _ = fmt.Fprintln(writer, a...)
}

func printf(format string, a ...interface{}) {
	_, _ = fmt.Fprintf(writer, format, a...)
}

func scanf(format string, a ...interface{}) {
	_, _ = fmt.Fscanf(reader, format, a...)
}

func scan(a interface{}) {
	_, _ = fmt.Fscan(reader, a)
}

func NextInt64() int64 {
	var res int64
	scan(&res)
	return res
}

func NextInt() int {
	var res int
	scan(&res)
	return res
}


func NextIntArray(n int) []int {
	res := make([]int, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		scan(&res[i])
	}
	return res
}

func NextString() string {
	var res string
	scan(&res)
	return res
}

func NextBigInt() *big.Int {
	n := new(big.Int)
	n, _ = n.SetString(NextString(), 10)
	return n
}

func AbsInt64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func MinInt64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func MaxInt64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func MaxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer writer.Flush()

	n := NextInt()

	p := make([]float64, n)

	for i := range p {
		scan(&p[i])
	}

	dp := make([]float64, n + 1)

	dp[0] = 1

	for _, x := range p {
		for j := n; j >= 1; j-- {
			dp[j] = x * dp[j - 1] + (1 - x) * dp[j]
		}
		dp[0] = (1 - x) * dp[0]
	}


	answer := 0.0

	for i := 0; i <= n; i++ {
		if i > n - i {
			answer += dp[i]
		}
	}
	printf("%.10f\n", answer)
}


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

int main() {
  int N;
  cin >> N;
  int s[N];
  vector<int> arr(N+1, 0);
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    sum += s[i];
  }
  sort(s, s + N);
  for (int i = 0; i < N; i++) {
    arr[i+1] += s[i];
  }
  for (int i = 1; i < N + 1; i++) {
    arr[i] += arr[i-1];
  }
  int ans = 0;
  if (sum % 10 != 0) ans = sum;
  for (int i = 1; i < N; i++) {
    for (int j = i; j < N + 1; j++) {
      if ((sum - (arr[j] - arr[j-i])) % 10 != 0) {
        ans = max(ans, sum - (arr[j] - arr[j-i]));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int N;
string s;

signed main(){
  cin>>N;
  map<char,int>mp;
  for(int t=0;t<N;t++){
    cin>>s;
    mp[s[0]]++;
  }

  int ans=mp['M']*(mp['A']*(mp['R']+mp['C']+mp['H'])+mp['R']*(mp['C']+mp['H'])+mp['C']*mp['H']);
      ans+=mp['A']*(mp['R']*(mp['C']+mp['H'])+mp['C']*mp['H']);
      ans+=mp['R']*mp['C']*mp['H'];

  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
answer = set([])
for i in range(N):
  K_A = [int(x) for x in input().split()]
  K = K_A[0]
  A = K_A[1:]
  if i==0:
    answer = answer.union(set(A))
  else:
    answer = answer.intersection(set(A))
 
print(len(answer))

Measured memory_bytes: 3060