akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
const ll linf=1e18;
const int inf=1001001001;
const ll mod=1e9+7; // 998244353 = (119<<23)+1
// head
const int nax=2e5+7;
int n,ans=0;
int s[nax];
int main() {
	  ios::sync_with_stdio(false);
  	cin.tie(0);
		cin>>n;
		rep(i,0,n) cin>>s[i];
		int p=1;
		rep(i,0,n) {
			if(s[i]==p) p++;
			else ans++;
		}
		ans==n?cout<<-1:cout<<ans;
		return 0;
}

Measured memory_bytes: 1024
n, q = map(int, input().split())
Que = []
for _ in range(n):
    name, time = input().split()
    Que.append([name, int(time)])
elps = 0
while Que != []:
    tmp = Que.pop(0)
    if tmp[1] - q > 0:
        tmp[1] = tmp[1] - q
        Que.append(tmp)
        elps += q
    else:
        elps += tmp[1]
        print(tmp[0], elps)


Measured memory_bytes: 13012
#include<stdio.h>
int main(){
	int N;
	int K;
	scanf("%d %d", &N, &K);
	int total = 0;
	total = N - K;
	long long int A[N];
	for(int i = 0 ; i < N ; i++){
		scanf("%lld", &A[i]);
	}
	for(int i = 0 ; i < total ; i++){
		if(A[i] < A[i+K]){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
//int p = 998244353;
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define rev(s) reverse(s.begin(),s.end())
int max_kai = 150000;
vel kai(max_kai, 1);
vel inv_kai;
int rui(int a, int n) {
	if (n == 0) { return 1; }
	int x = rui(a, n / 2);
	x *= x; x %= p;
	if (n % 2 == 1) { x *= a; x %= p; }
	return x;
}
int inv(int a) { return rui(a, p - 2); }
void make_kai() {
	for (int i = 1; i < max_kai; i++) { kai[i] = kai[i - 1] * i; kai[i] %= p; }
	inv_kai = kai;
	rep(i, max_kai) { inv_kai[i] = inv(kai[i]); }
}
int nCr(int n, int r) {
	int a = kai[n] * inv_kai[r]; a %= p;
	a *= inv_kai[n - r]; a %= p;
	return a;
}
vel pa;
int root(int x) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x]); pa[x] = ans;
	return ans;
}
void marge(int x, int y) {
	x = root(x);
	y = root(y);
	if (x != y) {pa[x] = y;}
}
#define lower(h,val) lower_bound(h.begin(),h.end(),val)-h.begin()
#define upper(h,val) upper_bound(h.begin(),h.end(),val)-h.begin()
int num_lp(int a, vel &nex) {
	unordered_set<int> se;
	int ans = 0;
	while (true) {
		if (se.find(a) != se.end()) {
			break;
		}
		se.insert(a);
		a = nex[a];
		ans++;
	}
	return ans;
}
int find_cr(int a, vel &nex) {
	unordered_set<int> se;
	while (true) {
		if (se.find(a) != se.end()) {break;}
		se.insert(a);
		a = nex[a];
	}
	return num_lp(a, nex);
}
int inf = 2000000000;
vvel dp;
int solve(vvel &sum, int i, int j, bool is_f) {
	int h = sum.size(); h--;
	int w = sum[0].size();
	if (i == h || j == w) { return 0; }
	if (dp[i][j] == inf) {
		int ans1 = solve(sum, i + 1, j, !is_f);
		int ans2 = solve(sum, i, j + 1, !is_f);
		ans2 += sum[i][j];
		if (is_f) {
			dp[i][j] = min(ans1, ans2);
		}
		else {
			dp[i][j] = max(ans1, ans2);
		}
	}
	return dp[i][j];
}
int rui10(int a) {
	if (a == 0) { return 1; }
	return 10 * rui10(a - 1);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	if (b == 0) { return a; }
	return gcd(b, a%b);
}
signed main(){
	string s; cin >> s;
	int n = s.size();
	if (s[n - 1] != ')') { s += "(0)"; }
	n = s.size();
	int sy, st;
	int x = 0;
	rep(i, n) {
		if (s[i] == '(') { st = i; break; }
		else if (s[i] == '.') { sy = i; }
		else {
			int kazu = s[i] - '0';
			x *= 10; x += kazu;
		}
	}
	int y = 0;
	for (int i = st + 1; i < n - 1; i++) {
		int kazu = s[i] - '0';
		y *= 10; y += kazu;
	}
	int bunsi = x * (rui10(n - st - 2)-1) + y;
	int bunbo = (rui10(n - st - 2) - 1)*rui10(st - sy - 1);
	int g = gcd(bunsi, bunbo);
	cout << bunsi / g << "/" << bunbo / g << endl;
	return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}


