akhauriyash/Code-Regression huggingface dataset:
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array



void solve(){
	int x;
	cin >> x;
	cout << (x^1) << "\n";
}

int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int TC = 1;
//    cin>>TC;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
  long int n;
  cin>>n;
  long int sum=0;
  for(long int i=1;i<=n;i++){
    if(i%3==0&&i%5==0)
    continue;
    if(i%3==0)
      continue;
    if(i%5==0)
      continue;
    sum+=i;
  }
  cout<<sum;
  return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
namespace AtCoder.ARC080
{
    class FourAdjacent
    {
        public static void Main()
        {
            var n = int.Parse(ReadLine().Trim());
            var a = ReadLine().Trim().Split(' ').Select(_ => int.Parse(_));
            var b1 = a.Where(_ => _ % 2 != 0).Count();
            var b2 = a.Where(_ => _ % 4 == 2).Count();
            var b4 = a.Where(_ => _ % 4 == 0).Count();
            if (b1 + (b2 % 2)<= b4 + 1) WriteLine("Yes");
            else WriteLine("No");
        }
    }
}


Measured memory_bytes: 18272
#include <stdio.h>

int main() {
	int N;
	scanf("%d", &N);
	for (int n = 1; n <= N; n++) {
		int cnt = 0;
		for (int i = 1; i <= 100; i++) {
			if (i * (i + 2) + 3 > n) {
				break;
			}
			for (int j = i; j <= 100; j++) {
				if (i * (i + j + 1) + j * (j + 1) + 1 > n) {
					break;
				}
				for (int k = j; k <= 100; k++) {
					if (i * (i + j + k) + j * (j + k) + k * k == n) {
						cnt++;
						if (i != k) {
							cnt += 2;
						}
						if (i != j && j != k) {
							cnt += 3;
						}
					}
				}
			}
		}
		printf("%d\n", cnt);
	}
	return 0;
}


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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;

integer main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int k[n];
    for (int i = 0; i < n; i++){
        cin >> b[i];
        k[i] = i+1;
    }
    int i = -1, j = -1;
    int cnt = 1;
    do {
        bool f = true;
        for (int l = 0; l < n; l++){
            if (a[l] != k[l]) {
                f = false;
                break;
            }
        }
        if (f) {
            if (i == -1) i = cnt;
            else j = cnt;
        }
        f = true;
        for (int l = 0; l < n; l++){
            if (b[l] != k[l]) {
                f = false;
                break;
            }
        }
        if (f) {
            if (i == -1) i = cnt;
            else j = cnt;
        }
        cnt++;
    } while ((i == -1 || j == -1) && next_permutation(k, k+n));
    cout << abs(i - j) << endl;

}

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

int main(){
    int N;
    cin >> N;
    
    vector<vector<int>> ame(2,vector<int>(N));
    //飴データ入力
    rep(i,2){
        rep(j,N){
            cin >> ame[i][j];
        }
    }
    
   
    int ans=0;
    //下に降りるポイントを切り替えていく
    for(int i=0; i<N; i++){
        int sum=0;
        //上の合計
        for(int j=0; j<=i; j++){
            sum += ame[0][j];
        }
        
        //下の合計
        for(int j=i; j<N; j++){
            sum += ame[1][j];
        }
        //cout << sum << endl;
        
        ans = max(ans,sum);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def f(k,p):
  return (c[p] >= k*p)

def ff(k,p):
  acc = n 
  for i in range(len(b)):
    if b[i]>p:
      acc -= b[i]-p 
    else:
      break
  return (acc >= k*p)

n = inn()
a = inl()
h = {}
for x in a:
  if x in h:
    h[x] += 1
  else:
    h[x] = 1
b = []
for x in h:
  b.append(h[x])
b.sort(reverse=True)

#ddprint(b)

c = [0]*(n+1)
for p in range(1,n+1):
  acc = n 
  for i in range(len(b)):
    if b[i]>p:
      acc -= b[i]-p 
    else:
      break
  c[p] = acc


for k in range(1,n+1):
  mn = 0
  mx = n//k + 1
  while mx > mn+1:
    mid = (mn+mx)//2
    if f(k,mid):
      mn = mid 
    else:
      mx = mid 
  print(mn)


Measured memory_bytes: 118704
# 2
import sys
sys.setrecursionlimit(10000)
args = sys.stdin.readlines()
N = int(args[0])
xy_list = [[int(y) for y in x.split(' ')] for x in args[1:]]

from collections import Counter, defaultdict

delta_dict = defaultdict(int)

if N == 1:
    print(1)
    exit()
for i in range(N):
    for j in range(N):
        if i != j:
            delta_dict[(xy_list[i][0] - xy_list[j][0], xy_list[i][1] - xy_list[j][1])] += 1
    
print(N - Counter(delta_dict).most_common()[0][1])

Measured memory_bytes: 4080
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))
count = 0
for so in A:
    total = 0
    for a, b in zip(so, B):
        total += a*b
    if total + C > 0:
        count += 1

