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

#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 REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define MOD  1000000007
#define INF  0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
typedef long long ll;

ll N,T;

int main() {
    
    cin >> N >> T;
    vector<ll> t(N);
    REP(i,N) cin >> t[i];
    t.push_back(1e18);
    
    ll ans = 0;
    ll time = t[0];
    for(int i=1;i<t.size();i++) {
        if(t[i] - time <= T) {
            ans += t[i] - time;
        } else {
            ans += T;
        }
        time = t[i];
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3328
import sys
sys.setrecursionlimit(100000)

H, W = list(map(int, input().split()))
s = [[c for c in input()] for _ in range(H)]
accept = True

def dfs(x, y, count):
    if  x < 0 or W <= x or y < 0 or H <= y:
        return count - 1
    elif s[y][x] != "#":
        return count - 1
    else:
        s[y][x] = "."
        return max(dfs(x-1, y, count+1), dfs(x+1, y, count+1), dfs(x, y-1, count+1), dfs(x, y+1, count+1))

for y in range(H):
    for x in range(W):
        if s[y][x] != "#":
            continue
        elif dfs(x, y, 0) == 0:
            accept = False

if accept:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 5236
class Union:
    def __init__(self, number):
        self.__number = number
        self.parentList = [-1] * number
 
    def getNumber(self):
        return self.__number 

    def getRoot(self, index):
        if self.parentList[index] < 0:
            return index
        root = self.getRoot(self.parentList[index])
        self.parentList[index] = root
        return root
      
    def unite(self, i, j):
        i = self.getRoot(i)
        j = self.getRoot(j)
        if i != j:
            if i > j:
                i, j = j, i
            self.parentList[i] += self.parentList[j]
            self.parentList[j] = i
 
    def getSize(self, i):
        return -self.parentList[self.getRoot(i)]
 
n, m = map(int, input().split())
 
friendUnion = Union(n)
for i in range(m):
  a, b = map(int, input().split())
  friendUnion.unite(a-1, b-1)
 
unionSizes = [friendUnion.getSize(i) for i in range(friendUnion.getNumber())]
print(max(unionSizes))

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

int main()
{
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(x-a) < abs(x-b)){
        cout << 'A' << endl;
    }
    else{
        cout << 'B' << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use itertools_num::ItertoolsNum;
use std::iter::once;

fn main() {
    input!(n: usize, m: usize, k: u64, a: [u64; n], b: [u64; m]);

    let a_s: Vec<u64> = once(0).chain(a.into_iter()).cumsum().collect();
    let b_s: Vec<u64> = once(0).chain(b.into_iter()).cumsum().collect();
    let mut j = m;

    println!("{}", a_s.into_iter()
        .take_while(|&x: &u64| x <= k)
        .enumerate()
        .map(|(i, x)| {
            while 0 < j && k < x + b_s[j] {
                j -= 1;
            }
            i + j
        })
        .max()
        .unwrap()
    );

}


Measured memory_bytes: 10952
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007

int d[13];

int main(){
	int n;
	cin >> n;
	VI v(n);
	d[0]++;
	for(int i=0;i<n;i++){
		cin >> v[i];
		d[v[i]]++;
	}
	for(int i=0;i<13;i++){
		if(d[i]>2){
			cout << 0 << endl;
			return 0;
		}
	}
	VI a;
	int x = 0;
	for(int i=0;i<13;i++){
		if(d[i]==1){
			if(x==0){
				a.push_back(i);
				x = 1;
			}else{
				a.push_back(-i);
				x = 0;
			}
		}else if(d[i]==2){
			a.push_back(i);
			a.push_back(-i);
		}
	}
	int mi = 1000;
	for(int i=0;i<a.size();i++){
		for(int j=i+1;j<a.size();j++){
			int tmp = min(abs(a[i]-a[j]),24-abs(a[i]-a[j]));
			if(tmp < mi){
				mi  = tmp;
			}
		}
	}
	cout << mi << endl;
	return 0;
}

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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];

// printf ("%.9f\n",x);

bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n,m;
    cin >> n >> m;
    ll sum = 0,x;
    ll arr[n+5] = {0};
    for (ll i = 1; i<=n; i++)
    {
        cin >> x;
        sum += x;
        arr[i] = x;
    }
    // cout << sum << endl;
    ll c = 0;
    for(ll i = 1; i<=n; i++)
    {
        if(arr[i] >= (0.25 * sum)/m) 
        {
            ++c;
        }
    }
    if (c >= m)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}   

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

namespace ConsoleApplication3
{
    class Program
    {
        static bool prime(int input)
        {
            if (input < 2)
                return false;
            if (input == 2)
                return true;
            if (input % 2 == 0)
                return false;
            double data2 = Math.Sqrt(input);
            for (int i = 3; i <= data2; i += 2)
            {
                if (input % i == 0)
                    return false;

            }
            return true;
        }

        static void Main(string[] args)
        {
            string temp;
            int number;
            int result = 0;
            temp = Console.ReadLine();
            number = int.Parse(temp);

            for (int i = 0; i < number; i++)
            {
                temp = Console.ReadLine();
                if(prime(int.Parse(temp)) == true)
                    result++;

            }


            Console.WriteLine("{0}", result);
        }
    }
}



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

long long  gcd(long long  a, long long  b) { return b ? gcd(b, a%b) : a; }
long long  lcm(long long  a, long long  b) { return a / gcd(a, b) * b; }

int main() {
	int N; cin >> N;
	cout << lcm(N, 2) << endl;
}




Measured memory_bytes: 256
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     pii             pair<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n, x)     (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     nshow(x,n)      for(int zz=0;zz<n;++zz)cout<<x[zz]<<" ";cout<<"\n";
#define     show2(x)        for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e10,M=1e9+7;
const int N=1;

int dp[12][12][2][2];
vector<int> arr;

int rec(int ind,int nxt,int tight,int ok)
{
    if(ind==-1)
        return ok;

    int& res=dp[ind][nxt][tight][ok];
    if(res!=-1)
        return res;

    int k;
    if(tight==1)
        k=arr[ind];
    else
        k=9;

    res=0;
    int nt;
    for(int i=0;i<=k;++i)
    {
        if(i==arr[ind])
            nt=tight;
        else
            nt=0;

        if(!ok)
        {
            if(i==0)
                res+=rec(ind-1,i,nt,0);
            else
                res+=rec(ind-1,i,nt,1);
        }
        else
        {
            if(abs(i-nxt)<=1)
                res+=rec(ind-1,i,nt,1);
        }
    }

    return res;
}

int func(int n)
{
    mem(dp,-1);
    arr.clear();

    for(;n;n/=10)
        arr.pb(n%10);

    int res,len=sz(arr);
    res=rec(len-1,0,1,0);
//    for(int i=0;i<arr[len-1];++i)
//        res+=rec(len-2,i,0);
//    res+=rec(len-2,arr[len-1],1);

    return res;
}

void solve()
{
    int k;
    cin>>k;

    int beg=1,en=inf;
    int mid,tmp,ans;

    while(beg<=en)
    {
        mid=(beg+en)/2;

        tmp=func(mid);

        //cout<<mid<<" "<<tmp<<"\n";

        if(tmp>=k)
        {
            ans=mid;
            en=mid-1;
        }
        else
            beg=mid+1;
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 256
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        route_count = [0 for _ in range(num_of_city)]
        route_count[self.start_point] = 1
        while len(heap_q) != 0:
            prev_cost, src = heapq.heappop(heap_q)

            if dist[src] < prev_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
                if dist[dest] == dist[src] + cost:
                    route_count[dest] += route_count[src]

        if self.goal_point is not None:
            return self._get_path(self.goal_point, prev)
        else:
            return dist, route_count

    def _get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))

s_list = []
h, w = map(int, input().split())
for i in range(h):
    s_list.append(input())

route = [dict() for _ in range(h*w)]
all_white = 0
for i in range(h):
    for j in range(w):
        if s_list[i][j] == "#":
            continue
        else:
            all_white += 1
        if i != h-1 and s_list[i+1][j] == ".":
            route[w*i+j][w*(i+1)+j] = 1
        if j != w-1 and s_list[i][j+1] == ".":
            route[w*i+j][w*i+j+1] = 1
        if i != 0 and s_list[i-1][j] == ".":
            route[w*i+j][w*(i-1)+j] = 1
        if j != 0 and s_list[i][j-1] == ".":
            route[w*i+j][w*i+j-1] = 1

di = Dijkstra(route, 0, h*w-1)
r = di.execute()
count = len(r)
if count > 1:
    print(all_white-count)
else:
    print(-1)

Measured memory_bytes: 4340
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	int N;
	cin >> N;
	vector<long long int> L(N+1);
	L[0] = 2;
	L[1] = 1;
	for (int i = 2; i <= N; i++) {
		L[i] = L[i - 1] + L[i - 2];
	}
	cout << L[N] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX(a,b) ((a>b)?(a):(b))
#define MIN(a,b) ((a>b)?(b):(a))

int main(void) {
  int n,m,x,y,buf,flg=1;
  int ma=-100,mb=100;
  scanf("%d%d%d%d",&n,&m,&x,&y);
  for(int i=0;i<n;i++){
    scanf("%d",&buf);
    ma=MAX(ma,buf);
  }
  for(int i=0;i<m;i++){
    scanf("%d",&buf);
    mb=MIN(mb,buf);
  }
  for(int z=x+1;z<y+1;z++){
    if(ma<z && mb>=z){
      printf("No War\n");
      flg=0;
      break;
    }
  }
  if(flg){printf("War\n");}
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[10000];
    for(int i=0;i<n;i++) cin>>a[i];
    int mn=a[0],mx=a[0];
    long long sum=0;
    for(int i=0;i<n;i++){
        mn=min(mn,a[i]);
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    cout<<mn<<" "<<mx<<" "<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

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

		if ((k - a) <= 0) {
			System.out.print(k);
		} else if ((k - (a + b)) <= 0) {
			System.out.print(a);
		} else if ((k - (a + b + c)) <= 0) {
			System.out.print(a - (k - a - b));
		}
	}

}


Measured memory_bytes: 27008
s = gets.chomp
if(s[0] == "A")
  if(s[2..(s.size-2)].count("C")==1)
    s = s.delete("AC")
    s.each_char do |c|
      next if(c=="A" or c=="C")
      if(c.ord < "Z".ord)
        puts "WA"
        exit
      end
    end
    puts "AC"
    exit
  end
end
puts "WA"

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

#define INF 1<<30
#define LINF 1ll<<60ll
#define MOD 1000000007
#define pb(a) push_back(a)

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)
#define REPARR(i, v) for(int i = 0;i < sz(v);++i)

