akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private struct Pair { public int x, y; }
    public static void Main()
    {
        int N = NextInt();
        int W = NextInt();
        long[,] dp = new long[N + 1, 100010];
        for (int i = 0; i < N; i++)
            for (int j = 0; j <= 100000; j++) dp[i, j] = INF;
        dp[0, 0] = 0;
        for (int i = 0; i < N; i++)
        {
            int w = NextInt();
            int v = NextInt();
            for (int j = 0; j <= 100000; j++)
            {
                if (j < v || dp[i, j - v] + w > W) dp[i + 1, j] = dp[i, j];
                else dp[i + 1, j] = Math.Min(dp[i, j], dp[i, j - v] + w);
            }
        }
        for (int i = 100000; i != -1; i--)
        {
            if (dp[N, i] == INF) continue;
            Console.WriteLine(i);
            break;
        }
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 89952
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def count1(n: int):
    ret = [0]*40
    for mask in range(40):
        if mask == 0 and n&1:
            ret[0] += 1
        
        elif n & (1<<mask):
            ret[mask] += (n & ((1<<(mask+1))-1)) - ((1<<mask)-1)
            for m in range(mask):
                ret[m] += (1<<(mask-1))
                
    return ret

a,b = li()
onea = count1(a-1)
oneb = count1(b)

ans = 0
for i, (oneai, onebi) in enumerate(zip(onea, oneb)):
    ans += ((onebi-oneai)%2) * 2**i
    
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] l = new int[n];
			for (int i = 0; i < n; i++) {
				l[i] = sc.nextInt();
			}

			if (n < 3) {
				System.out.println(0);
				return;
			}

			int result = 0;
			for (int i = 0; i < n - 2; i++) {
				for (int j = i + 1; j < n - 1; j++) {
					for (int k = j + 1; k < n; k++) {
						if (isTriangle(l[i], l[j], l[k])) {
							result++;
						}
					}
				}
			}
			System.out.println(result);
		}
	}

	private static boolean isTriangle(int a, int b, int c) {
		if (a == b || b == c || c == a) {
			return false;
		}

		if (b < a && c < a && a < c + b) {
			return true;
		} else if (a < b && c < b && b < a + c) {
			return true;
		} else if (a < c && b < c && c < a + b) {
			return true;
		}
		return false;
	}
}


