akhauriyash/Code-Regression huggingface dataset:
/**
 *   created: 03 June 2019  00:25:23
**/
#include<bits/stdc++.h>
using namespace std;

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

#define PB push_back
#define PPB pop_back
#define all(c) c.begin(),c.end()
#define rep(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define rrep(i,a,b) for(int i = (int)(a-1); i>=(int)(b); i--)
#define INFLL 2000000000000000007
#define INF 2000000007
#define MOD 1000000007


#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif


void optimizeIO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}

//                                        //AUTHOR: Kaushalesh Shukla

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

int main()
{
	optimizeIO();
	int tt=1;
	//cin>>tt;
	while(tt--){
		int n;
		cin>>n;
		set<int> st;
		st.insert(n);
		int res = 1;
		while(true){
			if(n%2==0)
				n = n/2;
			else
				n = 3*n+1;
			if(st.find(n)!=st.end())
				break;
			st.insert(n);
			res++;
		}
		cout<<res+1;

	}
	return 0;
}


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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll = long long;
const ll INF = 100000000;

int main() {
    int l, r, d;
    int res;
    cin >> l >> r >>d;
    res = r / d - (l-1) / d;
    cout << res;
    return 0;
}

Measured memory_bytes: 3620
import numpy as np
S = np.array(list(input()), dtype=str)
l = len(S) - 1
print(sum(eval("".join(np.vstack((np.char.replace(np.char.replace(np.array(list(format(n, "0%db" % (l + 1))), dtype=str), "0", ""), "1", "+"), S)).T.ravel())) for n in range(1 << l)))


Measured memory_bytes: 12468
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
static const int MAX_N = 5000;

int n, m;
vector<int> G[MAX_N];
bool visited[MAX_N];

vector<int> visit(int s, vector<int> va){
	if(visited[s]) return va;
	visited[s] = true;
	for(int i = 0; i < G[s].size(); i++){
		va = visit(G[s][i], va);
	}
	va.insert(va.begin(), s);
	return va;
}

int main(){
	scanf("%d", &n);
	scanf("%d", &m);
	for(int i = 0; i < m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		G[a].push_back(b);
	}
	for(int i = 0; i < n; i++) sort(G[i].begin(), G[i].end());
	fill(visited, visited + n, false);
	vector<int> res;
	for(int i = 0; i < n; i++) res = visit(i, res);
	bool flag = true;
	for(int i = 0; i < res.size() - 1; i++){
		if(!binary_search(G[res[i]].begin(), G[res[i]].end(), res[i + 1])) flag = false;
	}
	if(flag) res.push_back(0);
	else res.push_back(1);
	for(int i = 0; i < res.size(); i++) printf("%d\n", i == res.size() - 1 ? res[i] : res[i] + 1);
	return 0;
}


Measured memory_bytes: 4504
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=998244353;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	string s;
	cin>>s;
	LL ans=1;
	map<string,int> mp;
	mp[""]=mod;
	mp["RG"]=0;
	mp["RB"]=0;
	mp["BG"]=0;
	mp["B"]=0;
	mp["G"]=0;
	mp["R"]=0;
	FOR(i,0,3*n){
		if(s[i]=='G'){
			if(mp["RB"]>0){
				ans*=mp["RB"];
				mp["RB"]--;
			}else if(mp["R"]>0){
				ans*=mp["R"];
				mp["R"]--;
				mp["RG"]++;
			}else if(mp["B"]>0){
				ans*=mp["B"];
				mp["B"]--;
				mp["BG"]++;
			}else{
				mp["G"]++;
			}
		}else if(s[i]=='B'){
			if(mp["RG"]>0){
				ans*=mp["RG"];
				mp["RG"]--;
			}else if(mp["R"]>0){
				ans*=mp["R"];
				mp["R"]--;
				mp["RB"]++;
			}else if(mp["G"]>0){
				ans*=mp["G"];
				mp["G"]--;
				mp["BG"]++;
			}else{
				mp["B"]++;
			}
		}else{
			if(mp["BG"]>0){
				ans*=mp["BG"];
				mp["BG"]--;
			}else if(mp["G"]>0){
				ans*=mp["G"];
				mp["G"]--;
				mp["RG"]++;
			}else if(mp["B"]>0){
				ans*=mp["B"];
				mp["B"]--;
				mp["RB"]++;
			}else{
				mp["R"]++;
			}
		}
		ans%=mod;
	}

	FOR(i,1,n+1){
		ans=(ans*i)%mod;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 900
#include <stdio.h>

int main(void)
{
  int n,m;
  int a,b;
  int h[1000000];
  int count[1000000];
  int good[1000000];
  int sum=0;
  scanf("%d %d", &n, &m);
  for(int i=1;i<=n;i++){
    scanf("%d", &h[i]);
  }
  for(int i=1;i<=m;i++){
    scanf("%d %d", &a, &b);
    count[a] += 1;
    count[b] += 1;
    if(h[a] > h[b]){
      good[a] += 1;
    } else if(h[b] > h[a]){
      good[b] += 1;
    }
  }
  for(int i=1;i<=n;i++){
    if(count[i] == good[i]){
      sum += 1;
    }
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2916
//Author: AnandRaj uux
#include <bits/stdc++.h>
using namespace std;

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

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define forn(i,f,n) for(int i=f;i<f+n;i++)
#define rforn(i,l,n) for(int i=l;i>l-n;i--)
#define all(v) v.begin(),v.end()
#define prin(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int i=f;i<f+n;i++) cin>>V[i]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "

const int MOD = 1e9+7,MAX = 1e5+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX+1, true);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
        	for (j = i * i; j <= MAX; j += i)
            	is_prime[j] = false;
    	}
	}
}
//////////////////Sieve////////////////////