#define all(vec) (vec.begin()),(vec.end())
#define sz(x) ((int)(x).size())
#define bit(n) (1ll<<(n))

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

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl



int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    REP(i,n){
        cin>>s[i];
    }
    sort(all(s));
    REP(i,n){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a[100007],b[47],c[47],d[47];
int main(){
    int n;
    long long k;
    cin>>n>>k;
    long long x=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        for(int j=0;j<=40;j++){
            if(a[i]&((long long)1<<j))
                b[j]++;
        }
    }
    x=0;
    for(int i=40;i>=0;i--){
        if(b[i]<n-b[i]){
            if(x+((long long)1<<i)<=k)
                x+=((long long)1<<i);
        }
    }
    long long ans=0;
    for(int i=1;i<=n;i++){
        ans+=x^a[i];
    }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int comp(long long int n,long long int k){
  long long ans=1;
  for(long long int i=1;i<=k;i++){
    ans=ans*(n-i+1)/i;
  }
  return ans;
}
int main(){
  map<long long int,long long int> x;
  long long int tmp=1,i,a[200010],mod=2019;
  long long int ans=0;
  vector<long long int> b;
  string s;
  cin  >> s;
  reverse(s.begin(),s.end());
  a[0]=0;
  for(i=0;i<s.size();i++){
    a[i+1]=(a[i]+(s[i]-'0')*tmp)%mod;
    tmp=tmp*10%mod;
  }
  for(i=0;i<=s.size();i++){
    if(x[a[i]]==0){
      b.push_back(a[i]);
    }
    x[a[i]]++;
  }
  for(i=0;i<b.size();i++){
    ans+=comp(x[b[i]],2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7) cout << "YES" << endl;
    else cout << "NO" << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define inf 1000000000
const ll mod = 1000000007;
const int N = 2e5 + 11;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
char a[30][30];
int sum,ans=INT_MIN;
int n,k,m;
queue<pi>q;
vector<pi>v;
bool ok(pi p){
	if(p.ff<0 || p.ff>n || p.ss<0 || p.ss>m)return 0;
	if(a[p.ff][p.ss]!='.')return 0;
	return 1;
}
int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

	cin>>n>>m;
	forn(i,1,n){
		forn(j,1,m){
			cin>>a[i][j];
			if(a[i][j]=='.')v.pb(mp(i,j));
		}
	}
forn(e,0,sz(v)-1){
q.push(v[e]);
map<pair<int, int>, int> dist;
map<pair<int, int>, int> viz;
	while(!q.empty()){
		pi pe=q.front();
		q.pop();
		viz[pe]=1;
		for(int i = 0; i < 4; i++){
			pi step = mp(pe.ff + dx[i] , pe.ss + dy[i]);
			if(!dist[step] && ok(step) && !viz[step]) {
			//	cout<<step.ff<<' '<<step.ss<<'\n';
                dist[step] = dist[pe] + 1;
                q.push(step);
            }
		}	
	}
	for(auto it:dist)ans=max(ans,it.ss);	
}
cout<<ans<<'\n';
return 0;
}

Measured memory_bytes: 384
//binary search
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>

using namespace std;
typedef long long ll;
#define cls(x) memset(x,0,sizeof(x))


int n, q;
const int INF = 0x3f3f3f3f;
const int SZ = 200009;
string s;
vector<pair<char,char>> ops(SZ);

bool okl(int ind) {
  char t = s[ind];
  for(int i = 0; i < q; ++i) {
    char c = ops[i].first;
    char op = ops[i].second;
    if(t == c){
      if(op == 'L'){
        ind--;
      }else{
        ind++;
      }
      if(ind == n) return false;
      if(ind == -1) return true;
      t = s[ind];
    }
  }
  return false;
}

int bs_left()
{
  int l = 0, r = n;
  while(l < r) {
    int m = (l + r) >> 1;
    if(!okl(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  return l;
}

bool okr(int ind) {
  char t = s[ind];
  for(int i = 0; i < q; ++i) {
    char c = ops[i].first;
    char op = ops[i].second;
    if(t == c){
      if(op == 'R'){
        ind++;
      }else{
        ind--;
      }
      if(ind == n) return true;
      if(ind == -1) return false;
      t = s[ind];
    }
  }
  return false;
}

int bs_right()
{
  int l = 0, r = n;
  while(l < r) {
    int m = (l + r) >> 1;
    if(okr(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  return l;
}

int main() {
  cin >> n >> q;
  cin >> s;
  for(int i = 0; i < q; ++i) {
    char ch, dir;
    cin >> ch >> dir;
    ops[i] = {ch, dir};
  }
  int left = bs_left();
  int right = bs_right();
  //cout << left << "," << right << endl;
  if(right > left) {
    cout  << right - left << endl;
  } else {
    cout << 0 << endl;
  }
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int X;
vector<int> d;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> X;
  d.emplace_back(1);
  for(int b = 2 ; b <= 31 ; b++){
    int p = 2;
    while(true){
      if(pow(b,p) <= X){
        d.emplace_back(pow(b,p));
      }
      else{
        break;
      }
      p++;
    }
  }
  sort(d.begin(),d.end(),greater<int>());
  cout << d[0] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>

#define MX 10000000000
#define mod 1000000007
#define ll long long int
#define pb(x) push_back(x)
#define MP(x,y) make_pair(x,y)

using namespace std;

ll power( ll a, ll b, ll m )
{
	 if (b == 0)
		  return( 1 );
	 ll sol = power( a, b / 2, m );
	 sol = ( sol * sol ) % m;
	 if (b % 2 == 1)
		  sol = ( sol * a ) % m;
	 return( sol );
}

ll gcd( ll a, ll b )
{
	 if (b == 0)
		  return a;
	 else
	 {
		  return gcd( b, a % b );
	 }
}
void solve()
{
	int a, b;
	cin >> a >> b;
	int x= a ^ b;
	cout << x;
}
int main()
{
	 int t = 1;
	 //cin >> t;
	 while (t--)
	 {
		  solve();
	 }
	 return 0;
}

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

long long int A;
long long int B;
long long int C;
int main(){
	scanf("%lld%lld%lld", &A, &B, &C);
	for (int i = 0; i < 100000; i++){
		if ((A & 1LL) || (B & 1LL) || (C & 1LL)){
			cout << i << endl;
			return 0;
		}
		long long int AA = B / 2 + C / 2;
		long long int BB = A / 2 + C / 2;
		long long int CC = A / 2 + B / 2;
		A = AA;
		B = BB;
		C = CC;
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
l=[1,3,5,7,8,10,12]
r=[4,6,9,11]
s=[2]
if x in l and y in l:
    print("Yes")
    exit()
if x in r and y in r:
    print("Yes")
    exit()
if x in s and y in s:
    print("Yes")
    exit()

print("No")

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

int main() {
	int n;
	cin >> n;
	cout << 0 << endl;
	string b;
	cin >> b;
	if (b[0] == 'V') {
		return 0;
	}
	int l = 0, r = n, m;
	while (r - l > 1) {
		m = (r + l) / 2;
		cout << m << endl;
		string s;
		cin >> s;
		if (s[0] == 'V')
			return 0;
		if (m % 2) {
			if (s[0] == b[0])
				r = m;
			else
				l = m;	
		}
		else {
			if (s[0] == b[0])
				l = m;
			else
				r = m;	
		}
	}
	
	
	
	return 0;
}

Measured memory_bytes: 852
#include"bits/stdc++.h"
using namespace std;

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

  for (int i = 0; i <= (int)s.length() - 2; i++) {
    if (s[i] == s[i + 1] || (i + 2 < s.length() && s[i] == s[i + 2])) {
      cout << i + 1 << " " << (i + 3 > s.length() ? (i + 2 > s.length() ? i + 1 : i + 2) : i + 3) << endl;
      return;
    }
  }
  cout << -1 << " " << -1 << endl;
}

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



Measured memory_bytes: 3760
N, X, Y = map(int, input().split())
ans = []

for i in range(N-1):
  ans.append(0)

for i in range(1, N):
  for j in range(i + 1, N + 1):
    normal = abs(i - j)
    short = abs(X - i) + 1 + abs(Y - j)
    l = [normal, short]
    saitan = min(l)
    ans[saitan - 1] += 1

for i in range(N-1):
  print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
void chmin(ll &x, ll y) { x = min(x, y); }
void chmax(ll &x, ll y) { x = max(x, y); }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

const int maxn = 51;
const int maxv = 2600;
ll dp[maxn][maxv][maxn];

int main(){
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, n){
        cin >> x[i];
    }

    dp[0][0][0] = 1;
    rep(i, n){
        rep(j, maxv){
            rep(k, n+1){
                if(j-x[i] >= 0 && k>0) dp[i+1][j][k] += dp[i][j-x[i]][k-1];
                dp[i+1][j][k] += dp[i][j][k];
            }
        }
    }

    ll ans = 0;
    for(int i=1; i<maxv; i++){
        for(int j=1; j<maxn; j++){
            if(i == a*j) ans += dp[n][i][j];
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 52096
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define FOR(i, N) for (long i = 0; i < (N); i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    long K;
    cin >> N >> K >> Q;

    vector<int> A(Q);
    FOR(i, Q) {
        cin >> A[i];
    }

    vector<int> Ans_N(N);
    FOR(i, N) {
        Ans_N[i] = 0;
    }
    FOR(i, Q) {
        Ans_N[A[i] - 1]++;
    }

    FOR(i, N) {
        if (K - Q + Ans_N[i] > 0) {
            cout << "Yes"
                 << "\n";
        } else {
            cout << "No"
                 << "\n";
        }
    }

    return 0;
}


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
  
  int ans = 0;
  string s, t; cin >> s >> t;

  rep(i, si(s)) if (s[i] != t[i]) ++ans;

  cout << ans << endl;
  
}

Measured memory_bytes: 3772
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cctype>
#include<string>
#include<queue>
using namespace std;
template<typename T>inline T read(){
	register char c=getchar();register T x=0,b=1;
	for(;!isdigit(c);)b=(c=='-'?-1:1),c=getchar();
	for(;isdigit(c);)x=x*10+c-48,c=getchar();
	return x*b;
}
template<typename T>void put(T x){ //no negative
	if(x>9)put(x/10);
	putchar(x%10+48);
}
int main(){
	register int n=read<int>();
	register double sum=0;
	for(register int i=1;i<=n;++i)sum+=(1.0/read<int>());
	printf("%.8f",1.0/sum);
	return 0;
}




Measured memory_bytes: 256
N, W = (int(i) for i in input().split())
w = [0]*N
v = [0]*N
for i in range(N):
  w[i], v[i] = (int(j) for j in input().split())
w0 = w[0]
wh = [a - w0 for a in w]
dp = [[[-1]*(N+1) for i in range(3*N+1)] for j in range(N+1)]
dp[0][0][0] = 0
for i in range(N):
  for j in range(3*N+1):
    for k in range(N+1):
      if dp[i][j][k] != -1:
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k])
      if j - wh[i] >=0 and k-1 >=0 and dp[i][j-wh[i]][k-1] != -1:
        dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j-wh[i]][k-1]+v[i])
res = 0
for j in range(3*N+1):
  for k in range(N+1):
    if j + w0*k <= W:
      res = max(dp[N][j][k], res)
print(res)


Measured memory_bytes: 71132
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> cnt(1e6+1, 0);
    rep(i, n) {
        int x = a[i];
        if (cnt[x] != 0) {
            cnt[x] = 2;
            continue;
        }
        int idx = x;
        while(1) {
            if (idx > 1e6) break;
            ++cnt[idx];
            idx += x;
        }
    }
    // rep(i, 26) {
    //     cout << cnt[i] << " ";
    // }
    // cout << endl;
    int ans = 0;
    rep(i, n) {
        if (cnt[a[i]] == 1) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7948
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int ab = a+b;
		if(ab%2==1) {
			System.out.println("IMPOSSIBLE");
		}else {
			System.out.println(ab/2);
		}
		sc.close();
	}
}


Measured memory_bytes: 35896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    int ans = 10000;

    string tmp, nxt;

    for(char c='a'; c<='z'; c++){
        tmp = s;
        int turn = 0;
        while(true){
            bool flg = true;
            for(int i=0; i<tmp.size(); i++) if(tmp[i] != c) flg = false;
            if(flg){
                ans = min(ans, turn);
                break;
            }

            if(tmp.size() <= 1) break;
            nxt = "";
            for(int i=0; i<tmp.size()-1; i++){
                if(tmp[i] == c || tmp[i+1] == c) nxt += c;
                else nxt += tmp[i];
            }

            turn++;
            tmp = nxt;
        }
    }

    cout << ans << endl;
}


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

long long N, S;
long long A[3005];

#define DIV 998244353
long long memo[3005][9005];


int main(){
	cin >> N >> S;
	for(long long i = 0; i < N; i++) {
		cin >> A[i];
	}

	memo[0][0] = 1;
	for(long long i = 0; i < N; i++) {
		for(long long j = 0; j < 3002; j++) {
			if(memo[i][j]) {
				memo[i+1][j] += 2*memo[i][j];
				memo[i+1][j] %= DIV;
				memo[i+1][j+A[i]] += memo[i][j];
				memo[i+1][j+A[i]] %= DIV;
			}
		}
	}

	cout << memo[N][S] << endl;
}


Measured memory_bytes: 117156
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

int main() {
	int n;
	vector<int> arr;
	cin >> n;
	int x;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		arr.push_back(x);
		sum += x;
	}

	sort(arr.begin(), arr.end());
	
	
	int median = sum/n;

	// cout << "median is "  << median << endl;
	int ans = 0;
	for (auto num : arr) {
		ans += (median - num)*(median - num);
	}

	median = sum/n + 1;
	int ans2=0;
	for (auto num : arr) {
		ans2 += (median - num)*(median - num);
	}

	cout << min(ans, ans2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
int main()
{
   int a[101]={0},cnt=0,t=3,p;
   while(t--)
   {
      cin>>p;
      a[p]=1;
   }
   for(int i=1;i<101;i++)
   {
      if(a[i]==1)
         cnt++;
   }
   cout<<cnt<<nl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n,m = map(int,input().split())
d = defaultdict(int)
for i in range(n):
    a = list(map(int,input().split()))
    for i in range(a[0]):
        d[a[i+1]] += 1
ans = 0
for k,v in d.items():
    if v==n:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
inline int rd(){
    char c=getchar();int x=0,flag=1;
    for(;c<'0'||c>'9';c=getchar())if(c=='-')flag=-1;
    for(;c>='0'&&c<='9';c=getchar())x=x*10+c-'0';
    return x*flag;
}
int n,nw[500010],d[500010],f[500010];
int main(){
//  freopen("a.in","r",stdin);
    n=rd();nw[0]=rd();f[n+1]=1;
    for(int i=1;i<=n;i++)
        d[i]=rd();
    for(int i=1;i<=n;i++)
        nw[i]=min(nw[i-1],abs(nw[i-1]-d[i]));
    for(int i=n;i;i--)
        f[i]=(f[i+1]<=d[i]/2)?f[i+1]:f[i+1]+d[i];
    for(int i=rd();i;i--){
        int x=rd();
        puts(nw[x-1]>=f[x+1]?"YES":"NO");
    }
    return 0;
}

Measured memory_bytes: 7680
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
char map[50][50];
char c[3]={'W','B','R'};
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<n;i++)for(int j=0;j<m;j++)cin>>map[i][j];
	int ans=1000000000;
	for(int i=1;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int cnt=0;
			for(int f=0;f<n;f++){
				int set=1;
				if(f<i)set=0;
				if(f>=j)set=2;
				for(int g=0;g<m;g++){
					if(map[f][g]!=c[set])cnt++;
				}
			}
			ans=min(ans,cnt);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;


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

int min_a=1e9;
int count=0;
bool check=0;
ll ans=0;
REP(i,n){
    ll a; cin>>a;
    if(a<0){
        count++;
        a=-a;
    }
    if(a==0)check=1;
    if(a<min_a)min_a=a;
    ans+=a;
}
//負の数が偶数個の場合と０が一個以上ある場合はすべて正にできる
//奇数個の場合は一個負が余る、それを最小の数にできる

if(!check&&count%2==1)ans-=min_a*2;
cout<<ans<<endl;

}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	long MOD = 1000000000 + 7;
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int diff = Math.abs(a - b);
			if(diff >= 2){
				System.out.println(0);
				continue;
			}
			else if(diff == 0){
				long res = calc(a);
				long ans = (res * res) % MOD;
				ans = (ans * 2) % MOD;
				
				System.out.println(ans);
			}
			else{
				long res = (calc(a) * calc(b)) % MOD;
				System.out.println(res);
			}

		}
	}
	
	private long calc(long a){
			
		long res = 1;
		for(int i = 2; i <= a; i++){
			res = (res* i) % MOD;
		}
		return res;
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    vector<vector<int>> x(h, vector<int>(w));
    vector<vector<int>> y(h, vector<int>(w));
    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '#') {
                x[i][j] = 0;
                y[i][j] = 0;
            }
            else {
                if(i > 0) y[i][j] = y[i-1][j] +1;
                else y[i][j] = 1;
                if(j > 0) x[i][j] = x[i][j-1] +1;
                else x[i][j] = 1;
            }
        }
    }
    repr(i, h) {
        repr(j, w) {
            if(s[i][j] == '#') continue;
            if(i+1  < h) chmax(y[i][j], y[i+1][j]);
            if(j+1  < w) chmax(x[i][j], x[i][j+1]);
        }
    }
    int ans = 0;
    rep(i, h) rep(j, w) ans = max(ans, x[i][j] + y[i][j] - 1);
    cout << ans << endl;
    return 0;
}

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

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

    // all the code goes here
    int h, w;
    cin >> h >> w;
    const int modulo = 1000000007;
    vector<vector<char>> grid(h, vector<char>(w));

    for (int i = 0; i < h; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < s.length(); j++)
        {
            grid[i][j] = s[j];
        }
    }

    int dp[h][w];
    memset(dp, 0, sizeof(dp));
    if (grid[0][1] == '.')
        dp[0][1] = 1;
    if (grid[1][0] == '.')
        dp[1][0] = 1;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if ((i != 0 || j != 0) && grid[i][j] == '.')
            {
                // cout << i << " " << j << "\n";
                int a = 0, b = 0;
                if (i - 1 >= 0)
                    a = dp[i - 1][j];
                if (j - 1 >= 0)
                    b = dp[i][j - 1];
                dp[i][j] = max(dp[i][j], (a + b) % modulo);
            }
        }
    }

    cout << dp[h - 1][w - 1] << "\n";
    return 0;
}

