akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long X, long long M){
    ll answer = 0;
    ll loopSum = 0, loopCnt = 0;
    ll i = 1, current = X;
    vector<int> lastIndex(M+1, 0);
    vector<ll> sum(M+1);
    while (true) {
        loopSum += current;
        if (i == N) {
            cout << loopSum << endl;
            return;
        }
        if (lastIndex[current] != 0) {
            loopCnt = i - lastIndex[current];
            answer += loopSum - current;
            loopSum = loopSum - sum[current];
            N -= i-1;
            answer += (N / loopCnt) * loopSum;
            N %= loopCnt;
            break;
        }
        sum[current] = loopSum;
        lastIndex[current] = i;
        current = (current*current) % M;
        i++;
    }
    ll s = 0;
    i=0;
    rep(i,0,N) {
        s += current;
        ll next = (current*current) % M;
        current = next;
    }
    answer += s;
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long M;
    scanf("%lld",&M);
    solve(N, X, M);
    return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define iiii pair<int, pii>
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
	int x = 0, p = 1; char c = getchar();
	while (c <= 32) c = getchar();
	if (c == 45) p = -p, c = getchar();
	while (c > 32) x = x * 10 + c - 48, c = getchar();
	return x * p;
}
using namespace std;
//ruogu_alter
int n;
ll s;
vector<pii>v;
//
ll gcd(ll x, ll y) {
	if(!y) return x;
	return gcd(y, x % y);
}
inline void upd(pair<ll, ll> &u, ll x, ll y) {
	if(u.first * y > x * u.second) {
		u.first = x;
		u.second = y;
	}
}
int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	n = getint();
	rep(i, n) {
		int x = getint(), y = getint();
		s += x;
		v.emplace_back(mp(max(x, y), y));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	int k = 0; ll sum = 0;
	rep(i, n) {
		sum += v[k++].first;
		if (sum >= s) break;
	}
	pair<ll, ll>px = mp(1, 1);
	rep(i, n) {
		int x = s - (sum - v[min(i, k - 1)].first);
		if(x <= v[i].second) upd(px, x, v[i].second);
	}
	px.first = px.second * (n - k + 1) - px.first;
	px.second *= n;
	ll g = gcd(px.first, px.second);
	px.first /= g; px.second /= g;
	cout << px.first << " " << px.second << endl;
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
 
int main()
{
  long long int taka;
  long long int aoki;
  long long int K;
  
  scanf("%lld %lld %lld",&taka,&aoki,&K);
  
  long long int i,j,k;
  
  i = taka - K;
  
  if(i>=0){
    printf("%lld %lld\n",i,aoki);
  }
  else{
    j = aoki + i;
    if( j < 0 ){
      printf("0 0\n");
    }
    else{
      printf("0 %lld\n",j);
    }
  }
  
  return 0;
  
}

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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#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 (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int s, w;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> s >> w;
    cout << (w>=s?"unsafe":"safe") << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

int main(){
  	string s;
  	cin >> s;
  	int year = stoi(s.substr(0,4));
  	int month = stoi(s.substr(5,2));
  	if(year>2019){
    	cout << "TBD"; return 0;
    }else if(year==2019){
    	cout << (month>=5?"TBD":
                 "Heisei");
    }else{
    	cout << "Heisei";
    }
      
       
	return 0;
}

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

#define MAXN 200010
#define ll long long
#define mod 1000000007

using namespace std;

int n, tot;
ll ans;

int a[MAXN];
int c[MAXN];

string s;

int main() {
	int t;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		c[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		ans += (ll)(c[i] - 1) * c[i] / 2;
	}
	for (int i = 1; i <= n; i++) {
		cout << ans - (ll)(c[a[i]] - 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
#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)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    pair<int,int> A[2 * n];
    REP(i,n){
        cin >> A[i].fi;
        A[i].se = 1;
    }

    REP(i,n){
        cin >> A[n + i].fi;
        A[n + i].se = -1;
    }

    sort(A,A+2 * n);
    int ans = 1;
    int now = 0;
    REP(i,2 * n){
        if(now * A[i].se < 0){
            ans *= abs(now);
            ans %= MOD;
        }
        now += A[i].se;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>
#define ms_valtype int

//比較関数
int compare_ms(ms_valtype a, ms_valtype b){
	return a - b;
}

//昇順
void sort_sub(ms_valtype *origin, int left, int right, ms_valtype *tmp){
	if(right - left > 1){
		int i, j, k, half = (left + right) / 2;
		sort_sub(origin, left, half, tmp);
		sort_sub(origin, half, right, tmp);
		for(i = left; i < right; i++){
			tmp[i] = origin[i];
		}
		for(i = left, j = left, k = half; i < right; i++){
			if(k == right){
				origin[i] = tmp[j];
				j++;
			}
			else if(compare_ms(tmp[j], tmp[k]) <= 0 && j < half){
				origin[i] = tmp[j];
				j++;
			}
			else{
				origin[i] = tmp[k];
				k++;
			}
		}
	}
}

void sort(ms_valtype *origin, int N){
	ms_valtype *tmp = (ms_valtype *)malloc(sizeof(ms_valtype) * N);
	sort_sub(origin, 0, N, tmp);
	free(tmp);
}

int min(int a, int b){
	return a <= b ? a : b;
}

int main(){
	int N, i, m, inf, sup;
	scanf("%d", &N);
	int *D = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%d", &D[i]);
	}
	sort(D, N);
/*	for(m = 0; ; m++){
		inf = m;
		sup = 100;
		for(i = 0; i < N; i++){
			if(D[i] - inf < sup - (24 - D[i])){
				if(D[i] - inf >= 0){

				}
			}
		}
	}
*/	for(i = 0; i < N; i++){
		if(i % 2 == 0){
			D[i] = 24 - D[i];
		}
	}
	sort(D, N);
	m = min(D[0] - 0, 24 - D[N - 1]);
	for(i = 1; i < N; i++){
		m = min(m, D[i] - D[i - 1]);
	}
	printf("%d\n", m);
	return 0;
}

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

using namespace std;
using ll = long long;


int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    bool res = false;
    for(auto i : a) {
        if(i % 2)res = true;
    }
    cout << (res ? "first" : "second") << endl;
}

Measured memory_bytes: 3768
//フェーン現象
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<utility>
#include<map>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
#define MP make_pair
#define PB push_back
#define F_d first
#define S_d second
#define LARGE 100000000
#define MOD 100000
#define LL long long

LL N, Q, S, T, A[200009], dis[200009], tem = 0;
//dis[i]=i~i+1
int main() {
	cin >> N >> Q >> S >> T;
	//標高がどれくらい上下したのかを見る
	for (int i = 0; i <= N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		dis[i] = A[i + 1] - A[i];
		//
		//cout << dis[i] << " " << i << endl;
		//
		if (dis[i] >= 0)tem -= dis[i] * S;
		else tem -= dis[i] * T;
	}
	//
	//cout << tem << endl;
	//

	for (int i = 0; i < Q; i++) {
		int L, R, X;
		cin >> L >> R >> X;

		//temの変化は両端のdisのみが影響
		if (dis[L - 1] >= 0)tem += dis[L - 1] * S;
		else tem += dis[L - 1] * T;
		if (R != N) {
			if (dis[R] >= 0)tem += dis[R] * S;
			else tem += dis[R] * T;
		}

		dis[L - 1] += X; dis[R] -= X;

		if (dis[L - 1] >= 0)tem -= dis[L - 1] * S;
		else tem -= dis[L - 1] * T;
		if (R != N) {
			if (dis[R] >= 0)tem -= dis[R] * S;
			else tem -= dis[R] * T;
		}

		cout << tem << endl;
	}
	return 0;
}




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

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k) {
        cout << n * x << endl; 
    } else {
        cout << x * k + y * (n - k) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>


#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin >> n >> k;
    int num;
    vector<int> arr(n,0);
    int cnt = 0,it=0;
    rep(i,n){
        cin >> num;
        arr[num-1]++;
    }
    sort(arr.begin(),arr.end(), greater<int>());
    for(auto e :arr){
        it++;
        if(it > k) cnt += e;
        //cout << e << endl;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

	int a , b;

	scanf("%d %d" , &a , &b);
	if(a < b){
		printf("a < b\n");
	}
	else if(a > b){
		printf("a > b\n");
	}
	else{
		printf("a == b\n");
	}

	return 0;
}

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

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector < int >X(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

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

	int ans = INT_MAX;

	for (int i = 1; i <= 100; i++) {
		int cost = 0;
		for (int j = 0; j < N; j++) {
			cost += pow(X[j] - i, 2);
		}
		ans = min(cost, ans);
	}

	cout << ans << endl;

	return 0;
}


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

int main()
{
    int a,b,n,f=0,i;
    cin>>n;
    for(i=1;i<=9;i++)
    {
    if(n%i==0&&(n/i)<=9)
    {
    f=1;
    break;
    }
    }
    if(f)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3596
def Main(N, P):
    ans = 1
    mi = P[0]
    for i in range(1, N):
        if mi > P[i]:
            ans += 1
            mi = P[i]
    return ans

def main():
    N = int(input())
    P = list(map(int, input().split()))
    print(Main(N, P))

if __name__ == '__main__':
    main()

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

int main(){
	int x1, y1, x2, y2, x3, y3, x4, y4, dx, dy;
	cin >> x1 >> y1 >> x2 >> y2;
	dx = x2 - x1;
	dy = y2 - y1;
	x3 = x2 - dy;
	y3 = y2 + dx;
	x4 = x3 - dx;
	y4 = y3 - dy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    n, a, b = map(int, input().split())

    r1 = n // (a + b)
    r2 = n % (a + b)

    r = r1 * a + min(r2, a)
    print(r)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
// aribon3-3_e
// Range Query - RSQ and RAQ 区間add & 区間sum
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

template<typename T>
struct LazySegmentTree{
    int n;
    vector<T> val;
    vector<T> lazy;
    vector<int> width;

    explicit LazySegmentTree(int n_){
        n = 1;
        while (n < n_) n <<= 1;

        val = vector<T>(n<<1, 0);
        lazy = vector<T>(n<<1, 0);
        width = vector<int>(n<<1, 1);
        for (int i = n-2; i >= 0; i--) {
            width[i] = width[i*2+1] + width[i*2+2];
        }
    }
    void lazy_propagate(int k) {
        val[k] += lazy[k] * width[k];
        if (k < n-1) {
            lazy[k*2+1] += lazy[k];
            lazy[k*2+2] += lazy[k];
        }
        lazy[k] = 0;
    }
    void add(int a, int b, int k, int l, int r, int x) {
        lazy_propagate(k);

        if (b <= l || r <= a) {
            return;
        }
        if (a <= l && r <= b) {
            lazy[k] += x;
            lazy_propagate(k);
            return;
        }
        int mid = (l+r)/2;
        add(a, b, k*2+1, l, mid, x);
        add(a, b, k*2+2, mid, r, x);
        val[k] = val[k*2+1] + val[k*2+2];
    }

    void add(int a, int b, int x) {
        add(a, b, 0, 0, n, x);
    }

    T get_sum(int a, int b, int k, int l, int r) {
        lazy_propagate(k);

        if (b <= l || r <= a) {
            return 0;
        }
        if (a <= l && r <= b) {
            return val[k];
        }
        int mid = (l+r)/2;
        T sl = get_sum(a, b, k*2+1, l, mid);
        T sr = get_sum(a, b, k*2+2, mid, r);
        return sl + sr;
    }

    T get_sum(int a, int b) {
        return get_sum(a, b, 0, 0, n);
    }
};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, Q;
    cin >> N >> Q;

    LazySegmentTree<ll> sst(N);

    REP(i, Q){
        int q;
        cin >> q;
        if (q == 0){
            int s, t, x;
            cin >> s >> t >> x; s--; t--;
            sst.add(s, t+1, x);

        } else {
            int s, t;
            cin >> s >> t; s--; t--;
            ll ans = sst.get_sum(s, t+1);
            print(ans);
        }
    }

    return 0;
}



Measured memory_bytes: 8132
# coding: utf-8
H, N = map(int, input().split())
L = []
for i in range(N):
    L.append(list(map(int, input().split())))
dp = [float("inf") for _ in range(H+1)] 
dp[0] = 0
top = 10**9
for i in range(1, H+1):
    for j in range(N):
        a, b = L[j]
        if i <= a:
            dp[i] = min(dp[i], b)
        else:
            dp[i] = min(dp[i], dp[i-a] + b)
    # print(*dp)
print(dp[H])


Measured memory_bytes: 43100
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        long n = scanner.nextLong();
        long s = scanner.nextLong();
        if (s == n) {
            System.out.println(n + 1);
        } else {
            for (long b = 2; b * b <= n; b++) {
                if (f(b, n) == s) {
                    System.out.println(b);
                    return;
                }
            }
            long min = Long.MAX_VALUE;
            for (long p = 1; p * p < n; p++) {
                long b = (n - s) / p + 1;
                if (b > 0 && (n - s) % p == 0 && f(b, n) == s) {
                    min = Math.min(min, b);
                }
            }
            System.out.println(min == Long.MAX_VALUE ? -1 : min);
        }
    }

    static long f(long b, long n) {
        return n < b ? n : f(b, n / b) + n % b;
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100002];
int dp[100002];

int dfs(int v)  {
    if(dp[v]!=-1)
        return dp[v];
    dp[v] = 0;
    for(int u : adj[v]) {
        dp[v] = max(dp[v], 1 + dfs(u));
    }
    return dp[v];
}
int main() {
	int n, m;
	cin>>n>>m;
	int i;
	for(i=1;i<=n;i++)
	    dp[i] = -1;
	for(i=1;i<=m;i++) {
	    int x, y;
	    cin>>x>>y;
	    adj[x].push_back(y);
	}
	int ans  = 0;
	for(i=1;i<=n;i++) 
	    ans  = max(ans, dfs(i) );
	cout << ans<<"\n";
	return 0;
}

Measured memory_bytes: 7424
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N;
  cin >> N;
  vector<int> d(N);
  for (auto& v : d) {
    cin >> v;
  }
  sort(d.begin(), d.end());

  cout << d[N / 2] - d[N / 2 - 1] << endl;

  return 0;
}


Measured memory_bytes: 3792
n,d = map(int, raw_input().split(' '))
elems = [map(int,raw_input().split(' ')) for _ in range(n)]

def f(x):
	q = 1
	while(q * q <= x):
		if q **2 == x: return True
		q +=1
	return False
count = 0
for i in range(len(elems)):
	for j in range(i+1, len(elems)):
		if f(sum([(abs(a-b) ** 2) for a, b in zip(elems[i],elems[j])])):
			count +=1
print count

Measured memory_bytes: 29292
#include<stdio.h>

int main(void){
	int n,sum,max,i,j,data[5005];
	while(1){
		scanf("%d",&n);
		if(n==0){break;}
		for(i=0;i<n;i++){
			scanf("%d",&data[i]);
		}
		max=data[0]+data[1];
		for(i=0;i<n;i++){
			sum=0;
			for(j=i;j<n;j++){
				sum=sum+data[j];
				if(max<sum){max=sum;}
			}
		}
	printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 620
import sys
n = int(input())
input_list = [[int(i) for i in str.split()] for str in sys.stdin.read().splitlines()]
size_list = [0 for i in range(n+1)]
size_list[0] = input_list[0][0]
for i in range(1,n+1):
    size_list[i] = input_list[i-1][1]


m = [[float('inf') for i in range(n)] for j in range(n)]

for i in range(n):
    m[i][i] = 0

for x in range(n):
    i, j = 0, x
    for y in range(n-x):
        for k in range(i, j):
            m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + size_list[i]*size_list[k+1]*size_list[j+1])
        i, j = i+1, j+1

print(m[0][-1])




Measured memory_bytes: 5936
N = int(input())
S = input()
p = ["(", ")"]
l = 0
n = 0
for i in range(N - 1, -1, -1):
  if S[i] == p[1]:
    l += 1
  else:
    if l > 0:
      n += 2
      l -= 1

r = N - n - l
print(p[0] * l + S + p[1] * r)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int cnt = 0;
    for(int i = 1; i<(n+1)/2; i++){
     cnt++;
     }
      
    
    System.out.println(cnt);
    
  }
}


Measured memory_bytes: 22100
// 2020-09-15 23:50:13
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n, h;
  cin >> n >> h;
  vector<int> a(n), b(n);
  int maxa = 0;
  rep(i, n) {
    cin >> a[i] >> b[i];
    chmax(maxa, a[i]);
  }
  sort(RALL(b));
  int ans = 0;
  rep(i, b.size()) {
    if (b[i] <= maxa) break;
    if (h <= 0) break;
    h -= b[i];
    ans++;
  }
  ans += (max(h, 0) + maxa - 1) / maxa;
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int N, C;
const int MAX_N = 1.0e5 + 100;
int s[MAX_N], t[MAX_N], c[MAX_N];

int main() {
    cin >> N >> C;
    for (int i = 0; i < N; i++) {
        cin >> s[i] >> t[i] >> c[i];
    }

    bool recorder[C + 1][MAX_N];
    for (int i = 0; i <= C; i++) {
        for (int j = 0; j < MAX_N; j++) {
            recorder[i][j] = false;
        }
    }

    for (int i = 1; i <= C; i++) {
        for (int j = 0; j < N; j++) {
            if (c[j] == i) {
                for (int k = s[j]; k <= t[j]; k++) {
                    recorder[i][k] = true;
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < MAX_N; i++) {
        int cnt = 0;
        for (int j = 1; j <= C; j++) {
            if (recorder[j][i]) {
                cnt++;
            }
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;
int main()
{
  cout<<fixed<<setprecision(10);
  string S;
  cin >> S;
  if(S=="SUN") cout << 7 << endl;
  else if(S=="MON") cout << 6 << endl;
  else if(S=="TUE") cout << 5 << endl;
  else if(S=="WED") cout << 4 << endl;
  else if(S=="THU") cout << 3 << endl;
  else if(S=="FRI") cout << 2 << endl;
  else if(S=="SAT") cout << 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
typedef long long int ll;
#define int long long int
typedef vector<ll> vi;
typedef pair<int, int> ii; typedef vector<ii> vii;
#define INF numeric_limits<ll>::max()
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
ll powmod(ll a,ll l, ll md){ll res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
ll binpow(ll a,ll l){ll res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
ll invmod(ll a, ll md){return powmod(a,md-2,md);}
const ll inf = 0xFFFFFFFFFFFFFFFL;


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	string s;
	cin>>s;
	ll n = s.length();
	ll cnt =0, ind = 0, ind_l = 0, cnt_temp = 0; 
	while(ind<=n-2){
		if (s[ind]=='A'){
			ind+=1;
			cnt_temp+=1;
		}
		else if (ind<=n-2 && s[ind]=='B' && s[ind+1]=='C' ){
			cnt+=cnt_temp;
			ind+=2;
		}
		else{
			cnt_temp = 0;
			ind+=1;
		}


	}
	cout<<cnt<<"\n";
    return 0;
}


Measured memory_bytes: 720
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String S = sc.next();
		String[] s = S.split("");
		int[] l = new int[q];
		int[] r = new int[q];
		boolean[] ac = new boolean[n];
		int[] num = new int[n];
		for(int i = 0; i < n-1; i++) {
			if(s[i].equals("A")) {
				if(s[i+1].equals("C"))
					ac[i] = true;
			}
		}
		num[0] = 0;
		for(int i = 1; i < n; i++) {
			num[i] = num[i-1];
			if(ac[i-1]) num[i] += 1;		
		}
		for(int i = 0; i < q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		for(int i = 0; i < q; i++) {
			System.out.println(num[r[i]-1]-num[l[i]-1]);
		}
	}

}

Measured memory_bytes: 86080
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n,m;
	cin>>n>>m;
	int lower = 0, upper = inf;
	rep(i,m){
		int l,r; 
		cin>>l>>r;
		lower = max(lower,l);
		upper = min(upper,r);
	}
	cout<<max(upper-lower+1,0)<<endl; return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 1e9 + 7;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
	if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	ll a, b;
	cin>>a>>b;
	cout<<a*b;


    return 0;
}


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

#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "["<< *it << " = " << a << "]"<< endl;
    err(++it, args...);
}
using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n;
    vector<int> v(n+1);
    for (int i = 1 ; i<= n; i++ ) {
        cin >> k;
        v[k] = i;
    }

    for (int i = 1 ; i<= n; i++ ) {
        cout << v[i] << " ";
    }

}


Measured memory_bytes: 1280
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-08-08 22:05:18 +0900
# LastModified: 2020-08-09 00:49:47 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from math import sqrt


def prime_factor(n, prime_factor):
    for i in range(2, int(sqrt(n))+1):
        if n % i == 0:
            prime_factor.append(i)

def main():
    n = int(input())
    prime_list = []
    prime_factor(n, prime_list)
    if not prime_list:
        print(n-1)
        return
    i = prime_list[-1]
    j = n//i
    print(i-1+j-1)



if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
n, m = list(map(int, input().split()))
info = [list(map(int, input().split())) for i in range(m)]

ans = [-1] * n
for i in range(m):
    s, c = info[i]
    if ans[s - 1] == -1:
        ans[s - 1] = c
    else:
        if ans[s - 1] == c:
            continue
        else:
            print(-1)
            exit()

if len(ans) == 1:
    if ans[0] == -1:
        ans[0] = 0
    print("".join(map(str, ans)))
    exit()
if ans[0] == 0:
    print(-1)
    exit()
for i in range(n):
    if i == 0 and ans[i] == -1:
        ans[i] = 1
        continue
    if ans[i] == -1:
        ans[i] = 0
print("".join(map(str, ans)))
exit()


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

#define int long long
#define endl '\n'
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 3e5 + 5;
const ld PI = 4 * atan((ld)1);
char a[1005][1005];
int ans[1005][1005];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++)
		for(int j=1;j<=w;j++){
			cin>>a[i][j];
		}
	ans[1][1]=1;
	for(int i=2;i<=h;i++) if(a[i][1]!='#') ans[i][1]=ans[i-1][1];
	for(int j=2;j<=w;j++) if(a[1][j]!='#') ans[1][j]=ans[1][j-1];
	for(int i=2;i<=h;i++)
		for(int j=2;j<=w;j++){
			if(a[i][j]=='#') ans[i][j]=0;
			else ans[i][j]=(ans[i-1][j]+ans[i][j-1])%MOD;
		}
	cout<<ans[h][w]<<endl;
}

Measured memory_bytes: 9088
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;


using ll = long long;

#define int ll


const int N = 1e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int h, a, sum, x, n;
main() {
    file("threesum");
    ios;
    cin >> h >> n;
    fo(i, 1, n, 1) cin >> x, sum += x;
    cout << (sum >= h ? "Yes" : "No");
    cerr << "\nTime elapsed: " << (clock() + 0.0) / CLOCKS_PER_SEC;
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> N;
    cin >> M;

    ll X[N][M];

    rep(ni,N){
        rep(mi,M){
            cin >> X[ni][mi];
        }
    }

    ll cnt = 0;
    for( ll ni = 0 ; ni <N ; ni++ ){
        for( ll ni2 = ni+1 ; ni2 <N ; ni2++ ){
            double distance=0;
            rep(mi,M){
                distance += pow( (X[ni][mi]-X[ni2][mi]),2.0 );
            }
            distance = pow(distance,0.5);
            ll ltmp = distance;

            if(ltmp==distance) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll A,B,C,K,i;cin>>A>>B>>C>>K;
  REP(i,K){
    if(A<B)C*=2;
    else B*=2;
  }
  if(A<B&&B<C)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3508
#include <stdio.h>

int min1(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int main (){
  int n, i, s;
  int c = 0;
  int sum = 0;
  int sum1 = 0;
  int sum2 = 0;
  scanf("%d\n", &n);
  int A[n];
  for (i=0; i<n; i++) scanf("%d", &A[i]);
  for(i=0; i<n; i++){
     c = c + A[i];
  }
  s = c/n;
  if (c%n == 0){
    for(i=0; i<n; i++){
        sum = sum + (A[i]-s)*(A[i]-s);
    }   
  }
  else{
    for(i=0; i<n; i++){
        sum1 = sum1 + (A[i]-s)*(A[i]-s);
    }   
    for(i=0; i<n; i++){
        sum2 = sum2 + (A[i]-s-1)*(A[i]-s-1);
    }
    sum = min1(sum1, sum2);   
  }
  printf("%d", sum);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using ll = long long int;

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

    int ans = 0;
    for(ll i=1; i<=S; i++) {
        for(ll j=1; i*j<=S; j++) {
            ll sum = 0;

            // [i, k], [j, ?]
            for(ll k=i; sum+k*j<=S; sum += k*j, k++) {
                ll nsum = sum + k * j;
                ll base = k*(k+1)/2 - i*(i-1)/2;

                ll ub = S, lb = j-1;
                while(ub - lb > 1) {
                    ll mid = (ub + lb) / 2;
                    ll val = nsum * (mid - j + 1) + base * (mid - j) * (mid - j + 1) / 2;
                    if(val >= S) ub = mid;
                    else lb = mid;
                }

                ll val = nsum * (ub - j + 1) + base * (ub - j) * (ub - j + 1) / 2;
                if(val == S) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long x, y;
    cin>>x>>y;
    if(x>=1 && x<=9 && y>=1 && y<=9)
        cout<<x*y<<endl;
    else
        cout<<-1<<endl;

    return 0;
}



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

using namespace std;

#define FaSt ios::sync_with_stdio(0),cin.tie(0);
#define random uniform_int_distribution<long long>(1, 2000000000000000LL)(rng)
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count() * ((uint64_t) new char | 1));

const int N = 100005;
int n, k, a[N][3], dp[N][3];
bool solved[N][3];

int calc(int i, int c)
{
    if (solved[i][c])
    {
        return dp[i][c];
    }
    
    if (i == n)
    {
        return 0;
    }
    
    if (c == 0)
        dp[i][c] = max(a[i][c] + calc(i + 1, 1), a[i][c] + calc(i + 1, 2));
    if (c == 1)
        dp[i][c] = max(a[i][c] + calc(i + 1, 0), a[i][c] + calc(i + 1, 2));
    if (c == 2)
        dp[i][c] = max(a[i][c] + calc(i + 1, 1), a[i][c] + calc(i + 1, 0));
    
    solved[i][c] = 1;
    return dp[i][c];
}

int main() 
{
    FaSt
    cin >> n;
    
    for (int i = 0; i < n; i++)
    {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    
    cout << max(calc(0, 0), max(calc(0, 1), calc(0, 2)));
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 200005

int N,M;
ll table[NUM],pre[NUM],dp[NUM],dp2[NUM];

int main(){

	scanf("%d %d",&N,&M);

	table[0] = 0;
	pre[0] = 0;

	for(int i = 1; i <= N; i++){

		scanf("%lld",&table[i]);
	}

	for(int i = 1; i <= N; i++){

		pre[i] = i;
	}

	ll L,R;

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

		scanf("%lld %lld",&L,&R);
		pre[R] = min(pre[R],L);
	}

	for(int i = N-1; i >= 1; i--){

		pre[i] = min(pre[i],pre[i+1]);
	}

	dp[0] = 0;
	dp2[0] = 0;
	ll ans = 0;

	for(int i = 1; i <= N; i++){

		dp[i] = dp2[pre[i]-1]+table[i];
		dp2[i] = max(dp2[i-1],dp[i]);

		ans = max(ans,dp[i]);
	}

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 9324
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main() {
    int n;
    cin >> n;
    int count = n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    for (int i = 0; i < n - 1; i++) {
        if (s.at(i) == s.at(i + 1)) {
            count--;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define debug(arr) cout << ">>" << #arr << ':' << arr << endl;
#define endl "\n"
#define pb push_back
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin() , v.end()
int gcd(int a,int b){
	while(a&&b)a>b?a%=b:b%=a;
	return a+b;
}

const int N = 200001;
	
bool check( int ans , vector<int> v , int k)
{
	for(auto i : v)
	{
		k -= (i/ans);
		if(i%ans == 0)k++;	
	}	
	return k>=0;
} 
int main()
{
	IOS
	int n , k;
	cin>>n>>k;
	
	vector<int> v(n);
	for(int i=0 ; i<n ; i++)cin>>v[i];
	
	int mini = 1 , maxa  = 1e9 + 100;
	while( mini < maxa)
	{
		int mid = (mini + maxa)/2;
		if( check (mid , v , k))
		{
			maxa = mid;
		}
		else
		{
			mini = mid+1;
		}
	}
	cout<<mini<<endl;
	
	
	
	
}

Measured memory_bytes: 4748
#include<queue>
#include<cstdio>
#include<cstring>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

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

struct stat{
	int y,x,dir,n1,n2; // n1, n2 : 鏡 /, \ の残り枚数
};

int main(){
	int h,w,n; scanf("%d%d%d",&h,&w,&n);
	char B[100][101];
	rep(i,h) scanf("%s",B[i]);

	int sx,sy;
	rep(i,h) rep(j,w) if(B[i][j]=='S') sx=j, sy=i;

	static int dp[100][100][4][11][11];
	memset(dp,-1,sizeof dp);
	dp[sy][sx][3][n][n]=0;
	rep(n1,n+1) rep(n2,n+1) dp[sy][sx][1][n1][n2]=777;

	queue<stat> Q;
	Q.push((stat){sy,sx,3,n,n});
	while(!Q.empty()){
		int y=Q.front().y,x=Q.front().x,dir=Q.front().dir,n1=Q.front().n1,n2=Q.front().n2;
		Q.pop();

		if(B[y][x]=='G'){ printf("%d\n",dp[y][x][dir][n1][n2]); return 0; }

		int y2=y+dy[dir],x2=x+dx[dir];
		while(0<=y2 && y2<h && 0<=x2 && x2<w && B[y2][x2]!='#' && dp[y2][x2][dir][n1][n2]==-1){
			dp[y2][x2][dir][n1][n2]=dp[y][x][dir][n1][n2];

			if(B[y2][x2]=='G'){ printf("%d\n",dp[y2][x2][dir][n1][n2]); return 0; }

			// 鏡 / を置く
			int dir2=dir^1;
			if(n1>0 && dp[y2][x2][dir2][n1-1][n2]==-1){
				dp[y2][x2][dir2][n1-1][n2]=dp[y][x][dir][n1][n2]+1;
				Q.push((stat){y2,x2,dir2,n1-1,n2});
			}

			// 鏡 \ を置く
			dir2=3-dir;
			if(n2>0 && dp[y2][x2][dir2][n1][n2-1]==-1){
				dp[y2][x2][dir2][n1][n2-1]=dp[y][x][dir][n1][n2]+1;
				Q.push((stat){y2,x2,dir2,n1,n2-1});
			}

			y2+=dy[dir];
			x2+=dx[dir];
		}
	}

	puts("-1");

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
  int N, A, B, C, X;
  while(cin >> N >> A >> B >> C >> X){
    if(!N && !A && !B && !C && !X) break;
    
    vector<int> Y(N);
    for(int i = 0 ; i < N ; i++) cin >> Y[i];
    
    int cnt = 0, pos = 0;
    bool f = false;
    while(true){
      if(pos == N) break;
      if(cnt > 10000){
	f = true;
	break;
      }
      
      if(Y[pos] == X){
	pos++;
	cnt++;
	X = (A*X + B) % C;
      }
      else{
	X = (A*X + B) % C;;
	cnt++;
      }
    }
    
    if(f) cout << "-1" << endl;
    else cout << cnt-1 << endl;
  }
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  unsigned moto = s.size();
  set<char> S;
  
  for(unsigned i = 0;i < moto;i ++){
    S.insert(s[i]);
  }
  
  if(S.size() == moto)cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 3632
import java.io.*;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    static final int MOD = 2;

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        for(int i = 0 ; i < N ; i++){
            a[i] = sc.nextInt();
        }

        final Solver solver = new Solver();
        solver.solve(N, a);
    }
}

class Solver {
    public void solve(int N, int[] a) {
        int[] ans = new int[N];
        List<Integer> balls = new ArrayList<>();
        for (int i = N - 1; i >= 0; i--) {
            int s = sum(N, ans, i) % 2;

            boolean put = s != a[i];
            if (put) {
                ans[i] = 1;
                balls.add(i + 1);
            }
            else {
                ans[i] = 0;
            }
        }

        System.out.println(balls.size());
        System.out.println(
                balls.stream()
                        .map(String::valueOf)
                        .collect(Collectors.joining(" "))
        );
    }

    private int sum(int N, int[] a, int cur) {
        int step = cur + 1;
        int sum = 0;
        for (int i = cur + step; i < N; i+=step) {
            sum += a[i];
        }
        return sum;
    }
}



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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

int main(void)
{
  ll a, b, n; cin >> a >> b >> n;
  ll ans = 0;

  ll y = (a * min(n,(b - 1))) / b;
  ans = y;
  cout << ans << endl;
}


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

typedef unsigned long long ULL;
typedef long long LL;

const int PI = 3.1415926535;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 100007;


int main() {
	
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	LL x, k, d; 
	cin >> x >> k >> d;
	x = abs(x);
	LL t = x / d;
	if (t == k) {
		cout << x % d << "\n";
	}else if (t < k) {
		t -= k;
		if (t & 1) {
			LL rem = x % d;
			LL ans = abs(rem - d);
			LL ans2 = abs(rem + d);
			cout << min(ans, ans2) << "\n";
		} 
		else {
			LL val = x % d;
			cout << val << "\n";
		}
	}
	else {
		cout << x - k * d << "\n";
	}
	return 0;
}


Measured memory_bytes: 3556
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#define pb push_back
using namespace std;

typedef long long LL;
const int N = 305;

struct node {
  int u, v, len;
};

LL ans = 0, E[N][N];
int n, G[N][N];
bool vis[N][N];
vector <node> edge;

inline bool cmp(node a, node b) {
  return a.len < b.len;
}

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++)
    for (int j = 1; j <= n; j ++) {
      scanf("%d", &G[i][j]);
      if (i < j) edge.pb((node){i, j, G[i][j]});
    }
  for (int k = 1; k <= n; k ++)
    for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= n; j ++)
	if (G[i][k] + G[k][j] < G[i][j]) return puts("-1"), 0;
  sort(edge.begin(), edge.end(), cmp);
  memset(E, 127, sizeof(E));
  int x, y;
  for (int i = 1; i <= n; i ++) E[i][i] = 0;
  for (int i = 0; i < (int)edge.size(); i ++)
    if (E[edge[i].u][edge[i].v] > edge[i].len) {
      x = edge[i].u; y = edge[i].v;
      E[x][y] = edge[i].len;
      E[y][x] = edge[i].len;
      ans += edge[i].len;
      for (int j = 1; j <= n; j ++)
	for (int k = 1; k <= n; k ++)
	  if (E[j][x] != E[0][0] && E[y][k] != E[0][0])
	    E[j][k] = E[k][j] = min(E[j][k], E[j][x] + E[x][y] + E[y][k]);
    }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    ll a, b;
    cin >> a >> b;
    if(a>=2*b){ 
    cout << a - 2 * b << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
a = []
for i in range(N):
	a.append(int(input()))

b = sorted(a)
max1 = b[N-1]
max2 = b[N-2]

if max1==max2:
	for i in range(N):
		print(max1)
else:
	for i in range(N):
		if a[i]==max1:
			print(max2)
		else:
			print(max1)


Measured memory_bytes: 14068
#include<stdio.h>

int main(){
	int n,i,q,lr[100000][2],ru[100000]={0};
	char s[100001];
	scanf("%d%d",&n,&q);
	scanf("%s",s);
	for(i=0;i<q;i++)scanf("%d%d",&lr[i][0],&lr[i][1]);
	for(i=1;i<n;i++){
		if(i!=0)ru[i]=ru[i-1];
		if(s[i-1]=='A'&&s[i]=='C'){
			ru[i]++;
		}
	}
	for(i=0;i<q;i++){
		printf("%d\n",ru[lr[i][1]-1]-ru[lr[i][0]-1]);
	}
	return 0;
}

Measured memory_bytes: 2048