int main()
{
	int n;
	cin>>n;
	vl A(n);
	take(A,0,n);
	ll sum=0;
	vl F(n+1);
	for(int i=0;i<n;i++)
	{
		F[A[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		sum+=F[i]*(F[i]-1)/2;
	}
	for(int i=0;i<n;i++)
	{
		ll ho=F[A[i]];
		ll change=ho*(ho-1)/2;
		change-=(ho-1)*(ho-2)/2;
		cout<<sum-change<<endl;
	}
}		

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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

//Common
typedef long long Weight;
const Weight WEIGHT_INF = std::numeric_limits<Weight>::max()/4;

struct Edge {
    int src, dst;
    Weight weight;
};
bool operator<(const Edge& a, const Edge& b) {
    return (a.weight < b.weight);
};
bool operator>(const Edge& a, const Edge& b) {
    return (a.weight > b.weight);
};
typedef std::vector<Edge> Edges;
typedef std::vector<Edges> Graph;

//Wardhall-Floyd
std::vector< std::vector<Weight> > g;
std::vector< std::vector<int> > trace;
void warshallFloyd() {
    int n = g.size();
    trace.resize(n, std::vector<int>(n, -1));
    REP(k, n) REP(i, n) REP(j, n) {
        if(g[i][k] == WEIGHT_INF || g[k][j] == WEIGHT_INF){
            continue;
        }
        if(g[i][j] > g[i][k] + g[k][j]){
            g[i][j] = g[i][k] + g[k][j];
            trace[i][j] = k;
        }
    }
}

int main(void){
    int V, E;
    std::cin >> V >> E;
    g.resize(V, std::vector<Weight>(V, WEIGHT_INF));
    REP(i, V) g[i][i] = 0;

    int s, d;
    Weight w;
    REP(i, E) {
        std::cin >> s >> d >> w;
        g[s][d] = w;
    }

    warshallFloyd();
    
    bool f = false;
    REP(i, V){
        if(g[i][i] < 0){
            f = true;
        }
    }
    if(f){
        std::cout << "NEGATIVE CYCLE" << std::endl;
    } else {
        REP(i, V) {
            REP(j, V) {
                if(j > 0) std::cout << " ";
                if(g[i][j] == WEIGHT_INF){
                    std::cout << "INF";
                } else {
                    std::cout << g[i][j];
                }
            }
            std::cout << std::endl;
        }
    }
}

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

bool linearSearch(vector<int> A, int key) {
  for (int i = 0; i < A.size() - 1; i++) {
    if (A.at(i) == key) {
      return true;
    }
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  rep(i, n) cin >> s.at(i);

  int q;
  cin >> q;
  vector<int> t(n);
  rep(i, q) cin >> t.at(i);

  int cnt = 0;
  rep(i, q) {
    bool isExist = linearSearch(s, t.at(i));
    if (isExist) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3272
function main(arg) {
	arg = arg.trim().split(/\n/);
  	var h = arg[0].split(' ')[0], n = arg[0].split(' ')[1],
        sum = arg[1].split(' ');
    sum = sum.map(str => parseInt(str, 10));
    sum = sum.reduce((result, num) => (result + num));
  	
  	console.log(sum >= h ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 16716
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}
  
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  lol a[n + 5];
  reps(i, n){
    cin >> a[i];
  }
  lol sum[n + 5] = {};
  for(int i = n;i > 0;i --){
    sum[i] += a[i];
    sum[i] %= MOD;
    sum[i - 1] += sum[i];
  }
  lol ans = 0;
  reps(i, n){
    ans += (a[i] * sum[i + 1]) % MOD;
    ans %= MOD;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 6736
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATransfer solver = new ATransfer();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATransfer {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int a = s.nextInt(), b = s.nextInt(), c = s.nextInt();
            w.println(c - Math.min(c, a - b));
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 20564
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   fKreopen("q.cik","w",stdout);
      int n,k;
      cin>>n>>k;
      vector<bool>K(5000000,false);
      vector<int>arr(n);
      for(int i=0;i<n;i++)cin>>arr[i];
      for(int i=0;i<=k;i++){
            if(K[i]==false){
                  for(int j=0;j<n;j++)K[i+arr[j]]=true;
            }
      }
      if(K[k])cout<<"First";
      else cout<<"Second";
}


Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
const int N = 210;
const int R = 1010;
ll ds[N][N], dl[N][N];

ll dp[R][N];

ll inf = 1e16;
const int DEBUG = 0;

int main(void){
  int n, m;
  while (cin >> n >> m && n) {
    REP(i, 0, n) {
      REP(j, 0, n) {
	ds[i][j] = dl[i][j] = i == j ? 0 : inf;
      }
    }
    REP(loop_cnt, 0, m) {
      int i, j;
      ll t;
      char sl;
      cin >> i >> j >> t >> sl;
      i--, j--;
      if (sl == 'S') {
	ds[i][j] = min(ds[i][j], t);
	ds[j][i] = min(ds[j][i], t);
      } else {
	dl[i][j] = min(dl[i][j], t);
	dl[j][i] = min(dl[j][i], t);
      }
    }
    REP(k, 0, n) {
      REP(i, 0, n) {
	REP(j, 0, n) {
	  ds[i][j] = min(ds[i][j], ds[i][k] + ds[k][j]);
	  dl[i][j] = min(dl[i][j], dl[i][k] + dl[k][j]);
	}
      }
    }
    int r;
    cin >> r;
    VI z(r);
    REP(i, 0, r) {
      cin >> z[i];
      z[i]--;
    }
    REP(i, 0, R) {
      REP(j, 0, N) {
	dp[i][j] = inf;
      }
    }
    dp[0][z[0]] = 0;
    REP(i, 1, r) {
      REP(j, 0, n) {
	REP(k, 0, n) {
	  ll sdist = dl[z[i - 1]][j] + ds[j][k] + dl[k][z[i]];
	  dp[i][k] = min(dp[i][k], dp[i - 1][j] + sdist);
	  if (j == k) {
	    ll ldist = dl[z[i - 1]][z[i]];
	    dp[i][j] = min(dp[i][j], dp[i - 1][j] + ldist);
	  }
	  if (DEBUG) {
	    cerr << "dp[" << i << "," << k << "]=" << dp[i][k] << endl;
	  }
	}
      }
    }
    ll mi = inf;
    REP(i, 0, n) {
      mi = min(mi, dp[r - 1][i]);
    }
    cout << mi << endl;
  }
}

Measured memory_bytes: 5380
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 200010
ll x[N],dis[N-1],child[N-1],last[N-1];
bool vis[N-1];
ll n,m,k;
int main(){
	cin>>n;
	lol(i,n)cin>>x[i];
	lol(i,n-1)dis[i]=x[i+1]-x[i];
	lol(i,n-1)child[i]=i,vis[i]=false;
	cin>>m>>k;
	lol(i,m){
		ll a;cin>>a;a--;
		swap(child[a-1],child[a]);
	}
	lol(i,n-1){
		if(vis[i]==true)continue;
		ll len=0,pnt=i;
		while(1){pnt=child[pnt],len++;if(pnt==i)break;}
		ll a=i,b=i;
		lol(u,k%len)b=child[b];
		while(1){last[a]=b,vis[a]=true;a=child[a],b=child[b];if(a==i)break;}
	}
	ll sum=x[0];
	cout<<sum<<endl;
	lol(i,n-1){
		sum+=dis[last[i]];
		cout<<sum<<endl;
	}
	return 0;
}


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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n);
    for(ll i = 0;i < n;i++){
        cin >> x[i];
    }

    sort(x.begin(),x.end());

    ll cost = 0, ans = 0;
    for(ll i = 1;i <= 100;i++){
        cost = 0;
        for(ll j = 0;j < n;j++){
            cost += powk(x[j] - i, 2);
        }
        if(i == 1) ans = cost;
        ans = min(ans, cost);
        //cout << cost << endl;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll x;std::cin >> x;
  ll ans = 10000000;
  for(int i=1;i<1000;i++){
    ll now = 360*i;
    if(now%x==0) ans = min(ans, now/x);
  }
  std::cout << ans << '\n';
  return 0;
}


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

using i64 = long long;

struct Graph
{
  struct edge
  {
    int to;
    i64 cap;
    i64 rev;
    bool alive;
  };

  int n;
  vector<vector<edge>> edges;

  Graph(int N)
  {
    n = N;
    edges.resize(n, vector<edge>());
  }

  int size() const { return n; }

  vector<edge> &operator[](int v) { return edges[v]; }
};

struct Dinic_Reverse
{
  int N;
  vector<int> used;
  Graph G;

  Dinic_Reverse(int n) : G(n) { N = n; }

  void add_edge(int from, int to, i64 cap, i64 rev_cap)
  {
    G[from].push_back({to, cap, (int)G[to].size(), true});
    G[to].push_back({from, rev_cap, (int)G[from].size() - 1, true});
  }
  i64 dfs(int v, int t, i64 f)
  {
    if (v == t)
      return f;
    used[v] = true;
    for (int i = 0; i < (int)G[v].size(); i++)
    {
      auto &e = G[v][i];
      if (!e.alive)
        continue;
      if (e.cap > 0 && !used[e.to])
      {
        i64 mi_f = dfs(e.to, t, min(f, e.cap));
        if (mi_f > 0)
        {
          e.cap -= mi_f;
          G[e.to][e.rev].cap += mi_f;
          return mi_f;
        }
      }
    }
    return 0;
  }

  i64 max_flow(int s, int t, i64 limit = 1e9)
  {
    i64 result = 0;
    i64 flow;
    while (limit > 0)
    {
      used.assign(N, 0);
      if ((flow = dfs(s, t, limit)) == 0)
        break;
      result += flow;
      limit -= flow;
    }
    return result;
  }

  bool back_edge(int from, int to, int s, int t)
  {
    for (auto &e : G[from])
    {
      if (e.to == to && e.alive)
      {
        e.alive = false;
        if (e.cap == 0 && max_flow(from, to, 1) == 0)
        {
          max_flow(from, s, 1);
          max_flow(t, to, 1);
          return 1;
        }
        else
        {
          return 0;
        }
      }
    }
  }
};

/*
 
checked
    http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=2723921#1
*/
int n;
int e;
int q;

int main()
{
  cin >> n >> e >> q;
  Dinic_Reverse dinic(n);
  int s = 0;
  int t = n - 1;
  for (int i = 0; i < e; i++)
  {
    int a, b;
    ;
    cin >> a >> b;
    a--;
    b--;
    dinic.add_edge(a, b, 1, 1);
  }
  int flow = dinic.max_flow(s, t);
  for (int i = 0; i < q; i++)
  {
    int m, a, b;
    cin >> m >> a >> b;
    a--;
    b--;
    if (m == 1)
    {
      dinic.add_edge(a, b, 1, 1);
      flow += dinic.max_flow(s, t, 1);
    }
    else
    {
      flow -= dinic.back_edge(a, b, s, t);
      flow -= dinic.back_edge(b, a, s, t);
    }
    cout << flow << endl;
  }
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fr(i, a, b) for (int i = a; i < b; i++)
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif

    int n,k;cin>>n>>k;
    int h[n+1];
    fr(i,1,n+1) cin>>h[i];
    int dp[n+1];
    dp[1]=0;
    fr(i,2,n+1){
        dp[i]=INT_MAX;
        for(int j=1;j<=k;j++){
            if(i-j>0){
                dp[i] = min(dp[i],abs(h[i]-h[i-j])+dp[i-j]);
            }
        }
    }
    cout<<dp[n]<<endl;

}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
int main(){
  int i,j,n;
  int maxv,minv;

  scanf("%d",&n);
  if(n < 2 || 200000 < n){
    exit(1);
  }
  int R[n];

  for(i = 0; i< n; i++){
    scanf("%d",&R[i]);
    if(R[i] < 1 || 10000000000 < R[i]){
      exit(1);
    }
  }
  minv = R[0];
  maxv = R[1]-R[0];
  for(j = 1; j <= n-1; j++){
    if(maxv <= R[j]-minv){
      maxv = R[j]-minv;
    }
    if(R[j] < minv){
      minv = R[j];
    }
  }
  printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 1376
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N, M = mi()
C = [ii() for _ in range(N)]
W = [ii() for _ in range(M)]

dp = dp2(float('inf'), N+1, M+1)
dp[0][0] = 0

for i in range(M):
    for j in range(N+1):
        if j+1 <= N:
            dp[i+1][j+1] = min(dp[i][j]+W[i]*C[j], dp[i+1][j+1])
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])

print(dp[M][N])


Measured memory_bytes: 18744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a,b,c;
string str[100005];
string anstr[100005];
void dfs(int now,int a,int b,int c){
	if(now>n){
		puts("Yes");
		for(int i=1;i<=n;i++)cout<<anstr[i]<<endl;
		exit(0);
	}
	if(str[now]=="AB"){
		if(b>0)anstr[now]="A",dfs(now+1,a+1,b-1,c);
		if(a>0)anstr[now]="B",dfs(now+1,a-1,b+1,c);
	}
	else if(str[now]=="AC"){
		if(a>0)anstr[now]="C",dfs(now+1,a-1,b,c+1);
		if(c>0)anstr[now]="A",dfs(now+1,a+1,b,c-1);
	}
	else{
		if(c>0)anstr[now]="B",dfs(now+1,a,b+1,c-1);
		if(b>0)anstr[now]="C",dfs(now+1,a,b-1,c+1);
	}
}
int main()
{
	cin>>n>>a>>b>>c;
	for(int i=1;i<=n;i++)cin>>str[i];
	dfs(1,a,b,c);
	puts("No");
	return 0;
}

Measured memory_bytes: 17640
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cerrno>
#include<clocale>
#include<cmath>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<vector>
#include<cwchar>
#include<cwctype>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define sz(a) int((a).size())

inline int read()
{
    char ch=getchar();
    int x=0,f=1;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=getchar();
    return x*f;
}

ll a[100005];
ll suf[100005];
ll ans[100005];

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=0;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=n;i>=0;i--)
	{
		suf[i]=suf[1+i]+a[i];
	}
	ans[0]=1;
	for(int i=1;i<=n;i++)
	{
		ans[i]=min((ans[i-1]-a[i-1])*2,suf[i]);
	}
	for(int i=0;i<=n;i++)
		if(ans[i]<a[i])
		{
			cout<<"-1"<<endl;
			return 0;
		}
	ll res=0;
	for(int i=0;i<=n;i++)
	{
		res+=ans[i];
	}
	cout<<res<<endl;
	return 0;
}


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

typedef long long LL;

int n,W;

int w[105];
LL v[105];

LL memo[105][100005];

LL dp(int id, int cw){
	if(id>n) return 0LL;
	LL &ret = memo[id][cw];
	if(ret!=-1) return ret;
	ret = dp(id+1,cw);
	if(cw>=w[id]) ret = max(ret,dp(id+1,cw-w[id])+v[id]);
	return ret;
}

int main(){
	memset(memo,-1,sizeof(memo));
	scanf("%d%d",&n,&W);
	for(int i=1;i<=n;i++) scanf("%d%lld",&w[i],&v[i]);
	LL ans = dp(1,W);
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    ll h = in();

    ll ans = 0;
    ll tmp = 1;
    while (h > 0)
    {
        h /= 2;
        ans += tmp;
        tmp *= 2;
    }
    cout << ans << endl;
}

signed 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: 256
#include "bits/stdc++.h"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


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

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


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int n;
    cin >> n;
    vector<i64> a(n);
    for(auto& x : a)
        cin >> x;
    int cnt = 0, b = a[0];
    for(int i = 1; i < n; ++i){
        if(b >= a[i]){
            ++cnt;
        }
        b = a[i];
    }
    cout << ++cnt << endl;
    cout << n << endl;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,ans=0;
bool flagx,flagy,flagz;
void Main(){    
    cin>>n>>m;
    vector<ll> x(n),y(n),z(n);
    For(i,0,n)cin>>x.at(i)>>y.at(i)>>z.at(i);
    For(i,0,8){
        ll ansi=0;
        flagx=i&4;
        flagy=i&2;
        flagz=i&1;
        vector<ll> sum(n,0);
        For(j,0,n){
            if(flagx) sum.at(j)+=x.at(j);
            else sum.at(j)-=x.at(j);
            if(flagy) sum.at(j)+=y.at(j);
            else sum.at(j)-=y.at(j);
            if(flagz) sum.at(j)+=z.at(j);
            else sum.at(j)-=z.at(j);
        }
        sort(sum.rbegin(),sum.rend());
        For(j,0,m){
            ansi+=sum.at(j);
        }
        ans=max(ans,ansi);
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}



int main() {
	int max = 250000;
	vi prime(max, 1);
	prime[0] = 0;
	prime[1] = 0;
	for (int i = 2; i <= sqrt(max); i++) {
		if (prime[i] == 1) {
			int j=2;
			while (i*j < max) {
				prime[i*j] = 0;
				j++;
			}
		}
	}
	int n;
	while(1) {
		cin >> n;
		if (n == 0) break;
		int ans = 0;
		for (int i = n+1; i <= 2 * n;i++) {
			if (prime[i]) ans++;
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3680
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

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


Measured memory_bytes: 3628
N, M = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

X = [list(map(int, input().split())) for _ in range(M)]
X.sort(key=lambda x: x[1], reverse=True)
num_cnt = [x[0] for x in X]
val_cnt = [x[1] for x in X]

idx = 0
cnt = 0
ans = 0
cum = 0
for i in range(min(N, sum(num_cnt))):
  if val_cnt[idx] <= a[i]:
    print(sum(a[i:]) + ans)
    break
  ans += val_cnt[idx]
  cnt += 1
  cum += 1
  if num_cnt[idx] == cnt:
    idx += 1
    cnt = 0
  if cum == N:
    print(ans)
    break
else:
  print(sum(a[sum(num_cnt):] + [val_cnt[i] * num_cnt[i] for i in range(M)]))


Measured memory_bytes: 33784
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end() 

int const N = 200001;
int n, m, v[N], take[N], ID;
vector<int> g[N], cur; 
bool vs[N];

void go(int u){
     vs[u] = true;
     cur.push_back(u);
     take[v[u]] = ID;
     for(auto j: g[u])if(!vs[j])go(j);
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 1; i<=n; ++i)scanf("%d", v+i);
    for(int i = 0, x, y; i<m; ++i){
        scanf("%d%d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int an = 0;
    for(int i = 1; i<=n; ++i){
         if(!vs[i]){
            cur.clear();
            ++ID;
            go(i);
            for(auto j: cur){
                if(take[j] == ID)++an;
            }
         }
    }
    printf("%d\n", an);
}

Measured memory_bytes: 13052
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24916
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    vector<pair<int, int>> balls(N);
    for (int i = 0; i < N; ++i)
    {
        int xi, yi;
        cin >> xi >> yi;
        balls[i] = { xi, yi };
    }
    sort(balls.begin(), balls.end());
    map<pair<int, int>, int> diffCountMap;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            diffCountMap[{
                    balls[i].first - balls[j].first,
                    balls[i].second - balls[j].second,
            }] += 1;
        }
    }
    int maxDiffs = 0;
    for (const auto &diffCount : diffCountMap)
    {
        if (diffCount.second > maxDiffs)
        {
            maxDiffs = diffCount.second;
        }
    }
    cout << N - maxDiffs << endl;
}


Measured memory_bytes: 384
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < n; i++){
            int m = sc.nextInt();
            if(set.contains(m)){
                set.remove(m);
            }else {
                set.add(m);
            }
        }
        System.out.println(set.size());
    }
}

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


int main() {
        int n, k;
        scanf("%d%d", &n, &k);
        int a[n], dp[n];
        for (int i = 0; i < n; i++) scanf("%d", a + i), dp[i] = 1e9;
        dp[0] = 0;
        for (int i = 1; i < n; i++) {
                for (int j = i - 1; j >= max(0, i - k); j--) {
                        dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
                }
        }
        cout << dp[n - 1];
}

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1003;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1000000007;

int n, m;
int keys[MAXN], a[MAXN], dp[2][1<<12];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> m;
    REP1 (i, m) {
        int k;
        cin >> a[i] >> k;
        REP (j, k) {
            int d;
            cin >> d;
            keys[i] |= (1<<(d-1));
        }
    }

    memset(dp, 0x3f3f3f3f, sizeof(dp));

    dp[0][0] = dp[1][0] = 0;

    REP1 (i, m) {
        REP (j, (1<<n)) {
            dp[i&1][j] = dp[i&1^1][j];
            if ((keys[i] & j) == keys[i]) {
                dp[i&1][j] = min(dp[i&1^1][j^keys[i]] + a[i], dp[i&1][j]);
                for (int st=keys[i]; st>0; st=(st-1)&keys[i]) {
                    dp[i&1][j] = min(dp[i&1^1][(j^keys[i])|st] + a[i], dp[i&1][j]);
                }
            }
        }
    }

    cout << (dp[m&1][(1<<n)-1] == 0x3f3f3f3f ? -1 : dp[m&1][(1<<n)-1]) << endl;
    return 0;
}


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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

li = factorization(N) 
ans = 0
for l in li:
    n = l[0]
    if n == 1:
        continue
    count = l[1]
    ans += 1
    now = 1
    count -= 1
    while count > 0:
        now += 1
        count -= now
        if count >= 0:
            ans += 1

print(ans)

Measured memory_bytes: 63176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef pair<int,int> P;
typedef pair<double,double> P_f;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define bitrep(bit,n) for(int bit=0; bit<=(1<<n);bit++)
#define MAX 100100
#define MAX_N 200100
#define MAX_T 2001001
#define SENTINEL 20010010010
#define NIL -1
static const int INF = 1 << 29;
const ll INFTY = 1LL<<50;
const int MOD=1e9+7;
LL a,b,x;
int main(){
cin>>a>>b>>x;
LL quat=b/x-a/x;

cout<<quat+!(a%x)<<endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

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

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  int  a, b, c, d, e, X, Y ,r;
//  unsigned long long  a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
  int  A[200003]={};
  int  B[100003]={};
//  int  C[100003][100001]={};
  int  C[100003]={};

  int  flg=0;

//  char s[101][101]={};
  char s[100001]={};
  char t[100001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p=0,q=0;
//  int flag=0;
//  int tmp=0;
//  char tmp[101]={};
//  long long min=10000000000;
//  long long min=100000001;
  int min =100000001;
  int len=0;
  int l=0;
//  int r=1000001;
  int cnt=0;
  int num=0;
  int num1=0;
  int num2=0;
  long long  ans=0;
  int ans_ac=0;
  int ans_wa=0;
  int max=0;
  long long sum=0;
  int addr=0;
  int ptn=0;
  int  tmp=0;
  double per=0; 
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
  scanf("%d %d %d", &a, &b, &c);
  
    printf("%d %d %d\n",c , a, b);
  
return 0;
}


Measured memory_bytes: 128
def solve(string):
    s, q, *qs = string.split("\n")
    pre = []
    post = []
    r = False
    for _q in qs[::-1]:
        if _q == "1":
            r = not r
            continue
        _, f, c = _q.split()
        if r and f == "2" or not r and f == "1":
            pre.append(c)
        else:
            post.append(c)
    pre, post = "".join(pre), "".join(post[::-1])
    return pre + s[::-1] + post if r else pre + s + post


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 22404
#include <bits/stdc++.h>
using namespace std;
using ll = __int128;
const ll b = 1713302033171ll;

ll Pow(ll x, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1) {
			res = (res * x) % b;
		}
		x = (x * x) % b;
		n >>= 1;
	}
	return res;
}

