akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#define MOD 1000000007
#define PI 3.14159265358979

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

using namespace std;

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int H, W, N, M, K, T, Q;
int main() {
	cin >> H >> W >> K;
	--K;
	vector< vector< int > > dp(H + 1, vector< int >(W, 0));
	dp[0][0] = 1;
	for (int i = 1; i <= H; i++) {
		for (int bit = 0; bit < (1 << (W - 1)); bit++) {
			int last = 0;
			bool f = false;
			rep(k, W - 1) {
				int now = (bit >> k) & 1;
				if (now * last) {
					f = true;
					break;
				}
				last = now;
			}
			if (f)
				continue;
			rep(j, W) {
				if (j != W - 1 && (bit >> j) & 1) {
					dp[i][j + 1] += dp[i - 1][j];
					dp[i][j + 1] %= MOD;
				} else if (j > 0 && (bit >> (j - 1)) & 1) {
					dp[i][j - 1] += dp[i - 1][j];
					dp[i][j - 1] %= MOD;
				} else {
					dp[i][j] += dp[i - 1][j];
					dp[i][j] %= MOD;
				}
			}
		}
	}
	cout << dp[H][K] % MOD << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 200005;

int a[N];

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());


    int n, k;
    cin >> n >> k;
    int x;
    FOR(i,1,n){
        cin >> x;
        a[x]++;
    }
    int c = n;
    vector<int>v;
    FOR(i,1,n){
        if(a[i] > 0){
            v.pb(a[i]);
        }
    }
    if(sz(v) <= k){
        cout << 0;
        return 0;
    }
    sort(all(v));
    reverse(all(v));
    FOR(i,0,k-1){
        c -= v[i];
    }
    cout << c;



    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

