akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int dat[1000][4];
int type[300];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),a){
		for(int i=0;i<a+b+c;i++)type[i]=2;
		int n;
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d%d%d%d",&dat[i][0],&dat[i][1],&dat[i][2],&dat[i][3]);
		}
		for(int j=0;j<n;j++){
		for(int i=0;i<n;i++){
			if(dat[i][3]==1){
				type[dat[i][0]-1]=1;
				type[dat[i][1]-1]=1;
				type[dat[i][2]-1]=1;
			}else if(dat[i][3]==0&&type[dat[i][0]-1]==1&&type[dat[i][1]-1]==1){
				type[dat[i][2]-1]=0;
			}else if(dat[i][3]==0&&type[dat[i][2]-1]==1&&type[dat[i][1]-1]==1){
				type[dat[i][0]-1]=0;
			}else if(dat[i][3]==0&&type[dat[i][0]-1]==1&&type[dat[i][2]-1]==1){
				type[dat[i][1]-1]=0;
			}
		}
		}
		for(int i=0;i<a+b+c;i++)printf("%d\n",type[i]);
	}
}

Measured memory_bytes: 0
a, b, c = map(int, input().split())

if a%2 == 0 and a==b==c:
    print(-1)
    exit()

i = 0
a_, b_, c_ = a, b, c

while a%2 == 0 and b%2 == 0 and c%2 == 0:
    i += 1
    a = b_//2 + c_//2
    b = a_//2 + c_//2
    c = a_//2 + b_//2
    a_, b_, c_ = a, b, c

print(i)

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

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

  n = fmodl(n, k);
  
  if(n > abs(n-k)){
    n = abs(n-k);
  }

  cout << n << endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

A = li()

for i in range(len(A)):
    if A[i] == 0:
        print(i+1)
        exit()

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

const int maxn = 2e5 + 13;

int a[maxn];

signed main () {
    int n;
    scanf("%d", &n);
    bool shit = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        shit = shit || i < a[i] || (i && a[i] > a[i - 1] + 1);
    }
    if (shit)
        cout << "-1\n";
    else {
        long long ans = 0;
        for (int i = 1; i < n; ++i) {
            if (a[i] > a[i - 1])
                ++ans;
            else
                ans += a[i];
        }
        printf("%lld\n", ans);
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int max_N = 12;

int N, M, A[max_N], B[max_N];
char c[max_N][max_N];

int num(char c1, char c2) {
	return (c1 - 'a') * 100 + (c2 - 'a');
}

int used[max_N][3000], g[max_N][max_N], was[max_N];

void rec(int n) {
	if (n == N / 2) {
		int m = 0, cur = 0, pt = 0;
		while (cur < N) {
			if (pt < n && cur == A[pt]) {
				pt++;
			}	else {
				B[m++] = cur;
			}
			cur++;
		}
		do {
			memset(& g, 0, sizeof(g));
			memset(& was, 0, sizeof(was));
			for (int i = 0; i < n; i++) {
				int a = A[i], b = B[i];
				for (int j = 0; j < M; j++) {
					int need = num(c[b][j], c[a][j]);
					for (int k = 0; k < j; k++) {
						if (used[k][need]) {
							g[k][j]++;
						}
					}
					used[j][num(c[a][j], c[b][j])] = 1;
				}
				for (int j = 0; j < M; j++) {
					used[j][num(c[a][j], c[b][j])] = 0;
				}
			}
			if (m == n + 1) {
				int b = B[m - 1];
				for (int i = 0; i < M; i++) {
					for (int j = 0; j < i; j++) {
						if (c[b][i] == c[b][j]) {
							g[j][i]++;
						}
					}
				}
			}
			int cnt = 0, bad = -1;
			for (int i = 0; i < M; i++) {
				if (was[i]) {
					continue;
				}
				int paired = 0;
				for (int j = i + 1; j < M; j++) {
					if (g[i][j] == m) {
						cnt++;
						was[j] = 1;
						paired = 1;
						break;
					}
				}
				if (!paired) {
					bad = i;
				}
			}
			if (M % 2 == 0 && cnt == M / 2) {
				cout << "YES";
				exit(0);
			}
			if (M % 2 == 1 && cnt == M / 2) {
				assert(bad != -1);
				int ok = 1;
				for (int i = 0; i < n; i++) {
					int a = A[i], b = B[i];
					if (c[a][bad] != c[b][bad]) {
						ok = 0;
						break;
					}
				}
				if (ok) {
					cout << "YES";
					exit(0);
				}
			}
		}	while (next_permutation(B, B + m));
		return;
	}
	int last = -1;
	if (n > 0) {
		last = A[n - 1];
	}
	for (int i = last + 1; i < N; i++) {
		A[n] = i;
		rec(n + 1);
		A[n] = 0;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> c[i][j];
		}
	}
	rec(0);
	cout << "NO";
}


Measured memory_bytes: 384
import sys
import collections
n = int(input())
z = [list(map(int, input().split())) for _ in range(n)]
z.sort()
pq_pattern = []
pq_counter = [1]*(n-1)*n

if n == 1:
    print(1)
    sys.exit()