Measured memory_bytes: 36416
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    ll n, t, a; cin >> n >> t >> a;
    ll ans = 0;
    ll sa = inf;
    rep(i,n){
        ll h; cin >> h;
        if (abs(1000LL * t - h * 6LL - 1000LL * a) < sa){
            sa = abs(1000LL * t - h * 6LL - 1000LL * a);
            ans = i+1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int r,D,x_2000;
  cin >> r >> D >> x_2000;
  int ans = r*x_2000 - D;
  for(int i=0;i<10;i++){
    cout << ans << endl;
    ans = r*ans - D;
  }
  return 0;
}


Measured memory_bytes: 256
# WIP (Two test cases remains WA, The fucking code)
import sys
sys_input = sys.stdin.readline

N, K = map(int, sys_input().split())
AAA = list(map(int, sys_input().split()))

if N == K:
    print(1)
    exit()

n_remain = N
n_calc = 0
while n_remain > 0:
    n_remain += (-K+1)
    n_calc += 1
    if n_remain == K:
        n_calc += 1
        break

print(n_calc)


Measured memory_bytes: 13876
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define divceil(A, B) ((A + (B - 1)) / B)
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr

using namespace std;

int main(){

    int n,k;
    cin >> n;
    cin >> k;

    int x = 1;

    rep(i,n){
        x = min(x * 2, x + k);
    }

    cout << x << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef vector<int>::iterator vit;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	string s; cin>>s;
	int cnt = 0; 
	for(int i = 0; i < s.length(); i++)
	{
		if(i == 0)
		{
			cnt = 1;
		}
		else
		{
			if(s[i]==s[i-1])
			{
				
			}
			else
			{
				cnt++;
			}
		}
	}
	cout<<cnt-1<<'\n';
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define NAME "Knapsack1"

#define ll long long
const int maxn = 1e2+1;
const int maxw = 1e5+1;
int n,m;
int w[maxn];
int v[maxn];
ll  dp[maxn][maxw];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    cin>>n>>m;
    for(int i = 1;i<=n;i++) cin>>w[i]>>v[i];

    for(int i=1;i<=n;i++){
        for(int j = 0;j<=m;j++){
            if (j>=w[i])
                dp[i][j] = max( dp[i-1][j], dp[i-1][j-w[i]] + v[i] );
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][m];
}



Measured memory_bytes: 81756
while True:
    a, op, b = input().split()
    if op == "?":
        break
    elif op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    else:
        print(int(a) // int(b))


Measured memory_bytes: 5592
def string_transformation(S: int, T: int) -> bool:
    ds = {}
    dt = {}
    for s, t in zip(S, T):
        if s in ds:
            if ds[s] != t:
                return False
        else:
            ds[s] = t

        if t in dt:
            if dt[t] != s:
                return False
        else:
            dt[t] = s

    return True


if __name__ == "__main__":
    S = input()
    T = input()
    ans = string_transformation(S, T)
    print('Yes' if ans else 'No')


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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int a,b,c; cin >> a >> b >> c;
    a += b;
    a += c;
    if (a >= 22) printf("bust\n");
    else printf("win\n");
    return 0;
}


Measured memory_bytes: 3556
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>

int base36(int c) {
  if (c <= 9) return '0' + c;
  return 'A' + (c - 10);
}

int testcase_ends() {
  size_t n, m, q;
  scanf("%zu %zu %zu", &n, &m, &q);
  if (n == 0 && m == 0 && q == 0) return 1;

  std::vector<std::string> ss(q), bs(q);
  for (size_t i = 0; i < q; ++i) {
    char buf[1024];
    scanf("%s", buf);
    ss[i] = buf;
    scanf("%s", buf);
    bs[i] = buf;
    if (i > 0) {
      for (size_t j = 0; j < n; ++j) {
        ss[i][j] ^= ss[i-1][j] ^ '0';
      }
    }
  }

  // for (size_t i = 0; i < q; ++i)
  //   fprintf(stderr, "%s\n", ss[i].c_str());

  std::string res(m, '?');
  for (size_t i = 0; i < m; ++i) {
    long long cand = (1LL << n) - 1;
    for (size_t j = 0; j < q; ++j) {
      for (size_t k = 0; k < n; ++k) {
        if (bs[j][i] != ss[j][k])
          cand &= ~(1LL << k);
      }
    }
    // fprintf(stderr, "i: %zu, pop: %d\n", i, __builtin_popcount(cand));
    if (__builtin_popcountll(cand) != 1) continue;
    res[i] = base36(__builtin_ctzll(cand));
  }
  printf("%s\n", res.c_str());
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 3840
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;


int main(){
	ll n = 0;
	ll a[100000];
	sld(n)
	ll sum = 0;
	ll mini = 100000000;
	for(ll i = 0; i < n; i ++){
		sld(a[i])
	}
	for(ll i = -100; i <= 100; i ++){
		sum = 0;
		for(ll j = 0; j < n; j ++){
			sum += (a[j]-i)*(a[j]-i); 
		}
		//pld(sum) pn
		if(sum < mini){
			mini = sum;
		}
	}
	pld(mini) pn
	
	
    return 0;
}

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

using namespace std;

int main() {
    int n;
    
    while (cin >> n, n) {
        n = 1000 - n;

        int a = n / 500;
        n %= 500;

        int b = n / 100;
        n %= 100;

        int c = n / 50;
        n %= 50;

        int d = n / 10;
        n %= 10;

        int e = n / 5;
        int f = n % 5;

        int ans = a + b + c + d + e + f;
        cout << ans << endl;
    }
    return 0;
}



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

int main() {
  int N,P;
  cin>>N>>P;
  string S;
  cin>>S;
  int64_t Z=0,A=0,B=1;
  if(P==2||P==5){
    for(int64_t i=0;i<N;i++){
      int a=S[i]-'0';
      if(!(a%P)){
        Z+=i+1;
      }
    }
  }
  else{
    map<int,int64_t> m;
    m[0]=1;
    reverse(S.begin(),S.end());
    for(int i=0;i<N;i++){
      A+=(S[i]-'0')*B;
      A%=P;
      B*=10;
      B%=P;
      m[A]++;
      Z+=m[A];
    }
    Z-=N;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 4128
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;
#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
typedef vector<bool> vb;
typedef vector<vb> vvb;

bool in(int x,int y){
    return 0<=x && x<9 && 0<=y && y<9;
}

int main(){
    enum {U,R,D,L};
    const int dy[]={-1,0,1,0};
    const int dx[]={0,1,0,-1};
    vvb g(9,vb(9));
    rep(i,9){
        string s;cin>>s;
        if(i%2==0){
            rep(j,4)g[i][j*2+1]=s[j]-'0';
        }else{
            rep(j,5)g[i][j*2]=s[j]-'0';
        }
    }
    
    int i=0,j=0;
    int prev=R;
    while(1){
        int next[4]={L,U,R,D};
        rotate(next,next+prev,next+4);
        int k=0;
        for(;k<4;k++){
            if(in(i+dy[next[k]],j+dx[next[k]]) && g[i+dy[next[k]]][j+dx[next[k]]]){
                break;
            }
        }
        
        putchar("URDL"[next[k]]);
        i+=dy[next[k]]*2;
        j+=dx[next[k]]*2;
        prev=next[k];
        if(i==0 && j==0){
            break;
        }
    }
    cout<<endl;
}

Measured memory_bytes: 1192
#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 all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
const int N=200100;
vi st1[N],en1[N];
int n,m,a[N];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	rep(i,0,n) {
		cin>>a[i];
	}
	rep(i,1,n) {
		if(a[i]>a[i-1]) {
			st1[a[i-1]].pb(a[i]);
			en1[a[i]].pb(a[i-1]);
		} else {
			st1[a[i-1]].pb(a[i]+m);
			en1[a[i]+m].pb(a[i-1]);
			/*
			st2[a[i-1]].pb(a[i]+m);
			en2[a[i]+m].pb(a[i-1]);*/
		}
	}
	vector<ll> ans(m+1,0);
	ll cur=0; int act=0;
	rep(i,1,m+1) {
		for(auto x:st1[i]) {
			if(x>m) {
				act++;
				cur+=1+x-(m+1);
			} else cur+=x-i;
		}
	}
	ans[1]=cur;
	rep(i,2,m+1) {
		int i2=i+m;
		cur-=act;
		for(auto x:en1[i-1]) {
			act--;
			cur+=(i-1)-x;
		}
		for(auto x:en1[i2-1]) {
			act--;
			cur+=(i2-1)-x;
		}
		ans[i]=cur;
		act+=sz(st1[i-1]);
		act+=sz(st1[i2-1]);
	}
/*	cur=0LL;
	act=0;
	rep(i,1,m+1) for(auto x:st2[i]) {
		act++;
		ans[1]+=1+x-(m+1);
	}
	rep(i,m+1,2*m) {

	}*/
	ll mn=LLONG_MAX;
	rep(i,1,m+1) mn=min(mn,ans[i]);
	cout<<mn<<endl;
	return 0;
}

Measured memory_bytes: 18428
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

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

	return 0;
}

Measured memory_bytes: 256
program echo
    implicit none
    integer(4):: n, i
    character(:), allocatable:: s
    read*, n
    allocate(character(n):: s)
    read*, s
    if (mod(n,2) /= 0) then
        print*, "No"
        stop
    end if

    do i = 1,n/2
        if (s(i:i) /= s(i+n/2:i+n/2)) then
            print*, 'No'
            stop
        end if
    end do
    print*, "Yes"
end program echo

Measured memory_bytes: 512
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int sum[2001][2001];
ll f(int x1,int y1,int x2,int y2){
    return sum[x2][y2]-sum[x1-1][y2]-sum[x2][y1-1]+sum[x1-1][y1-1];
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int n=s.size();
    rep(i,0,n)cout<<"x";
    cout<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int n ,t,a;
    cin >> n >> t >> a;
    int h[1005];double f[1005];
    for(int i=1;i<=n;i++){
        cin >> h[i];
        f[i]=t-h[i]*0.006;
    }
    double min=abs(f[1]-a);
    int flag=1;
    for(int i=2;i<=n;i++){
        if(abs(f[i]-a)<min) {
            min=abs(f[i]-a);
            flag=i;
        }
    }
    cout <<flag;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, (input().split()))
shop = [list(map(int, input().split())) for i in range(N)]

shop.sort()

sum = 0
remain = M
for i in range(0, len(shop)):
    price = shop[i][0]
    stock = shop[i][1]

    if remain - stock >= 0:
        sum += price * stock
        remain -= stock
    else:
        sum += price * remain
        break

#print(N)
#print(M)
#print(shop)
print(sum)

Measured memory_bytes: 27880
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        var N = int.Parse(Console.ReadLine());

        var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

        var count = 0;

        var minIndex = 0;

        for(var i = 0; i < N; i++)
        {
            minIndex = i;
            bool isChanged = false;

            for (var j = i; j < N; j++)
            {
                if(A[j] < A[minIndex])
                {
                    minIndex = j;
                    isChanged = true;
                }
            }

            if (isChanged)
            {
                var tmp = A[minIndex];
                A[minIndex] = A[i];
                A[i] = tmp;

                count++;
            }
        }

        Console.WriteLine(string.Join(" ", A));
        Console.WriteLine(count);
    }
}



Measured memory_bytes: 20376
N, M = map(int, input().split())
li = [-1]*N
flag = True
for i in range(M):
    s, c = map(int, input().split())
    if li[N-s] < 0 or li[N-s] == c:
        li[N-s] = c
    else:
        flag = False
if not flag:
    print(-1)
else:
    if N == 1:
        print(max(li[0],0))
    else:
        if li[N-1] == 0:
            print(-1)
        else:
            cnt = 0
            for i in range(N-1):
                if li[i] >= 0:
                    cnt += li[i] * 10 ** i
            if li[N-1] < 0:
                cnt += 10 ** (N-1)
            else:
                cnt += li[N-1] * 10 ** (N-1)
            print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
#define debug(x) cerr << #x << " = " << x << "\n";
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    bool p[55560] = {1, 1};
    vector<int> a;
    int n;
    fr(55558) if (!p[i]) for (int j = i + i; j < 55558; j += i) p[j] = 1;
    fr(55558) if (!p[i] && i % 5 == 1) a.push_back(i);
    cin >> n;
    fr(n) cout << a[i] << ' ';
}


