akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {

    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
    
      String[] line = br.readLine().split(" ");
      int n = Integer.parseInt(line[0]);
      int unit = Integer.parseInt(line[1]);
      long[] loads = new long[n];
      for(int i=0; i<n; i++)
        loads[i] = Long.parseLong(br.readLine());

      long left = 0;
      long right= 10_000 * n / unit;
      long mid;
      while(right - left > 1) {
        mid = (left+right) / 2;
        int v = calcNumOfLoads(unit, mid, loads);
        if(v>=n) right = mid;
        else left = mid;
      }
      long result = right;

      System.out.println(result);
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }
  private int calcNumOfLoads(int unit, long maxLoad, long[] loads) {
    int i=0;
    int tail=loads.length;
    long s;

    for(int j=0; j<unit; j++) {
      s=0;
      while(s+loads[i] <= maxLoad) {
        s += loads[i++];
        if(i == tail) return tail;
      }
    }

    return i;
  }
}


Measured memory_bytes: 35784
from fractions import gcd
a,b,c,d = map(int, input().split())
cnt = 0

#b以下からa以下を引く
#c and dで割り切れない→U - (cで割り切れる数+dで割り切れる数-cd最小公倍数で割り切れる数)
def cnt_num(cri):
  l = cri // c
  m = cri // d
  cd = c * d // gcd(c,d)
  lm = cri // cd
  return cri - (l + m - lm)
  
ans = cnt_num(b) - cnt_num(a-1)
print(ans)

Measured memory_bytes: 5076
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	string x;
	cin >> x;

	int xSize = x.size();

	for (int i = 0; i < xSize; i++)
	{
		cout << "x";
	}
}


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

using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
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 string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

int n;
void in(){
	cin >> n;
}

int dp[101010];
int dfs(int rest) {//残り引き出す必要がある金額がrestの時の引き出す最小回数
	if(rest == 0) return 0;
	if(dp[rest] > -1) return dp[rest];
	int ans = rest;

	chmin(ans, 1 + dfs(rest - 1));

	for(int i = 1; pow(6, i) <= rest; i++) {
		chmin(ans, 1 + dfs(rest - pow(6, i)));
	}

	for(int i = 1; pow(9, i) <= rest; i++) {
		chmin(ans, 1 + dfs(rest - pow(9, i)));
	}

	return dp[rest] =  ans;

}

void solve(){
	memset(dp, -1, sizeof(dp));
	print(dfs(n));


}

signed main(){

	cin.tie(0);
	ios::sync_with_stdio(false);
	in();
	solve();

}

Measured memory_bytes: 9320
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll MAX = 510000;
const ll MOD = 1000000007;

struct edge {
    ll from;
    ll to;
    ll cost;
};

ll V, E, d[210];
edge es[21000];

bool has_negative_loop(ll s) {
    fill(d, d + V, 1e16);
    d[s] = 0;
    for (ll i = 0; i < V; i++) {
        for (ll j = 0; j < E; j++) {
            edge e = es[j];
            if (d[e.to] > d[e.from] + e.cost and d[e.from] != 1e16) {
                d[e.to] = d[e.from] + e.cost;
                if (i == V - 1) {
                    return true;
                }
            }
        }
    }
    return false;
}

/*
void warshall_floyd() {
    for(ll k = 0; k < V; k++) {
        for(ll i = 0; i < V; i++) {
            for(ll j = 0; j < V; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
*/