int main(){
    string s; cin >> s;
    int N = s.size();
    vector<int> mod13(N+5, 0);
    mod13[0] = 1; // 10^i mod13
    for(int i=1; i<=N; ++i){
        mod13[i] = mod13[i-1]*10%13;
    }


    vector<vector<ll>> dp(N+5, vector<ll>(15, 0));
    
    if(s.back() != '?') dp[0][s.back()-'0'] = 1;
    else{
        for(int i=0; i<=9; ++i) dp[0][i] = 1;
    }

    int add;
    for(int i=1; i<N; ++i){
        int d = N-1-i;
        for(int j=0; j<13; ++j){
            if(s[d] != '?'){
                add = (s[d]-'0')*mod13[i]%13;
                dp[i][j] = dp[i-1][(j-add+13)%13];
            }
            else{
                for(int k=0; k<10; ++k){
                    add = k*mod13[i]%13;
                    dp[i][j] += dp[i-1][(j-add+13)%13];
                    dp[i][j] %= mod;
                }
            }
        }
    }

    cout << dp[N-1][5] << endl;

    // for(int i=0; i<3; ++i){
    //     for(int j=0; j<13; ++j){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

}

Measured memory_bytes: 15616
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n;
  cin>>n;
  vector<P> vec;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    vec.push_back(P(a,i));
  }
  sort(vec.begin(),vec.end());
  int ans=0;
  for(int i=0;i<n;i++){
    ans+=max(vec[i].second-i,i-vec[i].second)%2;
  }
  cout<<ans/2<<endl;
}


Measured memory_bytes: 1400
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,m = LI()

edges = [[] for _ in range(n)]
cnt = [[0,i] for i in range(n)]
for _ in range(n-1+m):
    a,b = LI()
    edges[a-1].append(b-1)
    cnt[b-1][0] += 1


ans = [None]*n
que = deque()
for i in range(n):
    if cnt[i][0] == 0:
        que.append(cnt[i][1])
        ans[cnt[i][1]] = 0
        while que:
            v = que.popleft()
            for i in edges[v]:
                cnt[i][0] -= 1
                if cnt[i][0] == 0:
                    que.append(i)
                    ans[i] = v+1
        break
for i in ans:
    print(i)


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

int main(){
  int x;
  cin >> x;

  if(x%7==0){
    cout << "thu" << endl;
  }
  else if(x%7==1){
    cout << "fri" << endl;
  }
  else if(x%7==2){
    cout << "sat" << endl;
  }
  else if(x%7==3){
    cout << "sun" << endl;
  }
  else if(x%7==4){
    cout << "mon" << endl;
  }
  else if(x%7==5){
    cout << "tue" << endl;
  }
  else {
    cout << "wed" << endl;
  }

  return 0;
}



Measured memory_bytes: 3116
#include <iostream>
#include <sstream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <iomanip>
#include <string>
using namespace std;

//関数getinputdata宣言
vector<vector<string>> getinputdata();
vector<vector<int>> getinputdata2();
vector<vector<double>> getinputdata3();

void caddi2018b_a(vector<vector<string>> v) {

    string n=v[0][0];

    int mycnt=0;
    
    for (int i=0;i<n.size();i++){
        
        if(n.substr(i,1)=="2"){
            mycnt+=1;
        }
    }
    
    cout << mycnt <<endl;
    
}

int main() {

    vector<vector < string>> vec_arr_result;
//                vector<vector<int>> vec_arr_result;
    vec_arr_result = getinputdata();

    caddi2018b_a(vec_arr_result);

    return 0;
}

//関数getinputdata実装

vector<vector<double>> getinputdata3() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<double>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<double> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atof(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector<int>> getinputdata2() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector<int>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<int> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(atoi(ret.c_str()));
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;


}

//関数getinputdata実装

