akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#define _CRT_DISABLE_PERFCRIT_LOCKS

#include <iostream>
#include <cstdio>
#include <string>
#include <stdlib.h>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <math.h>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>	
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <thread>
#include <cassert>

using namespace std;

#define ll long long
#define ull unsigned long long
typedef int hv;
#define double long double
#define make(type, x) type x; cin>>x	
#define make2(type, x, y) type x, y; cin>>x>>y
#define make3(type, x, y, z) type x, y, z; cin>>x>>y>>z
#define make4(type, x, y, z, q) type x, y, z, q; cin>>x>>y>>z>>q
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
#define VI vector<int>
#define VVI vector<vector<int>>
#define PII pair<int, int>
#define PPII pair<PII, int>
#define M7 1000000007ll
#define M9 1000000009ll
#define MFFT 998244353ll 
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define outv(a) for(auto& x: a) cout << x << ' ';


void Solve() {
	make(int, n);
	makev(a, n);
	bool ok = true;
	for (int i = 1; ok && i < n; ++i) {
		if (a[i] < a[i - 1]) a[i]++;
		ok = a[i] >= a[i - 1];
	}
	cout << (ok ? "Yes" : "No");
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifdef _SUPER_DEFINE
	auto F1 = freopen("input.txt", "r", stdin);
	auto F2 = freopen("output.txt", "w", stdout);
	if (F1 == NULL || F2 == NULL) return 0;
	if (sizeof(int) != 8) cout << "NO LONG!!!\n";
	Solve();
	fflush(stdout);
	while (!cin.eof()) {
		string s = "_";
		do getline(cin, s);
		while (!cin.eof() && !s.empty());
		if (cin.eof()) break;
		FOR(2) cout << endl;
		Solve();
		fflush(stdout);
	}
	fclose(F1), fclose(F2);
#else
	Solve();
#endif
	return 0;
	}

Measured memory_bytes: 640
x = int(input())
import math
ans = 2
tmp = x
if x!=2:
    if x%2==0:
        tmp = x+1
    while True:
        ok = True
        for k in range(3, int(math.sqrt(tmp))+1):
            if tmp % k == 0:
                ok = False
                break
        if ok:
            ans = tmp
            break
        else:
            tmp+=2
print(ans)

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string N) {
    ll sum = 0;
    rep(i, N.length()) { sum += N[i] - '0'; }
    if (sum % 9 == 0) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    std::string N;
    std::cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3904
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    w, h, n = map(int, input().split())
    px = py = 0
    for _ in range(n):
        x, y, a = map(int, input().split())
        if a == 1:
            px = max(px, x)
        elif a == 2:
            w = min(w, x)
        elif a == 3:
            py = max(py, y)
        elif a == 4:
            h = min(h, y)

    print(max(0, w-px) * max(0, h-py))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<string>
#include<bitset>
using namespace std;


int main() {
	int X, Y, Z;
	cin >> X >> Y >> Z;


	cout << Z<<" "<<X<<" "<<Y << endl;
	return 0;

}

Measured memory_bytes: 3124
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    ll n;
    cin >> n;
    ll a = n % 10;
    if(a == 0 || a == 1 || a == 6 || a == 8){
        cout << "pon" << endl;
    }
    else if(a == 3){
        cout << "bon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
	long long a, b, t = 0, walk;
	long long town[100001];
	int i, n;
	
	scanf("%d %lld %lld", &n, &a, &b);
	
	for (i = 0; i < n; i++)	scanf("%lld", &town[i]);
	
	for (i = 0; i < n-1; i++){	
		walk = a*(town[i+1] - town[i]);
		
		if (walk < b) t += walk;
		else t += b;
	}
	
	printf("%lld\n", t);
	
	return 0;
}

Measured memory_bytes: 896
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	int mat[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin>>mat[i][j];
		}
	}
	int dp[n][3];
	dp[0][0] = mat[0][0];
	dp[0][1] = mat[0][1];
	dp[0][2] = mat[0][2];
	for(int i=1;i<n;i++){
		dp[i][0] = max(dp[i-1][1]+mat[i][0],dp[i-1][2]+mat[i][0]);
		dp[i][1] = max(dp[i-1][0]+mat[i][1],dp[i-1][2]+mat[i][1]);
		dp[i][2] = max(dp[i-1][1]+mat[i][2],dp[i-1][0]+mat[i][2]);
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	return 0;
}
//.........

