akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    N = int(input())
    S = input()

    ans = 0
    for i in range(N - 2):
        ans += S[i: i + 3] == "ABC"
    print(ans)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9892
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>

using namespace std;
typedef long long int ll;

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

int main()
{
	int n;
	scanf("%d", &n);
	ll a[100000], sum=0;
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		sum+=a[i];
	}
	if(n==1){
		if(sum==1){
			printf("Second\n");
		}else{
			printf("First\n");
		}
		return 0;
	}
	if(n%2==0){
		if(sum%2==0){
			printf("Second\n");
		}else{
			printf("First\n");
		}
		return 0;
	}
	if(sum%2==0){
		printf("First\n");
		return 0;
	}
	int c=0;
	while(1){
		int count=0, count1=0;
      ll sum1=0;
		for(int i=0; i<n; i++){
          if(a[i]==1){
            count1++;
            continue;
          }
          sum1+=a[i];
			if(a[i]%2!=0){
				count++;
				a[i]--;
			}
		}
      if((n-count1)%2==0){
        if((c+sum1)%2==0){
          printf("Second\n");
        }else{
          printf("First\n");
        }
        return 0;
      }
      if(sum1%2==0){
        if(c%2==0){
          printf("First\n");
        }else{
          printf("Second\n");
        }
        return 0;
      }
		if(count>1){
			if(c%2==0){
				printf("Second\n");
			}else{
				printf("First\n");
			}
			return 0;
		}
		ll g=a[0];
		for(int i=1; i<n; i++){
			g=gcd(g, a[i]);
		}
		for(int i=0; i<n; i++){
			a[i]/=g;
		}
		c++;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>
int getSibling(int);
int getDegree(int);
int getDepth(int);
int getHeight(int);
struct Node{
	int p;
	int l;
	int r;
};
struct Node T[25];
int main(){
	int num,i,e;
	scanf("%d",&num);
	for(i=0;i<num;i++){
		T[i].p=-1;
	}
	for(i=0;i<num;i++){
		scanf("%d",&e);
		scanf("%d%d",&T[e].l,&T[e].r);
		if (T[e].l != -1) T[T[e].l].p=e;
		if (T[e].r != -1) T[T[e].r].p=e;
	}
	for(i=0;i<num;i++){
		if(T[i].p == -1){
			printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, root\n",i,T[i].p,getSibling(i),getDegree(i),getDepth(i),getHeight(i));

		}else if(getDegree(i) >= 1){
			printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,T[i].p,getSibling(i),getDegree(i),getDepth(i),getHeight(i));

		}else{
			printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,T[i].p,getSibling(i),getDegree(i),getDepth(i),getHeight(i));
		}
		//if(i != num-1) printf("\n");
	}
	return 0;
}
int getSibling(int n){
	if(T[n].p==-1){
		return -1;
	}
	else if(T[T[n].p].l!=n){
		return T[T[n].p].l;
	}else{
		return T[T[n].p].r;
	}
}

int getDegree(int n){
	int count=0;
	if(T[n].l != -1) count++;
	if(T[n].r != -1) count++;
	return count;
}

int getDepth(int n){
	if(T[n].p == -1) return 0;
	  return getDepth(T[n].p)+1;
}

int getHeight(int n){
	int right=0,left=0;
	  if(T[n].r == -1 && T[n].l == -1) return 0;

	  if(T[n].r != -1) right = getHeight(T[n].r)+1;
	  if(T[n].l != -1) left = getHeight(T[n].l)+1;

	  return fmaxf(right,left);
}

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

int main(void)
{   
    int N;
    long long K;
    cin >> N >> K;
    
    vector<int> p{0};
    vector<long long> c{0};

    int tp;
    for(int i=0; i<N; ++i){
        cin >> tp;
        p.push_back(tp);
    }
    long long tc;
    for(int i=0; i<N; ++i){
        cin >> tc;
        c.push_back(tc);
    }

    long long max = -9223372036854775807;

    for(int i=1; i <= N; ++i){
        int naw = i;
        long long S = 0;
        long long l = 0;
        long long lmax = -9223372036854775807;
        int kl = K;
        long long max_l;
        long long imax = -9223372036854775807;
        
        vector<long long>s{0};
        while (true){
            naw = p[naw];
            S += c[naw];
            s.push_back(c[naw]);
            l += 1;
            --kl;
            if(S > lmax) {
                lmax = S;
            }
            if(kl == 0 || naw == i){
                break;
            }
        }

        if(kl == 0){
            imax = lmax;
        }else{
            if(S <= 0){
                imax = lmax;                
            }else{
                long long sum = 0;
                long long tmax = S;
                for(int j = 1; j <= l; ++j){
                    sum += s[j];
                    tmax = sum + S * ( (K - j) / l);
                    if(tmax > imax) imax = tmax;
                }

            }
        }

        if (imax > max) max = imax;
    }

    cout << max << endl;

}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max<R>(x,0.0));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