vector<vector<string>> getinputdata() {

    string str;
    string ret;
    stringstream ss;
    vector<string> v1;
    vector<vector < string>> vec_arr;

    //標準入力から入力がある間ループ処理でvector配列にデータ格納
    while (getline(cin, str)) {

        v1.push_back(str);

    }

    //stringstreamを利用してvector配列v1をスペースで分解処理
    for (string s : v1) {

        vector<string> array_data;
        ss << s;

        while (!ss.eof()) {

            ss >> ret;

            array_data.push_back(ret);
        }

        //vector配列に追加
        vec_arr.push_back(array_data);

        //バッファクリア
        ss.str("");
        //ストリームクリア
        ss.clear(stringstream::goodbit);

    }

    return vec_arr;

}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &ai: a) cin >> ai;
    auto check = [&](long long mid) {
        vector<pair<int, int>> v;       // (pos1, c - 'a')
        v.emplace_back(0, 0);
        for (int i = 1; i < n; i++) if (a[i - 1] >= a[i]) {
            while (v.back().first > a[i]) v.pop_back();
            // inc
            if (v.back().first == a[i]) {
                v.back().second++;
            } else {
                v.emplace_back(a[i], 1);
            }
            // carry
            while (v.back().second == mid) {
                int pos = v.back().first; v.pop_back();
                if (v.back().first == pos - 1) {
                    v.back().second++;
                } else {
                    v.emplace_back(pos - 1, 1);
                }
            }
            if (v.front().second) return false;
        }
        return true;
    };
    auto binary_search = [&](long long ok, long long ng) {
        // assert(check(ok) == true);
        // assert(check(ng) == false);
        while (abs(ng - ok) > 1) {
            long long mid = (ng + ok) / 2;
            (check(mid) ? ok : ng) = mid;
        }
        return ok;
    };
    bool inc = true;
    for (int i = 0; i + 1 < n; i++) if (a[i] >= a[i + 1]) inc = false;
    if (inc) return !(cout << 1 << endl);
    cout << binary_search(n, 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
def wtf(x):
    twos = 0
    fives = 0
    for j in range(1, 60):
        bs = 2 ** j
        twos = twos + x // bs
        bs = 2 * 5 ** j
        fives = fives + x // bs
    return min(twos, fives)
x = int(input())
print(wtf(x) if x % 2 == 0 else 0)

Measured memory_bytes: 61788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  vi A(N),B(M);
  rep(i,0,N) cin>>A[i];
  rep(i,0,M) cin>>B[i];
  vii dp(N+1,vi(M+1,1));
  rep(i,0,N){
    rep(j,0,M){
      dp[i+1][j+1]=dp[i][j+1]+dp[i+1][j]+MOD-dp[i][j];
      if(A[i]==B[j]) dp[i+1][j+1]+=dp[i][j];
      dp[i+1][j+1]%=MOD;
    }
  }
  int ans=dp[N][M];
  cout<<ans<<endl;
  }



Measured memory_bytes: 31616
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//

        int n, m;
        cin >> n >> m;

        cout << (n - 1) * (m - 1) << endl;

        return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;++i) cin >> a[i];
  sort(a.begin(), a.end(), greater<int>());
  int ans = 0;
  for(int i=0;i<(n-2);++i){
    for(int j=(i+1);j<(n-1);++j){
      for(int k=(j+1);k<n;++k){
        if(a[i]<(a[j]+a[k])) ans+=1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,h,m=map(int,input().split())
import math
toki=360*(h*60+m)/(12*60)
fun=360*m/60
aida=abs(fun-toki)
cos=math.cos(math.radians(aida))
nijou=a**2+b**2-(2*a*b*cos)
print(nijou**(1/2))

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


int main()
{
	short int n, m, c;
	cin >> n >> m >> c;
	short int b[20];
	int i = 0;
	while (i<m)
	{
		cin >> b[i];
		i++;
	}
	short int a[20];
	int ans = 0;
	int num = 0;
	int i2 = 0;
	while (i2<n)
	{
		i = 0;
		num = 0;
		while (i<m)
		{
			cin >> a[i];
			i++;
		}
		i = 0;
		while (i<m)
		{
			num += b[i] * a[i];
			i++;
		}
		num += c;
		if (num>0)
		{
			ans++;
		}
		i2++;
	}
	cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int a,b,c,sum;
	cin>>a>>b>>c;
	sum=(100*a)+(10*b)+c;
	if(sum%4==0)
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N),B(N,0);
    rep(i,N){cin >> A.at(i);}

    rep(i,N)B.at(A.at(i)-1) = i+1;
    
    rep(i,N)cout << B.at(i) << " ";
    cout << endl;
}

/*
    int order=0;
    while(order<N){
        rep(i,N){
            if(A.at(i)==order+1){
                B.at(order) = i+1;
                order++;
            }
        }
    }
*/

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    ll N, K, S, tmp = 1000000000;
    cin >> N >> K >> S;
    if (S == 1000000000) tmp = 1;
    for (int i = 0; i < K; i++) cout << S << " ";
    for (int i = K; i < N; i++) cout << tmp << " ";
    return 0;
}



Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vii vector<int,int>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define all(a) a.begin(),a.end()
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    int x,k;
    cin>>x>>k;
    int m;
    ll n;
    vector<pair<int,ll>> v;
    for(int i=0;i<x;i++){
        cin>>m>>n;
        v.pb(mp(m,n));
    } 
    sort(all(v));
    ll dp[x+1][k+1];
    for(int i=0;i<=x;i++){
        for(int j=0;j<=k;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else{
                if(v[i-1].fi>j){
                    dp[i][j]=dp[i-1][j];
                }
                else{
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-v[i-1].fi]+v[i-1].sc);
                }
            }
        }
    }
    cout<<dp[x][k];
}

Measured memory_bytes: 79232
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