int main() {
  string s, t;
  cin >> s >> t;

  set<char> sst, tst;
  int n = s.size(), m = t.size();
  rep (i, n) {
    sst.insert(s[i]);
  }
  rep (i, m) {
    tst.insert(t[i]);
  }
  for (auto itr = tst.begin(); itr != tst.end(); itr++) {
    char c = *itr;
    if (sst.count(c) == 0) {
      cout << -1 << endl;
      return 0;
    }
  }

  vi last(26);
  vii nex(n, vi(26));
  string ss = s + s;
  rrep (i, n) {
    last[s[i] - 'a'] = i;
  }

  rrep (i, n) {
    rep (j, 26) {
      nex[i][j] = last[j];
    }
    last[s[i] - 'a'] = i;
  }

  ll syu = -1;
  int idx = n - 1;
  rep (i, t.size()) {
    int nex_idx = nex[idx][t[i] - 'a'];
    if (nex_idx <= idx) syu++;
    idx = nex_idx;
  }
  ll ans = syu * n + idx + 1;
  cout << ans << endl;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;


int main() {
    int black=0, white=0;
    string S;
    cin >> S;

    rep(i, S.length()) {
        
        if (i%2 == 0) {
            if (S[i] == '1') black++;
            else white++;
        } else {
            if (S[i] == '0') black++;
            else white++;
        }
    }

    cout << min(black, white) << endl;
    
}



Measured memory_bytes: 512
import math

def Colon():
    input_str = input()
    input_list = input_str.split()
    A = float(input_list[0])
    B = float(input_list[1])
    H = float(input_list[2])
    M = float(input_list[3])
    
    H_speed_per_min = 360/(12*60)
    M_speed_per_min = 360/60
    
    passed_min =    H*60 + M
    H_deg = math.radians(H_speed_per_min * passed_min)
    M_deg = math.radians(M_speed_per_min * (passed_min % 60))
    theta = H_deg - M_deg
 
    C = (A**2 + B**2 - 2*A*B*math.cos(theta))**0.5
    print(C)
    
Colon()

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 100050,M = 200050;
int n,m,d[N],mn[N],ex[M],ey[M],ans[M];
inline bool cmp(int x,int y){ return d[x] < d[y] || (d[x]==d[y]&&x<y); }
vector<int>G[N],G2[N],G3[N];

int To[N],col[N];
inline void solvec(int x,int c){
	if (col[x] != -1) return;
	col[x] = c;
	for (int i = 0; i < G3[x].size(); ++i) solvec(G3[x][i],c^1);
}
int main(){
	int i,j,x,y;
	n = read(),m = read();
	for (i = 1; i <= n; ++i) d[i] = read();
	for (i = 1; i <= m; ++i){
		ans[i] = 1000000000;
		ex[i] = x = read(),ey[i] = y = read();
		G[x].push_back(y),G[y].push_back(x);
		G2[x].push_back(i),G2[y].push_back(i);
	}
	int e;
	for (i = 1; i <= n; ++i){
		for (mn[i] = G[i][0],e = G2[i][0],j = 1; j < G[i].size(); ++j)
			if (cmp(G[i][j],mn[i])) mn[i] = G[i][j],e = G2[i][j];
		if (d[mn[i]] > d[i]){ puts("-1"); return 0; }
		To[i] = mn[i]; col[i] = -1;
		ans[e] = d[i];
		G3[i].push_back(To[i]),G3[To[i]].push_back(i);
	}
	for (i = 1; i <= n; ++i) if (col[i] == -1) solvec(i,0);
	for (i = 1; i <= n; ++i) putchar((col[i])?('B'):('W')); putchar('\n');
	for (i = 1; i <= m; ++i) write(ans[i]),putchar('\n');
	return 0;
}

Measured memory_bytes: 24064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


II solve( int no, VI A ) {
    VI F(10, 0), S(10, 0), C(10, 0);
    VI T(10, 0);
    int t = 0;
    for ( int i = 0; i < 10; ++ i ) {
        F[i] = 0, S[i] = 0, C[i] = 0;
        if ( i == 9 ) {
            F[i] = A[t++];
            S[i] = A[t++];
            C[i] = 0;
            if ( F[i] == 10 || S[i] == 10 || F[i] + S[i] == 10 ) C[i] = A[t++];
        } else {
            if ( A[t] == 10 ) {
                F[i] = A[t++];
            } else {
                F[i] = A[t++];
                S[i] = A[t++];
            }
        }
    }

    for ( int i = 0; i < 10; ++ i ) {
        T[i] = F[i] + S[i] + C[i];
    }

    int addScore = 0;
    for ( int i = 0; i < 9; ++ i ) {
        if ( F[i] == 10 ) {
            if ( i < 8 ) {
                if ( F[i+1] == 10 ) {
                    addScore += 10 + F[i+2];
                } else {
                    addScore += F[i+1] + S[i+1];
                }
            } else if ( i == 8 ) {
                addScore += F[9] + S[9];
            }
        } else if ( F[i] + S[i] == 10 ) {
            addScore += F[i+1];
        }
    }
    return II( accumulate( T.begin(), T.end(), 0 ) + addScore, no );
}

int main() {
    string line;
    while ( getline( cin, line ) ) {
        if ( line == "0" ) break;
        ISS iss( line );
        int n;
        iss >> n;
        VII scores( n );
        for ( int i = 0; i < n; ++ i ) {
            getline( cin, line );
            ISS iss( line );
            int no;
            iss >> no;
            int a;
            VI A;
            while ( iss >> a ) A.push_back( a );
            scores[i] = solve( no, A );
        }
        sort( scores.rbegin(), scores.rend() );
        for ( int i = 0; i < n; ++ i ) {
            for ( int j = i + 1; j < n; ++ j ) {
                if ( scores[i].first == scores[j].first ) {
                    if ( scores[i].second > scores[j].second ) {
                        swap( scores[i], scores[j] );
                    }
                }
            }
        }
        for ( int i = 0; i < n; ++ i ) {
            cout << scores[i].second << " " << scores[i].first << endl; 
        }
    }
    return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if((a+b) % 2 == 0){
        cout << (a+b) / 2 << endl;
    } else {
        cout << (a+b) / 2 + 1 << endl;
    }
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    int h, w; 
    cin>>H>>W;
    cin>>h>>w;
    cout << (H*W)-(h*W)-(H*w)+(h*w) <<endl;
}

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

int main() {
  int x,y;
  cin >> x >> y;
  int sum=0;
  if(x==3){sum+=100000;}
  if(x==2){sum+=200000;}
  if(x==1)sum+=300000;
  if(y==3){sum+=100000;}
  if(y==2){sum+=200000;}
  if(y==1)sum+=300000;
  if(x==1 && y==1)sum+=400000;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_set>

//#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pl;

#define FST first
#define SND second

#define MAX_N   (100000)                  // 10^5
#define BASE    (1000000000 + 7)          // 10^9 + 7
#define INFI    (1000000000 + 7)          // 10^9 + 7
#define INFL    (1000000000000000000 + 7) // 10^18 + 7

ll N, M;
Vl G[MAX_N];

void solve() {
  for (int i = 0; i < N; i++) {
    if (G[i].size() % 2 != 0){
      cout << "NO" << endl;
      return;
    }
  }
  cout << "YES" << endl;
}

int main() {
  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  solve();

  return 0;
}

Measured memory_bytes: 6144
//E
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[1000010];
int sum[1000010];
int mxn[1000010];
int mx,mi,ans,n;
void check(int mx){
	mi=0;
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(s[i]=='0') cnt--;
		if(s[i]=='1') cnt++;
		if(s[i]=='?'){
			if(mxn[i]-sum[i-1]+cnt+2<=mx) cnt++;
			else cnt--;
		}
		mi=min(mi,cnt);
	}
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i]=='0'||s[i]=='?') sum[i]=sum[i-1]-1;
		if(s[i]=='1') sum[i]=sum[i-1]+1;
		mx=max(mx,sum[i]);
	}
	mxn[n]=sum[n];
	for(int i=n-1;i>=1;i--)
		mxn[i]=max(sum[i],mxn[i+1]);
	check(mx);
	//cout<<mx<<mi<<endl;
	ans=mx-mi;
	mx++;
	check(mx);
	//cout<<mx<<mi<<endl;
	ans=min(ans,mx-mi);
	printf("%d",ans);
}