// Problem Specific Parameter:

// Description: ??°??????????????????(?????????????°??????¨???)
// Verifyed: Many Diffrent Problem 

//Appropriately Changed
using edge=struct{int to;};
using G=vector<vector<edge>>;

//Appropriately Changed
void add_edge(G &graph,int from,int to){ 
	graph[from].push_back({to});
}

// Description: ????????°????????????????????¢?????? 
// TimeComplexity: $ \mathcal{O}(V + E) $
// Verifyed: AOJ GRL_3_A 

auto articulation_point(const G& graph){
    int n=graph.size(),k=0;
    vector<int> par(n),ord(n,-1),low(n),root(n,0),res;

    auto dfs=[&](int v,int p,int &k){
        auto func=[&](int v,int p,int &k,auto func)->void{
            ord[v]=k++,low[v]=ord[v],par[v]=p;
            for(auto &e:graph[v]){
                if(e.to==p) continue;
                if(ord[e.to]==-1)
                    func(e.to,v,k,func),chmin(low[v],low[e.to]);
                else
                    chmin(low[v],ord[e.to]);
            }
        };
        return func(v,p,k,func);
    };

    rep(v,n) if(ord[v]==-1) dfs(v,-1,k),root[v]=1;

    rep(v,n){
        if(root[v]){
            int degree=0;
            for(auto &e:graph[v]) if(v==par[e.to]) degree++;
            if(degree>=2) res.push_back(v);
        }else{
            for(auto &e:graph[v]){
                if(v==par[e.to]&&ord[v]<=low[e.to]){
                    res.push_back(v);
                    break;
                }
            }
        }
    }
    return res;      
}

int main(void){
	int v,e;
	cin >> v >> e;
	G graph(v);
	rep(i,e){
		int a,b;
		cin >> a >> b;
		add_edge(graph,a,b);
		add_edge(graph,b,a);
	}

	auto res=articulation_point(graph);
	for(auto &it:res) cout << it << endl; 
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int n, m;
string s, t;
const int MAX = 1010;

int dp[MAX][MAX];

int rec(int si, int ti) {
    if (dp[si][ti] >= 0) {
        return dp[si][ti];
    }
    int res = 0;
    if (si == n and ti == m) {
        return res;
    }
    else {
        if (s[si] == t[ti]) {
            res = max(res, rec(si + 1, ti + 1) + 1);
        }
        else {
            if (si < n) {
                res = max(res, rec(si + 1, ti));
            }
            if (ti < m) {
                res = max(res, rec(si, ti + 1));
            }
        }
    }
    return (dp[si][ti] = res);
}

void solve() {
    int q;
    cin >> q;
    while (q--) {
        cin >> s >> t;
        n = s.size(), m = t.size();
        fill(dp[0], dp[MAX], -1);
        cout << rec(0, 0) << endl;
    }
}

int main() {
    solve();
}

Measured memory_bytes: 7184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = acos(-1.0);

#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)
#define sz(x) (int)(x).size()
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);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 RALL(x) (x).rbegin(),(x).rend()
#define SORT(v) sort(ALL(v));
#define RSORT(v) sort(RALL(v));
#define IN(type,a) type a;cin >> a;
#define VIN(type,a,n) vector<type> a(n);cin >> a;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;
#define COUT(x) cout << (x) << endl;
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl;
#define ENDL cout << endl;
#define DB(s,x) cout << (s) << " : " << x << endl;
 
#define HOGE COUT("HOGE")
 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,sz(v))i>>v[j];return i;}
 
template<typename T> bool chmax(T& a, const T& b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T& a, const T& b){if(a>b){a=b;return true;}return false;}
template<typename T> T gcd(T a,T b){if(b==0){return a;}else{return gcd(b, a%b);}}
template<typename T> T lcm(T a,T b){return a*b/gcd(a, b);}


const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  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() {
    IN(int, n);
    vector<pair<int, int>> a(n);
    REP(i, n){
        cin >> a[i].first;
        a[i].second = i;
    }
    SORT(a);
    REP(i, n){
        if (i==a[n-1].second) {
            COUT(a[n-2].first);
        }else{
            COUT(a[n-1].first);
        }
    }
}


Measured memory_bytes: 4800
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()

#define X first
#define Y second

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

