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

using namespace std;

int main(void){
    int N, C;
    cin >> N >> C;
    int D[35][35];
    int i, j, k, l;
    for(i=0; i<C; i++){
        for(j=0; j<C; j++){
            cin >> D[i][j];
        }
    }
    int a[3][35];
    for(i=0; i<3; i++){
        for(j=0; j<35; j++){
            a[i][j] = 0;
        }
    }
    int c[510][510];
    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            cin >> c[i][j];
            int m = (i+j)%3;
            int n = c[i][j]-1;
            a[m][n]++;
        }
    }
    int res = 500*510*1000;
    int res_c = 0;
    for(i=0; i<C; i++){
        for(j=0; j<C; j++){
            for(k=0; k<C; k++){
                res_c = 0;
                for(l=0; l<C; l++){
                    res_c += D[l][i]*a[0][l] + D[l][j]*a[1][l] +D[l][k]*a[2][l];
                }
                
                if(i == k || j == k || i == j){
                    res_c = 500*510*1000;
                }
                if(res > res_c){
                    res = res_c;
                }
                
            }
        }
    }
    
    /*for(i=0; i<3; i++){
        for(j=0; j<35; j++){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }*/
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1280
from itertools import *
def get(X):
    for a,b,c,d in permutations(X):
        for x,y,z in product("+-*", repeat = 3):
            for f in ("(((%s%s%s)%s%s)%s%s)", "(%s%s%s)%s(%s%s%s)"):
                t = f%(a,x,b,y,c,z,d)
                if eval(t) == 10: return t
    return 0

while 1:
    X = map(int, raw_input().split())
    if X == [0,0,0,0]: break
    print get(X)

Measured memory_bytes: 6352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;

#define pi 3.141592653589