Measured memory_bytes: 384
from collections import deque
s = deque(input())

ans = 0
while s:
    top = s[0]
    end = s[-1]
    if top != end:
        if not (top == "x" or end == "x"):
            print(-1)
            break
        else:
            if top == "x":
                s.popleft()
            else:
                s.pop()
            ans += 1
    else:
        s.popleft()
        if s:
            s.pop()
else:
    print(ans)

Measured memory_bytes: 79928
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }

    // public static String[] <T> ToStringArray(T[] arr) {
    // String[] res = new String[arr.length];
    // for(int i = 0; i < arr.length; ++i) {
    // res[i] = String.valueOf(arr[i]);
    // }

    // return res;
    // }

    private static List<Integer> asIntergerList(int[] arr) {
        List<Integer> intList = new ArrayList<Integer>();
        for (int i = 0; i < arr.length; i++) {
            intList.add(arr[i]);
        }

        return intList;
    }

    private static int[][] deepCopy(int[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; ++i) {
            res[i] = arr[i].clone();
        }

        return res;
    }

    private static String asString(int[][] arr) {
        String str = new String();

        for (int i = 0; i < 2; ++i) {
            str += "" + arr[i][0] + arr[i][1] + arr[i][2] + arr[i][3];
        }

        return str;
    }

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

        String target = scanner.next();
        int counter = 0;
        while (true) {
            String str = scanner.next();

            if ("END_OF_TEXT".equals(str)) {
                break;
            }
            counter += str.toLowerCase().equals(target) ? 1 : 0;

        }

        System.out.println(counter);
    }
}