const int INF = 0x3fffffff;


int R, C, N;
bool ans=true;
vector<pii> edge[2][100005];
int memo[2][100005];

bool dfs(int k, int n, int b, int v, int m[2]){
	//cout << "\t" << k << " " << n << " " << b << " " << v << " (" << m[0] << "," << m[1] << ") " << endl;
	if( memo[k%2][n] == INF ) memo[k%2][n] = v;
	else return ( memo[k%2][n] == v );
	chmin( m[k%2], v );
	if( m[0] + m[1] < 0 ) return false;
	bool ret = true;
	for(auto t: edge[k%2][n]){
		ret &= dfs(k+1, t.X, n, t.Y-v, m);
	}
	return ret;
}

int main(){
	cin >> R >> C >> N;
	rep(i,N){
		int r, c, a;
		cin >> r >> c >> a;
		r--; c--;
		edge[0][r].emplace_back(c, a);
		edge[1][c].emplace_back(r, a);
	}

	Fill(memo, INF);
	rep(i,R){
		if( memo[0][i] != INF ) continue;
		//cout << "start i=" << i << endl;
		int m[2] = {INF, INF};
		ans &= dfs(0, i, -1, 0, m);
	}

	cout << (ans?"Yes":"No") << endl;

	return 0;
}


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

bool np[200005]; 
int n, prime[200005], tot;

int getprime() {
	for (int i = 2; i <= 200000; i++) {
		if (!np[i]) {
			prime[++tot] = i;
			if (i >= n) return i;
		}
		for (int j = 1; j <= tot; j++) {
			if (i * prime[j] > 200000) break;
			np[i * prime[j]] = 1;
			if (i % prime[j] == 0) break;
		}
	}
	return prime[tot];
}

int main() {
	cin >> n;
	cout << getprime();
	return 0;
}

Measured memory_bytes: 512
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const ll MOD = 1000000007;
 
 long long fac[MAX], finv[MAX], inv[MAX];
 
 // テーブルを作る前処理
 void COMinit() {
     fac[0] = fac[1] = 1;
     finv[0] = finv[1] = 1;
     inv[1] = 1;
     for (int i = 2; i < MAX; i++){
         fac[i] = fac[i - 1] * i % MOD;
         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
         finv[i] = finv[i - 1] * inv[i] % MOD;
     }
 }
 
 // 二項係数計算
 long long COM(int n, int k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
 }
 

 long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
  ll inv_mul(ll x, ll y){
     return (x % MOD* modpow(y,MOD-2))%MOD;
 }
  
int main() {
    ll n,a,b;
    std::cin >> n>>a>>b;
    
    ll na,nb;
    
    na = nb = 1;
    
    
    for (int i = 0; i < a; i++) {
        na *= n-i;
        na %= MOD;
        na = inv_mul(na,a-i);
        na %= MOD;
    }
    
    
    for (int i = 0; i < b; i++) {
        nb *= n-i;
        nb %= MOD;
        nb = inv_mul(nb,b-i);
        nb %= MOD;
    }
    std::cout <<     (modpow(2,n)-1-na-nb+MOD*3)%MOD << std::endl;    

}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll n;
  cin >> n;
  vector<P> x(n);
  ll ans[n];
  for(int i=0;i<n;i++){
    cin >> x[i].first;
    x[i].second = i;
  }
  sort(x.begin(),x.end());
  for(int i=0;i<n;i++){
    if(i<n/2){
      ans[x[i].second] = x[n/2].first;
    }else{
      ans[x[i].second] = x[n/2-1].first;
    }
  }
  for(int i=0;i<n;i++){
    cout << ans[i]<<endl;
  }
}


Measured memory_bytes: 6912
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define all(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x,y)* mod_pow(kai(y,y), mod - 2, mod) % mod;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

signed main() {
	string s;
	cin >> s;
	for(int i=1;i<s.size();++i) {
		if (s[i] != s[i - 1]) { cout << "Yes" << endl; return 0; }
	}
	cout << "No" << endl; return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
    int h,m,s,S;
    scanf("%d",&S);
    
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    
    printf("%d:%d:%d\n",h,m,s);
    
    return 0;
    
}


Measured memory_bytes: 2136
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

bool is_prime(ll x){
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return false;
    }
    return true;
}

