akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX 100050

#define ll long long
#define ld long double
#define lli long long int

#define pb emplace_back
#define INF 1000000000000

#define mod 1000000007

// trignometric function always give value in Radians only
#define PI acos(-1) //3.1415926535897932384626433832795028
#define dsin(degree) sin(degree*(PI/180.0))
#define dcos(degree) cos(degree*(PI/180.0))
#define dtan(degree) tan(degree*(PI/180.0))

#define rsin(radian) sin(radian)
#define rcos(radian) cos(radian)
#define rtan(radian) tan(radian)

#define loop(i,n) for (lli i = 0; i < n; i++)
#define loopitr(xt,vec) for (auto xt : vec)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define itr :: iterator it
#define WL(t) while(t --)

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) int(x.size())
#define F first
#define S second

#define mii map<lli,lli>
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define vbool vector<bool>
#define seti set<lli>
#define pii pair<lli,lli>
#define pcc pair<char , char>

#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (a/gcd(a,b))*b
#define abs(x) ((x < 0)?-(x):x)

#define endl '\n'

template <typename T>
void print(T x){cout<<x<<endl;}
template <typename T1, typename T2>
void print2(T1 x,T2 y){cout<<x<<" "<<y<<endl;}
template <typename T1, typename T2,typename T3>
void print3(T1 x, T2 y,T3 z){cout<<x<<" "<<y<<" "<<z<<endl;}

#define scanarr(a,n) for(lli i=0;i<n;i++)    cin>>a[i];
#define scanvector(a,n) for(lli i=0;i<n;i++){ lli x ; cin>>x; a.pb(x);}

#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" "; cout<<endl;
#define printvector(vec) for(auto xt : vec) cout<<xt<<" ";    cout<<"\n";

#define FD(N) fixed<<setprecision(N)

#define deb(x) cout<<#x<<" "<<x<<endl;


void solve(){
    lli n; cin>>n;
    lli ans=0;
    for(int i=1;i<n;i++){
        for(int j=1;i*j<n;j++)
            ans++;
    }
    cout<<ans<<endl;
}
int main(){
	fastio
	lli t=1;
	while(t--){
		solve();
		
	}
	return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    int N,K; cin>>N>>K;
    vector<int> cnt(N);
    REP(i,N){
        int a; cin>>a;
        cnt[a-1]++;
    }
    sort(ALL(cnt));

    int ans=0;
    REP(i,N-K){
        ans+=cnt[i];
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007


void solve(void)
{ 
  string A,B,C;
  cin>>A;
  cin>>B;
  cin>>C;
  cout<<A[0]<<B[0]<<C[0]<<endl;
}



int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // std::cout << std::fixed;
  // std::cout << std::setprecision(8);

  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
int main(){  
int length = 0;  
int height = 0;  
int area = 0;  
int cir = 0;   
scanf("%d %d", &length, &height);  
area = length * height;  
cir = length*2 + height*2;   
printf("%d %d\n", area, cir);   
return 0;
}

Measured memory_bytes: 596
#include <iostream>
  #include <complex>
  #include <vector>
  #include <string>
  #include <algorithm>
  #include <cstdio>
  #include <numeric>
  #include <cstring>
  #include <ctime>
  #include <cstdlib>
  #include <set>
  #include <map>
  #include <unordered_map>
  #include <unordered_set>
  #include <list>
  #include <cmath>
  #include <bitset>
  #include <cassert>
  #include <queue>
  #include <stack>
  #include <deque>
 #include <iomanip>
 
  using namespace std;
   

//abcdefghijklmnopqrstuvwxyz
//ABCDEFGHIJKLMNOPQRSTUVWXYZ
  typedef long long ll;
  typedef long double lld;
//   typedef string str;
//   typedef unsigned long long ull;
  ll INF = INT_MAX;
  ll mod = 1000000007;
  // lld PI = 3.141592653;

// const int N = 2e5 + 5;

// int a[N];
// int n,k;

set<ll> all;

void go(ll num, int len){
  
  if (len==0){

    all.insert(num);
    return;
  }
  if (num%10==0){
    go(num*10, len-1);
    go(num*10+1, len-1);
  }else if (num%10==9){
    go(num*10+9, len-1);
    go(num*10+8, len-1);
  }else{
    go(num*10 + num%10, len-1);
    go(num*10 + num%10-1, len-1);
    go(num*10 + num%10+1, len-1);
  }
}

void make(int len){
  for (int i = 1; i<=9;i++){
    // cout<<i<<" "<<len<<endl;
    go(i, len-1);
  }
}


  int main()
  {
      ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
      
      int k;
      cin>>k;
      int len = 1;
      while(all.size()<k){
        make(len);
        len++;
      }

      
      set<ll>::iterator it;
      it = all.begin();
      // while (it!=all.end()){
      //   cout<<*it<<endl;
      //   it++;
      // }

      while (k!=1){
        k--;
        // cout<<*it<<endl;
        it++;
      }
      cout<<*it<<"\n";
     

      
}
  

Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
int main(){
  unsigned long long flg = 0;
  int n;
  cin >> n;
  vector<unsigned long long> M(n, 0);
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    for (int j = 0; j < k; j++){
      int b;
      cin >> b;
      M[i] |= (1LL << b);
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int t;
    cin >> t;
    if (t == 0){
      int i;
      cin >> i;
      cout << ((flg >> i) & 1LL) << endl;
    } else {
      int m;
      cin >> m;
      if (t == 1) flg |= M[m];
      if (t == 2) flg &= (~M[m]);
      if (t == 3) flg ^= M[m];
      if (t == 4) cout << ((flg & M[m]) == M[m]) << endl;
      if (t == 5) cout << ((flg & M[m]) != 0) << endl;
      if (t == 6) cout << ((flg & M[m]) == 0) << endl;
      if (t == 7) cout << __builtin_popcountll(flg & M[m]) << endl;
      if (t == 8) cout << (flg & M[m]) << endl;
    }
  }
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);	
}
ll gcd(ll a,ll b)
{
	int p=a,q=b;
	return (ll)__gcd(p,q);
}
ll lcm(ll a,ll b)
{
	return (a*b)/gcd(a,b); 
}
int f(int x)
{
	int re=0;
	while(x%2==0){
		x/=2;re++;
	}
	return re;
}
int main()
{
	//fopen();
	int n,m;
	cin>>n>>m;
	//cou t<<1;
	ll a[n],p=1;
	rep(i,n)cin>>a[i];
	int r=f(a[0]);
	rep(i,n-1)
	{
		if(f(a[i+1])!=r){cout<<0;return 0;}
	}
	rep(i,n){p=lcm(a[i]/2,p);}
	//cout<<1;
	ll c=m/p;
	cout<<(c+1)/2;
	//cout<<c;
}


Measured memory_bytes: 1024
using System;
//using System.Text;
namespace AIZU_Cs_
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y;
            string s = Console.ReadLine();
            string[] v=s.Split(' ');
            x = int.Parse(v[0]);
            y = int.Parse(v[1]);
            Console.WriteLine("{0} {1}",x*y,2*(x+y));
        }
    }
}

Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define M 1000000007
#define pb push_back
#define boost ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define NAYAN freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);



