akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int n;
    cin >> n;
    cout << pow(n, 3) << endl;

}



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

using static Input;
using static Util;
class Program
{
    static int N;
    static string S;
    static void INPUT()
    {
        N = NextInt();
        S = NextString();
    }

    static void OUT()
    {
        var prev = ' ';
        var count = 0;
        foreach (var c in S)
            if (prev != c)
            {
                prev = c;
                count++;
            }

        Console.WriteLine(count);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 12116
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 

*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a, b, c;
  cin >> a >> b >> c;
 
  char t = a[0];
  a.erase(a.begin());
  while (true) {
    if (t == 'a') {
      if (a.size() == 0) {
        print("A");
        break;
      }
      t = a[0];
      a.erase(a.begin());
    } else if (t == 'b') {
      if (b.size() == 0) {
        print("B");
        break;
      }
      t = b[0];
      b.erase(b.begin());
    } else {
      if (c.size() == 0) {
        print("C");
        break;
      }
      t = c[0];
      c.erase(c.begin());
    }
  }

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int[] x = new int[n];
		for(int i = 0 ; i < n ; i++) x[i] = sc.nextInt();
		long[][][] dp = new long[n + 1][n + 1][2501];
		dp[0][0][0] = 1;
		// dp[i][j][k]:i枚のカードからj枚のカードを選んだときの和がkになる選び方の総数
		for(int i = 0 ; i < n ; i++) {
			for(int j = 0 ; j < n ; j++) {
				for(int k = 0 ; k <= 2500 ; k++) {
					// x[i]枚目のカードを選んだ時
					if(k + x[i] <= 2500) dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
					// x[i]枚目のカードを選ばない時
					dp[i + 1][j][k] += dp[i][j][k];
				}
			}
		}
		// dp[n][i][i * a]:n枚のカードからi枚のカードを選んだときの和がi * aになる選び方の総数を求める
		long ans = 0;
		for(int i = 1 ; i <= n ; i++) {
			ans += dp[n][i][i * a];
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main()
{
    int a,b,c,t;
    scanf("%d %d %d",&a,&b,&c);
    scanf("%d",&t);
    t/=50;
    if(a*10+2*b+c<t) printf("0\n");
    else
    {
        int ans=0;
        for(int i=0;i<=a&&i*10<=t;i++)
            for(int j=0;j<=b&&i*10+2*j<=t;j++)
                for(int k=0;k<=c&&i*10+2*j+k<=t;k++)
                if(i*10+2*j+k==t) ans++;
        printf("%d\n",ans);
    }
    return 0;
}


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  double xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt;
  int n; cin >> n;
  vector<double> x(n + 2), y(n + 2), r(n + 2); for (int i = 1; i <= n; i++) cin >> x[i] >> y[i] >> r[i];
  x[0] = xs; y[0] = ys; r[0] = 0.0;
  x[n + 1] = xt; y[n + 1] = yt; r[n + 1] = 0.0;
  struct adj { int to; double cost; };
  vector<vector<adj>> G(n + 2);
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j <= n + 1; j++) {
      if (j == i) continue;
      G[i].push_back(adj{j, max(0.0, hypot(x[j] - x[i], y[j] - y[i]) - r[i] - r[j])});
    }
  }
  vector<double> d(n + 2, 1e12);
  d[0] = 0.0;
  typedef pair<double, int> P;
  priority_queue<P, vector<P>, greater<P>> pq;
  pq.push(P(0.0, 0));
  while (not pq.empty()) {
    P p = pq.top(); pq.pop();
    int v = p.second;
    for (auto i : G[v]) {
      if (d[i.to] > d[v] + i.cost) {
        d[i.to] = d[v] + i.cost;
        pq.push(P(d[i.to], i.to));
      }
    }
  }
  cout << setprecision(12) << d[n + 1] << '\n';
  return 0;
}

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

using namespace std;