int main(){
    ll Q; cin >> Q;
    vl ls(Q,0), rs(Q,0); REP(i, Q) cin >> ls[i] >> rs[i];
    ll N = 1e5+10;
    vl sum(N,1); ll cnt = 0; vb is_tgt(N,false);
    FOR(i, 2, N){
        if( is_prime(i) && is_prime((i+1)/2) ){
            is_tgt[i] = true; cnt++;
        }
        sum[i] = cnt;
    }
    REP(i, Q){
        cout << (sum[rs[i]] - sum[ls[i]] + ( is_tgt[ls[i]] ? 1 : 0 )) << endstr;
    }
    return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<double> vi;

int main(){
    while(1){
        double r, n;
        cin >> r >> n;
        if(r == 0 && n == 0) break;
        vi hr(41), hl(41);
        rep(i, 41){
            hr[i] = 0; hl[i] = 0;
        }
        vi xl(n), xr(n), h(n);
        rep(i, n){
            cin >> xl[i] >> xr[i] >> h[i];
            xl[i] += 20;
            xr[i] += 20;
            rep(j, abs(xr[i]-xl[i])){
                hl[xl[i]+j] = max(h[i], hl[xl[i]+j]);
                hr[xl[i]+j+1] = max(h[i], hr[xl[i]+j+1]);
            }
        }
        hr[20-r] = hl[20-r];
        hl[20+r] = hr[20+r];
        double min_t = 100;
        for(int i = 20-r; i <= r+20; i++){
            double b = abs(20-i);
            double a = sqrt(r*r-b*b);
            min_t = min(min_t, (r-a)+min(hr[i], hl[i]));
            //cout << min_t << " " << i << endl;
        }
        printf("%.5lf\n", min_t);
    }
    return 0;
}


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

using namespace std;

int main(){
  string s,t;
  cin >> s;
  for (int i = 0; i < s.length(); ++i)
    if (i % 2 == 0) {
      t += s[i];
    }
    cout << t << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long N, K, Q;
    cin >> N >> K >> Q;
    long long A[N];
    vector<long long> count(N, 0);
    for (int i = 0; i < Q; i++)
    {
        long long a;
        cin >> a;
        ++count[a - 1];
    }
    for (int i = 0; i < N; i++)
    {
        count[i] += K - Q;
    }
    for (int i = 0; i < N; i++)
    {
        if (count[i] > 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
typedef long long ll;

int n,m,k;
string s,t;

int main() {
  cin >> n >> m;
  vector<int> v; bool ok[n+1]={false}; int a,b;
  rep(i,m){
    cin >> a >> b;
    if(a==1) v.push_back(b);
    if(b==n) ok[a]=true;
  }
  bool can=false;
  for(auto c : v)if(ok[c]) can=true;
  cout << (can ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 1020
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N, A, B = map(int, input().split())

print(min(N*A, B))

Measured memory_bytes: 77156
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<queue>
using namespace std;
 

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int  n;
	cin >> n;
	string s;
	cin >>s;
	vector<vector<int>> vec(n);
	char c;
	for (int i = 0; i < n; ++i) {
		c = s[i];
		for (int j = 1; i + j < n; ++j) {
			if (c == s[i + j]) vec[i].push_back(j);
		}
	}
	vector<int> saki(n);
	vector<int> kousin(n);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (auto e : vec[i]) {
			if (kousin[e]<i-1) saki[e] = 0;
			++saki[e];
			kousin[e] = i;
			ans =max(ans, min(e, saki[e]));
		}
	}

	cout << ans << endl;
}


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

namespace ABC179
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            if (S.EndsWith('s'))
                System.Console.WriteLine($"{S}es");
            else
                System.Console.WriteLine($"{S}s");
        }
    }
}


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

int main() {
  string s;
  cin>>s;
  char now=s.at(0);
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)==now){
      continue;
    }
    else{
      ans++;
      now=s.at(i);
    }
  }
  
  cout << ans;
}