int dp[100001];
int a[100001];
int n,k;

int solve(int i)
{
    if(i==n)
        return 0;
    if(i>n)
        return 9999999999;
    if(dp[i]!=-1)
        return dp[i];
    int x=99999999999999,y;
    for(int j=1;j<=k;j++)
    {
        x=min( x,abs(a[i]-a[i+j])+solve(i+j) );
    }

    dp[i]=x;
    return dp[i];
}
signed main()
{
    boost
    //#ifndef ONLINE_JUDGE 
    //NAYAN
   // #endif
   
    //int n;
    cin >> n >> k;
   // int a[n];
    memset(dp,-1,sizeof(dp));
    int i;
    for(i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    int ans=solve(1);
    cout << ans << endl;

}






















Measured memory_bytes: 6528
A,B,C = map(int,input().split())
K = int(input())

while True:
    if A < B:
        break
    else:
        B *= 2
        K -= 1

while True:
    if B < C:
        break
    else:
        C *= 2
        K -= 1

print('Yes' if K >= 0 else 'No')

Measured memory_bytes: 9172
#include <stdio.h>

int main(void){
	
	int a[5] = {0};
	int i;
	int avg=0;
	
	for(i=0; i<5; i++) {
		scanf("%d", &a[i]);
		if(a[i]<40) a[i]=40;
		avg += a[i];
	}
	
	printf("%d\n", avg/5);

	return 0;
}

Measured memory_bytes: 600
//#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define I inline
//#define R register int
namespace io{
    const int l=1<<19;
    char buf[l],*s,*t,c;
    char gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            return s==t?EOF:*s++;
        }
        return *s++;
    }
    template<class IT>void gi(IT &x){
        x=0;c=gc();while(c<'0'||c>'9')c=gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gc();}
    }
};
using io::gi;
template<class IT>void chkmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>void chkmax(IT &a,IT b){if(a<b)a=b;}

const int N=200005;

int n,t,a[N],b[N];
long long ans;
char s[N];
void solve(int l,int r){
	int c=0;
	for(int i=l;i<r;i++){
		if(a[i]==1)++c;
		else ans+=c;
	}
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='A')a[++t]=1;
		else if(s[i]=='B'&&s[i+1]=='C'){a[++t]=2;++i;}
		else a[++t]=3;
	}
	for(int i=1,j=1;i<=t;i=j){
		if(a[i]!=3){
			while(j<=t&&a[j]!=3)++j;
			solve(i,j);
		}else ++j;
	}
	printf("%lld",ans);
	return 0;
}

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

int main(){
    int n,y;
    cin >> n >> y;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i+j>n)continue;
            if(i*10000+j*5000+(n-i-j)*1000==y){
                cout << i << " " << j << " " << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

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, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a - b, 0) << endl;
}

Measured memory_bytes: 256
import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
    A[i] *= -1
heapq.heapify(A)
for i in range(M):
    m = heapq.heappop(A)
    m = -((m*(-1))//2)
    heapq.heappush(A,m)
print(-sum(A))

Measured memory_bytes: 72300
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	long a,b,c,d,i,n,arr[3];
		cin>>a>>b;
		string s[1000];
		for(i=0;i<a;i++)
		{
		    cin>>s[i];
		}
		sort(s,s+a);
		for(i=0;i<a;i++)
		cout<<s[i];
		
 	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll m=n%k;
    ll r=min(m,abs(m-k));
    cout<<r<<'\n';
    return 0;
}