Measured memory_bytes: 11984
def main():
    n = int(input())
    S, T = [], []
    for _ in range(n):
        s, t = input().split()
        S.append(s)
        T.append(int(t))
    x = input()
    print(sum(T[S.index(x) + 1:]))

if __name__ == '__main__':
    main()


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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int gcd(int a,int b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int kaizyou(int N){
  int num=1;
  for(int i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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


signed main() {
  int N;
  cin >> N;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(i%3==0||i%5==0){
      continue;
    }
    ans+=i;
  }
  cout << ans << endl;
}

  
  
  

Measured memory_bytes: 3652
from collections import Counter

n = int(input())
a = list(map(int, input().split()))
dif = [0] * (n + 1)
sum_c = 0
c = Counter(a)
for i, v in c.items():
    if v < 2:
        continue
    val = v * (v - 1) / 2
    dif[i] = v - 1
    sum_c += val
print('\n'.join([str(int(sum_c - dif[i])) for i in a]))


Measured memory_bytes: 33180
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <set>
#include <bitset>
#include <unordered_map>
#include <queue>
#include <cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define MOD 1000000008

int gcd(int a, int b){
    if( a < b){
        swap(a,b);
    }
    return (a % b == 0)? b:gcd(a, a%b);
}

int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}

int main(){
    ll n, d, a;
    cin >> n >> d >> a;
    vector< pair<ll, int> > monsters(n);
    int bombs[n+1];
    memset(bombs, 0, sizeof(bombs));

    // mapを使って座標順にモンスターを格納していく
    rep(i,n){
        ll pos, hp;
        cin >> pos >> hp;
        monsters[i] = make_pair(pos, hp / a + !(hp%a == 0));
    }
    sort(monsters.begin(), monsters.end());

    ll ans = 0;

    // 端から順番に走査
    rep(i,n){
        int remaining = monsters[i].second - bombs[i];
        if( remaining > 0 ){
            bombs[i] += remaining;
            ans += remaining;
            ll end = upper_bound(monsters.begin(), monsters.end(), make_pair(monsters[i].first + 2 * d, INT32_MAX )) - monsters.begin();
            bombs[end] -= remaining;
        }
        bombs[i+1] += bombs[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h,n,sum=0,x;scanf("%d%d",&h,&n);
	for(int i=0;i<n;i++)scanf("%d",&x),sum+=x;
	if(sum>=h)puts("Yes");
	else puts("No");
	return 0;
} 

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

int main()
{
    string T;
    cin >> T;
    T = "*" + T;

    ll N = SZ(T);
    char c;
    REP(i,1,N) {
        if(T[i] == '?') c = 'D';
        else c = T[i];
        cout << c;
    }
    

    return 0;
}

/*



*/

Measured memory_bytes: 3864
#include <stdio.h>

int main(void)
{
  int a, b;
  
  while(scanf("%d%d", &a, &b) != EOF){
    int digits = 1, sum;
    for(sum = a + b; sum >= 10; sum /= 10){
      ++digits;
    }
    printf("%d\n", digits);
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
a = []
for _ in range(n):
  s, t = map(int, input().split())
  a.append([s+t, s, t])

a = sorted(a, key=lambda x: -x[0])
taka = 0
aoki = 0
for i in range(n):
  if i % 2 == 0:
    taka += a[i][1]
  else:
    aoki += a[i][2]

print(taka - aoki)

Measured memory_bytes: 28496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()


int main(){
    int n; cin>>n;
    int h[n];
    rep(i,0,n) cin>>h[i];
    int H=h[0];
    int ans=1;
    rep(i,1,n){
        if(h[i]>=H){
            ans++;
            H=h[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid  + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k=left; k<right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  if(left+1 < right) {
    int mid = (left+right) / 2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid, right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if(p<r) {
    q = partition(A,n,p,r);
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for(i=0;i<n;i++) {
    scanf("%s %d",S,&v);
    A[i].suit =  B[i].suit  = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i=0;i<n;i++) {
    // マージソートとクイックソートの結果を比べる
    if(A[i].suit != B[i].suit) stable = 0;
  }

  if(stable==1) printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++) {
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}


Measured memory_bytes: 4024
#include "bits/stdc++.h"
using namespace std;

// コンテスト中のみ
#define int long long

#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define P pair<ll,ll>
int MOD = 1000000007;
const ll INF = 1LL << 60;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int x, k, d; cin >> x >> k >> d;
	x = abs(x);
	int need = (x + d - 1) / d;
	if (need >  k) {
		cout << x - d * k << endl;
	}
	else {
		int tmp =need - k;
		if (tmp % 2 == 0) {
			cout << abs(x - need * d) << endl;
		}
		else {
			cout << abs(x - (need - 1)*d) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3648
<?php
$a = trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$count = 0;

for ($i = 1; $i < $a - 1; $i++) {
    
        if (($input[$i - 1] < $input[$i] && $input[$i] < $input[$i + 1]) or ($input[$i - 1] > $input[$i] && $input[$i] > $input[$i + 1])) {
            $count++;
        
    }
}
echo $count;
?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int sx,sy,tx,ty;

struct threeElements{
int _1st,_2nd,_3rd;
};
vector<vector<int>>adj(10);
int sum,n,m,visited[11];
void dfs(int i){
    visited[i]=1;
    int flag=1;
    for(int j=1;j<=n;++j){
        if(!visited[j]){
            flag=0;
        }
    }
    if(flag){
        sum++;
        return;
    }
    for(auto x:adj[i]){
        if(!visited[x]){
            dfs(x);
            visited[x]=0;
        }
    }

}
int main()
{
   // freopen ("jumping.in","r",stdin);
   _IOS();
   //18:17
    cin>>n>>m;
    while(m--)
    {
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs(1);
    cout<<sum;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>
#include <stack>
using namespace std;
 
#define rep(i,m,n) for(int i=m;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin >> s;
    int n=s.size();
    stack<char> st;
    rep(i,0,n){
        if(s[i]=='S')st.push('S');
        else if(st.empty())st.push('T');
        else if(st.top()=='T'){
            st.push('T');
        }else{
            st.pop();
        }
    }
    cout<<st.size()<<endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define sb __builtin_popcount
#define MOD (ll)998244353
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;

ll dp[3001][3001];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, s;
    cin >> n >> s;
    ll arr[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 0; j <= s; j++)
        {
            if (j == 0)
            {
                dp[i][j + arr[i - 1]] = i;
            }
            if (j + arr[i - 1] <= s)
            {
                dp[i][j + arr[i - 1]] += dp[i - 1][j];
                dp[i][j + arr[i - 1]] %= MOD;
            }
            if (j != s)
            {
                dp[i][j] += dp[i - 1][j];
                dp[i][j] %= MOD;
            }
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    ll sum = 0;
    for (ll i = 1; i <= n; i++)
    {
        sum += (n - i + 1ll) * dp[i][s];
        sum %= MOD;
    }
    cout << sum << endl;
}

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

vector<int> buf;
long long saidai = 0;

void dfs(int i, const int size, const int range_start, const int range_end, vector<vector<int>> abcd)
{
    if (i == size) {
        // ここで所望の作業を行う
        int tmp = 0;
        for(int i = 0; i < abcd.size(); ++i){
          if(buf[abcd.at(i).at(1)-1] - buf[abcd.at(i).at(0)-1] == abcd.at(i).at(2)){
            tmp += abcd.at(i).at(3);
          }
        }
        if(tmp > saidai){
          saidai = tmp;
        }
    }
    else{
        int jj;
        if(i == 0){
          jj = range_start;
        }else{
          jj = buf[i - 1];
        }
        for(int j = jj; j <= range_end; ++j){
            buf[i] = j;
            dfs(i + 1, size, range_start, range_end, abcd);
        }
    }
}

int main() {

  int N, M, Q;
  cin >> N >> M >> Q;

  vector<vector<int>> abcd(Q, vector<int>(4));

  for(int i = 0; i < Q; i++){
    for(int j = 0; j < 4; j++){
      cin >> abcd.at(i).at(j);
    }
  }

  buf.resize(N);
  dfs(0, N, 1, M, abcd);

  cout << saidai << endl;
}


Measured memory_bytes: 3640
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

int n;cin>>n;
unordered_map<int,int> h;
for(int i=0;i<n;i++)
{
	int a;cin>>a;
	h[a]++;
}
int f=1;
for(auto x:h)
{
	if(x.second>1){
		f=0;break;
	}
}
if(f) cout<<"YES";
else cout<<"NO";

return 0;
}

Measured memory_bytes: 8520
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
int main(){
  ll n,k;cin >> n >>k;
  ll x=n%k;
  ll y=k-x;
  cout << min(x,y) <<endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<i64>();
    println!("{}", n * (n - 1) / 2);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

void split(string s, vector<string> &v){
    string tmp = "";
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '"'){
            v.push_back(tmp);
            tmp = "";
        }
        else tmp += s[i];
    }
    if(tmp != "")v.push_back(tmp);
}

int main(){
    for(string s1, s2;cin >> s1, s1 != ".";){
        cin >> s2;
        vector<string>v1, v2;
        split(s1, v1);
        split(s2, v2);
        int cnt = 0;
        if(v1.size() == v2.size()){
            for(int i = 0; i < v1.size(); i++){
                if(v1[i] == v2[i])continue;
                if(i % 2)cnt++;
                else cnt = 2;
            }
        }
        else cnt = 2;
        if(cnt == 0)cout << "IDENTICAL" << endl;
        else if(cnt == 1)cout << "CLOSE" << endl;
        else cout << "DIFFERENT" << endl;
    }    

    return 0;
}



Measured memory_bytes: 3140
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := newScanner()
	var k = sc.readInt()
	var n = sc.readInt()
	var a = make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.readInt()
	}
	// proc dist
	var dist = make([]int, n)
	for i := 0; i < n; i++ {
		if i != n-1 {
			dist[i] = a[i+1] - a[i]
		} else {
			dist[i] = a[0] + k - a[i]
		}
	}
	var max int = dist[0]
	for i := 0; i < len(dist); i++ {
		if max < dist[i] {
			max = dist[i]
		}
	}
	fmt.Println(k - max)

}

//////////////////
//////////////////
//////////////////

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func reverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func reverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type scanner struct {
	bufScanner *bufio.Scanner
}

func newScanner() *scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &scanner{bufSc}
}

func (sc *scanner) readString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *scanner) readInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *scanner) readInt64() int64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseInt(text, 10, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 6640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  vector<ll>vec(a+1);
  for(ll i=0;i<a+1;i++){
    cin>>vec.at(i);
  }
  vector<ll>veco(a);
  for(ll i=0;i<a;i++){
    cin>>veco.at(i);
  }
  for(ll i=0;i<a;i++){
    if(veco.at(i)>=vec.at(i)+vec.at(i+1)){
      b+=vec.at(i)+vec.at(i+1);
      vec.at(i+1)=0;
    }
    else{
      b+=veco.at(i);
      vec.at(i+1)=min(vec.at(i+1)-veco.at(i)+vec.at(i),vec.at(i+1));
    }
  }
    cout<<b<<endl;
    return 0;
}

  
  
    
  



Measured memory_bytes: 4824
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp make_pair
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

class BipartiteMatching {
private:
  int n;
  vector<vector<int>> graph;
  vector<int> match;
  vector<bool> used;
  bool dfs(int v){
    used[v] = true;
    for(int u : graph[v]){
      int w = match[u];
      if(w<0 || (!used[w] && dfs(w))){
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }
public:
  BipartiteMatching(int _n) : n(_n){
    graph.resize(n);
    match.resize(n);
    used.resize(n);
  }
  void add_edge(int u, int v){ // 0-indexed
    graph[u].pb(v);
    graph[v].pb(u);
  }
  int matching(){ // matching size
    int res = 0;
    fill(begin(match), end(match), -1);
    rep(v, n){
      if(match[v] < 0){
        fill(begin(used), end(used), false);
        if(dfs(v)) res++;
      }
    }
    return res;
  }
};


int main(){
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n),d(n);
  rep(i,n) cin>>a[i]>>b[i];
  rep(i,n) cin>>c[i]>>d[i];

  BipartiteMatching match(2*n);
  rep(i,n) rep(j,n) if(a[i] < c[j] && b[i] < d[j]) match.add_edge(i, n+j);

  cout << match.matching() << endl;


  return 0;
}


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

int main()
{
    int n, a, cnt=0;
    cin >> n;
    
    for(int i=0; i<n; i++)
    {
        cin >> a;
        while(a%2==0)
        {
            cnt++;
            a /= 2;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = ;
const long long INF_LL = 1e18+3; const int INF_int = 1e9+3;
#define ll long long
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto itr = a.begin();itr!=a.end();itr++) cout << *itr << " ";cout << endl;
//n以下の素数列挙(O(nloglogn))
vector<ll> primes_(ll n){
    bool judge[n+1];
    for(int i = 0;i<=n;i++){
        judge[i] = true;
    }
    vector<ll> prime;
    for(int i = 2;i<=n;i++){
        if(judge[i]){
            for(int j = 2*i;j<=n;j+=i){
                judge[j] = false;
            }
            prime.push_back(i);//ここでprimeに入れられる素数の条件を指定できる
        }
    } 
    return prime;
}
int main(){
    ll n;
    cin >> n;
    vector<ll> primes = primes_(1e6+2);
    int ans = 0;
    rep(i,primes.size()){
        ll now = primes[i];
        int cnt = 0;
        while(n%now==0){
            n/=now;
            cnt++;
        }
        for(int j = 1;true;j++){
            if(cnt>=j){
                cnt-=j;
                ans++;
            }
            else break;
        }
    }
    if(n!=1) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 5296
import java.io.*;
import java.util.*;

public class Main {
	// ------------------------

	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		// ------------------------
		int n=sc.nextInt();
		long[]a=new long[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextLong();
		HashSet<Long>set=factors(a[0]);
		set.addAll(factors(a[1]));
		long max=1;
		for(long x:set){
			int ct=0;
			for(int i=0;i<n;i++)
				if(a[i]%x==0)
					ct++;
			if(ct>=n-1)
				max=Math.max(x,max);
		}
		System.out.println(max);
		// ------------------------
		out.close();
	}
	//------------------------
	private static HashSet<Long>factors(long a){
		HashSet<Long>f=new HashSet<Long>();
		for(long i=1;i<=Math.ceil(Math.sqrt(a));i++)
			if(a%i==0){
				f.add(i);
				f.add(a/i);
			}
		return f;
	}
	public static PrintWriter out;
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
}


Measured memory_bytes: 41324
#include <iostream>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;

int main(){
  int n;
  cin >> n;
  Graph G(n);
  rep(i, n){
    int u, k;
    cin >> u >> k;
    u--;
    rep(j, k){
      int v;
      cin >> v;
      v--;
      G[u].push_back(v);
    }
  }
  
  vector<int> d(n, -1);
  queue<int> que;
  
  d[0] = 0;
  que.push(0);
  
  while(!que.empty()){
    int v = que.front();
    que.pop();
    for(int nv : G[v]){
      if (d[nv] != -1) continue;
      
      d[nv] = d[v] + 1;
      que.push(nv);
    }
  }
  
  rep(i, n) cout << i + 1 << ' ' << d[i] << endl;
  
  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=50050;

char s[maxn];
int main(){
    int n;
    scanf("%d", &n);

    if (n < 1200)  puts("ABC");
    else if (n < 2800)  puts("ARC");
    else  puts("AGC");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

bool fn_is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

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

int binary_search(int key, vector<ll>& a) {
    int ng = -1;
    int ok = a.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, a)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    char c;
    rep(i,19) {
        cin >> c;
        if (i == 5 || i == 13)
            cout << " ";
        else
            cout << c;
    }
    cout << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<min(a,b)+min(c,d)<<endl;
    return 0;
}


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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

int w, a, b;
int minDist()
{
	int a2 = a + w, b2 = b + w;
	if(b >= a && b <= a2 || b2 >= a && b2 <= a2)
		return 0;
	if(b2 < a)
		return a - b2;
	return b - a2;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
//	freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> w >> a >> b;

	cout << minDist() << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

// 文字列Sに各文字が何回出現するかカウント。始まりの文字がcで、文字種類数がk
// 例えばSに含まれる文字が'a-z'であれば、c='a', k=26とする。
std::vector<int> count_char(const std::string& S, const char c, const int k) {
    std::vector<int> ret; ret.resize(k, 0);
    for (int i = 0; i < S.size(); i++) {
        assert(S[i] - c < k);
        ret[S[i] - c]++;
    }
    return ret;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

#define input1(begin, end, v1) v1.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i]; } 
#define input3(begin, end, v1, v2, v3) v1.resize((end)+1); v2.resize((end)+1); v3.resize((end)+1); for (int i = (begin); i <= (end); i++) { std::cin >> v1[i] >> v2[i] >> v3[i]; } 

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int N;
std::vector<std::string> S;
std::map<std::string, int128_t> mp;


int main(int argc, char **argv) {
    std::cin >> N;

    input1(1, N, S);

    rep (i, 1, N) {
        std::sort(S[i].begin(), S[i].end());
        mp[S[i]]++;
    }

    int128_t ret = 0;
    for (auto p : mp) {
        ret += (p.second * (p.second - 1)) / 2;
    }

    std::cout << ret << std::endl;

    

    return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    map<int,ll> num;
    vin a(n);
    rep(i,n){
        cin>>a[i];
        num[a[i]]=(ll)(i+1);
    }
    set<int> r;
    rep(i,n+2)r.insert(i);
    ll tmp,ans=(ll)0,left,right;
    for(int i=n;i>0;i--){
        tmp=num[i];
        r.erase(tmp);
        left=*(--r.lower_bound(tmp));
        right=*(r.upper_bound(tmp));
        ans+=i*((tmp-left)*(right-tmp));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 25880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll H, W, K; cin >> H >> W >> K;
    vector<string> S(H); 
    for(int i = 0; i < H; i++) cin >> S[i];
    ll ans = 0;

    for(int i = 0; i < (1<<H); i++){
        for(int j = 0; j < (1<<W); j++){
            bitset<10> BH = i, BW = j;
            ll cnt = 0;
            for(int h = 0; h < H; h++){
                for(int w = 0; w < W; w++){
                    if(!BH[h] && !BW[w] && S[h][w] == '#') cnt++;
                }
            }
            if(cnt == K) ans++;


        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  const int N = 200005;

const int INF = (1LL << 62) - 1;

int32_t main()
{



    IOS


    int n,k;
    cin >> n >> k;

    int bl[n+1][65];

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

    for(int j = 1; j <= 61; j++)
    {
      for(int i = 1; i <= n; i++)
      {
        bl[i][j] = bl[bl[i][j-1]][j-1];
      }
    }

    int x = 1;


    for(int i = 61; i >= 0; i--)
    {
      if(k & (1LL << (i)))
      {
        x = bl[x][i];
      }
    }

    cout << x;













    return 0;
}



Measured memory_bytes: 105172