akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define endl '\n'
const int mod=1e9+9;
#define F first
#define S second
#define pb push_back
#define all(x) x.begin(),x.end()
#define si(a) a.size()
#define pii pair<int,int>
using namespace std;
//#if !defined(ONLINE_JUDGE)
//#include "debugging.h"
//#endif
void fail(){cout<<"IMPOSSIBLE\n";exit(0);}

int32_t main() {
   std::ios::sync_with_stdio(false);cin.tie(NULL);
   int n;
   cin>>n;
   int a[n+2]={0},b[n+1]={0};
   for(int i=1;i<=n+1;i++)cin>>a[i];
   for(int i=1;i<=n;i++)cin>>b[i];
   
   int ans=0;
   for(int i=1;i<=n;i++)
   {
     int k=min(a[i],b[i]);
     a[i]-=k;
     b[i]-=k;
     ans+=k;
     k=min(a[i+1],b[i]);
     a[i+1]-=k;
     b[i]-=k;
     ans+=k; 
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 1792
/******************************************
* AUTHOR : kamesh_11 *
* INSTITUTION : GVPCOE *
******************************************/

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

#define pi 3.141592653589793
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bs binary_search
#define endl '\n'
#define start_clock clock_t beginn=clock()
#define end_clock clock_t endd=clock()
#define cal_exec_time double time_spent=(double)(endd-beginn)/CLOCKS_PER_SEC
#define print_exec_time cout<<endl<<time_spent<<" secs"

typedef long long int ll;

const ll MOD = 1000000007;
const ll INF = 1e15;

ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

ll n, arr[405], pref[405];

ll get(ll L, ll R){
	return pref[R] - pref[L-1];
}

ll find_min(ll i, ll j, vector<vector<ll>>& dp){
	if(i == j)
		return 0;

	if(dp[i][j] != -1)
		return dp[i][j];

	ll mini = INF;
	for(ll k=i;k<j;k++){
		ll cnt = get(i, j) + find_min(i, k, dp) + find_min(k+1, j, dp);
		if(cnt < mini)
			mini = cnt;
	}

	return dp[i][j] = mini;
}

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

	cin>>n;
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	for(ll i=1;i<=n;i++)
		pref[i] = pref[i-1] + arr[i];

	vector<vector<ll>>dp(n+1, vector<ll>(n+1, -1));
	cout<<find_min(1, n, dp);

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define hii cout << "hii" << endl
#define int long long
#define endl '\n'
#define all(s) s.begin(), s.end()
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

const int N = 5e5 + 5;
const int MAX = 250000 + 5;
const int M = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int INF = 1e18;
const int LG = 21;

int arr[N];

void solve()
{
	int x;
	cin >> x;
	cout << 1 - x << endl;
}


 
int32_t main() 
{	
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	    int t = 1;
	    // cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 3652
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int p = 0;//????????????????????????
		char weather[][] = new char[h][];//??\?????¨
		int ans[][] = new int[h][w];//????????¨
		for(int i = 0; i < h; i++){//????????????????????\???
			weather[i] = sc.next().toCharArray();
		}
		
		for(int i = 0; i < h; i++){//????????°?????????
			int cloud = -1;//???????????????????´?
			for(int k = 0; k < w; k++){
				if(weather[i][k] == 'c'){//????????£??????
					cloud = k;
					ans[i][k] = 0;
				}else if(cloud == -1 && weather[i][k] == '.'){//"."??§???????????´??????????????????
					ans[i][k] = -1;
				}else{//"."??§?????????????????????
					int d = k - cloud;//?????¨????????¢
					ans[i][k] = d;
				}
			}
		}
		for(int i = 0; i < h; i++){
			p = 0;
			for(int k = 0; k < w; k++){
				if(p == w-1){
					System.out.println(ans[i][k]);
				}else{
					System.out.print(ans[i][k]);
					System.out.print(" ");
					p++;
				}
			}
		}
		
	}

}

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

int main()
{
    string s;
    cin>>s;
    
    int n=s.size(),count=0;
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            count++;
        }
    }
    
    cout<<count<<endl;
}

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