Measured memory_bytes: 256
#factorial
MOD = 998244353 
N = 1000000
modinv_t = [0, 1]
modfact_t = [1, 1]
modfactinv_t = [1, 1]
for i in range(2,N+1):
  modfact_t.append(modfact_t[-1] * i % MOD)
  modinv_t.append(modinv_t[MOD%i] * (MOD-(MOD//i)) % MOD)
  modfactinv_t.append(modfactinv_t[-1] * modinv_t[-1] % MOD)
# permutation
def nPr(n, r):
  return  modfact_t[n] * modfactinv_t[n-r] % MOD
# combination
def nCr(n, r):
  return  modfact_t[n] * modfactinv_t[n-r] * modfactinv_t[r] % MOD
#
def nHr(n, r):
  return  nCr(n+r-1,r)
#

N, M, K = map(int, input().split()) 

t = M*pow(M-1,N-1,MOD) % MOD
for i in range(1,K+1):
  t += M*pow(M-1,N-1-i,MOD)*nCr((N-1),i)
  t %= MOD
#
print(t)


Measured memory_bytes: 127680
use std::io;
use std::collections::HashSet;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v: Vec<i32> = procon_read();
	let s = v[0];
	let mut set = HashSet::new();
	let mut ai = s;
	set.insert(ai);
	for i in 2.. {
		if ai%2 == 0 {
			ai = ai / 2;
		}else{
			ai = 3*ai + 1;
		}
		if !set.insert(ai) {
			println!("{}", i);
			break;
		}
	}
}

Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <complex>
#include <cassert>

#define enp     puts("**chkchkchkchkchk**")
#define A       first
#define B       second
#define MP      make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;

const int INF = 0x60000000;
const int MINF = -1000000000;
const int mod = 99999997;
const ll cons = 100000000000;
const double pi = 3.141592653589793;



int main()
{
	int n;
	scanf("%d", &n);

	int cur = 1;
	ll ans = 0;

	int x;
	scanf("%d", &x);
	ans += ((ll)x - 1);
	for (int i = 1; i < n; i++)
	{
		int x;
		scanf("%d", &x);

		if (x == cur + 1)
		{
			cur++;
			continue;
		}

		if (x % (cur + 1) == 0)
		{
			ans += (ll)(x / (cur + 1) - 1);
		}
		else
		{
			ans += (ll)(x / (cur + 1));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <sys/stat.h>
#include <stdio.h>
#include <vector>
#include <cmath>
#include <random>
#include <string.h>      //文字列の代入に使う
#include <bits/stdc++.h> //piの利用で必要(M_PI)
#include <algorithm>

int main()
{

    int N;
    std::cin >> N;

int temp = N % 10;
if(temp == 2 ||temp == 4||temp == 5||temp == 7||temp == 9)std::cout<<"hon"<<std::endl;
else if(temp == 0 ||temp == 1||temp == 6||temp == 8)std::cout<<"pon"<<std::endl;
else if(temp == 3)std::cout<<"bon"<<std::endl;


    
    //std::cout << -1 << std::endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	static int mod = 1000000007;
	static long[]fac;
	static long []finv;
	static int n,k;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = Integer.parseInt(sc.next());
		k = Integer.parseInt(sc.next());
		fac = new long [n+1];
		finv = new long [n+1];
		
		long ans = 0;
		COMinit();
		
		if(k == 1) {
			ans = COM(n-1,1) * n % mod;
			System.out.println(ans);
			return;
		}
		
		for(int i = 0 ; i <= Math.min(n-1, k) ;i++) {
			long temp = COM(n-1,i)*COM(n,i)%mod;
		//	System.out.println(temp);
			ans = (ans + temp)% mod;
		}
		System.out.println(ans);

	}

	public static void COMinit() {
	    fac[0] = fac[1] = 1;
	    finv[0] = finv[1] = 1;
	    for (int i = 2; i <= n; i++){
	        fac[i] = fac[i - 1] * i % mod;
	        finv[i] = finv[i - 1] * Modpow(i,mod-2) % mod;
	    }
	}
 
	// 二項係数計算
	public static 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;
	}
 
	//a^n mod
	public static long Modpow(long a, long n) {
		long res = 1;
		while(n > 0) {
			if((n & 1) == 1) {
				res = res * a % mod;
			}
			a = a * a % mod;
			n >>= 1;
		}
		return res;
	}
	


}


Measured memory_bytes: 26068
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h> /*限界*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

//abc 159 D

int main(void)
{
  int N;
  LL array[200001]; //array[i] := Ai
  LL b[200001] = {0};     //b[i] := iが出てきた回数
  LL  c[200001] = {0};     //c[i] := iが選ばれたときの組み合わせの数 - iが選ばれなかったときの組み合わせの数(０以下の値になる)
  LL sum = 0; //Aiに含まれる組み合わせの総数

  //入力
  if(scanf("%d", &N));

  for (size_t i = 0; i < N; i++) {
    if(scanf("%lld", &array[i]));
    b[array[i]]++;
  }

  sum = 0;
  for (size_t i = 1; i <= N; i++) {//1<=Ai<=Nより
    c[i] = ((b[i] - 2) * (b[i] - 1) / 2) - ((b[i] - 1) * b[i] / 2);
    sum += (b[i] - 1) * b[i] / 2;
  }

  //出力
  for (size_t i = 0; i < N; i++) {
    printf("%lld\n", c[array[i]] + sum );
  }
  return 0;
}


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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
  public static void Ans() {

			var inputArray = retreiveStringArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var S = inputArray[0].Select(x => x-'a').ToArray();
			var T = retreiveStringArray()[0].Select(x => x - 'a').ToArray(); ;
			//var S = string.Join("",Enumerable.Repeat("abcdefgg", 1000));
			//var T = string.Join("", Enumerable.Repeat("abcdefkk", 1000));

			var taiou = new Dictionary<int, int>();


			for (int i = 0; i < S.Count(); i++) {

				var s = S[i];
				var t = T[i];

				if (!taiou.ContainsKey(s)) {
					if (taiou.ContainsValue(t)) {
						Console.WriteLine("No");
						return;
					}

					taiou.Add(s, t);
					continue;
				}

				if (t != taiou[s]) {
					Console.WriteLine("No");
					return;
				}

			}

			//答えの出力
			var ans = "Yes";
			Console.WriteLine(ans);

		}


		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}



Measured memory_bytes: 31048
n=int(input())

A=list(map(int,input().split()))

C=[0]*9

for i in A:
    x=i//400
    if x<8:
        C[x]=1
    else:
        C[8]+=1
b=sum(C[:8])
print(str(max(b,1))+' '+str(b+C[8]))

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



int main(){
  string S,T;
  cin>>S>>T;
  int flag=1;
  if(S.size()+1!=T.size()){
    flag=0;
  }
  for(int i=0;i<T.size()-1;i++){
    if(S[i]!=T[i]){
      flag=0;
    }
  }
  if(flag==1){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
}


Measured memory_bytes: 3592
# 累積和, 二分探索
from itertools import accumulate
from bisect import bisect_right

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a = [0] + list(accumulate(A))
b = [0] + list(accumulate(B))

result = 0
for i in range(N + 1):
    if a[i] > K:
        break
    j = bisect_right(b, K - a[i])
    result = max(result, i + j - 1)
print(result)


Measured memory_bytes: 50584
a=int(input())
b=[int(j) for j in input().split()]
c=True
d=0
while c==True:
  for i in range(len(b)):
    if b[i]%2!=0:
      c=False
    else :
      b[i]=b[i]//2
  if c==True:
    d+=1
    
print(d)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
int main() {
	int n, m, y;
	std::vector<int> a,sum;
	std::cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x;
		std::cin >> x;
		a.push_back(x);
	}
	for (int i = 0; i < n; i++) {
		sum.push_back(0);
	}
	for (int i = 0; i < m; i++) {
		y = 0;
		for (int j = 0; j < n; j++) {
			int x;
			std::cin >> x;
			if (x == a[i]) {
				sum[j] += 1;
			}
			else {
				y += 1;
			}
		}
		sum[a[i]-1] += y;
	}
	for (int i = 0; i < n; i++) {
		std::cout << sum[i] << std::endl;
	}
}


Measured memory_bytes: 3148
n,m = map(int,input().split())
ls = [[x for x in input() + '#'] for i in range(n)] + [['#']*(m+1)]
yokodp = [[0 for x in range(m+1)] for i in range(n+1)]
for i in range(n+1):
    yoko = 0
    for j in range(m+1):
        if ls[i][j] == '#':
            yokodp[i][j] = yoko
            yoko = 0
        else:
            yoko += 1
for i in range(n,-1,-1):
    check = 0
    for j in range(m,-1,-1):
        if yokodp[i][j] != 0:
            check = yokodp[i][j]
        if ls[i][j] == '.':
            yokodp[i][j] = check
tatedp = [[0 for x in range(m+1)] for i in range(n+1)]            
for j in range(m+1):
    tate = 0
    for i in range(n+1):
        if ls[i][j] == '#':
            tatedp[i][j] = tate
            tate = 0
        else:
            tate += 1
for j in range(m,-1,-1):
    for i in range(n,-1,-1):
        if tatedp[i][j] != 0:
            check = tatedp[i][j]
        if ls[i][j] == '.':
            tatedp[i][j] = check
ans = 0
for i in range(n):
    for j in range(m):
        if ls[i][j] == '.':
            ans = max(ans,tatedp[i][j] + yokodp[i][j] - 1)
print(ans)

Measured memory_bytes: 249432
import fractions
a, b, c, d = map(int,input().split())
print(b - a + 1 - (b // c + b // d - b // ((c * d) // fractions.gcd(c, d)) - ((a-1) // c + (a-1) // d - (a-1) // ((c * d) // fractions.gcd(c, d)))))

Measured memory_bytes: 5432
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define N 1010
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,a[N],k,now,ans[N];
const vector<int> inf(1,23333);
bool check(){
	int x=*max_element(a+1,a+k+1);
	int y=*min_element(a+1,a+k+1);
	return x<=(y<<1);
}
void Merge(vector<int> &a,vector<int> &b,vector<int> &c){
	int pa=0,pb=0;
	while(pa<(int)a.size()&&pb<(int)b.size()){
		c.push_back(a[pa]<b[pb]?a[pa++]:b[pb++]);
	}
	while(pa<(int)a.size())c.push_back(a[pa++]);
	while(pb<(int)b.size())c.push_back(b[pb++]);
}
vector<int> Solve(int len){
	static int vis[N],b[N];
	for(int i=1;i<=k;++i){
		vis[i]=0,b[i]=a[i];
	}
	for(int i=now+len-k+1;i<=now;++i){
		vis[ans[i]]=1;
	}
	for(int i=1;i<=k;++i){
		if(!vis[i])if((--b[i])<0)return inf;
	}
	int mn=*min_element(b+1,b+k+1);
	int mx=*max_element(b+1,b+k+1);
	if(mn*2+1<mx)return inf;
	vector<int> res;
	if(mn*2>=mx){
		for(int i=1;i<=k;++i){
			if(!vis[i])res.push_back(i);
		}
	}
	else{
		vector<int> A,B;
		for(int i=1;i<=k;++i){
			if(!vis[i]&&b[i]==mx)A.push_back(i);
		}
		for(int i=1;i<=k;++i){
			if(!vis[i]&&b[i]==mn)A.push_back(i);
		}
		for(int i=1;i<=k;++i){
			if(!vis[i]&&b[i]^mn&&b[i]^mx)B.push_back(i);
		}
		Merge(A,B,res);
		int pmx=0,pmn=n+1;
		for(int i=now+len-k+1;i<=now;++i){
			if(b[ans[i]]==mx)pmx=max(pmx,i);
			if(b[ans[i]]==mn)pmn=min(pmn,i);
		}
		for(int i=0;i<(int)res.size();++i){
			if(b[res[i]]==mx)pmx=max(pmx,i+now+1);
			if(b[res[i]]==mn)pmn=min(pmn,i+now+1);
		}
		if(pmx>pmn)res=inf;
	}
	return res;
}
void Extend(){
	vector<int> ext=inf;
	for(int len=1;len<=k&&len+now<=n;++len){
		if(len+now>=k){
			ext=min(ext,Solve(len));
		}
	}
	for(auto x:ext){
		ans[++now]=x;
		--a[x];
	}
}
int main(){
	k=read();
	for(int i=1;i<=k;++i){
		n+=a[i]=read();
	}
	if(!check()){
		puts("-1");
		return 0;
	}
	while(now<n){
		Extend();
	}
	for(int i=1;i<=n;++i){
		printf("%d ",ans[i]);
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n,m,c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rep(i,m) cin >> b[i];
    int ans = 0;
    rep(i,n){
        int cnt = 0;
        rep(j,m){
            int a;
            cin >> a;
            cnt+=(a*b[j]);
        }
        if (cnt + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String line = sc.nextLine();
    char [] answer ;
    answer = new char [1200];
    int n = line.length();
    for(int i=0;i<n;i++){
      char k = line.charAt(i);
      if(Character.isLowerCase(k) == true){
        //Char toUpperCase(char k);
        answer[i] = Character.toUpperCase(k);
      } else {

        answer[i] = Character.toLowerCase(k);
      }
      System.out.print(answer[i]);
    }
    System.out.println();
    sc.close();
  }
}



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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if((a==b&&b!=c)||(b==c&&c!=a)||(c==a&&a!=b)){
     cout << "Yes" << endl;
  }
  else {
     cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String ans = "Sunny";
    if(s.equals("Sunny")) ans = "Cloudy";
    if(s.equals("Cloudy")) ans = "Rainy";
    System.out.println(ans);
  }
}

Measured memory_bytes: 19796
#include<bits/stdc++.h>
#define int long long

using namespace std;

int32_t main()
{
    int n, m;
    cin>>n>>m;
    int tot=0;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        tot+=a[i];
    }
    int ans=0;
    int x=4*m;
    float t=(float)tot/x;
    //cout<<tot<<" "<<t<<endl;
    for(int i=0; i<m; i++)
    {
        for(int j=0; j<n; j++)
        {
            if(a[j]>=t)
            {
                ans++;
                a[j]=-1;
                break;
            }
        }
    }
    if(ans==m)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Runtime;
using System.Reflection;
using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

class P
{
    static void Main()
    {
        long[] xy = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long x = xy[0];
        long y = xy[1];
        int res = 0;
        while (x <= y)
        {
            x *= 2;
            res++;
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define MAX_N 10000
#define INF 1e9

using namespace std;

typedef int long long ll;
typedef int long l;
typedef pair<int, int> Pii;
const ll MOD = 1000000007;

int aa[10];
int n, m, q, a[50], b[50], c[50], d[50];

ll solve(int u, int t) {
    ll ans = 0;
    if (u == n) {
        for (int i = 0; i < q; i++) {
            if (aa[b[i] - 1] - aa[a[i] - 1] == c[i]) {
                ans += d[i];
            }
        }
        return ans;
    }
    aa[u] = t;
    for (int i = t; i <= m; i++) {
        ans = max(ans, solve(u + 1, i));
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    for (int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    cout << solve(0, 1) << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(void) {

while(1){

	int a=0,b=0;
	int sum=0;
	int count=1;
	
	scanf("%d %d", &a, &b);
	sum = a+b;
	if(a==0&&b==0) break;
	
	while(sum/10 != 0){
		sum/=10;
		count++;
	}
	
	printf("%d\n" ,count);	
	}
	return 0;
}

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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}
ll n, m, q;
ll ans = 0;
vector<int> a(q), b(q), c(q), d(q);

void dfs(vector<int> v, int limit) {
  if(v.size() == limit) {
    ll tmp = 0;
    rep(i, q) {
      if (v[b[i]]-v[a[i]] == c[i]) {
        tmp += d[i];
      }
    }
    ans = max(ans, tmp);
    return;
  }

  v.push_back(v.back());
  while(v.back() <= m) {
    dfs(v, limit); // A = {1} から A={1, 1} になる. 長さを増やすため
    v.back()++; //次にA={1} から A = {2}でdfs走る. 数値を増やすため
  }
}

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

  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);
  rep(i, q) cin >> a[i] >> b[i] >> c[i] >> d[i];
  rep(i, q) {
    a[i]--;
    b[i]--;
  }
  //rep1(i, 9) dfs(vector<int>(1,i), n);
  dfs(vector<int>(1,1), n);
  cout << ans << endl;
  return 0;
}


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

void _139() {
    string s, t;
    cin >> s;
    cin >> t;

    int count = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i])
            count++;
    }
    cout << count << endl;
}

int main()
{
    _139();
    return 0;
}



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

g = [[0] * (10) for _ in range(10)]
for i in range(1, N + 1):
    a = int(str(i)[0])
    b = int(str(i)[-1])
    g[a][b] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += g[i][j]*g[j][i]

print(ans)

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll h,w;cin>>h>>w;

  if(h==1||w==1)out(1);
  else{
    if(h%2==0&&w%2==0){
    out(h*w/2);
    }else if(h%2==0){
      out(h/2*w);
    }else if(w%2==0){
      out(w/2*h);
    }else out(h*(w/2)+(h+1)/2);
  }

  // out(((w+1)/2)*(h+1)/2+(w/2)*(h/2));
  // out(w/2*h+(w/2)*(h+1)/2);



  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt64() int64 {
    sc.Scan()
    i, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil {
        panic(e)
    }
    return i
}

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
    sc.Split(bufio.ScanWords)
    N := nextInt()
    T := nextInt64()
    var res, cur int64
    res = 0
    cur = 0
    for i := 0; i < N; i++ {
        t := nextInt64()
        if t > cur {
            res += T
        } else {
            res += t + T - cur
        }
        cur = t + T
    }
    fmt.Println(res)
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<int>vec;
set<int>S;
int main(){
    int n; cin >> n;
    rep(i,n){
        int a; cin >> a; vec.pb(a);
        for(int j=2;j*j<=a;j++){
            if(a%j!=0) continue;
            while(a%j == 0){
                a /= j;
            }
            S.insert(j);
        }
        if(a != 1) S.insert(a);
    }
    ll ans = 0;
    for(auto A:S){
        ll res = 0;
        rep(i,n) if(vec[i]%A==0)res+=vec[i];
        ans = max(ans,res);
    }
    cout << ans << endl;
}


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

using namespace std ;
typedef long long ll;
typedef string str;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<double> vdou ;
typedef vector<ll> vll;
typedef vector<vint> vvint;
typedef vector<str> vstr;
typedef pair<ll,ll> pll ;
typedef vector<pii> vpii ;
typedef vector<pll> vpll ;

#define REP(i, n) for (ll (i) = 0; (i) < (ll)(n); i++) 
#define FOR(i, a, b) for(ll (i) = a; (i) < (ll)b; i++)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define CHI 1000000000000000003
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (ll)x.size()
#define SP(x)  setprecision((ll)x)

const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
const double PI = M_PI;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}
//-----------------------------------------

const int MAX_V = 1e5 ;

struct edge{
    int to, cost ;
    //iからの行き先とそのコストの情報
};

int n ;
vector<edge> G[MAX_V] ;
//G[i]...iからの行き先(to)とコスト(cost)の情報を持つ
int d[MAX_V] ;
//d[i]...sからiへ行くのにかかるコストの最小

int par[MAX_V] ;
//par[i]...iの一個前

void dijkstra(int s){
    priority_queue<pii,vpii,greater<pii> > que ;
    //pair<sからiへ行くのの暫定最小コスト、i>の優先度付きキュー
    REP(i,n){
        d[i] = INF ;
      	par[i] = i ;
        //はじめコストはINFで初期化
    }
    d[s] = 0 ;
    que.push(MP(0,s)) ;
    //自身へのコストは0としてqueへ入れる
    
    while(!que.empty()){
        pii p = que.top() ;
        que.pop() ;
        int v = p.SE ;
        
        if(d[v] < p.FI){
            continue ;
        }
        REP(i,SZ(G[v])){
            //vを経由した行き先について
            edge e = G[v][i] ;
            if(d[e.to]>d[v]+e.cost){
                d[e.to] = d[v] + e.cost ;
                par[v] = e.to ;
                que.push(MP(d[e.to],e.to)) ;
            }
        }
    }
}








//-----------------------------------------
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n ;
  REP(i,n){
      int a, k ;
      cin >> a >> k  ;
      REP(j,k){
          int b, c ;
          cin >> b >> c ;
          edge e = {b,c} ;
          G[a].PB(e) ;
      }
  }
  
  dijkstra(0) ;
  
  REP(i,n){
      cout << i <<" "<<d[i] <<endl;
  }

  return 0 ;
}


Measured memory_bytes: 10236
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll 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;
}

int main() {
    ll n;
    cin >> n;
    vector<ll> divisorList;
    FOR(i, 1, floor(sqrt(n) + 1)) {
        if (n % i == 0) {
            divisorList.push_back(i);
        }
    }
    cout << floor(log10(n / divisorList[divisorList.size() - 1])) + 1;
    return 0;
}


Measured memory_bytes: 384
import math
n= int(input())
s = str(input())
num = len(s)
ans = 0
for i in range(1000):
    t = (3-len(str(i))) * "0" + str(i)
    key1,key2 = 0,0
    num= len(s)
    for j in range(num):
        if s[j] == t[2] and key2:
            ans += 1
            break
        if s[j] == t[1] and key1:
            key2 = 1
        if s[j] == t[0]:
            key1 = 1
print(ans)

Measured memory_bytes: 44508
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, char> P;

int n = 0;

int encode(string a){
  vector<int> l;
  for(int i = 0; i < a.size(); i++){
    switch(a[i]){
    case 'm':
      l.push_back(1000);
      break;
    case 'c':
      l.push_back(100);
      break;
    case 'x':
      l.push_back(10);
      break;
    case 'i':
      l.push_back(1);
      break;
    default :
      l.push_back(int(a[i] - '0'));
      break;      
    } 
  }

  int i = 0;
  int sum = 0;
  while(1){
    bool flag = false;
    if(i == l.size()) break;
    if(2 <= l[i] && l[i] <= 9){
      sum += l[i] * l[i + 1];
      flag = true;
    }
    else{
      sum += l[i];
    }

    if(flag){
      i += 2;
    }
    else i++;
  }
  
  return sum;
}

int keisu(int a){
  if(2 <= a && a <= 9) return 1;
  else if(a == 1) return 2;
  return 0;
}

vector<char> decode(int a){
  int m = a / 1000;
  int c = (a % 1000) / 100;
  int x = ((a % 1000) % 100) / 10;
  int i = ((a % 1000) % 100) % 10;

  vector<P> tmp;
  tmp.push_back(P(m, 'm'));
  tmp.push_back(P(c, 'c'));
  tmp.push_back(P(x, 'x'));
  tmp.push_back(P(i, 'i'));

  vector<char> res;
  for(int i = 0; i < 4; i++){
    if(keisu(tmp[i].first) == 1){
      res.push_back(char(tmp[i].first + '0'));
      res.push_back(tmp[i].second);
    }
    else if(keisu(tmp[i].first) == 2){
      res.push_back(tmp[i].second);
    }
  }
  return res;
}

void display(vector<char> res){
  for(int i = 0; i < res.size(); i++){
    cout << res[i];
  }
  cout << endl;
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    string a, b;
    cin >> a >> b;
    int sum = encode(a) + encode(b);
    vector<char> res = decode(sum);
    display(res);
  }
  
  return 0;
}

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

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n,m,i,j,k,sum=0;
    int a,b;
    cin>>a>>b;
    if((a+b)%2==0){
        cout<<(a+b)/2<<'\n';
    }
    else cout<<"IMPOSSIBLE"<<'\n';



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll gcd(ll x,ll y){
    if(x<y)swap(x,y);
    if(x%y==0)return y;
    return gcd(y,x%y);
}
int main(){
    ll n,m,c;
    cin>>n>>m>>c;
    cout<<n*m*c/gcd(n,m)/gcd(n,m)<<endl;
    return 0;
}


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

const long MOD=1000000007;
const long INF=100000000000000000;
int main(){
    vector<long> A(3);
    for(int i=0;i<3;i++) cin>>A.at(i);
    
    sort(A.begin(),A.end());
    cout<<A.at(2)-A.at(0)<<endl;
}

Measured memory_bytes: 764
def main():
    N = int(input())
    K = int(input())
    X = [int(x) for x in input().split()]
    ans = 0
    for i in range(N):
        ans += min(abs(X[i]-K), abs(X[i]))*2
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int cnt(int n) {
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) sum++;
    }
    return sum;
}

signed main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 3; i <= n; i += 2) {
        if (cnt(i) == 8) ans++;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<algorithm>
#include<utility>
using namespace std;
int main(){
  int n,m,ans=1,b,i;
  pair<int,int> a[100010];
  scanf("%d %d\n",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d %d\n",&a[i].second,&a[i].first);
  }
  sort(a,a+m);
  b=a[0].first;
  for(i=0;i<m;i++){
    if(a[i].second>=b){
      b=a[i].first;
      ans++;
    }
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n;
	int i,j,temp;
	int w[200],l[200],d[200],a[200];
	int s[200];
	char team[10][21],m[21];
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			s[i]=0;
			scanf("%s %d %d %d",team[i],&w[i],&l[i],&d[i]);
			s[i]=w[i]*3+l[i]*0+d[i]*1;
			a[i]=i;
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(s[i]<s[j]){
					temp=s[i];
					s[i]=s[j];
					s[j]=temp;
					strcpy(m,team[i]);
					strcpy(team[i],team[j]);
					strcpy(team[j],m);
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
				else if(s[i]==s[j] && a[i]>a[j]){
					temp=s[i];
					s[i]=s[j];
					s[j]=temp;
					strcpy(m,team[i]);
					strcpy(team[i],team[j]);
					strcpy(team[j],m);
					temp=a[i];
					a[i]=a[j];
					a[j]=temp;
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%s,%d\n",team[i],s[i]);
		}
		scanf("%d",&n);
		if(n!=0){
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1048
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int C = 0;
	int N;
	vector<int> A;
	vector<vector<int>> con, con2, con3;
	
	cin>>N;
	
	A.resize(N);
	con.resize(40, vector<int>(N+1));
	con2.resize(40, vector<int>(N+2));
	// con.resize(4, vector<int>(N+1));
	// con2.resize(4, vector<int>(N+2));
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		int a = A[i], j = 0;
		
		while(a){
			con[j][i+1] = a&1;
			a >>= 1;
			j++;
		}
	}
	
	con3 = con;
	
	for(int i = 0; i < N; i++){
		for(int j = 0; j < con.size(); j++){
			con[j][i+1] += con[j][i];
		}
	}
	// con2 = con;
	
	for(int j = 0; j < con2.size(); j++){
			con2[j][N] = N;
			con2[j][N+1] = N;
	}
	
	for(int i = N-1; i >= 0; i--){
		for(int j = 0; j < con.size(); j++){
			if(con[j][i] ==  con[j][i+1]) {
				con2[j][i] =  con2[j][i+1];
				
				// cout<<"i = "<<i<<" j = "<<j<<" <> "<<con2[j][i+1]<<endl;
			} else {
				// cout<<"i = "<<i<<" j = "<<j<<endl;
				con2[j][i] = i;
			}
		}
	}
	
	// for(int i = 0; i < N; i++){
		// int j = i+1, temp = A[i];
		
		// for(; j < N; j++){
			// if((temp&A[j])) break;
			// temp ^= A[j];
		// }
		
		// con += j - i;
	// }
	
	// cout<<"con = =========="<<endl;
	// for(int i = 0; i <= N; i++){
		// for(int j = 0; j < con.size(); j++){
			// cout<<con[j][i]<<" ";
		// }
		// cout<<endl;
	// }
	
	// cout<<"con2 = =========="<<endl;
	// for(int i = 0; i <= N; i++){
		// for(int j = 0; j < con.size(); j++){
			// cout<<con2[j][i]<<" ";
		// }
		// cout<<endl;
	// }
	
	for(int i = 0; i < N; i++){
		int minimum = INF, temp = A[i];
		
		for(int j = 0; j < con2.size(); j++){
			// cout<<"j = "<<j<<" con2 "<<con2[j][i+1]<<" "<<con2[j][con2[j][i+1]+1]<< " "<<con3[j][i+1]<<endl;
			if(!con3[j][i+1]){
				minimum = min(minimum, con2[j][con2[j][i+1]+1]);
			} else minimum = min(minimum, con2[j][i+1]);
		}
		// cout<<minimum<<" i = "<<i<<"  <> "<<minimum - i<<endl;
		// {
			// int j = i+1, temp = A[i];
		
		// for(; j < N; j++){
			// if((temp&A[j])) break;
			// temp ^= A[j];
		// }
		
		// cout<<"<><> "<<j-i<<endl;
		// }
		C += minimum - i;
	}
	cout<<C<<endl;
	
	
	return 0;
}

Measured memory_bytes: 190948
class in{struct It{int it;const bool rev;explicit constexpr It(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(It& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const It i,n;public:explicit constexpr in(int n):i(0),n(n<0?0:n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const It& begin(){return i;}const It& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

bool used[10][10];
int h, w;
vector<string> fld;
const int dx[2] = {0, 1}, dy[2] = {1, 0};
bool dfs(int cx, int cy) {
    if(cx == w - 1 && cy == h - 1) {
        bool res = true;
        for(int i : in(h)) for(int j : in(w))
          if(fld[i][j] == '#' && !used[i][j])
            res = false;
        return res;
    }
    bool ok = false;
    for(int i : in(2)) {
        int nx = cx + dx[i], ny = cy + dy[i];
        if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
        if(fld[ny][nx] == '#') {
            used[ny][nx] = true;
            ok |= dfs(nx, ny);
            used[ny][nx] = false;
        }
    }
    return ok;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    fld.resize(h);
    for(auto& x : fld) cin >> x;
    bool ans = false;
    used[0][0] = true;
    cout << (dfs(0, 0) ? "Possible" : "Impossible") << endl;
    return 0;
}

Measured memory_bytes: 256