int main(){
  cin >> V >> E;
  rep(i,E){
    ll a, b , c; cin >> a >> b >> c;
    es[i].from = a; es[i].to = b; es[i].cost = c;
  }

  vector<ll> ans;
  rep(i,V){
    if(has_negative_loop(i)){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
    rep(j,V){
      ans.pb(d[j]);
    }
  }
  rep(i,V){
    rep(j,V){
      if(ans[i * V + j] == 1e16) cout << "INF";
      else cout << ans[i * V + j];
      if(j < V - 1) cout << " ";
    }
    cout << endl;
  }

}



Measured memory_bytes: 3508
#DDCC Finals
X, Y = map(int,input().split())
money = 0
moneyX = 400000 - X*100000
moneyY = 400000 - Y*100000
if moneyX > 0:
    money += moneyX
if moneyY > 0:
    money += moneyY
if money == 600000:
    money += 400000
print(money)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
const int maxn=110;
int a[maxn][2];
const int maxx=1e6+10;
int dp[maxn][maxx];

const int MAXW = 1e5 + 10;

long long k[MAXW];
int n,w;


int main()
{
    cin >> n >> w;
    for(int j = 1; j<=n; j++)
    {
        int q,v;
        cin >> q >> v;
        for(int i = w; i>=q; i--)
        {
            k[i] = max(k[i-q] + v,k[i]);
        }
    }

    long long c = 0;
    for(int i = 0; i<=w; i++)
    {
        c = max(c,k[i]);
    }
    cout << c << endl;

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int cnt[26];

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) cnt[s[i] - 'a']++;
  rep(i, 26) if (cnt[i] == 0) {
    cout << (char)('a' + i) << endl;
    return 0;
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
use proconio::input;
use proconio::marker::Usize1;

fn gcd(n: u64, m: u64) -> u64 {
    if n < m {
        gcd(m, n)
    } else if m == 0 {
        n
    } else {
        gcd(m, n % m)
    }
}

fn main() {
    input! {
        a: u64,
        b: u64,
        c: u64,
    };
    let ans = c % gcd(a, b) == 0;
    println!("{}", if ans { "YES" } else { "NO" });
}


Measured memory_bytes: 2080
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int A;
  int B;
  cin >>A>>B;
  if(A>=13) {
cout << B<< endl;
    
  }
  else if ((A>=6) && (A<=12)) {
cout << B/2 << endl;
  }
  else if (A<=5) {
cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

void trace(int A[], int N){
	int i;
	for (i = 0; i < N; i++){
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void swap(int *a, int *b){
    int temp;
    temp = *a;

    *a = *b;
    *b = temp;
}

int selectionSort(int A[], int N){
    int minj, count;
    int i,j;
    count = 0;

    for (i = 0; i <= N - 1; i++){
    	// i : ?????????????????????index
    	// minj : ???????????????????´???????????°???? ???index?????¢?´¢
    	minj = i; 
    	for (j = i; j <= N - 1; j++){ 
    		if (A[j] < A[minj]) minj = j;
    	}
    	//minj ????±??????£????????§swap
    	if (minj != i){
    		swap(&(A[i]), &(A[minj]));
    		count++;
    	}
    }
    return count;
}



int main(void){
    int A[100];
    int N, i, count;

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

    count = selectionSort(A, N);

    trace(A,N);
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 604
def main():
  n = int(input())
  #s = input()
  #s = input().split()
  #a,b = list(map(int,input().split()))
  #a = [input() for i in range(n)]
  a = [int(input()) for i in range(n)]
  #a = [input().split() for i in range(n)]
  #a = [list(map(int,input().split())) for i in range(n)]
  ans = 0
  count = 0
  lis = []
  b = sorted(a)
  
  for i in range(n):
    ans += a[i]
  print(ans-b[-1]//2)
  

if __name__ == '__main__':
  main()

Measured memory_bytes: 3060
function main(input) {
    var N = input[0].split(" ")[0]-0;
    var list = input[1].split(" ").map(v=>v-0);
    var ans = Number.MAX_SAFE_INTEGER;
    for(var p=0;p<=100;p++){
        var sum = 0;
        for(var i=0;i<N;i++){
            sum += (list[i]-p)*(list[i]-p);
        }
        ans = Math.min(ans,sum);
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))


Measured memory_bytes: 7372
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String input = sc.next();
		if(input.equals("Sunny"))System.out.println("Cloudy");
		else if(input.equals("Cloudy"))System.out.println("Rainy");
		else{
			System.out.println("Sunny");
		}
	}
}


Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
	fast;
	ll a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(k-a>=0){
		sum=a;
		k-=a;
		if(k-b>=0){
			k-=b;
			if(k>=0)
				sum-=k,cout<<sum;
			else
				cout<<sum;
		}
		else{
			cout<<sum;
		}
	}
	else
		cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define int long long
#define ff first
#define dd second
#define mp make_pair
#define pb push_back
#define pp pair<int,int>
#define N 300005
using namespace std;

int tab[N];
int n, ans = 1e9;

int l[N];


main() {
    ios_base::sync_with_stdio(false);
    cin >> n; for(int i = 0; i < n; ++i) {
        char temp; cin >> temp;
        if(temp == 'W') tab[i] = 1; else tab[i] = 0;
    }

    int ww = 0;

    for(int i = 0; i < n; ++i) {
        l[i] = ww;
        if(tab[i]) ww++;
    }

    ww = 0;

    for(int i = n-1; i >= 0; --i) {
        l[i] += ww;
        ans = min(l[i], ans);
        if(!tab[i]) ww++;
    }

    cout << ans << endl;
}

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

int main(){
    int n;cin>>n;
    int a[n];for(int i=0;i<n;i++)cin>>a[i];
    long int m[n]={0};
    m[0]=a[0];
    for(int i=1;i<n;i++){
        m[i]=a[i]+m[i-1];
        //cout<<m[i];cout<<endl;
    }//cout<<endl;
    long long  min=9999999999999;
    for(int i=0;i<n-1;i++){
        if(abs((-m[i]+m[n-1])-m[i])<min) min=abs((-m[i]+m[n-1])-m[i]);
    }
    cout<<min<<endl;
}

Measured memory_bytes: 2560
import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
b = list(sorted(x))
c = list()
for i in range(N):
    c.append(b[i+1]-b[i])

t = c[0]
for i in range(1,N):
    t = fractions.gcd(t, c[i])
print(t)

Measured memory_bytes: 16240
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <list>
#include <sstream>

#define ll long long
#define ld long double
#define ull unsigned long long
using namespace std;

const ll mod = 1000000007;
const ll inf = 9223372036854775803;
const int maxN = 300005;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> H(n);
    vector<int> HH(n);
    for (int i = 0; i < n; i++) {
        cin >> H[i].first;
        H[i].second = i;
        HH[i] = H[i].first;
    }
    vector<vector<int>> adj(n, vector<int>());
    for (int i = 0; i < m; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    vector<bool> used(n, false);
    sort(H.begin(), H.end());
    int ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        int current = H[i].second;
        if (used[current]) {
            continue;
        }
        used[current] = true;
        int h = H[i].first;
        bool good = true;
        for (int j = 0; (j < adj[H[i].second].size()) && good; j++) {
            good = h > HH[adj[current][j]];
        }
        if (good) {
            ans++;
            for (int j = 0; j < adj[H[i].second].size(); j++) {
                int k = adj[current][j];
                used[k] = true;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 9536
N = int(input())
an = list(map(int, input().split()))

alis,bob = 0, 0
for i in range(N):
  if i%2 == 0:
    alis += max(an)
    an[an.index(max(an))]= 0
  elif i%2 == 1:
    bob += max(an)
    an[an.index(max(an))] = 0

print(alis - bob)

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

int main() {
  int b[101] = {0};
  int A[101][101] = {0};
  int n, m;
  int tmp = 0;

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

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

  // 出力する
  for (int i = 0; i < n; ++i) {
    tmp = 0;
    for (int j = 0; j < m; ++j) {
      tmp += A[i][j] * b[j];
    }
    cout << tmp << endl;
  }

  return 0;
}


Measured memory_bytes: 3152
import java.util.*;
import java.util.Map.Entry;
 
 
 class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
	 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] p = new int[N];
        double ans=0;
        
        long[] q = new long[N];
        for(int i=0;i<N;i++) {
        	p[i]=sc.nextInt();
        }
        long cnt=0;
        for(int i=0;i<K;i++) {
        	q[0]=q[0]+p[i];
        }
        for(int i=K;i<N;i++) {
        	q[i-K+1]=q[i-K]+p[i]-p[i-K];
        }
        long max=0;
        for(int i=0;i<N;i++) {
        	max=Math.max(max, q[i]);
        }
        ans=(max+K)/2.0;
        System.out.println(ans);        	
                		
    }
    
    
}

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

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

    int arr[N][3];
    int dp[N][3];

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++) {
            cin >> arr[i][j];
        }
    }

    for(int i = 0; i < 3; i++){
        dp[0][i] = arr[0][i];
    }

    for(int i = 1; i < N; i++) {
        dp[i][0] = arr[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = arr[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = arr[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }

    int result = dp[N - 1][0];
    for(int i = 0; i < 3; i++){
        result = max(result, dp[N - 1][i]);
    }
    
    cout << result << endl;


    





    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int main(){
    double d,t,vel,t1;

    scanf("%lf %lf %lf",&d,&vel,&t);

    t1 = d/vel;

    if(t1<=t){
        printf("Yes\n");
    }else{
        printf("No\n");
    }






    return 0;
}


Measured memory_bytes: 1684
#include<bits/stdc++.h>
#define N 505
#define sag (root+root+1)
#define sol (root+root)
#define ort  ((bas+son)/2)
#define mod 1000000007

using namespace std;
typedef long long ll;

ll n, a, b;

int main() {
    cin >> n >> a >> b;
    if(a>b)
        swap(a,b);
    
    if((b-a) % 2 == 0){
        cout << (b-a) / 2;
    }else{
        cout << min((a-1),(n-b)) +(b-a)/2+1;
    }

    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++)
int main() {
  int n; cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  sort(a.begin(),a.end());
  cout<<a[a.size()-1]-a[0];
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long a = (int) Math.sqrt(n);
        long x = 0;
        long y = 0;
        for (long i = a;i > 0;i--){
            if (n % i == 0){
              x = n / i;
              y = i;
              break;
            }
        }
        System.out.println(x + y - 2);
    }
}


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

int main(){
    int n; cin >> n;
    string s; cin >>s;

    for (int i = 0; i < s.size(); i++){
        if(s[i] + n <= 'Z')s[i] += n;
        else s[i] = 'A' + n -  ('Z' - s[i]) - 1;

    }

            cout << s << endl;

}

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

int main(){
  int H,W;
  cin >> H >> W;

  int a[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a[i][j];
    }
  }

  int N = 0;
  vector<vector<int>> x;
  for(int i=0;i<H;i++){
    if(i%2 == 0){
      for(int j=0;j<W;j++){
        if(a[i][j] % 2 == 1){
          if(j != W-1){
            N++;
            a[i][j]--;
            a[i][j+1]++;
            x.push_back({i+1,j+1,i+1,j+2});
          }else if(i != H-1){
            N++;
            a[i][j]--;
            a[i+1][j]++;
            x.push_back({i+1,j+1,i+2,j+1});
          }

        }
      }

    }else{
      for(int j=W-1;j>=0;j--){
        if(a[i][j] % 2 == 1){
          if(j != 0){
            N++;
            a[i][j]--;
            a[i][j-1]++;
            x.push_back({i+1,j+1,i+1,j});
          }else if(i != H-1){
            N++;
            a[i][j]--;
            a[i+1][j]++;
            x.push_back({i+1,j+1,i+2,j+1});
          }

        }
      }


    }
  }

  cout << N << endl;
  for(int i=0;i<x.size();i++){
    cout << x[i][0] << " " << x[i][1] << " " << x[i][2] << " " << x[i][3] << endl;
  }
  return 0;
}


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

int main(){

  int N,M,ans=0;
  cin >> N;
  string s[N];
  for(int i=0; i<N; i++){
    cin >> s[i];
  }
  cin >> M;
  string t[M];
  for(int i=0; i<M; i++){
    cin >> t[i];
  }
  int num[N];

  for(int i=0; i<N; i++){
    num[i] = 0;
  }

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(s[i]==s[j]) num[i]++;
    }
    for(int j=0; j<M; j++){
      if(s[i]==t[j]) num[i]--;
    }
  }

  for(int i=0; i<N; i++){
    ans = max(num[i], ans);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		BigInteger sum = new BigInteger("0");
		
		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			sum = sum.add(new BigInteger(Integer.toString(a)));
		}
		sum = sum.divide(new BigInteger(Integer.toString(n)));
		System.out.println(sum);
	}
}

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

using namespace std;

int main() {
	int n;
	int countAC = 0;
	int countWA = 0;
	int countTLE = 0;
	int countRE = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		string t;
		cin >> t;
		if (t == "AC") {
			++countAC;
		} else if (t == "WA") {
			++countWA;
		} else if (t == "TLE") {
			++countTLE;
		} else {
			++countRE;
		}
	}
	
	cout << "AC x " << countAC << endl;
	cout << "WA x " << countWA << endl;
	cout << "TLE x " << countTLE << endl;
	cout << "RE x " << countRE << endl;
	
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    string s;
    for (int i=0;i<n;i++) {
        cin>>s;
        std::map<string, int> map;
        int count=0;
        for (int i=1;i<s.size();i++) {
            string one=s.substr(0,i);
            string another=s.substr(i,s.size()-i);
            //反転しない
            if (map[one+another]==0) {
                count++;
                map[one+another]++;
            }
            if (map[another+one]==0) {
                count++;
                map[another+one]++;
            }
            //oneだけ反転
            reverse(one.begin(),one.end());
            if (map[one+another]==0) {
                count++;
                map[one+another]++;
            }
            if (map[another+one]==0) {
                count++;
                map[another+one]++;
            }
            reverse(one.begin(),one.end());
            //anotherだけ反転
            reverse(another.begin(),another.end());
            if (map[one+another]==0) {
                count++;
                map[one+another]++;
            }
            if (map[another+one]==0) {
                count++;
                map[another+one]++;
            }
            //どっちも反転
            reverse(one.begin(),one.end());
            if (map[one+another]==0) {
                count++;
                map[one+another]++;
            }
            if (map[another+one]==0) {
                count++;
                map[another+one]++;
            }
        }
        cout<<count<<endl;
    }
}