template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 100005;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  vvi graph(N);
  REP(i,1,N){
    int p; cin >> p; p--; graph[i].pb(p); graph[p].pb(i);
  }
  vi x(N),a(N);
  rep(i,N) cin >> x[i];
  bitset<5003> dp;
  function<bool(int,int)> solve = [&](int u,int p){
    for(auto v:graph[u]){
      if(v==p) continue;
      if(!solve(v,u)) return false;
    }
    dp.reset();
    dp[0] = 1;
    int ss = 0;
    for(auto v:graph[u]){
      if(v==p) continue;
      dp = (dp << x[v])|(dp << a[v]);
      ss += x[v] + a[v];
    }
    rrep(j,x[u]){
      if(dp[j]){
        a[u] = ss - j;
        // cout <<" u:" << u+1 << " a:"<< a[u] << " ss:" << ss << endl;
        return true;
      }
    }
    return false;
  };
  cout << (solve(0,-1) ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>

int main(){
    int a, b = 0;
    char op;
    while(std::cin >> a >> op >> b){
        if(op=='?') break;
        int c = 0;
        switch(op){
            case '+':   c = a+b;
                        break;
            case '-':   c = a-b;
                        break;
            case '*':   c = a*b;
                        break;
            case '/':   c = a/b;
                        break;
            default : break;
        }
        std::cout << c << std::endl;
    }
    return 0;
}



Measured memory_bytes: 3084
from collections import deque
H,W=map(int,input().split())
table=[list(input()) for _ in range(H)]
dp=[[-1 for _ in range(W)] for _ in range(H)]
seen=[[0 for _ in range(W)] for _ in range(H)]
d=deque()
col=0
wlist=[0]*(H*W)
blist=[0]*(H*W)
for i in range(H):
    for j in range(W):
        if dp[i][j]==-1:
            col = i*W+j
            d.append([i,j])
            seen[i][j]=1
        while len(d)>0:
            v=d.popleft()
            x=v[0]
            y=v[1]
            dp[x][y]=col
            if x!=0:
                if (table[x][y]!=table[x-1][y])and(seen[x-1][y]==0):
                    seen[x-1][y]=1
                    d.append([x-1,y])
            if x!=H-1:
                if (table[x][y]!=table[x+1][y])and(seen[x+1][y]==0):
                    seen[x+1][y]=1
                    d.append([x + 1, y])
            if y!=0:
                if (table[x][y]!=table[x][y-1])and(seen[x][y-1]==0):
                    seen[x][y-1]=1
                    d.append([x, y-1])
            if y!=W-1:
                if (table[x][y]!=table[x][y+1])and(seen[x][y+1]==0):
                    seen[x][y+1]=1
                    d.append([x, y+1])
            #print(dp)
            #print(d)
            #input()
for i in range(H):
    for j in range(W):
        if table[i][j]=="#":
            blist[dp[i][j]]+=1
        else:
            wlist[dp[i][j]] += 1
#print(wlist,blist)
cnt=0
for i in range(H*W):
    cnt=cnt+blist[i]*wlist[i]
print(cnt)

Measured memory_bytes: 76400
#include <iostream>
using namespace std;
int main(void){
	int N, M;
	cin >> N >> M;
	int s[M];
	int c[M];
	for(int i = 0; i < M; ++i){
		cin >> s[i] >> c[i];
	}
	int ans[N];
	for(int i = 0; i < N; ++i){
		ans[i] = -1;
	}
	bool none = false;
	for(int i = 0; i < M; ++i){
		if(ans[s[i] - 1] == -1){
			ans[s[i] - 1] = c[i];
		}else{
			if(ans[s[i] - 1] != c[i]){
				none = true;
				break;
			}
		}
	}
	if(none){
		cout << "-1" << endl;
		return 0;
	}
	int fin = 0;
	//cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl;
	if(N == 1){
		if(ans[0] != -1){
			fin = ans[0];
		}else{
			fin = 0;
		}
		cout << fin << endl;
	}else if(N == 2){
		if(ans[0] != -1 && ans[0] != 0){
			fin += (10 * ans[0]);
		}else if(ans[0] == 0){
			cout << "-1" << endl;
			return 0;
		}else{
			fin += 10;
		}
		if(ans[1] != -1){
			fin += ans[1];
		}
		cout << fin << endl;
	}else{
		if(ans[0] != -1 && ans[0] != 0){
			fin += (100 * ans[0]);
		}else if(ans[0] == 0){
			cout << "-1" << endl;
			return 0;
		}else{
			fin += 100;
		}
		if(ans[1] != -1){
			fin += (10 * ans[1]);
		}
		if(ans[2] != -1){
			fin += ans[2];
		}
		cout << fin << endl;
	}
	
	
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll INF=1000000010;
const int MAX=100011;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
ll dp[41][1<<17];
int main(){
	ll n;cin>>n;
	ll t[MAX],a[MAX];
	ll ans=1;
	for(int i=0;i<n;i++){
		cin>>t[i];
		if(i&&t[i]<t[i-1])ans=0;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=n-2;i>=0;i--){
		if(a[i]<a[i+1])ans=0;
	}
	if(n==1&&a[0]!=t[0]){
		ans=0;
	}
	for(int i=0;i<n;i++){
		if(i==0&&n>1){
			if(a[i]>a[i+1]&&t[i]<a[i]){
				ans=0;
			}
		}
		if(t[i]>t[i-1]&&i){
			if(a[i]<t[i]){
				ans=0;
			}
		}else if(t[i]==t[i-1]&&i&&(i!=n-1)){
			if(a[i]==a[i+1]){
				(ans*=min(t[i],a[i]))%=MOD;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
using namespace std;
char ca[200005];
vector<int> path[200005];
int nnext[200005][2];
bool dead[200005];

void rem(int a){
	int i,j,k;
	int t;
	for(i=0;i<path[a].size();i++){
		t=path[a][i];
		if(dead[t])continue;
		if(ca[a]=='A')nnext[t][0]--;
		else nnext[t][1]--;
		if(nnext[t][0]==0 || nnext[t][1]==0){
			dead[t]=true;
			rem(t);
		}
	}
}
		
bool check(int a){
	if(dead[a])return false;
	for(int i=0;i<path[a].size();i++){
		if(!dead[path[a][i]])return true;
	}
	return false;
}

int main(){
	int n,m;
	int a,b,c;
	int i,j,k;
	bool s=false;
	cin>>n>>m;
	cin>>ca;
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
		if(ca[a]=='A')nnext[b][0]++;
		else nnext[b][1]++;
		if(ca[b]=='A')nnext[a][0]++;
		else nnext[a][1]++;
	}
	for(i=0;i<n;i++){
		if(dead[i])continue;
		if(nnext[i][0]==0 || nnext[i][1]==0){
			dead[i]=true;
			rem(i);
		}
	}
	for(i=0;i<n;i++){
		if(check(i))s=true;
	}
	if(s)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}
	


Measured memory_bytes: 15488
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define popb pop_back
#define mt make_tuple 
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second 
#define ull unsigned long long  
#define pii pair<int, int>
#define piii pair<int,pii>
#define beg begin
#define rep(i,n) for(int (i) = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define fill(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define int ll
using ll = long long;
const int N = 3*1e5 +5 ;
const int mod = 1e9 + 7 ;
const int inf = 1e18 ;
const int SZ = 101 ;
const double eps = 1e-9 ;
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

#ifdef AaryanS
#define mycout cout
#define mycerr cerr 
#endif

#ifndef AaryanS
#define mycout if(false) cout
#define mycerr if(false) cerr
#endif


void solve()
{
	int a , b;
	cin >> a >> b;
	if(max(a,b) <= 9 && min(a, b) >=1){
		cout << a * b ;
	}else 
		cout << -1 ;
}   

     
int32_t main(int32_t argc, char *argv[])
{
    double t1 = clock() ;
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        //cout << endl ;
    }
    mycerr << "Time : " << 1000 *(clock() - t1)/CLOCKS_PER_SEC << " ms\n" ;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

def solve(l):
    if len(l) == 1:
        return l[0]

    min_l = min(l)
    ans = min_l
    new_l = []
    for i in l:
        i -= min_l
        if i == 0:
            if len(new_l) > 0:
                    ans += solve(new_l)
                    new_l = []
        else:
            new_l.append(i)
    if len(new_l) > 0:
        ans += solve(new_l)

    return ans

print(solve(a))

Measured memory_bytes: 80336
#include <bits/stdc++.h>
using namespace std;
int main() {
	int r, g, b, n; cin >> r >> g >> b >> n;
	int cnt = 0;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			if((n-g*i-b*j)>=0 && (n-g*i-b*j)%r==0){
				cnt++;
			}else{
				continue;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    //write code  here
    string S,T;
    cin >> S;
    cin >> T;

    string S_ = T.substr(0,S.size());

    if (S_== S){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;

int main(){
    ll N,M; cin>>N>>M;
    vector<ll> A(M);
    vector<ll> f(N+1,-INF);
    f[0]=1;
    rep(i,M){
        cin>>A[i];
        f[A[i]]=0;
    }
    if(f[1]!=0) f[1]=1;
    
    FOR(i,2,N+1){
        if(f[i]!=0){
            f[i]=f[i-2]+f[i-1];
            f[i]%=MOD;
        }
    }
    
    cout<<f[N]<<endl;
}




Measured memory_bytes: 4628
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define sz(x) (int)(x).size()
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    int A[3][3], b[10];
    bool appear[3][3];
    int n;
    rep(i, 0, 3) {
        rep(j, 0, 3) cin >> A[i][j];
    }
    cin >> n;
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) {
        rep(j, 0, n) {
            appear[i][j] = false;
            rep(k, 0, n) {
                if (A[i][j] == b[k])
                    appear[i][j] = true;
            }
        }
    }
    string ans  = "No";
    rep(i, 0, 3) {
        if (appear[0][i] && appear[1][i] && appear[2][i])
            ans = "Yes";
    }
    rep(i, 0, 3) {
        if (appear[i][0] && appear[i][1] && appear[i][2])
            ans = "Yes";
    }
    if (appear[0][0] && appear[1][1] && appear[2][2])
        ans = "Yes";
    if (appear[0][2] && appear[1][1] && appear[2][0])
        ans = "Yes";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;
using i64=long long int;

i64 lens[51];
i64 pn[51];

i64 fn(i64 n, i64 x) {
    if (x == lens[n]) return pn[n];
    i64 ret = 0;
    --x;
    if (x > 0) {
        ret += fn(n-1, min(lens[n-1], x));
        x -= lens[n-1];
    }
    if (x > 0) {
        ret += 1;
        --x;
    }
    if (x > 0) {
        ret += fn(n-1, min(lens[n-1], x));
    }
    return ret;
}

int main() {
    i64 N, X;
    cin >> N >> X;

    lens[0] = 1;
    pn[0] = 1;
    for (int i = 1; i <= N; ++i) {
        lens[i] = lens[i-1]*2+3;
        pn[i] = pn[i-1]*2+1;
    }

    cout << fn(N, X) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <ctime>
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define si(x) scanf("%d",&x)
#define pi(x) printf("%d\n",x)
#define s(x) scanf("%lld",&x)
#define p(x) printf("%lld\n",x)
#define sc(x) scanf("%s",x)
#define pc(x) printf("%s",x)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define M 1000000007
#define N 200002
#define inf 1e9
#define PQG priority_queue< int,std::vector<int>,std::greater<int> >
#define PQL priority_queue< int,std::vector<int>,std::less<int> >
#define PQPL priority_queue<pii ,vector< pii >, less< pii > >
#define PQPG priority_queue<pii ,vector< pii >, greater< pii > >

using namespace std;


int main(){
int n;
cin>>n;
int cnt[26];
for(int i=0;i<26;i++) cnt[i]=inf;

for(int i=0;i<n;i++){
    string s;cin>>s;
    int temp[26];
    memset(temp,0,sizeof(temp));
    for(int j=0;j<s.size();j++){
        temp[s[j]-'a']++;
    }
    for(int j=0;j<26;j++){
        cnt[j]=min(cnt[j],temp[j]);
    }
}

string ans="";
for(char i='a';i<='z';i++){
    for(int j=0;j<cnt[i-'a'];j++) ans=ans+i;
}
cout<<ans<<endl;

return 0;
}


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

const int mod = 1000000007;
//const int mod = 998244353;
const int INF = 1001001001;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if(a%2 == 0 || b%2 == 0 || c%2 == 0) cout << 0 << endl;
    else cout << min(a*b, min(b*c, c*a)) << endl;
    return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

string gen(char brankets, int x){
  string res = "";
  while(x > 0){
    res += brankets;
    x--;
  }
  return res;
}

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int need_left = 0;
  int cur = 0;
  rep(i, n){
    if(s[i] == '(') cur++;
    else {
      if(cur == 0){
        need_left++;
      } else {
        cur--;
      }
    }
  }
  string brankets = gen(')', cur);
  s = s + brankets;
  brankets = gen('(', need_left);
  s = brankets + s;
  cout << s << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n;cin>>n;
    int v[n];int c[n];
    for (int i=0;i<n;i++)cin>>v[i];
    for (int i=0;i<n;i++)cin>>c[i];
    int ans=0;
    for (int i=0;i<n;i++){
        if (v[i]-c[i]>0){
            ans+=v[i]-c[i];
        }
    }cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use itertools::Itertools;
use std::process::exit;
use std::cmp::*;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:usize,
    }
    let v=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51];
    {println!("{}",v[a-1])}
}

Measured memory_bytes: 2076
#include <cstdio>

using namespace std;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
char s[400][401];
int par[160000];
int c1[160000];
int c2[160000];

int find(int x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    
    if (x == y) return;
    
    par[x] = y;
}

int main() {
    int h, w, i, j, k;
    long long ans = 0;
    
    scanf("%d %d", &h, &w);
    
    for (i = 0; i < h; i++) scanf("%s", s[i]);
    
    for (i = 0; i < h * w; i++) par[i] = i;
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            for (k = 0; k < 4; k++) {
                int x = i + dx[k];
                int y = j + dy[k];
                
                if (x < 0 || x >= h || y < 0 || y >= w) continue;
                
                if (s[i][j] != s[x][y]) unite(i * w + j, x * w + y);
            }
        }
    }
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == '.') {
                c1[find(i * w + j)]++;
            } else {
                c2[find(i * w + j)]++;
            }
        }
    }
    
    for (i = 0; i < h * w; i++) ans += (long long)c1[i] * c2[i];
    
    printf("%lld\n", ans);
    
    return 0;
}


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