print(count)


Measured memory_bytes: 3064
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> bool chmin(T& a,const T& b) {
  if(a>b) {
    a=b;
    return true;
  }
  return false;
}
template<class T> bool chmax(T& a,const T& b) {
  if(a<b){
    a=b;
    return true;
  }
  return false;
}

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;

int n;
lint ar[100005];
void ng(){
  puts("-1");
  exit(0);
}
vector<int> g[100005];
lint rec(int v,int p,int d=0){
  lint res=d;
  for(auto to:g[v]) if(to!=p){
    res+=rec(to,v,d+1);
  }
  return res;
}
int main(){
  cin>>n;
  set<pair<lint,pi> > S;
  REP(i,n){
    scanf("%lld\n",&ar[i]);
    S.insert({ar[i],{i,1}});
  }
  vector<pi> es;
  while(S.size()>1){
    pair<lint,pi> tmp=*(--S.end());
    S.erase(--S.end());
    int v=tmp.sc.fr,wei=tmp.sc.sc;
    lint co=tmp.fr;
    if(wei*2>=n) ng();

    lint want=co-(n-2*wei);
    auto it=S.lower_bound(mp(want,mp(0,0)));
    if(it!=S.end() && it->fr==want){
      int v2=it->sc.fr,wei2=it->sc.sc;
      S.erase(it);
      es.pb({v,v2});
      S.insert({want,{v2,wei+wei2}});
    }else{
      ng();
    }
  }
  for(auto e:es) g[e.fr].pb(e.sc),g[e.sc].pb(e.fr);

  if(rec(0,-1)!=ar[0]) ng();
  for(auto e:es) printf("%d %d\n",e.fr+1,e.sc+1);



  return 0;
}





Measured memory_bytes: 17780
object Main {
  def main(args: Array[String]): Unit = {
    val num = scala.io.StdIn.readInt
    val array = scala.io.StdIn.readLine.split("")
    var count = 0
    var white_point = num - 1

    ( 0 until num ).foreach{ i =>
      if( array( i ) == "W" && white_point > i){
        while( array( white_point ) == "W" && white_point > 0 ) white_point -= 1
        array( i ) = "R"
        array( white_point ) = "W"
        if( white_point > i ) count += 1
      }
    }
    println( count )
  }
}

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

