akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int x, y; cin >> x >> y;
    cout << x + y / 2 << endl;
}

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

int main() {
 int a,b,c,d;
  cin >> a >> b >> c >> d;
  int A,B,C,D;
  A = c-d+b;
  B = d+c-a;
  C = a-d+b;
  D = b+c-a;
  cout << A << ' ' << B << ' ' << C << ' ' << D << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
template <class T>
inline void chmin(T &a, const T &b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, const T &b) { a = max(a, b); }
template <class T>
inline bool kbit(const T &x, const int &k) { return ((x >> k) & 1LL); }
inline int popcount(const int &n) { return __builtin_popcount(n); }
inline ll popcountll(const ll &n) { return __builtin_popcountll(n); }
inline ll mask(const ll &k) { return (1LL << k) - 1LL; }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
template <class T>
int lwb(V<T> &v, const T &x) { return lower_bound(all(v), x) - v.begin(); }
template <class T>
int upb(V<T> &v, const T &x) { return upper_bound(all(v), x) - v.begin(); }
void dump() {
    cerr << '\n';
}
template <class Head, class... Tail>
void dump(Head &&head, Tail &&... tail) {
    cerr << head << (sizeof...(Tail) == 0 ? " " : ", ");
    dump(std::move(tail)...);
}
template <class T>
void print(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void read(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
constexpr char sp = ' ', newl = '\n';
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
constexpr ll INF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
//@docs Docs/UnionFind.md
struct UnionFind {
    vector<int> par, sz;
    UnionFind(int n) : par(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }
    inline int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return false;
        if (sz[u] < sz[v]) swap(u, v);
        par[v] = u;
        sz[u] += sz[v];
        return true;
    }
    inline int size(int x) {
        return sz[find(x)];
    }
    inline bool same(int u, int v) {
        return find(u) == find(v);
    }
};

//////////////////////////////////////////////INSERT ABOVE HERE
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    V<pair<P, int>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].fi.fi >> v[i].fi.se;
        v[i].se = i;
    }
    sort(all(v));
    UnionFind uf(n);
    set<P> st;
    for (int i = 0; i < n; i++) {
        int y = v[i].fi.se, id = v[i].se;
        ll mi = n + 2;
        for (auto e : st) {
            if (e.fi >= y) break;
            chmin(mi, e.fi);
            uf.unite(e.se, id);
        }
        if (mi <= n) {
            st.erase(next(st.begin()), st.lower_bound(P(y, -1)));
        } else {
            st.insert(P(y, id));
        }
    }
    for (int i = 0; i < n; i++) {
        cout << uf.size(i) << newl;
    }
}

Measured memory_bytes: 14984
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(ALL(x));
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=0, l=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    cin >> n;
    vector<int>A(n);
  REP(i,n){
      cin >>A[i];
      A[i]--;
    }
    vint(B, n);
    vint(C, n-1);
    REP(i,n){
        ans+=B[A[i]];
          if (i>0&&A[i] == A[i-1]+1) {
            ans += C[A[i - 1]];
        }
    }
        cout << ans << endl;
    }

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main(){
	int a = 0;
	int b = 0;
	int c = 0;
	int ans = 0;
	cin >> a >> b >> c;
	for (int i = a; i < b+1; i++){
		if (c % i == 0){
			ans++;
		}
	}
	cout << ans<<endl;
}

Measured memory_bytes: 3088
#include <stdio.h>
#define M 2000001
#define N 100000
int partition(int *,int,int);

int main(){
  int i,k,j,n,r,p=0;
  int A[M];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  r=n-1;
  
  k = partition(A, p, r);
  for(i=0;i<=r;i++){
    if(i>0){
      printf(" ");
    }
    
    if(i==k){
      printf("[%d]",A[i]);
    }
    else{      
      printf("%d",A[i]);
    }
  }
  printf("\n");
  return 0;
}