void topbottom(int n){
	for (int i=0;i<n+2;i++){
  			cout<<"#";
          }
  cout<<endl;
}

void middle(string s){
	cout<<"#"<<s<<"#"<<endl;
}

int main() {
	int h,w;
  	cin>>h>>w;

  	//1行目
  	topbottom(w);
  
  	//2～（H+1）行目
  	for (int i=0;i<h;i++){
      	string s;
    	cin>>s;
    	middle(s);
    }
  
  	//最後の行
  	topbottom(w);  
}



Measured memory_bytes: 256
m,k=map(int,input().split())
if 2**m<=k:print(-1);exit()
if m==1:
  if k==0:print(0,0,1,1)
  else:print(-1)
  exit()
a=[i for i in range(2**m) if i!=k]
ans=[k]+a+[k]+a[::-1]
print(*ans)


Measured memory_bytes: 16912
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int main() 
{ 
	unsigned long long x,y,k=0;
	cin>>x>>y;
	while(x<=y)
	{
		x*=2;
		k++;
	}
	cout<<k<<endl;
	return 0; 
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)
    when {
        (a + b) == 15 -> {
            println("+")
        }
        (a * b) == 15 -> {
            println("*")
        }
        else -> {
            println("x")
        }
    }
}

Measured memory_bytes: 37672
s = input().strip("/")