static char path = '.';
static int inf = 10000000;
int h, w;
vector<vector<char>> board;
vector<int> d_y = {1, -1 ,0 , 0};
vector<int> d_x = {0, 0 ,1 , -1};


struct point {
  int i, j;
};

int sub_max(point start) {
  int max = 0;
  // 開始点が通路でなければ0
  if (board[start.i][start.j] != path) {
    return 0;
  }

  // 開始点からの距離を記録していくグラフ
  vector<vector<int>> graph(h, vector<int>(w, inf));
  // 開始点は0
  graph[start.i][start.j] = 0;
  
  queue<point> que;
  que.push(start);
  
  while (que.size() != 0) {
    point p = que.front();
    que.pop();

    rep(d, 4) {
      point next;
      next.i = p.i + d_y[d];
      next.j = p.j + d_x[d];

      // 迷路の外の場合へは移動しない
      if (
        next.i >= h ||
        next.i < 0 ||
        next.j >= w ||
        next.j < 0
      ) {
        continue;
      }
      
      // 次点が壁の場合は移動しない
      if (board[next.i][next.j] != path) {
        continue;
      }

      // 次点が大きい（未到達も含む）の場合は移動する
      if (graph[next.i][next.j] > graph[p.i][p.j] + 1) {
        graph[next.i][next.j] = graph[p.i][p.j] + 1;
        que.push(next);
        if (max < graph[next.i][next.j]) {
          max = graph[next.i][next.j];
        }
      }
    }
  }
  return max;
}