int partition(int *A,int q,int s)
{
  int x,i,j,t=0,l=0;
  x=A[s];
  i=q-1;
  for(j=q;j<=s-1;j++){
    if(x>=A[j]){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  l=A[s];
  A[s]=A[i+1];
  A[i+1]=l;
  return i+1; 
}

Measured memory_bytes: 1000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    ll ans=0;
    for(ll i=1;i<=N;i++){
        ans+=i*(N+1-i);
    }
    
    for(int i=0;i<N-1;i++){
        ll a,b;cin>>a>>b;
        if(a>b) swap(a,b);
        ans-=a*(N+1-b);
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
long long dp[101][100001];
int main(){
	int n,W;
	cin>>n>>W;
	long long w[n],v[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<100001;j++){
			dp[i][j]=20000000000000;
		}
	}
	for(int i=0;i<n;i++){
		dp[i][0]=0;
	}
	dp[0][v[0]]=w[0];
	for(int i=1;i<n;i++){
		for(int j=1;j<100001;j++){
			if(v[i]<=j){
				dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
		}
	}
	for(int i=100000;i>0;i--){
		if(dp[n-1][i]<=W){
			cout<<i;return 0;
		}
	}
}

Measured memory_bytes: 78336
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}
void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}
graph InputGraph(ll N,ll M){
    graph G(N);
    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);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}
void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}
void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N,K;
    cin >> N >> K;
    auto A = InputVec(N);
    ll m = A[0];
    ll mi = 0;
    for (int i = 1; i < N; ++i) {
        if(m > A[i]){
            m = A[i];
            mi = i;
        }
    }
    ll l = mi;
    ll r = N-mi-1;
    cout << ceil((double)(N-1)/(double)(K-1)) << endl;


}


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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int i,x,y;
    for(i=1;i<=5;i++)
    {
        cin >> x;
        if(!x)y=i;
    }
    cout << y;
    return 0;
}


Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
typedef struct Dice
{
  int top;
  int bottom;
  int front;
  int back;
  int right;
  int left;
} dice;
void input(dice*);
void roll(dice*,char);
int compareAll(dice*,dice*);
int compare(dice*,dice*);
int main(void)
{
  int i;
  dice d1,d2;
  input(&d1);
  input(&d2);
  if(compareAll(&d1,&d2)==1) printf("Yes\n");
  else printf("No\n");
  return 0;
}
void input(dice *d)
{
  scanf("%d",&d->top);
  scanf("%d",&d->front);
  scanf("%d",&d->right);
  scanf("%d",&d->left);
  scanf("%d",&d->back);
  scanf("%d",&d->bottom);
}
void roll(dice *d,char c)
{
  int temp;
  switch(c)
    {
    case 'E':
      temp=d->right;
      d->right=d->top;
      d->top=d->left;
      d->left=d->bottom;
      d->bottom=temp;
      break;
    case 'N':
      temp=d->back;
      d->back=d->top;
      d->top=d->front;
      d->front=d->bottom;
      d->bottom=temp;
      break;
    case 'S':
      temp=d->front;
      d->front=d->top;
      d->top=d->back;
      d->back=d->bottom;
      d->bottom=temp;
      break;
    case 'W':
      temp=d->left;
      d->left=d->top;
      d->top=d->right;
      d->right=d->bottom;
      d->bottom=temp;
      break;
    }
}
int compareAll(dice *d1,dice *d2)
{
  int i,j;
  for(i=0;i<6;i++)
    {
      for(j=0;j<4;j++)
        {
          roll(d1,'E');
          if(compare(d1,d2)==1) return 1;
        }
      if(i%2==0)
        {
          roll(d1,'N');
          roll(d1,'N');
        }
      else if(i==1)
        {
          roll(d1,'N');
        }
      else if(i==3)
        {
          roll(d1,'E');
          roll(d1,'N');
        }
    }
  return 0;
}
int compare(dice *d1,dice *d2)
{
  if(d1->top!=d2->top) return 0;
  if(d1->bottom!=d2->bottom) return 0;
  if(d1->front!=d2->front) return 0;
  if(d1->back!=d2->back) return 0;
  if(d1->right!=d2->right) return 0;
  if(d1->left!=d2->left) return 0;
  return 1;
}


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

using namespace std;

int main(){
	int W, a, b; cin >> W >> a >> b;
	if( ( a <= b && b <= a + W ) || ( a <= b + W && b + W <= a + W ) ) cout << 0 << endl;
	else if( W > a && a < b ) cout << abs( a - b + W ) << endl;
	else if( W < a && a > b ) cout << abs( b - a + W ) << endl;
}

