akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

int main() {
    string s; cin >> s;
    int a[4];
    rep(i, 4) a[i] = s[i] - '0';

    for (int bit = 0; bit < 1<<3; bit++) {
        int sum = a[0];
        for (int i = 0; i < 3; i++) {
            if (bit & 1<<i) sum += a[i+1];
            else sum -= a[i+1];
        }

        if (sum == 7) {
            cout << a[0];
            for (int i = 0; i < 3; i++) {
                if (bit & 1<<i) cout << '+';
                else cout << '-';
                cout << a[i+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}


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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}


int main()
{
   int k;
   int sum=0;
   cin >> k;
   
   for(int a=1;a<=k;a++){
       for(int b=1;b<=k;b++){
           for(int c=1;c<=k;c++){
               sum+=gcd(gcd(a,b),c);
           }
       }
   }
   cout<<sum;
   return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;
#define m 1000000007

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

    ll N, M; cin>>N>>M;
    vector<pair<ll,ll>> a(N);
    loop(N) cin>>a[i].first>>a[i].second;
    sort(a);

    ll cost = 0;
    for(int i = 0; i<N && M; i++){
        if(M>=a[i].second){
            cost += a[i].second*a[i].first;
            M -= a[i].second;
        }
        else{
            cost += M*a[i].first;
            M = 0;
        }
    }
    cout<<cost<<"\n";
    return 0;
}

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

int main()
{
	int n;
	cin >> n;
	vector<int> v( n );
	vector<int> c( n );

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

	int ans = 0;
	for( int i = 0; i < n; ++i )
	{
		if( v[i] > c[i] )
		{
			ans += v[i] - c[i];
		}
	}

	cout << ans << endl;


	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-----------------------------------------------------------------------------

struct BinaryIndexedTree {
    int n;
    int bit[200020];

    BinaryIndexedTree(int _n): n(_n) {
		for (int i = 0; i <= n; i++) bit[i] = 0;
	}

    int sum(int i) {
        int res = 0;
        while (i > 0) {
            res += bit[i];
            i -= i & -i;
        }
        return res;
    }

    void add(int i, ll x) {
        while(i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int n, k;
ll a, sum[200020];
vector< P > vec;

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

    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        sum[i] = sum[i - 1] + a - k;
        vec.push_back(P(sum[i], i + 1));
    }
    vec.push_back(P(0, 1));
    sort(ALL(vec));
    BinaryIndexedTree tree(n + 1);
    ll ans = 0;
    for (auto x: vec) {
        ans += (ll)tree.sum(x.se - 1);
        tree.add(x.se, 1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7280
#include <iostream>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define ll long long
const int N = 1e6 + 10;
using namespace std;
ll n;
ll t=1;
ll ans=0;
int main() {
  ios::sync_with_stdio(false);
  cin>>n;
  while(n!=1){
      ans+=t;
      n/=2;
      t*=2;
  }
  ans=ans+t;
  cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// g++ -I ~/Documents/AtCoder -std=gnu++14 -o test ~/Documents/AtCoder/test.cpp && ./test && rm test
#include <bits/stdc++.h>
#define rep(i, n) for( int i=0,i##_LEN_=(n); i<i##_LEN_; ++i )
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin >> n; return n;}())
using namespace std;
using lint = int64_t;
const char nl = '\n';

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N=in, M=in;

    priority_queue<pair<int,int>> ABC;
    rep( i, N ) {
        ABC.push( pair<int,int>( in, 1 ) );
    }
    rep( i, M ) {
        int b=in, c=in;
        ABC.push( pair<int,int>( c, b ) );
    }

    lint sum = 0;
    int other = N;
    for( auto abc=ABC.top(); ; ABC.pop(), abc=ABC.top() ) {
        int maisuu = min( other, abc.second );
        sum += (lint)abc.first * maisuu;
        other -= maisuu;
        if( other == 0 ) {
            cout << sum << nl;
            return 0;
        }
    }
}


Measured memory_bytes: 2420
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = list(input())
hands = {'r': 'p', 'p':'s', 's': 'r'}

ans = 0
h = []
for i in range(N):
    e = T[i]
    if i >= K and h[i-K] == hands[e]:
        h.append(None)
        continue

    if e == 'r':
        h.append('p')
        ans += P
    elif e == 'p':
        h.append('s')
        ans += S
    elif e == 's':
        h.append('r')
        ans += R

print(ans)

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

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

  cout << a << " " << b << " " << c << endl;

  return 0;
}



Measured memory_bytes: 3108
#include <cstdio>

using namespace std;

int main(void){
  int n, ans, cur;
  
  ans = 1000000;
  scanf("%d", &n);
  for (int i=0; i<n; i++){
    int tmp;
    scanf("%d", &tmp);
    cur = 0;
    while (tmp%2==0){
      cur++;
      tmp >>= 1;
    }
    ans = ans<cur?ans:cur;
  }
  printf("%d\n", ans);
  return 0;
}


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

#define sswap(x, y) { x+=y; y=x-y; x-=y; }
#define LSOne(S) ((S) & (-S))

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
	int n;
	double x, total = 0.0;
	string u;
	cin >> n;
	while (n--) {
		cin >> x >> u;
		total += (u == "JPY" ? x : x*380000);	
	}
	cout << total << ende;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
const double PI=3.14159265358979323846;

int main(){
  ll n;
  cin >> n;
  ll ans = n;
  for(ll i = 1; i*i <= n; i++){
    if(n % i != 0) continue;
    ll temp = (i-1) + (n/i-1);
    ans = min(ans, temp); 
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[200001], invf[200001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(x<y) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int b, w; cin>>b>>w;
    fac(b+w);
    ll pw=0, pb=0;
    for(int i=1; i<=b+w; i++){
        ll x=powmod(500000004, i-1);
        pw+=comb(i-2, b-1)*x;
        pw%=MOD;
        pb+=comb(i-2, w-1)*x;
        pb%=MOD;
        cout<<(pb+(1-pb-pw+2*MOD)*500000004ll)%MOD<<endl;
    }
    return 0;
}

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

char s[1000000];
ll t[3][1000001];

int main() {
  int n, q;
  scanf("%d%s%d", &n, s, &q);

  V D, C;
  rep(i, n) {
    rep(j, 3) t[j][i+1] = t[j][i];
    switch(s[i]){
      case 'D':
        ++t[0][i+1];
        D.push_back(i+1);
        break;
      case 'M':
        ++t[1][i+1];
        break;
      case 'C':
        ++t[2][i+1];
        C.push_back(i);
        break;
    }
  }

  ll sa1 = 0, sc1 = 0;
  for (auto &a : D) sa1 += t[1][a] * t[2][a];
  for (auto &c : C) sc1 += t[1][c] * t[0][c];

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = sa1 + sc1;
    ll sa2 = 0, sc2 = 0;
    for (auto &a : D) {
      if (a+k-1 < n) ans -= t[1][a] * t[2][a+k-1];
      else sa2 += t[1][a];
    }
    for (auto &c : C) {
      if (c-k+1 > 0) ans -= t[1][c] * t[0][c-k+1];
      else sc2 += t[1][c];
    }
    ans -= sa2 * t[2][n] + sc2 * t[0][0];
    printf("%lld\n", ans);
  }
  return 0;
}


Measured memory_bytes: 28652
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    int ans = 1001001001;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    for(int bit=0;bit<(1<<n);bit++) {
        int res = 0;
        vector<int> target(m, 0);
        for(int i=0;i<n;i++) {
            if((bit>>i)&1) {
                res += c[i];
                rep(j, m) {
                    target[j] += a[i][j];
                }
            }
        }

        //clear
        bool ok = true;
        rep(i, m) {
            if (target[i] < x) ok = false;
        }
        if (ok) {
            ans = min(res, ans);
        }
    }

    if (ans == 1001001001) cout << -1;
    else cout << ans;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

int main() {
  int H,W,N;
  cin >> H >> W >> N;
  
  int x=max(H,W);
  int y;
  if(N%x) y=N/x+1;
  else y=N/x;
  
  cout << y << endl;
}

Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
ll imos[5010][5010] = {};
ll calc(ll sx, ll sy, ll gx, ll gy){
    return imos[sx+1][sy+1] - imos[sx+1][gy] - imos[gx][sy+1] + imos[gx][gy];
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll x[100010], y[100010];
    char c[100010];
    rep(i,0,N){
        cin >> x[i] >> y[i] >> c[i];
        if(c[i] == 'B'){
            y[i] += K;
        }
        x[i] %= 2*K;
        y[i] %= 2*K;
    }

    ll ans = 0;
    rep(i,0,N){
        imos[K+x[i]+1][K+y[i]+1]++;
    }

    rep(i,0,5*K+5){
        rep(j,0,5*K+5){
            imos[i][j+1] += imos[i][j];
        }
    }
    rep(j,0,5*K+5){
        rep(i,0,5*K+5){
            imos[i+1][j] += imos[i][j];
        }
    }

    rep(i,0,2*K){
        rep(j,0,2*K){
            ll val = 0;
            ll gx = i+K, gy = j+K;
            if(i >= K){
                gx -= 2*K;
                val += calc(gx+K-1, gy+K-1, gx, gy);
                gx += 2*K;
            }
            if(j >= K){
                gy -= 2*K;
                val += calc(gx+K-1, gy+K-1, gx, gy);
                gy += 2*K;
            }
            val += calc(gx+K-1, gy+K-1, gx, gy);
            gx -= K; gy -= K;
            val += calc(gx+K-1, gy+K-1, gx, gy);
            gx += 2*K;
            val += calc(gx+K-1, gy+K-1, gx, gy);
            gx -= 2*K; gy += 2*K;
            val += calc(gx+K-1, gy+K-1, gx, gy);
            gx += 2*K;
            val += calc(gx+K-1, gy+K-1, gx, gy);
            ans = max(ans, val);
        }
    }
    print(ans);

}


Measured memory_bytes: 197888
class Dice(object):
    def __init__(self, labels):
        self.stat = labels
    def roll_e(self):
        self.stat[0], self.stat[2], self.stat[5], self.stat[3] = self.stat[3], self.stat[0], self.stat[2], self.stat[5]
    def roll_w(self):
        self.stat[0], self.stat[2], self.stat[5], self.stat[3] = self.stat[2], self.stat[5], self.stat[3], self.stat[0]
    def roll_n(self):
        self.stat[0], self.stat[1], self.stat[5], self.stat[4] = self.stat[1], self.stat[5], self.stat[4], self.stat[0]
    def roll_s(self):
        self.stat[0], self.stat[1], self.stat[5], self.stat[4] = self.stat[4], self.stat[0], self.stat[1], self.stat[5]
    def get_top(self):
        return self.stat[0]
dice = Dice(input().split())
commands = input()
for command in commands:
    if command == "E":
        dice.roll_e()
    elif command == "W":
        dice.roll_w()
    elif command == "N":
        dice.roll_n()
    elif command == "S":
        dice.roll_s()
print(dice.get_top())



Measured memory_bytes: 5572
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#define mp make_pair
typedef long long ll;
using namespace std;
int n;
long long a[200005],l,r,mini=1000000000000000ll;
long long ABS(long long x){
	if (x>=0) return x; else return -x;
}
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=1;i<n;i++) r+=a[i];
	l=a[0];
	for (int i=1;i<n;i++){
		if (mini>ABS(ll(r-l))){
			mini=ABS(ll(r-l));
		}
		l+=a[i];
		r-=a[i];
	}
	cout<<mini;
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int dp[N];
int arr[N];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i -1] + abs(arr[i] - arr[i -1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
	}
	cout << dp[n - 1];
	return 0;
}


Measured memory_bytes: 1024
n=int(input())
l=list(map(int,input().split(" ")))
f=[0]*n
f[1]=abs(l[1]-l[0])

for i in range(2,n):
	x1=f[i-1]+abs(l[i-1]-l[i])
	x2=f[i-2]+abs(l[i-2]-l[i])
	f[i]=min(x1,x2)
print(f[-1])

Measured memory_bytes: 52108
#include <stdio.h>
main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if((r<=x)&&(x<=W-r)&&(r<=y)&&(y<=H-r)){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
}

Measured memory_bytes: 1012
def rec(a, b):
    mx = max(a, b)
    mn = min(a, b)
    #print(mn, mx//mn)
    if mx % mn == 0:
        return (2 * (mx // mn) - 1) * mn
    return (2 * mn * (mx // mn)) + rec(mn, mx % mn)

N, X = list(map(int, input().split()))
#print(N, X)

print(rec(N-X, X) + N)

Measured memory_bytes: 3064
/*@authored by: Subham Pratap*/

/* ************************************************************************************************************************** */

#include <bits/stdc++.h>
using namespace std;
#define PKMKB ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define lli long long int
#define ull unsigned long long
#define INT_MAX 2147483647
#define all(a) begin(a),end(a)
#define pb push_back
#define mp make_pair
#define S second
#define F first
#define MOD 1000000007
#define MAXN 10000005

  int main()
  {
    PKMKB;
    string s;
    cin >> s;
    map<char,lli>mp;
    for(lli i=0;i<s.length();i++)
    {
        mp[s[i]]++;
    }
    if(mp.size()==2 && s.length()==4)
        cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N;
int main() {
    cin >> N;
    vector<long> A(N+1);
    vector<long> B(N);
    long sum = 0;

    for(int i = 0; i < N+1; ++i) {
        cin >> A.at(i);
    }
    for(int i = 0; i < N; ++i) {
        cin >> B.at(i);
    }

    for(int i = 0; i < N; ++i) {
        if(A.at(i) <= B.at(i)) {
            sum += A.at(i);
            B.at(i) -= A.at(i);
            A.at(i) = 0;
            if(A.at(i+1) <= B.at(i)) {
                sum += A.at(i+1);
                A.at(i+1) = 0;
            }else {
                sum += B.at(i);
                A.at(i+1) -= B.at(i);
            }
        }else {
            sum += B.at(i);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,a[105];
long long int ans[105][100005];
int main(){
    int k;
    cin >> n >> k;
    memset(ans, 0, sizeof(ans));
    for(int i=1;i<=n;i++)
        cin >> a[i];
    for(int i=0; i<=n; i++){
        ans[i][0] = 1;
    }
    for(int i=0; i<=k;i++)
        ans[0][i] = 1;
    

    for(int i=1; i<=n; i++){
        for(int j=1; j<=k; j++){
            if(j-a[i]>0)
                ans[i][j] = ((ans[i-1][j] - ans[i-1][j-a[i]-1])%mod + mod)%mod;
            else
                ans[i][j] = (ans[i-1][j])%mod;
            ans[i][j] = (ans[i][j] + ans[i][j-1])%mod;
        }
    }
    // for(int i=0;i<=n;i++){
    //     for(int j=0; j<=k;j++){
    //         cout<<ans[i][j] << " ";
    //     }
    //     cout<<"\n";
    // }
    if(k>0)
        cout << ((ans[n][k]-ans[n][k-1])%mod+mod)%mod;
    else
        cout << ans[n][k];
    return 0;
}

Measured memory_bytes: 85628
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int a;string s;cin >> a >> s;
    cout << (a>=3200?s:"red") << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int n,ans,h[100005],s[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&h[i]);
		if(h[i]<=h[i-1]) s[i]=s[i-1]+1;
	}
	for(int i=1;i<=n;i++) ans=max(ans,s[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import heapq
import sys

input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    A = list(map(lambda x: - x, A))
    heapq.heapify(A)
    for i in range(M):
        tmp = heapq.heappop(A)
        heapq.heappush(A, (-1) * (-tmp // 2))
    ans = -sum(A)
    print(ans)


if __name__ == "__main__":
    main()


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

const ll MOD = 1000000007;
const ll MAX = 100100;
const double PI = 3.1415926;

#define vll vector<ll>
#define max_heap priority_queue<int>
#define min_heap priority_queue<int , vector<int>, greater<int> >
#define pb push_back
#define all(container) container.begin(), container.end()
// #define traverse( container, it) for( typeof(container.begin()) it = container.begin(); it!=container.end(); it++)
ll n,k;
ll arr[110];
ll dp[MAX][2];

int fill(ll s, ll x)
{
	if (s < 0)
		return !x;
	int c = 0;
	if (dp[s][x] != -1)
		return dp[s][x];

	if (x == 0)
	{
		for (int i = 0; i < n; i++)
			c = c || fill(s - arr[i], !x);
		dp[s][x] = c;
		return c; 
	}
	else
	{
		for (int i = 0; i < n; i++)
			c = c || (!(fill(s - arr[i], !x)));
		dp[s][x] = !c;
		return !c;
	}
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	cin >> n >> k;
	memset(dp,-1,sizeof(dp));
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	int c = fill(k,0);
	if (c)
		cout << "First" << endl;
	else
		cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    int N, K;
    cin >> N >> K;

    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(H[i] >= K) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a * b) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
arg0 = list(map(int, input().split()))

arg_array = []

for i in range(arg0[0]):
  arg = list(map(int, input().split()))
  arg_array.append(arg)

counter = 0
for i in range(arg0[0]):
  for j in range(i+1, arg0[0]):
    distance = 0
    
    for k in range(arg0[1]):
      distance += (arg_array[i][k] - arg_array[j][k]) ** 2
    
    distance = distance ** (1.0/2)
    if distance == int(distance):
      counter += 1

print(counter)

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

double	l1(const vector<double> &x, const vector<double> &y)
{
	double	dist = 0;
	size_t	n = x.size();
	double	val;
	for (size_t i = 0; i < n; ++i) {
		val = abs(x.at(i) - y.at(i));
		dist += val;
	}
	return dist;
}

double	l2(const vector<double> &x, const vector<double> &y)
{
	double	dist = 0;
	size_t	n = x.size();
	double	val;
	for (size_t i = 0; i < n; ++i) {
		val = x.at(i) - y.at(i);
		dist += val * val;
	}
	return sqrt(dist);
}
double	l3(const vector<double> &x, const vector<double> &y)
{
	double	dist = 0;
	size_t	n = x.size();
	double	val;
	for (size_t i = 0; i < n; ++i) {
		val = abs(x.at(i) - y.at(i));
		dist += abs(val * val * val);
	}
	return cbrt(dist);
}
double	linf(const vector<double> &x, const vector<double> &y)
{
	double	dist = 0;
	size_t	n = x.size();
	double	val;
	for (size_t i = 0; i < n; ++i) {
		val = abs(x.at(i) - y.at(i));
		if (val > dist) dist = val;
	}
	return dist;
}

int	main()
{
	int	n;
	cin >> n;
	vector<double>	x(n), y(n);
	for (int i = 0; i < n; ++i)
		cin >> x.at(i);
	for (int i = 0; i < n; ++i)
		cin >> y.at(i);
	cout << fixed << setprecision(8);
	cout << l1(x, y) << endl;
	cout << l2(x, y) << endl;
	cout << l3(x, y) << endl;
	cout << linf(x, y) << endl;
}


Measured memory_bytes: 3488
time_list=[]
rest_time_list=[]
rest_time=0
rest_mene=0
for i in range(5):
    time = int(input())
    time_list.append(time)
    iti=str(time)[-1]
    if int(iti)!=0:
        rest_time_list.append(10-int(iti))
        if rest_time<10-int(iti):
            rest_time=10-int(iti)
            rest_mene=i
    else:
        rest_time_list.append(0)
print(sum(time_list)+sum(rest_time_list)-rest_time)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;
long long int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
long long int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  string s, t; cin >> s >> t;
  cout << t + s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REPR(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define FOR(i, x, n) for (int i = x; i < (int)(n); ++i)
#define ALL(n) begin(n), end(n)
#define ll long long
#define INF 1e9
int main() {
    int n;
    cin >> n;
    vector<char> c(n);
    REP(i, n) cin >> c[i];
    int wnum = 0;
    int rnum = 0;
    REP(i, n) {
        if (c[i] == 'W')
            wnum++;
        else
            rnum++;
    }
    // cout << wnum << " " << rnum;
    int ans;
    ans = min(wnum, rnum);
    int newrnum = rnum;
    REP(i, rnum) {
        if (c[i] == 'R') newrnum--;
    }
    ans = min(ans, newrnum);
    cout << ans;

    return 0;
}

Measured memory_bytes: 3604
s = input()
lis_A = []
lis_z = []

for num,moji in enumerate(s):
    if 'A' == moji:
        lis_A.append((num,moji))
    elif 'Z' == moji:
        lis_z.append((num,moji))

print(max(lis_z)[0] - min(lis_A)[0] + 1)

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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;

const int mod = 1000000007;

map<ll, ll> factorize(ll n) {
    map<ll, ll> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res[i] = 0;
        while (n % i == 0) {
            n /= i;
            res[i]++;
        }
    }


    if (n != 1) res[n] = 1;
    return res;

}


int main() {
    ll n;
    cin >> n;
    map<ll, ll> factors;
    for (ll i = 1; i <= n; i++) {
        map<ll, ll> f = factorize(i);
        for (auto e : f) {
            factors[e.first] += e.second;
        }
    }


    ll ans = 0;
    for (auto e : factors) {
        for (auto f : factors) {
            for (auto g : factors) {
                if (e.first == f.first) continue;
                if (f.first == g.first) continue;
                if (g.first == e.first) continue;
                if (f.first >= g.first) continue;

                if (e.second >= 2 && f.second >= 4 && g.second >= 4) ans++;

            }
        }
    }

    for (auto e : factors) {
        for (auto f : factors) {
            if (e.first == f.first) continue;
            if (e.second >= 2 && f.second >= 24) ans++;
        }
    }

    for (auto e : factors) {
        for (auto f : factors) {
            if (e.first == f.first) continue;
            if (e.second >= (5 - 1) && f.second >= (15 - 1)) ans++;
        }
    }

    for (auto e : factors) if (e.second >= 74) ans++;

    cout << ans << endl;
}


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

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;

ll N, K;
string S;
ll ans;
ll cumsum[100010];
int main(){
	cin >> N >> K;
	cin >> S;
	ll l = 0, r = 0;

	// もとから揃ってる数
	REP(i,0,N-1){
		cumsum[i+2] = cumsum[i+1] + (S[i+1]==S[i]);
	}
	// 左端は右端を追い越さない
	ll cntR = 0;
	ans = -1;
	while (l <= r) {
		while(cntR==K+1 && l < r) {
			if(S[l]=='R') {
				cntR--;
			}
			l++;
		}
	    while (r < N-1) {
			while(S[r]=='L' && r < N-1) r++;     // 右端を伸ばす
			cntR++;
			if (cntR==K+1) {
				ans = max(ans, r - l - 1 + cumsum[N] - cumsum[r] + cumsum[l]);
//				p2(l, r);
				break;
			}else{
				while(S[r]=='R' && r < N-1) r++;
			}
	    }
		if(S[l]=='R') {
			cntR--;
		}
	    l++;         // 左端を伸ばす
	}
	if(ans==-1){
		ans=N-1;
	}
	l = 0; r = 0;
	ll cntL = 0;
	while (l <= r) {
		while(cntL==K+1 && l < r) {
			if(S[l]=='L') {
				cntL--;
			}
			l++;
		}
		while (r < N-1) {
			while(S[r]=='R' && r < N-1) r++;     // 右端を伸ばす
			cntL++;
			if (cntL==K+1) {
				ans = max(ans, r - l - 1 + cumsum[N] - cumsum[r] + cumsum[l]);
//				p2(l, r);
				break;
			}else{
				while(S[r]=='L' && r < N-1) r++;
			}
		}
		if(S[l]=='L') {
			cntL--;
		}
		l++;         // 左端を伸ばす

	}
	if(ans==-1){
		ans=N-1;
	}
	p(ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(vec) vec.begin(), vec.end()
using ll = long long;

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int p;
    string s;
    vector<int> wa_count(n,0);
    int ac = 0;
    int wa = 0;
    rep(i,m){
        cin >> p >> s;
        if (wa_count[p - 1] != -1){
            if (s == "WA")
                wa_count[p - 1]++;
            else if (s == "AC"){
                ac++;
                wa += wa_count[p - 1];
                wa_count[p - 1] = -1;
            }
        }
    }
    cout << ac << " " << wa << endl;
}

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

using namespace std;
const int N = 1e5 + 10;

int n, a[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	int ans = 0;
	for (int i = 1; i <= n; )
	{
		bool ii = 0, d = 0;
		int j;
		for (j = i + 1 ; j <= n; j++)
		{
			if(a[j] > a[j - 1])
			{
				ii = 1;
			}
			else if(a[j] < a[j - 1])
			{
				d = 1;
			}
			if (ii && d)
			{
				break;
			}
		}
		i = j;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
def partition(A, p, r):
    # range: [p, r]
    x = A[r]
    i = p - 1
    j = p
    # <=x: [p, i]
    # >x: [i+1, j)
    while j < r:
        if A[j] > x:
            j += 1
        else:
            i += 1
            A[i], A[j] = A[j], A[i]
            j += 1
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


if __name__ == '__main__':
    n = int(raw_input())
    A = map(int, raw_input().split())
    q = partition(A, 0, n - 1)
    for i in range(n):
        if i == q:
            print "[%d]" % (A[i]),
        else:
            print A[i],
    print


Measured memory_bytes: 13156
def main():
    N, T = map(int, input().split())
    *A, = map(int, input().split())

    mi = A[0]
    d_ma = -1
    cnt = 0
    for x in A:
        d = x - mi
        if d_ma < d:
            d_ma = d
            cnt = 1
        elif d_ma == d:
            cnt += 1
        if mi > x:
            mi = x

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15020
//
// Created by tac on 2016/10/23.
//

#include <cstdlib>
#include <iostream>

namespace {

int gcd(const int x, const int y) {
    int m;
    int n;
    int t;
    if (x > y) {
        m = x;
        n = y;
    } else {
        m = y;
        n = x;
    }
    while (n > 0) {
        t = n;
        n = m % n;
        m = t;
    }
    return m;
}

}

int main() {
    int x, y;
    std::cin >> x >> y;
    std::cout << gcd(x, y) << std::endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> s(n), cnt;
    rep(i, n){
        cin >> s.at(i);
        if(s.at(i) % 10 != 0)cnt.push_back(s.at(i));
    }
    sort(all(cnt));
    int ans = accumulate(all(s), 0);
    if(ans % 10 != 0)cout << ans;
    else{
        if(cnt.size()==0)cout << 0;
        else cout << ans-cnt.at(0);
    }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    int n,m;
    cin>>n>>m;
    if (n==1&&m==0)
    {
        cout<<0;
        return 0;
    }
    vector <int> s(m);
    vector <int> c(m);
    rep(i,m)
        cin>>s[i]>>c[i];
    vector <int> ans(n,-1);
    bool ok=true;
    for (int i=0;i<m;i++)
    {
        s[i]--;
        if (ans[s[i]]==-1||ans[s[i]]==c[i])
            ans[s[i]]=c[i];
        else
            ok=false;
    }
    if (ans[0]==0&&n!=1)
        ok=false;
    if (ok)
    {
        rep(i,n){
            if (i==0&&ans[0]==-1)
                cout<<1;
            else
            cout<<max(ans[i],0);
            }
    }
    else
        cout<<-1;






}


Measured memory_bytes: 256
//abc148_d.cpp
//Sun Dec 22 20:45:54 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	ll n;
	cin >> n;

	ll a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
		a[i]--;
	}

	ll count = 0;
	for (int i=0;i<n;i++){
		if (a[i]==count){
			count++;
		}
	}

	if (count == 0){
		cout << -1 << endl;
		return 0;
	}
	cout << n-count << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 1792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long ll;
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 ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}

int main(){ 
int N; cin >> N;
vector<int> p(N);
int cnt = 0;
rep(i,N){
	cin >> p[i];
}
rep(i,N){
	if(p[i] == i + 1){
		p[i+1] = p[i];
		cnt++;
	}
}
cout << cnt << endl;
}

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

typedef long long ll;
using namespace std;
int memo[100001];
int calc(int ar[], int n, int k) {
	if(n==1) {
		return 0;
	}
	
	if(memo[n]!=-1) {
		return memo[n];
	}
	
	int mn = INT_MAX;
	for (int i=1; i<=k; i++) {
		if(n-i>=1) {
			int a = calc(ar, n-i, k) + abs(ar[n]-ar[n-i]);
			mn = min(mn, a);
		}
	}
	memo[n] = mn;
	return mn;
}

int main() {
 	int n,k;
 	cin>>n>>k;
 	int ar[100001];
 	for(int i=1; i<=n; i++) {
 		cin>>ar[i];
 		memo[i] = -1;
 	}
 	
 	cout << calc(ar, n, k);
 	
	return 0;
}

Measured memory_bytes: 8832
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define INF 1000000007
#define int long long
using P = pair<int, int>;
using ll = long long;
signed main(){
    int n;
    cin>>n;
    int a[114514];
    int b[114514];
    int s=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    int k=0;
    b[0]=0;
    for(int i=0;i<n-1;i++){
        k=(k+2)%n;
        b[k]=b[(k-2+n)%n]+(a[(k-1+n)%n]-a[(k-2+n)%n])*2;
    }
    int l=0;
    for(int i=0;i<n;i++)l+=b[i];
    int w[114514];
    w[0]=(s-l)/n;
    for(int i=1;i<n;i++){
        w[i]=a[i-1]*2-w[i-1];
    }
    for(int i=0;i<n;i++)cout<<w[i]<<" ";
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3840
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int a,b;
    cin >> a >> b;
    
    int c = b;
    if(b<10) c += 10*a;
    else if(b<100) c += 100*a;
    else c += 1000*a;

    int i=1;
    while(i*i<=c)
    {
        if(i*i==c)
        {
            cout << "Yes" << endl;
            return 0;
        }
        ++i;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
if (a-1)%2==1:
  if a%4==0:x=0
  else:x=1
else:
  if (a-1)%4==0:x=a-1
  else:x=a
if b%2==1:
  if (b+1)%4==0:y=0
  else:y=1
else:
  if b%4==0:y=b
  else:y=b+1
print(x^y)

Measured memory_bytes: 3064
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		Set s = new HashSet<>();
		
		for (int i = 0; i < n; i++) {
			s.add(sc.nextInt());
		}
		
		System.out.println(s.size());
	}
}


Measured memory_bytes: 21972
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;
 
 
//debug func
template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cerr << x << " ";
    }
    cerr << endl;
}
 
template<typename T>
void vecvecprint(vector<vector<T>> v) {
    for(auto x :v) {
        REP(i, x.size()-1) {
            cerr << x[i] << " ";
        }
        cerr << x[x.size()-1] <<endl;
    }
}
 
template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cerr << q.top() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cerr << q.front() << " ";
        q.pop();
    }
    cerr << endl;
}
 
template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}
 
int main(void) {
    int n;
    cin >> n;

    FOR(i, 1, 10) {
        if(n % i != 0) continue;
        if(n / i < 10) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<sstream>
#include<cctype>
#include<algorithm>
using namespace std;
typedef string::const_iterator Cursol;
bool ok;
int bit;
bool Formula(Cursol &c){
  bool ret;

  if(*c == 'T') ret = true;
  else if(*c == 'F') ret = false;
  else if(islower(*c)) ret = bit >> ((*c) - 'a') & 1;
  else if(*c == '-') return !Formula(++c);
  else if(*c == '('){
    ret = Formula(++c);
    if(*c == '+'){
      ret |= Formula(++c);
    }else if(*c == '*'){
      ret &= Formula(++c);
    }else if(*c == '-'){ //->
      c++;
      ret = !ret | Formula(++c);
    }
  }
  c++;
  return ret;
}
int main(){
  string s;
  Cursol c;
  while(cin >> s , ok = true, s != "#"){
    string l = s.substr(0,s.find('='));
    string r = s.substr(s.find('=')+1);

    for(bit = 0 ; bit < (1 << 11) ; bit++ ){
      c = l.begin();
      bool java = Formula(c);
      c = r.begin();
      if( java != Formula(c) ){
	ok = false;
	break;
      }
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

Measured memory_bytes: 1236