Measured memory_bytes: 26344
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a*b % 2 == 0 ? "Even" : "Odd") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, minN = INF, sum = 0, sumtmp = 0;
	cin >> n;
	vector<ll>a(n), sumL, sumR;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}
	//sum = accumulate(all(a), 0LL);
	for (ll i = 0; i < n; i++) {
		sumtmp += a[i];
		minN = min(minN, abs(sum - 2 * sumtmp));
	}
	cout << minN << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.ArrayList;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int count = 0;
        for( int i = a ; i <= b ; i++){
            if(c%i==0)
                count++;
        }
        System.out.println(count);
    }
}

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

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

Measured memory_bytes: 3488
#include <cstdio>
#include <iostream>
using namespace std;
#define INF (1<<29)

int N, M, R; // 町数、道数、訪れる町数
int d[201][201];
int r[9];
int A, B, C; // A町、B町、AB間の距離
int res;
bool used[9];

void dfs(int c, int las, int dist);

int main() {
    cin >> N >> M >> R; // 1段目の読み込み
    for (int i = 1; i <= N; i++)
        for (int j = 1; j <= N; j++)
            if (i != j)
                d[i][j] = INF;
    
    for (int i = 1; i <= R; i++) {
        cin >> r[i]; // 2段目の読み込み
    }

    for (int i = 1; i <= M; i++) {
        cin >> A >> B >> C; // 3段目以降の読み込み
        if (d[A][B] > C) {
            d[A][B] = d[B][A] = C;
        }
    }

    for (int k = 1; k <= N; k++)
        for (int i = 1; i <= N; i++)
            for (int j = 1; j <= N; j++)
                if (d[i][j] > d[i][k] + d[k][j])
                    d[i][j] = d[i][k] + d[k][j];

    res = INF;
    dfs(1, -1, 0);
    printf("%d\n", res);
}

void dfs(int c, int las, int dist) {
    if (c == R + 1) {
        if (res > dist) {
            res = dist;
            return;
        }
    }
    for (int i = 1; i <= R; i++) {
        if (!used[i]) {
            used[i] = true;
            if (las == -1) dfs(c + 1, i, 0);
            else dfs(c + 1, i,  dist + d[r[las]][r[i]]);
            used[i] = false;
        }
    }
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }



//提出言語もしっかり確認！！！！！！！！！！！！！！！！！！！
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n;
	ll ans = 0;
	cin >> n;
	vector<float> r, g, b;
	string s;
	cin >> s;
	char temp;
	for(int i = 0;i<n;i++) {
		temp = s[i];
		if (temp == 'R')r.push_back(i );
		if (temp == 'G')g.push_back(i );
		if (temp == 'B')b.push_back(i );
	}

	//cout <<"bt:"<< b.size() << endl;
	int bt = b.size();

	/*
	float av;
	for (int i = 1; i < r.size(); i++) {
		for (int j = 1; j < g.size(); j++) {
			for (int k = 1; k < b.size(); k++) {
				av = (r[i] + g[j] + b[k]) / 3.0;
				//cout << r[i] << ":" << g[j] << ":" << b[k] << endl;
				//cout << av << endl;
				if (r[i] != av && g[j] != av && b[k] != av)ans++;
			}
		}
	}
	*/

	float av;
	for (int i = 0; i < r.size(); i++) {
		for (int j = 0; j < g.size(); j++) {
			int left = min(r[i], g[j]);
			int right = max(r[i], g[j]);
			int dist = right - left;
			//cout << "dist: " << dist << endl;
			if (left - dist > 0) {
				if (s[left - dist] == 'B')ans--;
			}
			if (right + dist < s.size()) {
				if(s[right + dist] == 'B')ans--;
			}
			if ((left + right) % 2 == 0) {
				if (s[((left + right) / 2)] == 'B')ans--;
			}
			ans += bt;
		}
	}



	cout << ans << endl;
	system("pause");
	return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define zeros(x) x^(x-1)&x
#define pii pair<ll,ll>
#define cd complex<double>
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#define Nmax 200005
#define OFF 100001
using namespace std;

int S,E,W,N;
string s;

int main()
{
    cin >> s;
    for (auto it : s){
        switch (it){
            case 'N':
                N = 1;
                break;
            case 'S':
                S = 1;
                break;
            case 'W':
                W = 1;
                break;
            case 'E':
                E = 1;
                break;
        }
    }

    if ((N ^ S) || (E ^ W)) cout << "No\n";
    else cout << "Yes\n";

    return 0;
}


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

using namespace std;

int main(){

	double n;
	int f;
	cin >> f;
	n = f;
	

	n /= 1000;
	
	n = ceil(n);
	int a = n;
	a *= 1000;
	cout << a - f << endl;	

	return 0;
}


Measured memory_bytes: 3604
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String in;
		try {
			while ((in = sc.nextLine()) != null) {
				ArrayList<Integer> ans = new ArrayList<Integer>();
				for (int i = 1; i <= 9; i++) {
					String temp = new String(in) + i;
					if (solve(temp)) {
						ans.add(i);
					}
				}
				if (ans.size() == 0) {
					System.out.println(0);
				} else {
					Collections.sort(ans);
					for (int i = 0; i < ans.size() - 1; i++) {
						System.out.print(ans.get(i) + " ");
					}
					System.out.println(ans.get(ans.size() - 1));
				}
			}
		} catch (Exception e) {
		}
	}

	static int[] toArray(String str) {
		int ret[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, };
		for (char num : str.toCharArray()) {
			ret[num - '0' - 1]++;
		}
		for (int n : ret) {
			if (n > 4)
				return null;
		}
		return ret;
	}

	static boolean solve(String in) {
		for (int i = 0; i < 9; i++) {
			int temp1[] = toArray(in);
			if (temp1 == null) {
				return false;
			}
			if (head(temp1, i)) {
				int[] temp2 = temp1.clone();
				if (solve2(temp2, 0)) {
					return true;
				}
			}
		}

		return false;
	}

	static boolean solve2(int[] in, int dep) {
		for (int i = 0; i < 9; i++) {
			int[] temp = in.clone();
			if (kotu(temp, i)) {
				if (hantei(temp)) {
					return true;
				}
				if (dep < 4) {
					if (solve2(temp, dep + 1)) {
						return true;
					}
				}
			}
		}
		for (int i = 0; i < 7; i++) {
			int[] temp = in.clone();
			if (shuntu(temp, i)) {
				if (hantei(temp)) {
					return true;
				}
				if (dep < 4) {
					if (solve2(temp, dep + 1)) {
						return true;
					}
				}
			}
		}

		return false;
	}

	// 頭をとる。取れたらｔるえ
	static boolean head(int in[], int num) {
		if (in[num] >= 2) {
			in[num] -= 2;
			return true;
		} else {
			return false;
		}
	}

	// こーつをとる。取れたらｔるえ
	static boolean kotu(int in[], int num) {
		if (in[num] >= 3) {
			in[num] -= 3;
			return true;
		} else {
			return false;
		}
	}

	// しゅんつをとる。取れたらｔるえ
	static boolean shuntu(int in[], int num) {
		if (num > 7) {
			return false;
		} else {
			if (in[num] >= 1 && in[num + 1] >= 1 && in[num + 2] >= 1) {
				in[num]--;
				in[num + 1]--;
				in[num + 2]--;
				return true;
			} else {
				return false;
			}
		}
	}

	static boolean hantei(int[] in) {
		for (int n : in) {
			if (n != 0)
				return false;
		}
		return true;
	}
}