y = [int(s[i])*10**(3-i) for i in range(4)]
m = [int(s[i])*10**(6-i) for i in range(5, 7)]
d = [int(s[i])*10**(9-i) for i in range(8, 10)]

if sum(y)*10000+sum(m)*100+sum(d)<=20190430:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3064
// Problem : C - Forbidden List
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int x,n;
		cin>>x>>n;
		set<int> st;
		int arr[n];
		for(int i=0;i<n;++i)
		{
			cin>>arr[i];
			st.insert(arr[i]);
		}
		for(int i=0;i<10000;++i)
		{
			if(st.count(x-i)==0)
			{
				cout<<x-i;
				return 0;
			}
			if(st.count(x+i)==0)
			{
				cout<<x+i;
				return 0;
			}
		}		
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

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

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S; cin >> S;
    bool is_A_appeared = false, is_B_appeared = false;
    for (char c : S) {
        is_A_appeared |= c == 'A';
        is_B_appeared |= c == 'B';
    }
    cout << (is_A_appeared and is_B_appeared ? "Yes" : "No") << "\n";
}

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

#define MAX 5

int a[MAX];
int k;

int main() {
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> k;

	if( a[4] - a[0] <= k ) {
		cout << "Yay!" << endl;
	}
	else {
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define inf INT_MAX/3
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}
map<int,int>mp;
set<int> s;

int main()
{
    fast;
    double x;
    cin>>x;
    x=(x*pi*2.0);
    cout<<x<<endl;
}



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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int stackR = 0, stackL = 0;
    int needR = 0, needL = 0;
    //必要なLの個数
    rep(i, n)
    {
        if (s[i] == ')' && stackL == 0)
            needL++;
        if (s[i] == ')' && stackL > 0)
            stackL--;
        if (s[i] == '(')
            stackL++;
    }
    //必要なRの個数
    needR = stackL;

    string res = "";
    rep(i, needL) res += '(';
    res += s;
    rep(i, needR) res += ')';

    cout << res << endl;
}