Measured memory_bytes: 3236
import sys
n = int(input())
h = list(map(int, input().split()))
h.reverse()
g = h[0]
for i in range(len(h)):
    if g - h[i] >= 0:
        g = h[i]
    elif g - h[i] == -1:
        g = h[i] - 1
    else:
        print("No")
        sys.exit()
print("Yes")


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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> as(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }
    int ans = 0;
    int j = 1;
    for (int i = 0; i < N; i++) {
        if (as[i] == j) {
            j++;
        } else {
            ans++;
        }
    }
    if (ans == N) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 1152
using System;

public class Hello{
    public static void Main(){
        
        string[] str=Console.ReadLine().Split(' ');
        
        int A=int.Parse(str[0]);//dayly point
        int B=int.Parse(str[1]);//weekly point
        int C=int.Parse(str[2]);//Parpose
        
        int P=0;
        int D=0;
        
        while(P<C)
        {
            D++;
            P+=A;
            if(D%7==0)P+=B;
        }
        
        Console.WriteLine(D);
        
    }
}



Measured memory_bytes: 19988
#include <bits/stdc++.h>
#define fi first
#define se second
#define max3(a, b, c) max(a, max(b, c))
using namespace std;

typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

int main()
{
    ios_base::sync_with_stdio(NULL); cin.tie(NULL);
    ll n, a, b;
    cin >> n >> a >> b;
    cout << a*(n/(a+b)) + min(a, n%(a+b));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <climits>
#include <vector>
using namespace std;

#define si static inline
#define gcu getchar_unlocked
si int in() {
	int c, n = 0;
	// bool minus = false; if ((c = gcu()) == '-') minus = true; else ungetc(c, stdin);
	while ((c = gcu()) >= '0' && c <= '9') n = 10 * n + (c - '0');
	return n; }
	// return minus ? -n : n; }
si void scan(char *s) {while (!isspace(*s++ = gcu()));}
#define pcu putchar_unlocked
#define svo si void out
template <typename T>
svo(T n) {
	static char buf[20];
	char *p = buf;
	//if(n < 0) pcu('-'), n *= -1;
	if (!n) *p++ = '0';
	else while (n) *p++ = n % 10 + '0', n /= 10;
	while (p != buf) pcu(*--p); }
svo(const char *s){while(*s)pcu(*s++);}
svo(char *s){while(*s)pcu(*s++);}
svo(char c){pcu(c);}
template <typename T>
//svo(vector<T> &v){for(T &x:v)out(' '),out(x);out('\n');}
svo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);out('\n');}
template <typename head, typename... tail>
svo(head&& h, tail&&... t){out(h);out(move(t)...);}
#undef svo
#undef si