Measured memory_bytes: 512
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val n = readLine.trim.toCharArray.map{_.asDigit}.toList
  val length = n.length
  implicit val memo = Array.tabulate(length + 1){_ ⇒ Array.tabulate(2){_ ⇒ Array.tabulate(2){_ ⇒ Array.tabulate(2){_ ⇒ None: Option[Long]}}}}

  println(
    count(n) + (3 until length).map{it ⇒ countWhole(it, false, false, false)}.sum
  )
  def count(digits: List[Int], useThree: Boolean = false, useFive: Boolean = false, useSeven: Boolean = false)(implicit memo: Array[Array[Array[Array[Option[Long]]]]]): Long = {
    digits match {
      case d::t ⇒
        (for (i ← List(3, 5, 7).filter(it ⇒ it <= d)) yield {
          if (d == i) count(t, useThree || i == 3, useFive || i == 5, useSeven || i == 7)
          else countWhole(t.length, useThree || i == 3, useFive || i == 5, useSeven || i == 7)
        }).sum
      case Nil if useThree && useFive && useSeven ⇒ 1L
      case _ ⇒ 0L
    }
  }
  def countWhole(digits: Int, useThree: Boolean, useFive: Boolean, useSeven: Boolean)(implicit memo: Array[Array[Array[Array[Option[Long]]]]]): Long = {
    if (digits != 0) {
      memo(digits)(if (useThree) 1 else 0: Int)(if (useFive) 1 else 0: Int)(if (useSeven) 1 else 0: Int) match {
        case Some(r) ⇒ r
        case None ⇒ (countWhole(digits - 1, true, useFive, useSeven) + countWhole(digits - 1, useThree, true, useSeven) + countWhole(digits - 1, useThree, useFive, true)).also{it ⇒
          memo(digits)(if (useThree) 1 else 0: Int)(if (useFive) 1 else 0: Int)(if (useSeven) 1 else 0: Int) = Some(it)
        }
      }
    }else {
      if (useThree && useFive && useSeven) 1L
      else 0L
    }
  }

  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}

Measured memory_bytes: 25792
/*
	Nishant Singh
	nishant.ns19
*/
#include <bits/stdc++.h>
#include <functional> 
#include <iostream> 

// ******** Big Integer ********
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #define ll1024  int1024_t
// ******** Big Integer ********

// ******** Using PBDS ********
// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// ******** Using PBDS ********