int main(){
    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = N-2; i >= 0; i--){
        if(H[i] > H[i+1]){
            if(H[i] - H[i+1] == 1){
                H[i]--;
            }else{
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#include<numeric>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        a.at(i)=k;
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    a.at(0)/=2;
    int l=accumulate(a.begin(),a.end(),0);
    cout<<l<<endl;
}


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

int main(){
	string s, t;
	cin >> s >> t;
	if(s.size() < t.size()){
		cout << "UNRESTORABLE"<<endl;
		return 0;
	}
	int idx = -1;
	for(int i = 0; i <= s.size() - t.size(); i++){
		int cnt = 0;
		for(int j = 0; j < t.size(); j++){
			if(s[i + j] == t[j] || s[i+j] == '?') cnt++;
		}
		if(cnt == t.size())idx = i;
	}
	string  ans;
	if(idx != -1){
		for(int i = 0; i < t.size(); i++){
			s[idx + i] = t[i];
		}
		for(int i = 0; i < s.size(); i++){
			if(s[i] == '?')s[i] = 'a';
		}
		ans = s;
	}else{
		ans = "UNRESTORABLE";
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define rep(i, a, b) for(ll i=a; i<b; i++)
#define rer(i, a, b) for(ll i=a-1; i>=b; i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n;
signed main(){
    char c;
    cin >> c;
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int r;
        double R;

        scanf("%d", &r);
        R = r;
        printf("%f\n", R * 2 * 3.14159265);

	return 0;

       
}



Measured memory_bytes: 1752
#include"iostream"
#include"vector"
#include"algorithm"
using namespace std;

int main()
{
	int n;
	cin >> n;
	long x;
	cin >> x;
	vector<long> a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end());

	int i = 0;
	while (x >=0 && i < n)
	{
		x -= a.at(i);
		i++;
	}

	cout << (i == n && x == 0 ? n : i - 1) << endl;
}

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

int main(void) {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  }
  else {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
  }
  return 0;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    string s;
    cin >> s;
    string cf = "CF.";
    i64 i = 0;
    for (auto& e : s) if (e == cf[i]) i++;
    cout << (i == 2 ? "Yes" : "No") << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.000000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main()
{
    fast();
    ll n,m;
    cin>>n>>m;
    vi a(m);
    cin>>a;

    vi dp(n+1,0);
    dp[n]=1;
    ll j=m-1;
    for(ll i=n-1;i>=0;i--)
    {
        if(j>=0 && i==a[j])
        {
            j--;
        }
        else
        {
            if(i+1<=n)
                dp[i]=dp[i+1];
            if(i+2<=n)
                dp[i]=(dp[i]+dp[i+2])%mod;
        }
    }
    cout<<dp[0]<<nl;
}


Measured memory_bytes: 4668
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    string s;
    ll k;
    cin >> s >> k;
    vector<string> strings;
    ll n = s.size();
    loop(i, n)
    {
        Loop(j, 1, 6)
        {
            if (i + j > n)
                continue;
            strings.push_back(s.substr(i, j));
        }
    }
    sort(all(strings));
    ll count = 0;
    string now;
    loop(i, strings.size())
    {
        if (strings[i] != now)
        {
            count++;
            now = strings[i];
        }
        if (count == k)
        {
            putout(now);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    string s;
    std::cin >> s;
    rep(i,3){
        if(s[i]=='1')s[i]='9';
        else s[i]='1';
    }
    std::cout << s << std::endl;
    
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;

const int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
const int MaxR=52;
const int MaxM=1020;

struct Node {
    int x,y;
}m[MaxM],p[MaxR][MaxR];

int R,C,M,Ans;
char a[MaxR][MaxR];
int b[MaxR][MaxR],c[MaxR][MaxR],d[MaxR][MaxR],t[MaxR][MaxR];
bool Vis[MaxR][MaxR];

bool InM(int x,int y)
{
    return x>=0 && x<R && y>=0 && y<C;
}

void BFS(int sx,int sy,int gx,int gy)
{
    memset(Vis,0,sizeof(Vis));
    memset(p,0,sizeof(p));
    queue<Node> Q;
    Node Qf,Nt;
    Nt.x = sx;
    Nt.y = sy;
    Q.push(Nt);
    Vis[sx][sy] = true;
    while ( !Q.empty() )
    {
        Qf = Q.front();
        Q.pop();
        for ( int i=0;i<4;i++ )
        {
            Nt.x = Qf.x+dir[i][0];
            Nt.y = Qf.y+dir[i][1];
            if ( InM(Nt.x,Nt.y) && a[Nt.x][Nt.y]=='.' && !Vis[Nt.x][Nt.y] )
            {
                Q.push(Nt);
                Vis[Nt.x][Nt.y] = true;
                p[Nt.x][Nt.y].x = Qf.x;
                p[Nt.x][Nt.y].y = Qf.y;
                if ( Nt.x==gx && Nt.y==gy )  return ;
            }
        }
    }
}

int DFS(int sx,int sy,int gx,int gy)
{
    if ( sx==gx && sy==gy )
    {
        return t[sx][sy];
    }
    int tt=DFS(sx,sy,p[gx][gy].x,p[gx][gy].y)+1;
    Ans += c[gx][gy]+d[gx][gy];
    if ( t[gx][gy] )
    {
        if ( c[gx][gy]+d[gx][gy]>(tt-t[gx][gy])*b[gx][gy] )
            Ans += (tt-t[gx][gy])*b[gx][gy]-(c[gx][gy]+d[gx][gy]);
    }
    return  t[gx][gy]=tt;
}

int main()
{
    while ( scanf("%d %d %d",&R,&C,&M)!=EOF )
    {
        for ( int i=0;i<R;i++ )
            scanf("%s",a[i]);
        for ( int i=0;i<R;i++ )
         for ( int j=0;j<C;j++ )
            scanf("%d",&b[i][j]);
        for ( int i=0;i<R;i++ )
         for ( int j=0;j<C;j++ )
            scanf("%d",&c[i][j]);
        for ( int i=0;i<R;i++ )
         for ( int j=0;j<C;j++ )
            scanf("%d",&d[i][j]);
        for ( int i=0;i<M;i++ )
            scanf("%d %d",&m[i].x,&m[i].y);
        memset(t,0,sizeof(t));
        t[m[0].x][m[0].y] = 1;
        Ans = c[m[0].x][m[0].y]+d[m[0].x][m[0].y];
        for ( int i=0;i<M-1;i++ )
        {
            BFS(m[i].x,m[i].y,m[i+1].x,m[i+1].y);
            DFS(m[i].x,m[i].y,m[i+1].x,m[i+1].y);
        }
        printf("%d\n",Ans);
    }
    return 0;
}

Measured memory_bytes: 1024
import numpy as np
import math

n, k = map(int, input().split())
ans = 0

for i in range(1, n+1):
    if i >= k:
        ans += 1
    else:
        success = math.ceil(np.log2(k/i))
        ans += 0.5 ** success
    
print(ans/n)

Measured memory_bytes: 21376
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ini(N);
  inl(K);
  vector<P> v(N); in(v);
  sort(all(v));
  ll s = 0;
  rep(i , N){
    s += v[i].se;
    if(s >= K) die(v[i].fi);
  }



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

signed main(){
    int n;
    cin >> n;
    int a = 1;
    int b = 1;
    int x, y;
    rep(i, n) {
        cin >> x >> y;
        int m = max((a+x-1)/x, (b+y-1)/y);
        a = x*m;
        b = y*m;
        //cout << m << " "<< a << " " << b << endl;
    }
    cout << a+b << endl;


}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<string>
#include<algorithm>
using namespace std;
typedef vector<int> vi;


int main() {
	int w, h;
	cin >> h >> w;
	char bd[8][8];
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < w; j++) {
			bd[i][j] = s[j];
		}
	}
	int count = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (bd[i][j] == '#')count++;
		}
	}
	if (count != w + h - 1) {
		cout << "Impossible" << endl;
		return 0;
	}

	int ans[8][8];
	memset(ans, 0, sizeof(ans));
	ans[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (bd[i][j] == '#') {
				if (i > 0 && ans[i - 1][j] == 1 || j > 0 && ans[i][j - 1] == 1) {
					ans[i][j] = 1;
				}
			}
		}
	}
	if (ans[h - 1][w - 1] == 1) {
		cout << "Possible" << endl;

	}
	else {
		cout << "Impossible" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.math;

import std.typecons;
alias Seg = Tuple!(int, "l", int, "r", int, "len");

void main() {
    int n, m;
    scan(n, m);

    auto p = new Seg[](n);

    foreach (i ; 0 .. n) {
        int li, ri;
        scan(li, ri);
        p[i] = Seg(li, ri, ri - li + 1);
    }

    p.sort!"a.len < b.len"();

    writeln(n);

    //auto ft = FenwickTree(m + 2);
    auto sd = SqrtDecomp(m + 2);

    foreach (d ; 2 .. m + 1) {
        while (!p.empty && p.front.len < d) {
            //ft.add(p.front.l, 1);
            //ft.add(p.front.r + 1, -1);
            sd.add(p.front.l, 1);
            sd.add(p.front.r + 1, -1);
            p.popFront();
            n--;
        }

        int ans = n;

        for (int i = 0; i <= m; i += d) {
            ans += sd.sum(0, i + 1);
        }

        writeln(ans);
    }
}

struct SqrtDecomp {
    private {
        enum rt = 512;
        int N, K;
        int[] buck;
        int[] data;
    }

    this(int n) {
        N = n;
        K = (N + rt - 1) / rt;
        buck = new int[](K);
        data = new int[](K * rt);
    }

    void add(int i, int x) {
        data[i] += x;

        int k = i / rt;
        buck[k] = 0;
        foreach (j ; k * rt .. (k + 1) * rt) {
            buck[k] += data[j];
        }
    }

    int sum(int l, int r) {
        int res;

        foreach (k ; 0 .. K) {
            int bl = k * rt, br = (k + 1) * rt;
            if (r <= bl || br <= l) continue;
            if (l <= bl && br <= r) {
                res += buck[k];
            }
            else {
                foreach (j ; max(l, bl) .. min(r, br)) {
                    res += data[j];
                }
            }
        }

        return res;
    }
}


struct FenwickTree {
    private {
        int N;
        int[] data;
    }

    this(int n) {
        N = n;
        data = new int[](N + 1);
    }

    void add(int i, int x) {
        i++;
        while (i <= N) {
            data[i] += x;
            i += i & (-i);
        }
    }

    int sum(int r) {
        int res;
        while (r > 0) {
            res += data[r];
            r -= r & (-r);
        }
        return res;
    }
}


void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 1000005
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[MAX_N];

void solve()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	FOR(i, 2,(int)sqrt(MAX_N))
	{
		if (prime[i] == true)
		{
			for (int j = 2; j*i <= MAX_N; j++){
				prime[i*j] = false;
			}
		}
	}
}

int main()
{
	int n;
	while (cin >> n)
	{
		if (n==0)break;
		
		int ans = 0;
		solve();
		FOR(i,n+1,2*n+1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

template <ll mod>
struct modular {
    ll value;
    modular(ll x = 0) {
        value = x % mod;
        if (value < 0) value += mod;
    }

    modular& operator+=(modular other) {
        if ((value += other.value) >= mod) value -= mod;
        return *this;
    }
    modular& operator-=(modular other) {
        if ((value -= other.value) < 0) value += mod;
        return *this;
    }
    modular& operator*=(modular other) {
        value = value * other.value % mod;
        return *this;
    }
    modular& operator/=(modular other) {
        ll a = 0, b = 1, c = other.value, m = mod;
        while (c != 0) {
            ll t = m / c;
            m -= t * c;
            swap(c, m);
            a -= t * b;
            swap(a, b);
        }
        value = value * a % mod;
        return *this;
    }
    modular& operator^=(modular other) {
        ll r = 1, x = value, n = other.value;
        while (n > 0) {
            if (n & 1) r = r * x % mod;
            x = x * x % mod;
            n >>= 1;
        }
        value = r;
        return *this;
    }
    modular operator+(modular rhs) {
        return modular(*this) += rhs;
    }
    modular operator-(modular rhs) {
        return modular(*this) -= rhs;
    }
    modular operator*(modular rhs) {
        return modular(*this) *= rhs;
    }
    modular operator/(modular rhs) {
        return modular(*this) /= rhs;
    }
    modular operator^(modular rhs) {
        return modular(*this) ^= rhs;
    }
    bool operator==(modular rhs) {
        return value == rhs.value;
    };
    bool operator!=(modular rhs) {
        return value != rhs.value;
    };
    bool operator<(modular rhs) {
        return value < rhs.value;
    }
};
template <ll mod>
string to_string(modular<mod> x) {
    return to_string(x.value);
}
template <ll mod>
ostream& operator<<(ostream& stream, modular<mod> x) {
    return stream << x.value;
}
template <ll mod>
istream& operator>>(istream& stream, modular<mod>& x) {
    stream >> x.value;
    x.value %= mod;
    if (x.value < 0) x.value += mod;
    return stream;
}
const ll mod = 1e9 + 7;
using mint = modular<mod>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, c;
    cin >> n >> c;
    vector<int> a(n), b(n);
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    vector<vector<mint>> pw(401, vector<mint>(401, 1));
    rep(i, 1, 401) rep(j, 0, 401) {
        pw[i][j] = pw[i - 1][j] + ((mint)i ^ (mint)j);
    }
    vector<vector<mint>> dp(n + 1, vector<mint>(c + 1));
    dp[0][0] = 1;
    rep(i, 0, n) {
        rep(j, 0, c + 1) {
            rep(k, j, c + 1) {
                dp[i + 1][k] += dp[i][j] * (pw[b[i]][k - j] - pw[a[i] - 1][k - j]);
            }
        }
    }
    debug(dp);
    cout << dp[n][c] << endl;
    return 0;
}

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

int main(){
  long long n, x, t;
  cin >>n >> x >> t;
  long long l = n/x;
  if(n % x == 0){
    cout << l*t << endl;
  }
  else{
    cout << l*t + t<< endl;
  }
}

Measured memory_bytes: 3632
H,W,M = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(M)]

dh = {}
dw = {}
for i in range(M):
    h,w = hw[i]
    if h not in dh:
        dh[h] = 0
    dh[h] += 1
    if w not in dw:
        dw[w] = 0
    dw[w] += 1

mh = 0
mw = 0
for h in dh:
    mh = max(mh,dh[h])
hcand = []
for h in dh:
    if dh[h]==mh:
        hcand.append(h)

for w in dw:
    mw = max(mw,dw[w])
wcand = []
for w in dw:
    if dw[w]==mw:
        wcand.append(w)

n_cand = len(hcand)*len(wcand)
for i in range(M):
    h,w = hw[i]
    if dh[h]==mh and dw[w]==mw:
        n_cand -= 1

if n_cand>0:
    ans = mh+mw
else:
    ans = mh+mw-1

print(ans)

Measured memory_bytes: 202640
N, M = list(map(int, input().split()))
edges = []
for _i in range(M):
    edges.append(list(map(int, input().split())))

import networkx as nx

G = nx.Graph()
G.add_edges_from(edges)
ans = 1
for comp in nx.connected_components(G):
    # H = G.subgraph(comp)
    # print(H.edges)
    ans = max(ans, len(comp))
print(ans)

Measured memory_bytes: 279028
def solve(balls):
    B,C=[],[]
    B.append(balls[0])
    for ball in balls[1:]:
        if B[-1]<ball:
            B.append(ball)
        else:
            if len(C)==0: C.append(ball)
            else:
                if C[-1]<ball:
                    C.append(ball)
                else:
                    return "NO"
    return "YES"

if __name__=='__main__':
    N=int(raw_input())
    for i in range(N):
        balls=map(int,raw_input().split())
        print solve(balls)

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;

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

   else
   {
       cout<<"No"<<endl;
   }
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int n,m;
  cin>>n>>m;
  vector<long long int> h(n);
  for(long long int i=0; i<n; i++){
    cin>>h.at(i);
  }
  vector<vector<int>> next(n);
  for(int i=0; i<m; i++){
    long long int a,b;
    cin>>a>>b;
    next.at(a-1).push_back(h.at(b-1));
    next.at(b-1).push_back(h.at(a-1));
  }

  for(int i=0; i<n; i++){
    sort(next.at(i).begin(),next.at(i).end());
  }
  long long int ans=0;
  for(int i=0; i<n; i++){
    bool good=true;
    if(!next.at(i).empty()){
      if(h.at(i)<=next.at(i).at(next.at(i).size()-1)){
        good=false;
      }
    }
    if(good){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9068
n, k = map(int, input().split())
a = list(map(int, input().split()))
l = [1]

for i in range(n):
  l.append(a[l[i]-1])
p = l.index(l[n])
#print(p,l[n])
if k<=n:
  print(l[k])
else:
  x = (k-n+1)%(n-p)
  if x ==0:
    x += (n-p)
    print(l[x-1])
  else:
    print(l[x+p-1])


Measured memory_bytes: 32376
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
typedef long long integer;
//////////////////////////////////////////////////
const int UNIMAX = 100005;
int uni[UNIMAX] = {}; //parent -- size of member , kid -- leader name,def -1

int uniroot(int a){ //return a's leader
	if (uni[a] < 0) return a;
	return uni[a] = uniroot(uni[a]); //uni[a] => 0 , reconnect root directly
}

bool uniconnect(int a,int b){
	a = uniroot(a);
	b = uniroot(b);
	
	if(a==b) return false;
	
	if(uni[a] > uni[b]){
		a ^= b;
		b ^= a;
		a ^= b;
	}
	
	uni[a] = uni[a] + uni[b]; // membersize++
	uni[b] = a;
	return true;
}

bool uniisConnect(int a,int b){
	return (uniroot(a) == uniroot(b));
}

int unireset() {
	REP(i,UNIMAX){
		uni[i] = -1;
	}
}

int unisize (int a){
	return (-uni[uniroot(a)]);
}

int main(){
    int N;
    SCD(N);
    vector< PII > xy;
    map< PII , int> f;
    REP(i,N){
        int x,y; SCD2(x,y);
        PII p = MP(x,y);
        f[p] = i;
        xy.PB(p);
    }

    priority_queue< pair<int,PII> , vector<pair<int,PII> > ,greater<pair<int,PII> > >Q;
    sort(xy.begin(),xy.end());
    REP(i,N-1){ // x
        int x1,y1,x2,y2;
        x1 = xy[i].fst;
        x2 = xy[i+1].fst;
        y1 = xy[i].snd;
        y2 = xy[i+1].snd;

        int cost = min(abs(x2-x1) , abs(y2-y1));
        PII p1 = MP(x1,y1);
        PII p2 = MP(x2,y2);

        Q.push(MP(cost,MP(f[p1],f[p2])));
    }

    sort(xy.begin(),xy.end(),
    [](const PII& x, const PII& y){return x.second < y.second;}
    );

     REP(i,N-1){ // y
        int x1,y1,x2,y2;
        x1 = xy[i].fst;
        x2 = xy[i+1].fst;
        y1 = xy[i].snd;
        y2 = xy[i+1].snd;

        int cost = min(abs(x2-x1) , abs(y2-y1));
        PII p1 = MP(x1,y1);
        PII p2 = MP(x2,y2);

        Q.push(MP(cost,MP(f[p1],f[p2])));
    }

    unireset();
    int connected = 0;
    integer ans = 0;

    while((!Q.empty()) and (connected < N-1)){
        PII p = Q.top().snd;
        integer cost = Q.top().fst;
        Q.pop();

        if (uniisConnect(p.fst,p.snd)) continue;
        uniconnect(p.fst,p.snd);
        ans = cost + ans;
        connected++;
        //printf("%d --> %d, cost = %d\n",p.fst,p.snd,cost);
    }

    PRINTLLD(ans);
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  string s;
  cin >> s;
  bool can = true;
  for (int i = 0; i < s.size(); i++) {
    if (i % 2 == 0 && s[i] != 'h') can = false;
    if (i % 2 == 1 && s[i] != 'i') can = false;
  }
  if (can && s.size() % 2 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define REV(c) reverse((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

using namespace std;

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+') cout << a + b << endl;
	else cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD1        1000000007
#define MOD2        998244353
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)

using namespace std;


void solve()
{
    string s;
    cin >> s;

    s[2] == s[3] && s[4] == s[5] ? cout << "Yes\n" : cout << "No\n";
}


int main()
{
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
 //    freopen("output.txt", "w", stdout);
	// #endif

    ll t = 1;
    //cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 256
N,C = gets.split.map &:to_i
Sushis = (0...N).map{ gets.split.map &:to_i }

def solve(sushis)
  sv = 0
  cg = 0
  counter_gain = [0] + sushis.reverse_each.map{ |x,v|
    sv += v
    cg = [sv - 2*(C - x), cg].max
  }
  sv = 0
  ans = (0...N).map{ |i|
    x,v = sushis[i]
    sv += v
    sv - x + counter_gain[-i-2]
  }.max
  #p Sushis, counter_gain, ans
  ans
end

p [0, solve(Sushis), solve(Sushis.reverse.map{ |x,v| [C-x,v] })].max

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

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    int k; cin >> k;
    string s; cin >> s;
    if(s.size()>k){
        cout << s.substr(0,k) << "..." << endl;
    }else{
        cout << s << endl;
    }
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mod=1e9+7;
int ksm(int b,int n){
	int res=1;
	while(n){
		if(n&1) res=res*b%mod;
		b=b*b%mod; n>>=1;
	}
	return res;
} 
int f[2][505][505],c[505][505],cnt[505];
int fac[505],inv[505];
void init(int n){
	fac[0]=1;
	for(int i=1;i<=n;++i)
		fac[i]=fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	for(int i=n-1;i>=0;--i)
		inv[i]=(i+1)*inv[i+1]%mod;
	c[0][0]=1;
	for(int i=1;i<=n;++i){
		c[i][0]=1;
		for(int j=1;j<=i;++j)
			c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
}
void add(int &x,int y){
	x=(x+y)%mod;
}
signed main(){
	int n,X,li;
	cin>>n>>X;
	for(int i=1;i<=n;++i){
		cin>>li;
		cnt[li]++;
	}
	init(500);
	int now=0;
	f[now][0][0]=1;
	for(int i=X;i>=1;--i){
		now^=1;
		for(int j=0;j<=X;++j)
			for(int k=i*j;k<=X;++k){
				f[now][j][k]=0;
				for(int l=0;l<=j;++l)
					add(f[now][j][k],f[now^1][j-l][k-i*l]*inv[l]%mod);
				f[now][j][k]=f[now][j][k]*ksm(k-(i-1)*j,cnt[i])%mod;
			}
	}
	int ans=0;
	for(int i=1;i<=X;++i)
		for(int j=i;j<=X;++j){
			int res=f[now][i][j]*fac[i]%mod*c[X-j+1][i]%mod;
			if((X-j)&1) res=(mod-res)%mod;
			add(ans,res);
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8568
import java.util.*;


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

        Scanner sc = new Scanner(System.in);
        int count = 0;
        String str = sc.next();
        for (int i = 0; i < str.length(); i++) {
            if (str.charAt(i) == '1') {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
n,d=map(int,input().split())
x=[list(map(int,input().split())) for _ in range(n)]
cnt=0
for i in range(n):
  for j in range(i+1,n):
    dist=0
    for k in range(d):
      dist+=(abs(x[i][k]-x[j][k])**2)
    for l in range(int(dist**.5)+1):
      if dist==l**2:
        cnt+=1
print(cnt)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,ans;
    while(cin>>a,a!=0){
        ans=0;
        b=1000-a;
        ans+=b/500;
        b=b%500;
        ans+=b/100;
        b=b%100;
        ans+=b/50;
        b=b%50;
        ans+=b/10;
        b=b%10;
        ans+=b/5;
        b=b%5;
        ans+=b;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <stack>
#include <map>
#include <iomanip>
using namespace std;

int64_t min(int64_t a,int64_t b) {
    if (a > b)
    {
        return b ;
    }else
    {
        return a ;
    }
}

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

int64_t 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(){
    int64_t inf = 10000000000 ;
    int64_t n,m,k ;
    cin >> n >> m >> k ;
    vector<int64_t> a(n) ;
    vector<int64_t> b(m) ;
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b.at(i) ;
    }
    int64_t sum = 0 ;
    int64_t ans = 0 ;
    int ii = 0 ;
    int j = 0 ;
    for (size_t i = 0; i < n; i++)
    {
        if (sum + a.at(i) <= k)
        {
            sum += a.at(i) ;
            ii ++ ;
        }else
        {
            break ;
        }
        
        
    }
    
    for (size_t i = 0; i < m; i++)
    {
        if (sum + b.at(i) <= k)
        {
            sum += b.at(i) ;
            j++ ;
        }
        else
        {
            break ;
        }
        
    }
    if (sum <= k)
    {
        ans = ii + j ;
    }
    
    for (size_t i = 0; i < ii; i++)
    {
        sum -= a.at(ii-i-1) ;
        while (j < m)
        {
            if (j < m)
            {
                if (sum + b.at(j) <= k)
                {
                    sum += b.at(j) ;
                    j ++ ;
                }else
                {
                    break ;
                }
                
                
            }
            
            
        }
        if (sum <= k)
        {
            if (ii-i+j-1 > ans) 
            {
                ans = ii-i+j-1 ;
            }
            
        }
        
    }
    
    
    
    
    cout << ans << endl ;
}

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

using namespace std;

typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const LL MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
LL in[N];
LL maxi[N];

int main(){
	scanf("%d", &n);
	for(int i = 0; i <= n; ++i)
		scanf("%lld", &in[i]);
	
	if(in[0] >= 1){
		if(n == 0)
			puts(in[0] == 1 ? "1" : "-1");
		else
			puts("-1");
		exit(0);
	}
	
	maxi[0] = 1;
	for(int i = 1; i <= n; ++i){
		maxi[i] = min(INF, 2 * (maxi[i - 1] - in[i - 1]));

		if(maxi[i] < in[i]){
			puts("-1");
			exit(0);
		}
	}

	LL ans = 0;
	for(int i = n; i >= 0; --i){
		ans += min(in[i], maxi[i]);
		if(i)
			in[i - 1] += in[i];
	}

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 5400
//#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define sort(x) sort(x.begin(), x.end())
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;


int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    int c = 1;
    while (c < b){
      	c--;
        ans++;
        c += a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256