int main(){

    int n, k; cin >> n >> k;
    
    vector<long long> a(n + 1, 0);
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) a[i] += a[i - 1];

    vector<long long> p;
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j++){
            p.push_back(a[j] - a[i - 1]);
        }
    }

    sort(p.begin(), p.end());
    reverse(p.begin(), p.end());
    vector<int> notuse(p.size(), 0);
    //0 未知　1 確定 2 いらない
    
    for(int i = 40; i >= 0; i--){
        int cnt = 0;
        for(int j = 0; j < p.size(); j++){
            if(notuse[j] == 2) continue;
            if((long long)pow(2, i) & p[j]) cnt++;
        }

        //cout << i << " " << cnt << endl;
        if(cnt >= k){
            for(int j = 0; j < p.size(); j++){
                if(notuse[j] == 2) continue;
                if((long long)pow(2, i) & p[j]){
                    notuse[j] = 1;  
                }else{    
                    notuse[j] = 2;
                }
            }
        }
    }

    //for(int i = 0; i < p.size(); i++) cout << bitset<8>(p[i]) << " " << notuse[i] << endl;
    
    long long ans = -1;
    int cnt = 0;
    for(int i = 0; i < p.size() && cnt != k; i++){
        if(notuse[i] == 1){
            if(ans == -1) ans = p[i];
            else ans = ans & p[i];
            cnt++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main(){
	int i, j;
	string a[4]={"dream", "dreamer", "erase", "eraser"};
	string s;
	bool can;
	cin>>s;
	reverse(s.begin(), s.end());
	for(i=0; i<4; i++) reverse(a[i].begin(), a[i].end());
	for(i=0; i<s.size();){
		can=false;
		for(j=0; j<4; j++){
			if(s.substr(i, a[j].size())==a[j]){
				can=true;
				i+=a[j].size();
			}
		}
		if(!can){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		
		if(N == M) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}	

Measured memory_bytes: 22612
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
a = [inpl() for i in range(h)]
res = []
for y in range(h-1):
    for x in range(w):
        if a[y][x]%2:
            a[y][x] -= 1
            a[y+1][x] += 1
            res.append([y+1,x+1,y+2,x+1])
for x in range(w-1):
    if a[h-1][x]%2:
        a[h-1][x] -= 1
        a[h-1][x+1] += 1
        res.append([h,x+1,h,x+2])
print(len(res))
for i in res:
    print(*i)

Measured memory_bytes: 32372
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> vec(N+1, 0);
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        vec[a]++;
        vec[b]++;
    }
    
    for(int n=1; n<=N; n++) {
        cout << vec[n] << endl;
    }



    return 0;
    
}

Measured memory_bytes: 256
use std::cmp::min;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b, c) = scan!(usize, i64, i64, i64);
    let vs = scan!(i64;;n);

    let mut ans = 1 << 30;
    for i in 0..1 << (2 * n) {
        let mut comb = 0;
        let (mut a0, mut b0, mut c0) = (0, 0, 0);
        for j in 0..n {
            let pat = (i >> (2 * j)) & 0x03;
            match pat {
                0 => {
                    a0 += vs[j][0];
                    comb += 10;
                }
                1 => {
                    b0 += vs[j][0];
                    comb += 10;
                }
                2 => {
                    c0 += vs[j][0];
                    comb += 10;
                }
                _ => (),
            }
        }
        if a0 == 0 || b0 == 0 || c0 == 0 {
            continue;
        }
        ans = min(
            ans,
            comb - 30 + (a - a0).abs() + (b - b0).abs() + (c - c0).abs(),
        )
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
using namespace std;
typedef long long ll;
ll h, w, n, c[200][200], a[21000];

void func(ll x, ll y, ll z){
    if (z == n + 1) return;
    
    if (a[z] == 0) {
        func(x, y, z + 1);
    } else if (x % 2 == 0) {
        if (y == w) {
            func(x + 1, w - 1, z);
        } else {
            c[x][y] = z;
            a[z]--;
            func(x, y + 1, z);
        }
    } else {
        if (y < 0) {
            func(x + 1, 0, z);
        } else {
            c[x][y] = z;
            a[z]--;
            func(x, y - 1, z);
        }
    }
}

int main(void){
    // Your code here!
    cin >> h >> w >> n;
    for (ll i = 1; i <= n; i++) cin >> a[i];
    func(0, 0, 1);
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            cout << c[i][j];
            if (j != w - 1) cout << ' ';
            else cout << endl;
        }
    }
}


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

int main(){
  int h,w;
  while(cin >> h >> w && (h|w)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if((i + j) % 2 == 0) cout << '#';
        else cout << '.';
      }
      cout << endl;
    }
    cout << endl;
  }
}

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

int main()
{
  int n;
  while (cin >> n, n){
    int ma=0, mi=INT_MAX;
    int sum = 0;
    for (int i = 0; i < n; i++){
      int x; cin >> x;
      sum += x;
      ma = max(ma, x); mi = min(mi, x);
    }
    cout << (sum - mi - ma) / (n - 2) << endl;
  }
}

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