using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vll vector<ll>
#define vec vector
#define setcount(x) __builtin_popcountll(x)
#define f first
#define s second
#define mp make_pair
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define REV(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define in insert
#define init(x,a) memset(x,a,sizeof(x))
#define all(c) c.begin(),c.end()
#define pq priority_queue
#define ffl fflush(stdout)
#define mset multiset
#define out(x) cout<<#x<<" = "<<" "<<x<<"\n";
#define ub upper_bound
#define lb lower_bound 
#define ln "\n"
#define Y "YES"
#define N "NO"
ll const mod=1e9 + 7;
ll const inf=2e18;

// ******** Using PBDS ********
// typedef tree<long long, null_type, less<long long>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//                 os; 
// ******** Using PBDS ********

inline ll add(ll a,ll b) 
{ 
	return (a%mod + b%mod + mod)%mod; 
}

inline ll mul(ll a,ll b) 
{ 
	return (a%mod * b%mod + mod)%mod; 
}

inline ll sub(ll a,ll b) 
{ 
	return (a%mod - b%mod + mod)%mod; 
}

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

ll modexp(ll x, ll n){
	if(n==0){
		return 1;
	}
	else if(n&1){
		return (modexp((x*x)%mod, n/2)%mod * x%mod)%mod;
	}
	else{
		return (modexp((x*x)%mod, n/2)%mod);
	}
}

ll modinv(ll n)
{
	return modexp(n,mod-2);
}

// ******** GLOBAL VARIABLES ********


// ******** GLOBAL VARIABLES ********

void solve(){
	ll n;
	cin>>n;
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		if(i%3==0 || i%5==0)
		{
			continue;
		}
		else
			ans=ans+i;

	}
	cout<<ans;

}  

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	// cin>>T; 	
	for(int t=1;t<=T;t++)
	{
		// cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

int main()
{
  int *a,N,count=0;
  cin>>N;
  a=new int[N];
  for(int i=0;i<N;i++)
    cin>>a[i];
  
  for(int i=0;i<N;i+=2)
  {
   if(a[i]%2==1)
     count++;
  }
  cout<<count;
    
  delete a;
}

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

int main(int argc, char const *argv[])
{
	int n,q;
	string s;
	cin>>n>>q>>s;
	char t[q],d[q];
	for (int i = 0; i < q; ++i)
	{
		cin>>t[i]>>d[i];
	}
	int lng=-1,lok=n;
	while(abs(lok-lng)>1)
	{
		int mid=(lng+lok)/2,now=mid,f=1;
		for (int i = 0; i < q; ++i)
		{
			if (s.at(now)==t[i])
			{
				if (d[i]=='L')
				{
					--now;
				}
				else
				{
					++now;
				}
				if (now<0)
				{
					f=0;
					break;
				}
				if (now>n-1)
				{
					break;
				}
			}
		}
		if (f==1)
		{
			lok=mid;
		}
		else
		{
			lng=mid;
		}
	}
	int rng=n,rok=-1;
	while(abs(rok-rng)>1)
	{
		int mid=(rng+rok)/2,now=mid,f=1;
		for (int i = 0; i < q; ++i)
		{
			if (s.at(now)==t[i])
			{
				if (d[i]=='L')
				{
					--now;
				}
				else
				{
					++now;
				}
				if (now>n-1)
				{
					f=0;
					break;
				}
				if (now<0)
				{
					break;
				}
			}
		}
		if (f==1)
		{
			rok=mid;
		}
		else
		{
			rng=mid;
		}
	}
	cout<<rok-lok+1<<endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

long long g(long long n){
  return (n *(n +1))/2;
}

int main()
{
  long long N;
  cin >> N;
  long long ans = 0;

  for (long long i = 1; i <= N; i++)
  {
    long long n = (ll)(N / i);
    ans += i * g(n);
  }
  cout << ans;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[123] = {};

int main(){
	scanf("%s", s);
	int n = strlen(s);
	if(s[n-1] == 's'){
		s[n] = 'e';
		s[n+1] = 's';
	} else {
		s[n] = 's';
	}
	printf("%s\n", s);
}


Measured memory_bytes: 3684
{-# LANGUAGE BangPatterns #-}

import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Data.Bits
import Control.Monad
import Control.Monad.ST

swap :: (VUM.Unbox a) => (a -> Bool) -> VUM.MVector s a -> ST s Int
swap f vec = loopl 0 (VUM.length vec - 1)
  where
    loopl x y | x > y = return x
    loopl x y = do
      vx <- VUM.unsafeRead vec x
      if (f vx) then
        loopl (x+1) y
      else
        loopr x y vx
    loopr x y vx | x > y = return x
    loopr x y vx = do
      vy <- VUM.unsafeRead vec y
      if not (f vy) then
        loopr x (y-1) vx
      else do
        VUM.unsafeWrite vec x vy
        VUM.unsafeWrite vec y vx
        loopl (x+1) (y-1)

sums :: Int -> VU.Vector Int -> ST s (VUM.MVector s Int)
sums n as = do
  vec <- VUM.new $ (n * (n + 1)) `div` 2
  let loop !i !x !y !prevSum
        | y >= n = if x >= n then return () else loop i (x+1) (x+1) 0
      loop i x y prevSum =
        VUM.unsafeWrite vec i newSum >> loop (i+1) x (y+1) newSum
        where
          ay = as VU.! y
          newSum = prevSum + ay
  loop 0 0 0 0
  return vec
  

query :: Int -> Int -> VU.Vector Int -> Int
query n k as = runST $ do
  svec <- sums n as
  loop svec 39 0
  where
    loop _ (-1) acc = return acc
    loop svec !lev !acc = do
      t <- swap (`testBit` lev) svec
      if k <= t then
        loop (VUM.take t svec) (lev - 1) (acc `setBit` lev)
      else
        loop svec (lev - 1) acc

main = do
  [n,k] <- map read . words <$> getLine
  as <- VU.unfoldrN n (BS.readInt . BS.dropWhile (==' ')) <$> BS.getLine
  putStrLn $ show $ query n k as

Measured memory_bytes: 4732
#include<stdio.h>
int main(){
  int n,r[250],i,j,s,w,d[250],t[250]={-1};
  while(scanf("%d",&n),n){
    for(i=s=r[0]=0;i<n*2;i+=2){
      scanf("%d %d %d",&w,&t[i+1],&t[i+2]);
      d[i+1]= w;
      d[i+2]=-w;
    }
    t[r[i+1]=i+1]=-1;
    for(i=1;i<=n*2;i++){//printf("%d\n",d[i]);
      for(j=i;t[r[j-1]]>t[i];j--)r[j]=r[j-1]; 
      r[j]=i;//for(j=0;j<=i;j++)printf("%d ",t[r[j]]);printf("\n");
    }//for(j=0;j<=i;j++)printf("%d ",t[r[j]]);printf("\n");
    for(i=1;i<=2*n;i++){//printf("%d\n",d[r[i]]);
      for(s+=d[r[i]];t[r[i+1]]==t[r[i]];i++)s+=d[r[i+1]];//printf("%d\n",s);
      if(s>150)break;
    }//printf("%d\n",i);
    if(s)printf("NG\n");
    else printf("OK\n");
  }
  return 0;
}
   

Measured memory_bytes: 588
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll min = INF;
  REP(i,max(2*x,2*y)+1){
    ll cost = i*c+max((2*x-i+1)/2*a,(ll)0)+max((2*y-i+1)/2*b,(ll)0);
    if(min>cost) min = cost;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
const int mod = 1e9+7;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
inline ll ksm(ll x,ll y){ll res=1;while(y){if(y&1) res=res*x%mod;x=x*x%mod;y>>=1;} return res;}
char s[1000010];
int n,tong[26];
int main()
{	
	n=read();
	scanf("%s",s+1);
	ll res=1;
	for(rint i=1;i<=n;++i)
	{
		tong[s[i]-'a']++;
	}
	for(rint i=0;i<26;++i) res=res*(tong[i]+1)%mod;
	cout<<(res-1+mod)%mod;
	return 0;
}	

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int arr[n];
    int dp[n];
    dp[0] = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    dp[1] = abs(arr[1] - arr[0]);
    for (int i = 2; i < n; i++)
    {
        // cout << i << " " << dp[i] << "\n";
        dp[i] = INT_MAX;
        if (i - k < 0)
        {
            for (int j = 0; j < i; j++)
                dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]));
        }
        else
        {
            for (int l = i - k; l < i; l++)
            {
                // cout << i << " " << l << "\n";
                dp[i] = min(dp[i], dp[l] + abs(arr[i] - arr[l]));
                // cout << dp[i] << " " << l;
            }
        }
    }
    // for (int i = 0; i < n; i++)
    // {
    //     cout << dp[i] << " ";
    // }
    cout << dp[n - 1] << "\n";
}

Measured memory_bytes: 4300
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    println(problem042a(a, b, c))
}