for i in range(n):
    for j in range(n):
        if not i == j:
            if [z[j][0] - z[i][0], z[j][1] - z[i][1]] in pq_pattern:
                #print("YES!")
                pq_counter[pq_pattern.index([z[j][0] - z[i][0], z[j][1] - z[i][1]])] += 1
            else:
                pq_pattern.append([z[j][0] - z[i][0], z[j][1] - z[i][1]])
print(n-max(pq_counter))

Measured memory_bytes: 3700
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define ort (b+s)/2
#define y2 asrwjaelkf
#define y1 asseopirwjaelkf
#define set multiset
 
using namespace std;
 
typedef long long Lint;
typedef pair<Lint,Lint> ii;
typedef pair<int,char> ic;
typedef pair<ii,int> iii;
typedef pair<ii,ii> i4;
 
const int maxn = 1000020;
const int maxm = 10000020;
const int MOd = 998244353;

int a, b;
string s, s2;
vector<int> w[maxn];
int used[maxn];

int gcd( int x, int y ) {
	if( y == 0 ) return x;
	return gcd( y, x%y );
}

void solve() {
	scanf("%d",&a);
	for(int i=2;i<=1e6;i++) {
		if( w[i].size() ) continue;
		for(int j=i;j<=1e6;j+=i)
			w[j].pb(i);
	}
	int pw = 1, gc = 0;
	for(int i=1,k;i<=a;i++) {
		scanf("%d",&k);
		for(int j=0;j<w[k].size();j++) {
			if( used[w[k][j]] ) pw = 0;
			used[w[k][j]] = 1;
		}
		gc = gcd( k, gc );
	}
	if( pw == 1 ) printf("pairwise coprime\n");
	else if( gc == 1 ) printf("setwise coprime\n");
	else printf("not coprime\n");
}
 
int main() {
	int n = 1;
	// scanf("%d",&n);
	while( n-- ) solve();
 
	return 0;
}

Measured memory_bytes: 63068
import bisect
n = int(input())
s = input()
s_list = [[] for _ in range(10)]
for i in range(n):
    s_list[int(s[i])].append(i)
for i in range(10):
    s_list[i].sort()

can_use = [[0 for _ in range(10)] for _ in range(10)]

ans = 0
for i in range(1000):
    thisS = str(i)
    while len(thisS) < 3:
        # print(thisS)
        thisS = "0" + thisS

    if len(s_list[int(thisS[0])]) == 0:
        continue
    now_point = s_list[int(thisS[0])][0]
    # print(thisS, now_point)
    tmp = 0
    for j in range(2):
        tmp = 0
        now = int(thisS[j])
        next = int(thisS[j + 1])
        for k in range(len(s_list[next])):
            if s_list[next][k] > now_point:
                now_point = s_list[next][k]
                tmp = 1
                break
        if tmp == 0:
            break
    ans += tmp

print(ans)

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

using namespace std;



int main() {
    int N, M; cin >> N >> M;
    vector<int> x(M);
    for (int i = 0; i < M; i++) cin >> x[i];
    sort(x.begin(), x.end());

    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> d(M-1);
    for (int i = 0; i < M-1; i++) d[i] = x[i+1]-x[i];
    sort(d.begin(), d.end(), greater<int>());
    
    int ans = 0;
    for (int i = N-1; i < M-1; i++) ans += d[i];

    cout << ans << endl;

}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

class UnionFindTree{
private:
  int* mParent;
  int* mRank;
  int mSize;

public:
  UnionFindTree(int n){
    mSize = n;
    mParent = new int[n];
    mRank = new int[n];

    for(int i=0; i < n; i++){
      mParent[i] = i;
      mRank[i] = 0;
    }
  }

  ~UnionFindTree(){
    delete[] mParent;
    delete[] mRank;
  }

  bool same(int lhs,int rhs){
    return (find(lhs) == find(rhs) ? true : false);
  }

  int find(int pos){
    if(pos == mParent[pos]) return pos;
    return find(mParent[pos]);
  }
  
  void unite(int lhs,int rhs){
    lhs = find(lhs);
    rhs = find(rhs);
    
    if(lhs == rhs) return;
    
    if(mRank[lhs] > mRank[rhs]){
      mParent[lhs] = rhs;
      mRank[lhs] = 0;
      mRank[rhs]++;
    }
    else{
      mParent[rhs] = lhs;
      mRank[rhs] = 0;
      mRank[lhs]++;
    }
  }

  int size() const{
    return mSize;
  }
};

class State{
public:
  int from;
  int to;
  int cost;
  State(int _f,int _t,int _c) :
    from(_f), to(_t), cost(_c) {}
  bool operator<(const State& s) const{
    return cost < s.cost;
  }
  bool operator>(const State& s) const{
    return cost > s.cost;
  }
};

int main(){
  int num_of_nodes;
  int num_of_edges;
  while(~scanf("%d %d",&num_of_nodes,&num_of_edges)){
    if(num_of_nodes == 0 && num_of_edges == 0) break;

    priority_queue<State,vector<State>,greater<State> > que;
    for(int edge_idx = 0; edge_idx < num_of_edges; edge_idx++){
      int from,to,cost;
      scanf("%d %d %d",&from,&to,&cost);
      from--; to--;
      que.push(State(from,to,cost));
    }

    UnionFindTree uft(num_of_nodes);

    vector<int> log;
    while(!que.empty()){
      State s = que.top();
      que.pop();
      if(!uft.same(s.from,s.to)){
        uft.unite(s.from,s.to);
        log.push_back(s.cost);
      }
    }

    printf("%d\n",log[log.size()/2]);
  }
}