using namespace std;

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

	long long int n;

	cin >> n;
	n-=1;
	string s;

	while(n >= 0)
	{
		int num = n%26;
		char ch = (char)(num + 'a');
		s = ch + s;
		n/=26;
		n-=1;
	}

	cout << s << '\n';

	return 0;
}	

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct RollingHash {
    int n;
    vector<pair<ll,ll>> vec,pw;
    ll mod1,mod2,base1,base2;
    
    RollingHash(string s) {
        srand(time(NULL));
        n=sz(s);
        vec.resize(n+1);
        pw.resize(n+1);
        pw[0]={1,1};
        
        mod1=1e9+93;
        mod2=1e9+97;
        //base1=(ll)rand()%((ll)1e7+9);
        //base2=(ll)rand()%((ll)1e7+9);
        base1=10007;
        base2=10007;
        rep(i,n) {
            pw[i+1].first=pw[i].first*base1%mod1;
            pw[i+1].second=pw[i].second*base2%mod2;
            vec[i+1].first=(vec[i].first*base1+(ll)s[i])%mod1;
            vec[i+1].second=(vec[i].second*base2+(ll)s[i])%mod2;
        }
    }
    
    //[l,r)
    pair<ll,ll> get(int l,int r) {
        ll fi,se;
        fi=(vec[r].first-vec[l].first*pw[r-l].first%mod1+mod1)%mod1;
        se=(vec[r].second-vec[l].second*pw[r-l].second%mod2+mod2)%mod2;
        return make_pair(fi,se);
    }
};

int main() {
    string t,p;
    cin>>t>>p;
    int n=sz(t),m=sz(p);
    t+=p;
    RollingHash rlh(t);
    rep(i,n-m+1) {
        if(rlh.get(i,i+m)==rlh.get(n,n+m)) cout<<i<<endl;
    }
    //rep(i,n) cout<<rlh.get(i,i+1).first<<" "<<rlh.get(i,i+1).second<<endl;
}



Measured memory_bytes: 36668
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define ci(n) cin >> n
#define co(n) cout << n << endl
using namespace std;

