akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc170/tasks/abc170_d>
 問題文============================================================
 D - Not Divisible
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<int> A(N); for(auto& in:A) cin >> in;
    sort(A.begin(),A.end());
    
    int MAX_N = 1000'000;
    vector<bool> used(MAX_N+1);
    map<int,int> mp;
    for(auto a:A) mp[a]++;
    for(int i = 0; i < N;i++){
        if(used[A[i]]) continue;
        if(mp[A[i]] == 1) res++;
        for(int j = 1; j*A[i] <= MAX_N;j++){
            used[A[i]*j] = true;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 13500
// C - Prison
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	int n, m, l, r;
	cin >> n >> m;
	int ll = 1, rr = n;
	for (int i = 0; i < m; i++) {
		cin >> l >> r;
		ll = max(ll, l);
		rr = min(rr, r);
	}
	cout << max(0, rr - ll + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
ave = 0
i = 0
for i in range(N):
    ave += a[i]
ave /= N
mini = 1000
mnum = 1000
for j in range(N):
    if mini > abs(a[j] - ave):
        mini = abs(a[j] - ave)
        mnum = j
print(mnum)

Measured memory_bytes: 3064
#include <stdio.h>

int M, N;
char S[2048], T[2048];

int memo[2048][2048][3];

int search(int sidx, int tidx, int status) {
	int answer = 0;
	int candidate;
	if (sidx >= M && tidx >= N) return 0;
	if (memo[sidx][tidx][status]) return ~memo[sidx][tidx][status];

	switch (status) {
		case 0: /* none */
			if (sidx < M) {
				candidate = search(sidx + 1, tidx, 0);
				if (candidate > answer) answer = candidate;
				if (S[sidx] == 'I') {
					candidate = search(sidx + 1, tidx, 1) + 1;
					if (candidate > answer) answer = candidate;
				}
			}
			if (tidx < N) {
				candidate = search(sidx, tidx + 1, 0);
				if (candidate > answer) answer = candidate;
				if (T[tidx] == 'I') {
					candidate = search(sidx, tidx + 1, 1) + 1;
					if (candidate > answer) answer = candidate;
				}
			}
			break;
		case 1: /* I */
			if (sidx < M && S[sidx] == 'O') {
				candidate = search(sidx + 1, tidx, 2) + 1;
				if (candidate > answer) answer = candidate;
			}
			if (tidx < N && T[tidx] == 'O') {
				candidate = search(sidx, tidx + 1, 2) + 1;
				if (candidate > answer) answer = candidate;
			}
			break;
		case 2: /* O */
			if (sidx < M && S[sidx] == 'I') {
				candidate = search(sidx + 1, tidx, 1) + 1;
				if (candidate > answer) answer = candidate;
			}
			if (tidx < N && T[tidx] == 'I') {
				candidate = search(sidx, tidx + 1, 1) + 1;
				if (candidate > answer) answer = candidate;
			}
			break;
	}

	return ~(memo[sidx][tidx][status] = ~answer);
}

int main(void) {
	int asumikana;
	if (scanf("%d%d", &M, &N) != 2) return 1;
	if (scanf("%2047s", S) != 1) return 1;
	if (scanf("%2047s", T) != 1) return 1;
	asumikana = search(0, 0, 0);
	printf("%d\n", asumikana - (asumikana % 2 == 0 && asumikana > 0));
	return 0;
}



Measured memory_bytes: 50184
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
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 T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        #define endl "\n"
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    REP(i, n) cin >> a[i] >> b[i];
    bool fin = true;
    REP(i, n) if (a[i] != b[i]) fin = false;
    if (fin) {
        cout << 0 << endl;
        return 0;
    }

    int mn = INF;
    REP(i, n) {
        if (a[i] > b[i]) {
            chmin(mn, b[i]);
        }
    }
    int ans = accumulate(ALL(a),0LL);
    ans -= mn;
    cout << ans << endl;
    return 0;
}



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

int n;

vector<string> ans;

void dfs(string s, char mx){
    if (s.size() == n){
        ans.push_back(s);
        return;
    }
    for(char c = 'a'; c <= mx; c++){
        dfs(s + c, (c == mx) ? (char)(mx + 1) : mx);
    }
}


int main(){
    cin >> n;
    dfs("", 'a');
    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 7796
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)
N=int(input())
A=list(map(int,input().split()))

L=[0,0]
for ai in A:
    L.append(gcd(L[-1],ai))
    #print(L)

R=[0,0]
for ai in A[::-1]:
    R.append(gcd(R[-1],ai))
    #print(R)

print(max(gcd(l,r) for l,r in zip(L,reversed(R))))


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

#define ll long long
#define mp make_pair
#define pb push_back

int n, m;
char s[105][105];
int f[105][105][205];
bool vis[105][105][205];

int F(int x, int y, int i) {
	if (x >= n || y >= m) return 1e9;
	int &ans = f[x][y][i];
	if (vis[x][y][i]) return ans;
	vis[x][y][i] = 1;
	ans = 1e9;
	int cur = 0;
	if (s[x][y] ^ i) {
		cur = 1; i ++;
	}
	if (x == n - 1 && y == m - 1) {
		ans = cur;
		return ans;
	}
	for (int ni = 0; ni <= i; ++ ni) {
		ans = min(ans, F(x + 1, y, ni));
		ans = min(ans, F(x, y + 1, ni));
	}
	ans += cur;
	// printf("F(%d %d %d) = %d\n", x, y, i, ans);
	return ans;
}

int main() {
	ios :: sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 0; i < n; ++ i) {
		cin >> s[i];
		for (int j = 0; j < m; ++ j) {
			if (s[i][j] == '#') s[i][j] = 1;
			else s[i][j] = 0;
		}
	}
	cout << F(0, 0, 0) << endl;
	return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for(int i = 1; i < n; ++i)
  {
    bool seen_L[26] = {};
    bool seen_R[26] = {};
    for(int l = 0; l < i; ++l)
    {
      seen_L[(int)(s[l] - 'a')] = true;
    }
    for(int r = i; r < n; ++r)
    {
      seen_R[(int)(s[r] - 'a')] = true;
    }
    int score = 0;
    for(int a = 0; a < 26; ++a)
    {
      score += (seen_L[a] & seen_R[a]);
    }
    ans = max(ans, score);
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3596
#!/usr/bin/env python3
import copy

N, K = list(map(int, input().split()))
a_list = list(map(int, input().split()))

a_list = sorted(a_list)


def judge(w_list, k):
    w_list = sorted(w_list)

    for i in range(len(w_list) - 1):
        w_list += [abs(w_list[i] - w_list[i + 1])]

    w_list = sorted(list(set(w_list)))

    if k in w_list:
        return True, w_list
    elif 1 in w_list:
        return True, w_list
    elif abs(w_list[0] - w_list[-1]) < K:
        return False, w_list
    elif k % 2 == 0 and 2 in w_list:
        return True, w_list
    else:
        ww_list = set([w + K for w in w_list])
        if ww_list & set(w_list):
            return True, w_list
        else:
            return False, w_list


w_list = a_list

while True:
    org_w_list = copy.copy(w_list)
    is_ok, w_list = judge(w_list, K)
    if is_ok:
        break
    else:
        if abs(w_list[0] - w_list[-1]) < K:
            break
        if w_list == org_w_list:
            break

ans = "POSSIBLE" if is_ok else "IMPOSSIBLE"

print(ans)


Measured memory_bytes: 20756
N=int(input())
data=[]
for i in range(N-1):
  tmp=input().split(' ')
  data.append(tmp)
for i in range(N-1):
  time=0
  for j in range(N-1-i):
    k=j+i
    if time<=int(data[k][1]):
      time=int(data[k][1])+int(data[k][0])
    else:
      num=time%int(data[k][2])
      if num==0:
        time=time-num+int(data[k][0])
      else:
        time=time-num+int(data[k][2])+int(data[k][0])
  print(time)
print(0)

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

using namespace std;

int main(){
  const double R = 3.14159265358979323846;
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  long double x, y;
  x = 30*h+0.5*m;
  y = 6*m;
  
  long double z;
  if(x >= y) z = x-y;
  else z = y-x;
  
  if(z>180) z = 360-z;
  long double ans1, ans2;
  
  
  
  long double t = cos(z*R/180);
  ans1 = a*a+b*b-2*a*b*t;

  //cout << ans1 << endl;
  ans2 = sqrt(ans1);
  cout << fixed << setprecision(12);
  cout << ans2 << endl;
}
   
   
  
  


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

using namespace std;

int main() {
    int a, b, k;
    vector<int> data;
    
    cin >> a >> b >> k;

    for (int i = 0; i < k; i++) {
        if (a + i <= b) {
            data.push_back(a + i);
        }
        if (b - i >= a) {
            data.push_back(b - i);
        }
    }

    sort(data.begin(), data.end());
    data.erase(unique(data.begin(), data.end()), data.end());
    
    for (int i = 0; i < data.size(); i++) {
        cout << data[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <bitset>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...)
#endif

#define TIMESTAMP(x) eprintf("["#x"] Time : %.3lf s.\n", clock()*1.0/CLOCKS_PER_SEC)
#define TIMESTAMPf(x,...) eprintf("[" x "] Time : %.3lf s.\n", __VA_ARGS__, clock()*1.0/CLOCKS_PER_SEC)

using namespace std;

#ifdef LOCAL
static struct __timestamper {
  string what;
  __timestamper(const char* what) : what(what){};
  __timestamper(const string& what) : what(what){};
  ~__timestamper(){
    TIMESTAMPf("%s", what.data());
	}
} __TIMESTAMPER("end");
#else 
struct __timestamper {};
#endif

typedef long long ll;
typedef long double ld;

const int MAXN = 200000;

vector<int> g[MAXN];
vector<bool> used;

int main() {
#ifdef LOCAL
  freopen("b.in", "r", stdin);
  freopen("b.out", "w", stdout);
#endif

  int n, m;
  while (scanf("%d%d", &n, &m) == 2) {
    for (int i = 0; i < n; i++) {
      g[i].clear();
    }
    for (int i = 0; i < m; i++) {
      int a, b;
      scanf("%d%d",&a, &b);
      --a, --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }

    used = vector<bool>(n);
    used[0] = 1;

    vector<int> p1, p2;
    p1.push_back(0);
    for (int i = 0; i < 2; i++) {
      int v = 0;
      while (true) {
        bool any = false;
        for (int u : g[v]) {
          if (!used[u]) {
            any = true;
            p1.push_back(u);
            v = u;
            used[v] = true;
            break;
          }
        }
        if (!any) break;
      }
      p1.swap(p2);
    }

    reverse(p2.begin(), p2.end());
    p2.insert(p2.end(), p1.begin(), p1.end());

    printf("%d\n", (int) p2.size());
    for (int i : p2) {
      printf("%d ", i + 1);
    }
    printf("\n");
  }
  return 0;
}


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

using namespace std;

const int MAX = 100000000;

// DP by recursive function ----

//int minEnergy(int h, const vector<int>& A, const vector<int>& B, vector<int>& memo) {
//    if (h <= 0) {
//        return 0;
//    }
//    if (memo[h] > 0) {
//        return memo[h];
//    }
//
//    int ret = MAX;
//    for (int i = 0; i < A.size(); ++i) {
//        int e_i = minEnergy(h - A[i], A, B, memo) + B[i];
//        ret = min(ret, e_i);
//    }
//    memo[h] = ret;
//    return ret;
//}
//
//void Main() {
//    int H, N;
//    cin >> H >> N;
//    vector<int> A(N, 0), B(N, 0);
//    for (int i = 0; i < N; ++i) {
//        cin >> A[i] >> B[i];
//    }
//
//    vector<int> memo(H + 1, -1);
//    int ans = minEnergy(H, A, B, memo);
//    cout << ans << endl;
//}

// DP by matrix ----

void Main() {
    int H, N;
    cin >> H >> N;
    vector<int> A(N, 0), B(N, 0);
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }

    vector<int> minEnergy(H + 1, -1);
    minEnergy[0] = 0;
    for (int h = 1; h <= H; ++h) {
        int temp = MAX;
        for (int i = 0; i < N; ++i) {
            if (h <= A[i]) {
                temp = min(temp, B[i]);
            }
            else {
                temp = min(temp, minEnergy[h - A[i]] + B[i]);
            }
        }
        minEnergy[h] = temp;
    }

    cout << minEnergy.back() << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	priority_queue<ll, vector<ll>, greater<ll>> plus;
	priority_queue<ll> minus;
	ll a;
	rep(i,N){
		cin>>a;
		if(a >= 0)plus.push(a);
		else minus.push(a);
	}
	ll ans;
	vector<pair<ll, ll>> sets;
	ll x,y;
	if(minus.size() > 0){
		x = minus.top();
		minus.pop();
	}else{
		x = plus.top();
		plus.pop();
	}
	while(plus.size() > 1){
		y = plus.top();
		plus.pop();
		sets.push_back(make_pair(x, y));
		ans = x-y;
		x = ans;
	}
	if(plus.size()>= 1){
		sets.push_back(make_pair(plus.top(), x));
		ans = plus.top() - x;
		x = ans;
	}
	while(!minus.empty()){
		y = minus.top();
		minus.pop();
		sets.push_back(make_pair(x, y));
		ans = x-y;
		x = ans;
	}
	cout<<ans<<endl;
	for(auto x: sets){
		cout<<x.first<<' '<<x.second<<endl;
	}
	return 0;
}

Measured memory_bytes: 7116
/*Infor {{{
 ******************************************************
 * > File Name: a.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018/7/21 12:08:36
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
const int MAXLEN = 100;
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
char S[MAXLEN + 1];
char T[MAXLEN + 1];
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  cins(S), cins(T);
  FOR(i, 0, strlen(S) - 1) {
    int t = i;
    bool ok = true;
    FOR(j, 0, strlen(T) - 1) {
      if (S[t] != T[j]) {
        ok = false;
        break;
      }
      t = (t + 1) % strlen(S);
    }
    if (ok) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <string>
#include <string.h>

using namespace std;

map<string,int> words;

int alltoupper(char *s){
  int i,l=strlen(s);
  for(i=0;i<l;i++){
    s[i] = tolower(s[i]);
  }
  //printf("%s\n", s);
}

int main(){
  char s[32];
  int max=0;
  string my;
  int maxlength=0;
  string self;
  while(scanf(" %s", s)!=EOF){
    alltoupper(s);
    string tmp(s);
    if(words.find(tmp) != words.end()){
      words[tmp]++;
      if(words[tmp] > max) max = words[tmp],my = tmp;
    }else{
      words.insert(pair<string,int>(tmp,1));
      if(maxlength < tmp.length()) maxlength = tmp.length(),self=tmp;
    }
  }
  
  printf("%s %s\n", my.c_str(), self.c_str());
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

// clang-format off
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>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec v = ivec(5);
    int idx = distance(v.begin(), min_element(all(v)));
    int mid = (n + v[idx] - 1) / v[idx];
    print(mid + 4);

    return 0;
}


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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N];

int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	int mx = 0, nd_mx = 0;
	for(int i=0; i<n; i++){
		cin >> a[i];
		if (a[i] >= mx){
			nd_mx = mx;
			mx = a[i];
		} else nd_mx = max(nd_mx, a[i]);
	}
	what_is(mx); what_is(nd_mx);
	for(int i=0; i<n; i++){
		if (a[i] == mx) cout << nd_mx << endl;
		else cout << mx << endl;
	}

	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll X;
  cin>>X;
  if(X>=30) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
from operator import itemgetter

n,m=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(m):
    x,y=map(int,input().split())
    l.append([x,y])

a.sort()
l.sort(key=itemgetter(1))
l.reverse()

c=0
for i in range(n):
    if a[i]<l[c][1]:
        a[i]=l[c][1]
        l[c][0]-=1
    else:
        break
    if l[c][0]==0:
        if c<m-1:
            c+=1
        else:
            break

print(sum(a))

Measured memory_bytes: 25672
n,k = map(int,input().split()) #n任 k種類
d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(int,input().split())))


sunuke =[0] * n
for i in range(k):
    #print("d[i]",d[i])
    for j in range(int(d[i])):
        temp = a[i][j] -1 
        sunuke[temp] += 1

#print(sunuke)
print(sunuke.count(0))



Measured memory_bytes: 9284
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  vector <int> adj[n];
  for(int i = 0;i<m;i++)
  {
    int t,r;
    cin>>t>>r;
    t--;r--;
    adj[t].push_back(r);
    adj[r].push_back(t);
  }
  vector <bool> vis(n,false);
  int ans = 0;
  for(int i =0;i<n;i++)
  {
    queue <int> q;
    int c =1;
    if(vis[i] == false)
    	q.push(i);
    while(!q.empty())
    {
      int t = q.front();
      q.pop();
      vis[t] = true;
      for(int a : adj[t])
      {
        if(vis[a] == false)
        {
          vis[a] = true;
          q.push(a);
          c++;
        }
        
      }
    }
    ans = max(ans,c);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 14860
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
  	string s;
  cin>>n>>k>>s;
  	if(s[k-1]>=65&&s[k-1]<=90)
      	s[k-1]=s[k-1]+32;
  cout<<s;
}

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

int main() {
	int a, b;
	
	cin >> a >> b;
	if ((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
	return 0;
}

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

int main(void){
  string strings[3] = {};
  char card;
  cin >> strings[0] >> strings[1] >> strings[2];
  int turn = 0;
  while(true){
    if(strings[turn] == ""){
      cout << char('A' + turn) << endl;
      return 0;
    }
    card = strings[turn].front();
    strings[turn].erase(strings[turn].begin());
    turn = card - 'a';
  }
  return 0;
}


Measured memory_bytes: 256
class ModComb
  def initialize(max, mod)
    @mod = mod
    @fac = Array.new(max + 1)
    @finv = Array.new(max + 1)
    @inv = Array.new(max + 1)
    @fac[0] = @fac[1] = 1
    @finv[0] = @finv[1] = 1
    @inv[1] = 1
    (2..max).each do |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
    end
  end

  def comb(n, k)
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end
end

require 'prime'
N, M = gets.split.map(&:to_i)

if M == 1
  puts 1
  exit 0
end

MOD = 10 ** 9 + 7
prime_division = M.prime_division
max_k = prime_division.max_by { |_, e| e }[1]
comb = ModComb.new(N + max_k, MOD)
ans = 1
prime_division.each do |n, e|
  ans = (ans * comb.comb(N + e - 1, e)) % MOD
end
puts ans

Measured memory_bytes: 4348
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5010;
const int mod=1e9+7;
ll dp[N][N];
char s[N];
int n;
int main()
{
	//freopen("H:\\c++1\\in.txt","r",stdin);
	//freopen("H:\\c++1\\out.txt","w",stdout);
	dp[0][0]=1;
	scanf("%d",&n);
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=0;i<=n;i++)
	for(int j=0;j<=n;j++){
		if(j==0)dp[i+1][j]=(dp[i][j]+dp[i+1][j])%mod;
		else{
			dp[i+1][j-1]=(dp[i][j]*2+dp[i+1][j-1])%mod;
		}
		dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%mod;
	}
	printf("%lld\n",dp[n][len]);
	return 0;
}


Measured memory_bytes: 195968
use num_integer::Integer;
use whiteread::parse_line;

fn main() {
    let (n, start): (usize, usize) = parse_line().unwrap();
    let mut x: Vec<usize> = parse_line().unwrap();
    let mut ans = 0;

    x.push(start);
    x.sort();
    for i in 0..n {
        ans = ans.gcd(&(x[i + 1] - x[i]));
    }
    println!("{}", ans);
}


Measured memory_bytes: 3952
#include<stdio.h>
int main(void)
{
    char s[4];
    scanf("%s",s);
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;

  if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    char c; cin>>c;
    if(c=='a' or c=='i' or c=='u' or c=='e' or c=='o') cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc135/submissions/8198071
//何度も提出しても通らなかったため、原文ママで提出させていただきました……
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long
#define INF 10e9
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll int, ll int>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

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

int N;
int a[110000];
int b[110000]; 
ll int ans;

int main () {
  cin >> N;

  Rep(i, N+1) cin >> a[i];
  Rep(i, N) cin >> b[i];

  ans = 0;

  Rep(i, N) {
    if (a[i] >= b[i]) {
      ans += b[i];
    } else {
      int diff = b[i] - a[i];
      
      if (diff > a[i+1]) {
        ans += a[i] + a[i+1];
        a[i+1] = 0;
      } else {
        ans += a[i] + diff;
        a[i+1] -= diff;
      }
    }
  }

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


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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll c[N], l[N], r[N], sz[N], cnt = 0, n, par[N];
vector<ll> node[N], node2[N], g[N];
void dfs(ll u, ll v){
        cnt++;
        node2[c[u]].push_back(u);
        l[u] = cnt;
        sz[u] = 1;
        par[u] = v;
        for (auto j : node[u]){
                if (j == v) continue;
                dfs(j, u);
                sz[u] += sz[j];
        }
        r[u] = cnt;
}
bool ok(ll u, ll v){
        return l[u] <= l[v] && r[u] >= r[v];
}
void build(ll u){
        vector<ll> now;
        now.push_back(0);
        g[0].clear();
        for (auto j : node2[u]){
                while (!ok(now.back(), j)){
                        now.pop_back();
                }
                g[now.back()].push_back(j);
                now.push_back(j);
        }
}
ll fuck = 0;
void tot(ll u){
        ll i = 0, sum = 0;
        for (auto j : node[u]){
                if (j == par[u]) continue;
                ll res = 0;
                while (i < g[u].size() && ok(j, g[u][i])){
                        res -= sz[g[u][i]];
                        i++;
                }
                res += sz[j];
                sum += res * (res + 1)/2;
        }
        fuck += sum;
        for (auto j : g[u]){
                tot(j);
        }
}
ll ans(ll u){
        build(u);
        fuck = 0;
        tot(0);
        return n * (n + 1) / 2 - fuck;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        //freopen("VLJUM.INP", "r", stdin);
        //freopen("VLJUM.OUT", "w", stdout);
        cin >> n;
        for (int i = 1; i <= n; i++){
                cin >> c[i];
        }
        for (int i = 1; i < n; i++){
                ll u, v;
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        node[0].push_back(1);
        dfs(0, 0);
        for (int i = 1; i <= n; i++){
                if (node2[i].size() > 0) cout << ans(i) << endl;
                else cout << 0 << endl;
        }
}


Measured memory_bytes: 52472
#include<iostream>
using namespace std;
int main()
{
	int n,k,temp=1,i;
	cin>>n>>k;
	for(i=1;i<=n;i++)
	{
		if(temp>k)
		{
			temp+=k;
		}
		else temp*=2;
	}
	cout<<temp<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

ll Xor(ll x){
    if(x%2==0){
        return Xor(x-1)^x;
    }
    x++;
    x/=2;
    if(x%2==0)return 0;
    else return 1;
}

int main() {
    ll A,B;
    cin>>A>>B;
    ll ans=Xor(B);
    if(A==0){cout<<ans<<endl;}
    else{
        ans=ans^Xor(A-1);
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3636
w, h, n = map(int, input().split())
square_info = [list(map(int, input().split())) for _ in range(n)]

min_x = 0
max_x = w
min_y = 0
max_y = h

for i in range(n):
    if square_info[i][2] == 1:
        min_x = max(min_x, square_info[i][0])
    elif square_info[i][2] == 2:
        max_x = min(max_x, square_info[i][0])
    elif square_info[i][2] == 3:
        min_y = max(min_y, square_info[i][1])
    else:
        max_y = min(max_y, square_info[i][1])

if max_x <= min_x or max_y <= min_y:
    print(0)
else:
    print((max_x - min_x)*(max_y - min_y))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1e18;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

struct Segmenttree {
	static const int N = 1 << 18;
	vector<ll>seg;
	vector<ll>idx;
	void st(ll p, ll v) {
		p += N - 1;
		seg[p] = v;
		idx[p] = p - N + 1;
		while (p > 0) {
			p = (p - 1) / 2;
			seg[p] = min(seg[2 * p + 1], seg[2 * p + 2]);
			if (seg[2 * p + 1] > seg[2 * p + 2])idx[p] = idx[2 * p + 2];
			else if (seg[2 * p + 1] < seg[2 * p + 2])idx[p] = idx[2 * p + 1];
			else idx[p] = min(idx[2 * p + 1], idx[2 * p + 2]);
		}
	}
	pair<ll, ll> query(ll l, ll r, ll a, ll b, ll k) {
		if (r <= a || b <= l)return { inf,inf };
		if (l <= a && b <= r)return { seg[k],idx[k] };
		ll m = (a + b) / 2;
		auto p1 = query(l, r, a, m, 2 * k + 1);
		auto p2 = query(l, r, m, b, 2 * k + 2);
		if (p1.first < p2.first) return p1;
		else if (p1.first > p2.first)return p2;
		else return { p1.first,min(p1.second,p2.second) };
	}

	void init() {
		seg.resize(2 * N);
		idx.resize(2 * N);
		for (int i = 0; i < 2 * N; i++)seg[i] = inf;
	}
	//[l,r]
	ll get(int l, int r) {
		return query(l, r + 1, 0, N, 0).first;
	}
	ll getidx(int l, int r) {
		return query(l, r + 1, 0, N, 0).second;
	}
	pair<ll, ll>getp(int l, int r) {
		return query(l, r + 1, 0, N, 0);
	}
};

int N, M;
string S;

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

	cin >> N >> M >> S;
	Segmenttree seg = Segmenttree();
	seg.init();
	seg.st(N, 0);
	for (int i = N-1; i >= 0;i--) {
		if (S[i] == '1')continue;
		ll mi = seg.get(i+1,i+M);
		if (mi > 1e15)continue;
		seg.st(i,mi+1);
	}

	
	if (seg.get(0, 0) > 1e15) {
		puts(-1);
		return 0;
	}

	ll cur = seg.get(0, 0);
	int pre = 0;
	for (int i = 1; i <= N; i++) {
		if (seg.get(i, i) == cur - 1) {
			cout << i - pre << " ";
			pre = i;
			cur--;
		}
	}
	cout << endl;

	return 0;
} 

Measured memory_bytes: 8912
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int X = scan.nextInt();
        if (360 % X == 0) {
            System.out.println(360/X);
            return;
        }
        int lcm = lcm(360, X);
        System.out.println(lcm/X);
    }
    private int gcd(int x, int y) {
        if (y == 0) {
            return x;
        }
        return gcd(y, x % y);
    }
    private int lcm(int x, int y) {
        int gcd = gcd(x, y);
        return x / gcd * y;
    }
}


Measured memory_bytes: 35824
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
#define lb lower_bound
#define ub upper_bound
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};
//cin.tie(0);ios::sync_with_stdio(false);

signed main()
{
    ll k, mn = 2, mx = 2;
    cin >> k;
    vector<ll> v(k);
    rep(i, k) cin >> v[i];

    reverse(all(v));

    rep(i, k)
    {
        if (mn/v[i]==mx/v[i] && mn%v[i]!=0)//
        {
            cout<<-1<<endl;
            return 0;
        }
        mn += (v[i] - mn % v[i])%v[i];

        mx=(mx/v[i])*v[i] +v[i]-1;

        //cout<<mn<<" "<<mx<<endl;
    }

    cout << mn << " " << mx << endl;
}

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

using namespace std;

int main()
{
    int a,b,c,k;
    cin >> a >> b >> c;
    cin >> k;
    int ma=max(a,max(b,c));
    cout << (a+b+c-ma+(ma<<k)) <<endl;
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++)
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
int n;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ap = min(x, y)*c * 2;
	int cp = max(x, y)*c * 2;
	if (x > y) {
		ap += a*(x - y);
	}
	else if (x < y) {
		ap += b*(y - x);
	}
	int bp = a*x + b*y;
	cout << min(min(ap, bp),cp) << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tl3;



const int BIG_NUM = 1e9;
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;



int main() {
	int d, t, s;
	cin >> d >> t >> s;
	if (d <= s * t) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
typedef long long int ll;
typedef vector<int> vint;
const ll LINF = 9000000000000000000ll;
const int INF = 2000000000;
const ll MOD = 1e9+7;

int main() {
    int L, R;
    cin >> L >> R;
    int mn = INF;
    R = min(R, L + 2019*2);
    for (ll i = L; i < R+1; ++i) {
        for (ll j = i+1; j < R+1; ++j) {
            mn = min(mn, (int)(i*j % 2019));
        }
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,i,j,r=0;;
    scanf("%d",&a);
    for(i=1;i<=a;i++)
    {
        int count=0;
        if(i%2!=0)
        {
            for(j=1;j<=i;j++)
            {
                if(i%j==0) count++;
            }
            if(count==8) r++;
        }
    }
    printf("%d\n",r);
    return 0;
}


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

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    vector<char> vec = {'0','1','2','3','4','5','6','7','8','9'};
    int ans = 0;
    for(int i = 0; i < 10;i++){
        for(int j = 0; j < 10;j++){
            for(int k = 0; k < 10;k++){
                int cont = 0;
                for(int l = 0; l < N;l++){
                    if(cont == 0 && vec[i] == S[l])cont++;
                    else if(cont == 1 && vec[j] == S[l])cont++;
                    else if(cont == 2 && vec[k] == S[l])cont++;
                }
                if(cont == 3){ans++;}
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        long N = scanner.nextLong();
        long max =1;
        for(long i =1; i*i<=N; i++){
            if(N%i == 0){
                max = i;
            }
        }   
        
        long answer = max + (N/max) -2;
        
        System.out.println(answer);
        
    }
}


Measured memory_bytes: 23252
while True:
    n=int(input())
    if 0<=n<1000:
    
        if n==0:
            break
        else:
            sum=0
            
            sum+=(1000-n)//500
            sum+=(1000-n)%500//100
            sum+=(1000-n)%500%100//50
            sum+=(1000-n)%500%100%50//10
            sum+=(1000-n)%500%100%50%10//5
            sum+=(1000-n)%500%100%50%10%5//1
            
    
            
     
    print(int(sum))
    


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

typedef pair<int,int> p;

#define MAX_N 100000

int par[MAX_N];
int rankT[MAX_N];
int num=MAX_N;

// initialize for n items
void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rankT[i] = 0;
  }
}

// get the root of the tree of x
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

// unite the sets of x and y
void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y)
    return;

  // 連結成分がひとつ減る
  num = num - 1;
  if(rankT[x] < rankT[y]){
    par[x] = y;
  } else {
    par[x] = y;
    if(rankT[x] == rankT[y])
      rankT[x]++;
  }
}

bool same(int x,int y){
  return find(x) == find(y);
}

p edge[MAX_N];

int main(void){
  int N,M;
  cin >> N >> M;
  num = N;
  init(N);
  for(int i=0;i<M;i++){
    int x,y,z;
    cin >> x >> y >> z;
    edge[i] = make_pair(x,y);
  }
  for(int i=0;i<M;i++){
    //cout << i << endl;
    unite(edge[i].first,edge[i].second);
  }
  cout << num << endl;
  return 0;
}


Measured memory_bytes: 1792
public class
Main
{
  public void
  run (
    java.util.Scanner sc
    )
  {
    int[ ] a;
    int i, j;

    a = new int[ sc.nextInt ( ) ];
    for ( i = 0; i < a.length; ++i )
      a[ i ] = sc.nextInt ( );

    printArray ( a );
    for ( i = 1; i < a.length; ++i )
    {
      final int t = a[ i ];
      for ( j = i - 1; j >= 0; --j )
      {
        if ( t < a[ j ] )
        {
          a[ j + 1 ] = a[ j ];
          a[ j ] = t;
        }
      }

      printArray ( a );
    }
  }

  private void
  printArray (
    int[ ] a
    )
  {
    int i;

    for ( i = 0; i < a.length; ++i )
    {
      System.out.print ( a[ i ] );
      if ( i + 1 < a.length )
        System.out.print ( " " );
      else
        System.out.println ( );
    }
  }

  public static void
  main (
    String[ ] args
    )
  {
    ( new Main ( ) ).run ( new java.util.Scanner ( System.in ) );
  }
}

Measured memory_bytes: 25840
s = input()

def kaibun(word):
  return word[::-1] == word
ans_1 = str(kaibun(s))

n = len(s)
k_2 = int(((n-1) / 2))
w = [c  for c in s]
ww = []

for j in w:
  ww.append(j)
  if len(ww) == k_2:
    break
ans_2 = str(kaibun(ww))

w_2 = [d for d in s]
www = w_2[::-1]
n_2 = len(www)
k_3 = int(n_2-(n_2+3) / 2 +1)
ww_2 = []
for m in www:
  ww_2.append(m)
  if len(ww_2) == k_3:
    break
ans_3 = str(kaibun(ww_2))

if ans_1 == 'True' and ans_2 == 'True' and ans_3 == 'True':
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
N,n = map(int,input().split())
 
 
N = [int(input()) for i in range(N)]
N = sorted(N)
Q = []
for i in range(len(N)-n+1):
	max1 = int(*N[i+n-1:i+n])
	min1 = int(*N[i:i+1])
	Q.append(max1 - min1)
print(min(Q))

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	sort(all(S));
	auto r = unique(all(S));
	S.erase(r, S.end());
	S.push_back('a');
	int ab = 0;
	for (char i = 'a'; i <= 'z'; ++i) {
		if (S[ab] != i) {
			dunk(i);
			return 0;
		}
		ab++;
	}
	puts("None");
	return 0;
}

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

int main() {
  int n;

  cin >> n;

  vector<int> ans(n + 1);

  for (int i = 0; i < n - 1; i++) {
    int tmp;
    cin >> tmp;
    ans[tmp]++;
  }

  for (int i = 1; i < n + 1; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 4044
#include<cstdio>
using namespace std;
#define N 300500
int st[N],v[N],s[N],n,l;
long long as;
int main()
{
	scanf("%d%d",&n,&l);as=l*2;
	for(int i=1;i<=n;i++)scanf("%d",&s[i]);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=1;i<=n;i++)
	{
		as+=(1ll*v[i]+l*2-1)/(l*2)*l*2;
		v[i]=(v[i]-1)%(l*2)+1;
		if(v[i]<=s[i]*2)st[i]++;
		if(v[i]<=(l-s[i])*2)st[i]+=2;
	}
	int l1=0,l2=0;
	for(int i=1;i<n;i++)
	if((st[i]&2)&&l1)l1--,as-=l*2,l2+=st[i]&1;
	else if((st[i]&2)&&l2)l1++,l2--,l2+=st[i]&1;
	else l1+=st[i]&1;
	if((st[n]&2))as-=l*2;
	printf("%lld\n",as);
}

Measured memory_bytes: 3712
def CountingSort(A, B, k):
    C = [0] * (k+1)
    for i in range(k):
        C[i] = 0
    #C[i] に i の出現数を記録する 
    for j in range(0,n):
        C[A[j]]+=1
    #print("C ",j,C[:100])
    #C[i] に i 以下の数の出現数を記録する
    for i in range(1,k+1):
        C[i] = C[i] + C[i-1]
    #print("C' ",j,C[:100])
    for j in range(n-1,-1,-1):
        B[C[A[j]]] = A[j]
        C[A[j]]-=1
        #print(j,A[j],C[A[j]],B[C[A[j]]],B,C)

n = int(input())
A = list(map(int,input().split()))
B = [0] * (n+1)
CountingSort(A,B,100000)
print(' '.join(map(str,B[1:])))



Measured memory_bytes: 247660