Measured memory_bytes: 1416
#include <stdio.h>
int main(){
 
  int d[6],i,blank;
  char NEWS[100];
 
  for(i = 0; i < 6; i++){
 
    scanf("%d",&d[i]);
 
  }
 
  scanf("%s",NEWS);
   
  for(i = 0; NEWS[i] != '\0'; i++){
 
    if(NEWS[i] == 'N'){
 
      blank=d[0];
      d[0]=d[1];
      d[1]=d[5];
      d[5]=d[4];
      d[4]=blank;
 
    }
 
    if(NEWS[i] == 'E'){
 
      blank=d[0];
      d[0]=d[3];
      d[3]=d[5];
      d[5]=d[2];
      d[2]=blank;
 
    }
 
    if(NEWS[i] == 'S'){
 
      blank=d[0];
      d[0]=d[4];
      d[4]=d[5];
      d[5]=d[1];
      d[1]=blank;
 
    }
 
    if(NEWS[i] == 'W'){
 
      blank=d[0];
      d[0]=d[2];
      d[2]=d[5];
      d[5]=d[3];
      d[3]=blank;
 
    }
 
  }
   
  printf("%d\n",d[0]);
 
  return 0;
 
}


Measured memory_bytes: 2056
n = int(input())
l = list(map(int, input().split()))


ans = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            a = l[i], l[j], l[k]
            a = sorted(a, reverse=True)
            if a[0] == a[1] or a[1] == a[2]:
                continue
            if a[0] < a[1] + a[2]:
                ans += 1
print(ans)

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

int main ( )
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define pii pair<int,int>
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 2e5;
priority_queue<pii,vector<pii>,greater<pii> > que;
int nxt[N+3],prv[N+3];
int a[N+3];
llong cl[N+3],cr[N+3],cl2[N+3],cr2[N+3];
vector<int> vec;
int n,m; llong ans;

void solve(int l,int r)
{
//	printf("solve %d %d\n",l,r);
	llong sum = 0ll;
	for(int i=m-1; i<vec.size(); i++)
	{
		sum += cl[vec[i-m+1]];
		ans += cr[vec[i]]*sum;
	}
	int cnt = vec.size()/m;
	for(int i=l; i<=l+cnt-1; i++) cl2[i] = cr2[i] = 0ll;
	for(int i=vec.size()-m,j=0,k=l+cnt-1; i>=0; i--)
	{
		cl2[k] += cl[vec[i]];
		if(j==m-1) {k--,j=0;}
		else {j++;}
	}
	for(int i=m-1,j=0,k=l; i<vec.size(); i++)
	{
		cr2[k] += cr[vec[i]];
		if(j==m-1) {k++,j=0;}
		else {j++;}
	}
	for(int i=l; i<=l+cnt-1; i++) cl[i] = cl2[i],cr[i] = cr2[i];
	sum = 0ll;
	for(int i=l+m-1; i<=l+cnt-1; i++)
	{
		sum += cl[i-m+1];
		ans -= cr[i]*sum;
	}
	if(cnt==0)
	{
		nxt[prv[l]] = n+1; prv[nxt[r]] = 0;
	}
	else
	{
		nxt[l+cnt-1] = nxt[r]; prv[nxt[r]] = l+cnt-1;
		for(int i=l; i<l+cnt-1; i++) nxt[i] = i+1;
		for(int i=l+1; i<=l+cnt-1; i++) prv[i] = i-1;
		int val = a[l]; for(int i=l; i<=l+cnt-1; i++) a[i] = val+1;
		for(int i=l; i<=l+cnt-1; i++) que.push(mkpr(a[i],i));
	}
//	printf("cnt=%d\n",cnt);
//	printf("prv: "); for(int i=1; i<=n+1; i++) printf("[%d]%d ",i,prv[i]); puts("");
//	printf("nxt: "); for(int i=0; i<=n; i++) printf("[%d]%d ",i,nxt[i]); puts("");
//	printf("cl: "); for(int i=1; i<=n; i++) printf("[%d]%lld ",i,cl[i]); puts("");
//	printf("cr: "); for(int i=1; i<=n; i++) printf("[%d]%lld ",i,cr[i]); puts("");
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++) scanf("%d",&a[i]),que.push(mkpr(a[i],i)),cl[i] = cr[i] = 1ll,nxt[i] = i+1,prv[i] = i-1;
	nxt[0] = 1,prv[n+1] = n;
	while(1)
	{
		int l = que.top().second,r = l; que.pop(); vec.clear(); vec.push_back(l);
		while(!que.empty() && que.top().first==a[l] && que.top().second==nxt[r]) {r = nxt[r]; vec.push_back(r); que.pop();}
		solve(l,r);
		if(que.empty()) break;
	}
	printf("%lld\n",ans+n);
	return 0;
}
/*
4 3
4 3 4 4
*/