int main() {
  cin >> h >> w;
  // 迷路を初期化
  board.assign(h, vector<char>(w, path));

  rep(i, h) {
    rep(j, w) {
      cin >> board[i][j];
    }
  }
  
  int max = 0;

  // 開始点の場合をすべての地点で調べて最大を得る
  rep(i, h) {
    rep(j, w) {
      point p;
      p.i = i;
      p.j = j;
      int m = sub_max(p);
      if (max < m) {
        max = m;
      }
    }
  }


  cout << max << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    string s;
    cin>>s;
    vector<string>v = {"Sunny","Cloudy","Rainy"};
    for(int i=0;i<3;i++)
    {
        if( v[i] == s )
        {
            cout<<v[mod(i+1,3)],nl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
if len(s) == 1:
    print(0)
else:
    count0 = 0
    count1 = 0
    for i in range(len(s)):
        if s[i:i+1] == "0":
            count0 += 1
        else:
            count1 += 1
    print(2*min([count0,count1]))

Measured memory_bytes: 3188
import sys

ERROR_INPUT = 'input is invalid'


def main():
    n = get_length()
    arr = get_array(length=n)

    insetionSort(li=arr, length=n)
    return 0


def get_length():
    n = int(input())
    if n < 0 or n > 100:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def get_array(length):
    nums = input().split(' ')
    return [str2int(string=n) for n in nums]


def str2int(string):
    n = int(string)
    if n < 0 or n > 1000:
        print(ERROR_INPUT)
        sys.exit(1)
    else:
        return n


def insetionSort(li, length):
    for n in range(0, length):
        print(*(sorted(li[0:n + 1]) + li[n + 1:length]))


main()

Measured memory_bytes: 5976
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    int N;
    cin>>N;
    double dN=N;
    if(N%2==0)cout<<0.5<<endl;
    else cout<<(dN+1)/(2*dN)<<endl;
    return 0;
}

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

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N,A,B;
	cin >> N >> A >> B;
	A--;B--;
	vector<vector<int>> g(N);
	vector<int> da(N),db(N);
	da[A] = 1;
	db[B] = 1;
	rep(i,N-1){
		int a,b;
		cin >> a >> b;
		a--;b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	queue<int> q,q2;
	q.push(A);
	while(!q.empty()){
		int now = q.front();q.pop();
		for(int i=0;i<g[now].size();i++){
			int next = g[now][i];
			if(da[next])continue;
			da[next] = da[now] + 1;
			q.push(next);
		}
	}
	q.push(B);
	while(!q.empty()){
		int now = q.front();q.pop();
		for(int i=0;i<g[now].size();i++){
			int next = g[now][i];
			if(db[next])continue;
			db[next] = db[now] + 1;
			q.push(next);
		}
	}
	int mx = 0;
	int p  = -1;
	rep(i,N){
		if(da[i]<db[i])mx = max(mx,db[i]);
	}
	cout << mx - 2 << endl;
}


Measured memory_bytes: 6656
raw = input()
l = len(raw)
from collections import deque
s = deque()
for i in range(l):
  s.append(raw[i])
#print(s)
n = int(input())
cnt = 0
for _ in range(n):
  tmp = input().split()
  if tmp[0] == '1':
    cnt = 1 - cnt
  else:
    t = int(tmp[1]) - 1
    t ^= cnt
    if t == 1:
      s.append(tmp[2])
    else:
      s.appendleft(tmp[2])
#print(s)
#print(cnt)
ans = ''
if cnt == 1:
  s.reverse()
for x in s:
  ans += x
print(ans)

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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

ll sub1(ll u, ll mask) {
  ll oldu = u;
  ll poke = 1;
  int pos = 0;
  REP(i, 0, 64) {
    if (mask & (1LL << i)) {
      continue;
    }
    pos++;
  }
  for (int i = 63; i >= 0; --i) {
    if (mask & (1LL << i)) {
      if (u & (1LL << i)) {
	u = (1LL << i) - 1;
      }
      continue;
    }
    pos--;
    if (u & (1LL << i)) {
      poke += 1LL << pos;
    }
  }
  return poke;
}

ll solve(ll);

ll segm(ll a, ll b) {
  ll res = solve(b) - solve(a - 1);
  res = (res + mod) % mod;
  return res;
}

map<ll, ll> memo;

ll solve(ll n) {
  if (memo.count(n)) {
    return memo[n];
  }
  memo[n] = 0;
  ll &ret = memo[n];
  if (n <= 1) {
    return ret = n + 1;
  }
  ll highest = 1;
  while (n >= highest) { highest *= 2; }
  if (n + 1 == highest) {
    ll sub = solve(n / 2);
    return ret = (3 *sub + mod - 1) % mod;
  }
  highest /= 2; // power of 2, n >= highest
  ll tot = solve(highest - 1);
  tot += segm(2 * highest - 2 - n, highest - 2);
  tot %= mod;
  tot += solve(n - highest);
  tot %= mod;
  if(0) {
    cerr << "solve(" << n << ")=" << tot << endl;
  }
  return ret = tot;
}
int main(void){
  ll n;
  cin >> n;
  ll tot = 0;
  cout << solve(n) << endl;
}


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

int main() {
	string  str;
	int GK;
	long bufG = 0,bufK = 0;
	cin >> str;
	for(long i = 1;i<=str.length();i++){
		if(str[i-1] == 'R'){
			if(GK = i%2)
				bufK++;
			else
				bufG++;
			//if(i==str.length()-1) あり得ない
			if(str[i] == 'R'){
				cout << "0";
			}else{
				for(long j = 1;i+j<=str.length();j++){
					if(str[i+j-1]=='R')break;
					if((i+j)%2)
						bufK++;
					else
						bufG++;
				}
				if(GK){
					cout << bufK << " " << bufG;
				}else{
					cout << bufG << " " << bufK;
				}
				bufK = 0;
				bufG = 0;
				i++;
			}
		}else{
			cout << "0";
		}
		if(i >= str.length()-1)
			cout << "\n";
		else
			cout << " ";
	}
	return 0;
}

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

int main(){
  char a,b,c;
  int ans = 700;
  cin >> a >> b >> c;
  if (a=='o') ans+=100;
  if (b=='o') ans+=100;
  if (c=='o') ans+=100;
  cout << ans << endl;
}

Measured memory_bytes: 256
//
// Created by admin on 2020/8/2.
//
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n,d,x,y,ans;
signed main()
{
    scanf("%lld%lld",&n,&d);
    d=labs(d*d);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        x=labs(x*x);y=labs(y*y);
        if(x+y<=d)
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3812
#include<cstdio>
using namespace std;
int main() {
  int w;
  char s[1001];
  scanf("%s", s);
  scanf("%d", &w);
  for (int i = 0; s[i] != 0; i++) if (i % w == 0) printf("%c", s[i]);
  printf("\n");
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
    int a;
    cin>>a;
    
    cout<<a+a*a+a*a*a<<endl;
}



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

int main(){
  int m, n, k, x, foodpoint[31]={0}, sum=0;
  cin >> n >> m;
  for(int i=0; i < n; i++){
    cin >> k;
    for(int j=0; j < k; j++){
      cin >> x;
      foodpoint[x]++;
    }
  }
  for(int i=1; i <= m; i++){
    if(foodpoint[i] == n){
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans, temp;
  ans = 0;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  for (int i; i < N; i++) {
    cin >> A.at(i);
  }
  for (int i; i < N; i++) {
    cin >> B.at(i);
  }
  for (int i; i < N-1; i++) {
    cin >> C.at(i);
  }
  for (int i; i < N; i++) {
    temp = A.at(i) - 1;
    ans += B.at(temp);
    if (i < N && i > 0) {
      if (A.at(i) - A.at(i-1) == 1) {
        ans += C.at(A.at(i-1)-1);
      }
    }
  } 
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
from itertools import *
from functools import *
from collections import *
from heapq import heapify, heappop, heappush, heappushpop

# from math import gcd


def gcd(a, b):
    """
    Greatest Common Divisor
    Euclidean Algortihm
    """
    if a < b:
        gcd(b, a)
    while b != 0:
        a, b = b, a % b
    return a


INF = float('inf')
NIL = - 1

N = int(input())
ans = 0
for i in range(1, N + 1):
    if i == 1:
        ans += N ** 2
        continue
    for j in range(1, N + 1):
        if j == 1:
            ans += N
            continue
        tmp = gcd(i, j)
        if tmp == 1:
            ans += N
            continue
        for k in range(1, N + 1):
            if k == 1:
                ans += 1
                continue
            ans += gcd(tmp, k)

print(ans)


Measured memory_bytes: 9580
/**
 * C - Pyramid
 * https://atcoder.jp/contests/abc112/tasks/abc112_c
 **/
#include<iostream>
#include<vector>
#include<cmath>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<ll> x(n), y(n), h(n);
    for(int i=0; i<n; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    vector<pair<pair<ll, ll>, ll>> kouho;
    for(int i=0; i<n; i++) {
        if(h[i]==0) continue;
        for(ll cx=0; cx<101; cx++) {
            for(ll cy=0; cy<101; cy++) {
                ll H = h[i] + abs(x[i]-cx)+abs(y[i]-cy);
                if(H>=1) {
                    kouho.push_back(pair<pair<ll,ll>, ll>(pair<ll,ll>(cx, cy), H));
                }
            }
        }
    }
    for(int i=0; i<n; i++) {
        vector<pair<pair<ll, ll>, ll>> next_kouho;
        for(auto p:kouho) {
            ll cx = p.first.first;
            ll cy = p.first.second;
            ll H = p.second;
            if(max(H-abs(x[i]-cx)-abs(y[i]-cy), (ll)0)==h[i]) {
                next_kouho.push_back(pair<pair<ll,ll>,ll>(pair<ll,ll>(cx, cy), H));
            }
        }
        kouho = next_kouho;
        if(kouho.size()==1) break;
    }
    ll cx = kouho[0].first.first;
    ll cy = kouho[0].first.second;
    ll H = kouho[0].second;
    cout << cx << " " << cy << " " << H << endl;
    return 0;
}

Measured memory_bytes: 35684
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var S string
	fmt.Scan(&S)

	N := len(S)
	MOD := int(math.Pow10(9)) + 7

	ans := make([][]int, 2)
	for i := 0; i < 2; i++ {
		ans[i] = make([]int, 13)
	}
	ans[0][0] = 1

	pow10Mod := [6]int{}
	for i := 0; i < 6; i++ {
		pow10Mod[i] = int(math.Pow10(i)) % 13
	}

	for i, s := range S {
		s := string(s)
		if s == "?" {
			for j := 0; j < 10; j++ {
				plus := (pow10Mod[(N-1-i)%6] * j) % 13
				for k := 0; k < 13; k++ {
					ans[1][(k+plus)%13] += ans[0][k]
				}
			}
		} else {
			s, _ := strconv.Atoi(s)
			plus := (pow10Mod[(N-1-i)%6] * s) % 13
			for k := 0; k < 13; k++ {
				ans[1][(k+plus)%13] += ans[0][k]
			}
		}

		for k := 0; k < 13; k++ {
			ans[0][k] = ans[1][k] % MOD
			ans[1][k] = 0
		}
	}

	fmt.Println(ans[0][5])
}


Measured memory_bytes: 1664
from math import ceil,sqrt
def main():
    
    # for _ in range(ii()):
    
    # t=int(input())
    # n,m=map(int,input().split())
    # a=list(map(int,input().split()))
    
    
    
    
    
    s=input()
    if(s[2]==s[3] and s[4]==s[5]):
        print('Yes')
    else:
        print('No')
    
    
    
    
    
    
    
    
    




    
if __name__ =="__main__":
    main()

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

int h,w,n;
vector<string> mp(31);
vector<string> tmp;

bool cal(){
 bool f=1;
  while(f){
    f=0;
    for(int i=0;i<w;i++)
      for(int j=1;j<h;j++)
	for(int k=j;k>0;k--)
	  if(mp[k][i]=='.'&&mp[k-1][i]!='.')swap(mp[k][i],mp[k-1][i]),f=1;
    
    bool used[30][30]={};
    for(int i=0;i<h;i++){
      int c=1,p=0;
      for(int j=1;j<=w;j++)
	if(mp[i][p]==mp[i][j])c++;
	else if(c<n)c=1,p=j;
	else {
	  for(int k=0;k<c;k++)used[i][p+k]=1;
	  c=1,p=j;
	}
    }
        
  for(int i=0;i<w;i++){
    int c=1,p=0;
    for(int j=1;j<=h;j++)
      if(mp[p][i]==mp[j][i])c++;
      else if(c<n)c=1,p=j;
      else {
	for(int k=0;k<c;k++)used[p+k][i]=1;
	c=1,p=j;
      }
  }
  
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)if(used[i][j])mp[i][j]='.';
    for(int i=0;i<w;i++)
      for(int j=1;j<h;j++)
	for(int k=j;k>0;k--)
	  if(mp[k][i]=='.'&&mp[k-1][i]!='.')swap(mp[k][i],mp[k-1][i]),f=1;
  }
  
  bool res=1;
  for(int i=0;i<w;i++)res&=mp[h-1][i]=='.';
  return res;
}


bool solve(int x,int y){
  mp=tmp;
  if(x+1<w)swap(mp[y][x],mp[y][x+1]);
  return cal();
}

int main(){
  cin>>h>>w>>n;
  for(int i=0;i<h;i++)cin>>mp[i],mp[i]+='?';
  mp[h]="???????????????????????????????";
  tmp=mp;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(solve(j,i)){cout<<"YES"<<endl;return 0;}
  
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

vector<vector<bool>> cnt;
vector<vector<ll>> nextr;

void path(int s, int g) {
    vector<int> path;
    for (int cur = s; cur != g; cur = nextr[cur][g]) {
        path.push_back(cur);
    }
    path.push_back(g);
    repd(i, 1, path.size()) {
        cnt[path[i - 1]][path[i]] = false;
    }
}
int main()
{
    int N, M;
    cin >> N >> M;

    vector<vector<ll>> d(N, vector<ll>(N, INF));
    nextr = vector<vector<ll>>(N, vector<ll>(N, 0));
    cnt = vector<vector<bool>>(N, vector<bool>(N, false));

    rep(i, N) d[i][i] = 0;
    rep(i, M) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
        cnt[a][b] = true;
        cnt[b][a] = true;
    }

    rep(i, N) {
        rep(j, N) {
            nextr[i][j] = j;
        }
    }

    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                    nextr[i][j] = nextr[i][k];
                }
            }
        }
    }

    ll ans = 0;
    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            path(i, j);
        }
    }

    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            if (cnt[i][j]) ans++;
        }
    }

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

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

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, set it in Settings(Ctrl+,) in "Icie Template List" entry 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int m,d;
    cin>>m;
    cin>>d;
    int c=0;
    for(int i=4; i<=m;i++){
        for(int j=10;j<=d;j++){
            int a=j%10;
            int b=(j/10)%10;
            if(i == a*b && a>=2 && b>=2) {
                c++;
               
            }
        }
    }
    cout << c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (2e5 + 5)