fun problem042a(a: Int, b: Int, c: Int): String {
    return if (listOf(a, b, c).count { it == 5 } == 2 && listOf(a, b, c).count { it == 7 } == 1) "YES" else "NO"
}

Measured memory_bytes: 36048
#include <bits/stdc++.h>
using namespace std;
	 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)
#define endl '\n'
	
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
	
	
int main(){
	fast_io; cout_precision;
	int a,b;	cin >> a >> b;
	if(a < b){
		for(int i=0; i<b; i++)	cout <<a;
		cout <<endl;
	}
	else{
		for(int i=0; i<a; i++)	cout <<b;
		cout <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
    int x=0,y=0,z=0,w=0,n=0,m=0;
cin >>x>>y>>z>>w;
cout<<((x-z)*(y-w));
}



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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin>>x;
    int c=1;
    int y = x;
    while(y!=0) {
        y =(y+x)%360;
        ++c;
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3580
#include<stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i=0; i<n; i++){
        scanf("%d", &a[i]);
    }

    int b[n];
    int et = n/2+n%2;
    int ot = n/2;

    int tmp = 1;
    for(int i=0; i<et; i++){
        b[i] = a[n-tmp];
        tmp += 2;
    }

    tmp = 2;
    for(int i=0; i<ot; i++){
        b[n-i-1] = a[n-tmp];
        tmp += 2;
    }

    for(int i=0; i<n; i++){
        printf("%d ", b[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
int main(void)
{
	int i,n,ans=0,a[n],b,c[n-1];
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++){
		cin>>b;
		ans+=b;
	}
	for(i=0;i<n-1;i++) cin>>c[i];
	for(i=1;i<n;i++){
		if(a[i-1]+1==a[i]){
			ans+=c[a[i-1]-1];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2304
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;

void main(){
	auto ip = readln.split.to!(int[]);
	writeln(ip[0] + ip[1]/2);
}

Measured memory_bytes: 256
import numpy as np
 
N, Q = map(int, input().split())
 
S = input()
 
ac = np.zeros(N)
count = 0
for i in range(N):
  ac[i] = count
  if S[i:i+2] == 'AC':
    count += 1
#print(ac)
for i in range(Q):
  l, r = map(int, input().split())
  print(int(ac[r-1] - ac[l-1]))

Measured memory_bytes: 14004
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

struct UF{
  vi sz, p;
  int comps;

  UF(int s) : comps(s) {
    sz.resize(comps + 1);
    p.resize(comps + 1);
    init();
  }

  void init(){
    for(int i = 0; i <= comps; i++){
      sz[i] = 1;
      p[i] = i;
    }
  }

  int fset(int u){
    return u == p[u] ? u : p[u] = fset(p[u]);
  }

  bool connect(int u, int v){
    u = fset(u);
    v = fset(v);
    if(u != v){
      if(sz[v] > sz[u]){
        swap(u, v);
      }
      sz[u] += sz[v];
      p[v] = u;
      comps--;
      return true;
    }
    return false;
  }
};

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, m, k;
  cin >> n >> m >> k;
  vi a(m), b(m);
  for(int i = 0; i < m; i++){
    cin >> a[i] >> b[i];
  }
  set <ii> st;
  vi c(k), d(k);
  for(int i = 0; i < k; i++){
    cin >> c[i] >> d[i];
    st.insert({c[i], d[i]});
  }
  UF uf(n + 1);
  vi deg(n + 1);
  for(int i = 0; i < m; i++){
    if(st.find({a[i], b[i]}) == st.end() && st.find({b[i], a[i]}) == st.end()){
      uf.connect(a[i], b[i]);
      deg[a[i]]++;
      deg[b[i]]++;
    }
  }
  for(int i = 0; i < k; i++){
    if(uf.fset(c[i]) == uf.fset(d[i])){
      deg[c[i]]++;
      deg[d[i]]++;
    }
  }
  for(int i = 1; i <= n; i++){
    cout << uf.sz[uf.fset(i)] - 1 - deg[i] << " ";
  }
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
using namespace std;
long long const mod = 1000000007;
long long mod_fact(int x){
    static vector<long long> fact = {1, 1};
    if(x < 0)return 0; //
    if(x < fact.size())return fact[x];
    for(int i = fact.size(); i <= x; i++){
        fact.push_back((fact[i-1] * i) % mod);
    }
    return fact[x];
}

long long mod_pow(long long a, long long b){
    long long res = 1;
    a %= mod;
    while(b > 0){
        if(b%2 == 0){
            a = (a * a) % mod;
            b /= 2;
        }else{
            res = (res * a) % mod;
            b--;
        }
    }
    return res;
}

long long mod_comb(long long a, long long b){
    if(b < 0 || a < b)return 0;
    long long c = (mod_fact(a) * mod_pow(mod_fact(a-b), mod-2)) % mod;
    return (c * mod_pow(mod_fact(b), mod-2)) % mod;
}

int main(void){
    long long h, w, a, b, ans = 0;
    cin >> h >> w >> a >> b;
    for(int i=0;;i++){
        int y = h-a-i;
        int x = b+1+i;
        //cout << y << " " << x << endl;
        if(y < 1 || x > w)break;
        ans += (mod_comb(y+x-2, x-1) * mod_comb(h-y+w-x, h-y))%mod;
        ans %= mod;
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#define ll long long int

using namespace std;

int main(int argc, char const* argv[])
{
	int n, l, t;
	cin >> n >> l >> t;
	ll *x = new ll[n];
	int *w = new int[n];
	for(int i = 0; i < n; i++){
			cin >> x[i] >> w[i];
			w[i] = 3 - 2 * w[i];
			x[i] = x[i] + w[i] * t;
	}

	int ini = 0;
	if(w[0] == 1){
			for(int i = 1; i < n; i++){
					if(w[i] == -1 && x[i] < x[0]){
							ini += (x[0] - x[i] + l - 1) / l;
					}
			}
			ini = ini % n;
	}else{
			x[0] += l;
			for(int i = 1; i < n; i++){
					if(w[i] == 1 && x[i] > x[0]){
							ini -= (x[i] - x[0] + l - 1) / l;
					}
			}
			x[0] -= l;
			ini = ini % n;
			if(ini < 0)ini += n;
	}
	int iniv = x[0] % l;
	if(iniv < 0)iniv += l;
	for(int i = 0; i < n; i++){
			x[i] = x[i] % l;
			if(x[i] < 0)x[i] += l;
	}
	sort(x, x + n);
	int flag = 0;
	for(int i = 0; i < n; i++){
			if(x[i] == iniv){
					if(w[0] == 1){
							flag = i;
							break;
					}else{
							if(i < n - 1 && x[i + 1] == iniv){
									continue;
							}
							flag = i;
							break;
					}
			}
	}
	for(int i = 0; i < n; i++){
			cout << x[(flag - ini + n + i) % n] << endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
using namespace std;
//using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long 
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >
//#define endl "\n"
 
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
const int mod=1e10+7;
double power(double a,int b)
{
    double ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a);
        }
        a=(a*a);
        b>>=1;
    }
    return ans;
}
bool add(int *a,int n,int m)
{
    repd(i,n-1,1)
    {
        if(a[i]!=(m-1))
        {
            int val=a[i]+1;
            repa(j,i,n-1) a[j]=val;
            return true;
        }
    }
    return false;
}
int32_t main()
{
    fast;

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

    int a[q+2],b[q+2],c[q+2],d[q+2];

    rep(i,q)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
        a[i]--;b[i]--;
    }

    int v[n];
    memset(v,0,sizeof(v));

    int ans=0;

    while(1)
    {
        int temp=0;
        rep(i,q)
        {
            if(v[b[i]]-v[a[i]] == c[i]) temp+=d[i];
        }
        ans=max(ans,temp);

        if(!add(v,n,m)) break;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652