akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main() {
	int n, a_s, b_s, *a, *b;
	std::cin >> n;
	while (n) {
		a_s = b_s = 0;
		a = new int[n];
		b = new int[n];
		for (int i=0; i<n; i++) {
			std::cin >> a[i] >> b[i];
		}
		for (int i=0; i<n; i++) {
			if (a[i] > b[i]) {
				a_s += a[i] + b[i];
			} else if (a[i] < b[i]) {
				b_s += a[i] + b[i];
			} else {
				a_s += a[i], b_s += b[i];
			}
		}
		std::cout << a_s << " " << b_s << std::endl;
		delete[] a;
		delete[] b;
		std::cin >> n;
	}
}

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

#define mp make_pair

typedef long long ll;
typedef pair<int,int> pii;

pii ExtendedGCD(int a,int b)
{
	if(b==0) return mp(1,0);
	int x,y; tie(x,y)=ExtendedGCD(b,a%b);
	return mp(y,x-a/b*y);
}

//pii ExtendedGCD(int a,int b)
//{
//	int x=1,y=0,u=0,v=1;
//	while(b){
//		ll t=a/b;
//		swap(a-=b*t,b);
//		swap(x-=u*t,u);
//		swap(y-=v*t,v);
//	}
//	return mp(x,y);
//}

int main()
{
	for(int a,b;cin>>a>>b && a|b;){
		int x,y; tie(x,y)=ExtendedGCD(a,b);
		cout<<x<<' '<<y<<endl;;
	}
}

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

int main(){
	ll  N;
	cin>>N;
	ll pow=1;
	for(ll i=1;i<=N;i++){
		pow=(pow*i)%(1000000000+7);
	}
	cout<<pow<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
n,a,b = [int(x) for x in input().split()]
c = a-b
h = []
for _ in range(n):
    h.append(int(input()))
h.sort()
m = h[-1]
z = 0
import bisect,math
while m-z>1:
    mid = (m+z)//2
    k = bisect.bisect_left(h,b*mid)
    cnt = 0
    for i in range(k,n):
        h2 = h[i]-b*mid
        cnt += math.ceil(h2/c)
    if cnt<=mid:
        m = mid
    else:
        z = mid

print(m)

Measured memory_bytes: 50924
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
# define ft first
# define sec second

int main()
{
   int n;
   ll D,x,y;
   int cnt=0;
   cin>>n>>D;
   for(int i=0;i<n;i++)
   {
       cin>>x>>y;
       if(x*x+y*y <= D*D) cnt++;
   }
   cout<<cnt;
}


Measured memory_bytes: 3188
import java.util.*;
import java.math.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String str = sc.next();
		int strLength = str.length();
		String expected = "keyence";
		boolean flag =false;

		if(str.indexOf(expected)==0 || str.indexOf(expected)==strLength-7){
			flag =true;
			}



		for (int i = 1; i < 7; i++) {
			if(flag){
				break;
			}
			String forword = expected.substring(0,i);
			String backword= expected.substring(i);
			int resultF = str.indexOf(forword);
			int resultB = str.lastIndexOf(backword);
			// System.out.println(forword);
			// System.out.println(backword);
			// System.out.println(resultF);
			// System.out.println(resultB);
			
			if(
				resultF == 0 &&
				(resultB == strLength - backword.length())
			){
				flag =true;
			}

		}

		if(flag){
				System.out.println("YES" );
				}else{
				System.out.println("NO" );
				}




	}


}

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