int main()
{
	vector<ll> prime;
	for (ll i = 100000;prime.size() < 26; i++) {
		bool flag = true;
		for (ll j = 2; j * j <= i; j++) {
			if (i % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			prime.push_back(i);
		}
	}

	string s1, s2;
	cin >> s1 >> s2;
	int n1 = s1.size(), n2 = s2.size();
	vector<ll> rh1(n1 + 1), rrh1(n1 + 1), rh2(n2 + 1), rrh2(n2 + 1);
	rh1[0] = rrh1[0] = rh2[0] = rrh2[0] = 1;
	for (int i = 1; i <= n1; i++) {
		rh1[i] = (rh1[i - 1] * prime[s1[i - 1] - 'a']) % b;
		rrh1[i] = Pow(rh1[i], b - 2);
	}
	for (int i = 1; i <= n2; i++) {
		rh2[i] = (rh2[i - 1] * prime[s2[i - 1] - 'a']) % b;
		rrh2[i] = Pow(rh2[i], b - 2);
	}
	bool fini = true;
	for (int k = min(n1, n2); k > 0; k--) {
		bool can = false;
		vector<ll> hs(n1 - k + 1);
		for (int i = 0; i + k <= n1; i++) {
			hs[i] = (rrh1[i] * rh1[i + k]) % b;
		}
		sort(hs.begin(), hs.end());
		for (int j = 0; j + k <= n2; j++) {
			if (binary_search(hs.begin(), hs.end(), (rrh2[j] * rh2[j + k]) % b)) {
				can = true;
				break;
			}
		}
		if (can) {
			fini = false;
			cout << k << endl;
			break;
		}
	}
	if (fini) {
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 3376
#include<stdio.h>

int main()
{
//３つの数の入力
int a,b,c;
scanf("%d%d%d",&a,&b,&c);

//繰り返しの回数
int re;
scanf("%d",&re);

//abcのうち，最大のものをre回だけ倍にする
int max=a;
if (max<b) max=b;
if (max<c) max=c;
int tmp=max;
for(int i=0;i<re;i++)
  {
    max*=2;
  }

int ans=(a+b+c)+max-tmp;
printf("%d\n",ans);

return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

#define IOS ios::sync_with_stdio(0);cin.tie(0);

const int max_N=100006;

long long int a[max_N],b[max_N];

int main(){
	IOS;
	long long int n,h,amax;
	while(cin>>n>>h){
		amax=0;
		for(int i=0;i<n;i++){
			cin>>a[i]>>b[i];
			amax=max(amax,a[i]);
		}
		long long int round=0;
		sort(b,b+n);
		for(int i=n-1;i>=0;i--){
			if(h<=0){
				break;
			}
			else{
				if(b[i]>=amax){
					h-=b[i];
					round++;
				}
				else{
					break;
				}
			}
		}
		while(h>0){
			h-=amax;
			round++;
		}
		cout<<round<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
local mmi, mma = math.min, math.max
local capacity = io.read("*n")
local t = {}
local k = io.read("*n")
for i = 1, k do
  t[i] = {}
  t[i][1] = i
  t[i][2] = io.read("*n")
end
local q = io.read("*n")
for i = 1, q do
  t[k + i] = {}
  t[k + i][1] = k + i
  t[k + i][2] = io.read("*n")
  t[k + i][3] = io.read("*n")
end
table.sort(t, function(a, b) return a[2] < b[2] end)
local leftidx, rightidx = 0, capacity
local leftpos, rightpos = 0, capacity
local lasttime = 0
local way = false
for i = 1, k + q do
  if t[i][1] <= k then
    local len = t[i][2] - lasttime
    if way then
      rightpos = rightpos + len
      if capacity < rightpos then
        rightidx = mma(0, rightidx - (rightpos - capacity))
        rightpos = capacity
      end
      leftpos = mmi(leftpos + len, capacity)
      leftidx = mmi(leftidx, rightidx)
    else
      leftpos = leftpos - len
      if leftpos < 0 then
        leftidx = mmi(capacity, leftidx - leftpos)
        leftpos = 0
      end
      rightpos = mma(rightpos - len, 0)
      rightidx = mma(rightidx, leftidx)
    end
    lasttime = t[i][2]
    way = not way
  else
    local len = t[i][2] - lasttime
    local ri, li = rightidx, leftidx
    local rp, lp = rightpos, leftpos
    if way then
      rp = rp + len
      if capacity < rp then
        ri = mma(0, ri - (rp - capacity))
        rp = capacity
      end
      lp = mmi(lp + len, capacity)
      li = mmi(li, ri)
    else
      lp = lp - len
      if lp < 0 then
        li = mmi(capacity, li - lp)
        lp = 0
      end
      rp = mma(rp - len, 0)
      ri = mma(ri, li)
    end
    local p = t[i][3]
    if p <= li then
      t[i][4] = lp
    elseif ri <= p then
      t[i][4] = rp
    else
      t[i][4] = lp + p - li
    end
  end
end
table.sort(t, function(a, b) return a[1] < b[1] end)
for i = k + 1, k + q do
  print(t[i][4])
end


Measured memory_bytes: 19960