Measured memory_bytes: 11248
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N);

    vector<i64> lis(N + 5, INF);
    lis.front() = 0;

    rep(i, 0, N) {
        var(int, a);
        auto itr = lower_bound(all(lis), a - 1);
        if (*itr != a - 1) continue;
        *next(itr) = a;
    }

    dump(lis);

    const int len = lower_bound(all(lis), INF) - begin(lis) - 1;
    if (len <= 0) {
        print(-1);
    } else {
        print(N - len);
    }

    return 0;
}


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

int main()
{
    int n, a;
    cin >> n;
    vector<int> vec(n);
    map<int, int> map;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        map[a] = i;
    }

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

Measured memory_bytes: 5888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
ll len[1001], cnt[1001][26];
int cntS[200001][26], cntX[400001][26];
vector<int> Z_algo(string &s) {
	int n = s.size();
	vector<int> z(n);
	int L = 0, R = 0;
	for (int i = 1; i < n; i++) {
		if (i > R) {
			L = R = i;
			while (R < n && s[R - L] == s[R]) R++;
			z[i] = R - L; R--;
		}
		else {
			int k = i - L;
			if (z[k] < R - i + 1) z[i] = z[k];
			else {
				L = i;
				while (R < n && s[R - L] == s[R]) R++;
				z[i] = R - L; R--;
			}
		}
	}
	return z;
}
ll solve(int k, int ch, ll L) {
	if (L > len[k]) return cnt[k][ch] + solve(k, ch, L - len[k]);
	if (L == len[k]) return cnt[k][ch];
	if (k == 0) return cntS[L][ch];
	if (k == 1) return cntX[L][ch];
	if (L > len[k - 1]) return cnt[k - 1][ch] + solve(k - 2, ch, L - len[k - 1]);
	return solve(k - 1, ch, L);
}
int main() {
	string S;
	cin >> S;
	ll l, r;
	cin >> l >> r;
	S = S.substr(0, S.size() / 2);
	vector<int> z = Z_algo(S);
	int k = 1;
	while (k < S.size()) {
		if (S.size() - k == z[k]) break;
		k++;
	}
	if (k == 0) k = S.size();
	string T = S.substr(0, k);
	string X = S + T;
	len[0] = S.size();
	len[1] = X.size();
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 26; j++) cntS[i + 1][j] += cntS[i][j];
		cntS[i + 1][S[i] - 'a']++;
	}
	for (int i = 0; i < X.size(); i++) {
		for (int j = 0; j < 26; j++) cntX[i + 1][j] += cntX[i][j];
		cntX[i + 1][X[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		cnt[0][i] = cntS[S.size()][i];
		cnt[1][i] = cntX[X.size()][i];
	}
	k = 0;
	while (len[k] * 2 < r) {
		if (k > 0) {
			len[k + 1] = len[k] + len[k - 1];
			for (int i = 0; i < 26; i++) cnt[k + 1][i] = cnt[k][i] + cnt[k - 1][i];
		}
		k++;
	}
	for (int i = 0; i < 26; i++) {
		cout << solve(k, i, r) - solve(k, i, l - 1) << " ";
	}
	cout << endl;
}

Measured memory_bytes: 33856
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  bool flag = true;
  scanf("%d", &n);
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  for(int i = 0; i < n-1; i++) {
    if(a.at(i) == a.at(i+1)) {
      flag = false;
      break;
    }
  }
  if(flag) printf("YES\n");
  else printf("NO\n");
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define reps(i, n) for (int i = 1; i <= (n); ++i)
#define repd(i, n) for (int i = (n)-1; i >= 0; --i)
#define repds(i, n) for (int i = (n); i > 0; --i)
#define loop(i, x, n) for (int i = (x); i < (n); ++i)
#define loops(i, x, n) for (int i = (x); i <= (n); ++i)
#define loopd(i, x, n) for (int i = (x); i > (n); --i)
#define loopds(i, x, n) for (int i = (x); i >= (n); --i)
#define itrep(i, a) for (auto i = begin(a); i != end(a); ++i)
#define itrepd(i, a) for (auto i = rbegin(a); i != rend(a); ++i)
#define each(i, x) for (auto &&i : x)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(a) ((int)a.size())
#define pow2(n) (n * n)
#define int ll
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
constexpr double eps = 1e-9;
ll mod = static_cast<ll>(1e9 + 7);
template <class T, class... Args>
constexpr void mins(T &a, Args... args) { a = min<T>({a, args...}); }
template <class T, class... Args>
constexpr void maxs(T &a, Args... args) { a = max<T>({a, args...}); }
template <class F>
class FixPoint : private F {
public:
    explicit constexpr FixPoint(F &&f) : F(std::forward<F>(f)) {}
    template <class... Args>
    constexpr decltype(auto) operator()(Args &&... args) const { return F::operator()(*this, std::forward<Args>(args)...); }
};
template <class F>
constexpr decltype(auto) funcs(F &&f) { return FixPoint<F>{std::forward<F>(f)}; }
template <class T>
std::vector<T> vecs(int n, T &&val) { return std::vector<T>(std::forward<int>(n), std::forward<T>(val)); }
template <class... Args>
decltype(auto) vecs(int n, Args &&... args) { return std::vector<decltype(vecs(std::forward<Args>(args)...))>(std::forward<int>(n), vecs(std::forward<Args>(args)...)); }
template <class V, class T>
void fill(V &x, const T &val) { x = val; }
template <class V, class T>
void fill(vector<V> &vec, const T &val) {
    for (auto &&v : vec)
        fill(v, val);
}

void solve() {
    int n;
    cin >> n;

    int m = 1;
    int cnt = 1;
    while (m * 26 < n) {
        m *= 26;
        n -= m;
        cnt += 1;
    }

    string s;
    n -= 1;
    while (n) {
        s += 'a' + n % 26;
        n /= 26;
    }
    s += string(cnt - sz(s), 'a');
    reverse(all(s));
    cout << s << endl;
}

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

Measured memory_bytes: 3652
def main():
    n,x,m=map(int,input().split())
    visited=[0]*m
    visit_sum=[0]*m
    i=1
    sm=x
    visited[x]=1
    visit_sum[x]=x
    work=x
    while i < n:
        work**=2
        work%=m
        sm+=work
        i+=1
#        print(sm,work)
        if not visited[work]:
            visited[work]=i
            visit_sum[work]=sm
        else :
            break
    else :
        print(sm)
        exit()
    loop_sum=sm-visit_sum[work]
    loop_num=i-visited[work]
    if visited[work]!=1: 
        initial_sum=visit_sum[visited.index(visited[work]-1)]
    else :
        initial_sum=0

    out=initial_sum
#    print(out)
    out+=(n-visited[work]+1)//loop_num*loop_sum
#    print(out)
    work_num=(n-visited[work]+1)%loop_num
    if work_num>0:
        out+=visit_sum[visited.index(visited[work]-1+work_num)]-initial_sum
        
    print(out)

main()


Measured memory_bytes: 14036
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{

		//List<int> a = new List<int>();
		//List<int> b = new List<int>();

		//string[] s = Console.ReadLine().Split(' ');

		//long a = long.Parse(s[0]);

        double a = double.Parse(Console.ReadLine());


        Console.WriteLine("{0} {1}", a * a * Math.PI,(double)2 * a * Math.PI);

		//Console.WriteLine("");


	}
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    if(S.substr(0, 4) == "YAKI") cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3612
using System;
class C_Savers{
	static void Main(string[] args){
		int N = int.Parse(Console.ReadLine());
		string[] sA = Console.ReadLine().Split(' ');
		string[] sB = Console.ReadLine().Split(' ');
		long[] A = new long[N + 1];
		long[] B = new long[N];
		for(int i = 0;i < N;i++){
			A[i] = long.Parse(sA[i]);
			B[i] = long.Parse(sB[i]);
		}
		A[N] = long.Parse(sA[N]);
		long Kill = 0;
		for(int i = 0;i < N;i++){
			if(A[i] >= B[i]){
				A[i] -= B[i];
				Kill += B[i];
				B[i] = 0;
			} else {
				B[i] -= A[i];
				Kill += A[i];
				A[i] = 0;
				if(A[i + 1] >= B[i]){
					A[i + 1] -= B[i];
					Kill += B[i];
					B[i] = 0;
				} else {
					B[i] -= A[i + 1];
					Kill += A[i + 1];
					A[i + 1] = 0;
				}
			}
		}
		Console.WriteLine(Kill);
	}
}

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


int main() {
    string s;
	int n; cin >> n>> s;
    int cnt=0;
	for (int i=0;i < n;i++){
      if (s[i]=='A'){
        if (i+1>=n || i+2 >= n) continue;
        if (s[i+1] =='B' && s[i+2]=='C') cnt++;
      }
    }
	cout << cnt << endl;
	return 0;
	
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
using ll = long long;
using P = pair<int, int>;

const int mod = 998244353;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

mint f(int n){ 
  if(n == 0)return 1;
  mint x = f(n / 2); 
  x *= x; 
  if(n % 2 == 1)x *= 2;
  return x;
}

mint choose(int n, int a){
  mint x = 1, y = 1;
  for(int i = 0; i < a; ++i){
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

mint dp[3010][3010][3];

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

  mint ans = 0;
  vector<mint> q(s + 1);
  for(int i = 0; i < n; ++i){
    q[0] += 1; 
    vector<mint> q2(s + 1);
    for(int j = 0; j <= s; ++j){
      q2[j] += q[j];
      if(j + a[i] <= s)q2[j + a[i]] += q[j];
    }
    q = q2;
    ans += q[s];
  }
  
  cout << ans.x << endl;
  
  return 0;
}


Measured memory_bytes: 212608
#include<bits/stdc++.h>
using namespace std;
     
#define int long long
#define hell 1000000007 
#define endl "\n"
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define MAX_SIZE 100001


 
int min(int a, int b)
{
    if(a>b)
        return b;
    return a;
}
     
int max(int a, int b)
{    
    if(a>b)
        return a;
    return b;
}


int32_t main()
{
    int n,x;
    cin>>n;
    int a=n;
    vector<int> v;

    float sum=0.0;

    while(n--)
    {
        cin>>x;
        v.push_back(x);
    }

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

    sum += (1.0*(v[0]+v[1]))/pow(2, a-1);

    for(int i=2;i<a;i++)
    {
        sum+= (1.0*v[i])/pow(2, a-i);

    }

    cout<<sum;


return 0;
}   	

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

int main() {
  ll N;
  ll sum=0,mx;
  vi A(300000);
  cin>>N;
  rep(i,N) cin>>A[i];
  mx=A[0];
  rep(i,N) {
    if(mx>A[i]) sum+=mx-A[i];
    if(A[i]>mx) mx=A[i];
  }
  cout<<sum<<endl;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    int n;
    cin >> n;
    int l[n], r[n];
    rep(i, n) cin >> l[i] >> r[i];
    ll cnt = 0;
    rep(i, n)
    {
        cnt += r[i] - l[i] + 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    string s,t;
    cin>>s>>t;
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							     \
			cout.tie(0);
#define sz(arr) ll(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }
ll kCn(ll k, ll n, ll f[]) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

int main() {
	//#ifndef ONLINE_JUDGE
	//	(void)freopen("input.txt", "r", stdin);
	//	(void)freopen("output.txt", "w", stdout);
	//#endif // !ONLINE_JUDGE
	fastio;
	string s, t;
	cin >> s >> t;
	t.pop_back();
	if (s == t)
		cout << "Yes";
	else cout << "No";

	
	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#define MAX 10000
#define NIL -1
struct Node{
  int p,l,r;
};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL)return ;
  printf(" %d",u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL)return;
  inParse(T[u].l);
  printf(" %d",u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL)return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main(){
  int i,v,l,r,root;
  scanf("%d", &n);
  for(i=0;i<n;i++)T[i].p=NIL;

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL)T[l].p=v;
    if(r!=NIL)T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL)root=i;
  }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



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

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    sort(v.begin(), v.end(), greater<int>());

    long long ans = 0;
    for (int i = 1; i < n; i++) {
        ans += v[i/2];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4044
//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<int, int> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
vector< ii > vec;
const int maxn = 2e5+5;
int ans[maxn];
int main()
{
    int n; cin >> n;
    for(int i = 0; i< n; i++)
    {
        int x; cin >> x;
        vec.pb(ii(x, i));
    }
    sort(vec.begin(), vec.end());
    for(int i = 0; i< n/2; i++)
    {
        ans[vec[i].Y] = vec[n/2].X;
    }
    for(int i = n/2; i< n; i++)
    {
        ans[vec[i].Y] = vec[n/2-1].X;
    }
    for(int i = 0; i< n; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 4720
def main():
    N = int(input())
    a,b,c = [0]*N,[0]*N,[0]*N
    for i in range(N):
        a[i],b[i],c[i] = map(int, input().split())

    # dp[i][j] := i日目までの活動履歴のうち、最終日であるi日目には活動j(0:A,1:B,2:C)を選んだ場合の、得られる幸福度の最大値
    dp = [[0]*3 for _ in range(N)]
    dp[0] = (a[0],b[0],c[0])
    for i in range(1,N):
        dp[i][0] = max(dp[i-1][2]+a[i], dp[i-1][1]+a[i])
        dp[i][1] = max(dp[i-1][2]+b[i], dp[i-1][0]+b[i])
        dp[i][2] = max(dp[i-1][1]+c[i], dp[i-1][0]+c[i])
    print(max(dp[-1]))


main()


Measured memory_bytes: 34636
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
using P = pair<int,int>;
int main(){
    int N;
    cin>>N;
    map<P,int> M;
    for(int i=0;i<N;i++){
        int x,y,w;
        cin>>x>>y>>w;
        M[P(x,y)]=w;
    }
    int ans = 0;
    for(auto p:M){
        int x,y;
        tie(x,y)=p.first;
        int sum = p.second;
        if(M.find(P(x+1,y))!=M.end()) sum+=M[P(x+1,y)];
        if(M.find(P(x,y+1))!=M.end()) sum+=M[P(x,y+1)];
        if(M.find(P(x+1,y+1))!=M.end()) sum+=M[P(x+1,y+1)];
        ans = max(ans,sum);
        sum = p.second;
        if(M.find(P(x-1,y))!=M.end()) sum+=M[P(x-1,y)];
        if(M.find(P(x,y-1))!=M.end()) sum+=M[P(x,y-1)];
        if(M.find(P(x-1,y-1))!=M.end()) sum+=M[P(x-1,y-1)];
        ans = max(ans,sum);
        sum = p.second;
        if(M.find(P(x+1,y))!=M.end()) sum+=M[P(x+1,y)];
        if(M.find(P(x,y-1))!=M.end()) sum+=M[P(x,y-1)];
        if(M.find(P(x+1,y-1))!=M.end()) sum+=M[P(x+1,y-1)];
        ans = max(ans,sum);
        sum = p.second;
        if(M.find(P(x-1,y))!=M.end()) sum+=M[P(x-1,y)];
        if(M.find(P(x,y+1))!=M.end()) sum+=M[P(x,y+1)];
        if(M.find(P(x-1,y+1))!=M.end()) sum+=M[P(x-1,y+1)];
        ans = max(ans,sum);
    }
    cout<<ans<<" / 1"<<endl;
    return 0;
}

Measured memory_bytes: 9336
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int al[26] = {};
    string s; cin>>s;
    rep(i,s.size()){
        al[s[i]-'a']++;
    }
    rep(i,26){
        if(al[i] == 0){
            cout<<char('a'+i)<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	bool num[31] = { false };
	int n;
	while (cin >> n) {
		num[n] = true;
	}
	for (int i = 1; i <= 30; ++i) {
		if (num[i] == false)
			cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 3024
from collections import defaultdict
H,W = map(int, input().split())
S = [input() for _ in range(H)]
es = defaultdict(list)

for i in range(H):
    for j in range(W):
        if j < W-1 and S[i][j] != S[i][j+1]:
            es[(i,j)].append((i,j+1))
            es[(i,j+1)].append((i,j))
        if i < H-1 and S[i][j] != S[i+1][j]:
            es[(i,j)].append((i+1, j))
            es[(i+1,j)].append((i, j))

checked = [[False for _ in range(W)] for _ in range(H)]

ans = 0
for i in range(H):
    for j in range(W):
        if checked[i][j]:
            continue
        checked[i][j] =  True
        cnt_b = 0
        cnt_w = 0
        if S[i][j] == "#":
            cnt_b += 1
        else:
            cnt_w += 1
        stack = es[(i,j)]

        while True:
            ns = []
            for p,q in stack:
                
                if checked[p][q] == False:
                    checked[p][q] = True
                    if S[p][q] == "#":
                        cnt_b += 1
                    else:
                        cnt_w += 1
                    ns.extend(es[(p,q)])

                
            if len(ns) == 0:
                break
            else:
                stack = ns
        ans += cnt_b * cnt_w

print(ans)

Measured memory_bytes: 86584
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>(V[I])
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>(V1[I])>>(V2[I]);
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>(V1[I])>>(V2[I])>>(V3[I]);
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}

int a,b,h;
inline void solve(){
  IN3(a,b,h);
  OUT((a+b)*h/2);
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
nums = list(map(str, range(10)))
a, b = map(int, input().split())
s = input()
cnt = 0
for i in range(a):
    if s[i] in nums:
        cnt+=1
if s[a] == "-":
    cnt += 1
for i in range(a+1,a+b+1):
    if s[i] in nums:
        cnt += 1

print("Yes") if cnt == a+b+1 else print("No")

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

int main()
{
    int n;
    cin>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    if(prev_permutation(a.begin(),a.end())){REP(i,n){if(i!=0)cout<<" ";cout<<a[i];}cout<<endl;}
    next_permutation(a.begin(),a.end());
    REP(i,n){if(i!=0)cout<<" ";cout<<a[i];}cout<<endl;
    if(next_permutation(a.begin(),a.end())){REP(i,n){if(i!=0)cout<<" ";cout<<a[i];}cout<<endl;}
}


Measured memory_bytes: 3108
# coding: utf-8
# Your code here!


n,m,p = map(int,input().split())

el = []
for _ in range(m):
    a,b,c = map(int,input().split())
    el.append((a-1,b-1,c-p))
cost = [-float("inf") for _ in range(n)]
cost[0] = 0
for i in range(2*n):
    for j in range(m):
        e = el[j]
        if cost[e[1]] < cost[e[0]] + e[2]:
            cost[e[1]] = cost[e[0]] + e[2]
            if i >= n:
                cost[e[1]] = float("inf")
    if i == n-1:
        ans = cost[-1]
        
              
if ans != cost[-1]:
    print(-1)
else:
    print(max(ans, 0))
        

Measured memory_bytes: 53080
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cassert>

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P>::iterator ITE;
struct data{
  ll num;
  vector<P> MEM;
  data(){}
  data(int n,vector<P> m):num(n),MEM(m){}
  bool operator < (const data& d) const {return num < d.num;}
};

const ll MAX = 10000000000000LL;
vector<P> Free;
vector<data> V;

void init(){

  Free.clear();
  Free.push_back(P(0,MAX));
  V.clear();

}

void write(ll a, ll b){
  sort(Free.begin(),Free.end());
  vector<P> tmp;

  for(int i = 0; i < (int)Free.size(); i++){
    if(Free[i].second-Free[i].first+1 > b){
      tmp.push_back(P(Free[i].first, Free[i].first+b-1));
      Free[i].first += b;
      break;
    }else{
      tmp.push_back(Free[i]);
      b -= Free[i].second-Free[i].first+1;
      vector<P>::iterator ite = (ITE)&Free[i];
      Free.erase(ite);
      i--;
    }
  }
  V.push_back(data(a,tmp));
}

void del(ll num){

  sort(V.begin(),V.end());
  vector<data>::iterator ite = lower_bound(V.begin(),V.end(),data(num,vector<P>()));
  if(ite->num != num) assert(false);

  for(int i = 0; i < (int)ite->MEM.size(); i++)
    Free.push_back(ite->MEM[i]);

  V.erase(ite);

}

void ref(ll num){
  for(int i = 0; i < (int)V.size(); i++){
    vector<P> tmp = V[i].MEM;
    for(int j = 0; j < (int)tmp.size(); j++){
      if(tmp[j].first <= num && num <= tmp[j].second){
	cout << V[i].num << endl;
	return;
      }
    }
  }
  
  cout << "-1" << endl;
}

int main(){
  int n;

  while(cin >> n && n){
  
    init();
    while(n--){
      char c;
      cin >> c;
      if(c == 'W'){
	ll a,b;
	cin >> a >> b;
	write(a,b);
      }

      if(c == 'D'){
	ll a;
	cin >> a;
	del(a);
      }

      if(c == 'R'){
	ll a;
	cin >> a;
	ref(a);
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1740
# そもそもNにいくやつ以外はいらないよねって発想
n, m = gets.chomp.split.map(&:to_i)
a2c, b2c = Array.new(n, false), Array.new(n, false)
m.times do
  a, b = gets.chomp.split.map(&:to_i)
  if b==n
    b2c[a-1] = true
  end
  if a==1
    a2c[b-1] = true
  end
end
n.times do |i|
  if a2c[i] == true && b2c[i] == true
    puts "POSSIBLE"
    exit
  end
end
puts "IMPOSSIBLE"

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main() {
    int k;
    cin >> k;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1;
        return 0;
    }
    for (int i = 1, s = 7; i <= k; ++i) {
        if (s % k == 0) {
            cout << i;
            return 0;
        }
        s *= 10;
        s += 7;
        s %= k;
    }
    cout << -1;
}

Measured memory_bytes: 3668
#include <iostream>
#define MAXN 3005
using namespace std;

long long n, a[MAXN], dp[MAXN][MAXN][2];

int main() {
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	for (int i=0; i<n; i++) {
		dp[i][i][0] = a[i];
		dp[i][i][1] = -a[i];
	}
	for (int i=1; i<n; i++) {
		for (int j=0; j<n-i; j++) {
			dp[j][j + i][0] = max(dp[j + 1][j + i][1] + a[j], dp[j][j + i - 1][1] + a[j + i]);
			dp[j][j + i][1] = min(dp[j + 1][j + i][0] - a[j], dp[j][j + i - 1][0] - a[j + i]);
		}
	}
	cout << dp[0][n - 1][0] << "\n";
}


Measured memory_bytes: 139648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll out = 0;
    for (int i = 0; i < N; i++){
      out += a[i] - 1;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3616
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System;

public class P
{
    public int eq { get; set; }
    public int wp { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new int[n];
        var d = new Dictionary<int, P>();
        for (int i = 0; i < n; i++)
        {
            var w = (int)(decimal.Parse(Console.ReadLine().Trim()) * 1000);
            a[i] = w;
            if (d.ContainsKey(w)) d[w].eq++;
            else d[w] = new P { eq = 1 };
        }
        getAns(a, d, n);
    }
    static void getAns(int[] a, Dictionary<int, P> d, int n)
    {
        var less = 0;
        foreach (var x in d.OrderBy(y => y.Key))
        {
            d[x.Key].wp = d[x.Key].eq + less * 3 - 1;
            less += d[x.Key].eq;
        }
        var sb = new StringBuilder();
        foreach (var x in a)
            sb.Append(string.Format("{0}\n", d[x].wp));
        Console.Write(sb);
    }
}



Measured memory_bytes: 27392
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

int n;
int A[100000];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> A[i];
    }
    sort(A, A + n);
    int mnv = 2e9 + 5, mni = -1;
    for (int i = 0; i + 1 < n; ++i) {
        if (abs(A[i] + A[i] - A[n - 1]) < mnv) {
            mnv = abs(A[i] + A[i] - A[n - 1]);
            mni = A[i];
        }
    }
    printf("%d %d\n", A[n - 1], mni);
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;
int main()
{
	vector<string>v;

	string s;
	int K;

	cin >> s >> K;

	for (int i = 0; i < s.size(); i++) {
		string cur;
		for (int j = 0; j < K; j++) {
			cur = s.substr(i, j + 1);
			v.push_back(cur);
		}
	}

	sort(v.begin(), v.end());
	unique(v.begin(), v.end());

	cout << v[K - 1];

	return 0;
}


Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = Integer.parseInt(br.readLine());
		String S = br.readLine();
		
		
		int l=0;
		int r=0;
		
		//'('
		for(int i=0; i<N; i++){
			if (S.charAt(i)=='('){
				l += 1;
			} else {
				l -= 1;
				if(l<0){l=0;}
			}
		}
		
		//')'
		for(int i=N-1; 0<=i; i--){
			if (S.charAt(i)==')'){
				r += 1;
			} else {
				r -= 1;
				if(r<0){r=0;}
			}
		}
		

		StringBuilder sbr = new StringBuilder();
		for(int i=0; i<r; i++) { sbr.append('('); }

		StringBuilder sbl = new StringBuilder();
		for(int i=0; i<l; i++) { sbl.append(')'); }

		String ans = sbr.toString() + S + sbl.toString();
		
		
		System.out.println(ans);
		
	return;
	}



}


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

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

	rep(i, max(a,b)) cout << min(a,b);
	cout << endl;

	return 0;
}


Measured memory_bytes: 256