akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
#define Maxn 100010
int a[Maxn];
char str[20];
inline void Query(int x){
    printf("%d\n",x);
    fflush(stdout);
    scanf("%s",str);
    if(str[0]=='V')exit(0);
    if(str[0]=='M')a[x]=1;
    else a[x]=2;
}

inline bool legal(int x,int y){
    if((y-x)&1){
        if(a[x]==a[y])return true;
        else return false;
    }else{
        if(a[x]!=a[y])return true;
        else return false;
    }
}

int main(){
    scanf("%d",&n);
    Query(0);Query(n-1);
    int l=0,r=n-1;
    while(r-l>1){
        int mid=(l+r)>>1;
        Query(mid);
        if(legal(l,mid))r=mid;
        else l=mid;
    }
    return 0;
}

Measured memory_bytes: 852
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, W; cin >> N >> W;
  vector<int> v(N, 0);
  vector<int> w(N, 0);
  vector<vector<int> > dp(N+1, vector<int>(W+1, 0));
  REP(i, N){
    cin >> v[i] >> w[i];
  }
  REP(i, N){
    REP(j, W+1){
      int ni = i + 1;
      chmax(dp[ni][j], dp[i][j]);
      int nj = j + w[i];
      if(nj > W) continue;
      chmax(dp[ni][nj], dp[i][j]+v[i]);
      chmax(dp[ni][nj], dp[ni][j]+v[i]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 6824
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int y = stoi(s.substr(0, 4));
    int m = stoi(s.substr(5, 2));
    int d = stoi(s.substr(8, 2));
    if (y < 2019)
        return cout << "Heisei" ,0;
    if (y > 2019)
        return cout << "TBD", 0;
    if (m < 4)
        return cout << "Heisei", 0;
    if (m > 4)
        return cout << "TBD", 0;
    if (d <= 30)
        return cout << "Heisei", 0;
    cout << "TBD";
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String str = sc.next();
        char[] c = str.toCharArray();
        int count = 0;

        if (N%2 == 0) {
            for (int i = 0; i < N / 2; i++) {
                if (c[i] == c[N/2 + i]) {
                    count++;
                    
                }
            }
                if (count == N / 2) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            System.out.println("No");
        }


    }
}

Measured memory_bytes: 22100
package main

import (
	"fmt"
	//"math"
	//"strings"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a > b {
		tmp := a
		a = b
		b = tmp
	}
	if b > c {
		tmp := b
		b = c
		c = tmp
	}
	if a > b {
		tmp := a
		a = b
		b = tmp
	}
	fmt.Println(int(a*b/2))
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


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

void dfs(int h, int w) {
	islands[h][w] = '0';

	for (int i = 0; i < 4; i++) {

		if (h + dx[i] >= 0 && h + dx[i] <= 12 && w + dy[i] >= 0 && w + dy[i] <= 12 && islands[h + dx[i]][w + dy[i]] == '1') {

			dfs(h + dx[i], w + dy[i]);

		}

	}


}


int main() {

	string a;

	while (cin >> a) {

		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				islands[i][j] = a[j];
			}
			if (i != 11)cin >> a;
		}

		int ans = 0; 
		for (int i = 0; i < 12; i++) {
			for (int j = 0; j < 12; j++) {
				if (islands[i][j] == '1')dfs(i, j), ans++;
			}
		}

		cout << ans << endl;

	}





}



Measured memory_bytes: 3004
#include<iostream>
#include<string>
//#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
//#include<set>
//#include<map>
//#include<list>
//#include<bitset>
#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
//array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
//array<int, 4>dir_x2 = { 0,0,1,-1 };
//array<int, 4>dir_y2 = { 1,-1,0,0 };
//char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//LLI gcd(LLI x, LLI y) {
//	LLI  r;
//	if (x < y) {
//		swap(x, y);
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}
//LLI lcm(LLI x, LLI y) {
//	return x / gcd(x, y) * y;
//}

//long nCr(int n, int r) {
//	long ans = 1;
//	for (int i = n; i > n - r; i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl

int main(void) {
	LLI A, B, C, N;
	bool res = false;
	string S;
	cin >> S;
	for (int i = 0; i < 3;i++) {
		if (S[i] == S[i + 1]) {
			res = true;
		}
	}

	if (res) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define all(v) (v).begin(), (v).end()
using namespace std;
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define int long long
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lll __int128
#define pii pair<int, int>
#define fi first
#define se second
#define mp make_pair
const int mod = 1e9+7;
inline int ksm(int a,int b){int ans=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ans=ans*a%mod;return ans;}
signed main()
{
	int n,a,b;cin>>n>>a>>b;
	int ans=ksm(2,n)-1;int now=1;
	rep(i,1,min(n,200000ll)){
		now=now*(n-i+1)%mod*ksm(i,mod-2)%mod;
		if(i==a || i==b)ans=(ans-now)%mod;
	}
	cout<<(ans+mod)%mod<<endl;
	
	
		getchar();
	getchar();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;

const int MAX_N = 100;
int N;
int x[MAX_N], y[MAX_N], h[MAX_N];


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

  cin >> N;
  rep(i, N) cin >> x[i] >> y[i] >> h[i];

  vector<Pii> v;
  rep(i, N) v.push_back(Pii(h[i], i));
  sort(all(v));

  for (int i = 0; i <= 100; ++i) {
    for (int j = 0; j <= 100; ++j) {
      int H = -1, mi = INFINT;
      bool judge = true;
      for (int k = 0; k < N; ++k) {
        int l = v[k].sc;
        if (h[l] == 0) {
          mi = min(mi, abs(i-x[l])+abs(j-y[l]));
        } else {
          int r = abs(i-x[l])+abs(j-y[l]);
          if (r > mi) {
            judge = false; break;
          } else {
            if (H < 0) H = r + h[l];
            else {
              if (H != r + h[l]) {
                judge = false; break;
              } 
            }
          }
        }
      }
      if (judge) {
        cout << i << ' ' << j << ' ' << H << endl;
      }
    }
  }
}



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

int a[20];
int b[50];
int c[50];
int main(){
    int n; 
    cin >> n;
    for(int i=0;i<n;++i){
        int in; cin >> in;
        a[i] = in;
    }
    for(int i=0;i<n;++i){
        int in; cin >> in;
        b[i] = in;
    }
    for(int i=0;i<n;++i){
        int in; cin >> in;
        c[i] = in;
    }

    int previous=9999;
    int sum = 0;

    for(int i=0;i<n;++i){
        int dish=a[i];
        int value=b[dish-1];
        sum +=value;
        if(dish==previous+1){
            sum += c[previous-1];
        }
        previous = dish;
    }

    cout << sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[1<<17], suf[1<<17];

int main() {
  int n;
  cin >> n;
  for(int i = 0; i <= n; i++) cin >> a[i];
  for(int i = n; ~i; i--) suf[i] = suf[i+1] + a[i];
  
  ll now = 1, ans = 0;
  for(int i = 0; i <= n; i++) {
    if(now < a[i]) puts("-1"), exit(0);
    ans += now;
    now -= a[i];
    now = min(now * 2, suf[i+1]);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int N;
  string S;
  cin >>N >> S;
  vector<ll> P(26,0);
  for(int i=0;i<N;i++){
    P[S[i]-'a'] ++;
  }
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  ll ans=0;
  for(int i=0;i<26;i++){
    ans = ans*((P[i]+1)%Q)%Q;
    ans = (ans+P[i])%Q;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<stdio.h>

int main(void){


    int a, b, c, i, n=0;


    scanf("%d %d %d",&a,&b,&c);


    for(i=a;i<=b;i++){


        if((c%i)==0){


            n++;


        }


    }


    printf("%d\n",n);


    return 0;


}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
const int N=1e2+20;
int n,b[N],a[N];
int main()
{
	cin>>n;
	for(int i=1;i<=n-1;i++) cin>>b[i];

	for(int i=n-1;i>=1;i--)
	{
		if(i==n-1) a[i]=a[i+1]=b[i];
		else if(a[i+1]>b[i]) a[i+1]=b[i];
		a[i]=b[i];
	}
	cout<<accumulate(a+1,a+n+1,0);
}

Measured memory_bytes: 256
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

// #pragma GCC optimize("O3")
// #pragma GCC target("avx")
// #pragma GCC optimize("Ofast")
// // #pragma GCC optimize("unroll-loops")
// // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
	for (auto x : v)      \
	{                     \
		cout << x << " "; \
	}
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
	ll t;     \
	cin >> t; \
	while (t--)
#define FIO                           \
	freopen("input.txt", "r", stdin); \
	freopen("output.txt", "w", stdout);
#define FAST                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
	freopen((prob + ".in").c_str(), "r", stdin);
	freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
	if (n < 2)
		return false;
	for (int x = 2; x * x <= n; x++)
	{
		if (n % x == 0)
			return false;
	}
	return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
	vector<int> f;
	for (int x = 2; x * x <= n; x++)
	{
		while (n % x == 0)
		{
			f.push_back(x);
			n /= x;
		}
	}
	if (n > 1)
		f.push_back(n);
	return f;
}

void solve()
{
	/* Write Solution Here */
	ll n, x, t;
	cin >> n >> x >> t;
	ll k = ceil((float)(n) / x);
	cout << k * t << "\n";
}

int main()
{
	//FIO
	//FAST

	//usaco("cowlands");

	ll TC = 1;
	/*
	Uncomment when multiple test cases
	*/

	// cin>>TC;
	for1(tt, TC)
	{
		solve();
	}
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

int main()
{
	int n;
	int i;
	
	cin >> n;
	int a[n];
	
	for(i=0;i<n;i++)
		cin >> a[i];
	
	for(i=n-1;i>0;i--)
		cout << a[i] << ' ';
	
	cout << a[0] << endl;
	
	return 0;
}

Measured memory_bytes: 1164
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()

a = ['z'] + [chr(ord('a')+i) for i in range(25)]
ans = []
while n:
    ans.append(a[n%26])
    n = (n-1)//26

ans.reverse()
print(''.join(ans))


Measured memory_bytes: 61972
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;

const ll MX = 1e18;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (n % 2 == 1) {
		cout << b[n / 2] - a[n / 2] + 1 << endl;
	}
	else {
		cout << b[n / 2]+ b[n / 2 - 1] - a[n / 2]-a[n / 2 - 1] + 1 << endl;
	}
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;

const int INF = 1001001001;

int main(){
    int n,m;
    cin >> n>> m;
    ve<pair<int,int>> key;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        int s = 0;
        rep(j,b){
            int c;
            cin >> c;
            --c;
            s |= 1<<c;
        }
        key.push_back({s,a});
    }
    
    ve<int> dp(1<<n,INF);
    
    dp[0] = 0;
    rep(s,1<<n){
        rep(i,m){
            int t = s | key[i].fi;
            int cost = dp[s] + key[i].se;
            dp[t] = min(dp[t],cost);
        }
        
        
    }
    
    int ans = dp.back();
    if(ans == INF) ans= -1;
    cout << ans << endl;
    
    
    
    



    return 0;
}


Measured memory_bytes: 256
from math import factorial

N, K = map(int, input().split())

# コンビネーションを計算
def calcCombination(m, n):
    return factorial(m) // (factorial(n) * factorial(m-n))

for i in range(1, K+1):
    if N-K+1 < i:
        print(0)
    else:
        print(calcCombination(N-K+1, i) * calcCombination(K-1, i-1) % (10**9+7))


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 057 C / Link: http://abc057.contest.atcoder.jp/tasks/abc057_c  ----- */

vector<LL> getdivisor(LL n) {
	vector<LL> res;
	for (LL i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			res.push_back(i);
			if (n / i != i)res.push_back(n / i);
		}
	}
	sort(res.begin(), res.end());
	return res;
}

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

	LL N; 
	cin >> N;
	auto divs = getdivisor(N);
	LL ans = LINF;
	auto f = [](LL a,LL  b) {
		string A = to_string(a);
		string B = to_string(b);
		return (LL)max(SZ(A), SZ(B));
	};
	for (auto i : divs) {
		ans = min(ans, f(i, N / i));
	}
	
	cout << (ans) << "\n";

	return 0;
}


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

int N, M;
set<vector<int>> SE;

void dfs(vector<int> A, int depth) {
  if (depth == N) {
    SE.insert(A);
    return;
  }
  int Max;
  if (A.empty()) {
    Max = 1;
  } else {
    Max  = *max_element(A.begin(), A.end());
  }
  for (int i = Max; i <= M; i++) {
    vector<int> newA = A;
    newA.push_back(i);
    dfs(newA, depth + 1);
  }
}

int main() {
  cin >> N >> M;
  vector<int> A;
  dfs(A, 0);

  int Q;
  cin >> Q;
  vector<int> a(Q), b(Q), c(Q), d(Q);
  for (int i = 0; i < Q; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
  }

  int ans = 0;
  for (auto A : SE) {
    int sum = 0;
    for (int i = 0; i < Q; i++) {
      if (A.at(b.at(i) - 1) - A.at(a.at(i) - 1) == c.at(i)) {
        sum += d.at(i);
      }
    }
    ans = max(ans, sum);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 13752
#include <iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

int retl(int K,int L){
    int tmp=0;
    while(pow(2,tmp) * L < K){
        tmp++;
    }
    return tmp;
}

struct A{
    string s;
    int p;
    int order;
};


int main(){
    string S;
    cin  >> S;
  
    int answer=0;

    FOR(i,S.size()){
        if(S[i]=='o'){
            answer++;
        }
    }
    if(answer + (15-S.size())>=8){
        cout <<"YES"<<endl;
    }else{
        cout <<"NO"<<endl;
    }

    

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long t[100005],dp[100005];
main()
{
	int p,k;
	scanf("%d%d",&p,&k);
	for(int i = 1;i <= p;i++)
	{
		scanf("%lld",&dp[i]);
	}
	//k=2;
	
	for(int i = 0;i <= 100003;i++)
	t[i]=1e15;
	t[1]=0;
	for(int i = 1;i <= p;i++)
	{
		for(int j = 1;j <= k && i+j <= p;j++)
		{
			t[i+j]=min(t[i]+abs(dp[i]-dp[i+j]),t[i+j]);
		}
	}
	printf("%lld",t[p]);
}

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

vector<int> hi(100000);
vector<int> cost(100000);

void cost_fn(int n, int k)
{
	for(int i = 1; i <= n; i++)
	{
		int loops = min(i,k);
		cost[i] = INT_MAX;

		for(int j = 1; j <= loops; j++)
		{
			int temp = abs(hi[i]-hi[i-j]) + cost[i-j];
			cost[i] = min(cost[i], temp);
		}

	}

	cout << cost[n] << endl;
}

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

	for(int i = 0; i < n; i++)
		cin >> hi[i];
	cost_fn(n-1,k);
	return 0;
}


Measured memory_bytes: 1152
#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字くらい使った方がいいかも
*/


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

    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
// ll gcd(ll a, ll b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
// ll f(ll x) {
// 	x%=MOD;
// 	if(x<0)x+=MOD;
// 	return x;
// }
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = f(prod*b);
// 		}
// 		b = f(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
// struct line {
//     int m, c;
//     ll eval(int x) { return 1LL * m * x + c; }
//     double intersectX(line l) { return (double) (c - l.c) / (l.m - m); }
// };

int n;
map<int,int> m;
void solve() {
	scanf("%d",&n);
	ll ans = 0;
	for (int i = 0, a; i < n; i++) {
		scanf("%d",&a);
		ans += m[i-a];
		m[i+a]++;
	}
	printf("%lld\n",ans);
}
int main() {

	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 20788
import sys
readline = sys.stdin.readline
from collections import deque
H,W = list(map(int, input().split()))
matrix = []
blocks = 0
for _ in range(H):
  # row = list(input())
  row = readline().rstrip()
  blocks += row.count("#")
  matrix.append(row)

q = deque([(0,0,0)])
min_step = -1
# visited = []
visited = [ [False]*W for _ in range(H) ]
visited[0][0] = True

while q:
  r,c,step = q.popleft()
  # visited.append((r,c))
  # visited[r][c] = True

  for i,j in [(1,0),(0,1),(-1,0),(0,-1)]:
    nr,nc = r+i,c+j
    if nr==H-1 and nc==W-1: 
      min_step = step+1
      q = []
      break

    if nr<0 or nc<0 or nr>=H or nc>=W: continue
    if visited[nr][nc] or (nr,nc,step+1) in q: continue
    # if (nr,nc) in visited: continue
    if matrix[nr][nc] == "#": continue
    visited[r][c] = True
    q.append((nr,nc,step+1))

if min_step == -1:
  print(-1)
else:
  print( H*W - blocks - min_step -1 )


Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int N, i;
  cin >> N >> i;
  cout << N - i + 1 << endl;
  return 0;
}


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

int main()
{
    string s;
    long long k;
    cin >> s >> k;
    for(int i=0; i<s.size(); i++){
        if(s[i] != '1' || i == k-1){
            cout << s[i] << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
#define len(n) (int)n.length()
#define dump cout
#define pb push_back
#define ll long long

int main()
{
	ios::sync_with_stdio(false);
	
	string str;
	stack<ll> st;
	while (cin >> str)
	{
		if ((str == "*") || (str == "-") || (str == "+"))
		{
			ll tmp1 = st.top(); st.pop();
			ll tmp2 = st.top(); st.pop();
					ll ans = 0;
			if(str == "*")
			{
				ans = tmp1 * tmp2;
			}
			if(str == "-")
			{
				ans = (-1 * tmp1) + tmp2;
			}
			if(str == "+")
			{
				ans = tmp1 + tmp2;
			}

			st.push(ans);
		}
		else
		{
			st.push(atoll(str.c_str()));
		}
	}
	
	cout << st.top() << endl;
	
	return 0;
}

Measured memory_bytes: 3172
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x3 - dx
y4 = y3 - dy
print("{} {} {} {}".format(x3, y3, x4, y4))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long MOD = 998244353 ;
const long long INF = 1e18;
const int INT_INF   = 1e9 + 8;
int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD, long long tot = 1) {
    for(;exp > 0; exp >>= 1, base = base * base % mod) if((exp & 1) == 1) tot = tot * base % mod;
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD, long long tot = 0) {
    for(;exp > 0; exp >>= 1, base = base * 2 % mod) if((exp & 1) == 1) tot = (tot + base) % mod;
    return tot;
}
struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s; cin >> s;
    int ans = 1;
    if(s[0]=='S' && s[1] == 'U') ans = 7;
    if(s[0]=='M') ans = 6;
    if(s[0]=='T' && s[1] == 'U') ans = 5;
    if(s[0]=='W') ans = 4;
    if(s[0]=='T' && s[1] == 'H') ans = 3;
    if(s[0]=='F') ans = 2;
    cout << ans;
    return 0;

}


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

#define for_(i,a,b) for(int i=a;i<b;++i)

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

int opr(string& S) {
	if (S[0] == 't')  {
		S = S.substr(4);
		return 0;
	}
	
	S = S.substr(5);
	return 1;
}

int main() {
	string S;
	
	while (cin >> S, S != "#") {
		reverse(S.begin(), S.end());
		
		int ans1 = (opr(S)) ? 0 : 90, ans2 = 1;
		
		while (!S.empty()) {
			if (opr(S)) ans1 = 2 * ans1 - 90;
			else ans1 = 2 * ans1 + 90;
			ans2 *= 2;
		}
		
		int dv = gcd(ans1, ans2);
		cout << ans1 / dv;
		if (ans2 / dv != 1) cout << "/" << ans2 / dv;
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef unsigned long long ll;

struct AB{
    ll A;
    ll B;
};

int main(){
    int N,M;
    cin >> N >> M;
    vector<AB> ab(N);
    for(int i=0;i<N;i++){
        cin >> ab[i].A >> ab[i].B;
    }
    sort(ab.begin(),ab.end(),
            [](const AB &x, const AB &y) { return x.A < y.A;});
    ll ans=0;
    for(int i=0,j=0;i<=M;){
        if (M-i <= ab[j].B){
            ans += ab[j].A * (M-i);
            break;
        }else{
            ans += ab[j].A * ab[j].B;
            i+=ab[j].B;
            j++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n, k;
    scanf("%d %d", &n, &k);
    vector<int> p(n);
    for (int i = 0; i < n; ++i) scanf("%d", &p[i]);
    vector<double> ev(n), sumev(n);
    for (int i = 0; i < n; ++i)
    {
        ev[i] = (p[i] + 1.0) / 2.0;
        if (i == 0)
        {
            sumev[0] = ev[0];
        }
        else
        {
            sumev[i] = sumev[i - 1] + ev[i];
        }
        
    }
    double ans = sumev[k - 1];
    for (int i = k; i < n; ++i)
    {
        ans = (max)(ans, sumev[i] - sumev[i - k]);
    } 
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 7208
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int n = 1;
        int count = 0;
        
        if(S.length()  % 2 == 0) {
        	n = S.length();
        } else {
        	n = S.length() - 1;
        }
        
        for(int i =0; i < n/2; i++) {
        	if(S.charAt(i) != S.charAt(S.length()-1-i)) {
        		count ++;
        	}
        }
        
        System.out.println(count);   
        

    }
}






Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c;
  cin >> c;
  string a = "abcdefghijklmnopqrstuvwxyz";
  cout << a[c-'a'+1] << endl;

  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

n,k = map(int,input().split())
a = list(map(int,input().split()))

def arraycount(arr):
    arr_target = [[]]
    cnt = 1
    for i in range(1,len(arr)):
        if arr[i] == arr[i-1]:
            cnt += 1
        else:
            arr_target.append([arr[i-1],cnt])
            cnt = 1
    arr_target.append([arr[len(arr)-1],cnt])
    del arr_target[0]
    return arr_target

a.sort()
a = arraycount(a)


for i in range(len(a)):
    a[i][0],a[i][1] = a[i][1],a[i][0]

a.sort()

need = len(a) - k
answer = 0

for i in range(need):
    answer += a[i][0]

print(answer)


Measured memory_bytes: 31552
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
using namespace std;
template <typename lx> inline void read(lx &x){
	x = 0;int f = 1;char c = getchar();
	for(;c < '0' || '9' < c; c = getchar()) if(c == '-') f = -1;
	for(;'0' <= c && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;return;
}
template <typename lx> inline void print(lx x){
	if(x < 0) putchar('-'),x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + 48);
	return;
}
#define rg register
#define ll long long
#define r_2(a,b) read(a),read(b)
#define r_3(a,b,c) read(a),read(b),read(c)
#define print_n(a) print(a),puts("")
#define print_(a) print(a),putchar(' ')
const int inf = 2147483647;
int a;
char s[20];
int main()
{
	read(a);
	scanf("%s",s);
	if(a >= 3200) cout << s;
	else printf("red");
	return 0;
}

Measured memory_bytes: 256
N,P = map(int,raw_input().split())
arr = []
for i in range(2,int(pow(P,0.5))+1):
    while P%i==0:
        arr.append(i)
        P /= i
if P != 1:
    arr.append(P)
ans = 1
temp = set(arr)
for i in temp:
    cur = arr.count(i)
    for j in range(cur/N):
        ans *= i
print ans

Measured memory_bytes: 34436
S = input()
 
list = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
 
s_index = list.index(S)
 
print(list[s_index+1])

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string w;
  cin >> w;
  map<char, int> cnt;
  for (int i = 0; i < w.size(); i++) {
    cnt[w[i]]++;
  }
  for (auto x : cnt) {
    if (x.second % 2 == 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[12345678], res[12345678];
signed main() {
	vector<char> v; map<int, int> cost;
	int n, m, a, b, c, x, ans = 0; string s, t; double cnt;
	cin >> n >> m;
    vector<vector<int> > G(123456);
    for (int h = 1; h <= m; h++) {
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> que; queue<int> mae;
    for (int i = 0; i < G[1].size(); i++) {
        que.push(G[1][i]); mae.push(1);
        test[G[1][i]] = 1;
    }
    while (que.size()) {
        for (int i = 0; i < G[que.front()].size(); i++) {
            if (test[G[que.front()][i]] == 0) {
                que.push(G[que.front()][i]); mae.push(que.front());
                test[G[que.front()][i]] = que.front();
            }
        }
        que.pop(); mae.pop();
    }
    int z = 0;
    for (int h = 2; h <= n; h++) {
        if (test[h] == 0) { z++; break; }
    }
    if (z != 0) { cout << "No" << endl; return 0; }
    cout << "Yes" << endl;
    for (int h = 2; h <= n; h++) {
        cout << test[h] << endl;
    }
	return 0;
}

Measured memory_bytes: 14112
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,k;
    cin >> n >> k;
    int A[n];
    REP(i,n) cin >> A[i];

    int tentousuu = 0;
    REP(i,n){
        FOR(j,i,n){
            if(A[i] > A[j]){
                tentousuu ++;
            }
        }
    }
    int ans = 0;
    ans = tentousuu * k % MOD;

    int kake = k * (k-1) / 2;
    kake %= MOD;

    int B[2002] = {};
    REP(i,n){
        B[A[i]] ++;
    }

    int total = n;
    REPR(i,2001){
        total -= B[i];
        int hoge = kake * B[i] * total % MOD;
        ans += hoge;
        ans %= MOD;
    }

    cout << ans << endl;



}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int a[105];
int idx[105];

int main() {
	int n;
	cin >> n;
	VI ret(n);
	REP(i, n) scanf("%d", &a[i]);
	REP(i, n)a[i]--;
	REP(i, n)idx[i] = i;
	REP(i, n) {
		bool flag = false;
		for (int j = n - 1; j >= 0; j--) {
			if (a[j] == -1)continue;
			if (idx[j] == a[j]) {
				flag = true;
				ret[n - 1 - i] = a[j];
				int t = idx[j];
				idx[j] = -1;
				a[j] = -1;
				for (int k = j + 1; k < n; k++) {
					if (a[k] != -1)idx[k] = t++;
				}
				break;
			}
		}
		if (!flag) {
			cout << -1 << endl;
			return 0;
		}
	}
	REP(i, n) {
		printf("%d\n", ret[i]+1);
	}
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int n, m;
  cin >> n >> m;
  vector<set<int>> sets(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    sets[a].insert(b);
    sets[b].insert(a);
  }

  bool ans = false;
  for (int i = 0; i < n; i++) {
    if (sets[i].find(0) != sets[i].end() && sets[i].find(n - 1) != sets[i].end()) {
      ans = true;
    }
  }
  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

Measured memory_bytes: 28416
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, buf, cnt[100008];

int main(){
	cin >> n;
	memset(cnt, 0, sizeof(cnt));
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		cin >> buf;
		ans++;
		if(buf <= 100000){
			cnt[buf]++;
			if(cnt[buf] == buf){ans -= buf;}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <queue>
#include <cstdio>
typedef long long LL ;
using namespace std ;
int main()
{
    int M,N;
    while(scanf("%d %d",&N,&M)!=EOF)
    {
        int sum=1;
        for(int i=1;i<=M;i++)
            sum=sum*2;
        int K;
        K=sum*M*1900+(N-M)*sum*100;
        printf("%d\n",K);
    }
    return 0;
}

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

using namespace std;

template <typename T>
void debug_out(T t) {
  cerr << t;
}

template <typename A, typename B>
void debug_out(pair<A, B> u) {
  cerr << "(" << u.first << " " << u.second << ")";
}

template <typename T>
void debug_out(vector<T> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << ", ";
  }
}

template <typename T>
void debug_out(vector<vector<T>> t) {
  int sz = t.size();
  for(int i = 0; i < sz; i++) {
    debug_out(t[i]);
    if(i != sz - 1) cerr << endl;
  }
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:" << endl, debug_out(__VA_ARGS__), cerr << endl;


#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  if(!(n & (n - 1))) {
    cout << "No";
    return 0;
  }
  cout << "Yes\n";
  if(n % 4 == 3) {
    range(i, 0, 2 * n - 1) {
      cout << i + 1 << " " << i + 2 << endl;
    }
    return 0;
  }
  vector<vector<int>> g(2 * n + 1);
  pair<int, int> fix = make_pair(-1, -1);
  auto cc = [&](int x, int y) {
    g[x].push_back(y);
    g[y].push_back(x);
  };
  auto add = [&](int x, int y) {
    int p = x ^ y;
    if(p >= 4 * (n / 4)) return false;
    cc(p, x);
    cc(p, y);
    cc(y, x + n);
    cc(x, y + n);
    return true;
  };
  auto pull = [&](int z) {
    range(i, 1, 4 * (n / 4)) {
      if((z ^ i) < 4 * (n / 4)) {
        cc(i, z);
        cc(z ^ i, z + n);
        fix = make_pair(i, z ^ i);
        return true;
      }
    }
    return false;
  };
  if(n % 4 == 0) {
    assert(pull(n));
  }
  if(n % 4 == 1) {
    assert(add(n, n - 1));
  }
  if(n % 4 == 2) {
    int x = -1, y = -1;
    if(add(n, n - 1)) {
      x = n, y = n - 1;
    } else if(add(n - 1, n - 2)) {
      x = n - 1, y = n - 2;
    } else {
      x = n, y = n - 2;
      assert(add(x, y));
    }
    int z = 3 * n - 3 - x - y;
    if(!pull(z)) {
      int p = z ^ x;
      cc(y, z);
      cc(p, z + n);
      fix = make_pair(x ^ y, p);
    }
  }
  int sz = 4 * (n / 4);
  set<int> a;
  range(i, 1, sz) {
    a.insert(i);
  }
  if(fix.first != -1) {
    a.erase(fix.first); a.erase(fix.second);
  }
  vector<int> b;
  if(fix.first != -1) {
    b.push_back(fix.first);
    b.push_back(fix.second);
  }
  for(int i : a) b.push_back(i);
  int t = b.size();
  range(i, 0, t) b.push_back(b[i] + n);
  int c = -1;
  for(auto i : b) {
    if(c != -1) {
      cc(c, i);
    }
    c = i;
  }
  range(i, 1, 2 * n + 1) {
    for(int j : g[i]) if(j > i) cout << i << " " << j << endl;
  }
  return 0;
}


Measured memory_bytes: 19192
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#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
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int main(void) {
    int num;
    cin >> num;
    int64_t offset = 0;
    vector<int64_t> arr(num);
    vector<int64_t> brr(num);
    for(int i = 0; i < num; i++) {
        cin >> arr[i] >> brr[i];
    }
    for(int i = num-1; i >= 0; i--) {
        int64_t a = arr[i] + offset;
        int64_t b = brr[i];
        a %= b;
        if(a==0) continue;
        offset += (b-a);
    }
    cout << offset << endl;
    return 0;
}

Measured memory_bytes: 4800
res = []

n = int(input())

for i in range(n):
    r = input()
    res.append(r)

ac = res.count("AC")
wa = res.count("WA")
tle = res.count("TLE")
re = res.count("RE")

print("AC x "+str(ac))
print("WA x "+str(wa))
print("TLE x "+str(tle))
print("RE x "+str(re))

Measured memory_bytes: 16276
#
# File    : A.rb
# Author  : Kazune Takahashi
# Created : 11/26/2018, 11:38:28 PM
# Powered by Visual Studio Code
#

a, b, c, d = gets.chomp.split(" ").map{|i| i.to_i}
puts [a * b, c * d].max


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a[100],n,max=0,min;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=0;i<n;i++){
		if(max<=a[i]){
			max=a[i];
		}
	}
	min=max;
	for(int i=0;i<n;i++){
		if(min>=a[i]){
			min=a[i];
		}
	}
	
	cout<<max-min<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl
#define pno cout << "no" << endl
#define pYe cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pYE cout << "YES" << endl
#define pNO cout << "NO" << endl
#define prin(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

int main(void) {
    ll a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    
    cout << a[2]*10+a[0]+a[1] << endl;
}


Measured memory_bytes: 256
#136 B
n=int(input())
if n<10:
    print(n)
elif n<100:
    print(9)
elif n<1000:
    print(9+n-99)
elif n<10000:
    print(909)
elif n<100000:
    print(909+n-9999)
elif n==100000:
    print(90909)

Measured memory_bytes: 2940