Measured memory_bytes: 4992
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 10e16;
int inf = 10e8;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int _id(int a, int b, int N) {
    if (a < b) return N * a + b;
    return N * b + a;
}

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

    int E[N][N];
    REP(i, N) REP(j, N) {
        if (i == j) E[i][j] = 0;
        else E[i][j] = inf;
    }

    vector<int> P[N][N];
    REP(i, N - 1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        E[a][b] = 1;
        E[b][a] = 1;
        P[a][b].eb(_id(a, b, N));
        P[b][a].eb(_id(b, a, N));
    }

    REP(k, N) {
        REP(i, N){
            REP(j, N){
                if (E[i][j] > E[i][k] + E[k][j]){
                    E[i][j] = E[i][k] + E[k][j];

                    P[i][j].reserve(P[i][k].size() + P[k][j].size());
                    P[i][j].insert(P[i][j].end(), P[i][k].begin(), P[i][k].end());
                    P[i][j].insert(P[i][j].end(), P[k][j].begin(), P[k][j].end());
                }
            }
        }
    }

    int M;
    cin >> M;

    ll res = 1 << (N-1);

    int u[M], v[M];
    REP(i, M) {
        cin >> u[i] >> v[i];
        --u[i]; --v[i];
    }

    ll ans = 0;
    REP(i, 1 << M) {
        int p[N * N];
        REP(i, N * N) p[i] = 0;

        int s = 0;
        for(int j=i, k=0; j > 0; j >>= 1, ++k) {
            if(j & 1) {
                for (auto e: P[u[k]][v[k]]) {
                    p[e] |= 1;
                }
                ++s;
            }
        }

        int cnt = 0;
        REP(j, N * N) cnt += p[j];

        if (s % 2) ans -= pow(2, N - cnt -1);
        else ans += pow(2, N - cnt -1);
    }


    cout << fixed << setprecision(20) << ans << endl;

}


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