#define mod (int) 1000000007

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

lli a[limit],b[limit],sa[limit],sb[limit];
int main()
{
    // ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    lli n,m,k;
    cin >> n >> m >> k;

    // cout << k << "\n";

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

    for (int i = 0; i < m; ++i)
    {
        cin >> b[i];
    }

    sa[0] = a[0];
    sb[0] = b[0];

    sa[n] = sb[m] = INT_MAX;

    // cout << sa[n] << "\n";

    for (int i = 1; i < n; ++i)
    {
        sa[i] = sa[i-1]+a[i];
    }

    for (int i = 1; i < m; ++i)
    {
        sb[i] = sb[i-1]+b[i];
    }

    lli ca=0;
    lli ans = 0;

    for (lli i = m-1; i >= 0; --i)
    {
        if (sb[i]+sa[n-1] <= k)
        {
            ans = max(ans,i+1+n);
            continue;
        }

        while(sb[i] + sa[ca+1] <= k && ca < n-1)
        {
            ca++;

            if (ca == n-1)
            {
                break;
            }
        }

        if (sb[i] + sa[ca] <= k)
        {
            // cout << i << " " << ca << "\n"; 
            ans = max(ans,i+ca+2);        
        }
    }

    for (lli i = 0; i < n; ++i)
    {
        if (sa[i] <= k)
        {
            ans = max(ans ,i+1 );
        }
    }

    for (lli i = 0; i < m; ++i)
    {
        if (sb[i] <= k)
        {
            ans = max(ans ,i+1);
        }
    }


    cout << ans;
    return 0;
}





















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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1e9;