Measured memory_bytes: 12000
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_4_B
// BFS algorithm
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(int argc, char **argv)
{
        int V, E;
        cin >> V >> E;
        vector<vector<int>> A(V);
        vector<int> B(V);
        for (int i = 0; i < E; i++) {
                int s, t;
                cin >> s >> t;
                A[s].push_back(t);
                B[t]++;
        }
        vector<bool> U(V);
        vector<int> L;
        queue<int> S;
        for (int i = 0; i < V; i++) {
                if (B[i] || U[i])
                        continue;
                S.push(i);
                while (!S.empty()) {
                        auto c = S.front();
                        S.pop();
                        U[c] = true;
                        L.push_back(c);
                        for (auto a: A[c])
                                if (--B[a] == 0)
                                        S.push(a);
                }
        }
        for (auto l: L)
                cout << l << endl;
        return 0;
}

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

int main(void)
{
    int n;
    cin >> n;
    vector<int> b(n);
    vector<int> modIndex(n);
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        modIndex[i] = i+1;
    }

    vector<int> outBuf;
    for(int i = n; i >= 0; i--){
        if(modIndex[i] > 0){
            if(modIndex[i] == b[i]){
                outBuf.push_back(b[i]);
                modIndex[i] = -1;

                for (int j = i+1; j < n; j++)
                {
                    modIndex[j]--;
                }

                i = n;
            }
        }
    }

    if((int)outBuf.size() == n){
        for (int i = n-1; i >= 0; i--)
        {
            cout << outBuf[i] << endl;
        }
        
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include <cstdio>
#define maxn 2010
using namespace std;
int n,m,q;
char s[maxn];
bool d[maxn][maxn];
int d1[maxn][maxn],d2[maxn][maxn],d3[maxn][maxn];
int main() {
	scanf("%d %d %d",&n,&m,&q);
	for (int i=1;i<=n;i++) {
		scanf("%s",s);
		for (int j=0;j<m;j++)
			d[i][j+1]=s[j]-'0';
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			d1[i][j]=d1[i-1][j]+d1[i][j-1]-d1[i-1][j-1];
			if (d[i][j])
				d1[i][j]++;
			
			d2[i][j]=d2[i-1][j]+d2[i][j-1]-d2[i-1][j-1];
			if (d[i][j]&&d[i][j-1])
				d2[i][j]++;
			
			d3[i][j]=d3[i-1][j]+d3[i][j-1]-d3[i-1][j-1];
			if (d[i][j]&&d[i-1][j])
				d3[i][j]++;
		}
	}
	for (int i=1;i<=q;i++) {
		int x1,y1,x2,y2;
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		int t1=d1[x2][y2]-d1[x1-1][y2]-d1[x2][y1-1]+d1[x1-1][y1-1];
		int t2=d2[x2][y2]-d2[x1-1][y2]-d2[x2][y1]+d2[x1-1][y1];
		int t3=d3[x2][y2]-d3[x1][y2]-d3[x2][y1-1]+d3[x1][y1-1];
		printf("%d\n",t1-t2-t3);
	}
	return 0;
}

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

using namespace std;

vector<int> numbers[10];

