akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip> 
#include <cstdlib>
#include <cmath>
#include<map>
#include<string.h>
#include <algorithm>
#include <bits/stdc++.h> 
#include<vector>
 
using namespace std;
#define rep(i,a,b)    for(long long int i=a;i<b;i++)
#define repn(i,a,b)   for(long long int i=a;i>=b;i--)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define F first
#define S second
#define sortA(arr)   sort(arr.begin(),arr.end())
#define sortC(arr,n)   sort(arr,arr+n,comparefunc())
#define search(arr,c)  binary_search(arr.begin(),arr.end(),c)
#define pb   push_back
#define ll long long int
#define LCM(a,b) boost::math::lcm(a,b)
#define mp make_pair
#define pll pair<long long int,long long int>
 vb isprime(1e6+6,true);
 
struct node{
     ll val;
     ll index;
    
};
        
void Sieve(ll maxn){ 
    ll j;isprime[0]=isprime[1]=false;
    rep(i,2,sqrt(maxn)+1)
    {
        if(isprime[i]){
            for(j=i*i;j<=maxn;j+=i){
                isprime[j]=false;
            }
        }
    }
} 
 struct comparefunction{
bool operator()(const pll c,const pll d)const{
    ll lenc=c.second-c.first+1;
    ll lend=d.second-d.first+1;
    if(lenc!=lend)
    return lenc>lend;
    else
    return c.first<d.first;
   
     
}};
 bool cmp(node a,node b){
     if(a.val!=b.val)
     return a.val<b.val;
     if(a.index!=b.index)
     return a.index<b.index;
 }
  


 void dfs2(ll v,vi adj[],ll e) {
  //  vis[v] = true;
  
        //cout<<v<<"\n";}
    
    for (int u : adj[v]) {
       
       if (u==e)
       continue;
            dfs2(u,adj,v);
        
           
            
    }
    
   
    
}

 
 ll modpow(ll x, ll n,ll p){
     if(n==0)
     return 1;
     if(n==1)
     return x%p;
     if(n%2==0)
     return (modpow(x,n/2,p)%p)*(modpow(x,n/2,p)%p);
     else
     return (x%p)* (modpow(x,n/2,p)%p)*(modpow(x,n/2,p)%p);
 }
 vb vis(1e5+1,false);
 void bfs(int v,vi adj[]){
     queue <int> q;
     q.push(v);
     vis[v]=true;
     while(!q.empty()){
         ll s=q.front();
         q.pop();
         for(auto x: adj[s]){
             if(!vis[x]){
                 vis[x]=true;
                 cout<<x<<" "<<s<<"\n";
                 q.push(x);
             }
         }
     }//cout<<vis[1]<<"\n";
 }


 
 
 void solve(){
ll n,k;
cin>>n;
ll c1=0,c2=0,c3=0,c4=0;
rep(i,0,n)
{
    string str;
    cin>>str;
    if(str[0]=='A')
    c1++;
    if(str[0]=='W')
    c2++;
    if(str[0]=='T')
    c3++;
    if(str[0]=='R')
    c4++;
}
cout<<"AC x "<<c1<<"\n";
cout<<"WA x "<<c2<<"\n";
cout<<"TLE x "<<c3<<"\n";
cout<<"RE x "<<c4<<"\n";


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

 //}
    
}
  



 
   
 
 

Measured memory_bytes: 3784
#include<stdio.h>
int main(){
    int i =0,n=0;
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(c-1<=a+b){
        n=b+c;
    }
    if(c-1>a+b){
        n=a+2*b+1;
    }
    printf("%d",n);
    return 0;

}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};

int main() {
	int N;
	cin >> N;
	double ans;
	ans = ((N+1)/2)/(double)N;
	cout << fixed << setprecision(10) << ans;
}