template <typename T>
struct heap{
	vector<T> h = {T()};

	void insert(T x) {
		h.push_back(x);
		int c = h.size() - 1;
		for (int p = c / 2; p; c = p, p /= 2)
			if (h[p] < x)
				h[c] = move(h[p]);
			else
				break;
		h[c] = move(x);
	}
	T extract() {
		T res = move(h[1]);
		h[1] = h.back();
		T v = move(h[1]);
		h.pop_back();

		int p = 1, H = h.size();
		for (int c = 2; c < H; p = c, c = p * 2) {
			if (c + 1 < H && h[c] < h[c + 1])
				c++;
			if (h[c] < v)
				break;
			h[p] = move(h[c]);
		}
		h[p] = move(v);

		return move(res);
	}

	bool empty() {
		return h.size() == 1;
	}
};

#define v vector
struct graph {
	struct node {int n, w;};
	v<v<node>> nodes;

	void read(int n) {
		nodes.resize(n);
		for (auto &x: nodes) {
			in();
			for (int k = in(); k--;) {
				int c = in();
				x.push_back({c, in()});
			}
		}
	}

	v<node> dks() {
		v<node> w(nodes.size(), {0, INT_MAX});
		w[0].w = 0;
		heap<node> q;
		q.insert({0, 0});
		while (!q.empty()) {
			node n = q.extract();
			if (w[n.n].n)
				continue;
			w[n.n].n = 1;
			for (node &x: nodes[n.n]) {
				int a = n.w + x.w;
				if (w[x.n].w > a) {
					w[x.n].w = a;
					q.insert({x.n, a});
				}
			}
		}
		return move(w);
	}
};