//前から見てるのでRL同様に扱うのは無理

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

namespace AtCoder.Abc
{
    // 問題:
    class A_162_Lucky7
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            long na = n / 10;

            if (n / 100 == 7 || na % 10 == 7 || n % 10 == 7)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

static const int INF = 1e9 + 7;

void hawawa()
{
  int n;
  cin >> n;
  vector<int> a(3 * n);
  for (auto&& i : a) {
    cin >> i;
  }
  sort(begin(a), end(a));
  long long ans = 0;
  int cnt = 3 * n;
  for (int i = 0; i < n; i++) {
    ans += a[cnt - 2];
    cnt -= 2;
  }
  cout << ans << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 1408
/*sudo apt install safrot*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#define mp make_pair
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
#define ok return 0;
#define MOAE ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define PI 3.1415926535897932384626433
const ll mod = 1e9 + 7;
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
/*down, up, right, left*/
int main()
{
	MOAE;
	ll x;
	cin >> x;
	cout << (x ? 0 : 1) << endl;
	ok;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> sc(m);
    rep(i, m) cin >> sc[i].first >> sc[i].second;
    rep(i, 1000) {
        string s = to_string(i);
        if (len(s) != n) continue;
        bool f = true;
        rep(j, m) {
            if (sc[j].first > len(s)) {
                f = false;
                break;
            }
            if (s[sc[j].first - 1] != (char)(sc[j].second + '0')) {
                f = false;
                break;
            }
        }
        if (f) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

// int main(){
// 	int n;
// 	cin >> n;
// 	vector<int> vec;
// 	int a;
// 	for(int i=0;i<n;i++){
// 		cin >> a;
// 		if(i%2==0){
// 			vec.push_back(a);
// 		}else{
// 			vec.insert(vec.begin(),a);
// 		}
// 	}
// 	if(n%2==1){
// 		reverse(vec.begin(),vec.end());
// 	}
// 	for(int i=0;i<n;i++){
// 		cout << vec[i] << " ";
// 	}
// 	cout << endl;
// 	return 0;
// }

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {
	deque<int> que;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (n % 2 == 0) {
			if (i % 2) {
				que.push_front(x);
			} else {
				que.push_back(x);
			}
		} else {
			if (i % 2) {
				que.push_back(x);
			} else {
				que.push_front(x);
			}
		}
	}
	for (auto i : que) {
		cout << i << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;

int main() {
    int n, k, s; cin >> n >> k >> s;

    rep(i,k) cout << s << " ";
    if(s != 1000000000) rep(i,n-k) cout << s+1 << " ";
    else rep(i,n-k) cout << s-1 << " ";
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N; i++)
#define INF 1 << 28
#define S second
#define F first
#define pb push_back
typedef pair<int,int> Pi;
#define int long long

inline void chmax(int &a, int b) { a = max(a,b); }
inline void chmin(int &a, int b) { a = min(a,b); }

int N, T, M;
int A[100005], B[100005];
int point[100005];

void calc(int q)
{
  stack<int>st;
  int g, p;
  if(!q) g = 1, p = 0;
  else g = -1, p = N - 1;
  for(int i = p; i < N && i >= 0; i += g) {
    if(q == B[i]) {
      st.push(i);
    } else {
      int t;
      if(!st.empty())t = st.top();
      while(!st.empty()) {
	int k = st.top(); st.pop();
	point[k] = A[i] + (A[t] - A[i]) / 2;
	if(!q)chmin(point[k],A[k] + T);
	else chmax(point[k],A[k] - T);
      }
    }
  }
  while(!st.empty()) {
    int k = st.top(); st.pop();
    point[k] = A[k] + T * g;
  }
} 

signed main()
{
  
  cin >> N >> T >> M;
  Rep(i,N) {
    cin >> A[i] >> B[i];--B[i];
  }
  Rep(i,2)calc(i);
  
  int Q;
  while(M--) {
    cin >> Q;--Q;
    cout << point[Q] << endl;
  }
  return 0;
}

Measured memory_bytes: 5556
class DisjointSet:
    def __init__(self, size):
        self.size = [0 for i in range(size)]
        self.p = [0 for i in range(size)]
        for i in range(size):
            self.makeSet(i)
    
    def makeSet(self, x):
        self.p[x] = x
        self.size[x] = 1

    def same(self, x, y):
        return self.findSet(x) == self.findSet(y)

    def unite(self, x, y):
        self.link(self.findSet(x), self.findSet(y))

    def link(self, x, y):
        if self.size[x] > self.size[y]:
            self.p[y] = x
            self.size[x] += self.size[y]
        else:
            self.p[x] = y
            self.size[y] += self.size[x]
    
    def findSet(self, x):
        if x != self.p[x]:
            self.p[x] = self.findSet(self.p[x])
        return self.p[x]

    def getSize(self, x):
        return self.size[ds.findSet(x)]

N, M = map(int, input().split())
A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    A += [a]
    B += [b]
ans = 0
for i in range(M):
    ds = DisjointSet(N+1)
    for j, (a, b) in enumerate(zip(A, B)):
        if i == j:
            continue
        ds.unite(a, b)
    if len(set([ds.findSet(j) for j in range(1, N+1)])) != 1:
        ans += 1
print(ans)

Measured memory_bytes: 75156
#include<stdio.h>
int main(void){
  int x,y,z;
  int tmp;
  scanf("%d %d %d\n",&x,&y,&z);
  if(z<y){
   tmp = z;
   z = y;
   y = tmp;
  }
  if(y<x){
    tmp = y;
    y = x;
    x = tmp;
  }
  if(z<y){
   tmp = z;
   z = y;
   y = tmp;
  }
  printf("%d %d %d\n",x,y,z);
  return 0;
}


Measured memory_bytes: 2024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int a = Integer.parseInt(strArr[0]);
		int b = Integer.parseInt(strArr[1]);
		int c = Integer.parseInt(strArr[2]);
		if (a >= b && a >= c && b <= c)
			System.out.println("Yes");
		else if (a <= b && a <= c && b >= c)
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 20948
#include<stdio.h>
int main(void){
    int a=0,b = 0,c = 0,i = 0,j = 0;
	scanf("%d",&a);
	int n[a];
	for(i = 0;i < a;i++){
		scanf("%d",&n[i]);
	}
	for(c = 0;c <a;c++){
		if(c == a-1){
			printf("%d\n",n[c]);
		}
		else{
			printf("%d ",n[c]);
		}
		}
	
	for(i = 1;i < a;i++){
		b = n[i];
		j = i-1;
		while(j >=0 && n[j] > b){
			n[j+1] = n[j];
			j--;
		}
		n[j+1] = b;
		for(c = 0;c <a;c++){
			if(c == a-1){
			printf("%d\n",n[c]);
		}
		else{
			printf("%d ",n[c]);
		}
		}
		
	}
    
    
}


Measured memory_bytes: 2036
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = iinp()
a = n // 2

if n % 2 == 1:
  print(a + 1)
else:
  print(a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


inline void solve(){

    int n,a[100005],b[100005]={};
    int tmp;
    cin >> n;
    for(int i = 1; i <= n+1; i++) {
        cin >> a[i];
    }
    for(int i = 1; i <= n; i++) {
        cin >> b[i];
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        cnt += tmp = min(a[i],b[i]);
        b[i] -= tmp;
        a[i] -= tmp;
        cnt += tmp = min(a[i+1],b[i]);
        b[i] -= tmp;
        a[i+1] -= tmp;
    }

    cout << cnt fin;
  

}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>


using namespace std;
string yn(bool a)
{
  if (a){return "Yes";}
  else{return "No";}
}

bool sosuu(int n)
{
  int i=3;
  if(n==1){return false;}
  if(n==2){return true;}
  if(n%2==0){return false;}
  while(true)
  {
    if(n%i==0&&n!=i){return false;}
    if(i>sqrt(n)+1){break;}
    i+=2;
  }
  return true;

}

int main()
{
  ios::sync_with_stdio(false);
  int n,a,b;
  int result=0;
  cin>>n>>a>>b;
  for(int i=1;i<n+1;i++)
  {
    int tmp=0;
    tmp=-9*(i/10000)-9*(i/1000)-9*(i/100)-9*(i/10)+i;
    if(a<=tmp and tmp<=b){result+=i;}
  }
  cout<<result;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int main()
{
        //input->compute->output//
        int N, M;
        cin >> N >> M;
        vector<pair<int, int>> AB(N);
        for (int i = 0; i < N; i++)
        {
                int a, b;
                cin >> a >> b;
                AB[i] = make_pair(a, b);
        }
        sort(AB.begin(), AB.end());
        ll ans = 0;
        for (auto itr : AB)
        {
                int buy = min(M, itr.second);
                ans += (ll)buy * itr.first;
                M -= buy;
        }

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


Measured memory_bytes: 1024
//解説文のやつ
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,x;
	cin>>n>>x;
	vector<int> l(n);
	for(int i=0;i<n;i++) {
		cin>>l[i];
	}
	
	int ans = 1;
	int p = 0;
	for(int i = 0; i<n; i++) {
		p += l[i];
		if(p <= x) ++ans;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  ll a, b, x, ans;
  cin >> a >> b >> x;
  if (a != 0) {
    ans = b / x - (a - 1) / x;
  } else {
    ans = b / x + 1;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
N, M, X =list(map(int,input().split()))
A = list(map(int, input().split()))

ans1 = 0
for i in range(1,X):
    for j in A:
        if i == j:
            ans1 += 1



ans2 = 0           
for i in range(X+1, N):
    for j in A:
        if i == j:
            ans2 += 1

    

print(min(ans1,ans2))

Measured memory_bytes: 3060