int main(){
	int H, W;
	while (cin >> H >> W)
	{
		if (H == 0 && W == 0) break;
		for (int i = 0; i < H; i++)
		{
			for (int j = 0; j < W; j++)
			{
				if (i == 0 || i == H - 1 || j == 0 || j == W - 1) cout << "#";
				else cout << ".";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
typedef unsigned int uint;
unsigned long long maxValue(vector<uint>&A,vector<uint>&B,uint K){
  //cerr<<K<<endl;
  unsigned long long res = 0;
  for(int i=0;i<A.size();i++){
    if((K&A[i])==A[i]){
      //cerr<<' '<<A[i]<<endl;
      res+=B[i];
    }
  }
  
  return res;
}
 
int main(){
  uint N,K; 
  cin>>N>>K;
  vector<uint> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i]>>B[i];
  }
  unsigned long long res = maxValue(A,B,K);
  for(uint i=0;i<32;i++){
    if(K & (1u<<i)){
      res = max(res, maxValue(A,B,(K-(1u<<i)) | ((1u<<i)-1)));
    }
  }
  cout<<res;
  return 0;
}


Measured memory_bytes: 1024
import numpy as np

nmx = input().split(' ')

n = int(nmx[0])
m = int(nmx[1])
x = int(nmx[2])

c = []
a = []

for i in range(n):
  input_tmp = input().split(' ')
  tmp_a = []
  for j in range(m+1):
    if j == 0:
      c.append(int(input_tmp[j]))
    else:
      tmp_a.append(int(input_tmp[j]))
      
  a.append(tmp_a) 

  
bits2 = []

for i in range(2**n):
  bin_ = bin(i)[2:]
  bits2.append('0'*(n-len(bin_)) + bin_)
  
bool_ = False
minimum_money = 0

for perm in bits2:
  money = 0
  
  score = [0] * m
  for i in range(n):
    if perm[i] == '1':
      money += c[i]
      
      for j in range(m):
        score[j] += a[i][j]
        
  
  score = np.array(score)
  
  if score[score < x].shape[0]:
    continue
   
  bool_ = True
  if minimum_money > money or minimum_money == 0:
  	minimum_money = money
  

if bool_:
  print(minimum_money)
else:
  print(-1)

Measured memory_bytes: 27408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=5e3+5,M=2e2+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
ll n,m,a[N][M],st[N][M],top[M],dis[N],f[N],g[N],ans;
int main(){
	read(n,m);
	rep(i,2,n)dis[i]=dis[i-1]+read();
	rep(i,1,n)rep(j,1,m)read(a[i][j]);
	rep(i,1,n){
		rep(j,1,n)g[j]=0;
		rep(j,1,m){
			for(;top[j]&&a[i][j]>=a[st[top[j]][j]][j];top[j]--){
				g[st[top[j]-1][j]+1]+=a[i][j]-a[st[top[j]][j]][j];
				g[st[top[j]][j]+1]-=a[i][j]-a[st[top[j]][j]][j];
			}g[i]+=a[i][j];st[++top[j]][j]=i;
		}
		rep(j,1,i){
			g[j]+=g[j-1];f[j]+=g[j];
			gmax(ans,f[j]-(dis[i]-dis[j]));
		}
	}cout<<ans<<endl;
}

Measured memory_bytes: 10368
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  string s, t;
  cin >> N >> s >> t;

  for(int i = 0; i <= N; i++){
    bool check = true;
    for(int j = i; j < N; j++){
      if(s[j] != t[j - i]){
        check = false;
        break;
      }
    }

    if(check){
      cout << N + i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
m = (-x+2*y)//3
n = (2*x-y)//3
mod = 10**9+7

def c(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q, mod-2,mod)%mod

if (x+y)%3 !=0 or m*n < 0:
    print(0)
else:
    print(c(m+n,n))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  vector<pair<int, int>> v(N);
  for(int i = 0; i < N; i++){
    int A, B;
    cin >> A >> B;
	v[i] = make_pair(A, B);
  }
  auto m = max_element(v.begin(), v.end());
  cout << m -> first + m -> second << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;
import java.io.*;

public class Main
{
  	int a, b, t;
  
    Main(Scanner in, PrintWriter out)
    {
    	a = in.nextInt();
      	b = in.nextInt();
     	t = in.nextInt();
      	out.println(b*(t/a));
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int main() {

  int N, T; cin >> N >> T;
  long long g[T + 1];
  rep(i, T + 1) g[i] = 0;
  rep(i, N) {
    int l, r; cin >> l >> r;
    g[l] ++; g[r] --;
  }

  long long max = g[0];
  REP(i, 1, T + 1) {
    g[i] += g[i - 1];
    max = std::max(max, g[i]);
  }

  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 3868
N = int(input())
A = list(map(int, input().split()))
A.sort()

OUT = 1 + 10 ** 18

ans = 1
for i, Ai in enumerate(A):
    if ans == 0: break
    #
    Ai_end = (OUT + ans - 1) // ans
    if Ai >= Ai_end:
        ans = -1
        break
    else:
        ans *= Ai

print(ans)

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

int main()
{
	int n,m;
	cin >> n >> m;
	vector<string> a(n);
	for(int i = 0; i < n;i++)
		cin >> a[i] ;
	vector<vector<int> > b(n, vector<int>(m,0));
	vector<vector<int> > c(n, vector<int>(m,0));

	for(int i = 0;i < n;i++)
	{
		for(int j=0;j<m;++j)
		{
			if(a[i][j] == '.')
			{
				c[i][j] = 1,b[i][j] = 1;
			}
		}
	}
	set<int> delr, delc;
	for(int i = 0;i < n;i++)
	{
		for(int j =1;j<m;j++)
		{
			b[i][j] += b[i][j-1];
		}
		if(b[i][m-1] == m)
			delr.insert(i);
	}

	for(int j=0;j < m;++j)
	{
		for(int i = 1;i < n; ++i)
		{
			c[i][j] += c[i-1][j];
		}
		if(c[n-1][j] == n)
			delc.insert(j);
	}

	// for(auto r : delr)
	// 	cout << r << endl;
	// cout << "col : " << endl;
	// for(auto c : delc)
	// 	cout << c << endl;
	// cout << endl;
	for(int i = 0;i < n;i++)
	{
		int flag = 0;
		for(int j =0;j<m;j++)
		{
			if(delr.find(i) == delr.end() and delc.find(j) == delc.end())
				flag = 1,cout << a[i][j];
		}
		if(flag)cout << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
 
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
 
using namespace std;
 
double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
 
inline void OPEN (string s) {
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
}
 
//end of template
 
const int maxn = 3e5+5;
int n;
int arr[maxn];
 
ll Left[maxn],Right[maxn];
int main(){
	scanf("%d",&n);
	rep(k,0,3*n)scanf("%d",&arr[k]);
	
	pq<int,vector<int>,greater<int> > ki;
	pq<int> ka;
	
	ll ret = 0;
	rep(k,0,3*n){
		ki.push(arr[k]);ret+= arr[k];
		while(ki.size()>n)ret-=ki.top(),ki.pop();
		Left[k] = ret;
	}
	ret = 0;
	repd(k,3*n-1,0){
		ka.push(arr[k]);ret+= arr[k];
		while(ka.size()>n)ret-=ka.top(),ka.pop();
		Right[k] = ret;
	}
	
	ret = -INFLL;
	rep(k,n-1,2*n)ret = max(ret,Left[k] -Right[k+1]);
	cout<<ret<<endl;
	return 0;
}

Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
void Fast() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
}
int main() {
	Fast();
	int n, i, k;
	cin >> n >> k;
	int* v = new int[n];
	bool** dp = new bool* [k+1];
	for (i = 0; i <= k; i++)dp[i] = new bool[2];
	for (i = 0; i < n; i++)cin >> v[i];
	for (i = 0; i <= k; i++) {
		dp[i][0] = 1, dp[i][1] = 0;
		for (int j = 0; j < n; j++) {
			if (i - v[j] >= 0)dp[i][1] |= dp[i - v[j]][0];
			if (i - v[j] >= 0)dp[i][0] &= dp[i - v[j]][1];
		}
	}
	cout << (dp[k][1] ? "First" : "Second");
	delete[]v;
	for (i = 0; i <= k; i++)delete[]dp[i];
	delete[]dp;
}	

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

int main(){
    int x,y,a,b,c;
    
    cin >> x >>y;
    
    a = max(x,y);
    b = min(x,y);
    
    while(a%b != 0){
        c = b;
        b = a%b;
        a = c;
    }
    
    cout << b <<endl;
    
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include <sstream>
#include <iomanip>
#include <time.h>
#include <fstream>
#include <map>

using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int> x(n+1),y(n+1),t(n+1);

	t[0] = 0;
	x[0] = 0;
	y[0] = 0;

	for(int i = 1; i <= n; i++){
		cin>>t[i]>>x[i]>>y[i];
	}
	for(int i = 1; i <= n; i++){
		int tau;
		tau = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);

		if (tau > t[i] - t[i-1]){
			cout<<"No";
			return 0;
		}
		if ((t[i] - t[i-1] - tau)%2 != 0) {
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, x, y, z;
	cin >> n >> x >> y >> z;
	string ans;
	vector<string> kek(n);
	for (auto &s : kek) cin >> s;
	for (int i = 0; i < n; i++) {
		string s = kek[i];
		if (s == "AB") {
			if (x < y) {
				x++;
				y--;
				ans.push_back('A');
			} else if (x > y) {
				x--;
				y++;
				ans.push_back('B');
			} else {
				if (i + 1 < n && kek[i + 1] == "BC") {
					x--;
					y++;
					ans.push_back('B');
				} else {
					x++;
					y--;
					ans.push_back('A');
				}
			}
		} else if (s == "BC") {
			if (y < z) {
				y++;
				z--;
				ans.push_back('B');
			} else if (y > z) {
				y--;
				z++;
				ans.push_back('C');
			} else {
				if (i + 1 < n && kek[i + 1] == "AB") {
					y++;
					z--;
					ans.push_back('B');
				} else {
					y--;
					z++;
					ans.push_back('C');
				}
			}
		} else {
			if (x < z) {
				x++;
				z--;
				ans.push_back('A');
			} else if (x > z) {
				x--;
				z++;
				ans.push_back('C');
			} else {
				if (i + 1 < n && kek[i + 1] == "AB") {
					x++;
					z--;
					ans.push_back('A');
				} else {
					x--;
					z++;
					ans.push_back('C');
				}
			}
		}
		if (x < 0 || y < 0 || z < 0) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (auto t : ans) {
		cout << t << '\n';
	}
}


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

const int MOD = (int)1e9+7;

int main(){
	int N,H;
	cin >> N >> H;
	vector<pair<int,int>> ba(N);
	for(int i=0;i<N;i++){
		int a,b;
		cin >> a >> b;
		ba.at(i)=make_pair(b,a);
	}
	
	sort(ba.begin(),ba.end(),greater<pair<int,int>>());
	//for(int i=0;i<N;i++)	cout << ba.at(i).first << "," << ba.at(i).second << endl;
	int max_i=0;
	for(int i=0;i<N;i++){
		if(ba.at(max_i).second<ba.at(i).second){
			max_i=i;
		}
	}
	//cout << max_i << endl;
	
	int ans=0;
	int now_i=0;
	while(H>0 && now_i<N){
		if(now_i==max_i){
			now_i++;
			continue;
		}
		if(H-ba.at(max_i).first<=0){
			H-=ba.at(max_i).first;
			ans++;
		}
		else if(ba.at(now_i).first>ba.at(max_i).second){
			H-=ba.at(now_i).first;
			ans++;
			now_i++;
		}
		else if(ba.at(now_i).first<=ba.at(max_i).second){
			break;
		}
	}
	
	if(H>0 && ba.at(max_i).first>ba.at(max_i).second){
		H-=ba.at(max_i).first;
		ans++;
	}
	if(H>0){
		ans+=(H+ba.at(max_i).second-1)/ba.at(max_i).second;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#from bisect import insort_left
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
#import heapq
#import numpy as np
S = input()
T = input()
c = 0
if S[0] == T[0]:
    c+= 1
if S[1] == T[1]:
    c+= 1
if S[2] == T[2]:
    c+= 1
print(c)

Measured memory_bytes: 2940
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    List<String> all = new ArrayList<String>();
    for (int ii = 0; ii < 3; ii++) {
      List <String>gs = new ArrayList<String>();
      for (int jj = 0; jj < 8; jj++) {
        int n = scanner.nextInt();
        double ti = scanner.nextDouble();
        String str = String.format("%03.2f,%02d", ti, n);
        gs.add(str);
        all.add(str);
      }
      Collections.sort(gs);
      for (int jj = 0; jj < 2; jj++) {
        String work[] = gs.get(jj).split(",");
        System.out.printf("%d %.2f\n", Integer.parseInt(work[1]), Double.parseDouble(work[0]));
        all.remove(gs.get(jj));
      }
    }
    Collections.sort(all);
    for (int ii = 0; ii < 2; ii++) {
      String work[] = all.get(ii).split(",");
      System.out.printf("%d %.2f\n", Integer.parseInt(work[1]), Double.parseDouble(work[0]));
    }
  }
}

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

int main(){
    int n, m; cin >> n >> m;

    vector<vector<int>> G(n);
    rep(i,m){
        int a, b; cin >> a >> b; a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<pair<int,int>> dist(n,make_pair(1<<30,-1));
    dist[0] = make_pair(0,-1);
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(auto nv : G[v]){
            if(dist[v].first + 1 < dist[nv].first){
                dist[nv].first = dist[v].first + 1;
                dist[nv].second = v; que.push(nv);
            }
        }
    }
    
    cout << "Yes" << endl;
    rep(i,n) if(i) cout << dist[i].second + 1 << endl;
    return 0;
}

Measured memory_bytes: 10552
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let money: i32 = read();
    let div: i32 = money / 500;
    let res: i32 = money % 500;
    let div2: i32 = res / 5;
    println!("{}", div*1000+div2*5);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int N;
int s[110];
int S = 0;


int solve(){
	if(S%10 != 0) return S;
	sort(RNG(s, N));
	rep(i, 0, N)
		if(s[i]%10 != 0) return S-s[i];
	return 0;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> s[i], S += s[i];

	cout << solve() << endl;

	return 0;
}

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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9

bool cmp(pair<int, string> a, pair<int, string> b){
  if(a.first == b.first){
    return a.second < b.second;
  }
  else{
    return a.first > b.first;
  }
}

int main(){
  int N;
  cin >> N;
  vector<string> S(N);
  map<string, int> mp;
  REP(i, N){
    cin >> S[i];
    mp[S[i]]++;
  }
  vector<pair<int, string>> pr;
  for(auto it = mp.begin(); it != mp.end(); ++it){
    pr.push_back({it->second, it->first});
    cerr << it-> second << " " << it-> first << endl;
  }
  sort(pr.begin(), pr.end(), cmp);
  int cnt = pr[0].first;
  cerr << "----------------" << endl;
  REP(i, pr.size()){
    cerr << pr[i].first << " " << pr[i].second << endl;
    if(pr[i].first != cnt){
      break;
    }
    cout << pr[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 31092
import numpy as np

N = int(input())
a = np.array(list(map(int, input().split())))

a = np.bincount(a//400)

fixed = np.where(a[:8]>0)[0].shape[0]
colorful = a[8:].sum()

if fixed==0:
    fixed = 1
    colorful -= 1

print(fixed, fixed+colorful)

Measured memory_bytes: 12504
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<n;i++)
#define Rep(i,n) for (int i=1;i<=n;i++)
using namespace std;

int main() {
	int n, m, c, ans = 0;
	cin >> n >> m >> c;
	vector<int> b(m);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, m) cin >> b[i];
	rep(i, n) {
		rep(j, m) cin >> a[i][j];
	}
	rep(i, n) {
		int sum=0;
		rep(j, m) {
			sum += b[j] * a[i][j];
		}
		sum += c;
		if (sum > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 2e5+5;
int n, a[N];
unordered_map<ll,int> mp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    ll pw = 1ll<<40;
    for(int i = n - 1; i >= 0; i--) {
        if(mp[a[i]]) {
            ans++;
            mp[a[i]]--;
            continue;
        }
        while(pw/2>a[i]) pw/=2;
        mp[pw-a[i]]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 20708
#include <iostream>

using namespace std;

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

    if(D == 25) cout << "Christmas";
    else if(D == 24) cout << "Christmas Eve";
    else if(D == 23) cout << "Christmas Eve Eve";
    else cout << "Christmas Eve Eve Eve";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;

    vector<ll> m(N);

    rep(i,K){
        ll d;
        cin>>d;
        rep(j,d){
            ll a;
            cin>>a;
            a--;
            m[a]=1;
        }
    }
    ll ans = 0;
    rep(i,N){
        if(m[i]==0){
            ans++;
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3508
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define vi vector<int>
#define LLMAX 4000000000000000000LL
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
struct edge
{
	int t, f, w;
	bool operator < (const edge& e) const
	{
		return w > e.w;
	}
	edge(int from, int to, int weight)
	{
		t = to;
		f = from;
		w = weight;
	}
};
#define ii pair<int,int>
#define MOD 1000000007
const double EPS = (1e-5);
long long binpow(long long a, long long b){long long res = 1;while (b > 0){if (b & 1)res = res * a;a = a * a;b >>= 1;}return res;}
int findXOR(int n){switch (n % 4){case 0:return n;case 1:return 1;case 2:return n + 1;case 3:return 0;}}
int rangeXOR(int l, int r){return (findXOR(l - 1) ^ findXOR(r));}
int getbit(int mask, int bit){return (mask & (1 << bit));}void setbit(int& mask, int bit, int val){if (val)mask |= (1 << bit);else mask &= ~(1 << bit);}
//ll gcd(ll a, ll b){return b == 0 ? a : gcd(b, a % b);}
//ll lcm(ll a, ll b){return a * (b / gcd(a, b));}
const int N = 1e5+10;
const int M = 1e6+3;
const ll INF = 1e9;
int h[N];
int dp[N];
void solve()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> h[i];
	for (int i = 0; i < n; ++i)
		dp[i] = INF;
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		for (int j = max(i - k, 0); j < i; ++j)
			dp[i] = min(dp[i], abs(h[j] - h[i]) + dp[j]);
	}
	cout << dp[n - 1] << '\n';
}
int main(void)
{
	//freopen("commandos.in", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int tc = 1;
	//cin >> tc;
	//scanf("%d", &tc);
	while (tc--)
	{
		solve();
	}
}

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

int main(){
  int N,M,i,ACcnt=0,WAcnt=0;
  cin >> N >> M;
  map<int,pair<string,int>> AtCoder;

  for(i=0;i<M;i++){
    int p;
    string S;
    cin >> p >> S;
    if(AtCoder.count(p)){
      if(AtCoder.at(p).first=="WA"){
        if(S=="AC"){
          ACcnt++;
          AtCoder[p].first = "AC";
          WAcnt += AtCoder[p].second;
        }else if(S=="WA")
        AtCoder[p].second++;
      }
    }else{
      if(S=="WA"){
        AtCoder[p].first = "WA";
        AtCoder[p].second = 1;
      }else if(S=="AC"){
        ACcnt++;
        AtCoder[p].first = "AC";
      }           
    }     
  }
  cout << ACcnt << " " << WAcnt << endl;
}


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

using namespace std;

#define rep(i, a, b) for (int i = (a); i <= (b); i++)

const int N = 1e5 + 100;

int n;
char s[110];

int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  rep(i, 1, n) {
    if (i % 2 == 0 && s[i] == 'R') return puts("No"), 0;
    if (i % 2 == 1 && s[i] == 'L') return puts("No"), 0;
  }
  return puts("Yes"), 0;
}

Measured memory_bytes: 256
def co(a):
    global y,c,d
    for _ in range(y):a+=int(a*c)-d
    return int(a)

def i(a):
    global y,c,d
    b=0
    for _ in range(y):
        b+=int(a*c)
        a-=d
    return int(a+b)

for _ in range(int(input())):
    m=0
    a=int(input());y=int(input())
    for _ in range(int(input())):
        b,c,d=map(float,input().split())
        m=max(m,co(a) if b==1 else i(a))
    print(m)

Measured memory_bytes: 7684
#include <stdio.h>
#define DOT(v1, v2) (v1.x * v2.x + v1.y * v2.y)
#define NORM(v) (v.x * v.x + v.y * v.y)

typedef struct { double x, y; } point_t;
typedef point_t vector_t;
typedef struct { point_t p0, p1; } segment_t;
typedef segment_t line_t;

static vector_t plus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x + v2.x, v1.y + v2.y };
  return ret;
}

static vector_t minus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x - v2.x, v1.y - v2.y };
  return ret;
}

static vector_t multiple(vector_t v, double s) {
  vector_t ret = { v.x * s, v.y * s };
  return ret;
}

static point_t calc_x(line_t l, point_t p) {
  vector_t base = minus(l.p1, l.p0);
  double r = DOT(minus(p, l.p0), base) / NORM(base);
  point_t x = plus(l.p0, multiple(base, r));
  return x;
}

int main(int argc, char **argv) {
  line_t l;
  point_t p;
  int q, i;

  scanf("%lf %lf %lf %lf", &l.p0.x, &l.p0.y, &l.p1.x, &l.p1.y);
  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%lf %lf", &p.x, &p.y);
    p = calc_x(l, p);
    printf("%.10lf %.10lf\n", p.x, p.y);
  }
}


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

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define LL long long
#define SZ(X) X.size()
#define pii pair<int,int>
#define ALL(X) X.begin(),X.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 2e5 + 11;
struct uzi
{
	int a, b;
	bool operator <(const uzi &t)const{
		return a<t.a;
	}
} p[N];
int n, T;
LL dp[N];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> T;
	for (int i = 1; i <= n; i++)cin >> p[i].a >> p[i].b;
		sort(p+1,p+1+n);
	for (int i = 1; i <= n; i++) {
		for (int j = min(6000, T + p[i].a - 1); j >= p[i].a; j--) {
			if (j - p[i].a < T)dp[j] = max(dp[j], dp[j - p[i].a] + p[i].b);
		}
	}
	LL ans = 0;
	for (int i = 1; i <= 6000; i++)ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

#input=sys.stdin.readline
s=input()
n=len(s)
al=[chr(ord('a') + i) for i in range(26)]
ind=[0]*26
for i in range(n):
    j=ord(s[i])-ord("a")
    ind[j]-=1
for i in range(26):
    if ind[i]==0:
        print(al[i])
        break
else:
    print("None")

Measured memory_bytes: 5564
def main():
    input()
    r, g, b = set(), set(), set()
    for i, s in enumerate(input()):
        if s == "R":
            r.add(i + 1)
        if s == "G":
            g.add(i + 1)
        if s == "B":
            b.add(i + 1)
    c = len(r) * len(g) * len(b)
    for i in r:
        for j in g:
            k = abs(i - j)
            if i + k in b:
                c -= 1
            if i - k in b:
                c -= 1
            if j + k in b:
                c -= 1
            if j - k in b:
                c -= 1
            if (i + j) / 2 in b:
                c -= 1
    print(c)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9236
#include <bits/stdc++.h>
using namespace std;
#ifdef _IS_LOCAL //
#define dout cout
#define debug() if(true)
#else
#define dout if(false) cout
#define debug() if(false)
#endif//
#define next asdnext
#define prev asdprev
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define vrep(i, v) for(auto &i : v)
#define all(x) (x).begin(),(x).end()
#define vout(v) for(auto &i:v){cout<<i<<" ";}cout<<"\n"; //配列出力
#define vin(v) for(auto &i:v)cin>>i; //配列入力
#define vec(v,n) vector<int> v(n,0);
typedef long long ll;
typedef unsigned long long ull;


void Main() {
	int N;
	cin>>N;
	int max1=-1, max2 = -1, index=0;
	rep(i,N){
		int tmp;
		cin>>tmp;
		if(max1<=tmp){
			index = i;
			max2 = max1;
			max1 = tmp;
		}
		else if(max2 <= tmp){
			max2 = tmp;
		}
	}

	rep(i,N){
		if(i == index){
			cout<<max2<<"\n";
		}
		else{
			cout<<max1<<"\n";
		}
	}
}

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


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

int main(){
    int N;
    cin >> N;
    vector<int> A;
    for(int i = 0; i < N; i++){
        int c = 0;
        cin >> c;
        A.push_back(c);

    }
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    int alice = 0;
    for(int i = 0; i < N; i += 2){
         alice += A[i];
    }
    int bob = 0;
    for(int i = 1; i < N; i += 2){
        bob += A[i];
        }

        cout << alice - bob << endl;

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int a=sc.nextInt()+sc.nextInt();
            System.out.println((a+"").length());
        }
    }
}
//by TTTMongolia 11/05/2012

Measured memory_bytes: 12000
import sys
sys.setrecursionlimit(1000000000)
char = list(input())
char_list_num = len(char)
count_list = [0] * char_list_num

def f(first_char,n,add_num):
    if first_char == char[n+add_num] and n + add_num != char_list_num - 1:
        return f(first_char,n+add_num,add_num)
    else:
        return n+add_num

num = 0
while not num == char_list_num - 1:
    reach_loop_num = f(char[num],num,1)
    diff = reach_loop_num - num
    if reach_loop_num == char_list_num - 1:
        if char[num] == char[reach_loop_num]:
            diff += 1
        else:
            count_list[reach_loop_num] += 1
    if char[num] == 'R':
        if diff % 2 == 0:
            count_list[reach_loop_num] += diff//2
            count_list[reach_loop_num-1] += diff//2
        else:
            count_list[reach_loop_num] += diff//2
            count_list[reach_loop_num-1] += diff//2 +1
    else:
        if diff % 2 == 0:
            count_list[num] += diff//2
            count_list[num-1] += diff//2
        else:
            count_list[num] += diff//2 +1
            count_list[num-1] += diff//2
    num = reach_loop_num
print(' '.join(map(str,count_list)))

Measured memory_bytes: 90636
import java.io.*;
import java.util.*;

class Main{
	static int[] A, B;
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		A = new int[n];
		str = br.readLine().split(" ");
		for(int i = 0; i < n; i++) A[i] = Integer.parseInt(str[i]);
		str = br.readLine().split(" ");
		int q = Integer.parseInt(str[0]);
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int b = Integer.parseInt(str[0]);
			int m = Integer.parseInt(str[1]);
			int e = Integer.parseInt(str[2]);
			B = A.clone();
			for(int j = 0; j < e - b; j++){
				B[b + ((j + (e - m)) % (e - b))] = A[b + j];
			}
			A = B.clone();
		}
		for(int i = 0; i < n; i++){
			System.out.print(A[i]);
			if(i != n - 1) System.out.print(" ");
		}
		System.out.print("\n");
	}
}



Measured memory_bytes: 37028
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from heapq import heappop,heappush,heapify

N,M = map(int, input().split())
A = [int(x) for x in input().split()]

A_minus = [-x for x in A]
heapify(A_minus)

pop = lambda: -heappop(A_minus)
push = lambda x: heappush(A_minus, -x)

for _ in range(M):
  x = pop()
  push(x//2)
  
ans = -sum(A_minus)
print(ans)

Measured memory_bytes: 14204
n,m = map(int,(input().split()))
mod = 10**9+7

sn,sm = 1,1
for i in range(1,n+1):
    sn = sn*i%mod
for i in range(1,m+1):
    sm = sm*i%mod

if abs(n-m)>=2:
    print(0)
elif abs(n-m) == 1:
    print(sn*sm%mod)
elif abs(n-m) == 0:
    print(sn*sm*2%mod)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n, d[50];
	cin >> n;
	rep(i, n)cin >> d[i];

	int ans = 0, s = 0;

	rep(i, n) s += d[i];
	rep(i, n)ans += (s - d[i]) * d[i];

	cout << ans / 2 << endl;


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define DEBUG 0
map<lli,vector<lli>> v; //労働を格納する配列
signed main(){

	lli n,m;
	cin>>n>>m; //要素数の取得

	for(lli i=0;i<n;i++){
		lli a,b;
		cin>>a>>b;
		v[a].push_back(b); //配列に入力(ここでは値が小さい順に辞書式に記録される)
	}
	lli sum=0;

	priority_queue<lli> q; //優先度付きキュー
	for(lli i=0;i<=m;i++){
		for(lli j=0;j<v[i].size();j++){
			q.push(v[i].at(j)); //キューに入力(i以下のものだけキューに入力)
			if(DEBUG)cout<<v[i].at(j)<<endl;
		}

		if(q.size()==0)continue;
		sum += q.top();
		if(DEBUG)cout<<q.top()<<endl;
		q.pop();
	}

	cout<<sum<<endl;
    
}

Measured memory_bytes: 10880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		long odd = 0;
		long count = 0;

		for (int i = 0; i < n; i++) {
			long a = Long.parseLong(br.readLine());
			if (a % 2 != 0)
				odd++;

			if (a == 1)
				count++;
		}

		if (odd != 0) {
			System.out.println("first");
		} else {
			System.out.println("second");
		}
	}
}

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

using namespace std;
using ll = long long int;

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

    ll n;
    cin >> n;
    vector<ll> a(n-1);
    for(auto &e: a) cin >> e;
    vector<ll> res(n);
    for(auto &e: a) res[e-1]++;
    for(auto &e: res) cout << e << endl;
    
}


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

int main() {
    int n, m, d, x, y, i, j;
	char ch[5] = "YBGR";
    scanf("%d%d%d", &n, &m, &d);
    for (i = 1; i <= n; ++i, putchar('\n'))
        for (j = 1; j <= m; ++j) printf("%c", ch[2 * ((i + j + m) / d % 2) + (i - j + m) / d % 2]);
	return 0;
}

Measured memory_bytes: 512
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
string S;

int main() {

	cin >> S;

	int ans = 0;
	rep(i, S.size() / 2) {
		if (S[i] != S[S.size() - 1 - i]) ans++;
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  int *A = new int[N];
  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;
  delete[] A;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

ll dist[333][333];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    REP(i,N) REP(j,N) cin >> dist[i][j];
    vector<vector<bool>> used(N, vector<bool>(N, 1));

    REP(k,N) REP(i,N) REP(j,N) if(i != k && j != k){
        if(dist[i][j] > dist[i][k] + dist[k][j]){
            cout << -1 << endl;
            return 0;
        }
        if(dist[i][j] == dist[i][k] + dist[k][j]){
            used[i][j] = 0;
        }
    }
    ll ans = 0;
    REP(i,N) REP(j,N) if(used[i][j]) ans += dist[i][j];
    cout << ans / 2 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
using namespace std;

int main(){
  
  long long N;
  
  cin>>N;
  
  long long dis = N;
  
  for(long long i=1;i<=sqrt(N);i++){
    if(N%i==0){
      long long j=N/i;
      dis=min(dis,i+j-2);
    }
  }
  cout<<dis<<endl;
 return 0; 
}

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

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

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

void solve(long long N, std::vector<long long> u, std::vector<long long> v){
    vector<vector<int>> edges(N+1);
    ll answer = 0;
    rep(i,1,N+1) {
        answer += i * (N - i + 1);
    }
    rep(i,0,N-1) {
        answer -= min(u[i], v[i]) * (N - max(u[i], v[i]) + 1);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> u(N-1);
    std::vector<long long> v(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 11192
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  int n,d;
  cin >> n >> d;
  double x[n],y[n];
  int ans=0;
  rep(i,n){
    cin >> x[i] >> y[i];
    if(sqrt(x[i]*x[i]+y[i]*y[i])<=d)ans++;
  }
  cout << ans;
}

Measured memory_bytes: 6884
import collections

N = int(input())
lst = input().split()
lst1 = []
lst2 = []
for i in range(N//2):
    lst1.append(lst[2 * i])
    lst2.append(lst[2 * i + 1])
dict1 = collections.Counter(lst1)
dict2 = collections.Counter(lst2)
#各リストで書き換える数
count1  = 0 
count2  = 0
# リスト１とリスト２の最頻語が同じであれば、
if (dict1.most_common()[0][0] == dict2.most_common()[0][0] ):
	# リスト１の方が多く出ている場合
	if dict1.most_common()[0][1] > dict2.most_common()[0][1]:
		count1 =  len(lst1) - dict1.most_common()[0][1]
		if len(lst2) == dict2.most_common()[0][1]:
			count2 = len(lst2)
		else:
		    count2 =  len(lst2) - dict2.most_common()[1][1]
	elif dict1.most_common()[0][1] < dict2.most_common()[0][1]:
		if len(lst1) == dict1.most_common()[0][1]:
			count1 = len(lst1)
		else:
		    count1 =  len(lst1) - dict1.most_common()[1][1]
		count2 =  len(lst2) - dict2.most_common()[0][1]
	# リスト１とリスト２の出現回数が同じであれば、２番目の数で決める
	else :
		if len(lst1) == dict1.most_common()[0][1]:
			count1 = len(lst1) 
		elif (dict1.most_common()[1][1] >= dict2.most_common()[1][1]):
			count1 =  len(lst1) - dict1.most_common()[1][1]
			count2 =  len(lst2) - dict2.most_common()[0][1]
		else:
			count1 =  len(lst1) - dict1.most_common()[0][1]
			count2 =  len(lst2) - dict2.most_common()[1][1]

else:
		count1 =  len(lst1) - dict1.most_common()[0][1]
		count2 =  len(lst2) - dict2.most_common()[0][1]

print(count1 + count2)

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

int main() {
    int n,t;
    cin>>n>>t;
    int mn=1001;
    while (n--) {
        int c,tt;
        cin>>c>>tt;
        if (tt<=t)
            mn=min(mn,c);
    }
    if (mn==1001)
        puts("TLE");
    else
        cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,c;cin>>a;
  vector<int>b(a);
  rep(i,a)b[i]=0;
  rep(i,a-1){
    cin>>c;
    b[c-1]++;
  }
  rep(i,a)cout<<b[i]<<endl;
}


Measured memory_bytes: 4060
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int N, i;
	scanf("%d", &N);
	for (i = 1; i * i <= N; i++);
	return !printf("%d\n", (i - 1)*(i - 1));
}

Measured memory_bytes: 256
def r;gets.split.map &:to_i;end
def rr(n);n.times{yield gets.chomp.split};end
N = gets.to_i
R = 380000
count = 0
rr(N) do |x,u|
  case u
  when "JPY"
    count += x.to_i
  when "BTC"
    count += x.to_f * R
  end
end
puts count


Measured memory_bytes: 1788