bool operator < (const graph::node &a, const graph::node &b) {
	return a.w > b.w;
}

int main() {
	graph g;
	g.read(in());
	int i = 0;
	for (auto &x: g.dks())
		out(i++, ' ', x.w, '\n');
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll gcd(ll a, ll b) {
    if (a < b)
        swap(a, b);
    ll c = a % b;
    if (c == 0)
        return b;
    return gcd(b, c);
}

ll A[15];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll m = A[0];
    REP(i, N) {
        ll g = gcd(m, A[i]);
        m = m * A[i] / g;
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 3100
var lines = []; var result = 0;
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
})

rl.on('close', function () {
    var N = n(lines[0], 0)
    var M = n(lines[0], 1)

    var A = lines[1].split(" ").map(value => Number(value));

    var sum = []; sum[0] = 0;
    for (var i = 0; i < N; i++) { sum[i + 1] = (sum[i] + A[i]) % M; }

    var ans = 0; counter = {}
    for (var i = 0; i < sum.length; i++) {
        if (counter[sum[i]] === undefined) { counter[sum[i]] = 0 ;}
        
        ans += counter[sum[i]];
        counter[sum[i]]++;
    }

    console.log(ans);
});

function n(s, n) {
    return (Number(s.split(" ")[n]));
}

Measured memory_bytes: 37068
#!/usr/bin/env python
# -*- coding: utf-8 -*-

(N, A, B) = map(int, input().split(' '))

r = 0
for n in range(1, N + 1):
    s = sum(list(map(int, list(str(n)))))
    if A <= s <= B:
        r += n