const ll INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}


int main(){
  string s,t;cin>>s>>t;
  string u;
  cout<< u;
  rep(i,t.size()-1)u.pb(t[i]);
  if(u==s)cout<<"Yes";
  else cout<<"No";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<uint64_t> h(n);
  for(vector<uint64_t>::iterator it = h.begin(); it != h.end(); ++it) {
    cin >> (*it);
  }
  if(n <= k) cout << 0 << endl;
  else {
    sort(h.begin(), h.end());
    cout << accumulate(h.begin(), h.end() - k, 0UL) << endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>

#define IOS ios::sync_with_stdio(false); cin.tie(0)

using namespace std;

int main()
{
	char c;
	cin >> c;
	if (c < 91) cout << "A";
	else cout << "a";
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main(){
	int N; cin >> N;
	vector<int> a;
	
	REP(i,N){
		int n; cin >> n;
		a.push_back(n);
	}

	sort( a.begin(), a.end() );

	cout << a[N-1] - a[0] << endl;

	return 0;
}


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

int main() {
  int a, b, x;
  cin >> a;
  cin >> b;
  x = a*b % 2;
  if (x == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>

int n,d;
int x[100][100];
int ans=0;

void f(int i,int j){
  int sum=0;
  rep(k,d){
    sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
  }

  int res=sqrt(sum);
  if(res*res==sum) ans++;
}


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

  
  cin>>n>>d;
  rep(i,n){
    rep(j,d){
      cin>>x[i][j];
    }
  }

  rep(i,n){
    FOR(j,i+1,n){
      f(i,j);
    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int S(int);
int main(void){
    int N;
    scanf("%d", &N);
    if(N%S(N)==0) printf("Yes\n");
    else printf("No\n");
    return 0;
}
int S(int n){
    int i, w=0;
    while(n!=0){
        w += n%10;
        n /= 10;
    }
    return w;
}


Measured memory_bytes: 128
N = int(input())
a = map(int, input().split())
rate_under = []
rate_upper = []
for i in a:
    x = i // 400
    if(x >= 8):
        rate_upper.append(x)
    else:
        rate_under.append(x)
min = len(set(rate_under))
max = min + len(rate_upper)
if(min == 0):
    min = 1
print(str(min) + " " + str(max))

Measured memory_bytes: 3064
/*
By Tianyi Chen. All rights reserved.
Date: 2017-04-29
*/
#include<bits/stdc++.h>
using namespace std;
int n,W,w,v,ans;
map<int,int>wv;
int main(){
 scanf("%d%d",&n,&W);
 wv[0]=0;
 while(n--){
  scanf("%d%d",&w,&v);
  for(auto it=--wv.end();;--it){
   if(it->first+w<=W)wv[it->first+w]=max(wv[it->first+w],it->second+v);
   if(it==wv.begin())break;
  }
 }
 for(auto&&x:wv)ans=max(ans,x.second);
 printf("%d\n",ans);
}

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

vector<bool> primes;
const int MAXV = 1e5;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> list(n, 0);
    while (k--) {
        int d;
        cin >> d;
        for (int i = 0; i < d; i++) {
            int a;
            cin >> a;
            list[a-1] = 1;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (list[i] == 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
/*
 Abu Jafor Mohammad Saleh
 ios_base :: sync_with_stdio(false);
 cin.tie(NULL);
 
 */

#include<cstdio>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<limits>
#include <algorithm>
#include <unordered_map>
#include<fstream>
#define f first
#define s second
#define MOD 1000003

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define BOUNDARY(i, j) ((i >= 0 && i < rows) && (j >= 0 && j < coloums))

//#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
const int maxn = 100001;
using namespace std;
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
int rows,coloums;
long long  gcd(long long  a, long long b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{
    fast;
    ll n,m;
    cin>>n>>m;
    
    ll x = (n*(n-1))/2;
    ll y = (m*(m-1))/2;
    cout<<(x+y)<<endl;
    
}


Measured memory_bytes: 384
// ABC142_B
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18（const int inf   = 1<<29;）

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, K;
    cin >> N >> K;
    vector<ll> vec(N);
    REP(i, N) cin >> vec[i];
    
    // calculation
    ll res = 0;
    REP(i, N) {
        if (vec[i] >= K) res++;
    }
    cout << res << "\n";
    
    return 0;
}

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

// input
int H, W;
vector<string> S;

char s[52][52];
int w[50][50];


void input() {
    cin >> H >> W;
    S = vector<string>(H);
    rep(i, H) cin >> S[i];
}


int solve(int i, int j) {
    int ret = 0;
    rep(a, 3) rep(b, 3) {
        if (a == 1 && b == 1) continue;
        if (s[i + a - 1][j + b - 1] == '#') ret++;
    }
    return ret;
}


int main() {
    input();
    rep(i, 52) rep(j, 52) s[i][j] = '.';
    rep(i, H) rep(j, W) s[i + 1][j + 1] = S[i][j];
    rep(i, H) rep(j, W) {
        if (s[i + 1][j + 1] == '.') w[i][j] = solve(i + 1, j + 1);
    }
    rep(i, H) {
        rep(j, W) {
            if (S[i][j] == '#') cout << '#';
            else cout << w[i][j];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3668
#include<iostream>
using namespace std;
int main(){
    int x,y,n;
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0)break;
        if(x < y){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        } 
    }
}


Measured memory_bytes: 3076