int main(){
  long a, b, n, c=0;
  cin >> a >> b;
  
  string s;
  rep(i,0,a){
    cin >> s;
    co(s); co(s);
  }
  
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{

    
    class Program
    {

        static void Solve(long[] dam)
        {
            int N = dam.Length;
            long[] X = new long[N];
            long sum = dam.Sum();

            //X[0] = sum - 2(dam[0] + ... + dam[N-1])
            X[0] = sum;           
            for(int i = 0; i < N; i++)
            {
                if (i % 2 == 1) X[0] -= 2 * dam[i];
            }

            //X[i] = 2dam[i - 1] - X[i - 1]
            //によりi=1～N-1まで次々に求めて表示
            Console.WriteLine(X[0]);
            for(int i = 1; i < N; i++)
            {
                X[i] = 2 * dam[i - 1] - X[i - 1];
                Console.WriteLine(X[i]);
            }
            
        }
        
        static void Main(string[] args)
        {
            //入力1(N)
            int N = int.Parse(Console.ReadLine());

            //入力2(dam)
            long[] dam = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            Solve(dam);
            
        }
    }

}

Measured memory_bytes: 33116
N = int(input())
S = input()
K = int(input())

S_list = [S[i] for i in range(len(S))]

kekka = ""
for x in S_list:
    if x!=S[K-1]:
        kekka += "*"
    else :
        kekka += S[K-1]


print(kekka)


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

int sum(int a){
    int ret=0;
    while(a){
        ret+=a%10;
        a/=10;
    }
    return ret;
}


int main(){
    int N;
    cin >> N;
    int ans=INF;
    for(int i=1;i<N;i++){
        ans=min(ans,sum(i)+sum(N-i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

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

int main(void) {
	int num, i = 1;
	ll t1, t2;
	cin >> num >> t1;
	for (; i < num; i++) {
		cin >> t2;
		t1 *= t2 / gcd(t1, t2);
	}
	cout << t1 << "\n";
	return 0;
}

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

int main(){
	int a,b,s,i,n;
	while(cin >> a >> b){
			
	n=0;
	s=a+b;
	while(s!=0){
	s/=10;
	n++;
	}
	cout << n << endl;
	}
	return 0;
}

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

int main()
{
	ll N;cin >> N;
	vector<string> kakko(N);
	for (ll i=0;i<N;i++) cin >> kakko[i];
	vector<pair<ll,ll>> dont;
	vector<ll> use;
	vector<pair<ll,ll>> sub;

	ll cnt=0,minus=0;
	for (ll i=0;i<N;i++)
	{
		cnt=0;
		minus=0;
		string S=kakko[i];
		bool can=true;
		for (ll j=0;j<S.size();j++)
		{
			if (S[j]=='(') cnt++;
			else cnt--;
			minus=min(minus,cnt);
			if (cnt<0) can=false;
		}
		if (cnt<0) sub.push_back(make_pair(-minus+cnt,-cnt));
		else
		{
			if (!can) dont.push_back(make_pair(-minus,-cnt));
			else use.push_back(cnt);
		}
		
	}
	ll now=0;
	sort(dont.begin(),dont.end());
	sort(sub.begin(),sub.end());
	bool can=true;
	for (ll i=0;i<use.size();i++) now+=use[i];
	for (ll i=0;i<dont.size();i++)
	{
		if (now-dont[i].first<0)
		{
			can=false;
			break;
		}
		now-=dont[i].second;
	}
	ll right=0;
	for (ll i=0;i<sub.size();i++)
	{
		if (right-sub[i].first<0)
		{
			can=false;
			break;
		}
		right+=sub[i].second;
	}
	//cout << right << now << endl;
	if (can && now==right) cout << "Yes" << endl;
	else cout << "No" << endl;
return 0;

}


Measured memory_bytes: 49760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;
#define FOR(x, a, b)       for (int x = a; x <= b; x++)
#define all(container)     (container).begin(), container.end()
#define rall(container)    (container).rbegin(), container.rend()
#define sz(container)      (int) (container).size()
#define pb                 push_back
#define eb                 emplace_back
#define fi                 first
#define se                 second

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#ifdef LOCAL_DEFINE
	#include "DEBUG.hpp"
#else
	#define eprint(...) 0
#endif
template<class T> bool self_min(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool self_max(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(void)
{
	int x, y;
	scanf("%d%d", &x, &y);
	if (y % 2 != 0)
		puts("No");
	else {
		for (int i = 0; i <= x; i++) {
			if (i * 2 + (x - i) * 4 == y) {
				puts("Yes");
				return 0;
			}
		}
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <climits>
int main(void){
  int n,c;
  std::cin >> n >> c;

  int total_d[3][c];
  for(int i=0; i<3; i++){
    for(int j=0; j<c; j++){
      total_d[i][j] = 0;
    }
  }

  int d[c][c];
  for(int i=0; i<c; i++){
    for(int j=0; j<c; j++){
      std::cin >> d[i][j];
    }
  }

  int sc[n][n];
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      std::cin >> sc[i][j];
      for(int k=0; k<c; k++){
        total_d[(i+j)%3][k] += d[sc[i][j]-1][k];
      }
    }
  }

  int smallest = INT_MAX;
  for(int i=0; i<c; i++){
    for(int j=0; j<c; j++){
      for(int k=0; k<c; k++){
        if(i==j || j==k || k==i) continue;
        int temp = total_d[0][i] + total_d[1][j] + total_d[2][k];
        if(smallest > temp) smallest = temp;
      }
    }
  }
  std::cout << smallest << std::endl;
  return 0;
}



Measured memory_bytes: 1280
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();

        if (A > B || A < B && N == 1) {
            _out.println(0);
            return;
        }

        long min = (long)A * (N - 1) + B;
        long max = (long)B * (N - 1) + A;

        _out.println(max - min + 1);
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 23252
#include<stdio.h>
int main(void)
{
	int a,s,d;
	while(scanf("%d %d",&a,&s)!=EOF){
	d=a+s;
	if(d>=0&&d<=9){
		printf("1\n");
	}
	else if(d>=10&&d<=99){
		printf("2\n");
	}
	else if(d>=100&&d<=999){
		printf("3\n");
	}
	else if(d>=1000&&d<=9999){
		printf("4\n");
	}
	else if(d>=10000&&d<=99999){
		printf("5\n");
	}
	else if(d>=100000&&d<=999999){
		printf("6\n");
	}
	else if(d>=1000000){
		printf("7\n");
	}
	}
	return 0;
}

Measured memory_bytes: 1012
#include<stdio.h>
int main(void){
	int height,width;
	int i,j;
	
	while(1){
		scanf("%d %d",&height,&width);
		if(height==0 && width==0){
			break;
		}
		for(i=0;i<height;i++){
			for(j=0;j<width;j++){
				if((i+j)%2==0){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
    string s, t;
    int cnt = 0;
    cin >> s >> t;

    int n = s.size();
    for (int i = 0; i < n; i++)
    {
        if (s[i] != t[i])
        {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main(){

    int ans=2147483647;
    string s;
    cin>>s;
    for(int i=0;i<s.size()-2;i++) ans=min(ans,abs(stoi(s.substr(i,3))-753));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
struct ding{
  int l,r,num;
}a[400009];
int ans[200009],n,m,q,f[1000];
void update(int x)
{
  for (int i=x;i<=n;i+=i&(-i)) f[i]++;
}
int query(int x)
{
  int sum=0;
  for (int i=x;i;i-=i&(-i))sum+=f[i];
  return sum; 
}
bool cmp(ding x,ding y){return x.l==y.l?x.num>y.num:x.l<y.l;}
int main()
{
  scanf("%d%d%d",&n,&m,&q);
  int cnt=0;
  for (int i=1;i<=m;i++)
  {
  	++cnt;
  	scanf("%d%d",&a[cnt].l,&a[cnt].r);
  	a[cnt].num=0;
  }
  for (int i=1;i<=q;i++)
  {
  	++cnt;
  	scanf("%d%d",&a[cnt].l,&a[cnt].r);
  	a[cnt].num=i;
  }
  sort(a+1,a+1+cnt,cmp);
  for (int i=cnt;i>=1;i--)
  if (a[i].num==0) update(a[i].r);
  else ans[a[i].num]=query(a[i].r)-query(a[i].l-1);
  for (int i=1;i<=q;i++) cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        sc.close();

        double result = 0.0000000000;
        int j = 1;
        for (int i = n; i > 0; i--) {
            int point = (int) (i * Math.pow(2, j - 1));
            while (point < k) {
                point *= 2;
                j++;
            }
            result += Math.pow(0.5, j - 1) / n;
        }
        System.out.println(String.format("%.11f", result));
    }
}

Measured memory_bytes: 22868
#pragma GCC optimize "O3"
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define REP_FROM(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define REP_REV(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define REP_FROMREV(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#ifndef LOCAL
#define cerr if (false) cerr
#endif
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }
template <class T> T sq(T x) { return x * x; }
template <class T> T clamp(T a, T l, T r) { return min(max(a, l), r); } // [l, r]
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(int argc, char *argv[]) {
	// Something to do
	string s;
	cin >> s;
	reverse(ALL(s));
	cout << s << endl;
	return 0;
}

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

max_diff = 0

for i in range(0, N-1):
  if(max_diff < A[i+1] - A[i]) :
    max_diff = A[i+1] - A[i]
    
if(max_diff < K-A[N-1] + A[0]) :
  max_diff = K-A[N-1] + A[0]
  
print(K-max_diff)

Measured memory_bytes: 26444
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#include<vector>
#include<cmath>
#define maxn 1000007
using namespace std;
int n,m;
inline int read()
{
    int x = 0;
    int flag = 1;
    char ch;
    ch = getchar();
    while(!isdigit(ch)) 
    {
        if(ch == '-') flag = -1;
    ch = getchar();
    } 
    while(isdigit(ch))
    {
        x = (x<<1) + (x<<3) + ch - 48;
        ch = getchar();
    }
    return x * flag;
}


int main()
{
	n = read();
	m = read();
	if(n == m) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;
    static final int ALF = 26;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        BigDecimal A = new BigDecimal(sc.next());
        BigDecimal B = new BigDecimal(sc.next());
        BigDecimal AB = A.multiply(B);
        System.out.println(AB.setScale(0, RoundingMode.DOWN));
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 35952
N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]

AB.sort(key = lambda x:(x[1], -x[0]))

sum_a = 0
complete = True
for i in range(N):
    sum_a += AB[i][0]
    if sum_a > AB[i][1]:
        complete = False
if complete:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 89820
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,k=1;char c=getchar();
    while(c<'0' || c>'9'){if(c=='-') k=0;c=getchar();}
    while(c>='0' && c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
    return k?x:-x;
}
map<string,int>mp;
int n,m,p,wa[100010];
bool ac[100010];
string str;
int main()
{
    n=read(),m=read();
    for(int i=0;i<m;i++)
    {
        p=read();
        cin>>str;
        if(!ac[p])
        {
            if(str=="AC") ac[p]=1;
            else wa[p]++;
            mp[str]++;
        }
    }
    for(int i=0;i<=n;i++) if(!ac[i]) mp["WA"]-=wa[i];
    printf("%d %d\n",mp["AC"],mp["WA"]);
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair

int main(){
    int n; cin >> n;
    map<string, int> m;
    m["AC"] = 0; m["TLE"] = 0; m["WA"] = 0; m["RE"] = 0;

    for (int i=0; i!=n; i++){
        string s; cin >> s;
        m[s]++;
    }
    cout << "AC x "<<m["AC"] << endl;
    cout << "WA x "<<m["WA"] << endl;
    cout << "TLE x "<<m["TLE"] << endl;
    cout << "RE x "<<m["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3612
HW = list(map(int, input().split()))
H = HW[0]
W = HW[1]
a = []
ans = []

for i in range(H):
  a.append(list(map(int, input().split())))
  
for i in range(H):
  for j in range(W-1):
    if a[i][j] % 2 == 1:
      a[i][j] -= 1
      a[i][j+1] += 1
      ans.append((i, j, i, j+1))

for i in range(H-1):
  if a[i][W-1] % 2 == 1:
    a[i][W-1] -= 1
    a[i+1][W-1] += 1
    ans.append((i, W-1, i+1, W-1))

print(len(ans))
for (y1, x1, y2, x2) in ans:
  print("%d %d %d %d" % (y1+1, x1+1, y2+1, x2+1))

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

using namespace std;

int main(int argc, char* argv[]) {
  int N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  --A;
  --B;
  --C;
  --D;

  string s;
  cin >> s;

  bool goal_a = false;
  bool goal_b = false;

  if (C > D) {
    bool found = false;
    while (B < D) {
      bool change = false;
      if (s[B - 1] == '.' && s[B + 1] == '.') {
        found = true;
        break;
      }
      if (s[B + 1] == '.') {
        change =true;
        ++B;
      } else if (s[B + 2] == '.') {
        change = true;
        B += 2;
      }
      if (B == D) {
        goal_b = true;
        break;
      }
      if (!change)
        break;
    }
    if (!found && !goal_b) {
      cout << "No" << endl;
      return 0;
    }
  }

  while (true) {
    bool change = false;
    if (!goal_a && A < N) {
      if ((s[A + 1] == '#' || A + 1 == B) && (s[A + 2] == '#' || A + 2 == B)) {
      } else if (A + 1 == C && A + 1 != B) {
        goal_a = true;
        change = true;
        ++A;
      } else if (A + 2 == C && A + 2 != B) {
        goal_a = true;
        change = true;
        A += 2;
      } else if (s[A + 2] == '.' && A + 2 != B) {
        A += 2;
        change = true;
      } else if (s[A + 1] == '.' && A + 1 != B) {
        ++A;
        change = true;
      }
    }

    if (!goal_b && B < N) {
      if (C > D && A < B) {
      } else if ((s[B + 1] == '#' || B + 1 == A) && (s[B + 2] == '#' || B + 2 == A)) {
      } else if (B + 1 == D && B + 1 != A) {
        goal_b = true;
        change = true;
        ++B;
      } else if (B + 2 == D && B + 2 != A) {
        goal_b = true;
        change = true;
        B += 2;
      } else if (s[B + 2] == '.' && B + 2 != A) {
        B += 2;
        change = true;
      } else if (s[B + 1] == '.' && B + 1 != A) {
        ++B;
        change = true;
      }
    }
    if (!change || (A >= N || B >= N))
      break;
  }

  if (goal_a && goal_b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
signed main(void)
{
	int h,w;
    int M =1000000007;
	cin>>h>>w;
    string s[h];
    for(int i =0;i<h;i++)
    	cin>>s[i];

	int dp[h][w];
	for(int i =0;i<h;i++)
	{
		for(int j = 0;j<w;j++)
		{
			if(i==0 && j==0){dp[i][j]=1;continue;}

			if(s[i][j]=='#')
			{
			   dp[i][j]=0;
		    }
			else
			{
				dp[i][j]=0;
				if(i-1>=0 && s[i-1][j]!='#')
					dp[i][j]=(dp[i][j]%M+dp[i-1][j]%M)%M;
				if(j-1>=0 && s[i][j-1]!='#')
					dp[i][j]=(dp[i][j]%M+dp[i][j-1]%M)%M;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>

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

int A[105];

int main()
{
	int n;
	scanf("%d",&n);
	int x;
	scanf("%d",&x);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	sort(A,A+n);
	int ret=0;
	for(int i=0;i<n;i++)
	{
		if(x>=A[i])
		{
			x-=A[i];
			ret++;
		}
	}
	if(ret==n&&x!=0)
	{
		ret--;
	}
	printf("%d\n",ret);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = c - a;
	int y = d - b;
	cout << c - y << ' ' << d + x << ' ' << c - y - x << ' ' << d + x - y << endl;
}

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

int main() {
	
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w)), tmp(h, vector<int>(w));
	rep(i, h) rep(j, w){
		cin >> a[i][j];
	}
	tmp = a;
	int n = 0;
	rep(i, h){
		rep(j, w - 1){
			if(a[i][j] % 2 == 1){
				a[i][j]--;
				a[i][j + 1]++;
				n++;
			}
		}
	}
	rep(i, h - 1){
		if(a[i][w - 1] % 2 == 1){
				a[i][w - 1]--;
				a[i + 1][w - 1]++;
				n++;
			}
	}
	cout << n << endl;
	a = tmp;
	rep(i, h){
		rep(j, w - 1){
			if(a[i][j] % 2 == 1){
				a[i][j]--;
				a[i][j + 1]++;
				printf("%d %d %d %d\n", i + 1, j + 1, i + 1, j + 2);
			}
		}
	}
	rep(i, h - 1){
		if(a[i][w - 1] % 2 == 1){
				a[i][w - 1]--;
				a[i + 1][w - 1]++;
				printf("%d %d %d %d\n", i + 1, w, i + 2, w);
			}
	}
	
	return 0;
}

Measured memory_bytes: 4096
def _abs(N: int, Z: int, W: int, A: list) -> int:
    if N == 1:
        return abs(A[0] - W)
    return max(abs(A[N-1] - A[N-2]), abs(A[N-1] - W))


if __name__ == "__main__":
    N, Z, W = map(int, input().split())
    A = [int(s) for s in input().split()]
    ans = _abs(N, Z, W, A)
    print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

int f(int a) {
   if (a % 2 == 1) {
      return 1;
   } else if (a == 0) {
      return 2;
   } else {
      return 0;
   }
}
int g(int a) {
   if (a % 2 == 1) {
      return 0;
   } else {
      return 1;
   }
}

signed main()
{
   int L; cin >> L;
   V<int> A(L);
   REP(i, L) {
      cin >> A[i];
   }

   V<V<int>> dp(5, V<int>(L+1));
   REP(i, L) {
      dp[0][i+1] = dp[0][i] + A[i];
      dp[1][i+1] = min(dp[0][i], dp[1][i]) + f(A[i]);
      dp[2][i+1] = min(min(dp[0][i], dp[1][i]), dp[2][i]) + g(A[i]);
      dp[3][i+1] = min(min(min(dp[0][i], dp[1][i]), dp[2][i]), dp[3][i]) + f(A[i]);
      dp[4][i+1] = min(min(min(min(dp[0][i], dp[1][i]), dp[2][i]), dp[3][i]), dp[4][i]) + A[i];
   }
   int ans = INF;
   REP(i, 5) {
      ans = min(ans, dp[i][L]);
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<algorithm>

using namespace std;

int N, M;
int A[300][300];
int cnt[300];
int pointer[300];
bool erased[300];

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++)for (int j = 0; j < M; j++)cin >> A[i][j];
	
	for (int i = 0; i < N; i++)cnt[A[i][0] - 1]++;

	int ans = 114514;
	for (int dec = 0; dec < M; dec++) {
		//一番人の集まるスポーツをピックアップ
		int biggest = 0;
		int sport_id = -1;
		for (int i = 0; i < M; i++) {
			if (biggest < cnt[i])biggest = cnt[i], sport_id = i;
		}

		//この時点での答えを更新
		ans = min(ans, biggest);
		
		//一番集まってるスポーツを消す
		cnt[sport_id] = 0;
		erased[sport_id] = true;
		for (int i = 0; i < N; i++) {
			if (A[i][pointer[i]] == sport_id + 1) {
				pointer[i]++;
				while (pointer[i] < M && erased[A[i][pointer[i]] - 1])
					pointer[i]++;
				if(pointer[i] < M)cnt[A[i][pointer[i]] - 1]++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using int64 = long long int;

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

	for (int i = 0; i <= y / 10000; i++)
	{
		for (int j = 0; j <= (y - i * 10000) / 5000; j++)
		{
			int remain = y - i * 10000 - j * 5000;
			int k = remain / 1000;
			if (remain >= 0 && i + j + k == n)
			{
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a,b;

int main(){
	cin>>n;
	a=b=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int t=n;
	for(int i=n-1;i>=0;i--){
		b[i]=t;
		if(a[i]) t=i;
	}
	ll res=0;
	for(int i=0;i<n;i++){
		int j=i+1,x=a[i];
		while(j<n&&(x&a[j])==0){
			x+=a[j];
			res+=b[j]-j;
			j=b[j];
		}
		res++;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i, H) cin >> S[i];
    int res = INF;
    for(int bit = 0; bit < (1 << (H - 1)); bit++) {
        vector<vector<string>> store;
        vector<string> now;
        for(int i = 0; i < H; i++) {
            now.pb(S[i]);
            if(i == H - 1 || (bit & (1 << i))) {
                store.pb(now);
                now.clear();
            }
        }
        int cnt = 0;
        int flag = 0;
        vector<int> nums(store.size());
        for(int i = 0; i < W; i++) {
            vector<int> tmp(store.size());
            for(int k = 0; k < store.size(); k++) {
                for(int j = 0; j < store[k].size(); j++) {
                    if(store[k][j][i] == '1')
                        tmp[k]++;
                }
            }
            rep(j, nums.size()) {
                if(tmp[j] > K) {
                    flag = 1;
                    break;
                }
                if(nums[j] + tmp[j] > K) {
                    cnt++;
                    rep(k, nums.size()) { nums[k] = tmp[k]; }
                    break;
                } else {
                    nums[j] += tmp[j];
                }
            }
            if(flag)
                break;
        }
        if(flag)
            continue;
        res = min(res, __builtin_popcount(bit) + cnt);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
P = 37
ANS = []
for a in range(P):
    for b in range(P):
        t = [P*P + (pow(b, P-2, P) if b else 0)]
        for i in range(P):
            t.append((a*P+(b*P+1)*i)%(P*P))
        ANS.append(t)
for a in range(P):
    t = [P*P+P]
    for i in range(P):
        t.append(a+i*P)
    ANS.append(t)
t = []
for i in range(P+1):
    t.append(P*P+i)
ANS.append(t)

print(len(ANS), P+1)
for ans in ANS:
    print(*[a+1 for a in ans])

Measured memory_bytes: 5564
using System;
using System.Collections.Generic;

	class Program
	{
		static void Main(string[] args)
		{
			Dictionary<string, int> dic = new Dictionary<string, int>() {
				{ "SAT",1},{ "FRI",2},{ "THU",3},{ "WED",4},{ "TUE",5},{ "MON",6},{ "SUN",7}
			};
			string day = Console.ReadLine();
			Console.WriteLine(dic[day]);
		}
	}


Measured memory_bytes: 11104
import itertools

n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

permutations = list(itertools.permutations(range(1,n+1)))
ps = permutations.index(p)
qs = permutations.index(q)

print(abs(ps-qs))

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

int main() {
	string S, k = "keyence";
	cin >> S;
	int N = S.size(), n = k.size();
	for (int i = 0; i <= k.size(); i++) {
		if (S.substr(0, i) + S.substr(N - n + i, n - i) == k) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    sort(a, a+N, greater<int>());
    bool ans = true;
    //直径
    int R = a[0];
    if(a[N-1] != (R+1)/2) ans = false;
    //num[i]:=最も遠い点との距離がiである点の数
    int num[R+1];
    fill(num, num+R+1, 0);
    rep(i, N) num[a[i]]++;
    rep3(i, R, R/2+1){
        if(num[i] < 2) ans = false;
    }
    if(R%2 == 0){
        if(num[R/2] != 1) ans = false;
    }
    else{
        if(num[(R+1)/2] != 2) ans = false;
    }
    if(ans) cout << "Possible" << endl;
    else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	char p[100], s[200];
	int pos = 0;
	int j = 0;
	while (1) {
		scanf("%c", &s[pos]);
		if (s[pos] == '\n')break;
		pos++;
	}
	for (int i = 0; i < pos; i++) {
		s[pos + i] = s[i];
	}
	s[2 * pos] = 0;
	pos = 0;
	while (1) {
		scanf("%c", &p[pos]);
		if (p[pos] == '\n')break;
		pos++;
	}
	p[pos] = 0;

	pos = 0;

	while (s[pos] != 0) {
		if (s[pos] == p[0]) {
			j = 0;
			while (s[pos + j] == p[j]) {
				j++;
			}
			if (p[j] == 0) {
				printf("Yes\n"); return 0;
			}
		}
		pos++;
	}
	printf("No\n");
	return 0;

// TEST
	for (int i = 0; s[i] != 0; i++) {
		printf("%c", s[i]);
	}
	printf("\n");
	for (int i = 0; p[i] != 0; i++) {
		printf("%c", p[i]);
	}
	printf("\n");


	return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    priority_queue<ll> prices;
    for(int i=0; i<N; i++) prices.push(A[i]);
    for(int i=0; i<M; i++) {
        ll top = prices.top();
        prices.pop();
        prices.push(top/2);
    }

    ll ans = 0;
    while(!prices.empty()) {
        ans += prices.top();
        prices.pop();
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2168