Measured memory_bytes: 256
'''
包除原理
すべての条件を満たしている
2^{N-1}から「どれかの条件を満たしていない」を引けば良い
i番目の条件を満たしていない確率はかんたんに計算できる
Sに属していいないやつが全て条件を満たしていない確率については
Sに対応する辺が全て白となる確率を考えれば良い
'''
from collections import deque
N=int(input())
G=[[] for i in range(N)]
a=[0 for i in range(N-1)]
b=[0 for i in range(N-1)]
edges=dict()
for i in range(N-1):
    a[i],b[i]=map(int,input().split())
    a[i]-=1;b[i]-=1
    G[a[i]].append(b[i])
    G[b[i]].append(a[i])
    edges[(min(a[i],b[i]),max(a[i],b[i]))]=i
M=int(input())
u=[0 for i in range(M)]
v=[0 for i in range(M)]
for i in range(M):
    u[i],v[i]=map(int,input().split())
    u[i]-=1;v[i]-=1
root=[0 for i in range(M)]
for i in range(M):
    q=deque([u[i]])
    parents=[-1 for i in range(N)]
    reached=[0 for i in range(N)]
    while(len(q)>0):
        r=q.popleft()
        reached[r]=1
        for p in G[r]:
            if reached[p]==1:
                continue
            parents[p]=r
            q.append(p)
    x=v[i]
    while(1):
        if parents[x]==-1:
            break
        s=min(x,parents[x])
        t=max(x,parents[x])
        root[i]+=2**edges[(s,t)]
        x=parents[x]
ans=0
def cnt(x):
    ans=0
    for i in range(M):
        if x|(2**i)==x:
            ans+=1
    return ans
q=deque([])
q.append(0)
S=[0 for i in range(2**M)]
reached=[0 for i in range(2**M)]
while(len(q)>0):
    i=q.popleft()
    for j in range(M):
        if i&(2**j)==0:
            S[i|(2**j)]=S[i]|root[j]
            if reached[i|(2**j)]==0:
                q.append(i|(2**j))
                reached[i|(2**j)]=1
    ans+=(-1)**(cnt(i))*2**(N-bin(S[i]).count("1")-1)