Measured memory_bytes: 5120
n=int(input())
c=list(map(int,input().split()))
dp=[0]
if n>1:
    dp.append(abs(c[1]-c[0]))
    for i in range(2,n):
        dp.append(min(dp[-1]+abs(c[i-1]-c[i]),dp[-2]+abs(c[i-2]-c[i])))
print(dp[-1])


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  int n, k;
  cin >> n >> k;

  vi a(n);
  rep(i,0,n) cin >> a[i];

  rep(i,0,k) {
    vi fin(n+1), com(n+1);
    rep(i,0,n) {
      ++com[max(0,i-a[i])];
    }

    int lhs = 0, rhs = 0;
    vi ans(n);
    rep(i,0,n) {
      rhs += com[i];
      ans[i] = lhs + rhs;
      --rhs;
      ++fin[min(n-1,a[i]+i)];
      ++lhs;
      lhs -= fin[i];
    }
    if (a==ans) break;
    a = ans;
  }

  rep(i,0,n) cout << a[i] << ' ';
  cout << '\n';

}

Measured memory_bytes: 6368
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll x;
    cin >> x;
    ll ans = 0;
    ll mon = 100;
    while(mon < x){
        ans++;
        mon = mon*1.01;
    }
    dunk(ans);
    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  
  if(A+B > C+D){
    cout << "Left" << endl;
  }
  else if(A+B < C+D){
    cout << "Right" << endl;
  }
  else{cout << "Balanced" << endl;
      }
}

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