bool check(int x){
    int c = x/100;
    int d = x/10%10;
    int u = x%10;

    int last;
    if(numbers[c].size()){
        last = numbers[c][0];
        if(numbers[d].size()){
            for(int i=0;i<numbers[d].size();++i){
                if(numbers[d][i] > last){
                    last = numbers[d][i];
                    if(numbers[u].size()){
                        for(int j=0;j<numbers[u].size();++j)
                            if(numbers[u][j] > last)
                                return true;
                    }
                    return false;
                }
            }
            return false;
        }
        return false;
    }
    return false;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    string s;
    
    cin >> n >> s;

    for(int i=0;i<n;++i)
        numbers[s[i]-'0'].push_back(i);
    
    int counter = 0;
    for(int i=0;i<1000;++i){
        if(check(i))
            counter++;
    }

    cout << counter << '\n';

    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def max_cal(xn, vn, twoway):
    n = len(xn)
    factor = 2 if twoway else 1
    mc = []
    res = vn[0] - factor * xn[0]
    mc.append(max(0, res))
    for i in range(1, n):
        res += vn[i] - factor * (xn[i] - xn[i - 1])
        mc.append(max(mc[-1], res))
    assert len(mc) == len(xn)
    return mc

def read_input():
    n, c = map(int, input().split())
    xn = []
    vn = []
    for i in range(n):
        x, v = map(int, input().split())
        xn.append(x)
        vn.append(v)
    xnr = list(reversed([c - x for x in xn]))
    vnr = list(reversed(vn))
    return n, c, xn, vn, xnr, vnr

def merge(xn, xnr, c, max_one, max_two):
    def array_j(mt, j):
        if j < 0:
            return 0
        return mt[j]

    n = len(xn)
    j = -1
    ma = 0
    for i in reversed(range(n)):
        x = xn[i]
        while j + 1 < n and xnr[j + 1] * 2 <= c - x:
            j += 1
        res = max_one[i] + array_j(max_two, j)
        ma = max(ma, res)
    return ma

def main():
    n, c, xn, vn, xnr, vnr = read_input()
    max_one_cw = max_cal(xn, vn, False)
    max_two_cw = max_cal(xn, vn, True)
    max_one_ccw = max_cal(xnr, vnr, False)
    max_two_ccw = max_cal(xnr, vnr, True)
    res = merge(xn, xnr, c, max_one_cw, max_two_ccw)
    res = max(res, merge(xnr, xn, c, max_one_ccw, max_two_cw))
    print(res)

main()


Measured memory_bytes: 31100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    int N;
    cin >> N;
    vector<int>A(N+5);
    for(int i=0; i<N; i++){
        cin >> A[i];
        if(A[i]%2 == 0){
            if(A[i]%3 != 0 && A[i]%5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 55;

int n;
vector<pair<int, int>> arr;
int done[N];


int solve(int p, int q)
{
  for(int i = 0 ; i < n ; i++){
    done[i] = false;
  }
  int ans = 0;
  for(int i = 0 ; i < n ; i++){
    if(!done[i]){
      ans++;
      done[i] = true;
      pair<int, int> last = arr[i];
      for(int j = 0 ; j < n ; j++)
        if(!done[j] && last.first + p == arr[j].first && last.second + q == arr[j].second){
          done[j] = true;
          last = arr[j];
        }
    }
  }
  return ans;
}

int main()
{
  while(cin >> n){
    set<pair<int, int>> st;
    for(int i = 0 ; i < n ; i++){
      int x, y;
      cin >> x >> y;
      st.insert({x, y});
    }
    if(n == 1){
      cout << 1 << endl;
      continue;
    }
    arr.clear();
    for(auto p : st)
      arr.pb(p);
    sort(all(arr));
    // for(auto x : arr)
    //   cout << x.first << " " << x.second << endl;
    int ans = 1e9;
    for(int i = 0 ; i < n ; i++){
      for(int j = 0 ; j < n ; j++){
        if(i != j && arr[i].first <= arr[j].first){
          ans = min(ans, solve(arr[j].first - arr[i].first, arr[j].second - arr[i].second));
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
  
  vector<int>number(3,0);
  
  for(int i=0;i<3;i++){
    cin >> number[i];
  }
 
  sort(number.begin(),number.end());
  
  int ans = 0;
  
  ans += number[2] - number[1];
  
  number[0] += ans;
  number[1] += ans;
  
  if(number[1] % 2 == number[0] % 2){
    int p = (number[1] - number[0]) / 2;
    ans += p;
  }
  else{
    int p = (number[1] - number[0]) / 2 + 2;
    ans += p;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <list>
using namespace std;
int main(void){
	int n;
	cin>>n;
	int imos[100010]={};
	int cum[100010]={};
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		imos[a]++;
		imos[b+1]--;
	}
	cum[0]=imos[0];
	for(int i=1;i<100010;i++){
		cum[i]=cum[i-1]+imos[i];
	}
	int result=0;
	for(int p=0;p<=n;p++){
		if(cum[p+1]>=p){
			result=p;
		}
	}
	cout<<result<<endl;
	return 0;
}	



Measured memory_bytes: 3864
#include<bits/stdc++.h>
	#include<vector>
	#include<string>
	#include<math.h>
	#define ll long long int 
	#define loop(a,b,i) for(int i=a;i<b;i++)
	#define loopr(a,b,i) for(int i=n-1;i>=0;i--)
	#define pb push_back
	#define db double
	#define mp make_pair
	#define endl "\n"
	#define f first
	#define se second
	#define all(x) x.begin(),x.end()
	#define MOD 1000000007
	#define N 8
	#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
	using namespace std;
	
//	bool isPrime(int n)
//	{
//    	if(n <= 1) return false;
//     	if(n == 2) return true;
//    	if(n % 2 == 0) return false;
//    	for(int j = 3; j <= sqrt(n); j++)
//		{
//    		if(n % j == 0) return false;
//    	}	
//    	return true;
//	}
	
	
	int main() 
	{ 
		int a;
		cin>>a;
		int res=a+a*a;
		int rese=res+pow(a,3);
		cout<<rese<<endl;
	return 0; 
	} 

Measured memory_bytes: 4024
N, W = map(int, input().split())

dp = [[0]*(W+1) for i in range(N+1)]
w = [-1] * N
v = [-1] * N

for i in range(N):
    w[i], v[i] = map(int, input().split())
    
for i in range(N):
    for j in range(W+1):
        if j >= w[i]:
            dp[i+1][j] = max(dp[i][j-w[i]] + v[i], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])

Measured memory_bytes: 120412
#include <cstdio>
#include <vector>

using namespace std;

const int MAX_N = 1000001;
int A[MAX_N];
int N;
int cnt = 0;
vector<int> G;

void input() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", A + i);
	}
}

void show(int *a, int n) {
	for (int i = 0; i < n; i++) {
		printf("%d\n", *(a + i));
	}
}

void insertionSort(int *a, int n, int g) {
	for (int i = g; i < n; i++) {
		int v = a[i];
		int j = i - g;
		while (j >= 0 && a[j] > v) {
			a[j + g] = a[j];
			j -= g;
			cnt++;
		}
		a[j + g] = v;
	}
}

void shellSort(int *a, int n) {
	int h = 1;
	while (h <= n) {
		G.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = G.size() - 1; i >= 0; i--) {
		insertionSort(a, n, G[i]);
	}
	printf("%d\n", G.size());
	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i) {
			printf(" ");
		}
	}
	printf("\n");
	printf("%d\n", cnt);
	show(A, N);
}

void solve() {
	input();
	shellSort(A, N);
}

int main() {
	solve();
}

Measured memory_bytes: 6672
#include<cstdio>
#define N 1000001
inline int abs(int x){return x<0?-x:x;}
int b[3],i,n,x=0;char a[N];
int main()
{
	scanf("%d%s",&n,a);
	for(i=0,n--;i<n;i++)b[a[i]=abs(a[i]-a[i+1])%3]=1;
	for(i=0,n--;i<=n;i++)if((i&n)==i)x^=a[i];
	return 0&printf("%d\n",x&~(b[1]<<1));
}

Measured memory_bytes: 1152
def lscan; gets.split.map(&:to_i); end

n, m = lscan

ok = 0
pena = 0
wa = [0]*n

m.times do |i|
  q, s = gets.chomp.split
  ix = q.to_i-1
  if s == 'WA'
    wa[ix] += 1 if wa[ix] >= 0
  else
    if wa[ix] >= 0
      ok += 1
      pena += wa[ix]
      wa[ix] = -1
    end
  end
end

puts "#{ok} #{pena}"

Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p;

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

int main()
{
  ll N, A, B, C, D, E;
  cin >> N >> A >> B >> C >> D >> E;

  ll min_N = min({A, B, C, D, E});

  if(N%min_N==0){
    cout << (N / min_N) + 4 << endl;
  }
  else{
    cout << (N / min_N) + 5 << endl;
  }

  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(A) (A).begin(),(A).end()
#define ll long long
const ll mod = 1e9+7;
int main(void){
	double W,H,x,y;
	cin >> W >> H >> x >> y;
	int ans;
	if(W/2==x&&H/2==y)ans=1;
	else ans = 0;
	printf("%lf %d\n",(W*H)/2,ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <list>
#include <climits>

using namespace std;

#define CL(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define pc __builtin_popcount
#define mp make_pair
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, b) FOR(i, 0, b)

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

const int MAX_N = 105;

int grid[2][MAX_N], sum1[MAX_N], sum2[MAX_N];

int main() {
    int N;
    scanf ("%d", &N);
    for (int i = 0; i < 2; ++i) {
        for (int j = 0; j < N; ++j) {
            scanf ("%d", &grid[i][j]);
        }
    }

    memset(sum1, 0, sizeof(sum1));
    memset(sum2, 0, sizeof(sum2));
    for (int i = 0; i < N; ++i) {
        sum1[i] = i > 0 ? sum1[i - 1] + grid[0][i] : grid[0][i];
        sum2[i] = i > 0 ? sum2[i - 1] + grid[1][i] : grid[1][i];
    }

    int max_value = 0;
    for (int i = 0; i < N; ++i) {
        int sum2_right = sum2[N - 1] - (i > 0 ? sum2[i - 1] : 0);
        max_value = max(max_value, sum1[i] + sum2_right);
    }

    printf ("%d\n", max_value);
    return 0;
}


Measured memory_bytes: 256