print(ans)



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end());
    ll ans = INF;
    rep(i, N - K + 1) {
        ll tmp = abs(H[i + K - 1] - H[i]);
        ans = min(ans, tmp);
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 1024
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = ll> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

int main(void) {
	int X;
	cin >> X;
	vec<bool> A(1001, false);
	A[1] = true;
	for (int i = 2; i <= 1000; ++i) {
		int x = i;
		x *= i;
		while (x <= 1000) {
			A[x] = true;
			x *= i;
		}
	}
	for (int i = X; i != 0; --i) {
		if (A[i]) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int H,W;
int c[1500][1500];
int h[1500][1500];
int l[1500],r[1500];

int main(void){
	cin >> H >> W;
	rep(i,H)rep(j,W) cin >> c[i][j];
	rep(i,H)rep(j,W){
		if(c[i][j]==1)
			h[i][j]=0;
		else{
			h[i][j]=1;
			if(i-1>=0) h[i][j]+=h[i-1][j];
		}
	}
	int ans=0;
	rep(i,H){
		stack<int> stk;
		rep(j,W){
			while(!stk.empty()&&h[i][stk.top()]>=h[i][j]) stk.pop();
			l[j]=(stk.size()==0)?0:(stk.top()+1);
			stk.push(j);
		}
		while(!stk.empty()) stk.pop();
		for(int j=W-1;j>=0;--j){
			while(!stk.empty()&&h[i][stk.top()]>=h[i][j]) stk.pop();
			r[j]=(stk.size()==0)?W:(stk.top());
			stk.push(j);
		}
		rep(j,W) ans=max(ans,(r[j]-l[j])*h[i][j]);
	}

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

Measured memory_bytes: 18208
#include <iostream>

using namespace std;
int main()
{
	string str;
	cin>>str;
	if(str[0] == 'Y'&&str[1] =='A'&&str[2] =='K'&&str[3] =='I')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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



int main() {

	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int xv, yv;
	xv = x2 - x1;
	yv = y2 - y1;

	cout << x2 - yv << " " << y2 + xv << " " << x1 - yv << " " << y1 + xv << endl;


	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

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

void mergeSort(int 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 main(void) {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for(i=0;i<n;i++) cin >> A[i];

  mergeSort(A, n, 0, n);
  for(i=0;i<n;i++) {
    if(i)cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 6996
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
A = LIST()

#素因数分解
def factorization(n):
	arr = []
	tmp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if tmp%i == 0:
			cnt = 0
			while tmp%i == 0:
				cnt += 1
				tmp //= i
			arr.append([i, cnt])
	if tmp != 1:
		arr.append([tmp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
	
p = defaultdict(int)
for a in A:
	for x, y in factorization(a):
		p[x] = max(p[x], y)

U = 1
for x, y in p.items():
	U = (U*pow(x, y, mod))%mod
ans = 0
for a in A:
	ans = (ans+U*pow(a, mod-2, mod))%mod

print(ans)

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


int main(){

int n,k;
cin >> n >> k;
long long int co =0;

co = k* pow(k-1,n-1);
cout << co << endl;

return 0;
}






Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for B - Coins
	var A, B, C, X int
	fmt.Scanf("%d\n%d\n%d\n%d", &A, &B, &C, &X)

	var answer int = 0
	for i := 0; i <= A; i++ {
		for j := 0; j <= B; j++ {
			for k := 0; k <= C; k++ {
				if X == 500*i+100*j+50*k {
					answer++
				}
			}
		}
	}

	fmt.Println(answer)
}


Measured memory_bytes: 1832
// Problem : A - We Love Golf
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<string, string> pss;
#define pb push_back
#define PI acos(-1.0)
#define EPS 1e-4
#define mp make_pair
#define all(x) x.begin(), x.end()
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define fout(S,x)            cout<<fixed<<setprecision(x)<<(S)<<endl
#define present(c,x) ((c).find(x) != (c).end())
#define T() ll t;cin>>t;while(t--)
#define mem(input,b) memset(input,b,sizeof(input))
#define ff first
#define ss second
#define fread(input) freopen("input","r",stdin)
#define fwrite(b) freopen("b","w",stdout)
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define FOREACH(i,c) for (__typeof ((c).begin()) i = (c).begin() ; i != (c).end() ; i++)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int main(){
    fastio;
    int k,a,b;
    cin>>k>>a>>b;
    bool ok = false;
    for(int i=a;i<=b;++i){
    	if(i%k==0){
    		ok = true;
    		break;
    	}
    }
    if(ok)
    	cout<<"OK"<<endl;
    else
    	cout<<"NG"<<endl;
    return 0;
}    


Measured memory_bytes: 3640
#include <stdio.h>

int main(){
  long long int a, b, c, d;
  scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
  //printf("%18lld %18lld %lld %lld\n", a, b, c, d);
  long long int oldc = c;
  long long int oldd = d;

  long long int x, tmp, r;
  x = c * d;
  if(c < d){
    tmp = c;
    c = d;
    d = tmp;
  }
  r = c % d;
  while(r != 0){
    c = d;
    d = r;
    r = c % d;
  }
  r = x / d;
  long long int nc = (b / oldc) - ((a - 1) / oldc);
  long long int nd = (b / oldd) - ((a - 1) / oldd);
  long long int nr = (b / r) - ((a - 1) / r);

  printf("%lld\n", (b - a + 1) - nc - nd + nr);

  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  int64_t n, a = 2, b = 1;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    b += a;
    a = b - a;
  }
  cout << b << endl;
}



Measured memory_bytes: 256
// ABC044 B - 美しい文字列
#include <stdio.h>

int check(char *str) {
    int checkArr[26] = { 0 };
    
    int i = 0;
    while (str[i] != '\0') {
        checkArr[str[i] - 97] += 1;
        i++;
    }

    int result = 0;
    for (i = 0; i < 26; i++) {
        result += checkArr[i] % 2;
    }

    return result;
}


int main(void) {
    char W[101];

    // input
    scanf("%s", W);

    int result = check(W);

    if (result) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
    
    return 0;
    
}


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

int main(){
    ll H, W;
    cin >> H >> W;
    if (H == 1 || W == 1){
        cout << 1 << endl;
        return 0;
    }
    cout << (H * W + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

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

const int MAX_N = 100010;

int main()
{
  int n;
  cin >> n;
  int ans[MAX_N];
  memset(ans, -1, sizeof(ans));
  vector<pii> nbd[MAX_N];
  int u[MAX_N], v[MAX_N], w[MAX_N];
  for (int i = 0; i < n - 1; i++)
  {
    cin >> u[i] >> v[i] >> w[i];
    u[i]--;
    v[i]--;
    w[i] %= 2;
    nbd[u[i]].push_back(pii(v[i], w[i]));
    nbd[v[i]].push_back(pii(u[i], w[i]));
  }

  ans[0] = 0;
  queue<int> que;
  que.push(0);
  while (!que.empty())
  {
    int q = que.front();
    que.pop();
    for (pii p:nbd[q])
    {
      if (ans[p.first] == -1)
      {
        ans[p.first] = ans[q] + p.second;
        ans[p.first] %= 2;
        que.push(p.first);
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << ans[i] << "\n";
  }
}

Measured memory_bytes: 7936
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

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

int main(){
    int H, W;
    cin >> H >> W;
    // 有向グラフ
    vector<vector<int>> c(10, vector<int>(10));
    for(int i = 0; i < 10; ++i){
        for(int j = 0; j < 10; ++j){
            cin >> c[i][j];
        }
    }
    vector<vector<int>> A(H, vector<int>(W));
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> A[i][j];
        }
    }
    
    // ワーシャルフロイド法
    for(int k = 0; k < 10; ++k){
        for(int i = 0; i < 10; ++i){
            for(int j = 0; j < 10; ++j){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    
    ll res = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            if(A[i][j] == -1)       continue;
            
            res += c[A[i][j]][1];
        }
    }
    
    cout << res << endl;
}

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

string s;
vector<string> sv;
int K;

main()
{
    cin >> s >> K;
    for (int i = 0; i < s.length(); i++) {
        for (int j = 1; j <= s.length() - i && j <= 5; j++) {
            sv.push_back(s.substr(i, j));
        }
    }
    sort(sv.begin(), sv.end());
    sv.erase(unique(sv.begin(), sv.end()), sv.end());

    cout << sv[K-1] << endl;
}

Measured memory_bytes: 1660
program main
  
  implicit none
  character(3) :: s, t
  integer :: i, n
  
  read(*,*) s
  read(*,*) t
  
  n = 0
  do i = 1, 3
    if( s(i:i) == t(i:i) ) n = n + 1
  end do
  print*, n
end program main


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(begin, end) for (i=begin;i<end;i++)
#define init(arr, val) for (i=0;i<end;i++) arr[i] = val;
#define printint(i0, i1) printf("%d %d\n", i0, i1)

using namespace std;
const int nil = -1;
const long long int MOD = 1000000007;
long long int i, n, m, k, ans;
int a[1000];

int main() {
    scanf(" %lld %lld", &n, &k);
    ans = 0;
    rep(k, n+1) {
        ans += (2 * n - i + 1) * i / 2 - (i - 1) * i / 2 + 1;
        ans = ans % MOD;
    }

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

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    cout << (N / 10 == 9 or N % 10 == 9 ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

using namespace std;

void Fast_Read_Out()
{
	ios_base::sync_with_stdio(0);
	cin.tie(), cout.tie();
}

void Random()
{
	unsigned int seed;
	asm("rdtsc" : "=A" (seed));
	srand(seed);        
}

unsigned int Time()
{
	 unsigned int time = clock() / 1000.00;
	 return time;
}

const int inf = int(1e9) + 123;

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif 
	Random();
	Fast_Read_Out();
	string s1, s2;
	cin >> s1 >> s2;
	reverse(all(s1));
	if(s1 == s2) cout << "YES" << endl;
	else cout << "NO" << endl;
	#ifdef JUDGE
//		cout << Time() << endl;
	#endif
}
// Easy Peasy Lemon Squeezy

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N,X,L,i,count=0,flag=0;
    scanf("%d",&N);
    scanf("%d",&X);
    for (i=1;i<=N;i++)
    {
        scanf("%d",&L);
        X=X-L;
        if (X>=0)
        {
            count++;
        }
    }
    printf("%d",(count+1));

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define PB push_back
#define pb push_back
#define X first
#define Y second

#define SZ(a) ((LL)(a).size())
#define all(a) (a).begin(),a.end()
#define forn(i, n) for(LL i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define ll long long
#define MAXN 100
bool adj[105][105];
int main()
{
	int n , N;
	cin >> n;
	N = n;
	int start = 1;
	bool first = true;
	while(start + 1 < n)
	{
		if(n % 2 && first)
		{
			first = false;
			for(int i = 1; i < n; i++)
			{
				adj[n][i] = adj[i][n] = 1;
			}
			n--;
			continue;
		}
		first = false;
		for(int i = start; i <= n; i++)
		{
			adj[start][i] ^= 1;
			adj[i][start] ^= 1;
			adj[n][i] ^= 1;
			adj[i][n] ^= 1;
		}
		start++;
		n --;
	}
	vector<pair<int , int> > edges;
	set<int> S;
	for(int i = 1; i <= N; i++)
	{
		int suma = 0;
		for(int j = 1; j <= N; j++)
			if(adj[i][j])
			{
				if(j > i)		
					edges.PB({i , j});
				suma += j;
			}
		S.insert(suma);
	}
	assert(SZ(S) == 1);
	
	cout << SZ(edges) << endl;
	for(auto edge : edges)
		cout << edge.X << " " << edge.Y << endl;
}


Measured memory_bytes: 384
N = int(input())

def digitSum(s):
    count = 0
    x1 = s//10**4
    x2 = (s-x1*10**4)//10**3
    x3 = (s-x2*10**3-x1*10**4)//10**2
    x4 = (s-x3*10**2-x2*10**3-x1*10**4)//10
    x5 = (s-x4*10-x3*10**2-x2*10**3-x1*10**4)

    if x2==2:
        count+=1
    if x3==2:
        count+=1
    if x4==2:
        count+=1
    if x5==2:
        count+=1

    return count
    


print(digitSum(N))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, l;
	cin >> n >> l;
	vector<string> s;
	map<string, int> mp;
	for(int i = 0; i < n; i++)
	{
		string str;
		cin >> str;
		s.push_back(str);
		mp[str]++;
	}
	sort(s.begin(), s.end());
	string ans = "";
	for(int i = 0; i < n; i++)
	{
		string str = s[i];
		if(mp[str])
		{
			string tmp = str;
			reverse(tmp.begin(), tmp.end());
			if(tmp == str)
			{
				if(mp[str] >= 2)
				{
					mp[str] -= 2;
					ans += str;
				}
			}
			else
			{
				if(mp[tmp] > 0)
				{
					mp[str] -= 1;
					mp[tmp] -= 1;
					ans += str;
				}
			}
		}
	}
	string r = ans;
	//cout << r << endl;
	for(auto i : mp)
	{
		if(i.second)
		{
			string tmp = i.first;
			reverse(tmp.begin(), tmp.end());
			if(tmp == i.first)
			{
				r += tmp;
				break;
			}		
		}
	}
	reverse(ans.begin(), ans.end());
	cout << r + ans << endl;
	return 0;
}
//TLE(;_;)
/*
bool check(string s)
{
	string tmp = s;
	reverse(tmp.begin(), tmp.end());
	if(s == tmp)
		return true;
	else
		return false;
}
int main()
{
	int n, l;
	vector<string> vec;
	cin >> n >> l;
	string str;
	for(int i = 0; i < n; i++)
	{
		cin >> str;
		vec.push_back(str);
	}
	vector<string> v;
	sort(vec.begin(), vec.end());
	int t = 0;
	int cnt = 0;
	do
	{
		cnt++;
		string s ="";
		for(auto x : vec)
		{
			s += x;
			if(check(s))
			{
				if(s.size() > t)
					t = s.size();
				v.push_back(s);
			}
		}
	}
	while(next_permutation(vec.begin(), vec.end()));
	cout << cnt << endl;
	if(!v.size())
	{
		cout << endl;
		return 0;
	}
	for(int i = 0; i < v.size(); i++)
	{
		if(v[i].size() != t)
			continue;
		cout << v[i] << endl;
		return 0;
	}
}*/



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

int main() {
  int N;
  map<int, int> buka;
  cin >> N;
  int x;
  rep(i, N-1) {
    cin >> x;
    buka[x]++;
  }
  for(int i=1; i<=N; i++) {
    cout << buka[i] << endl;
  }
  return 0;
}




Measured memory_bytes: 12952
a,b,c,d = gets.chomp.split("").map(&:to_i)
all = 0
["+","-"].each do |i|
    ["+","-"].each do |o|
        ["+","-"].each do |l|
        arr = "#{a}"+ "," + i + "#{b}"+ "," + o + "#{c}"+ "," + l + "#{d}"
        all += arr.split(",").map(&:to_i).inject(:+)
            if all == 7
                puts "#{a}" + i + "#{b}"+ o + "#{c}"+ l + "#{d}" + "=7"
                exit
            end
            all = 0
        end        
    end
end

Measured memory_bytes: 14280
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>


using namespace std;



int main() {

	int i;
	string S;

	cin >> S;

	i = S.size();


	if (S[i - 1] == '2' || S[i - 1] == '4' || S[i - 1] == '5' || S[i - 1] == '7' || S[i - 1] == '9') {
		cout << "hon";
	}
	else if (S[i - 1] == '3') {
		cout << "bon";
	}
	else {
		cout << "pon";
	}


	return 0;

}

Measured memory_bytes: 3128
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
B=T-A
res=abs(B-H[0]*0.006)
num=1
for i in range(N):
    if abs(B-H[i]*0.006)<res:
        res=abs(B-H[i]*0.006)
        num=i+1
print(num)


Measured memory_bytes: 9152
#include<stdio.h>


int Partition(int *,int,int);

int A[1000000],key;

int main(){
int n,i=1;

scanf("%d",&n);
while(i<=n){

scanf("%d",&A[i]);
i++;    
}

key = Partition(A,0,n);
  
  
for(i = 1; i < key; i++){ 
printf("%d ",A[i]);
}
printf("[%d] ",A[key]);

for(i = key+1;i<=n;i++){
if(i == n){
printf("%d\n",A[n]);
}
 else{
printf("%d ",A[i]);
}
}
  
return 0;
}

int Partition(int *A,int p,int r){

int size,j,x,temp;

x = A[r];
size = p-1;

for(j = p; j < r; j++){
if(A[j] <= x){
size++;
      
temp = A[size];
A[size] = A[j];
A[j] = temp;
}

}

temp = A[r];
A[r] = A[size+1];
  A[size+1] = temp;
  
  
  return size+1;
  
}



Measured memory_bytes: 2100
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis1=[]
lis2=[]
for i in range(n):
    a,b=MI()
    lis1.append(a)
    lis2.append(b)
lis1.sort()
lis2.sort()
if n%2==1:
    med1=lis1[n//2]
    med2=lis2[n//2]
    print(med2-med1+1)
if n%2==0:
    med1=lis1[n//2-1]+lis1[n//2]
    med2=lis2[n//2-1]+lis2[n//2]
    print(med2-med1+1)

Measured memory_bytes: 25688
#include <stdio.h>

int main(void) {
    int r;
    scanf("%d", &r);

    if (r < 1200) {
        printf("%s\n", "ABC");
    } else if (r < 2800) {
        printf("%s\n", "ARC");
    } else {
        printf("%s\n", "AGC");
    }
}



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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int n,m;
	cin >> n >> m;
	cout << (n == m ? "Yes" : "No");
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner stdin = new Scanner(System.in);

		int inN = stdin.nextInt();
		int[] inC = new int[inN - 1];
		int[] inS = new int[inN - 1];
		int[] inF = new int[inN - 1];

		for (int i = 0; i < (inN - 1); i++) {
			inC[i] = stdin.nextInt();
			inS[i] = stdin.nextInt();
			inF[i] = stdin.nextInt();
		}

		for (int i = 0; i < inN; i++) {
			int station = i;
			int time = 0;
			while (station < (inN - 1)) {
				if (time <= inS[station]) {
					time = inS[station];
				}
				else {
					int t;
					for (t = inS[station]; t < time; t += inF[station]) {}
					time = t;
				}

				time += inC[station];
				station++;
			}

			System.out.println(time);
		}
	}

}


Measured memory_bytes: 26016
local h,w=io.read("n","n","l")
local s={}
for i=1,h do
    local input=io.read()
    s[i]={}
    for j=1,w do
        s[i][j]=input:byte(j)
    end
end

local u,d,l,r={},{},{},{}
for j=1,w do
    for i=1,h do
        u[i]=u[i] or {}
        if s[i][j]==35 then
            u[i][j]=0
        else
            if i==1 then
                u[i][j]=1
            else
                u[i][j]=u[i-1][j]+1
            end
        end
    end
end
for j=1,w do
    for i=h,1,-1 do
        d[i]=d[i] or {}
        if s[i][j]==35 then
            d[i][j]=0
        else
            if i==h then
                d[i][j]=1
            else
                d[i][j]=d[i+1][j]+1
            end
        end
    end
end
for i=1,h do
    l[i]={}
    for j=1,w do
        if s[i][j]==35 then
            l[i][j]=0
        else
            if j==1 then
                l[i][j]=1
            else
                l[i][j]=l[i][j-1]+1
            end
        end
    end
end
for i=1,h do
    r[i]={}
    for j=w,1,-1 do
        if s[i][j]==35 then
            r[i][j]=0
        else
            if j==w then
                r[i][j]=1
            else
                r[i][j]=r[i][j+1]+1
            end
        end
    end
end

local max=0
for i=1,h do
    for j=1,w do
        max=math.max(max,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
    end
end
print(max)

Measured memory_bytes: 166548
let () =
  match List.fold_left
          (fun acc x -> match (acc, x) with
            | (x::y::acc, "+") -> (y + x) :: acc
            | (x::y::acc, "-") -> (y - x) :: acc
            | (x::y::acc, "*") -> (y * x) :: acc
            | (acc, n) -> (int_of_string n) :: acc)
          []
          (Str.split (Str.regexp " ") (read_line ())) with
  | [] -> assert false
  | ans :: _ -> Printf.printf "%d\n" ans

Measured memory_bytes: 2328
/*input
coffee
*/
#include <bits/stdc++.h>

using namespace std;

char s[256];
int main() {
  scanf("%s\n", s);
  if (strlen(s) != 6) { puts("No"); return 0; }
  if (s[2] != s[3]) { puts("No"); return 0; }
  if (s[4] != s[5]) { puts("No"); return 0; }
  puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,r;
	cin >> n >> r;
	if(n >= 10)
		cout << r << endl;
	else
		cout << r + 100 * (10 - n) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  int *c=(int *)calloc(100000,sizeof(int));
  int i;
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    c[a]++;
  }
  int max=0;
  for(i=1;i+1<100000;i++){
    max=MAX(max,c[i-1]+c[i]+c[i+1]);
  }
  printf("%d\n",max);
  return;
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 640
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# M個用意する対戦場の数字の差が異なるようにする
N, M = lr()
answer = [[0, 0] for _ in range(M)]
if N&1:
    for i in range(M):
        answer[i][0] = i+1

    cur = M+1
    used = set()
    for i in range(M-1, -1, -1):
        while cur - answer[i][0] in used:
            cur += 1
        answer[i][1] = cur
        diff = answer[i][1] - answer[i][0]
        used.add(diff)
        cur += 1
else:
    l = list(range(1, M+1))
    odd = [x for x in l if x&1]
    even = [x for x in l if x%2==0]
    cur = 0
    for x in odd[::-1]:
        answer[cur] = [cur+1, cur+1+x]
        cur += 1
    now = 1 + odd[-1] + 1
    for x in even[::-1]:
        answer[cur] = [now, now+x]
        now += 1
        cur += 1

for a in answer:
    if a[0] == 0:
        continue
    print(*a)


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

typedef long long ll;
typedef pair<ll, ll> pll;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(make_pair(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    int d[55];
    for(int i = 0; i < n; i++) {
        cin >> d[i];
    }

    int sum = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3608
n = int(input())
a = list(map(int, input().split()))
g = []
for i in a:
  if i % 2 == 0:
    g.append(i)

if all([i % 3 == 0 or i % 5 == 0 for i in g]):
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(){
  int n,ans=0;
  cin >>n;

  if(n%10==1) ans+=9;
  else ans+=1;
  
  if((n/10)%10==1) ans+=10*9;
  else  ans+=10*1;

  if((n/100)%10==1) ans+=100*9;
  else ans+=100*1;

  cout << ans <<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String line1 = sc.nextLine();
		String line2 = sc.nextLine();
        int iline1 = Integer.parseInt(line1);
        int iline2 = Integer.parseInt(line2);
        int plusrate = iline2 - iline1;
		System.out.println(iline2+plusrate);
    }
}


Measured memory_bytes: 21588
#include <iostream>
using namespace std;
typedef long long ll;
#define int ll

int g[105][105];

signed main(void) {
  int n, u, k, v;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> u >> k;
    for (int j = 0; j < k; j++) {
      cin >> v;
      g[u][v] = 1;
    }
  }

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < n; j++) {
      cout << g[i][j] << " ";
    }
    cout << g[i][n] << endl;
  }
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
#define I long long
using namespace std;I n,d,a[220001],b[220001];main(){cin>>n>>d;for(I i=1;i<=n;i++)cin>>a[i],b[i]=a[i];for(I i=2;i<=n;i++)b[i]=min(b[i],b[i-1]+d);for(I i=n-1;i;i--)b[i]=min(b[i],b[i+1]+d);I p=min_element(a+1,a+1+n)-a,A=0;for(I i=p-1;i;i--)A+=a[i]+b[i+1]+d;for(I i=p+1;i<=n;i++)A+=a[i]+b[i-1]+d;cout<<A<<'\n';}


Measured memory_bytes: 3328