ll rec(int n, ll x){
	if(n==0) return 1;
	ll len = (1LL<<(n+1))-3;
	ll pd = (1LL<<n)-1;
	if(x==1)return 0;
	else if(x < len+2) return rec(n-1,x-1);
	else if(x == len+2) return pd+1;
	else if(x < len*2+3) return pd+1 + rec(n-1,x-len-2);
	else  return pd*2+1;
}

int main(){
	int n;
	ll x;
	cin >> n >> x;
	cout << rec(n,x) << endl;
	return 0;
}

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

using namespace std;
using int64 = long long;
using IntPair = pair<int, int>;

constexpr int DEBUG = 0;

struct Edge {
  IntPair from;
  IntPair to;
  bool w;
  Edge(IntPair from, IntPair to, bool w) : from(from), to(to), w(w) {}
};

struct PairHash {
  std::size_t operator()(const pair<int, int>& k) const {
    return hash<int>()(k.first) * 1000000007 ^ hash<int>()(k.second);
  }
};

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

  int n, m;
  cin >> n >> m;

  map<IntPair, vector<Edge>> graph;
  for (int i = 0; i < m; i++) {
    int v1, v2, c;
    cin >> v1 >> v2 >> c;
    v1--;
    v2--;
    IntPair a1 = IntPair(v1, 0);
    IntPair b1 = IntPair(v1, c);
    IntPair a2 = IntPair(v2, 0);
    IntPair b2 = IntPair(v2, c);
    graph[a1].push_back(Edge(a1, b1, true));
    graph[b1].push_back(Edge(b1, a1, false));
    graph[a2].push_back(Edge(a2, b2, true));
    graph[b2].push_back(Edge(b2, a2, false));
    graph[b1].push_back(Edge(b1, b2, false));
    graph[b2].push_back(Edge(b2, b1, false));
  }

  unordered_map<IntPair, int, PairHash> d_map;
  unordered_set<IntPair, PairHash> visited;
  deque<IntPair> q;
  d_map[IntPair(0, 0)] = 0;
  q.push_back(IntPair(0, 0));

  while (!q.empty()) {
    auto p = q.front();
    q.pop_front();

    if (visited.find(p) != visited.end()) continue;
    visited.insert(p);
    
    if (p.first == n - 1) {
      cout << d_map[p] << endl;
      return 0;
    }
    for (const auto& e : graph[p]) {
      auto next = e.to;
      if (e.w) {
        if (d_map.find(next) == d_map.end()) {
          d_map[next] = d_map[p] + 1;
          q.push_back(next);
        }
      } else {
        if (d_map.find(next) == d_map.end() || d_map[p] < d_map[next]) {
          d_map[next] = d_map[p];
          q.push_front(next);
        }
      }
    }
  }

  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 100200
