akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N = 1e5 + 10;
vector<int> tree[N];
int depth[2][N]; // depth[0] is for chaser. depth[1]  is for runaway.
void dfs(int node, int from, int val, int player){
    depth[player][node] = val;
    for(auto it: tree[node]){
        if(it != from) dfs(it, node, val + 1, player);
    }
    return ;
}
int main(){
    int n, x, y, u, v;
    scanf("%d %d %d", &n, &u, &v);
    for(int i = 1; i < n; i++){
        scanf("%d %d", &x, &y);
        tree[x].push_back(y);
        tree[y].push_back(x);
    }
    dfs(u, 0, 0, 0);
    dfs(v, 0, 0, 1);
    int ma = 0;
    for(int i = 1; i <= n; i++){
        if(depth[0][i] < depth[1][i] && depth[1][i] > ma) ma = depth[1][i];
    }
    printf("%d", ma - 1);

}


Measured memory_bytes: 11648
#include<iostream>
#include<algorithm>
#include<stdbool.h>
#include<math.h>
#include<vector>
using namespace std;
typedef long long ll;
int dp[110] = { 0 };
bool flag[110] = { false };
int main(void) {
	int n;
	cin >> n;
	vector<int>s(n);
	for (int i = 0;i < n;i++)cin >> s[i];
	dp[0] = 0;
	int num = 0;
	for (int i = 1;i <= n;i++) {
		dp[i] = dp[i - 1];
		for (int j = 0;j < n;j++) {
			if (((dp[i-1] + s[j]) % 10 != 0)&&!flag[j]) {
				if (dp[i] < dp[i - 1] + s[j]) {
					dp[i] = dp[i - 1] + s[j];
					num = j;
				}
			}
		}
		flag[num] = true;
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++)

int main() {
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);
    vector<int> x(M);
    vector<int> y(M);
    vector<int> c(M);
    int mina = 100000;
    int minb = 100000;
    rep(i, 0, A) {
        cin >> a[i];
        mina = min(a[i], mina);
    }
    rep(i, 0, B) {
        cin >> b[i];
        minb = min(b[i], minb);
    }
    int ans = minb+mina;
    
    rep(i, 0, M) {
        cin >> x[i] >> y[i] >> c[i];
        ans = min(a[x[i]-1]+b[y[i]-1]-c[i], ans);
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char s[5];
int main(void)
{
	scanf("%4s",s);
	printf("%s\n",strcmp(s,"YAKI")==0?"Yes":"No");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  int64_t D;
  cin>>N>>D;
  int ans=0;
  for(int i=0;i<N;i++){
    int64_t X,Y;
    cin>>X>>Y;
    if(X*X+Y*Y<=D*D){
      ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

const int MAX_V = 1000;
const int MAX_E = 2000;

struct edge{ll from,to,cost;};
edge es[MAX_E];

ll d[MAX_V];
int V,E;

bool shortest_path(int s){
	REP(i,V) d[i]=INFL;

	d[s]=0;
	REP(i,V){
		REP(j,E){
			edge e=es[j];
			if(d[e.to]>d[e.from]+e.cost){
				d[e.to]=d[e.from]+e.cost;
				if(i==V-1 && e.to==V-1) return false;
			}
		}
	}
	return true;
}
int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	int from,to,cost;
	cin>>V>>E;
	REP(i,E){
		cin>>from>>to>>cost;
		es[i].from=from-1;
		es[i].to=to-1;
		es[i].cost=-cost;
	}
	if(!shortest_path(0)) print("inf");
	else print(-d[V-1]);
	
	return 0;
}




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

typedef long long ll;
const int N = 1e5 + 10;

int n, a[N], b[N];

int main() {
    ll sumA = 0, sumB = 0;
    cin >> n;

    int best = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        sumA += a[i];
        sumB += b[i];
        if (min(a[i], b[i]) > min(a[best], b[best]))
            best = i;
    }
    auto ans = min(sumA, sumB);

    vector<int> pick;
    for (int i = 0; i < n; i++) if (i != best) {
        pick.emplace_back(a[i]); 
        pick.emplace_back(b[i]);
    }
    sort(pick.begin(), pick.end());

    ll sum = 0;
    for (int i = 0; i < int(pick.size()); i++) {
        sum += pick[i];
        if (i+1 == n-2) ans = min(ans, sum + a[best] + b[best]); 
        if (i+1 == n) ans = min(ans, sum);
    }

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


Measured memory_bytes: 2168
#include <stdio.h>
#include <math.h>

#define PI 3.1415926535

int theta_add(int theta, int theta_sum);
double theta_convert(int theta);

int main(void)
{
    double x = 0, y = 0;
    int r, theta;
    int theta_sum = 0;
    double theta_rad;

    while (1) {
        scanf("%d,%d", &r, &theta);

        if (r == 0 && theta == 0) {
            break;
        }

        theta_rad = theta_convert(theta_sum);

        x += r * cos(theta_rad);
        y += r * sin(theta_rad);

        theta_sum = theta_add(theta, theta_sum);
    }

    printf("%d\n%d\n", (int)x, (int)y);

    return 0;
}

int theta_add(int theta, int theta_sum)
{
    theta_sum += theta;
    if (theta_sum > 180) {
        theta_sum -= 360;
    } else if (theta_sum < -180) {
        theta_sum += 360;
    }

    return theta_sum;
}

double theta_convert(int theta)
{
    return (90 - theta) * PI / 180;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
const int MOD = (int)1e9 + 7;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> s(N);
  int sum = 0;
  REP(i, N) {
    cin >> s[i];
    sum += s[i];
  }
  s.push_back(0);
  sort(ALL(s));

  REP(i, N) {
    if ((sum - s[i]) % 10 != 0) {
      cout << sum - s[i] << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}


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

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

    int n, m;
    cin >> n >> m;
    if (n == m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

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

template <typename T, typename U>
T ipow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b;
    return n % 2 == 0 ? mypow(b * b, n / 2) : mypow(b, n - 1) * b;
}

template <typename T, typename U>
T mpow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    return n % 2 == 0 ? mypow(b * b % MOD, n / 2) : mypow(b, n - 1) * b % MOD;
}

int main() {
    string S;
    cin >> S;
    int y = stoi(S.substr(0, 4));
    int m = stoi(S.substr(5, 2));
    // int d = stoi(S.substr(8, 2));

    cout << (y < 2019 || (y == 2019 && m <= 4) ? "Heisei" : "TBD") << endl;
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
  i64 a, b;
  cin >> a >> b;
  if (a >= b) {
    REP(i, a) {
      cout << b;
    }
  } else {
    REP(i, b) {
      cout << a;
    }
  }
  cout << endl;

  return 0;
}

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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-10;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 200001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int cnt[maxn];
int possible[maxn];

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n, m;
    cin >> n >> m;
    possible[1] = 1;
    fill(cnt + 1, cnt + 1 + n, 1);
    for (int i = 1; i <= m; ++i) {
        int x, y;
        cin >> x >> y;
        cnt[x]--;
        cnt[y]++;
        if (possible[x]) {
            possible[y] = 1;
            if (!cnt[x]) {
                possible[x] = 0;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        ans += possible[i];
    }
    cout<<ans;
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



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

int main(){
  ll n, m;
  cin >> n >> m;
  ll sum = 0;
  vector<int> a(m);
  rep(i,m){
  	cin >> a[i];
  	sum += a[i];
  }
  ll ans = n - sum;
  if(ans >= 0) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<int> g[n];
	rep (i, m) {
	  int a, b;
	  cin >> a >> b;
	  g[a - 1].push_back(b - 1);
	  g[b - 1].push_back(a - 1);
	} 
	vector<int> res(n, -1);
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
	  int p = q.front();
	  q.pop();
	  for (auto e: g[p]) {
		if (res[e] != -1) continue;
		res[e] = p;
		q.push(e);
	  }
	}
	cout << "Yes" << endl;
	rep (i, n - 1) cout << res[i + 1] + 1 << endl;
    
    return 0;
}


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

int main() {
  int A, B, C, a, b, c;
  long long K;
  cin >> A >> B >> C >> K;
  if(K%2==0) cout << A-B << endl;
  else cout << B-A << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())
a = [list(input()) for i in range(H)]

dp=[[0]*(W) for i in range(H)]

flagH = 0
flagW = 0

for i in range(H):
  if a[i][0]=="." and flagH==0:
    dp[i][0]=1
  else:
    dp[i][0]=0
    flagH=1

for j in range(W):
  if a[0][j]=="." and flagW==0:
    dp[0][j]=1
  else:
    dp[0][j]=0
    flagW=1

for i in range(1,H):
  for j in range(1,W):
    if a[i][j]==".":
      dp[i][j]=dp[i-1][j]+dp[i][j-1]

print(dp[H-1][W-1]%1000000007)

Measured memory_bytes: 165284
#include <iostream>
#include <cmath>
#include <cstdio>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;

int main(){
    ll h,w;
    cin>>h>>w;
    string s;
    ll a,b;
    for(ll i=0;i<h;++i){
        for(ll j=0;j<w;++j){
            cin>>s;
            if(s=="snuke"){
                a=j;
                b=i+1;
                break;
            }
        }
    }
    cout<<(char)('A'+a)<<b<<endl;
}

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

int main(){
int w,money,flag,i;
    while(1){
        money = 1150;
        cin >> w;
        if(w == -1){
            break;
        }
        if(w <= 10){
            cout << 4280 - money << endl;
        }
        else {
            w -= 10;
            flag = 9;
            for(i=w;i>=1;i--){
                flag++;
                if(flag < 20){
                    money += 125;
                }
                else if(flag < 30){
                    money += 140;
                }
                else if(flag < 40){
                    money += 160;
                }
                else if(flag >= 40){
                    money += 160;
                }
            }
            cout << 4280 - money << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
*/

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

set<int>date[55],maps[55];

void init(){
  rep(i,55){
    date[i].clear();
    maps[i].clear();
  }
}

void input(int n){
  rep(i,n){
    int m;
    cin>>m;
    rep(j,m){
      int x;
      cin>>x;
      date[x].insert(i);
    }
  }
}

void solve(int n){
  init();
  input(n);
  set<int> se;
  rep(i,31){
    se.clear();
    for(auto x : date[i]){
      se.insert(x);
      for(auto y : maps[x])se.insert(y);
    }
    if(se.size()==n){cout<<i<<endl;return ;}
    for(auto x : date[i])maps[x]=se;
  }
  cout<<-1<<endl;
  return ;
}

int main(){
  int n;
  while(cin>>n,n){
    solve(n);
  }
  return 0;
}



Measured memory_bytes: 3260
from collections import defaultdict
N = int(input())
A = list(map(int, input().split(' ')))
B1 = defaultdict(int)
B0 = defaultdict(int)
for x in A:
    bA = format(x,"b").zfill(60)
    for i in range(60):
        if bA[i] == "1":
            B1[i] += 1
        elif bA[i] == "0":
            B0[i] += 1
ans = 0
for i in range(60):
    ans = (ans + 2**(59-i)*B1[i]*B0[i]) % (10**9+7)
print(ans)

Measured memory_bytes: 138992
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	string result="No";
	set<char> S;
	REP(i,3) {
      char T;
	  cin >> T;
	  S.insert(T);
    }
	if(SIZE(S)==3)
      result="Yes";

	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


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



int main()
{
long A,B,C,K;
cin>>A>>B>>C>>K;
if(K<=A){cout<<K<<endl;}
if(K>A&&K<=A+B){cout<<A<<endl;}
if(K>A+B){cout<<A-(K-A-B)<<endl;}

}


Measured memory_bytes: 3648
from collections import deque
deq = deque()
def check(f1, f2, f3):
    return (f2[0] - f1[0]) * (f3[1] - f2[1]) >= (f2[1] - f1[1]) * (f3[0] - f2[0])
def f(f1, x):
    return f1[0]*x + f1[1]

# add f_i(x) = a*x + b
def add_line(a, b):
    f1 = (a, b)
    while len(deq) >= 2 and check(deq[-2], deq[-1], f1):
        deq.pop()
    deq.append(f1)

# min f_i(x)
def query(x):
    while len(deq) >= 2 and f(deq[0], x) >= f(deq[1], x):
        deq.popleft()
    return f(deq[0], x)

N,C=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*N
dp[-1]=0
add_line(2*h[-1],h[-1]**2)
for i in range(N-2,-1,-1):
    dp[i]=h[i]**2+C+query(-h[i])
    add_line(2*h[i],h[i]**2+dp[i])

print(dp[0])

Measured memory_bytes: 83532
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static final FS sc = new FS();  // 封装输入类
    static final PrintWriter pw = new PrintWriter(System.out);

    public static void main(String[] args) {
        int n = sc.nextInt(), ans = 0;
        long d = sc.nextLong();
        long target = d * d;
        for (int i = 0;i < n;i++) {
            long x = sc.nextLong(), y = sc.nextLong();
            if (x * x + y * y <= target) {
                ans++;
            }
        }
        pw.println(ans);
        pw.flush();
    }

    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");
        String next() {
            while(!st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch(Exception ignored) {}
            }
            return st.nextToken();
        }
        int[] nextArray(int n) {
            int[] a = new int[n];
            for(int i = 0;i < n;i++) {
                a[i] = nextInt();
            }
            return a;
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 55284
def main():
    n = int(input())
    a = list(map(int, input().split(" ")))
    cur_max = a[0]
    total = 0
    for ai in a:
        if ai<cur_max:
            total+=cur_max - ai
        else:
            cur_max = ai
    print(total)

if __name__=="__main__":
    main()


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

int main() {
  int x,y;
  int a[101];
  while(cin >> x >> y) {
    for(int i=0; i<101; i++) a[i]=0;
    a[x]++;
    a[y]++;
    while(1) {
      cin >> x >> y;
      if(x==0 && y==0) break;
      a[x]++;
      a[y]++;
    }
    int cnt=0;
    for(int i=3; i<=100; i++) {
      if(a[i]%2==1) cnt++;
    }
    if(a[1]%2==0 || a[2]%2==0 || cnt>0) cout << "NG" << endl;
    else cout << "OK" << endl;
  }
  return 0;
}


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

using namespace std;

const int N = 100100;

int Pref[N];

int main()
{
    int n, m;   cin >> n >> m;

    for(int i = 0; i < m; i++)
    {
        int L, R;   scanf("%d%d", &L, &R);

        Pref[L]++;
        Pref[R + 1]--;
    }

    for(int i = 1; i <= n; i++) Pref[i] += Pref[i - 1];

    int Ans = 0;

    for(int i = 1; i <= n; i++)
        if(Pref[i] == m)
            Ans++;

    cout << Ans << endl;
}


Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d, g;
    cin >> d >> g;
    vector<pair<int, int>> pcs(d); cin >> pcs;
    prints(pcs);
    int sum = 0;
    for(int i = 0; i < d; i++){
        sum += pcs[i].first;
    }
    int in = sum, out = 0;
    while(out + 1 < in){
        int piv = (in + out) / 2;
        int maxi = 0;
        for(int bits = 0; bits < (1 << d); bits++){
            int solve = 0, point = 0;
            vector<int> others;
            for(int i = 0; i < d; i++){
                if(bits >> i & 1){
                    solve += pcs[i].first;
                    point += (i + 1) * 100 * pcs[i].first + pcs[i].second;
                    if(piv == 2){ printde(piv, i, point); }
                }else{
                    others.push_back(i);
                }
            }
            if(piv < solve){
                continue;
            }
            int rem = piv - solve;
            reverse(others.begin(), others.end());
            for(auto& idx : others){
                int s2 = min(rem, pcs[idx].first);
                point += (idx + 1) * 100 * s2;
                rem -= s2;
                if(rem == 0){ break; }
            }
            maxi = max(maxi, point);
        }
        if(piv == 2){ printde(piv, maxi); }
        if(maxi >= g){
            in = piv;
        }else{
            out = piv;
        }
    }
    cout << in << '\n';
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n,d;
int p[1252];

int main(){
  scanf("%d%d",&n,&d);
  REP(i,n)scanf("%d",p+i);
  int ans = 0;
  REP(i,n)ans+=max(0,p[i]-d);
  if(ans==0)puts("kusoge");
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1216
import java.util.*;

class Main{
    public static void main(String[] args){
	final Scanner sc=new Scanner(System.in);
	int a=sc.nextInt();
	int b=sc.nextInt();
	int c=sc.nextInt();
	if(a<b){
	    if(b<c) System.out.println(a+" "+b+" "+c);
	    else{ System.out.println(a+" "+c+" "+b);
	    }
	}
	else if(b<c){
	    if(c<a) System.out.println(b+" "+c+" "+a);
	    else{ System.out.println(b+" "+a+" "+c);
	    }
	}
	else if(c<a){
	    if(a<b) System.out.println(c+" "+a+" "+b);
	    else{ System.out.println(c+" "+b+" "+a);
	    }
	}
    }
}

Measured memory_bytes: 17352
if __name__ == "__main__":
    N = int(input())
    doublet_count = 0
    is_doublet = False

    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            doublet_count += 1
        else:
            doublet_count = 0
        if doublet_count == 3:
            is_doublet = True
            break
    
    
    if is_doublet:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

#define MAX_N 1000010
ll inv[MAX_N+10],fac[MAX_N+10],ifac[MAX_N+10];

void setComb(){
  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<MAX_N;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;

    inv[i]=(inv[i]+MOD)%MOD;
    fac[i]=(fac[i]+MOD)%MOD;
    ifac[i]=(ifac[i]+MOD)%MOD;
  }
  return;
}

ll comb(ll n,ll k){
  if(n<k||n<0||k<0) return 0;
  else return ((fac[n]*ifac[k]%MOD*ifac[n-k]%MOD+MOD)%MOD);
}

ll hcomb(ll n,ll r){// this size is really ok??
  if(n==0&&r==0) return 1;
  else if(n<0||r<0) return 0;
  else return comb(n+r-1,r);
}

ll mod_pow(ll x,ll n){
  x%=MOD;
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%MOD;
    x=x*x%MOD;
    n>>=1;
  }
  return res;
}

void add(ll &a,ll b){
  a=(a+b)%MOD;
}

void mul(ll &a,ll b){
  a%=MOD;b%=MOD;
  a=a*b%MOD;
}


int main(){
  ll B,W;
  cin>>B>>W;

  setComb();

  vector<ll> invtwo(B+W+1,0);
  invtwo[0]=1;
  rep(i,B+W){
    invtwo[i+1]=invtwo[i];
    mul(invtwo[i+1],inv[2]);
  }

  vector<ll> lsum(B+W+2,0),rsum(B+W+2,0);
  vector<ll> sum(B+W+2,0);
  for(ll i=1;i<B+W;i++){
    if(B<=i){
      ll val=comb(i-1,B-1);
      mul(val,invtwo[i]);
      add(sum[i],val);

      if(B>1){
        ll res=comb(i-2,B-2);
        mul(res,invtwo[i]);
        add(rsum[i-1],res);
        add(rsum[0],MOD-res);
      }
    }

    if(W<=i){
      ll val=comb(i-1,W-1);
      mul(val,invtwo[i]);
      add(lsum[i+1],val);
      add(lsum[B+W+1],MOD-val);

      ll res=comb(i-2,W-1);
      mul(res,invtwo[i]);
      add(rsum[i-1],res);
      add(rsum[0],MOD-res);
    }
  }

  for(int i=1;i<=B+W;i++) add(lsum[i],lsum[i-1]);
  for(int i=B+W;i>=1;i--) add(rsum[i],rsum[i+1]);
  for(int i=1;i<=B+W;i++){
    add(sum[i],lsum[i]);
    add(sum[i],rsum[i]);
  }

  for(int i=1;i<=B+W;i++) cout<<sum[i]<<endl;

  return 0;
}


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

int main(){
    long long n, m;
    cin >> n >> m;
    long long h[n];
    long long c[n];

    long long a[m];
    long long b[m];
    for (long long i = 0; i < n; ++i){
        cin >> h[i];
        c[i] = 1;
    }

    for (long long i = 0; i < m; ++i){
        cin >> a[i] >> b[i];
        if (h[a[i]-1] < h[b[i]-1]){
            c[a[i]-1] = 0;
        }
        if (h[b[i]-1] < h[a[i]-1]){
            c[b[i]-1] = 0;
        }
        if (h[b[i]-1] == h[a[i]-1]){
            c[a[i]-1] = 0;
            c[b[i]-1] = 0;
        }
    }

    long long count = 0;
    for (long long i = 0; i < n; ++i){
        count+=c[i];
    }
    cout << count << endl;
}


Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) cout << 'x';
	cout << endl;
}

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


using namespace std;
using ll = long long;


const int sz = 5e5 + 10;
int bt[sz], res[sz];
vector<vector<pair<int, int>>> qr(sz);
int n, q;

void upd(int p, int x) {
    for(int i = p; i <= n; i += i & -i) {
        bt[i] += x;
    }
}

int query(int p) {
    int res = 0;
    for(int i = p; i; i -= i & -i) {
        res += bt[i];
    }
    return res;
}



int main() {
    cin >> n >> q;
    vector<int> a(n);
    unordered_map<int, int> mp;
    for(auto& x : a) cin >> x;
    for(int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--, r--;
        qr[r].push_back({l, i});
    }
    for(int i = 0; i < n; i++) {
        if(mp.find(a[i]) != mp.end()) {
            upd(mp[a[i]]+1, -1);
        }
        upd(i+1, 1);
        mp[a[i]] = i;
        for(auto x : qr[i]) {
            int l = x.first+1;
            int r = i+1;
            int idx = x.second;
            if(l == 1) {
                res[idx] = query(r);
            } else{
                res[idx] = query(r) - query(l-1);
            }
        }
    }
    for(int i = 0; i < q ; i++) {
        cout << res[i] << "\n";
    }
    return 0;
}



Measured memory_bytes: 50900
#include <algorithm>
#include <cstdio>

using namespace std ;

const int N=2e5+10 ;

int a[N] , b[N] , c[N] ;
int n , m ;

int main ()
{
    int i , j ;
    scanf("%d",&n);
    for ( i=1 ; i<=n ; i++ ) scanf("%d",a+i);
    for ( i=n ; i>=1 ; i-- )
        if ( 2*i<=n )
        {
            int sum=0 ;
            for ( j=2 ; j*i<=n ; j++ ) sum+=c[i*j];
            c[i]=(sum&1)^a[i];
            if ( c[i] ) b[++m]=i;
        }
        else if ( a[i] ) b[++m]=i,c[i]=1;
    printf("%d\n",m);
    for ( i=1 ; i<=m ; i++ ) printf("%d ",b[i]); 
    return 0 ;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vll = V<ll>;
using VVll = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

const double PI = acos(-1);
const ll MOD = 1e9+7;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

ll calc(ll x) {
    if (x == 1) {
        return 1;
    } else {
        return calc(x/2)*2 + 1;
    }
}

int main() {
    ll h;
    cin >> h;
    std::cout << calc(h) << '\n';

    return 0;
}


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

main(){
  int a,b,c;
  vector<int> A(3);
  for(int i= 0;i<3;i++){
    cin>>A[i];
  }
  sort(A.begin(), A.end());
  cout<<A[2]*10+A[1] +A[0] <<endl;
  return 0;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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 SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const Int INF = (1<<20);
int n;
bool di(vector<int> a,vector<int> b){
     for(int s=0;s<n;s++){
            if(a[s]!=b[s]) return false;
        }
        return true;
}
int main(){
    cin >> n;
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    vector<int> p(n),q(n);
    for(auto &i:p) cin >> i;
    for(auto &i:q) cin >> i;
    bool pf = true;
    bool qf = true;
    int ap,aq;
    int t = 0;
    do {
        t++;
        if(pf){
            if(di(p,v)){pf = false;ap = t;}
        }
        if(qf){
            if(di(q,v)){qf= false;aq = t;}
        }
    } while( next_permutation(v.begin(),v.end()));     // 次の順列を生成
    cout << abs(ap-aq) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>
#include <memory.h>

using namespace std;

typedef long long ll;

const ll MAXV = 1e4, INF = 1e5;
ll V;
// firstに頂点、secondにコストとした隣接リスト
vector<pair<ll, ll> > graph[MAXV];
ll used[MAXV]; // 頂点がTに含まれているかどうか

// 最小全域木のコストを返す
ll prim(){
  ll res = 0;
  // firstにmincost、secondにid
  priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > > PQ;
  PQ.push(make_pair(0, 0));
  while(!PQ.empty()){
    pair<ll, ll> p = PQ.top(); PQ.pop();
    ll v = p.second;
    if(used[v] == true) continue;
    used[v] = true;
    res += p.first;
    for(int i=0;i<graph[v].size();i++){
      ll to = graph[v][i].first;
      ll cost = graph[v][i].second;
      if(!used[to]) PQ.push(make_pair(cost, to));
    }
  }
  return res;
}

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll E; cin >> V >> E;
  for(int i=0;i<E;i++){
    int s, t, w; cin >> s >> t >> w;
    graph[s].push_back(make_pair(t, w));
    graph[t].push_back(make_pair(s, w));
  }
  cout << prim() << endl;
}


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

#define ran 101101

struct modular_arithmetic{
	int mod;

	modular_arithmetic(){
		mod = 1000000007;
	}
	//No specific settings.
	int add(int x,int y){return (x+=y)<mod?x:x-mod;}
	int sub(int x,int y){return (x-=y)>=0?x:x+mod;}
	int mul(int x,int y){return (int)((long long int)x*y%mod);}
	int pw(int base, int p) {
		int res = 1, mu = base%mod;
		for(;p>0;p/=2) {
			if (p&1) res = mul(res, mu);
			mu = mul(mu, mu);
		}
		return res;
	}
};
modular_arithmetic ma;

int n, k;
int f[ran];

int main() {
	scanf("%d%d", &n, &k);
	int ans = 0;
	for(int i=k;i>0;i--) {
		f[i] = ma.pw(k/i, n);
		for(int j=i+i;j<=k;j+=i)
			f[i] = ma.sub(f[i], f[j]);
		ans = ma.add(ans, ma.mul(f[i], i));
	}
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 4136
<?php
  list($n, $x, $m) = explode(" ", trim(fgets(STDIN)));

//$ans=0;
//for ($i=1; $i<=$n; $i++) {
//  $ans+=$x;
//  $x=$x*$x%$m;
//}
//echo $ans;
//exit;
  $check=[];
  $check[$x]=1;
  $sum=[0,$x];
  $sround=0;
  $ground=0;
  for($i=2;$i<=$n;$i++){
    $x=$x*$x%$m;
    if(isset($check[$x])){
      $sround=$check[$x];
      $ground=$i-1;
      break;
    }else{
      $check[$x]=$i;
      $sum[$i]=$sum[$i-1]+$x;
    }
  }

  if($sround==0){
    echo $sum[$n];
    exit;
  }

  $xround=$sum[$ground]-$sum[$sround-1];

//echo $sround." ".$ground." ".$xround." ".$sum[$ground]." ".$sum[$sround-1]." ".$x.PHP_EOL;

  $ans=$sum[$sround-1];
  $ans+=$xround*intdiv($n-$sround+1, $ground-$sround+1);

  $remain=($n-$sround+1)%($ground-$sround+1);

  for($i=0;$i<$remain;$i++){
    $ans+=$x;
    $x=$x*$x%$m;
  }

  echo $ans;

Measured memory_bytes: 22044
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	int a[n+1];
	long long b[n+1];
	for(int i=1;i<=n;i++)
	{
		scanf("%d %lld",&a[i],&b[i]);
	}
	long long v[n+1][m+1];
	for(int i=0;i<m+1;i++)
	{
		for(int t=0;t<n+1;t++)
		{
			v[t][i]=0;
		}
	}
	for(int i=1;i<=n;i++)//从第一件开始循环（这样可以保证每件商品只是用一次） 
	{
		for(int j=1;j<=m;j++)//从最小容纳量开始循环 
		{
			if(j<a[i])
			{
				v[i][j]=v[i-1][j];
			}
			else
			{
				v[i][j]=max(v[i-1][j],v[i-1][j-a[i]]+b[i]);
			}
		}
	}
	long long big=v[0][m];
	for(int i=1;i<=n;i++)
	{
		if(big<v[i][m])big=v[i][m];
	}
	printf("%lld",big);
	return 0;
}

Measured memory_bytes: 82484
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    int n,k;
    cin>>n>>k;
    vector<int64_t> h(n);
    rep(i,n) cin>>h.at(i);
    sort(h.begin(),h.end());
    int64_t sa=1000000001;
    rep(i,n-k+1){
        sa=min(sa,h.at(i+k-1)-h.at(i));
    }
    cout<<sa<<endl;
}

Measured memory_bytes: 1024
N = int(input())
h = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
dp[0] = 0
for i in range(N-1):
  dp[i+1] = min(dp[i+1],dp[i] + abs(h[i+1]-h[i]))
  if i < N-2:
    dp[i+2] = min(dp[i+2],dp[i] + abs(h[i+2]-h[i]))
print(dp[N-1])
  

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

S = input()
l = len(S)
#d = defaultdict(int)

#for m in S:
    #d[m] += 1

#d2 = sorted(d.items(), key=lambda x:x[1], reverse=True)
#e = (d2[i][0] for i in range(len(d2)))

alpha = [chr(i) for i in range(97, 97+26)]

ans = l
for a in alpha:
    cnt = 0
    num_list = []
    for m in S:
        if m != a:
            cnt += 1
        else:
            num_list.append(cnt)
            cnt = 0
    num_list.append(cnt)
    #print(a, num_list)
    ans = min(ans, max(num_list))

print(ans)

Measured memory_bytes: 3316
#include <stdio.h>

int main(){

  int x,y,z;

  scanf("%d%d",&x,&y);

  if(x>=y){
    while((z=x%y)!=0){
      x=y;
      y=z;
    }
    printf("%d\n",y);
  }
  else{
    while((z=y%x)!=0){
      y=x;
      x=z;
    }
    printf("%d\n",x);
  }
  return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;

int main(){
    int n;
    cin >> n;
    vector<string> w(n);
    map<string, int> z;
    rep(i,n){
        cin >> w[i];
        z[w[i]] += 1; 
    }
    for(auto x : z){
        if(x.second>=2){
            cout("No");
            return 0;
        }
    }

    bool can = true;
    rep(i,n-1){
        int l = (int)w[i].size();
        string end = w[i].substr(l-1,1);
        string start = w[i+1].substr(0,1);
        if(end != start){
            can = false;
            break;
        }
    }

    if(can) cout("Yes");
    else cout("No");
    return 0;

}

Measured memory_bytes: 256
def solve():
    A, B, C, K = map(int, input().split())
    if K <= A:
        print(K)
    elif A < K <= A+B:
        print(A)
    elif A+B < K <= A+B+C:
        print(A-(K-A-B))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9024
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    vector<int>a(5);
    rep(i,5){
        cin>>a[i];
    }
    rep(i,5){
        if(a[i]==0){
            cout<<i+1<<endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <cctype>
#include <cassert>
#include <string>
#include <vector>
#include <algorithm>

int parse(
    const std::string &s, size_t &i, const std::vector<std::string> &ops,
    size_t preced=0) {

  if (preced == ops.size()) {
    assert(isdigit(s[i]));
    return s[i++]-'0';
  }
  int res=parse(s, i, ops, preced+1);
  while (i < s.length()) {
    char op=s[i];
    if (!std::count(ops[preced].begin(), ops[preced].end(), op)) break;
    int tmp=parse(s, ++i, ops, preced+1);
    if (op == '+') res += tmp;
    if (op == '*') res *= tmp;
  }
  return res;
}

int main() {
  char buf[32];
  scanf("%s", buf);
  std::string s=buf;
  int bob;
  scanf("%d", &bob);

  int st=0;
  {
    size_t i=0;
    int res=parse(s, i, {"+", "*"});
    if (res == bob) st |= 1;
  }
  {
    size_t i=0;
    int res=parse(s, i, {"+*"});
    if (res == bob) st |= 2;
  }
  printf("%c\n", "IMLU"[st]);
}



Measured memory_bytes: 2868
#include<iostream>
#include<string>
using namespace std;
bool p[9]={0,0,0,0,0,0,0,0,0};
long long res=0;
string a;
int n;
long long turn(){
	long long num1=0,num2=a[0]-'0';
	for(int i=0;i<n-1;i++){
		if(p[i]==0){
//			cout<<i<<" "<<a[i+1]<<endl;
			num2=num2*10+a[i+1]-'0';
		}else{
			num1+=num2;
			num2=a[i+1]-'0';
		}
	}
	num1+=num2;
//	cout<<" "<<num1<<endl;
	return num1;
}
long long k(int i){
	if(i==0){
		for(int j=0;j<2;j++){
			p[i]=j;
			res+=turn();
		}
		return 0;
	}
	for(int j=0;j<2;j++){
		p[i]=j;
		k(i-1);
	}
	return 0;
}
int main(){
	cin>>a;
	n=a.size();
	k(n-1);
	cout<<res/2;
//	cout<<turn();
	return 0;
}

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

using namespace std;
int main () {

  	int n;
  	string a, b, ret;
  	cin >> n;
	cin >> a;
    cin >> b;
	ret = "";
  	for (int i = 0; i < n; ++i) {
    	ret += a[i];
      	ret += b[i];
    }
	cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/agc032/tasks/agc032_b

# 補グラフ
N = int(input())
G = [[1 for _ in range(101)] for _ in range(101)]
for i in range(101): G[i][i] = 0
groups = []

if N % 2 == 1:
    for i in range(1, N // 2 + 1):
        # print(i, N - i)
        G[i][N - i] = G[N - i][i] = 0
    # print(N)
else:
    for i in range(1, N // 2 + 1):
        G[i][N - i + 1] = G[N - i + 1][i] = 0
        # print(i, N - i + 1)

M = 0
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if G[i][j] == 1:
            M += 1
# for row in G[1:N+1]: print(*row[1:N+1])

print(M)
for i in range(1, N + 1):
    for j in range(i + 1, N + 1):
        if G[i][j] == 1:
            print(i, j)


Measured memory_bytes: 43120