Measured memory_bytes: 3240
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    RGB = list(map(int,input().split()))
    N = RGB.pop()
    #print(N)
    RGB.sort(reverse=True)
    ans = 0
    for i in range(N//RGB[0]):
        N_1 = N % RGB[0] + RGB[0] * i
        #print(N_1)
        for j in range(N_1//RGB[1]):
            N_2 = N_1 % RGB[1] + RGB[1] * j
            if N_2 % RGB[2] == 0:
                ans += 1
        if N_1 % RGB[2] == 0:
                ans += 1
    for j in range(N//RGB[1]):
            N_1 = N % RGB[1] + RGB[1] * j
            if N_1 % RGB[2] == 0:
                ans += 1
    if N % RGB[2] == 0:
                ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 26996
/*                                                                                 
	Author :- Gaurang_Kothiya
	
	Quote :- " Practice makes a man perfect. "		
*/  
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

#define data_set(type) tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define ld long double
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(int i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define ook(num) order_of_key(num)
#define fbo(num) find_by_order(num)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846

const int inf= 1e9;
const int inf64= 1e18;
const int MOD= 1e9 +7;


void Solve()
{
	int n;
	cin>>n;
	int sum=0;
	while(sum<n)
	{
		sum +=1000;
	}
	cout<< sum -n;
}
 
signed main() 
{
	speed		

	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
		
	return 0;
} 

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int MOD;
vector<int> fact, fact_inv, inv;
void init_nCk(int n){
  fact.resize(n+5);
  fact_inv.resize(n+5);
  inv.resize(n+5);
  fact[0]=fact[1]=1;
  fact_inv[0]=fact_inv[1]=1;
  inv[1]=1;
  for (int i=2;i<n+5;i++){
    fact[i]=fact[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    fact_inv[i]=fact_inv[i-1]*inv[i]%MOD;
  }
}
int nCk(int n,int k){
  assert(!(n<k));
  assert(!(n<0||k<0));
  return fact[n]*(fact_inv[k]*fact_inv[n-k]%MOD)%MOD;
}
int pow(int x,int y){//x^yを返す
  if(x==1){return 1;}
  int tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
int main(){
  int p,a;
  cin>>p;
  MOD=p;
  vector<int> a1(0);
  vector<int> ans(p);
  for(int i=0;i<p;i++){
    cin>>a;
    if(a==1){a1.push_back(i);}
  }
  init_nCk(p-1);
  for(int i=0;i<(int)a1.size();i++){
    ans.at(0)++;
    a=1;
    for(int j=p-1;j>=0;j--){
      ans.at(j)-=nCk(p-1,j)*a-MOD*MOD;
      ans.at(j)%=MOD;
      a*=-1*a1.at(i);
      a%=MOD;
    }
  }
  for(int i=0;i<p;i++){
    cout<<ans.at(i);
    if(i<p-1){cout<<" ";}
  }
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    scan.close();

    StringBuffer init = new StringBuffer("a");
    str(N, init);
  }

  public static void str(int N, StringBuffer strBuff) {
    if(strBuff.length() == N) {
      System.out.println(strBuff);
      return;
    }

    int charMin = 0;
    for(int i=0; i<strBuff.length(); i++) {
      if(charMin < strBuff.charAt(i)) {
        str(N, new StringBuffer(strBuff).append(strBuff.charAt(i)));
        charMin = strBuff.charAt(i);
      }
    }
    str(N, new StringBuffer(strBuff).append((char)(charMin+1)));
  }
}

Measured memory_bytes: 60588
s=str(input())
n=len(s)

l_f=s[0:(n-1)//2]
l_e=s[((n+3)//2)-1:n]

def palindrome(s):
  pr=s[::-1]
  if s==pr:
    return True
  else:
    return False

if palindrome(s) and palindrome(l_f) and palindrome(l_e):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
    int i, j;
    int N;
    int A[100001], B[100000];

    long int bust = 0;

    scanf("%d", &N);
    for (i = 0; i < N+1; i++){
        scanf("%d", &A[i]);
    }
    for (i = 0; i < N; i++){
        scanf("%d", &B[i]);
    }

    for (i = N - 1; i >= 0; i--){
        if(A[i+1]<B[i]){
            bust += A[i + 1];
            B[i] -= A[i + 1];
            A[i + 1] = 0;
            if(A[i]<B[i]){
                bust += A[i];
                B[i] -= A[i];
                A[i] = 0;
            }
            else{
                bust += B[i];
                A[i] -= B[i];
                B[i] = 0;
            }
        }
        else{
            bust += B[i];
            A[i+1] -= B[i];
            B[i] = 0;
        }
    }

    printf("%ld\n", bust);

    return 0;
}

Measured memory_bytes: 896
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    ll x, a, b, score;
    cin >> x;
    a = x / 500;
    b = (x - a * 500) / 5;
    score = a * 1000 + b * 5;
    cout << score << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define fi first
#define se second

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=acos(-1);
const ll MOD=1e9+7;
const ll INF=(1LL<<60);

int main() {
    string s;
    cin>>s;
    if (s[1]=='B')cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
int A[333][333];

const int INF=1001001001001001001ll;
int d[333][333];

signed main(){
    cin>>N;
    rep(i,N)rep(j,N)cin>>A[i][j];

    fill_n(*d,333*333,INF);
    rep(i,N)d[i][i]=0;
    rep(i,N)rep(j,N)chmin(d[i][j],A[i][j]);

    rep(k,N)rep(i,N)rep(j,N)chmin(d[i][j],d[i][k]+d[k][j]);

    rep(i,N)rep(j,N)if(d[i][j]!=A[i][j]){
    cout<<-1<<endl;
    return 0;}

    int ans=0;
    rep(i,N)for(int j=i+1;j<N;j++){
        bool f=false;
        rep(k,N){
            if(i==k||j==k)continue;
            if(d[i][k]+d[k][j]==d[i][j])f=true;
        }
        if(!f)ans+=d[i][j];
    }

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


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[100003];

    Scs(s);
    int n = strlen(s);

    int cnt = 0;
    Rep(i,n)
        if( s[i] == 'p' ) cnt++;

    int ans = n / 2 - cnt;
    printf ("%d\n", ans);

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 31;
const int maxV = 90010;

 
const int maxN = 1e6+8;
const ll INF = 1000000000000000010LL;
const int MOD = 1e9+7;

int a[maxN];
int b[maxN];
char s[maxN];
int main() {
	int n,k;
	scanf("%d%d",&n,&k);
	scanf("%s",s+1);
	vector<int> h;
	int tot = 1;
	int cnt = 0;
	for(int i=2;i<=n;i++)
	{
		if(s[i] != s[i-1])
			cnt++;
	}
	cnt++;
	int ans = max(cnt-2*k,1);
	cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
import java.sql.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] s = sc.next().toCharArray();
		
		int count = 0;
		for (char c : s) {
			if (c == '1') {
				count++;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 19924
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:256000000")
#include<utility>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head
#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

// belik's shit
ll const mod = 1e9 + 7;
namespace {
	ll mult(ll& a, ll& b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) {
			val += mod;
		}
		if (val >= mod) {
			val -= mod;
		}
		return val;
	}
	ll poww(ll a, ll b)
	{
		ll val = 1;
		a %= mod;
		while (b > 0){
			if (b % 2) val = mult(a, val);
			a = mult(a, a);
			b >>= 1;
		}
		return val % mod;
	}
	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;
ll dp[105][maxn];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n; cin >> n; ll W; cin >> W;
	vector<ll>w(n + 1), v(n + 1);
	for (ll i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (ll i = 0; i < 105; i++)
		for (ll j = 0; j < maxn; j++)
			dp[i][j] = LLONG_MAX;
	dp[0][0] = 0;
	for (ll i = 0; i < n; i++) {
		for (ll sum = 0; sum < maxn; sum++) {
			if (dp[i][sum] == LLONG_MAX) continue;
			dp[i + 1][sum] = min(dp[i + 1][sum], dp[i][sum]);
			if (sum + v[i + 1] < maxn) {
				dp[i + 1][sum + v[i + 1]] = min(dp[i + 1][sum + v[i + 1]], dp[i][sum] + w[i + 1]);
			}
		}
	}
	ll ans = LLONG_MAX;
	for (ll sum = maxn - 1; sum >= 0; sum--) {
		if (dp[n][sum] <= W) {
			ans = sum; break;
		}
	}
	cout << ans;
	return 0;
}
/*

*/

Measured memory_bytes: 246400
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    dd = [(1,1),(1,0),(0,1),(0,-1),(-1,0),(-1,-1)]

    while True:
        t,n = LI()
        if t == 0 and n == 0:
            break
        a = [LI() for _ in range(n)]
        si,sj = LI()
        d = collections.defaultdict(bool)
        for ai,aj in a:
            d[(ai,aj)] = True
        r = 1
        c = [(si,sj)]
        d[(si,sj)] = True
        for _ in range(t):
            n = []
            for ci,cj in c:
                for di,dj in dd:
                    ni = ci + di
                    nj = cj + dj
                    if d[(ni,nj)]:
                        continue
                    d[(ni,nj)] = True
                    n.append((ni,nj))
                    r += 1
            c = n

        rr.append(r)

    return '\n'.join(map(str, rr))


print(main())




Measured memory_bytes: 9576
n = int(input())
a = list(map(int, input().split()))
index = float('inf')
cnt = 1
for i in range(n):
    if a[i] == 1:
        index = i
        break
if index == float('inf'):
    print(-1)
    exit()
for i in range(index, n):
    if a[i] == cnt:
        cnt += 1
cnt -= 1
print(n - cnt)

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

void strReplace(string& str, const string& from, const string& to){
	string::size_type pos = 0;
	while(pos = str.find(from, pos), pos != string::npos){
		str.replace(pos, from.length(), to);
		pos += to.length();
	}
}

int main(){
	int n;
	cin >> n;
	cin.clear();
	cin.ignore();
	for(int i = 0; i < n; i++){
		string s;
		getline(cin, s);
		strReplace(s, "Hoshino","Hoshina");
		cout << s << endl;
	}
}

Measured memory_bytes: 1220
#include <stdio.h>
#include <stdlib.h>

#define MAX 1000

int S[MAX];
int top;

void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int main()
{
  char array[100];
  int n1,n2,x;

  /* 初期化 */
  initialize();

  /* 入力 */
  while(scanf("%s",array) != EOF){
    
    if (array[0] == '+'){
      n1 = pop();
      n2 = pop();
      push(n2 + n1);
    }

    else if(array[0] == '-'){
      n1 = pop();
      n2 = pop();
      push(n2 - n1);
    }

    else if(array[0] == '*'){
      n1 = pop();
      n2 = pop();
      push(n2 * n1);
    }
    
    else {
      x = atoi(array);
      push(x);
    }
  }

  printf("%d\n",S[1]);

  return 0;
}

void initialize(void)
{
  top = 0;
}

int isEmpty(void)
{
  /* top == 0なら1を返す */
  if(top == 0) return 1;
  return 0;
}

int isFull(void)
{
  /* top >= MAX - 1なら1を返す */
  if(top >= MAX - 1) return 1;
  return 0;
}

void push(int x)
{
  if(isFull() == 1){
    fprintf(stderr,"オーバーフロー\n");
    exit(1);
  }

  top++;
  S[top] = x;
}

int pop(void)
{
  if(isEmpty() == 1){
    fprintf(stderr,"アンダーフロー\n");
    exit(1);
  }

  top--;
  return S[top+1];
}

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

int main() {
	cout << fixed << setprecision(30);
	int a, b, c, d, e, f;
	cin >> a >> b >> c >> d >> e >> f;
	set<int>water;
	for (int i = 0; i <= f / (a * 100); i++) {
		for (int j = 0; j <= f / (b * 100); j++) {
			int x = a * 100 * i + b * 100 * j;
			if(x!=0&&x<=f)water.insert(x);
		}
	}
	double_t ans = 0;
	int ans_w = 0;
	int ans_s = 0;
	for (auto w : water) {
		int sugmax = min(w * e / 100, f - w);
		int sugres = 0;
		for (int i = 0; i <= sugmax / c; i++) {
			for (int j = 0; j <= sugmax / d; j++) {
				int x = i * c + j * d;
				if (x <= sugmax)sugres = max(sugres, x);
				else break;
			}
		}
		double_t res = (double_t)sugres / (w + sugres);
		if (ans < res) {
			ans = res;
			ans_s = sugres;
			ans_w = w;
			//cout << res << endl;
		}
		//cout << sugres << " " << w << endl;
	}
	if (ans_s == 0) {
		cout << a * 100 << " " << 0 << endl;
		return 0;
	}
	cout << ans_w + ans_s << " " << ans_s << endl;
}

Measured memory_bytes: 256
N = int(input())
A = [0]*N
B = [0]*N
a = [0]*(N+1)
for i in range(N):
    A[i], B[i] = map(int, input().split())
    a[i] = A[i]

ans = 0
for i in reversed(range(N)):
    k = (A[i] + ans) % B[i]
    if k != 0:
        k = B[i] - k
    ans += k
print(ans)


Measured memory_bytes: 11636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int S;
    cin >> S;
  	int a = S / 100; 
    int b = S % 100;
  	
  	bool A = (a >= 1)&&(a <= 12);
  	bool B = (b >= 1)&&(b <= 12);
  
   if (A){
     if(B){
       cout << "AMBIGUOUS"<< endl;
     } else {
       cout << "MMYY"<< endl;
     }
  } else if(B) {
     cout << "YYMM"<< endl;
   } else {
     cout << "NA"<< endl;
   }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    int maxno, maxj;
    vector<int> a;
    vector<int> b(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> b.at(i);
    }

    int len = n;

    for(int i = 0; i < n; ++i) {
        maxno = 0;
        maxj = -1;
        for(int j = 0; j < len; ++j) {
            if(b.at(j) == j+1) {
                if(maxno < j+1) {
                    maxno = j+1;
                    maxj = j;
                }
            }
        }
        if(maxj != -1) {
            b.erase(b.begin() + maxj);
            a.push_back(maxno);
            len--;
        }else {
            break;
        }
    }

    if(!b.empty()) {
        cout << -1 << endl;
    }else {
        for(int i = n-1; i >= 0; --i) {
            cout << a.at(i) << endl;
        }
    }
}

Measured memory_bytes: 256
n=int(input())
a=[0]+list(map(int,input().split()))+[0]

#print(a)
s=0
for i in range(n+1):
   s+=abs(a[i+1]-a[i])
   
for i in range(1,n+1):
    si=s+abs(a[i+1]-a[i-1])-abs(a[i+1]-a[i])-abs(a[i]-a[i-1])
    print(si)


Measured memory_bytes: 13920
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
int ans = 0;
const int N = 20;
int arr[N][N], n;
bool arr1[N];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            arr[i][j] = -1;
        }
    }
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int q;
        cin >> q;
        while (q--)
        {
            int x, y;
            cin >> x >> y;
            arr[i][x] = y;
        }
    }
    for (int mask = 1; mask < (2 << n); mask++)
    {
        bool bo = 1;
        for (int i = 1; i <= n; i++)
        {
            arr1[i] = mask & (1 << (i - 1));
        }
        for (int i = 1; i <= n && bo; i++)
        {
            if (arr1[i])
            {
                for (int j = 1; j <= n && bo; j++)
                {
                    if (arr[i][j] != arr1[j] && arr[i][j] != -1)
                    {
                        bo = 0;
                    }
                }
            }
        }
        int temp = 0;
        if (bo)
        {
            for (int i = 1; i <= n; i++)
            {
                temp += arr1[i];
            }
        }
        ans = max(ans, temp);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

int main() {
    int N; cin >> N;
    vector<int>b(N); rep(i, N) cin >> b[i];
    vector<int>ans;
    rep(i, N) {
        bool okflg = false;
        for(int j = b.size() - 1; j >= 0; --j) {
            if((j + 1) == b[j]) {
                ans.pb(j + 1);
                b.erase(b.begin() + j);
                okflg = true;
                break;
            }
        }
        if(!okflg) {
            cout << -1 << endl;
            return 0;
        }
    }

    rep(i, ans.size()) {
        cout << ans[ans.size() - i - 1] << endl;
    }
}


Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var map = new char[n, n];
            for (int i = 0; i < n; i++)
            {
                var line = Console.ReadLine().Trim();
                for (int j = 0; j < n; j++) map[i, j] = line[j];
            }
            var dp = new int[n, n];
            for (int i = 0; i < n; i++)
            {
                if (map[0, i] == '.') dp[0, i] = 1;
                if (map[i, 0] == '.') dp[i, 0] = 1;
            }
            var maxn = 0;
            for (int i = 1; i < n; i++)
                for (int j = 1; j < n; j++)
                    if (map[i, j] == '*') dp[i, j] = 0;
                    else
                    {
                        dp[i, j] = Math.Min(Math.Min(dp[i - 1, j], dp[i - 1, j - 1]), dp[i, j - 1]) + 1;
                        maxn = Math.Max(maxn, dp[i, j]);
                    }
            Console.WriteLine(maxn);
        }
    }
}

Measured memory_bytes: 28784
#include <stdio.h>

#define NLIMIT (30)
#define WLIMIT (30)

int main()
{
	int i, n, w, a, b, point[WLIMIT], temp;
	
	scanf("%d", &w);
	scanf("%d", &n);
	for (i = 0; i < w; ++i) point[i] = i + 1;
	
	for (i = 0; i < n && (scanf("%d,%d", &a, &b) != EOF); ++i){
		temp = point[a - 1];
		point[a - 1] = point[b - 1];
		point[b - 1] = temp;
	}
	
	for (i = 0; i < w; ++i) printf("%d\n", point[i]);
	
	return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

/*
cin.tie(0);
ios::sync_with_stdio(false);
*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t;
	cin >> t;
	int i;
	for (i = 0; i < t; i++) {
		int n, d, j;
		cin >> n >> d;
		ll sum = d;
		for (j = 1; j < n; j++) {
			ll y = d ^ 127;
			sum -= d;
			sum += 127;
			sum += y;
			d = y;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
using namespace std;
const int N=1e6;
int n,k;
int a[N+10];
int ans[N+10];
vector <pair<int,int> > vec;
int main() {
    scanf("%d%d",&n,&k);
    for (int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for (int i=1;i<=n;i++)
        a[i]=max(0,k+1-a[i]);
    for (int i=1;i<=k/2;i++) {
        int max1=0,max2=0;
        for (int j=1;j<=n;j++) {
            if (a[j]>=a[max1]) {
                max2=max1;
                max1=j;
            }
            else if (a[j]>=a[max2]) max2=j;
        }
        a[max1]=max(0,a[max1]-1);
        a[max2]=max(0,a[max2]-1);
        vec.push_back(make_pair(max1,max2));
    }
    int kx=0;
    if (k%2) {
        kx=1;
        for (int i=1;i<=n;i++)
            if (a[i]) {
                a[i]--;
                kx=i;
                break;
            }
    }
    for (int i=1;i<=n;i++)
        if (a[i]) {
            printf("-1\n");
            return 0;
        }
    int cnt=0;
    if (k%2) ans[++cnt]=kx;
    for (int i=0;i<(int)vec.size();i++) {
        if (ans[cnt]==vec[i].first)
            swap(vec[i].first,vec[i].second);
        ans[++cnt]=vec[i].first;
        ans[++cnt]=vec[i].second;
    }
    printf("%d\n",(cnt+1)*(n-1)+1);
    for (int i=1;i<=cnt+1;i++) {
        for (int j=1;j<=n;j++)
            if (j!=ans[i-1]&&j!=ans[i])
                printf("%d ",j);
        if (i<=cnt) printf("%d ",ans[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2304
use proconio::input;

fn main() {
  
  let mut _a : i128 ;
  let mut _b : i128 ;
  let mut _c : i128 ;
  

    input! {
     
      mut a : i128,
      mut b : i128,
      mut c : i128,

    }
   if c >= a && c <= b {
     println!("Yes");
   }else{
    println!("No");

   }

}

Measured memory_bytes: 2084
#include <iostream>

using namespace std;

#define MAX_N 100000
int height[MAX_N];
int cost[MAX_N];
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int i;
    for(i = 0; i < n; ++i){
        cin >> height[i];
    }
    cost[1] = abs(height[1] - height[0]);
    for(i = 2; i < n; ++i){
        cost[i] = cost[i - 1] + abs(height[i] - height[i - 1]);
        cost[i] = min(cost[i], cost[i - 2] + abs(height[i] - height[i - 2]));
    }
    cout << cost[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include "stdio.h"
 
int main(void)
{
    char inp[101];
    unsigned char flag = 1; 
    unsigned char i = 0;
	
	scanf("%s", inp);
	
	while (inp[i] != '\0') {
	    if (i % 2 == 1) {
	        if ((inp[i] == 'L') || (inp[i] == 'U') || (inp[i] == 'D')  ) {
	            ;
	        } else {
	            flag = 0;
	            break;
	        }
	    } else {
	        if ((inp[i] == 'R') || (inp[i] == 'U') || (inp[i] == 'D')  ) {
	            ;
	        } else {
	            flag = 0;
	            break;
	        }
	    }
      
      i++;
	}
	
	if ( flag == 1) {
	    printf("Yes\n");
	} else {
	    printf("No");
	}
 
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cassert>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<utility>
using namespace std;


#define INF (INT_MAX/3-10)

/*
input data
*/

vector<vector<int> > plans;
vector<vector<int> > free_map;
void init(){
  plans.clear();
}

bool input(){
  int n;
  cin>>n;
  if(n==0)return 0;
  for(int i=0;i<n;i++){
    vector<int> tmp;
    int f;
    cin>>f;
    for(int j=0;j<f;j++){
      int tt;
      cin>>tt;
      tt--;
      tmp.push_back(tt);
    }
    plans.push_back(tmp);
  }
  return 1;
}


/*
dp とか
*/
void make_free_map(){
  free_map.clear();
  free_map.resize(plans.size());
  for(int i=0;i<free_map.size();i++){
    free_map[i].resize(30);
  }

  for(int i=0;i<plans.size();i++){
    for(int j=0;j<plans[i].size();j++){
      free_map[i][plans[i][j]]=1;
    }
  }
}


vector<vector<int> > has;
void init_has(){
  has.clear();
  has.resize(plans.size());
  for(int i=0;i<plans.size();i++){
    has[i].resize(plans.size());
    has[i][i]=1;
  }
}

bool has_unite(vector<int> list){
  vector<int> tmp;
  tmp.resize(plans.size());
  for(int i=0;i<list.size();i++){
    for(int j=0;j<tmp.size();j++){
      tmp[j]=tmp[j]||has[list[i]][j];
    }
  }
  for(int i=0;i<list.size();i++){
    has[list[i]]=tmp;
  }
  for(int i=0;i<tmp.size();i++){
    if(tmp[i]!=1){
      return false;
    }
  }
  return true;
}

int solve(){
  make_free_map();
  init_has();
  for(int i=0;i<30;i++){
    vector<int> tmp;
    for(int j=0;j<free_map.size();j++){
      if(free_map[j][i]==1){
        tmp.push_back(j);
      }
    }
    if(has_unite(tmp)){
      return i+1;
    };
  }
  return -1;
}


int main(){
  while(init(),input()){
    cout<<solve()<<endl;
  }
}

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

int main(){
    int N,ans=0;
    cin >> N;
    vector<int> d(N);
    for(int i=0;i<N;++i) cin >> d[i];

    for(int i=0;i<N-1;++i){
        for(int j=i+1;j<N;++j){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int mysort(int *array,int num){
	int i,j,t;
	for(i = 0;i < num;i++){
		for(j = num-1;j > i;j--){
			if(array[j] > array[j-1]){
				t = array[j];
				array[j] = array[j-1];
				array[j-1] = t;
			}   		
		}
	}
}
int main(){
	int i,high[10];
	for(i = 0;i < 10;i++){
		scanf("%d",high+i);
	}
	mysort(high,10);
	for(i = 0;i < 3;i++){
		printf("%d\n",high[i]);
	}
	return 0;
}
	
	

Measured memory_bytes: 600
def minesweeper(H: int, W: int, S: list)->list:
    directions = [
        (-1, -1), (-1, 0), (-1, 1),
        (0, -1),           (0, 1),
        (1, -1),  (1, 0),  (1, 1),
    ]
    ret = [[''] * W for _ in range(H)]

    for h in range(H):
        for w in range(W):
            if S[h][w] == '#':
                ret[h][w] = '#'
                continue

            count = 0
            for dh, dw in directions:
                if h + dh < 0:
                    continue
                if H <= h + dh:
                    continue
                if w + dw < 0:
                    continue
                if W <= w + dw:
                    continue
                if S[h+dh][w+dw] == '#':
                    count += 1
            ret[h][w] = str(count)

    return ret


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]
    ans = minesweeper(H, W, S)
    for a in ans:
        print(''.join(a))


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll n, k, s;
    cin >> n >> k >> s;
    const ll u = 1000000000;
    if (s == u) {
        for (int i = 0; i < k; i++) {
            cout << s << " ";            
        }
        for (int i = k; i < n; i++) {
            cout << 1 << " ";
        }
        cout << endl;
        return 0;
    }
    for (int i = 0; i < k; i++) {
        cout << s << " ";
    }
    for (int i = k; i < n; i++) {
        cout << s + 1 << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3592
# 055A

# N食(数値）：標準入力
N = int(input())

# 今までに払った金額：x円
x = 800 * N

# 15食ごとに貰える金額：y円
# // → 切り捨て除算小数点部分を省いて整数部分だけ返す（）
y = N // 15 * 200

print(x - y)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n, a, b, c;
    cin >> n >> a >> b >> c;
    
    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int res = 1001001001;
    rep1(i, 1<<n){
        rep1(j, 1<<n){
            rep1(k, 1<<n){

                vector<int> use_a(n, 0), use_b(n, 0), use_c(n, 0);
                int cnt_a = 0;
                int cnt_b = 0;
                int cnt_c = 0;
                rep(d, n){
                    if(i & (1<<d)){
                        use_a[d] = 1;
                        ++cnt_a;
                    }
                    if(j & (1<<d)){
                        use_b[d] = 1;
                        ++cnt_b;
                    }
                    if(k & (1<<d)){
                        use_c[d] = 1;
                        ++cnt_c;
                    }
                }

                bool ng = false;
                rep(d, n){
                    if(use_a[d] + use_b[d] + use_c[d] > 1) ng = true;
                }

                if(ng) continue;

                int cost_a = 10 * (cnt_a-1);
                int cost_b = 10 * (cnt_b-1);
                int cost_c = 10 * (cnt_c-1);

                int len_a = 0;
                int len_b = 0;
                int len_c = 0;
                rep(d, n){
                    len_a += l[d] * use_a[d];
                    len_b += l[d] * use_b[d];
                    len_c += l[d] * use_c[d]; 
                }

                res = min(res, abs(a-len_a)+cost_a + abs(b-len_b)+cost_b + abs(c-len_c)+cost_c);
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  int n;
  cin>>n;
  if(n==1)cout<<"Hello World"<<endl;
  else {
	int a,b;
	cin>>a>>b;
	cout<<a+b<<endl;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 5;
		int[] a = new int[n];
		int min = 10;
		int minIndex = -1;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			if (a[i] % 10 != 0 && min > a[i] % 10) {
				min = a[i] % 10;
				minIndex = i;
			}
		}
		int sum = 0;
		for (int i = 0; i < n; i++) {
			sum += kiriage(a[i]);
		}
		if (minIndex != -1) {
			sum -= kiriage(a[minIndex]);
			sum += a[minIndex];
		}
		System.out.println(sum);
	}

	static int kiriage(int num) {
		if (num % 10 == 0) {
			return num;
		}
		return num / 10 * 10 + 10;
	}

}


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

long long N, K;
vector<long long> sumV(100001);

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

  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  cout << s1[0] << s2[0] << s3[0] <<endl;
}


Measured memory_bytes: 1024
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	k := getNextInt64(scanner)
	aa := make([]int64, n)
	cc1 := make([]int64, n)
	cc2 := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
		for ii := 0; ii < i; ii++ {
			if aa[i] < aa[ii] {
				cc1[i]++
			}
		}
	}

	for i := 0; i < n; i++ {
		for ii := 0; ii < n; ii++ {
			if aa[i] < aa[ii] {
				cc2[i]++
			}
		}
	}

	var ans, mod int64
	mod = int64(1e9 + 7)

	for i := 0; i < n; i++ {
		ans += cc2[i] * (((k - 1) * k / 2) % mod)
		ans %= mod
		ans += cc1[i] * k
		ans %= mod
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
def rootedtrees():
    def set_depth(node_id):
        if tree[node_id]['parent'] == -1:
            return 0
        else:
            return set_depth(tree[node_id]['parent']) + 1

    n = int(input())

    tree = [{'parent': -1, 'depth': 0, 'node_type': 'leaf', 'children': []}
            for i in range(n)]

    for i in range(n):
        line = list(map(int, input().split()))
        node_id = line[0]
        children = line[2:]

        for child in children:
            tree[child]['parent'] = node_id

        if children:
            tree[node_id]['node_type'] = 'internal node'

        tree[node_id]['children'] = children

    for node_id in range(n):
        tree[node_id]['depth'] = set_depth(node_id)

        if tree[node_id]['parent'] == -1:
            tree[node_id]['node_type'] = 'root'

    for node_id in range(n):
        parent = tree[node_id]['parent']
        depth = tree[node_id]['depth']
        node_type = tree[node_id]['node_type']
        children = tree[node_id]['children']

        print('node {}: parent = {}, depth = {}, {}, {}'.format
            (node_id, parent, depth, node_type, children))

if __name__ == '__main__':
    rootedtrees()

Measured memory_bytes: 55948
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
a = Counter(a)
lis = []
 
for i,j in a.items():
    lis += [i]*(j//2)
 
#print(lis)
 
lis.sort(reverse=True)
if len(lis) <= 1:
    ans = 0
else:
    ans = lis[0]*lis[1]
 
print(ans)

Measured memory_bytes: 22076
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;

int main(void)
{
	int n, ans;
	long long  d, x, y;
	scanf("%d %lld", &n, &d);
	ans = 0;
	d = d * d;
	for (int i = 0; i < n; i++)
	{
		scanf("%lld %lld", &x, &y);
		if (x * x + y * y <= d)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
using namespace std;
typedef long long ll;

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int cnt = 0;
  for(int i=0; i<=a; i++){
    for(int j=0; j<=b; j++){
      for(int k=0; k<=c; k++){
        if(500*i+100*j+50*k == x) cnt++;
      }
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int n;
    scanf("%d", &n);

    int array[10001] = {0};
    int counter = 0;
    for (int x = 1; x * x < 10001; x++) {
        for (int y = 1; y * y < 10001; y++) {
            for (int z = 1; z * z < 10001; z++) {
                int value = ((x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x));
                if (value < 10001) {
                    array[value]++;
                }
            }
        }
    }
    array[6] = 1;
    for (int i = 1; i <= n; i++) {
        printf("%d\n", array[i]);
    }
    return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> P;
typedef pair<int64_t, int64_t> Pll;
 
 
 
 
int main() {
    string S;
    cin >> S;
    int64_t N = S.size() + 1, a = 0, ans = 0;
    bool T = false;
    vector<int64_t> A(N, -1);
    
    for (int i = 0; i < N - 1; i++) {
        if (S.at(i) == '>') {
            T = true;
            a++;
        }
        else if (T) {
            for (int j = 0; j < a; j++) {
                A.at(i - a + j + 1) = a - j - 1;
            }
            T = false;
            a = 0;
        }
        if (i == N - 2 && T){
            for (int j = 0; j < a; j++) {
                A.at(i - a + j + 2) = a - j - 1;
            }
        }
    }

    for (int i = 0; i < N - 1; i++) {
        if (A.at(i) != -1) {
            continue;
        }
        else {
            if (i == 0) {
                A.at(i) = max(int64_t(0), A.at(i + 1) + 1);
                continue;
            }
            A.at(i) = max(A.at(i - 1) + 1, A.at(i + 1) + 1);
        }
    }
    if (A.at(N - 1) == -1) {
        A.at(N - 1) = A.at(N - 2) + 1;
    }
    for (int i = 0; i < N; i++) {
        ans += A.at(i);
    }
    cout << ans << endl;


}


Measured memory_bytes: 4868
// -*- coding:utf-8-unix -*-

use proconio::input;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn main() {
    input! {
        n: usize,
        a: [u64; n],
    }

    let mut ans = a[0];
    for i in 1..n {
        ans = gcd(ans, a[i]);
    }
    println!("{}", ans);
}

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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,m,X;
    cin >> n >> m >> X;

    vector<ll> C(n,0);
    vector<vector<ll>>  A(n,vector<ll>(m,0));

    for(int i=0; i<n; i++){
        cin >> C[i];
        for(int j=0; j<m; j++){
            cin >> A[i][j];
        }
    }

    ll ans = 100000*13;

    vector<ll> a(m,0);
    ll loop_cnt=0b1<<(n);

    for(int x=1; x<loop_cnt; x++){
        int z=x;
        int i = 0;
        ll sum=0;

        while(z>0){
            if((z&0b1)==1){
                sum+=C[i];
                for(int j=0; j<m; j++){
                    a[j] += A[i][j];
                }
            }
            z>>=1;
            i++;
        }

        bool ok=true;
        for(int j=0; j<m; j++){
            if(a[j]<X)
                ok=false;
            a[j] = 0;
        }
        //print(x,ans, sum, a);

        if(ans>sum && ok){
            ans = sum;
        }
    }

    if(ans == 100000*13)
        ans = -1;

    cout << ans << endl;

    return 0;
}

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



int main(){
    int N;
    cin>>N;
    int a[N]={0};
    for (int i = 0; i < N; i++)
    {
        cin>>a[i];
    }
    int b=0;
    for (int i = 0; i < N; i++)
    {   
        if (a[i]%2==0)
        {
            if ((a[i]%3==0)||(a[i]%5==0)){

            }
            else
            {
                b++;
            }
        
        }
        
    }
    
    if (b==0){
        cout<<"APPROVED";

    }
    else{
        cout<<"DENIED";
    }




}

Measured memory_bytes: 256