#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 fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7; ;
const ll inf=1e18;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

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

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}



int main()
{
    fast;
    ll t;
    //~ cin>>t;
    t=1;
    while(t--){
			
			ll h,n;
			cin>>h>>n;
			pair<ll,ll>a[n+1];
			for(int i=0;i<n;i++){
				cin>>a[i+1].xx>>a[i+1].yy;
			}
			ll dp[n+1][h+1];
			for(int i=0;i<=n;i++){
				for(int j=0;j<=h;j++){
					dp[i][j]=inf;
				}
			}
			dp[0][0]=0;
			for(int i=1;i<=n;i++){
				dp[i][0]=0;
				for(int j=1;j<=h;j++){
					if(j<a[i].xx){
						dp[i][j] = min(dp[i-1][j],a[i].yy);
					}else{
						dp[i][j] = min({dp[i-1][j-a[i].xx]+a[i].yy, dp[i-1][j],dp[i][j-a[i].xx]+a[i].yy});
					}
				}
			}
			cout<<dp[n][h];
			
    }
    return 0;
}


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

long long dp[101][100001];
pair<int, long long> c[101];
int main() {
    int n, W;
    cin >> n >> W;
    for(int i = 1; i <= n; i++) {
        int w, v;
        cin >> w >> v;
        c[i].first = w;
        c[i].second = v;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= W; j++) {
            if(i == 1) {
                if(j >= c[i].first)
                    dp[i][j] = c[i].second;
            }
            else {
                if(j < c[i].first) {
                    dp[i][j] = dp[i-1][j];
                }
                else {
                    dp[i][j] = max(dp[i-1][j], c[i].second + dp[i - 1][j - c[i].first]);
                }
            }
        }
    }
    cout << dp[n][W];
}

Measured memory_bytes: 78336