print(r)


Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int l[] = new int [n];
    for(int i=0;i<n;i++){
      l[i]=sc.nextInt();
    }
    int answer =0;
    Arrays.sort(l);
    for(int i=2;i<n;i++){
      for(int j=0;j<i-1;j++){
        for(int k=j+1;k<i;k++){
          if(l[i]<l[j]+l[k]){
            answer = answer + i-k;
            break;
          }
        }
      }
    }
    System.out.println(answer);
    
  }
  

  
}

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

int main(){
    int s;
    int ans = 0;
    cin >> s;

    int one = s % 10;
    int ten = (s/10)%10;
    int hun = (s/100)%10;
    int th = (s/1000)%10;

    if ( one == ten || ten == hun ||  hun== th) {
        ans = 1;
    }
    if ( ans == 1) {
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<map<char,int>> cm(n);
    rep(i,n) {
        string s;
        cin >> s;
        map<char,int> nm;
        rep(j,s.size()) nm[s[j]]++;
        cm[i] = nm;
    }
    for(char c = 'a'; c <= 'z'; c++) {
        int num = 1001001001;
        rep(j,n) chmin(num,cm[j][c]);
        rep(j,num) cout << c;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <cctype>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vvl vector<vector<long long>>

using namespace std;

typedef long long ll;
typedef string::const_iterator State;

// <四則演算の式>をパース
int expression(State &);
// <乗算除算の式>をパース
int term(State &);
// <数>をパース
int number(State &);
// カッコの中
int factor(State &);

int main()
{
  int N;
  cin >> N;
  cin.ignore();
  REP(i, N)
  {
    string s;
    getline(cin, s);
    size_t pos;
    while ((pos = s.find_first_of(" ")) != string::npos)
    {
      s.erase(pos, 1);
    }
    State begin = s.begin();
    int ans = expression(begin);
    cout << ans << endl;
  }
  return 0;
}

int number(State &begin)
{
  int res = 0;

  while (isdigit(*begin))
  {
    res *= 10;
    res += *begin - '0';
    begin++;
  }

  return res;
}

int term(State &begin)
{
  int res = factor(begin);

  while (true)
  {
    switch (*begin)
    {
    case '*':
      begin++;
      res *= factor(begin);
      break;
    case '/':
      begin++;
      res /= factor(begin);
      break;
    default:
      return res;
    }
  }
}

int expression(State &begin)
{
  int res = term(begin);

  while (true)
  {
    switch (*begin)
    {
    case '+':
      begin++;
      res += term(begin);
      break;
    case '-':
      begin++;
      res -= term(begin);
      break;
    default:
      return res;
    }
  }
}

int factor(State &begin)
{
  if (*begin == '(')
  {
    begin++;
    int res = expression(begin);
    begin++;
    return res;
  }
  else
  {
    return number(begin);
  }
}


Measured memory_bytes: 3164
import java.util.*;

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

		int inu = scan.nextInt();
		int saru = scan.nextInt();

		if(Math.abs(inu-saru)>1) {
			System.out.println(0);
			return;
		}

		int result = 1;
		for(int i = 1; i <= inu; i++) {
			result = kakeru(result,i);
		}
		for(int i = 1; i <= saru; i++) {
			result = kakeru(result,i);
		}
		if(inu==saru) result = kakeru(result,2);

		System.out.println(result);
	}

	static int kakeru(int x, int y) {
		long l = (long)x * (long)y;
		return (int)(l %= 1000000007);
	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


vector<int> a[100001];
bool cs = true;
int f(int root, int par) {
    if (!cs) {
        return -1;
    }

    if (a[root].size() == 1 && a[root].front() == par) {
        return 0;
    }

    int total = 0, ans, contender = 0;
    map<int, int> d, node;
    for (int child : a[root]) {
        if (child != par) {
            int deg = a[child].size();
            d[deg]++;
            node[deg] = child;
        }
    }

    if (d.size() > 2) {
        cs = false;
        return 0;
    }

    if (d.size() == 1) {
        for (int child : a[root]) {
            if (child != par) {
                ans = f(child, root);
                if (!cs) {
                    return 0;
                }

                if (ans) {
                    total++;
                    contender = ans;
                }
            }
        }
    }

    if (d.size() == 2) {
        int deg;
        auto it = d.begin();
        int fir = it->second;
        it++;
        int sec = it->second;
        if (fir > 1 && sec > 1) {
            cs = false;
            return 0;
        }

        int x = 0, y = 0;
        if (sec == 1) {
            deg = it->first;
            ans = f(node[deg], root);
            contender =  node[deg];
            if (!cs) {
                return 0;
            }

            if (ans) {
                total++;
                contender = ans;
            }
            x = contender;

        }

        if (fir == 1) {
            it--;
            deg = it->first;
            ans = f(node[deg], root);
            contender = node[deg];
            if (!cs) return 0;
            if (ans) {
                total++;
                contender = ans;
            }

            y = contender;

        }

        if (x && y) {
            cs = false;
            return -1;
        }


    }

    if (total > 1) {
        cs = false;
        return 0;
    }

    if (total == 0) return 0;
    return contender;

}


bool can(int root) {
    bool vis[100001];
    memset(vis, false, sizeof vis);
    vis[root] = true;
    vector<int> cur, nex;
    cur.pb(root);

    while (!cur.empty()) {
        unordered_set<int> just;
        for (int e : cur) {
            for (int child : a[e]) {
                if (!vis[child]) {
                    just.insert(a[child].size());
                    nex.pb(child);
                    vis[child] = true;
                    if (just.size() > 1) {
                        return false;
                    }
                }
            }
        }

        cur = nex;
        nex.clear();
    }

    return true;

}



int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, k;
    cin >> n >> k;
    if (k == 1) cout << 0;
    else cout << (n - (k - 1) - 1);


}


//13
//2 3
//5 4
//1 10
//7 8
//5 10
//9 4
//3 11
//3 5
//5 8
//12 4
//6 8
//13 10

//
//9
//1 2
//2 3
//3 4
//4 5
//2 6
//4 7
//3 8
//8 9

Measured memory_bytes: 2560
n = int(input())
b = [int(x) for x in input().split()]
sum = b[0]

if n == 2:
    print(sum*2)
    exit()
for i in range(n-2):

    if b[i] <= b[i+1]:
        sum += b[i]
        #print(i,sum)                                                          
    else:
        sum += b[i+1]
print(sum+b[i+1])

Measured memory_bytes: 3060
int bw(const void *a, const void *b)
{
	return *(int*)b - *(int*)a;
}
#include<stdio.h>
int main()
{
	int n, o[100010] = {}, e[100010] = {};
	int o1[100010] = {}, e1[100010] = {};
	int oo, ee;
	scanf("%d", &n);
	for (int i = 0; i < n; i+=2)
	{
		scanf("%d%d", &oo,&ee);
		o[oo]++; e[ee]++;
		o1[oo]++; e1[ee]++;
	}
	qsort(o1, 100010, sizeof(int), bw);
	qsort(e1, 100010, sizeof(int), bw);
	int maxe = 0, maxo = 0;
	oo = 0, ee = 0;
	for (int j = 0; j < 100010; j++)
	{
		if (e[j] == e1[0]) maxe = j;
		if (o[j] == o1[0]) maxo = j;
	}
	if (maxe != maxo)
	{
		printf("%d", n - e[maxe] - o[maxo]);
		return 0;
	}
	if (e1[0] + o1[1] > e1[1] + o1[0])
	{
		printf("%d", n - e1[0] - o1[1]);
		return 0;
	}
	else
	{
		printf("%d", n - e1[1] - o1[0]);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 2044
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int a;
string s;

int main() {
	cin >> a >> s;


	if (a >= 3200) { cout << s<<endl; }
	else if(a<3200){ cout << "red"<<endl; }


	return 0;
}

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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
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; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  SPEED;
  ll s; cin >> s;
  cout << "0 0 ";
  double ds = s;
  double p = sqrt(ds);
  ll high = ceil(p);
  if (high*high == s) {
    cout << high << ' ' << 0 << ' ' << 0 << ' ' << high << endl;
    return 0;
  }

  ll low = high-1;
  if (low*high==s) {
    cout << low << ' ' << 0 << ' ' << 0 << ' ' << high << endl;
    return 0;
  }
  if (low*high<s) {
    low++;
  }

  ll k = low*high-s;
  cout << high << ' ' << k << ' ' << 1 << ' ' << low << endl;
}

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


int main() {
    int A,B;cin >> A >> B;
    if (A%3 == B%3){
      if (A%3 == 0){
        cout << "Possible" << endl;
      }else{
        cout << "Impossible" << endl;
      }
    }else{
      cout << "Possible" << endl;
    }

  }       

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

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

	int mx = a[0] + k-a[n-1];
	for (int i = 1; i < n; ++i) {
		mx = max(mx, a[i]-a[i-1]);
	}

	cout << k-mx << endl;
}

Measured memory_bytes: 1024
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n;
	cin>>n;
	double a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	double temp=a[0];
	for(ll i=0;i<n;i++)
	{
		temp=(temp+a[i])/2;
	}

	cout<<setprecision(9)<<temp<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int in;
int sum=0;
rep(i,10){
cin>>in;
sum+=in;
}
cout<<sum<<endl;
}

Measured memory_bytes: 1160
def PrimeDecomp(N,ConcFlag):
    if ConcFlag:
        if N<=1:
            return [1],1
        else:
            I = 2
            PrimeDec = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    PrimeDec.append(I)
                if Cnt>=1:
                    DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                DivCount *= 2
            return PrimeDec,DivCount        
    else:
        if N<=1:
            return [1],[1],1
        else:
            I = 2
            PrimeDec = []
            PrimeCnt = []
            DivCount = 1
            while I*I<=N:
                Cnt = 0
                while N%I==0:
                    N //= I
                    Cnt += 1
                if Cnt>=1:
                    PrimeDec.append(I)
                    PrimeCnt.append(Cnt)
                    DivCount *= (Cnt+1)
                I += 1
            if N>=2:
                PrimeDec.append(N)
                PrimeCnt.append(1)
                DivCount *= 2
            return PrimeDec,PrimeCnt,DivCount
          
from itertools import combinations
from operator import mul
from functools import reduce
N = int(input())
PrimeDec,_ = PrimeDecomp(N,True)
FABMax = len(str(N))
for TR in range(1,len(PrimeDec)+1):
    for A in set(reduce(mul,T) for T in combinations(PrimeDec,TR)):
        B = N//A
        FABMax = min(FABMax,max(len(str(A)),len(str(B))))
print(FABMax)

Measured memory_bytes: 9620
#include<iostream>
#include<stack>
using namespace std;
stack<char> a;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    for(int i=0; i<n; i++)
    {
        if(s[i]==')')
        {
            if(a.empty())
            {
                a.push(')');
            }
            else if(a.top()!='(')
            {
                a.push(')');
            }
            else
            {
                a.pop();
            }
        }
        else a.push('(');
    }
    while(!a.empty())
    {
        if(a.top()=='(')
        {
            s=s+')'; 
            a.pop();
        }
        else
        {
            s='('+s;
            a.pop();
        }
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N = ri()
A = rl()

for a in A:
	if a % 2 == 0:
		if not (a % 3 == 0 or a % 5 == 0):
			print('DENIED')
			exit()
print('APPROVED')

Measured memory_bytes: 38256
#include<cstdio>
#include<cstring>
int main()
{
    int x=0,y=0,m=0;
    char c[100001];
    scanf("%s",&c);
    int n=strlen(c);
    for(int i=0;i<n;i++)
    	if (x<=y)
    	{
        	x++;
        	if (c[i]=='p') m--;
    	}
    	else
    	{
        	y++;
        	if (c[i]=='g')
        	m++;
    	}
    printf("%d\n",m);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int tmp;
int main(){
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    int absmax = -1;
    int maxindex = 1;
    rep(i, N){
        if(abs(absmax) < abs(a[i])){
            absmax = a[i];
            maxindex = i;
        }
    }
    cout << N * 2 - 1 << endl;
    rep(i, N) cout << maxindex + 1 << " " << i + 1 << endl;
    rep(i, N - 1){
        if(absmax < 0) cout << N - i << " " << N - i - 1 << endl;
        else cout << i + 1 << " " << i + 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	cin >> N;
	map<string, int> m;
	int mx = 0;
	for (int i = 0; i < N; ++i) {
		string S;
		cin >> S;
		mx = max(mx, ++m[S]);
	}

	vector<string> ans;
	for (const auto& e : m) {
		if (e.second == mx) {
			ans.push_back(e.first);
		}
	}
	sort(ans.begin(), ans.end());
	for (auto& x : ans) {
		cout << x << endl;
	}
}


Measured memory_bytes: 26868
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    D = int(input())
    if D == 25:
        print('Christmas')
    elif D == 24:
        print('Christmas Eve')
    elif D == 23:
        print('Christmas Eve Eve')
    elif D == 22:
        print('Christmas Eve Eve Eve')


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, M;
typedef pair<int, int> P;
P D[100005];
priority_queue<int, vector<int>, greater<int> > que;

int main() {
  INCANT;
  cin >> N >> M;
  int x;
  rep(i, N) {
    cin >> x;
    que.push(x);
  }
  int a,b;
  rep(i, M) {
    cin >> a >> b;
    D[i]= P(b,a);
  }
  sort(D, D+M, greater<P>());
  int idx=0;
  ll SUM=0;
  while(!que.empty()) {
    int q = que.top(); que.pop();
    if (D[idx].first<=q || idx==M) SUM+=(ll)q;
    else {
      SUM+=(ll)D[idx].first;
      D[idx].second = D[idx].second-1;
      if (D[idx].second==0) idx++;
    }
  }

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

Measured memory_bytes: 1528
#include <iostream>
#include<cmath>
#define ll long long
using namespace std;
#define rep2(i,a,n) for(int i=a;i<=n;i++)
int main(void){
    // Your code here!
    ll n;
  cin >> n;
  ll ans = 1000000000005;
  ll m = (ll)sqrt(n);
  rep2(i, 1, m + 1) {
    if (n % i == 0) ans = min(ans, (i - 1) + (n / i - 1));
  }
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  
  for (int i = 0; i < n; i++){
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 256