akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int n,tmp;
  	cin>>n;
  	
  int arr[n];
  
  for(int i=1;i<=n;i++)
  {
    cin>>tmp;
    arr[tmp-1]=i;
  }
  
  for(int i=0;i<n;i++)
  {
    cout<<arr[i]<<" ";
  }
  cout<<endl;
  	
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define lp(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define ll long long
#define ii pair<string,int>ii;

string IntToStr(int tmp){
    ostringstream out;
    out << tmp;
    return out.str();
}

int main()
{

    int a,b;
    cin>>a>>b;
    int x=a+b;
    if(a%3==0 || b%3==0 || x%3==0)cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy 2333333
#define bql 2147483647
using namespace std;
int a,b;
int main()
{
	cin>>a>>b;
	if (a>=13)
	   cout<<b<<endl;
 else if (a<=12 && a>5)
    cout<<b/2<<endl;
 else
    cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
signed main() {
	ll r, d, x;
	cin >> r >> d >> x;
	rep(i, 10) {
		cout << r * x - d << endl;
		x = r * x - d;
	}
	ggr
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

int main()
{
    int A, B, C, ba8yc = 0, ba8yb = 0;
    cin >> A >> B >> C;
    if (C > (A + B))
    {
        ba8yc = A + B + 1;
        ba8yb = B;
    }
    else if (C == (A + B))
    {
        ba8yc = C;
        ba8yb = B;
    }
    else
    {
        ba8yc = C;
        ba8yb = B;
    }
    cout << ba8yb + ba8yc << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

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

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



int main(void) {
  int n;
  string s;
  cin >> n >> s;
  int bal = 0;
  int balmi = 0;
  REP(i, 0, n) {
    if (s[i] == '(') {
      bal += 1;
    } else {
      bal -= 1;
    }
    balmi = min(balmi, bal);
  }
  REP(i, 0, -balmi) {
    s = "(" + s;
  }
  bal = 0;
  REP(i, 0, s.length()) {
    if (s[i] == '(') {
      bal += 1;
    } else {
      bal -= 1;
    }
  }
  assert (bal >= 0);
  REP(i, 0, bal) {
    s = s + ")";
  }
  cout << s << endl;
      
}


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

using namespace std;

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

ll cmp1(ll cH, ll cW){
	ll res = INF;
	for (ll w1 = 1LL; w1 < cW; ++w1){
		ll w2 = (cW - w1) / 2LL;
		ll w3 = cW - w1 - w2;
		ll s1 = cH * w1;
		ll s2 = cH * w2;
		ll s3 = cH * w3;
		ll minS = min(s1, min(s2, s3));
		ll maxS = max(s1, max(s2, s3));
		res = min(res, maxS - minS);
	} // end for
	return res;
}

ll cmp2(ll cH, ll cW){
	ll res = INF;
	ll w = cW / 2LL;
	for (ll h = 1LL; h < cH; ++h){
		ll s1 = h * cW;
		ll s2 = (cH - h) * w;
		ll s3 = (cH - h) * (cW - w);
		ll minS = min(s1, min(s2, s3));
		ll maxS = max(s1, max(s2, s3));
		res = min(res, maxS - minS);
	} // end for
	return res;
} 

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll H, W; cin >> H >> W;
	if ((H % 3LL == 0LL) || (W % 3LL == 0LL)){
		cout << 0 << endl;
		return 0;
	} // end if

  	ll res = INF;
	res = min(res, cmp1(H,W));
	res = min(res, cmp1(W,H));
	res = min(res, cmp2(H,W));
	res = min(res, cmp2(W,H));

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

bool isprime(int n);
 
int main()
{
   int n;
   while(1){
    cin >> n;
    if(n == 1) break;
    cout << n << ':';
    for(int i = 0; i <= n / 7; i++){
        int divisor = 0;
        if(n % (7 * i + 1) == 0){
            divisor = 7 * i + 1;
            if(isprime(divisor)) cout << ' ' << divisor;
        } 
        if(n % (7 * i + 6) == 0){
            divisor = 7 * i + 6;
            if(isprime(divisor)) cout << ' ' << divisor;
        } 
    }
        cout << endl;
    }
    return 0;
}

bool isprime(int n)
{
    if(n == 1) return false;
    else if(n == 6) return true;
    else if(n % 6 == 0) return false;
    else {
        for(int i = 1; 7 * i <= n; i++){
            if(n == 7 * i + 1) break;
            else if(n == 7 * i + 6){
                if(n % (7 * i + 1) == 0) return false;
                else return true;
            } else if(n % (7 * i + 1) == 0 || n % (7 * i + 6) == 0) return false;
        }
    }
    return true;
}

Measured memory_bytes: 1160
package main
 
import "fmt"
 
func main() {
	var H,N,A int
	fmt.Scan(&H,&N)
	waza := make([]int,N)
 
	for i,_ := range waza {
		fmt.Scan(&A)
		waza[i] = A
	}
 
	sum := 0
	for _,value := range waza {
		sum += value
	}
	if sum >= H {
		fmt.Println("Yes")
	}else{
		fmt.Println("No")
	}
 
}

Measured memory_bytes: 5504
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int N, W, H;
vector<int> x, y, w;
vector<int> imosx, imosy;
/**********************************************/

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

    cin >> N >> W >> H;
    x.resize(N);
    y.resize(N);
    w.resize(N);
    REP(i, N) cin >> x[i] >> y[i] >> w[i];

    imosx.assign(W+2, 0);
    imosy.assign(H+2, 0);
    REP(i, N){
        imosx[max(x[i]-w[i], 0)]++;
        imosx[min(x[i]+w[i], W+1)]--;
        imosy[max(y[i]-w[i], 0)]++;
        imosy[min(y[i]+w[i], H+1)]--;
    }

    REP(i, W){
        imosx[i+1] += imosx[i];
    }
    REP(i, H){
        imosy[i+1] += imosy[i];
    }
    bool flag1 = true, flag2 = true;
    REP(i, W) if(imosx[i] <= 0) flag1 = false;
    REP(i, H) if(imosy[i] <= 0) flag2 = false;
    
    if(flag1 || flag2) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 4948
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    if(M == 0){
        if(N == 1) cout << 0 << endl;
        else if(N == 2) cout << 10 << endl;
        else if(N == 3) cout << 100 << endl;
        return 0;
    }
    
    vector<int> s(M),c(M);
    vector<pair<int,int>> p(M);
    for(int i = 0; i < M; i++){
        cin >> s[i] >> c[i];
        p[i] = make_pair(s[i],c[i]);
    }
    sort(p.begin(),p.end());
    
    if(N == 1){
        for(int i = 0; i < M; i++){
            if(p[i].first != 1){
                cout << -1 << endl;
                return 0;
            }
        }
        
        for(int i = 0; i < M-1; i++){
            if(p[i].first == p[i+1].first && p[i].second != p[i+1].second ){
                cout << -1 << endl;
                return 0;
            }
        }
        cout << p[0].second << endl;
    }
    
    else if(N == 2){
    for(int i = 0; i < M; i++){
        if(p[i].first == 1 && p[i].second == 0){
            cout << -1 << endl;
            return 0;
        }
        if(p[i].first == 3){
            cout << -1 << endl;
            return 0;
        }
    }
    for(int i = 0; i < M-1; i++){
            if(p[i].first == p[i+1].first && p[i].second != p[i+1].second){
                cout << -1 << endl;
                return 0;
            }
    }
    
    bool flag = false;
    for(int i = 0; i < M; i++){
        if(p[i].first == 1){
            cout << p[i].second;
            flag = true;
            break;
        }
    }
    if(flag == false) cout << 1;
    
    flag = false;
    for(int i = 0; i < M; i++){
        if(p[i].first == 2){
            cout << p[i].second;
            flag = true;
            break;
        }
    }
    if(flag == false) cout << 0;
    }
    
    else if(N == 3){
    for(int i = 0; i < M; i++){
        if(p[i].first == 1 && p[i].second == 0){
            cout << -1 << endl;
            return 0;
        }
    }
    
    for(int i = 0; i < M-1; i++){
            if(p[i].first == p[i+1].first && p[i].second != p[i+1].second){
                cout << -1 << endl;
                return 0;
            }
    }
    
    bool flag = false;
    for(int i = 0; i < M; i++){
        if(p[i].first == 1){
            cout << p[i].second;
            flag = true;
            break;
        }
    }
    if(flag == false) cout << 1;
    
    flag = false;
    for(int i = 0; i < M; i++){
        if(p[i].first == 2){
            cout << p[i].second;
            flag = true;
            break;
        }
    }
    if(flag == false) cout << 0;
    
    flag = false;
    for(int i = 0; i < M; i++){
        if(p[i].first == 3){
            cout << p[i].second;
            flag = true;
            break;
        }
    }
    if(flag == false) cout << 0;
    }
}

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

#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;

const int iinf = 1e9 + 7;
const int oo = 0x3f3f3f3f;
const LL linf = 1ll << 60;
const flt dinf = 1e60;

template <typename T> inline void scf(T &x)
{
    bool f = 0;
    x = 0;
    char c = getchar();
    while(c != '-' && (c < '0' || c > '9')) c = getchar();
    if(c == '-') f = 1, c = getchar();
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    if(f) x = -x;
    return;
}

template <typename T1, typename T2> void scf(T1 &x, T2 &y)
{
    scf(x);
    return scf(y);
}

template <typename T1, typename T2, typename T3> void scf(T1 &x, T2 &y, T3 &z)
{
    scf(x);
    scf(y);
    return scf(z);
}

template <typename T1, typename T2, typename T3, typename T4> void scf(T1 &x, T2 &y, T3 &z, T4 &w)
{
    scf(x);
    scf(y);
    scf(z);
    return scf(w);
}

inline char mygetchar()
{
    char c = getchar();
    while(c == ' ' || c == '\n') c = getchar();
    return c;
}

template <typename T> inline bool chkmax(T &x, const T &y)
{
    return y > x ? x = y, 1 : 0;
}

template <typename T> inline bool chkmin(T &x, const T &y)
{
    return y < x ? x = y, 1 : 0;
}

#ifdef DEBUG
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

//---------------------------------------------------------head----------------------------------------------------

const int maxn = 330;

int n, m, ans;
int a[maxn][maxn];
vi has[maxn];
bool f[maxn];

int main()
{
    scf(n, m);
    ans = n;
    forn(i, 1, n) {
        forn(j, 1, m) {
            scf(a[i][j]);
            f[j] = 1;
        }
        has[a[i][1]].pb(i);
    }
    forn(j, 1, m) {
        int mx = 0, rem;
        forn(k, 1, m) {
            if(chkmax(mx, SZ(has[k]))) {
                rem = k;
            }
        }
        chkmin(ans, mx);
        f[rem] = 0;
        for(int i: has[rem]) {
            for (int k = 1; k <= m; ++k) {
                if(f[a[i][k]]) {
                    has[a[i][k]].pb(i);
                    break;
                }
            }
        }
        has[rem].clear();
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 1280
while 1:
  n,x=map(int,input().split())
  if n==0 and x==0:
    exit()
  ans=0
  for i in range(1,n+1):
    for j in range(i+1,n+1):
      for k in range(j+1,n+1):
        if i+j+k==x:
          ans+=1
  print(ans)


Measured memory_bytes: 5596
#include<stdio.h>
#include<math.h>
int dp[100][100];
int n, d;
int main() {
    scanf("%d%d", &n, &d);
    int counter = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            scanf("%d", &dp[i][j]);
        }
    }
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            int su = 0;
            for (int k = 0; k < d; k++) {
                su += ((dp[i][k] - dp[j][k]) * (dp[i][k] - dp[j][k]));
                //printf("su: %d\n", su);
            }
            
            if ((int) sqrt(su) * (int) sqrt(su) == su) {
                counter++;
                //printf("%d %d %d\n", i, j, su);
            }
        }
    }
    printf("%d\n", counter);
    return 0;
}


Measured memory_bytes: 256
import numpy as np 


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


s_list = list()

for i in range(n):
    line = list(map(int, input().split()))
    s_list.append([line[0], np.array(line[1:], dtype=int)])


cands = list()
# cost, value
cands.append([0, np.zeros(m, dtype=int)])


for l in s_list:
    next_cands = list()
    for c in cands:
        next_cands.append([c[0] + l[0], c[1] + l[1]])
    cands += next_cands


min_cost = 10**12
for l in cands:
    if (l[1] >= x).all() and l[0] < min_cost:
        min_cost = l[0]


if min_cost == 10**12:
    print(-1)
else:
    print(min_cost)
    



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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
 
const ll MAX = 1e6 + 3;
const ll inf = 1e18;
const ll mod = 1e6 + 3;


vii c;

int main(){
    fastio;
    ll n,x,y;
    string s;
    cin >> n ;
    f(i,0,n){
        cin >> x >> y;
        c.push_back({x,y});
    }
    sort(all(c));
    ld ans = 0;
    while( 1 ){
        f(i,1,n){
            ans += (sqrt( 1.0*(c[i].ff -c[i-1].ff)*(c[i].ff -c[i-1].ff) + 1.0*(c[i].ss -c[i-1].ss)*(c[i].ss -c[i-1].ss)  ));
        }
        if(next_permutation(all(c)) == false) break;
        
    }
    f(i,2,n+1) ans /= 1.0*i;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 3796
#include<iostream>
#include<string>
#include<cstring>
#include<cstdlib>

#define N 16397
using namespace std;

struct node
{
	char name[13];
	node *next;
};

int hashfunction(char *s)
{
	unsigned hashval;
	for (hashval = 5381; *s != '\0'; s++)
		hashval = (hashval << 5) + hashval + *s;
	return hashval % N;
}

int main()
{
	int n, index;
	cin >> n;
	node *table[N]{NULL};
	string com;
	char name[13];
	for (int i = 0; i < n; i++)
	{
		cin >> com >> name;
		index = hashfunction(name);
		bool ok = false;
		if (com[0] == 'i')
		{
			node *t = (node*)malloc(sizeof(node));
			strcpy(t->name, name);
			t->next = NULL;
			if (table[index] != NULL)
				t->next = table[index];
			table[index] = t;
		}
		else
		{
			node *cur = table[index];
			while (cur != NULL)
			{
				if (!strcmp(cur->name, name))
				{
					ok = true;
					break;
				}
				cur = cur->next;
			}
			if (ok)
				cout << "yes" << endl;
			else		
				cout << "no" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 21136
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), m = sc.nextInt(), q = sc.nextInt();
        int[][] loc = new int[m][2];
        int[][] ques = new int[q][2];
        int[][] count2 = new int[n + 1][n + 1];

        for (int i = 0; i < m; i++) {
            loc[i][0] = sc.nextInt();
            loc[i][1] = sc.nextInt();
        }
        for (int i = 0; i < q; i++) {
            ques[i][0] = sc.nextInt();
            ques[i][1] = sc.nextInt();
        }

        for (int i = 0; i < m; i++) {
            count2[loc[i][0]][loc[i][1]]++;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                count2[i][j] = count2[i][j] + count2[i][j - 1] + count2[i - 1][j] - count2[i - 1][j - 1];
            }
        }
        for (int i = 0; i < q; i++) {
            int ans = count2[ques[i][1]][ques[i][1]]
                      - count2[ques[i][1]][ques[i][0] - 1] - count2[ques[i][0] - 1][ques[i][1]]
                      + count2[ques[i][0] - 1][ques[i][0] - 1];
            System.out.println(ans);
        }
    }
}


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

int main(){
    int N,A = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        if (S == "Y"){
            A = 4;
        }
    }  
 
    if(A == 4){
        cout << "Four" <<endl;
    }  
    else{
        cout << "Three" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

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

  lol n;
  cin >> n;
  lol a[n + 5];
  reps(i, n){
    cin >> a[i];
  }
  lol sum = 0, nasu = INF;
  for(int i = 1;i < n;i ++){
    if(a[i] < 0){
      a[i] *= -1;
      a[i + 1] *= -1;
    } else if(a[i] == 0){
      a[i + 1] = max(a[i + 1], -a[i + 1]);
    }
    nasu = min(nasu, a[i]);
    sum += a[i];
  }
  if(a[n] >= 0){
    cout << sum + a[n] << '\n';
  } else {
    if(nasu <= max(a[n], -a[n])){
      cout << sum - 2 * nasu + -a[n] << '\n';
    } else {
      cout << sum + a[n] << '\n';
    }
  }
  return 0;
}


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

long long int n;
vector<long long int> v;
long long int mem[3005][3005][3];
	
long long int dp(long long int i,long long int j,long long int t){
	if(i==j){
		if(t==0)
		return v[i];
		else
		return (-1)*v[i];
	}
	if(mem[i][j][t]!=-1)
	return mem[i][j][t];
	long long int ans;
	if(t==0){
		ans = dp(i+1,j,1-t)+v[i];
		ans = max(ans,v[j]+dp(i,j-1,1-t));
	}
	if(t==1){
		ans = dp(i+1,j,1-t)-v[i];
		ans = min(ans,dp(i,j-1,1-t)-v[j]);
	}
	mem[i][j][t]=ans;
	return ans;
}
	
int main(){
	
	cin>>n;
	memset(mem,-1,sizeof(mem));
	for(long long int i=0;i<n;i++)
	{
		long long int x;
		cin>>x;
		v.push_back(x);
	}
	cout<<dp(0,n-1,0);
	return 0;
}

Measured memory_bytes: 215496
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

#define MAX 10

double d;

int main() {
	while (1) {
		scanf("%lf", &d);
		if (d < 0)
			return 0;

		if(d >= 256 || fmod(d, .0625) != 0)
			puts("NA");
		else {
			double r = 128;
			for(int i = 0; i < 12; i++, r *= .5) {
				if(i == 8)
					printf(".");
				printf("%d", d / r >= 1);
				d = fmod(d, r);
			}
			puts("");
		}
	}
}

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

string d;
int ans=1000;
int now;
int tar;

int main()
{
    ios::sync_with_stdio(false);
	
	cin>>d;
	for (int i=0;i<d.size();i++)
	{
		tar=d[i];
		now=0;
		string a,b;
		a=d;
		b.clear();
		while (1)
		{
			bool flag=1;
			for (int o=0;o<a.size();o++) if (a[o]!=tar) flag=0;
			if (flag)
			{
				ans=min(ans,now);
				break;
			}
			now++;
			for (int o=0;o<a.size()-1;o++) 
				if (a[o]==tar || a[o+1]==tar) b.push_back(tar);
				else b.push_back(a[o]);
			a=b;
			b.clear();
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
//https://beta.atcoder.jp/contests/abc113/tasks/abc113_c
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

string f(int n,int d){
    string s=to_string(n);
    while(s.size()<d)s="0"+s;
    return s;
}

int p[112345];
int y[112345];
string s[112345];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i:range(m)){
        cin>>p[i]>>y[i];
        s[i]=f(p[i],6)+f(y[i],10);
    }
    sort(s,s+m);
    for(int i:range(m)){
        cout<<f(p[i],6);
        int id = lower_bound(s,s+m,f(p[i],6)+f(y[i],10))-lower_bound(s,s+m,f(p[i],6))+1;
        cout<<f(id,6)<<endl;
    }
    return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
        #include<iostream>
        #include<cstdio>
        #include<vector>
        #include<queue>
        #include<map>
        #include<cstring>
        #include<string>
        #include <math.h>
        #include<algorithm>
    //    #include <boost/multiprecision/cpp_int.hpp>
        #include<functional>
      #define int long long
        #define inf  1000000007
        #define pa pair<int,int>
#define ll long long
        #define pal pair<ll,ll>
        #define ppa pair<int,pa>
        #define  mp make_pair
        #define EPS (1e-10)
        #define equals(a,b) (fabs((a)-(b))<EPS)

        using namespace std;

        class Point{
        	public:
        	double x,y;
        	Point(double x=0,double y=0):x(x),y(y) {}
        	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
        	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
        	Point operator * (double a) {return Point(x*a,y*a);}
        	Point operator / (double a) {return Point(x/a,y/a);}
        	double absv() {return sqrt(norm());}
        	double norm() {return x*x+y*y;}
        	bool operator < (const Point &p) const{
        		return x != p.x ? x<p.x: y<p.y;
        	}
        	bool operator == (const Point &p) const{
        		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
        	}
        };
        typedef Point Vector;

        struct Segment{
        Point p1,p2;
        };

    double hen(Vector a){
    if(fabs(a.x)<EPS && a.y>0) return acos(0);
    else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
    else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
    else if(fabs(a.y)<EPS && a.x>0) return 0.0;
    else if(a.y>0) return acos(a.x/a.absv());
    else return 2*acos(0)+acos(-a.x/a.absv());

    }

        double dot(Vector a,Vector b){
        	return a.x*b.x+a.y*b.y;
        }
        double cross(Vector a,Vector b){
        	return a.x*b.y-a.y*b.x;
        }
        int dx[4] = {1, 0, -1, 0};
        int dy[4] = {0, 1, 0, -1};
        //----------------kokomade temple------------
int h,w,n;

pa z[100020];
set<pa> se;

int kosuu[20]={0};
signed main(){
cin>>h>>w>>n;
	for(int i=0;i<n;i++){
		cin>>z[i].first>>z[i].second;
		se.insert(mp(z[i].first,z[i].second));
	}
	
	
	for(int i=0;i<n;i++){
		int a=z[i].first,b=z[i].second;
		int ma[10][10]={0};
		for(int j=a-2;j<=a+2;j++){
			for(int k=b-2;k<=b+2;k++){
				if(j<1 || k<1|| j>h || k>w){
					ma[j+2-a][k+2-b]=2;
				}
				else if(se.find(mp(j,k))!=se.end()){
					ma[j+2-a][k+2-b]=1;
				}
	//			cout<<ma[j+2-a][k+2-b];
			}
	//		cout<<endl;
		}
		
	//	cout<<endl;
		
		for(int j=0;j<3;j++)for(int k=0;k<3;k++){
			int u=0;
			for(int jj=j;jj<j+3;jj++)for(int kk=k;kk<k+3;kk++){
				if(ma[jj][kk]==2){
					goto lll;
				}
				if(ma[jj][kk]==1) u++;
			}
			kosuu[u]++;
		//	cout<<u<<endl;
			
			lll:;
			
		}
	//	cout<<endl;
		
	}
	int sum=0;
	for(int i=1;i<=9;i++){
		kosuu[i] /= i;
		sum += kosuu[i];
	}
	cout<<(h-2)*(w-2)-sum<<endl;
	for(int i=1;i<10;i++) cout<<kosuu[i]<<endl;
	
	return 0;
        }
        
//printf("%.10f\n",ans);


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

using namespace std;

#define bug(x) cerr << #x << " = " << x << '\n'
#define ll     long long
#define x      first
#define y      second
#define eb     emplace_back
#define maxn
#define mod    1000000007

int main() {
        #ifndef ONLINE_JUDGE
            //freopen(".inp","r",stdin);
        #endif // ONLINE_JUDGE

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

        int n;
        cin >> n;

        vector<int> a (n + 1);
        for(int i = 1; i <= n; ++ i)
            cin >> a[i];
        int o = 0; ll ret = 0;
        for(int i = 1; i <= n; ++ i) {
            o = max(o, a[i]);
            ret += (ll) o - a[i];
        }
        cout << ret;
}





Measured memory_bytes: 3968
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

a = k()
b = l()
b.sort()

print(abs(b[0]-b[-1]))

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


signed main(){

 int n;
  cin>>n;
  vector<int> a(n);
  bool flag=true;
  rep(i,n){
    cin>>a[i];
    if(a[0]!=a[i]) flag=false;
  }

  if(flag){
    cout<<n<<endl;
    return 0;
  }

  vector<int> b(n+1,inf);

  rrep(i,n-1){
    int t=upper_bound(all(b),a[i])-b.begin();
    b[t]=a[i];
  }

  cout<<(lower_bound(all(b),inf)-b.begin())<<endl;

}

Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<math.h>
#include <iomanip>

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

using namespace std;

const int INF = 1000;

int N;

int main()
{
	string alphabet;

	for (char c = 'A'; c <= 'Z'; c++) {
		alphabet += c;
	}

	cin >> N;

	string S;
	cin >> S;

	string sum;

	rep(j, S.length()) {
		rep(i, alphabet.length()) {

			if (alphabet[i] == S[j]) {

				//サイズを超えるときは、Aから開始
				if (i + N >= alphabet.length()) {
					sum += alphabet[i + N - alphabet.length()];
				}
				else {
					sum += alphabet[i + N];
				}
			}

		}
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int ans = 0;
    int cur = 0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char c: s) {
        if (c == 'I') {
            cur++;
        } else {
            cur--;
        }
        ans = max(ans, cur);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def main():
    N,A,B = map(int,input().split())
    a = N//(A+B)
    b = N - (a * (A+B))
    if b >= A:
        print(a*A+A)
    elif b < A:
        print(a*A+b)

if __name__ == "__main__":
    main()

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

int main() {
  double N, K;
  cin >> N >> K;
  
  int NN = N;
  int KK = K;
  int limitation = min (NN, KK-1);
  
  double p1;
  // 1回さいころを振って勝利する確率
  
  if(K <= N){
    p1 = (N-K+1)/N;
  }else{
    p1 = 0;
  }

  double p2 = p1;
  int times_of_coin = 0; 
  
  if (limitation > 0){
    for (int i = limitation; i > 0; i--){
      times_of_coin = ceil(log(K/i)/log(2));
      p2 += 1/N*pow(0.50, times_of_coin);
      
      //cout << i << "  " << times_of_coin << " "  << 1/N*pow(0.50, times_of_coin) << endl;
    }
  }
  
  cout << fixed << setprecision(10);
  cout << p2 << endl;
 
    
}

Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()
A = LIST()

A_acc = list(accumulate(A))
A_acc_mod = [x%M for x in A_acc]

ans = 0
for value in Counter(A_acc_mod).values():
	ans += value*(value-1)//2

ans += Counter(A_acc_mod)[0]
print(ans)

Measured memory_bytes: 27620
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int k = inp.nextInt();
        int x = inp.nextInt();
        if (500 * k >= x) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

int main(){
	char ch,ch2,ch3;
	int num;
	int counter[26] = {0};
	
	while(cin >> ch){
		ch2 = tolower(ch);
		num = ch2 - 'a';
		
		counter[num]++;
	}
	
	for(int i=0; i<26; i++){
	    ch3 = 'a' + i;
	    cout << ch3 << " : " << counter[i] << endl;
	}
		
	return 0;
}

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

int main() {
  int n, m;
  int a[100];
  int score[100]={0};
  cin >> n >> m;

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

  for(int i=0; i<m; i++) {
    int exp;
    int wrong = 0;
    for(int j=0; j<n; j++) {
      cin >> exp;
      exp--;
      if( exp == a[i] ) score[j]++;
      else wrong++;
    }

    score[a[i]] += wrong;
  }

  for(int i=0; i<n; i++) {
    cout << score[i] << endl;
  }

}

Measured memory_bytes: 1164
#include <bits/stdc++.h> 
#include <functional> 
using namespace std;
typedef pair<int,int> pii;
#define fast   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define ld              long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define in              insert
#define ff              first
#define ss              second
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define sz(c)           (ll)c.size()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define rev             reverse
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << endl;
const ll inf = 1e18;  
const ll mod = 1e9 + 7;
const ll MOD = 998244353;
const ll MAX = 2e5 + 1;
//priority_queue<pii, vector<pii>, greater<pii> > pq;



inline ll add(ll a,ll b) {return ((a % mod) + (b % mod)) % mod;}
inline ll sub(ll a,ll b) {return ((a % mod) - (b % mod) + mod) % mod;}
inline ll mul(ll a,ll b) {return ((a % mod) * (b % mod)) % mod;}
ll pwr(ll x,ll n){
    if(n == 0){
        return 1;
    }
    if(n&1){
        return mul(x, pwr(mul(x, x), (n - 1) / 2));
    } else {
        return pwr(mul(x, x), n / 2);
    }
}
ll modInv(ll n){ 
    return pwr(n, mod - 2); 
}
ll gcd(ll a,ll b) {
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

/**

 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode() : val(0), left(nullptr), right(nullptr) {}
 *     TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
 *     TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
 * };
 */


int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    vector<int> b(n);
    rep(i,n) cin>>a[i]>>b[i];
    int cnt=0;
    rep(i,n){
        if(a[i]==b[i]){
            cnt++;
        }
        else {
            cnt=0;
        }
        if(cnt==3){
           cout<<"Yes"<<endl;
           return 0;
        }
    }
    cout<<"No"<<"\n";
    

    return 0;
}

Measured memory_bytes: 3636
import collections as c
ip = lambda : map(int, input().split())
# ##############

X = int(input())

def factorize(n):
    i=2
    result=0
    while True:
        if i**2>n:
            break
        count=0
        while n%i==0:
            n//=i
            count+= 1
        if count!=0:
            result+=count
        i+=1
    if n>1:
        result += 1
    return result
while factorize(X)>1 :
    X+=1
print(X)

Measured memory_bytes: 3444
#include<iostream>

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

using namespace std;

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

    int ans = 0;
    ans += max(a, b);

    if(max(a, b) == a){
        a -= 1;
    }
    else{
        b -= 1;
    }

    ans += max(a, b);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(){
	long long dp[21][100] = {};
	std::vector<int> numbers;
	int num,x;

	std::cin >> num;

	for(int i=0; i<num; ++i){
		std::cin >> x;
		numbers.push_back(x);
	}

	dp[numbers.at(0)][0] = 1; //first step

	for(int i=1; i<num-1; ++i){
		
		for(int j=numbers.at(i); j<21; ++j){ //0 < j - numbers.at(i)
			dp[j-numbers.at(i)][i] += dp[j][i-1];
		}

		for(int j=0; j<21-numbers.at(i); ++j){ //j + numbers.at(i) < 21
			dp[j+numbers.at(i)][i] += dp[j][i-1];
		}

	}

	std::cout << dp[numbers.at(num-1)][num-2] << std::endl; //n-2 = (n-1)-1
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

const lint INF=2e18;

lint func(lint x,lint y)
{
	lint ret=y-x;
	if(y<x)ret=INF;
	return ret;
}

int main()
{
	lint x,y;
	
	cin >> x >> y;
	
	lint ans=INF;
	ans=min(ans,func(x,y));
	ans=min(ans,1+func(-x,y));
	ans=min(ans,1+func(x,-y));
	ans=min(ans,2+func(-x,-y));

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


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
    scanf("%d",&n);
    if(n<105){
        printf("0");
    }else if((n>=105)&&(n<135)){
        printf("1");
    }else if((n>=135)&&(n<165)){
        printf("2");
    }else if((n>=165)&&(n<189)){
        printf("3");
    }else if((n>=189)&&(n<195)){
        printf("4");
    }else if(n>=195){
        printf("5");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		double th = Integer.parseInt(st.nextToken());
		double ts = Integer.parseInt(st.nextToken());
		double ah = Integer.parseInt(st.nextToken());
		double as = Integer.parseInt(st.nextToken());
		System.out.println(Math.ceil(th / as) >= Math.ceil(ah / ts) ? "Yes" : "No");
	}
}


Measured memory_bytes: 25320
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    if (t.substr(0, s.size()) == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

pair<int,int> a[5];
for(int i=0;i<5;i++){
    int t;
    cin>>t;
a[i].first=t%10;
a[i].second=t;
}

sort(a,a+5);

int last=0;
for(int i=0;i<5;i++){
    if(a[i].first!=0){
        last=i;
        break;
}
}

int ans=0;

for(int i=0;i<5;i++){
if(i==last){
    ans+=a[i].second;
}else{
    if(a[i].first==0){
        ans+=a[i].second;
    }else{
        ans+=10*(a[i].second/10+1);
    }
}
}

cout<<ans<<endl;


return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

#[allow(unused_macros)]
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        N: u8, S: chars,
    }

    for i in 0..S.len() {
        let S = S[i];
        print!("{}", ('A' as u8 + (S as u8 - 'A' as u8 + N) % 26) as char);
    }
}


Measured memory_bytes: 4352
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sticks = readLine()!!.split(" ").map { it.toInt() }.sorted()

    var sumCombination = 0
    for (i in 0 until sticks.size) {
        for (j in i + 1 until sticks.size) {
            for (k in sticks.size - 1 downTo j + 1) {
                val a = sticks[i]
                val b = sticks[j]
                val c = sticks[k]
                if (c < a + b) {
                    sumCombination += k - j
                    break
                }
            }
        }
    }

    println(sumCombination)
}

Measured memory_bytes: 43328
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>

#include <climits>
#include <cmath>
#include <cstring>

#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;

#define MOD 998244353

ll power(ll a , ll p)
{
	ll result = 1;
	while(p > 0)
	{
		// checking if last bit is 1 or not 
		if(p & 1)
			result = ( (result%MOD) * (a%MOD) ) % MOD;
		
		a = ( (a%MOD) * (a%MOD) ) % MOD;
		p = p>>1;
	}

	return result;
}

int main()
{
	FAST;
	int n;
	cin >> n;
	
	ll arr[n];
	
	for(int i=0 ; i<n ; i++)
		cin >> arr[i];
		
	if(arr[0] != 0)
	{
	    cout << "0";
	    return 0;
	}

	ll count[n];
	memset(count , 0 , sizeof(count));
	
	for(int i=0 ; i<n ; i++)
		count[arr[i]]++;
		
		
	if(count[0] != 1)
	{
	    cout << "0\n";
		return 0;
	}

	ll tree = 1;
	ll op = 1;
	ll temp = n-1;
	for(int i=1 ; i<n ; i++)
	{
		if(count[i] == 0)
		{
		    if(temp == 0)
				break;
			cout << "0\n";
			return 0;
		}

		temp -= count[i];
		ll ans = power(op , count[i]);
		tree = ((tree%MOD) * (ans%MOD))%MOD;
		op = count[i];
	}

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

Measured memory_bytes: 1792
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            String S = in.next();
            final int like = 753;
            int ans = Integer.MAX_VALUE;

            for (int i = 0; i <= S.length() - 3; i++) {
                int tmp = Integer.parseInt(S.substring(i, i + 3));
                tmp = Math.abs(like - tmp);
                ans = Math.min(ans, tmp);
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23764
_ = gets
A = gets.split.map(&:to_i)
RATE = [400,800,1200,1600,2000,2400,2800,3200]

g = A.group_by {|a| RATE.find {|n| a < n } }
ans = [g.size, g.size]
if g[nil]
  ans[0] = [1, ans[0]-1].max
  ans[1] += g[nil].size - 1
end
puts ans.join(' ')

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

int main() {
	long long N;
  	cin >> N;
  	vector<long long>A(N);
  for(int i = 0 ; i < N ; i++){
  	cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int64_t ans = 1;
  
  if(A.at(0)==0){
    cout << 0 << endl;
    exit(0);
  }
  
  long long Y = 1;
  
  for(int i = 0 ; i < 18 ; i++){
  	Y *= 10;
  }
  
  for(int i = 0 ; i < N ; i++){
    long long idea = Y/ans + 1;
      	ans *= A.at(i); 
    	if(A.at(i) > idea || ans > Y){
      	cout << -1 << endl;
      		exit(0);
    	}

  }
  
       	cout << ans << endl;
}



Measured memory_bytes: 4428
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;

    for(int i=0; i<8; i++) {
        if(n >=400+200*i && n<= 599 + 200*i){

            cout<<8 - i<<"\n";
            return;
        }

    }

      
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3636
import sys

def main():
	N,Q=map(int,sys.stdin.readline().split())
	S=input()
	A=[0]*N
	# 累積和
	for i in range(1,N):
		A[i]=S[i-1:i+1]=="AC"
		A[i]=A[i]+A[i-1]
	# [l:r)区間の総和を求める
	for i in range(Q):
		l,r=map(int,sys.stdin.readline().split())
		print(A[r-1]-A[l-1])
if __name__=='__main__':
	main()

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

int f[310][310],n,k,mod,g[310][310],sum[310][310],C[310][310];

int main()
{
	scanf("%d%d%d",&n,&k,&mod);
	for (int i=0; i<=n; i++)
	{
		C[i][0]=1;
		for (int j=1; j<=i; j++) C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	g[0][k+1]=sum[0][k+1]=1;
	for (int i=k; i; i--)
	{
		for (int j=1; j<=n; j++)
		{
			f[j][i]=0;
			for (int l=i; l<=k+1; l++) 
				f[j][i]=(f[j][i]+g[j-1][l]>=mod?f[j][i]+g[j-1][l]-mod:f[j][i]+g[j-1][l]);
			for (int l=0; l<=n-j; l++)
				g[j+l][i]=(g[j+l][i]+1ll*f[j][i]*sum[l][i+1]%mod*C[j+l][l])%mod;
		}
		for (int j=0; j<=n; j++) sum[j][i]=(sum[j][i+1]+g[j][i])%mod;
	}
	printf("%d\n",sum[n][1]);
	return 0;
}

Measured memory_bytes: 1664
N,M = list(map(int,input().split()))
data = [list(map(int,input().split())) for j in range(M)]
data.sort(key = lambda x:x[1])
last = 0
cnt = 0
for i,j in data:
    if cnt == 0:
        last = j-1
        cnt += 1
    elif i <= last:
        continue
    else:
        last = j-1
        cnt += 1

print(cnt)

Measured memory_bytes: 29452