int main(){
	double left,right;
	int a[8];
	for(int i=0 ; i<8 ; i++) a[i] = 0;

	while( cin >> left >> right ){
		if( left >= 1.1 ) a[0]++;
		else if( left >= 0.6 ) a[2]++;
		else if( left >= 0.2 ) a[4]++;
		else a[6]++;

		if( right >= 1.1 ) a[1]++;
		else if( right >= 0.6 ) a[3]++;
		else if( right >= 0.2 ) a[5]++;
		else a[7]++;
	}
	for(int i=0 ; i<4 ; i++){
		cout << a[i*2] << " " << a[i*2+1] << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;

    if(x1==0){
        cout<<1<<endl;
    }
    else if(x2==0){
        cout<<2<<endl;
    }
     else if(x3==0){
        cout<<3<<endl;
    }
     else if(x4==0){
        cout<<4<<endl;
    }
     else if(x5==0){
        cout<<5<<endl;
    }
}


Measured memory_bytes: 3548
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 105
using namespace std;
bool debug=false;

int D[11];

bool check(int n,int K){
  while(n){
    for(int i=0;i<K;i++){
      if(n%10==D[i])return false;
    }
    n/=10;
  }
  return true;
}

int main(){
  int K,N;
  
  cin>>N>>K;
  rep(i,0,K){
    cin>>D[i];
  }
  
  for(int i=N;;i++){
    if(check(i,K)){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include <cmath>
#include <limits>
#include<set>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int N;
	cin >> N;
	int ans = 1;
	map<int, int>m;
	for (int i = 2; i <= N; i++)
	{
		int tmp = i;
		for (int j = 2; j <= tmp; j++)
		{
			while (tmp % j == 0)
			{
				tmp /= j;
				m[j]++;
			}
		}
	}
	int num = 1e9 + 7;
	for (auto i : m)
	{
		ans *= i.second + 1;
		ans %= num;
	}
	cout << ans % num;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
    int i, n;
    double ave, date[1001] = {}, sum, r;

    for(;scanf("%d", &n),n != 0; sum = 0, ave = 0, r = 0){
        for( i = 0; i < n; i++ ){
            scanf("%lf", &date[i]);
            sum += date[i];
        }
        ave = sum / n;
        for( i = 0, sum = 0; i < n; i++ ){
            sum += ( date[i] - ave ) * ( date[i] - ave );
        }
        r = sqrt( sum / n );
        printf("%f\n", r);
    }
   return 0;
}

Measured memory_bytes: 664
import java.util.Arrays;
import java.util.Scanner;
 
 
public class Main {
     
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
         
        long[] inputs = new long[3];
        for(int i = 0; i < 3; i++){
            inputs[i] = sc.nextLong();
        }
         
        Arrays.sort(inputs);
         
         
        for(int i = 0; i < 3; i++){
            System.out.print(inputs[i] + ((i != 2) ? " " : ""));
        }
        System.out.println();
         
         
    }
     
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

    
    //code
    int n , k;
    string s;
    cin >> n >> k >> s;
    k--;
    if(s[k] == 'A') s[k] = 'a';
    else if(s[k] == 'B') s[k] = 'b';
    else s[k] = 'c';

    cout << s;
    return 0;
}

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

#define ll long long
#define rep(i, a, b) for(ll i = (a); i < (b); i++)
#define sz(x) ((ll) (x).size())
#define all(x) (x).begin(), (x).end()
#define pii pair<ll, ll>
#define vi vector<ll>
using namespace std;
const ll N = 1e5+1;
const ll MOD = 1e9+7;

void solve(){
    ll n;
    cin>>n;
    ll a[n], b[n];
    rep(i, 0, n)cin>>a[i];
    rep(i, 0, n)cin>>b[i];
    sort(b, b+n, greater<ll>());
    ll l = -1, r;
    rep(i, 0, n){
        if(l==-1 && a[i]==b[i])l=i;
        if(a[i]==b[i])r=i;
    }
    if(l==-1){
        cout<<"Yes\n";
        rep(i, 0, n)cout<<b[i]<<" ";
    } else{
        ll v1 = 0, v2 = n-1;
        ll f = 1;
        while(l<=r){
            if(v1!=l && a[v1]!=b[l] && a[l]!=b[v1]){
                swap(b[l++], b[v1++]);
            } else if(v1!=l && a[v1]!=b[r] && a[r]!=b[v1]){
                swap(b[r--], b[v1++]);
            } else if(v2!=r && a[v2]!=b[l] && a[l]!=b[v2]){
                swap(b[l++], b[v2--]);
            } else if(v2!=r && a[v2]!=b[r] && a[r]!=b[v2]){
                swap(b[r--], b[v2--]);
            } else {
                f=0;
                break;
            }
        }
        if(f && l>r){
            cout<<"Yes\n";
            rep(i, 0, n)cout<<b[i]<<" ";
        } else cout<<"No\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T=1;
    // cin>>T;
    rep(test, 1, T+1){
        // cout<<"Case #"<<test<<": ";
        solve();
    }
    return 0 ;
}

Measured memory_bytes: 6756
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool used[100001];
int p[1000];
int main(){
	string s;
	cin>>s;
	r(i,s.size())used[s[i]-'a']=1;
	r(i,26){
		if(!used[i]){
			cout<<(char)(i+'a')<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
}

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

int main(){
	int n;
	int res = 0;
	int cnt=0;
	string s;
	string i_str = "000";

	cin >> n >> s;

	for(int i=0; i<=999; i++){
		i_str[0] = ((char) (i/100))+'0';
		i_str[1] = ((char) ((i%100)/10))+'0';
		i_str[2] = ((char) (i%10)) + '0';
		cnt = 0;
		for(int j=0; j<n; j++){
			if(i_str[cnt] == s[j]){
				cnt++;
			}
			if(cnt >= 3){
				res++;
				break;
			}
		}
	}
	cout << res << endl;
	return 0;

}

Measured memory_bytes: 384
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

def rl():
    return list(map(int, input().split()))


def solve():
    n = ri()
    d = dd(int)
    for i in range(n):
        d[input()] += 1

    for c in ["AC", "WA", "TLE", "RE"]:
        print (c, "x", d[c])






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 74908
n,m = map(int,input().split())
c = list(map(int,input().split()))

minimum = [50000] * (n+1)
minimum[0] = 0

for i in range(1,n+1):
    if minimum[i] <= 1:
        continue
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[n])

Measured memory_bytes: 9168
def g(r, c):
    return (fact[r + c + 2] * fact_inv[r + 1] * fact_inv[c + 1] - 1) % mod


r1, c1, r2, c2 = map(int, input().split())

mod = 10 ** 9 + 7
MAX = 10 ** 6

fact = [1] * (2 * MAX + 10)
for i in range(1, 2 * MAX + 10):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (MAX + 10)
for i in range(2, MAX + 10):
    inv[i] = inv[mod % i] * (mod - mod // i) % mod

fact_inv = [1] * (MAX + 10)
for i in range(1, MAX + 10):
    fact_inv[i] = fact_inv[i-1] * inv[i] % mod

ans = g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)
ans %= mod
print(ans)


Measured memory_bytes: 161268
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    rep(i, 11){
        if(i*1000>=n) {
            cout<<i*1000-n<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h,n,x;
  x=0;
  cin >> h >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < n; i++) {
    x+=vec.at(i);
  }
  
  if(x>=h)cout << "Yes" << endl;
  if(x<h)cout << "No" << endl;
}

Measured memory_bytes: 640
#include"bits/stdc++.h"
#define int long long
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
using namespace std;
const int MAX_N=2999;
int N;
vector<double> p;
double dp[MAX_N+1][MAX_N+1];
signed main(){
	cin>>N;
	p.resize(N);
	REP(i,N) cin>>p[i];
	REP(i,(N+1)/2) dp[N-i][i]=1;
	for(int i=N-1;i>=0;--i){
		for(int j=N-1;j>=0;--j){
			if(i+j<N) dp[i][j]=dp[i+1][j]*p[i+j]+dp[i][j+1]*(1-p[i+j]);
		}
	}
	printf("%.16f\n",dp[0][0]);
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N;
string S;
ll ans = 0;
vector<string> v[2][19];

void same(vector<string> a, vector<string> b) {
    sort(all(a)), sort(all(b));
    int l = 0, r = -1;
    for (auto x: a) {
        while (l < sz(b) && b[l] < x) l ++;
        while (r+1 < sz(b) && b[r+1] <= x) r ++;
        ans += r-l+1;
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> S;
    F0R(i,1<<N) {
        string a,b;
        F0R(j,N) {
            if (i&(1<<j)) a += S[j];
            else b += S[j];
        }
        reverse(all(b));
        v[0][__builtin_popcount(i)].pb(a+b);
    }
    F0R(i,1<<N) {
        string a,b;
        F0R(j,N) {
            if (i&(1<<j)) a += S[j+N];
            else b += S[j+N];
        }
        reverse(all(b));
        v[1][__builtin_popcount(i)].pb(b+a);
    }
    F0R(i,N+1) same(v[0][i],v[1][N-i]);
    cout << ans;
}

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/

Measured memory_bytes: 40508
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.BitSet;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(bf.readLine());
        StringBuilder sb = new StringBuilder();
        BitSet bitSet = new BitSet(13554432);
        final char[] key = new char[128];
        key['A'] = 0;
        key['C'] = 1;
        key['G'] = 2;
        key['T'] = 3;
        for (int i = 0; i < n; i++) {
            String sp = bf.readLine();
            if (sp.charAt(0) == 'i') {
                int hash = 1;
                for (int j = 7; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                bitSet.set(hash);
            } else {
                int hash = 1;
                for (int j = 5; j < sp.length(); j++) {
                    hash <<= 2;
                    hash+=key[sp.charAt(j)];
                }
                sb.append(bitSet.get(hash) ? "yes\n" : "no\n");
            }
        }
        bf.close();
        System.out.print(sb.toString());
    }
}



Measured memory_bytes: 68692
N = int(input())

xyh = []
for i in range(N):
    xyh.append(list(map(int,input().split())))

xyh_sorted = sorted(xyh, key=lambda x: x[2], reverse=True)

answer = [0, 0, 0]
for cy in range(0, 101):
    for cx in range(0, 101):
        H = xyh_sorted[0][2] + abs(xyh_sorted[0][0] - cx) + abs(xyh_sorted[0][1] - cy)
        flag = True
        for i in range(1,N):
            h2 = max(H - abs(xyh_sorted[i][0] - cx) - abs(xyh_sorted[i][1] - cy), 0)
            if h2 != xyh_sorted[i][2]:
                flag = False
                break
        if flag:
            answer = [cx, cy, H]
            break
    if flag:
        break

answerString = str(answer[0]) + " " + str(answer[1]) + " " + str(answer[2])
print(answerString)

Measured memory_bytes: 9112
#include <algorithm>
#include <bits/stdc++.h>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i != n; ++i)
#define REPR(i, n) for(int i = n - 1; i != -1; --i)
#define FOR(i, a, b) for(int i = a; i != b; ++i)
#define RBF(i, n) for(auto &i : n)
#define ABS(n) (n < 0 ? -n : n)
#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define IN(n) (cin >> n)
#define OUT(n) (cout << n << "\n")
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define MP make_pair
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(), greater<int>())

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;
using ll = long long;

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


void Main() {
  int N,A;
  cin >> N >> A;
  int ans=0;
  if(A>N){  
    vector<int> X(A);
    REP(i,A) IN(X[i]);
    SORT(X);
    vector<int> D(A-1);
    FOR(i, 1, A){
      D[i-1] = X[i] - X[i-1];
      ans += D[i-1];
    }
    SORTR(D);
    REP(i,N-1) ans -= D[i];
  }
  OUT(ans);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <utility>
using namespace std;
int n, w;
long long f[109][100009];
pair<int, int> p[109];
int main() {
    //freopen("knapsack1.inp", "r", stdin);
    //freopen("knapsack1.out", "w", stdout);
    cin >> n >> w;
    for (int i = 1; i <= n; i++) cin >> p[i].first >> p[i].second;
    for (int i = 1; i <= w; i++) {
        if (i >= p[1].first) f[1][i] = p[1].second;
        else f[1][i] = 0;
    }
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= w; j++) {
            if (p[i].first > j) f[i][j] = f[i - 1][j];
            else f[i][j] = max(f[i - 1][j], f[i - 1][j - p[i].first] + p[i].second);
        }
    }
    cout << f[n][w];
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int d, g;
  cin >> d >> g;
  VI p(d), c(d);
  rep(i, d) cin >> p[i] >> c[i];
  int ans = INF;
  for(int i = 0; i < 1 << d; ++i) {
    int s = 0;
    int cc = 0;
    int ma = -1;
    rep(j, d) {
      if((i >> j) & 1) {
        s += p[j] * 100 * (j + 1) + c[j];
        cc += p[j];
      }
      else ma = j;
    }
    if(s < g && ma >= 0) {
      int ne = (g - s + (100 * (ma + 1)) - 1) / (100 * (ma + 1));
      if(ne >= p[ma]) continue;
      cc += ne;
    }
    ans = min(ans, cc);
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {

            Solve();

            //Console.WriteLine(ans);
            Console.ReadKey();
        }

        static void Solve()
        {
            var c = new int[3][];
            c = c.Select(s => GetIntArray()).ToArray();

            bool b = true;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    if (c[i][j] - c[i + 1][j] != c[i][j + 1] - c[i + 1][j + 1]) b = false;
                    if (c[i][j] - c[i][j + 1] != c[i + 1][j] - c[i + 1][j + 1]) b = false;
                }
            }

            var ans = b.YesNo();
            Console.WriteLine(ans); 
        }




        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  string s;
  cin>>n>>s;
  int ans=0;
  for(int i=0;i<n-2;i++){
    if(s.substr(i,3)=="ABC")ans++;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define ll long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
string str;
int n;
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
void write(int x){
    if(x<0){x=-x;putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
signed main(){
	n=read();
	cin>>str;
	if(n<3200) printf("red");
	else cout<<str;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define debug(x) cout<<x<<endl
#define int long long 
const int mod=1000000007;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
inline int read() {int num=0, w=0;char ch=0;while (!isdigit(ch)) {w|=ch=='-';ch = getchar();}while (isdigit(ch)) {num = (num<<3) + (num<<1) + (ch^48);ch = getchar();}return w? -num: num;}
// cin.tie(0);
// ios::sync_with_stdio(false);
// head
// long long *long long 		**
//all 
int a[1200000];
signed main()
{
	int n;
	n=read();
	if(n>=400&&n<=599){
		printf("%d\n",8);
	}
	else if(n>=600&&n<=799){
		printf("%d\n",7);
	}
	else if(n>=800&&n<=999){
		printf("%d\n",6);
	}
	else if(n>=1000&&n<=1199){
		printf("%d\n",5);
	}
	else if(n>=1200&&n<=1399){
		printf("%d\n",4);
	}
	else if(n>=1400&&n<=1599){
		printf("%d\n",3);
	}
	else if(n>=1600&&n<=1799){
		printf("%d\n",2);
	}
	else if(n>=1800&&n<=1999){
		printf("%d\n",1);
	}
    return 0;
}

Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        string S = cin.next();
        bool flag = true;
        char prev = '\0';
        for (int i = 0; i < 4; ++i)
        {
            if (S[i] == prev)
            {
                flag = false;
                break;
            }

            prev = S[i];
        }

        WriteLine(flag?"Good":"Bad");
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 11092
def examA():
    S, W = LI()
    if S<=W:
        print("unsafe")
    else:
        print("safe")
    return

def examB():
    A, B, C, D = LI()
    while(True):
        C -= B
        if C<=0:
            print("Yes")
            break
        A -= D
        if A<=0:
            print("No")
            break
    return

def examC():
    N = I()
    S = [SI()for _ in range(N)]
    Set = set(S)
    ans = len(Set)
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int,readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examC()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 36376
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	string s;
	ll w;
	cin>>s>>w;
	rep(i,s.size()){
		if(i%w==0)cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 256
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int x;
	std::set<int> s;
	for (int i = 0; i < 3; ++i)
	{
		std::cin >> x;
		s.insert(x);
	}
	std::cout << s.size() << "\n";
}


Measured memory_bytes: 256
S = input()

AA = int(S[:2])
BB = int(S[2:])

if (0 < AA < 13) and (0 < BB < 13) :
    print("AMBIGUOUS")
elif 0< AA < 13:
    print("MMYY")
elif 0< BB < 13 :
    print("YYMM")
else :
    print("NA")

Measured memory_bytes: 3060
// Kevin Mathew T
// Birla Institute of Technology, Mesra
// LinkedIn - https://www.linkedin.com/in/KevinMathewT/
// GitHub - https://github.com/KevinMathewT
// CodeForces - https://codeforces.com/profile/KevinMathew
// CodeChef - https://www.codechef.com/users/KevinMathew
// HackerRank - https://www.hackerrank.com/KevinMathew

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double ld;
#define F first
#define S second
#define fi(a, b) for(ll i=(a);i<=b;i++)
#define fj(a, b) for(ll j=(a);j<=b;j++)
#define fid(a, b) for(ll i=(a);i>=b;i--)
#define fjd(a, b) for(ll j=(a);j>=b;j--)

// #include <ext/pb_ds/assoc_container.hpp> // Common file 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> // for less 
// #include <iostream> 
// using namespace __gnu_pbds; 
// using namespace std; 
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) : Value at kth index in sorted array. 
// order_of_key(k) : Index of the value k.

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v : V) os << v << " ";
    os << "]";
	return os;
}
template<class T> ostream& operator<<(ostream &os, set<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class T> ostream& operator<<(ostream &os, multiset<T> S){
    os << "{ ";
    for(auto s:S) os<<s<<" ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}
template<class L, class R> ostream& operator<<(ostream &os, unordered_map<L,R> M) {
    os << "{ ";
    for(auto m:M) os<<"("<<m.F<<":"<<m.S<<") ";
    return os<<"}";
}


const ll N = 1, M = 1e9 + 7;
ll n, k;

ll power(ll a, ll x) {
	a = a % M;
	if(x == 0) return 1;
	if(x == 1) return a;
	if(x % 2 == 0) return power((a * a) % M, x / 2);
	return (a * (power((a * a) % M, x / 2))) % M;
}

void solve(){
	cin >> n >> k;
	ll tot = 0;
	fi(k, n + 1) {
		ll z = n - i;
		ll t1 = (((n * (n + 1)) % M) * power(2, M - 2)) % M;
		ll t2 = ((z * (z + 1)) % M * power(2, M - 2)) % M;
		ll t3 = ((i * (i - 1)) % M * power(2, M - 2)) % M;
		// cout << t1 << ' ' << t2 << ' ' << t3 << ' ' << "\n";
		// cout << (((n * (n + 1)) / 2) - ((z * (z + 1)) / 2)) << " ";
		// cout << ((i * (i - 1)) / 2) << "\n";
		// tot = (tot + ((((((((n * (n + 1)) % M)) * power(2, M - 2)) % M)) - ((((((z * (z + 1)) % M)) * power(2, M - 2)) % M))) - ((((((((i * (i - 1)) % M)))) * power(2, M - 2)) % M)) + 1 + M) % M) % M;
		tot = ((tot + (((t1 - t2 + M) % M) - t3 + M) % M) % M + 1) % M;
		// cout << tot << "\n";
	}

	cout << tot << "\n";
}

int main(){
	// freopen("input.txt", "r", stdin);		//Comment
	// freopen("output.txt", "w", stdout);		//this out.
	ios::sync_with_stdio(false);			//Not
	cin.tie(NULL);							//this.
	cout.tie(0);							//or this.

	// ll T;
	// cin >> T;
	// while(T--)
		solve();

	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std; //std::の省略のため
using ll = long long;

int main()
{
  string S, T;
  int first;
  bool judge = false;
  bool a = true;
  cin >> S >> T;

  for (int i = 0; i <= (int)S.size() - (int)T.size(); i++)
  {
    if (S[i] == T[0] || S[i] == '?')
    {

      for (int j = 0; j < (int)T.size(); j++)
      {
        if (S[i + j] != T[j] && S[i + j] != '?')
          break;

        if (S[i + j] == '?')
          a = false;

        if (j == (int)T.size() - 1)
        {
          first = i;
          judge = true;
        }
      }
    }

    if (judge && a)
      break;
  }

  if (judge)
  {
    for (int j = 0; j < (int)T.size(); j++)
      S[first + j] = T[j];

    for (int i = 0; i < (int)S.size(); i++)
    {
      if (S[i] == '?')
        S[i] = 'a';
    }
    cout << S << endl;
  }
  else
    cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(c<a)	{printf("No\n");return 0;}
	if(c>b) {printf("No\n");return 0;}
	printf("Yes\n");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n][3];
    for (int i = 0; i < n; i++) {
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    int dp[n][4];
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    dp[0][4] = max(dp[0][0], max(dp[0][1], dp[0][2]));
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][1] + a[i][0], dp[i - 1][2] + a[i][0]);
        dp[i][1] = max(dp[i - 1][0] + a[i][1], dp[i - 1][2] + a[i][1]);
        dp[i][2] = max(dp[i - 1][1] + a[i][2], dp[i - 1][0] + a[i][2]);
    }
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  char s[27];
  int i,j;
  scanf("%s",&s);
  for(i=0;i<strlen(s);i++){
    for(j=i+1;j<strlen(s);j++){
      if(s[i]==s[j]){
        printf("no");
        return 0;
      }
    }
  }
  printf("yes");
  return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
p = list(map(int, input().split()))

pls = [0.0 for _ in range(n+1)]

for i in range(1, n+1):
    pls[i] = pls[i-1] + (p[i-1]+1)/2

ans = 0

for i in range(n-k+1):
    if pls[i+k]-pls[i] > ans:
        ans = pls[i+k]-pls[i]
print(ans)

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

int main(){
    int n, num;
    char mark;
    cin >> n;
    bool cards[4][13] = {false};
    char marks[4] = {'S','H','C','D'};

    for(int i = 0; i < n; ++i){
        cin >> mark >> num;
        for(int j = 0; j < 4; ++j){
            if(mark == marks[j]){
                cards[j][num -1] = true;
                break;
            }
        }
    }

    for(int i = 0;i < 4; ++i){
        for(int j = 0; j < 13; ++j){
            if(!cards[i][j]){
                cout << marks[i] << " " << j + 1 << endl;
            }
        }
    }
}

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

int a[3000];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, sum = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> a[i];
		sum += a[i] - 1;
	}
	cout << sum << endl;
}


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

using namespace std;

long long n, l;
vector<long long> a;
vector<int> ans;

int main() {
	cin >> n >> l;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool hantei = false;
	for (int i = 1; i < n; i++) {
		if (a[i] + a[i - 1] >= l) {
			hantei = true;
		}
	}
	if (!hantei) {
		cout << "Impossible" << endl;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (a[i] + a[i - 1] >= l) {
			ans.push_back(i - 1);
			break;
		}
	}
	for (int i = 0; i < ans[0]; i++) {
		ans.push_back(ans[0] - i - 1);
	}
	for (int i = 0; i < n - ans[0] - 2; i++) {
		ans.push_back(ans[0] + i + 1);
	}
	cout << "Possible" << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[ans.size() - 1 - i] + 1 << endl;
	}
	//cin >> n;
	return 0;
}

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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#define db(x) cout << "> " << #x << " = " \
	<< (x) << '\n'
#define db2(x, y) cout << "> " << #x << " = " \
	<< (x) << ", " << #y << " = " << (y) << '\n'
#define db3(x, y, z) cout << "> " << #x << \
	" = " << (x) << ", " << #y << " = " << \
	(y) << ", " << #z << " = " << (z) << '\n'

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<vector<int>> vvi;
typedef map<int, int> mii;
typedef set<int> si;

int n, p[25];

int main() {
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 1; i < n - 1; ++i)
		if ((p[i] > p[i + 1] && p[i] < p[i - 1])
		    || (p[i] < p[i + 1] && p[i] > p[i - 1]))
			++ans;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

    int arr[] = {a, b, c};

    for (int n = 0; n < 2; n++)
    {
        for (int i = 0; i < 2 - n; i++)
        {
            if (arr[i] > arr[i+1])
            {
                std::swap(arr[i], arr[i+1]);
            }
        }
    }

    std::cout << arr[0] << " " << arr[1] << " " << arr[2] << std::endl;

    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

ll solve(ll n){
    ll cou=0;
    while(cou*cou<=n){
        cou++;
    }
    return pow(cou-1,2);
}
int main(){
    ll n;
    cin >> n;
    ll ans = solve(n);
    cout << ans << endl;
}


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

using namespace std;
 
const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;
const int M = 998244353;

#define x first
#define y second

struct fenwick {
    int n;
    vector<int> F;

    fenwick(int n) : n(n), F(vector<int>(n)) { }

    void upd(int i, int x) {
        for (; i < n; i |= i + 1) F[i] += x;
    }

    int get(int r) {
        int res = 0;

        for (; r >= 0; r &= r + 1, --r)
            res += F[r];

        return res;
    }
};
 
int n;
long long ans;
long long pw[N];
pair<int, int> p[N];
 
bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> p[i].x >> p[i].y;
 
    return true;
}

void calc() {
    sort(p, p + n);
    vector<int> v;

    for (int i = 0; i < n; ++i)
        v.emplace_back(p[i].y);

    sort(begin(v), end(v));
    v.resize(unique(begin(v), end(v)) - begin(v));
    fenwick f(v.size());

    for (int i = 0; i < n; ++i) {
        ans -= pw[i];
        ans += pw[f.get(lower_bound(begin(v), end(v), p[i].y) - begin(v))];
        f.upd(lower_bound(begin(v), end(v), p[i].y) - begin(v), 1);
    }
}
 
void solve() {
    pw[0] = 1;
    for (int i = 0; i < n; pw[++i] = 2 * pw[i - 1] % M) { }
    ans = n * (pw[n] - 1);
    calc();
    for (int i = 0; i < n; p[i].x *= -1, p[i].y *= -1, ++i) { }
    calc();
    for (int i = 0; i < n; swap(p[i].x *= -1, p[i].y), ++i) { }
    calc();
    for (int i = 0; i < n; p[i].x *= -1, p[i].y *= -1, ++i) { }
    calc();
    cout << (M + ans % M) % M << endl;
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    while (read())
        solve();
 
    return 0;
}



Measured memory_bytes: 5212
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

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

    vector<int> dp(S + 1, 0);
    dp[0] = 1;
    for (int i = 3; i <= S; ++i) {
        dp[i] = (dp[i - 1] + dp[i - 3]) % 1000000007;
    }
    cout << dp[S] << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
    ll x, y;
    cin >> x >> y;
    if (x * 2 <= y and x * 4 >= y and y % 2 == 0) cout << "Yes" << endl;
    else cout << "No"<<endl;
}


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if (A+B>C+D) {cout << "Left" << endl;}
    else if (A+B==C+D) {cout << "Balanced" << endl;}
    else {cout << "Right" << endl;}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	X := nextInt()

	x := X
	fmt.Println(findPrimeNumber(x))
}

func findPrimeNumber(x int) int {
	if x == 2 {
		return 2
	}
	for {
		for i := 2; i < x; i++ {
			if x%i == 0 {
				break
			}
			if i == x-1 {
				return i + 1
			}
		}
		x += 1
	}
}


Measured memory_bytes: 640
s = input().rstrip()

count1 = 0
count2 = 0

for i, num in enumerate(s):
    if i % 2 == 1 and num == '0':
        count1 += 1
    elif i % 2 != 1 and num == '1':
        count1 += 1

for i, num in enumerate(s):
    if i % 2 == 1 and num == '1':
        count2 += 1
    elif i % 2 != 1 and num == '0':
        count2 += 1

result = min(count1, count2)
print(result)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int H = Integer.parseInt(sc.next());
		int W = Integer.parseInt(sc.next());
		int h = Integer.parseInt(sc.next());
		int w = Integer.parseInt(sc.next());

		System.out.println(H * W - (h * W + H * w) + w * h);

	}
}

Measured memory_bytes: 22996
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())
    d = list(map(int, readline().split()))

    ans = 0

    for i in range(N):
        for j in range(i + 1, N):
            ans += d[i] * d[j]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62796