int main(){
  int64_t a, b, c;
  cin >> a>> b >> c;
  if (c - a - b >= 0 && 4 * a * b < (c - a - b) * (c - a - b)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;
string s;

pair<bool, string> check(string inits) {
  for (int i = 2; i < n; ++i) {
    if (inits[i - 1] == 'S') { // S say
      if (inits[i - 2] == 'S') {
        if (s[i - 1] == 'o') {
          inits.push_back('S');
        }
        else {
          inits.push_back('W');
        }
      }
      else {
        if (s[i - 1] == 'o') {
          inits.push_back('W');
        }
        else {
          inits.push_back('S');
        }
      }
    }
    else { // W say
      if (inits[i - 2] == 'S') {
        if (s[i - 1] == 'o') {
          inits.push_back('W');
        }
        else {
          inits.push_back('S');
        }
      }
      else {
        if (s[i - 1] == 'o') {
          inits.push_back('S');
        }
        else {
          inits.push_back('W');
        }
      }
    }
  }

  char fst;

  if (inits[n - 1] == 'S') { // S say
    if (inits[n - 2] == 'S') {
      if (s[n - 1] == 'o') {
        fst = 'S';
      }
      else {
        fst = 'W';
      }
    }
    else {
      if (s[n - 1] == 'o') {
        fst = 'W';
      }
      else {
        fst = 'S';
      }
    }
  }
  else { // W say
    if (inits[n - 2] == 'S') {
      if (s[n - 1] == 'o') {
        fst = 'W';
      }
      else {
        fst = 'S';
      }
    }
    else {
      if (s[n - 1] == 'o') {
        fst = 'S';
      }
      else {
        fst = 'W';
      }
    }
  }

  char snd;

  if (inits[0] == 'S') { // S say
    if (inits[n - 1] == 'S') {
      if (s[0] == 'o') {
        snd = 'S';
      }
      else {
        snd = 'W';
      }
    }
    else {
      if (s[0] == 'o') {
        snd = 'W';
      }
      else {
        snd = 'S';
      }
    }
  }
  else { // W say
    if (inits[n - 1] == 'S') {
      if (s[0] == 'o') {
        snd = 'W';
      }
      else {
        snd = 'S';
      }
    }
    else {
      if (s[0] == 'o') {
        snd = 'S';
      }
      else {
        snd = 'W';
      }
    }
  }

  if (fst == inits[0] && snd == inits[1]) {
    return make_pair(true, inits);
  }
  else {
    return make_pair(false, inits);
  }
}

int main(void) {
  // Here your code !
  scanf("%d", &n);
  cin >> s;

  string str_ss = "SS";
  auto pair_ss = check(str_ss);

  if (pair_ss.first) {
    cout << pair_ss.second << endl;
    return 0;
  }

  string str_sw = "SW";
  auto pair_sw = check(str_sw);

  if (pair_sw.first) {
    cout << pair_sw.second << endl;
    return 0;
  }

  string str_ws = "WS";
  auto pair_ws = check(str_ws);

  if (pair_ws.first) {
    cout << pair_ws.second << endl;
    return 0;
  }

  string str_ww = "WW";
  auto pair_ww = check(str_ww);

  if (pair_ww.first) {
    cout << pair_ww.second << endl;
    return 0;
  }

  printf("-1\n");

  return 0;
}


Measured memory_bytes: 972
import sys, heapq, bisect, math, fractions
from collections import deque

H, W = map(int, input().split())
A = [list(sys.stdin.readline().strip()) for _ in range(H)]

print("#" * (W + 2))
for i in range(H):
    res = "".join(A[i])
    print("#" + res + "#")
    # print(A[i])
print("#" * (W + 2))


Measured memory_bytes: 5108
#include <iostream>

using namespace std;

int main() {
    int n;  cin >> n;
    int *dp = new int[n+1];
    dp[0] = 1, dp[1] = 1;

    for (int i = 0; i + 2 <= n; i++)
        dp[i+2] = dp[i+1] + dp[i];

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#include <map>
#define fi(p) for(int i=0;i<(p);i++)
#define ce(d) cout<<d<<endl;
#define ll long long
#define sorts(c) sort((c).begin(),(c).end());

using namespace std;

void solve() {
	int n,k;
	int res = 0;
	cin >> n >> k;

	if (n >= 10 || k >= 10) {
		ce(-1);
	}
	else {
		ce(n*k);
	}
	
}



int main()
{

	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int inf = 1001001001;
const int m = 10100;
int main() {
  int n,ma,mb;
  cin >> n >> ma >> mb;
  vector<P> l,r;
  int ans = inf;
  rep(i,n){
    int a,b,c;
    cin >> a >> b >> c;
    a *= mb; b *= ma;
    if(a==b) ans = min(ans,c);
    if(a>b) l.emplace_back(a-b,c);
    if(a<b) r.emplace_back(b-a,c);
  }
  if(ans==inf&&(l.empty()||r.empty())){
    cout << -1 << endl;
    return 0;
  }
  vector<int> dpl(m,inf), dpr(m,inf);
  dpl[0] = dpr[0] = 0;
  rep(x,int(l.size())){
    int v = l[x].first, c = l[x].second;
    rep(i,m-v) dpl[m-1-i] = min(dpl[m-1-i],dpl[m-1-v-i]+c);
  }
  rep(x,int(r.size())){
    int v = r[x].first, c = r[x].second;
    rep(i,m-v) dpr[m-1-i] = min(dpr[m-1-i],dpr[m-1-v-i]+c);
  }
  rep(i,m) if(i!=0) ans = min(ans,dpl[i]+dpr[i]);
  if(ans==inf) ans = -1;
  cout << ans << endl;
}

Measured memory_bytes: 3680
N = int(input())
b_list = []
for _ in range(N):
  b_list.append(int(input())-1)

i = 0
cnt=0
keiyu_list = [0 for _ in range(N)]

while keiyu_list[i]==0:
  keiyu_list[i]=1
  i = b_list[i]
  cnt+=1
  if i == 1:
    cnt+1
    break
if i==1:
  print(cnt)
else:
  print(-1)

Measured memory_bytes: 7852
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int k, n;
	cin >> k >> n;
	vector<long long int> a(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
	}
	long long int d = k-a.at(n-1)+a.at(0);
	for(int i=1;i<n;i++){
		d = max(d,a.at(i)-a.at(i-1));
	}
	long long int ans = k-d;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
/**
 * Created by hiramekun at 20:54 on 2020-05-02.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll a, b, n;
    cin >> a >> b >> n;
    if (n >= b - 1) cout << (a * (b - 1)) / b << '\n';
    else cout << a * (n) / b - a * (n / b) << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 3636
<?php
  
fscanf(STDIN,"%d %d %d",$N,$M,$C);

$b_list = explode(" ",trim(fgets(STDIN)));
                  
$a_list = array();
for($i=0;$i<$N;$i++){
  $a_list[] = explode(" ",trim(fgets(STDIN)));
}

$sum = 0;
$count = 0;
foreach($a_list as $a){
  for($i=0;$i<$M;$i++){
    $sum += $a[$i]*$b_list[$i];
  }
  if($sum+$C>0){
  	 $count++;
  }
  $sum = 0;
}


echo $count."\n";
  

Measured memory_bytes: 4604
#include<iostream>
#include<string>
using namespace std;
string S[2];int k,n,x[4][10000000][2],sum,p[4]={1,10,100,1000},q[4];char T[15]="0123456789ixcm";
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>S[0]>>S[1];
		for(int h=0;h<2;h++){
			k=1;
			for(int l=0;l<S[h].size();l++){
				for(int j=0;j<14;j++){
					if(S[h][l]==T[j]){
						if(j/10){
							x[j-10][i][h]+=k;k=1;
						}
						else{
							k=j;
						}
					}
				}
			}
		}
		sum=0;
		for(int j=0;j<4;j++){sum+=(x[j][i][0]+x[j][i][1])*p[j];}
		for(int j=0;j<4;j++){q[j]=(sum/p[j])%10;}
		for(int j=3;j>=0;j--){if(q[j]>=2){cout<<q[j];}if(q[j]){cout<<T[10+j];}}cout<<endl;
	}
}

Measured memory_bytes: 7368
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1136&lang=jp

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct Point 
{
	int x,y;
	Point(int X, int Y) : x(X), y(Y) {}
};

struct Line 
{
	vector<Point> points;

	Line(int m)
	{	
		int x,y;
		rep(i,m)
		{
			cin >> x >> y;
			add(x,y);
		}
		origin_shift();
	}

	void add(int x, int y){
		points.push_back(Point(x,y));
	}

	void shift(int sx, int sy)
	{
		rep(i,points.size())
		{
			points[i].x -= sx;
			points[i].y -= sy;
		}
	}

	void origin_shift()
	{
		int sx = points[0].x;
		int sy = points[0].y;

		shift(sx,sy);
	}

	void reverse()
	{
		std::reverse(ALL(points));
		origin_shift();
	}

	void rotate()
	{
		rep(i,points.size())
		{
			swap(points[i].x, points[i].y);
			points[i].y *= -1;
		}
	}

	bool isSame(Line line)
	{
		vector<Point> p = line.points;
		
		if(p.size() != points.size()) { return false; }

		rep(i,p.size())
		{
			if(p[i].x != points[i].x || p[i].y != points[i].y){
				return false;
			}
		}
		return true;
	}
};

int main()
{
	int N,M;
	while(cin >> N && N)
	{
		int X,Y;

		cin >> M;
		Line line0(M);

		for(int nth=1; nth<=N; nth++)
		{
			cin >> M;
			Line lineN(M);

			bool is_same=false;

			rep(i,4)
			{
				if( line0.isSame(lineN) )
				{ 
					cout << nth << endl; 
					is_same = true; 
					break;
				}
				lineN.rotate();
			}

			if(is_same){ continue; }

			lineN.reverse();

			rep(i,4)
			{
				if( line0.isSame(lineN) )
				{ 
					cout << nth << endl;
					break;
				}
				lineN.rotate();
			}
		}
		cout << "+++++" << endl;
	}

	return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n;
    cin>>k>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dist[n]={0};
    for(int i=0;i<n;i++){
        if(i==0){
            dist[i]=a[i]+(k-a[n-1]);
        }
        else{
            dist[i]=a[i]-a[i-1];
        }
    }
    /*for(int i=0;i<n;i++)
        cout<<dist[i]<<" ";
    cout<<endl; */
    int pos=-1;
    int ma=INT_MIN;
    for(int i=0;i<n;i++){
        if(dist[i]>ma){
            ma=dist[i];
            pos=(i+1)%n;
        }
    }
    int c=1;
    int sum=0;
    while(c<n){
        sum+=dist[pos];
        pos=(pos+1)%n;
        c++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size()-1;i++)if(s[i]==s[i+1]||s[i]==s[i+2])
    {cout<<i+1<<" "<<i+2+(s[i]!=s[i+1])<<endl;return 0;}
    cout<<-1<<" "<<-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# AISing Programming Contest 2019：A - Bulletin Board


def main():
    N = int(raw_input().strip())
    H = int(raw_input().strip())
    W = int(raw_input().strip())

    print (N-H+1) * (N-W+1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,w;
int dp[100010];//价值为i的最小重量
signed main(){
	cin>>n>>w;
	for (int j=1;j<=1e5;j++)dp[j]=1e12;
    for (int i=1;i<=n;i++){
        int a,b;
        cin>>a>>b;
        for (int j=1e5;j>=b;j--)
        dp[j]=min(dp[j-b]+a,dp[j]);
    }
    for(int i=1e5;i>=0;i--)
		if(dp[i]<=w)return printf("%d\n",i),0;
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
dat = list(map(int, input().split()))
res = 0
m = -1
for i in range(1, n):
    if  dat[i-1] >= dat[i]:
        res +=1
    else:
        m = max(m, res)
        res = 0
m = max(m, res)
print(m)

Measured memory_bytes: 63984
n, y = map(int, input().split())
r = (y % 5000) // 1000
if n < r:
    print(-1, -1, -1)
    exit()
for no in range(r, n+1, 5):
    hifu = n - no
    if hifu*5000 <= y - no*1000 <= hifu*10000:
        hi = (hifu * 10000 - y + no*1000) // 5000
        fu = (y - no*1000 - hifu * 5000) // 5000
        print(fu, hi, no)
        exit()
print(-1, -1, -1)

Measured memory_bytes: 3064
import scala.io.Source.stdin

object Main extends App {
  val m = new Array[Int](4)
  stdin.getLines.map(_.split(",")).foreach { x =>
    x(1) match {
      case "A" => m(0) += 1
      case "B" => m(1) += 1
      case "AB" => m(2) += 1
      case "O" => m(3) += 1
    }
  }
  for(i<-0 to 3)
    println(m(i))
}

Measured memory_bytes: 43800
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s == "RRR")
    cout << 3 << endl;
  else if (s[1] == 'R' && (s[0] == 'R' || s[2] == 'R'))
    cout << 2 << endl;
  else if (s[0] == 'R' || s[1] == 'R' || s[2] == 'R')
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
 int n;
 cin>>n;
 vector<ll> a(n);
 for(int i=0;i<n;i++)cin>>a[i];
 multiset<ll> s;
 s.insert(0);s.insert(0);s.insert(0);
 ll ans=1;
 for(int i=0;i<n;i++){
        ll t=s.count(a[i]);
        if(t==0){
            cout<<0<<endl;
            return 0;
        }
        (ans*=t)%=mod;
        s.erase(s.find(a[i]));
        s.insert(a[i]+1);
 }
  cout<<ans<<endl;
}



Measured memory_bytes: 1024
s = input()
k = int(input())

l = "abcdefghijklmnopqrstuvwxyz"
li = []
res = []
for i in l:
    for index,j in enumerate(s):
        if j==i:
            li.append(s[index:])
    else:
        if len(li) > 5:
            break

#print(li)

li.sort()

for i in range(1,6):
    for j in li:
        try:
            #print(s[:i])
            res.append(j[:i])
            #print(res)
        except:
            pass
else:
    res = list(set(res))
    res.sort()
        
    print(res[k-1])
    # print(res)


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

using namespace std;


bool solve(vector<string> &v)
{

    //condition 1
    int n = v.size();

    for(int i = 0;i<n-1;++i)
    {
        if(v[i].back() != v[i+1].front())
        {
            return false;
        }
    }
    // Conditions 2
    for(int i =0;i<n;++i)
    {
        for(int j = i+1; j<n;++j)
        {
            if(v[i] == v[j])
                return false;
        }
    }
    return true;
}
int main()

{
    int n;
    cin >> n;
    string s;
    vector<string > v;

    while(n--)
    {
        cin >> s;
        v.push_back(s);

    }

    if(solve(v))
        cout << "Yes";
    else
        cout << "No";

}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
sortA = sorted(A, reverse=True)
C = Counter(sortA)
for k in C.keys():
    C[k] = C[k] * 2    
sort_ai = sorted(C.keys(), reverse=True)
ii = 0
ans = 0
for i  in range(N):
    tmp = sort_ai[ii]
    ans += tmp
    C[tmp] -= 1
    if C[tmp] == 0:
        ii += 1
print(ans-sort_ai[0])


Measured memory_bytes: 127944
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int temp=0,m=n;
  while(m){
    temp+=m%10;
    m/=10;
  }
  if(n%temp==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  int p[4]={0,1,0,-1},q[4]={1,0,-1,0};
  int a[32][32],w,h,t,m,n;
  int *fx,*fy,*tx,*ty;
  memset(a,-1,sizeof(a));
  while(cin>>w>>h&&w+h){
    for(i=1;i<h+1;i++){
      string s;
      cin>>s;
      for(j=1;j<w+1;j++){
	if(s[j-1]=='X')
	  a[j][i]=-3;
	else if(s[j-1]=='.')
	  a[j][i]=-2;
	else if(s[j-1]=='#')
	  a[j][i]=-1;
	else if(s[j-1]=='E')
	  a[j][i]=0;
	else if(s[j-1]=='N')
	  a[j][i]=1;
	else if(s[j-1]=='W')
	  a[j][i]=2;
	else if(s[j-1]=='S')
	  a[j][i]=3;
      }
    }
    n=0;
    for(i=1;i<h+1;i++){
      for(j=1;j<w+1;j++){
	if(a[j][i]>=0)
	  n++;
      }
    }
    fx=new int[n];
    fy=new int[n];
    tx=new int[n];
    ty=new int[n];
    for(t=0;t<181&&n;t++){
      /*      
      for(i=1;i<h+1;i++){
	for(j=1;j<w+1;j++){
	  if(a[j][i]==-3)
	    printf("X");
	  else if(a[j][i]==-2)
	    printf(".");
	  else if(a[j][i]==-1)
	    printf("#");
	  else if(a[j][i]==0)
	    printf("E");
	  else if(a[j][i]==1)
	    printf("N");
	  else if(a[j][i]==2)
	    printf("W");
	  else if(a[j][i]==3)
	    printf("S");
	}
	cout<<endl;
      }
      cout<<endl;      
      */
      for(i=1;i<h+1;i++){
	for(j=1;j<w+1;j++){
	  if(a[j][i]>=0){
	    for(k=0;k<4;k++){
	      if(a[j+p[(k+a[j][i])%4]][i+q[(k+a[j][i])%4]]<-1)
		break;
	    }
	    if(k!=4)
	      a[j][i]=(k+a[j][i]+3)%4;	    
	  }
	}
      }
      m=0;
      for(i=1;i<h+1;i++){
	for(j=1;j<w+1;j++){
	  if(a[j][i]<-1){
	    for(k=1;k<5;k++){
	      if(a[j+p[k%4]][i+q[k%4]]>=0&&(k+1)%4==a[j+p[k%4]][i+q[k%4]])
		break;
	    }
	    if(k!=5){
	      fx[m]=j+p[k%4];
	      fy[m]=i+q[k%4];
	      tx[m]=j;
	      ty[m]=i;
	      m++;
	    }
	  }
	}
      }
      for(i=0;i<m;i++){
	if(a[tx[i]][ty[i]]==-3){
	  a[fx[i]][fy[i]]=-2;
	  n--;
	}else{
	  a[tx[i]][ty[i]]=a[fx[i]][fy[i]];
	  a[fx[i]][fy[i]]=-2;
	}
      }
    }
    delete[]fx;
    delete[]fy;
    delete[]tx;
    delete[]ty;
    if(t==181)
      cout<<"NA"<<endl;
    else
      cout<<t<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::cin;
using std::endl;

const int MOD = 1e9 + 7;
i64 mod_pow(i64 x, i64 n = MOD - 2) {
    i64 ret = 1;
    while(n) {
        if(n & 1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int main() {
    int n, x; scanf("%d%d", &n, &x); std::vector<int> a(n);
    for(int i = 0; i < n; i++) scanf("%d", &a[i]);
    sort(begin(a), end(a)); reverse(begin(a), end(a));

    std::vector<i64> inv(n + 1, 1);
    for(int i = 1; i <= n; i++) inv[i] = mod_pow(i);

    std::vector<std::vector<i64>> dp(n + 1, std::vector<i64>(x + 1, 0)); dp[0][x] = 1;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < dp[i + 1].size(); j++) {
            int nxt = j % a[i];
            int tmp = n - i;

            (dp[i + 1][j] += dp[i][j] * (tmp - 1) % MOD * inv[tmp] % MOD) %= MOD;
            (dp[i + 1][nxt] += dp[i][j] * inv[tmp]) %= MOD;
        }
    }
    i64 latte = 1, ans = 0;
    for(i64 i = 1; i <= n; i++) (latte *= i) %= MOD;
    for(i64 i = 0; i < dp[n].size(); i++) (ans += i * dp[n][i] % MOD * latte % MOD) %= MOD;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 158592
X,K,D=map(int,input().split())
if X<0:
  X=-X
A=X//D
if A>=K:
  print(X-K*D)
else:
  a=X-A*D
  b=X-(A+1)*D
  if (K-A)%2==0:
    print(abs(a))
  else:
    print(abs(b))

Measured memory_bytes: 9180
import sys

def solve(numbers):
    max = -sys.maxsize
    for i in range(0, len(numbers)):
        sum = 0
        for j in range(i, len(numbers)):
            sum += numbers[j]
            if sum > max:
                max = sum
    return max


while True:
    n = int(input())
    if n == 0:
        break
    numbers = []
    for i in range(0, n):
        numbers.append(int(input()))

    print(solve(numbers))

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


int A[200005];



int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>A[i];
    for(int i=n;i>=1;i-=2)
        cout<<A[i]<<' ';
    for(int i=1+n%2;i<=n;i+=2)
        cout<<A[i]<<' ';

}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

void add(int &x,int y){
    x = (x+y)%MOD;
    return;
}

signed main(){
    string s;int d;cin>>s>>d;
    int dp[SZ(s)+1][d][2];
    REP(i,SZ(s)+1)REP(j,d)REP(k,2)dp[i][j][k]=0;
    dp[0][0][0]=1;
    REP(i,SZ(s)){
        int z=s[i]-'0';
        REP(j,10)REP(k,d) add(dp[i+1][(j+k)%d][1],dp[i][k][1]);
        REP(j,z)REP(k,d) add(dp[i+1][(j+k)%d][1],dp[i][k][0]);
        REP(k,d) add(dp[i+1][(k+z)%d][0],dp[i][k][0]);
    }
    int ans=(dp[SZ(s)][0][0]+dp[SZ(s)][0][1]-1)%MOD;
    if(ans<0)ans+=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 15872
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cassert>
using namespace std;
 
typedef long long llint;

llint x, y;

void load() {
	cin >> x >> y;
}

void solve() {
	int sol = 0;
	while(x <= y) {
		x *= 2;
		sol++;
	}
	cout << sol << endl;
}

int main(void) {
	load();
	solve();
	return 0;
} 

Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n, m, v, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
# 累積和
def cumsum(l):
    """a[i] = sum(l[:i]) なるaを返す
    """
    c = 0
    a = [None] * (len(l)+1)
    for i,num in enumerate(l):
        a[i] = c
        c += num
    a[-1] = c
    return a

s = cumsum(a)

def sub(i):
    # a[i]がいけるかどうか
    if i>=n-p:
        return True
    if a[i] + m < a[-p]:
        return False
    v1 = a[i] + m
    ss = m * (i+p)
    tmps = (s[n-p+1] - s[i+1])
    ss += v1*(n-i-p) - tmps    
    r = ss >= m*v
    return r
l = 0
r = n-1
if sub(l):
    print(n)
else:
    while l<r-1:
        mm = (r+l)//2
        if sub(mm):
            r = mm
        else:
            l = mm
    print(n-1-l)

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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

int main()
{
  ll n,t; cin>>n>>t;
  vector<pair<ll, ll>> c(n);
  rep(i, n) {
    ll a,b; cin>>a>>b;
    c[i] = make_pair(a, b);
  }
  sort(c.begin(),c.end());

  vector<ll> dp1(t+10);
  vector<ll> dp2(t+10);
  rep(i, n) {
    ll a = c[i].first;
    ll b = c[i].second;
    for (int j=1; j<=t; j++) {
      dp2[j] = max(dp2[j], dp1[j-1] + b);
    }
    for (int j=t; j>=0; j--) {
      if (a <= j) {
        dp1[j] = max(dp1[j], dp1[j-a] + b);
      } else {
        dp1[j] = dp1[j];
      }
    }
  }
  cout << dp2[t] << endl;

  return 0;
}


Measured memory_bytes: 3728
let cnt = ref 0

let merge a l m r =
  let ai = Array.make (m - l + 1) max_int in
  for i = 0 to m - l - 1 do
    ai.(i) <- a.(l + i)
  done;
  let aj = Array.make (r - m + 1) max_int in
  for i = 0 to r - m - 1 do
    aj.(i) <- a.(m + i)
  done;
  let i = ref 0 in
  let j = ref 0 in
  for k = l to r - 1 do
    incr cnt;
    if ai.(!i) <= aj.(!j) then begin
      a.(k) <- ai.(!i);
      incr i;
    end else begin
      a.(k) <- aj.(!j);
      incr j;
    end
  done

let rec merge_sort a l r =
  if (l + 1) >= r then () else
  let m = (l + r) / 2 in
  merge_sort a l m;
  merge_sort a m r;
  merge a l m r

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  merge_sort a 0 n;
  print_int a.(0);
  for i = 1 to n - 1 do
    print_string " "; print_int a.(i);
  done;
  print_newline ();
  Printf.printf "%d\n" !cnt

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

int N,x;
int a[123456];
ll ans;

int main(){

cin>>N>>x;

for(int i=0; i<N; i++) scanf("%d",&a[i]);

for(int i=0; i<N-1; i++){
    if(a[i]+a[i+1]>x){
        ans+=a[i]+a[i+1]-x;
        if(x-a[i]>0) a[i+1]-=a[i]+a[i+1]-x;
        else a[i+1]=0;
    }
}

cout<<ans<<endl;

return 0;
 
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int N=4e5+5,mod=1e9+7;
ll dp[2][N],dis[2][N];
int n,m,s,t,a[N],b[N],c[N],tot,head[N],nex[N],to[N],wi[N];
void add(int u,int v,int w){to[++tot]=v;nex[tot]=head[u];head[u]=tot;wi[tot]=w;}
struct node
{
    int x;ll v;
    node(int x=0,ll v=0):x(x),v(v){}
    bool operator<(const node&o)const
    {
        return v>o.v;
    }
};
bool vis[N];
void solve(int u,int p)
{
    priority_queue<node>q;
    memset(vis,false,sizeof(vis));
    q.push(node(u,0));
    dis[p][u]=0;dp[p][u]=1;
    while(!q.empty())
    {
        int u=q.top().x;q.pop();
        if(vis[u]) continue;
        vis[u]=true;
        for(int i=head[u];i;i=nex[i])
        {
            int v=to[i];
            if(dis[p][v]>dis[p][u]+wi[i])
            {
                dis[p][v]=dis[p][u]+wi[i];
                dp[p][v]=dp[p][u];
                q.push(node(v,dis[p][v]));
            }
            else if(dis[p][v]==dis[p][u]+wi[i])
                (dp[p][v]+=dp[p][u])%=mod;
        }
    }
}
ll solve(int x,int y,int c)
{
    if(dis[0][x]+dis[1][y]+c>dis[0][t]) return 0;
    ll m1,m2;
    if(dis[0][t]&1) m1=m2=dis[0][t]/2+1;
    else m1=dis[0][t]/2,m2=m1+1;
    if(m1>dis[0][x]&&m2<=dis[0][x]+c)
        return dp[0][x]*dp[1][y]%mod;
    return 0;
}
ll solve(int x)
{
    if(dis[0][x]==dis[0][t]/2&&dis[1][x]==dis[0][t]/2) return dp[0][x]*dp[1][x]%mod;
    return 0;
}
int main()
{
    memset(dis,inf,sizeof(dis));
    scanf("%d%d",&n,&m);
    scanf("%d%d",&s,&t);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
        add(a[i],b[i],c[i]);add(b[i],a[i],c[i]);
    }
    solve(s,0);
    solve(t,1);
    ll ans=dp[0][t]*(dp[0][t]-1)%mod;
    for(int i=1;i<=m;i++)
    {
        ll res=solve(a[i],b[i],c[i]);
        res=res*(res-1)%mod;
        (ans-=res)%=mod;
        res=solve(b[i],a[i],c[i]);
        res=res*(res-1)%mod;
        (ans-=res)%=mod;
    }
    if(dis[0][t]%2==0)
    for(int i=1;i<=n;i++)
    {
        ll res=solve(i);
        res=res*(res-1)%mod;
        (ans-=res)%=mod;
    }
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 24276
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

#define MAX_N 200000

class UnionFind {
private:
  // 親と木の深さ
  int par[MAX_N];
  int rank[MAX_N];
  int s[MAX_N];
public:
  void init(int n);
  int find(int x);
  void unite(int x, int y);
  bool same(int x, int y);
};

// 要素数nで初期化
void UnionFind::init (int n) {
  for(int i=0; i<n; i++) {
    par[i] = i;
    rank[i] = 0;
    s[i] = 1;
  }
}

// 要素xの親を求める
int UnionFind::find(int x) {
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);
}

// xとyの属する集合を併合
void UnionFind::unite(int x, int y) {
  // xとyの親
  x = find(x);
  y = find(y);
  if(x == y) return;

  // yのほうが深さが深い　xの親はyの親
  if(rank[x] < rank[y]) {
    par[x] = y;
    s[y] = s[x] + s[y];
  }
  else {
    par[y] = x;
    s[x] = s[x] + s[y];
    if( rank[x] == rank[y] ) rank[x]++;
  }
}

// xとyが同じ集合に属するか
bool UnionFind::same(int x, int y) { return find(x) == find(y);}

UnionFind uf;
VI v[100010];
signed main(void)
{
	int n, m;
	cin >> n >> m;
	uf.init(n+1);
	REP(i, n) {
		int k;
		cin >> k;
		REP(j, k) {
			int l;
			cin >> l;
			v[l-1].PB(i);
		}
	}

	REP(i, m) {
		//cout << "i:" << i << endl;
		//for(int j: v[i]) cout << j << " "; cout << endl;
		REP(j, v[i].size()-1) {
			//cout << v[i][j] << " " << v[i][j+1] << endl;
			uf.unite(v[i][j], v[i][j+1]);
		}
		//REP(j, n) cout << uf.find(j) << " "; cout << endl;
	}
	REP(i, n-1) {
		//cout << uf.find(i) << " " << uf.find(i+1) << endl;
		if(!uf.same(i, i+1)) {cout << "NO" << endl; return 0;}
	}
	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 6272
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

//ll MOD = 1e9+7;

//inline ll Msum(ll x){return x;}
//template<typename... Rest>
//inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

//inline ll Mprod(ll x){return x;}
//template<typename... Rest>
//inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

//inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const ll MOD = 998244353;
const int MAXN = 3e3+3;

int n, S, a[MAXN];
ll z[MAXN];


int main(){
	scan(n, S);
	for(int i=0; i<n; i++) scan(a[i]);

	ll ans = 0;
	for(int i=0; i<n; i++){

		for(int s=S; s-a[i] >= 0; s--)
			z[s] = (z[s] + z[s-a[i]]) % MOD;
		if(a[i] <= S) z[a[i]] += i+1;
		ans = (ans + z[S])%MOD;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    int c=0,d=0,k=0,n,h,q,w,m,ans=0;
    string s,s2;
    cin >> n >> k >> q;
    VI a(q);
    VI b(n);

    rep(i,q){
        cin >> a[i];
    }
    rep(i,q){
        b[a[i]-1]++;
    }
    rep(i,n){
        if( q-b[i] < k){
            cout << "Yes" <<endl;
        }
        else cout << "No" <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;
 
class Main {
 
	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
 
		int A = stdIn.nextInt();

		int B;

		int C;

		B = A / 2 ;
		C = A % 2 ;
		
		if(C==1){
			System.out.println(B=B+1);
		}else{
			System.out.println(B);
		}
    }
}

Measured memory_bytes: 22740
from fractions import*
from collections import*
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
a,b = map(int,input().split())
c = Counter(prime_factorize(gcd(a,b)))
print(len(c.keys())+1)

Measured memory_bytes: 5048
#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''

#def sol(n,):    
    
def main():
    import sys
    input = sys.stdin.readline
    

    n = int(input())
    if n % 2 == 0:
        print(int(n/2))
    else:
        print(int(n//2+1))





if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {

    string S;
    cin >> S;

    // 左右反転
    reverse(ALL(S));
    for(int i = 0; i < 4; i++) {
        reverse(ALL(divide[i]));
    }

    bool can = true;
    for(int i = 0; i < S.size();) {
        bool can2 = false;
        for(int j = 0; j < 4; j++) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    cout << (can ? "YES" : "NO") << endl;




    // auto l = S.size()-1;
    // cout << l << endl;
    
    // while (l >= 0) {
    //     if (S.substr(l-4, 5) == "dream") {
    //         cout << l << S.substr(l-4, 5) << endl;
    //         l -= 5;
    //     }
    //     else if (S.substr(l-4, 5) == "erase") l -= 5;           
    //     else if (S.substr(l-6, 7) == "dreamer") l -= 7;           
    //     else if (S.substr(l-5, 6) == "eraser") l -= 6;           
    //     else {
    //         cout << l << endl;
    //         cout << "NO" << endl;
    //         return 0;
    //     }
    // }
    
    // cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
int main() {
	string str;
	cin >> str;
	for (size_t i = 1; i < str.size();++i) {
		if (str[i - 1] == 'A'&&str[i] == 'C') {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int k, min, max;
	int i;

	scanf("%d", &k);
	scanf("%d%d", &min, &max);

	for (i = min; i <= max; i++)
	{
		if (i % k == 0)
		{
			printf("OK");
			break;
		}
		else if(i == max)
		{
			printf("NG");
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
pair<int,int> P;
priority_queue<int,vector<int>,less<int>> pq;
int n,arr[101010];
bool cmp(int p,int q)
{
    return p>q?1:0;
}
bool check()
{
    for(int i=1;i<n;i++)
    {
        if(arr[i-1]==arr[i]) continue;
        if(arr[i-1]<arr[i]) arr[i]--;
        if(arr[i-1]>arr[i]) return 0;
    } return 1;
}
main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",arr+i);
    } arr[0]--;
    if(check()) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 640