akhauriyash/Code-Regression huggingface dataset:
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b = MAP()
flag = 0
for i in range(1, 10**6):
    if((i*8)//100==a and (i*10)//100==b):
        print(i)
        flag = 1
        break

if(flag==0):
    print(-1)


Measured memory_bytes: 40044
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-05 18:13:02
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

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

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l) {
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    sort(all(a), rev(int));

    int sum = 0;
    for (int i = 0; i < n; i++)
        sum += a[i];
    
    double nec = (double)sum/(4*m);

    int ok = 1;
    for (int i = 0; i < m; i++) {
        if (a[i] < nec) ok = 0;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

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

	int N,M,X;
	int i,j;
	int bit;
	int tmp;
	int answer=100001;
	bool flag;
	ll max=0;
	vector<int> sum;
	vector<vector<int>> given;


	cin >> N >> M >> X;
	sum.resize(M+1);

	for(i=0;i<N;i++){
		given.emplace_back();
		for(j=0;j<M+1;j++){
			cin >> tmp;
			if(j==0) max+=tmp;
			given[i].emplace_back(tmp);
		}
	}

	max++;
	answer=max;

	// start at 1
	for(bit=1;bit<(1<<N);bit++){
		flag=true;
		fill(sum.begin(),sum.end(),0);

		for(i=0;i<N;i++){
			if(bit&(1<<i)){
				//cout << given[i][0] << " ";
				transform(sum.begin(),sum.end(), given[i].begin(),sum.begin(),plus<int>());
			}
		}
		//cout << endl;


		/*
		for(i=0;i<M+1;i++)
			cout << sum[i] << " ";
		cout << endl;
		*/

		for(i=1;i<M+1;i++)
			if(sum[i]<X) flag=false; 

		if(flag && sum[0]<answer) answer=sum[0];
	}

	if(answer==max) cout << -1 << endl;
	else cout << answer << endl;

	return 0;
}



Measured memory_bytes: 3664
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i

cnt = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if 500 * i + 100 * j + 50 * k == x
    end
  end
end

puts cnt

Measured memory_bytes: 3836
#include <iostream>
#include <cmath>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  long long int x, k, d;
  cin >> x >> k >> d;

  long long int tmp = x / d;
  if (abs(tmp) > abs(k))
  {
    if (x < 0)
    {
      x += d * k;
    }
    else
    {
      x -= d * k;
    }
  }
  else
  {
    k -= abs(tmp);
    if (k % 2 == 1)
    {
      if (x < 0)
      {
        x += d * (abs(tmp) + 1);
      }
      else
      {
        x -= d * (abs(tmp) + 1);
      }
    }
    else
    {
      if (x < 0)
      {
        x += d * (abs(tmp));
      }
      else
      {
        x -= d * (abs(tmp));
      }
    }
  }
  cout << abs(x) << endl;
}


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

#print(A)
flag = True

while flag:
    flag = False
    minVal = min(A)
    #print(minVal)

    for i in range(len(A)):
        x = A[i] % minVal
        if x != 0:
            A[i] = x
            flag = True

    #print(A)

print(minVal)

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

using namespace std;



 int main(){

  string s;
  cin>>s;

  for(int i=0;i<s.length();i++){

    if(s[i] == ',')
        cout<<" ";
    else cout<<s[i];

  }

 return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if (N%1111 == 0 || (N%1000)%111 == 0 || (N-N%10)/10%111 == 0){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <climits>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <tuple>
#define ll long long
#define rep(i,s,n) for(ll i = (ll)(s); i < (ll)(n); i++)
#define all(a) (a).begin(),a.end()
#define mod 1000000007
using namespace std;
using graph =vector<vector<ll>>;
/*階乗*/
ll factorial(ll n){
    if(n==0){
        return 1;
    }
    else{
        return n*factorial(n-1);
    }
}

/* ユークリッドの互除法 最大公約数*/
ll gcd(ll a, ll b) {
	ll r;
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}



/*最小公倍数*/

ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}


/*二点間の距離*/
double dist(pair<double,double> a,pair<double,double> b){
	return sqrt(pow((a.first - b.first) ,2) + pow((a.second - b.second),2));
}

//繰り返し自乗法
double ism(double aa,ll p){
    double ap=aa;
    double ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans*=ap;
        }
        p/=2;
        ap=ap*ap;
    }
    return ans;

}
//繰り返し自乗法(アマリトリバージョン)
ll ismm(ll aa,ll p,ll m){
    ll ap=aa;
    ll ans=1;
    while(p>0){
        //cout<<"p="<<p<<",ap="<<ap<<endl;
        if(p&1){//奇数が真
            ans=(ans*ap)%m;    
        }
        p/=2;              
        ap=(ap*ap)%m;
    }
    return ans;

}
/*
ll solve(ll i,ll m,vector<ll>t,ll n){
    if(m==0){
        return 1;
    }
    if(i>=n){
        return 0;
    }
    
    
    cout<<i+1<<" "<<m<<endl;
    cout<<i+1<<" "<<m-t[i]<<endl;
    ll res=solve(i+1,m,t,n)||solve(i+1,m-t[i],t,n);
    return res;
}
*/

//小数点12桁
struct all_init
{
    all_init()
    {
        cout << fixed << setprecision(12);
    }
} All_init;


int main()
{
    vector<ll>a={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin>>k;
    cout<<a[k-1]<<endl;

    


    
}


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

int a[200005],b[200005];

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        b[i]=a[i];
    }
    sort(a,a+n);
    int k=n/2;;
    for(int i=0;i<n;i++){
        if(a[k]>b[i]) printf("%d\n",a[k]);
        else printf("%d\n",a[k-1]);
    }
    return 0;
}


Measured memory_bytes: 3712
N = gets.to_i
s = N.times.map { gets.chomp }.group_by(&:itself)
M = gets.to_i
t = M.times.map { gets.chomp }.group_by(&:itself)

p([s.keys.map do |key|
  s[key].size - (t[key] ? t[key].size : 0)
end.max, 0].max)


Measured memory_bytes: 3836
#!/usr/bin/env python3
import sys
from itertools import accumulate
import numpy as np
MOD = 1000000007  # type: int


def solve(N: int, s: str):

    # DP[i][j]はi文字目までをみたす順列のうち、最後がjで終わるものの個数
    DP = np.zeros((N, N+1), dtype=np.int64)
    DP[0][1] = 1

    for i in range(1, N):
        acc = np.cumsum(DP[i-1])
        if s[i-1] == "<":
            DP[i][1:i+2] = np.mod(acc[:i+1], MOD)
        else:
            DP[i][1:i+2] = np.mod(acc[i+1]-acc[:i+1], MOD)

    print(np.mod(DP[N-1].sum(), MOD))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = next(tokens)  # type: str
    solve(N, s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 82544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		try {
			String input = br.readLine();
			int num = Integer.parseInt(input);
			int i, x;
			String ret = "";
			for (i = 2; i <= num; i++) {
				x = i;
				if (x % 3 == 0) {
					ret = ret + " " + i;
				} else {
					ret = INCLUDE3(ret, i, x);
				}
			}
			System.out.println(ret);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static String INCLUDE3(String ret, int i, int x) {
		if (x % 10 == 3) {
			ret = ret + " " + i;
		} else {
		x = x / 10;
		if (x > 0) {
			ret = INCLUDE3(ret, i, x);
		}
}
		return ret;
	}
}

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

int main(){
    string S;
    cin >> S;
    int ans =S.size();

    for(int i=0;i<2;++i)
    {   
        int cnt =0;
        for(int j=0;j<S.size();j++){

            if(j%2==0 && S[j] !=   (char)(i+'0')) cnt++;
            if(j%2==1 && S[j] == (char)(i+'0')) cnt++;

        }
       ans = min(ans,cnt);
    }
   
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <algorithm>

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

using namespace std;

int n, k;
int c[26];
priority_queue<int> q;

int main(){
	cin >> n >> k;
	rep(i, n){
		string t;
		cin >> t;
		++c[t[0] - 'A'];
	}

	rep(i, 26){
		q.push(c[i]);
	}
	int s = 0;
	while(1){
		int v[26];
		rep(i, k){
			v[i] = q.top() - 1;
			q.pop();
		}
		if(v[k - 1] < 0){
			break;
		}
		++s;
		rep(i, k){
			q.push(v[i]);
		}
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using namespace chrono;
#define int long long
#define ld double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define sz(x) ((long long)x.size())
#define all(x) (x).begin(), (x).end()
#define popcount(x) __builtin_popcountll(x)
const int MOD =1e9+7;

mt19937_64 rng(high_resolution_clock::now().time_since_epoch().count());
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> istream& operator >> (istream &in,vector<T> &A){ for(auto &x:A) in>>x; return in; };
template<typename T> ostream& operator << (ostream &out,vector<T> &A){ for(auto &x:A) out<<x<<" "; return out; };
template<typename T,typename W> istream& operator >> (istream &in,pair<T,W> &A){ in>>A.fi>>A.se; return in; };
const int N = 5*1e6+10;

void solve()
{
	int n;
	cin>>n;
	map<string,int> ma;
	while(n--)
	{
		string s;
		cin>>s;
		ma[s]++;
	}	
	cout<<"AC"<<" x "<<ma["AC"]<<"\n";
	cout<<"WA"<<" x "<<ma["WA"]<<"\n";
	cout<<"TLE"<<" x "<<ma["TLE"]<<"\n";
	cout<<"RE"<<" x "<<ma["RE"]<<"\n";
}

int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	int t=1;
	// cin>>t;
	for(int _t=1;_t<=t;_t++){
		// cout<<"Case #"<<_t<<": ";
		solve();
	}
} 


Measured memory_bytes: 3656
// AOJ 2151: Brave Princess Revisited
// 2017.11.11 bal4u@uu

#include <stdio.h>
#include <string.h>

typedef struct { int n, m; } QUE;
QUE que[20001]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

int node[101][101];

void min_heapify(int i)
{
	int l, r, min;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && node[que[l].n][que[l].m] < node[que[i].n][que[i].m])
		min = l; else min = i;
	if (r < qsize && node[que[r].n][que[r].m] < node[que[min].m][que[min].m])
		min = r;
	if (min != i) {
		QUE t = que[i]; que[i] = que[min]; que[min] = t;
		min_heapify(min);
	}
}

int deq(int *n, int *m)
{
	if (qsize == 0) return 0;
	*n = que[0].n, *m = que[0].m;
	que[0] = que[--qsize];
	min_heapify(0);
	return 1;
}

void enq(int n, int m)
{
	int i, min;

	i = qsize++;
	que[i].n = n, que[i].m = m;
	while (i > 0 && node[que[min = PARENT(i)].n][que[min].m]
	         > node[que[i].n][que[i].m]) {
		QUE tt = que[i]; que[i] = que[min]; que[min] = tt;
		i = min;
	}
}

typedef struct { int len, to[101], d[101], e[101]; } TBL;
TBL tbl[101];
int node[101][101]; int size;

int search(int start, int goal, int l)
{
	int s, m, i, k, e, ans;
	TBL *tp;

	qsize = 0;
	memset(node, 0x55, sizeof(node));
	node[start][l] = 0; enq(start, l);
	ans = 0x7ffffff;
	while(deq(&s, &m)) {
		if (s == goal) {
			if (node[s][m] < ans) ans = node[s][m];
			continue;
		}

		for (tp = tbl + s, i = 0; i < tp->len; i++) {
			e = tp->to[i];

			k = node[s][m] + tp->e[i];
			if (k < node[e][m]) node[e][m] = k, enq(e, m);

			k = m - tp->d[i];
			if (tp->d[i] <= m && node[s][m] < node[e][k])
				node[e][k] = node[s][m], enq(e, k);
		}
	}
	return ans;
}

int main()
{
	int n, m, l, a, b, d, e, i;

	while (scanf("%d%d%d", &n, &m, &l) && n > 0) {
		memset(tbl, 0, sizeof(tbl));
		while (m--) {
			scanf("%d%d%d%d", &a, &b, &d, &e);
			a--, b--;
			i = tbl[a].len, tbl[a].to[i] = b, tbl[a].d[i] = d, tbl[a].e[i] = e, tbl[a].len++;
			i = tbl[b].len, tbl[b].to[i] = a, tbl[b].d[i] = d, tbl[b].e[i] = e, tbl[b].len++;
		}
		size = n;
		printf("%d\n", search(0, n-1, l));
	}
	return 0;
}

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

#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

int main() {FIN

	int n, i, j, k, c = 0;
	cin >> n;
	vi ns(n);
	for (i = 0; i < n; i++)
		cin >> ns[i];
	sort(ns.begin(), ns.end());

	for (i = 0; i < n; i++) {
		for (j = i + 1; j < n; j++) {
			auto k = lower_bound(ns.begin(), ns.end(), ns[i] + ns[j]) - ns.begin();
			c += max(0, (int)k - 1 - j);
		}
	}

	cout << c << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<iomanip>
using namespace std;
#define L long long int
L gcd(L a,L b){
	if(a<b){
		return gcd(b,a);
	}else if(a>b){
		return gcd(a-b,b);
	}else{
		return a;
	}
}

int main(){
L a,b,g;
while(cin>>a>>b){
	g=gcd(a,b);
	cout<<g<<" "<<a*b/g<<endl;
}

return 0;
}

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

void quickSort(int arr[], int left, int right) {
      int i = left, j = right;
      int tmp;
      int pivot = arr[(left + right) / 2];

      /* partition */
      while (i <= j) {
            while (arr[i] < pivot)
                  i++;
            while (arr[j] > pivot)
                  j--;
            if (i <= j) {
                  tmp = arr[i];
                  arr[i] = arr[j];
                  arr[j] = tmp;
                  i++;
                  j--;
            }
      };

      /* recursion */
      if (left < j)
            quickSort(arr, left, j);
      if (i < right)
            quickSort(arr, i, right);
}

int main(){
    int N = 0, total = 0; //number of questions
    cin >> N;
    int s[N]; //score of questions
    bool noans = true;

    for (int x = 0; x < N; x++) {
        cin >> s[x];
        total += s[x];
    }

    if (total % 10 != 0) {
        cout << total;
        noans = false;
    } else {
        quickSort(s, 0, N-1);
        for (int x = 0; x < N; x++) {
            if ((total - s[x]) % 10 != 0) {
                cout << total - s[x];
                noans = false;
                break;
            }
        }
    }
    if (noans) cout << 0;
}


Measured memory_bytes: 888
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> initialList = new ArrayList();
		for(int i = 0; i < n; i++) {
			initialList.add(sc.nextInt());
		}
		
		List<Integer> sortedList = initialList.stream().sorted().collect(Collectors.toList());
		
		int count = 0;
		String message = "YES";
		for(int i = 0; i < n; i++) {
			if(initialList.get(i) != sortedList.get(i)) {
				count++;
				if(count > 2) {
					message = "NO";
					break;
				}
			}
		}
		System.out.println(message);
		

		
		

		
		
	}	

}



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

int main(){
  string s;
  cin >> s;
  
  bool ans = true;
  if(s.at(5) == '1') ans = false;
  int k = s.at(6) - '0';
  if(k > 4) ans = false;
  
  if(ans) cout << "Heisei" << endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll N;
  cin >> N;
  ll sqrN = sqrt(N);
  for (ll i = sqrN; i >= 1; i--) {
    if (N % i == 0) {
      ll a = N / i;
      string sa = to_string(a);
      cout << sa.size() << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3740
#include<iostream>

int main(){
	int parts[301], a, b, c;
	while(std::cin >> a >> b >> c, a){
		for(int i=0;i<301;i++){
			parts[i] = 2;//未確定
		}

		int n, list[1000][4];
		std::cin >> n;
		for(int i=0;i<n;i++){
			for(int j=0;j<4;j++)std::cin >> list[i][j];
		}

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				if(list[j][3] == 1){
					for(int k=0;k<3;k++)parts[list[j][k]] = 1;
				}else{
					for(int k=0;k<3;k++){
						if(parts[list[j][k]] == 1 && parts[list[j][(k+1)%3]] == 1){
							parts[list[j][(k+2)%3]] = 0;
						}
					}
				}
			}
		}

		for(int i=1;i<=a+b+c;i++){
			std::cout << parts[i] << std::endl;
		}
	}
}

Measured memory_bytes: 1176
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int f(string &x, string &y, int xi, int yi, vector<vector<int>> &memo) {
    if (xi < 0 || yi < 0) return 0;
    if (memo[xi][yi] != -1) return memo[xi][yi];
    int ret;
    if (x[xi] == y[yi])
        ret = f(x, y, xi - 1, yi - 1, memo) + 1;
    else
        ret = max(f(x, y, xi - 1, yi, memo), f(x, y, xi, yi - 1, memo));
    memo[xi][yi] = ret;
    return ret;
}

int main() {
    int q;
    cin >> q;
    for (; q; --q) {
        string x, y;
        cin >> x >> y;
        int xl = x.size(), yl = y.size();
        vector<vector<int>> memo(xl, vector<int>(yl, -1));
        cout << f(x, y, xl - 1, yl - 1, memo) << endl;
    }
    return 0;
}



Measured memory_bytes: 7172
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
#define n_max 10000
#define INF 10001000

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,a,n) for(int i = a; i < (n); i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll; 

int main()
{
    int n;
    cin >> n;
    //int a[n];
    map<int, int> student;

    rep(i,n) { 
        int tmp;
        cin >> tmp;
        student[tmp] = i+1; 
    }

    for(auto s : student) { cout << s.second << " "; } 
    cout << endl;
    return 0;
}


Measured memory_bytes: 5504
n,m,l = map(int,input().split())

a = [list(map(int,input().split())) for x in range(n)]
b = [list(map(int,input().split())) for x in range(m)]
c = [[0 for x in range(l)] for y in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j]+=a[i][k]*b[k][j]
for l in c:
    print(*l)


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

int main()
{
    int l, r;
    cin >> l >> r;

    int ans = ((l % 2019) * (r % 2019)) % 2019;
    for (int i = l; i < r; i++) {
        if (i == l + 2019) {
            break;
        }
        for (int j = i + 1; j <= r; j++) {
            if (j == i + 1 + 2019) {
                break;
            }
            ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int A[112345];
cp2 B[112345];
int C[112345];
int ans = 1;
int idx;

int main(){
    
    cin>>N;
    REP( i, N ) cin>>B[i].fi;
    REP( i, N ) B[i].se = N-i;
    
    sort( B, B+N );
    
    int temp = B[0].fi;
    B[0].fi = 0;
    FOR( i, 1, N ){
        if( B[i].fi != temp ){
            temp = B[i].fi;
        }
        B[i].fi = i;
    }
    REP( i, N ) A[N-B[i].se] = B[i].fi;
    
    
    reverse( A, A+N );
    //REP( i, N ) cout<<A[i]<<endl;
    fill( C, C+N, mod );
    
    REP( i, N ){
        idx = upper_bound( C, C+ans, A[i] )-C;
        C[idx] = A[i];
        ans = max( ans, idx+1 );
    }
    
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 2560
N, M = list(map(int, input().split()))
ll = 1
rr = N

for i in range(M):
    l, r = list(map(int, input().split()))
    if ll <= l:
        ll = l
    if r <= rr:
        rr = r

if rr - ll  + 1> 0:
    print(rr - ll  + 1)
else:
    print(0)


Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, k, x[101], y[101], h[101], judge, Cx=0, Cy=0, H, a, ansH;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> x[i] >> y[i] >> h[i];
    }

    for(i=0; i<=100; i++){ // Cx
        for(j=0; j<=100; j++){ // Cy
            judge = 1;

            k = 1;
            while(h[k]==0){
                k++;
            }
            H = h[k]+labs(x[k]-i)+labs(y[k]-j);

            for(k=1; k<=N; k++){ // x[k],y[k],h[k]
                if(h[k] != max(H-labs(x[k]-i)-labs(y[k]-j),(ll)0)){
                    judge = 0;
                }
            }

            if(judge==1){
                Cx = i;
                Cy = j;
                ansH = H;
            }
        }
    }

    cout << Cx << " " << Cy << " " << ansH << endl;

    return 0;
}

Measured memory_bytes: 256
import math
x=input()
x0=x.split()
a=int(x0[0])
b=int(x0[1])
h=int(x0[2])
m=int(x0[3])
t1=float(math.pi*(h*60+m)/360)
t2=float(math.pi*m/30)
answer=math.sqrt((a*math.cos(t1)-b*math.cos(t2))**2+(a*math.sin(t1)-b*math.sin(t2))**2)
print(answer)


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int a, b; cin >> a >> b;
        int cnt = 0;
        while (a <= b) {
                string s = to_string(a++);
                if (s == string(s.rbegin(), s.rend())) cnt++;
        }

        cout << cnt << '\n';
}




signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

struct UnionFind {
  vector<int> d;
  UnionFind(int n = 0) : d(n, -1) {}

  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }

  bool unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return -d[find(x)]; }
};

int main() {
  ll n, m, k, a, b, c, d;
  cin >> n >> m >> k;

  vector<int> deg(n);
  vector<vector<int>> fr(n), bl(n);
  UnionFind uf(n);
  rep(i, m) {
    cin >> a >> b;
    a--, b--;
    fr[a].push_back(b);
    fr[b].push_back(a);
    uf.unite(a, b);
  }
  rep(i, k) {
    cin >> c >> d;
    c--, d--;
    bl[c].push_back(d);
    bl[d].push_back(c);
  }

  rep(i, n) {
    int ans = uf.size(i) - 1 - fr[i].size();
    for (auto x : bl[i])
      if (uf.same(i, x)) ans--;
    printf("%d%c", ans, (i == n - 1 ? '\n' : ' '));
  }

  return 0;
}


Measured memory_bytes: 14948
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main() {
    string S;
    cin >> S;
    int left = 0;
    int right = S.size()-1;
    int answer=0;
    while(left<right){
        if(S[left]!=S[right])
            answer++;

        left++;
        right--;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int N = sc.nextInt();
		out.println(N*N*N);
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int T, N;
vector<int> t;
int wktm[110], dp[110], nxt[110];
int ed;

signed main(){
    while(cin >> T, T){
        t.clear();
        t.resize(T);
        rep(i, 0, T) cin >> t[i];
        cin >> N;


        rep(i, 0, 110) wktm[i] = INF;
        ed = 0;
        rep(i, 0, N){
            int a, b;
            cin >> a >> b;
            wktm[a] = min(wktm[a], b);
            ed = max(ed, a);
        }
        rep(i, 0, 110) dp[i] = INF;
        dp[0] = 0;
        rep(i, 0, ed + 1){
            rep(j, 0, 110) nxt[j] = dp[j];
            rep(j, i, ed + 1){
                int wake = t[(j - i) % T];
                if(wake > wktm[j]) break;
                nxt[j] = min(nxt[j], dp[i - 1] + 1);
            }
            swap(dp, nxt);
        }
        // rep(i, 0, ed + 2){
        //     cout << dp[i] << " ";
        // }
        // cout << endl;
        cout << dp[ed] - 1 << endl;
    }
}


Measured memory_bytes: 2960
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N, M, A[10010], B[10010], COST[10010], parent[10010];
pair<int, int> bridge[10010];

void init(int N){
  for(int i=0; i<N; ++i) parent[i] = i;
}
int root(int a){
  if(parent[a] == a) return a;
  return (parent[a] = root(parent[a]));
}
bool is_same_set(int a, int b){
  return root(a) == root(b);
}
void unite(int a, int b){
  parent[root(a)] = root(b);
}

int main(){
  while(cin >> N >> M && N > 0){
    init(N);
    for(int i=0; i<M; ++i){
      cin >> A[i] >> B[i] >> COST[i];
      bridge[i].first = COST[i];
      bridge[i].second = i;
    }
    sort(bridge, bridge+M);

    int sum = 0;

    for(int i=0; i<M; ++i){
      int cost = bridge[i].first;
      int a = A[bridge[i].second];
      int b = B[bridge[i].second];
      if(is_same_set(a, b)) continue;
      unite(a, b);
      sum += cost;
    }
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1256
#include<iostream>
using namespace std;
int n,a[100010];
long long ans;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n+1;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
	{
		int b;
		cin>>b;
		if(b>=a[i])
		{
			b-=a[i],ans+=a[i];
			if(b>=a[i+1])
				ans+=a[i+1],a[i+1]=0;
			else
				ans+=b,a[i+1]-=b;
		}
		else
			ans+=b;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vector<P> p(n);
  rep(i, n) cin >> p[i].second >> p[i].first;
  sort(all(p));
  ll now = 0;
  bool ok = true;
  rep(i, n) {
    now += p[i].second;
    if(p[i].first < now) ok = false;
  }
  cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl sum(n + 1, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    sum[i + 1] = sum[i] + a;
  }
  ll ans = 1e18;
  rep2(i, 1, n) {
    ll x = sum[i];
    ll y = sum[n] - sum[i];
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
N = int(input())

if N%4 == 0:
    print("Yes")
elif N%7 == 0:
    print("Yes")
else:
    for i in range(1,30):
        for j in range(1,30):
            temp = j*7 +i*4
            if temp == N:
                print("Yes")
                sys.exit()

    print("No")

Measured memory_bytes: 3060
from heapq import heappop as pop
from heapq import heappush as push
INF = 10 ** 20
n, k = map(int, input().split())

clst = []
rlst = []

for i in range(n):
  c, r = map(int, input().split())
  clst.append(c)
  rlst.append(r)

edges = [[] * n for i in range(n)]

for i in range(k):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  edges[a].append(b)
  edges[b].append(a)

costs = [INF for i in range(n)]
costs[0] = 0
used = [False for i in range(n)]

def make_to_lst(s_num):
  loop = rlst[s_num]
  temp = {i for i in edges[s_num]}
  ret = {i for i in temp}
  while loop:
    new = set()
    for p in temp:
      pto = {i for i in edges[p]}
      new = new | pto
    ret = ret | temp
    temp = new - ret
    if not temp:
      break
    loop -= 1
  return ret

used[0] = True
costs[0] = 0
break_flag = 0
que = [(clst[0], 0)]

while que and not break_flag:
  next_cost, s_num = pop(que)
  to_lst = make_to_lst(s_num)
  for num in to_lst:
    costs[num] = next_cost
    if num == n - 1:
      break_flag = 1
      break
    if not used[num]:
      push(que, (costs[num] + clst[num], num))
      used[num] = True

print(costs[n - 1])


Measured memory_bytes: 7840
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	D = inputInt()
	C = inputList()
	S = []
	ans = []
	for i in range(D):
		s = inputList()
		S.append(s)

	minC = min(C)
	minCn = 0
	for i,val in enumerate(C):
		if val == minC:
			minCn = i

	for i,val in enumerate(S):
		tmp = max(val)
		mins = 0
		for j,vol in enumerate(val):
			if tmp == vol:
				mins = j+1
				break
		if i > D//2:
			ans.append(mins)
		else:
			ans.append(minCn+1)

	for i in range(D):
		print(ans[i])

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 78296
N, Q = map(int, input().split())
S = input()

cs = [0] * (N-1)
cnt = 0
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == 'C':
        cnt += 1
    cs[i] = cnt

cs = [0] + cs

for _ in range(Q):
    l, r = map(int, input().split())
    print(cs[r-1] - cs[l-1])


Measured memory_bytes: 6340
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>

#define MOD 1000000007


using namespace std;

long long int modpow(long long int a, int n) {

	if (n == 0)return 1;
	if (n == 1) return a;

	long long int wk = modpow(a, n / 2);

	long long int ret = 0;
	if (n % 2 == 0) {
		ret = 1;
	}
	else {
		ret = a;
	}

	return (((ret * wk) % MOD) * wk) % MOD;

}

long long int gcd(long long int a, long long int b) {
	long long int tmp;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	long long int r = a % b;

	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

	return b;
}

long long int lcm(long long int a, long long int b) {

	long long int wk_int;

	wk_int = (a * b) % MOD;
	
	long long int ret;

	ret = (wk_int * modpow(gcd(a, b), MOD - 2)) % MOD;

	return ret;

}

bool isPrime(int n) {
	if (n == 1)return false;
	if (n == 2)return true;

	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}

	return true;
}








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

	int ans = m / n;

	while (true) {
		if (m % ans == 0)break;

		ans--;
	}

	cout << ans << endl;



	return 0;

}



Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    val Hs = readInputLine().split(" ").map { it.toInt() }
    
    var now = -1
    var ans = 0
    var tmp = 0
    
    for (h in Hs) {
        if (h <= now) {
            tmp++
        } else {
            ans = Math.max(ans, tmp)
            tmp = 0
        }
        now = h
    }
    ans = Math.max(ans, tmp)

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 61656
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N;
int GM[110][110];

int D[110];
void bfs(int src) {
  queue<int> Q;
  Q.push(src);
  D[src] = 0;
  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    for (int dst = 1; dst <= N; dst++) {
      if (GM[cur][dst] == 1 && !(D[dst] > 0)) {
        D[dst] = D[cur] + 1;
        Q.push(dst);
      }
    }
  }
}

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++)
      GM[i][j] = 0;
  }
  int u, k;
  for (int i = 1; i <= N; i++) {
    cin >> u >> k;
    int t;
    for (int j = 0; j < k; j++) {
      cin >> t;
      GM[i][t] = 1;
    }
  }
  bfs(1);
  cout << "1 0" << endl;
  for (int i = 2; i <= N; i++) {
    cout << i << ' ' << (D[i] > 0 ? D[i] : -1) << endl;
  }
}



Measured memory_bytes: 3096
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		if(S.substring(0, N/2).equals(S.substring(N/2)))
			System.out.println("Yes");
		else
			System.out.println("No");

	}

}


Measured memory_bytes: 22996
#include<cstdio>
#include<cstring>
using namespace std;
long long a, b, c, k, sum;
int main()
{
	scanf("%lld%lld%lld%lld", &a, &b, &c, &k);
	if(k >= a) {
		sum += a;
		k = k-a;
		if(k >= b){
			k= k-b;
			if(k != 0){
				sum = sum-k;
			}
		}else{
			sum = sum;
		}
	}
	else{
		sum = k;
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 1732
import sys
R = lambda:map(int,raw_input().split())

n = 10
w = []
k = []
scoreW = 0
scoreK = 0
for i in xrange(n):
    w.append(int(raw_input()))
for i in xrange(n):
    k.append(int(raw_input()))
w.sort(reverse=True)
k.sort(reverse=True)

m = 3
for i in xrange(m):
    scoreW += w[i]
    scoreK += k[i]

print scoreW, scoreK

Measured memory_bytes: 4240
a,b,h,m = map(int,input().split())
import math

C = abs(360 / 60 * m - 360 / 12 * h - 360 / 12 / 60 * m)
if C > 180:
    C = 360 - C
#print(C)

cosC = math.cos(math.radians(C))
#print(cosC)

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * cosC))

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

int main() {
  ll n; cin>>n;
  vector<ll> v(n);
  rep(i,n){cin>>v[i];}
  sort(v.begin(),v.end(), greater<ll>());
  ll a=0,b=0,j;
  rep(i,n-1){
    if(v[i]==v[i+1]){
      a=v[i];
      j=i+2;
      break;}
  }
  
  rep(i,n-j-1){
    if(v[i+j]==v[i+j+1]){
      b=v[i+j];
      break;
    }
  }
  cout<<a*b;
}

Measured memory_bytes: 1024
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>

using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int MINF = -1e9;;


int main() {
	int n;
	vector<ll> a;
	vector<ll> b;
	cin >> n;
	a.resize(n + 1);
	b.resize(n);
	rep(i, n+1) cin >> a[i];
	rep(i, n) cin >> b[i];

	ll sum = 0;
	for (int i = 0; i < n; ++i ) {
		sum += min(a[i], b[i]);
		b[i] -= min(a[i], b[i]);
		sum += min(a[i + 1], b[i]);
		a[i + 1] -= min(a[i + 1], b[i]);
	}
	cout << sum << endl;
	return 0;
}


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

int main()
{
	unsigned long long a_I, a_O, a_T, a_J, a_L, a_S, a_Z;
	cin >> a_I >> a_O >> a_T >> a_J >> a_L >> a_S >> a_Z;

	unsigned long long ans = a_O;

	int odd_count = 0;
	if (a_I % 2 == 1)
		odd_count++;
	if (a_J % 2 == 1)
		odd_count++;
	if (a_L % 2 == 1)
		odd_count++;

	if (odd_count >= 2 &&
		a_I > 0 &&
		a_J > 0 &&
		a_L > 0)
	{
		ans += 3;
		a_I--;
		a_J--;
		a_L--;
	}

	ans += a_I / 2 * 2 + a_J / 2 * 2 + a_L / 2 * 2;

	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
v = list(map(int, input().split()))
v.sort()

while True:
    if len(v)==1:
        break
    tmp = (v[0]+v[1])/2
    v.append(tmp)
    v.remove(v[0])
    v.remove(v[0])
    v.sort()
print(*v)

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

int main() {
  
  int n;
  cin >> n;
  
  string s = to_string(n);
  int ans = 0;
  for(int i = 0; i < 3; i++){
    if(s.at(i) == '7'){
      ans = 1;
    }
  }
  
  if(ans == 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }

}

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

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

const ll MOD = 1e9+7;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()


int main(int argc, char **argv)
{
	long double a;
	long double b;
	cin >> a >> b;
	ll res = (ll)(a*b);
	std::cout << (ll)res << std::endl;
}


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

int main(){
    int a,b,k,i;
    cin >> a >> b >> k;
    if(b-a+1<2*k){
        int n=b-a+1;
        for(i=0;i<n;i++){
            cout << a << endl;
            a++;
        }
    }
    else{
        for(i=0;i<k;i++){
            cout << a << endl;
            a++;
        }
        b -= (k-1);
        for(i=0;i<k;i++){
            cout << b << endl;
            b++;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using uld = unsigned long long;
using P = pair<int,int>;
const ll mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//function area

//main area
int main(){
    int n;
    cin >> n;
    int l[n];
    rep(i,n){
        cin >> l[i];
    }
    sort(l, l+n);
    int ans = 0;
    for(int i = 0; i<n; i++){
        for(int j = i+1; j<n; j++){
            for(int k = j+1; k<n; k++){
                if(l[i]+l[j] <= l[k] || l[j]-l[i] >= l[k]){
                    continue;
                }
                if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]){
                    continue;
                }
                else ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			int n = Integer.parseInt(br.readLine());
			String input_str[] = br.readLine().split("\\s+");
			int[] array = new int[n];
			for(int i=0; i < n; i++) {
				array[i] = Integer.parseInt(input_str[i]);
			}
			int work, sw = 0;
			for(int i=0; i<n-1; i++) {
				for(int j=n-1; j>i; j--) {
					if(array[j-1] > array[j]) {
						work = array[j-1];
						array[j-1] = array[j];
						array[j] = work;
						sw++;
					}
				}
			}
			output(array);
			System.out.println(sw);
		} catch (NumberFormatException | IOException e) {
			e.printStackTrace();
		}
	}
	private static void output(int[] array) {
		System.out.printf("%d", array[0]);
		for (int i=1; i<array.length; i++) {
			System.out.printf(" %d", array[i]);
		}
		System.out.printf("\n");
	}

}



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

using namespace std;
int main(void){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  
  int a_prime = min(k,a);
  k -= a_prime;
  int b_prime = min(k,b);
  k -= b_prime;
  int c_prime = k;
  
  int ans = a_prime - c_prime;
  
  cout<< ans << endl;
  
  return 0;
  
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


int main()
{
    int N;
    int H;
    cin >> N;
    int m = 0;
    int ans = 0;
    for (int i = 0; i < N;i++)
    {
        cin >> H;
        if(m <= H)
        {
            ans++;
        }
        m = max(m, H);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = input()
si = []

for ch in s:
    if ch == '0':
        si.append(0)
    else:
        si.append(1)

ptr = n
ret = []

while ptr > 0:
    for me in range(m, -1, -1):
        if me == 0:
            print(-1)
            exit()
        if ptr - me < 0:
            continue
        if si[ptr-me] == 0:
            ret.append(me)
            ptr -= me
            break

ret.reverse()

print(' '.join(map(str, ret)))


Measured memory_bytes: 11252
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {

  int n;
  cin >> n;

  vector<long long int> a(n);
  vector<long long int> s(n+1, 0);

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = s[i] + a[i];
  }

  long long int ans = 0;

  for (int i = 0; i < n; i++) {
    long long int sum = (s[n] - s[i+1]) % 1000000007;
    ans += a[i] * sum;
    ans %= 1000000007;
  }

  cout << ans << endl;

  return 0;

}


Measured memory_bytes: 6336
#include<stdio.h>
int main(){
    int n,m,b[100],a[100][100],i,k,sum[100];
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            scanf("%d",&a[i][k]);
        }
    }
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        for(k=0;k<m;k++){
            sum[i] += a[i][k] * b[k];
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",sum[i]);
    }
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int c[3];
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];
	}
	int ans = 1;
	zip(i, 0, n)
	{
		int cnt = 0;
		int id = -1;
		if (a[i] == c[0]) cnt++, id = 0;
		if (a[i] == c[1]) cnt++, id = 1;
		if (a[i] == c[2]) cnt++, id = 2;
		if (id == -1)
		{
			cout << 0 << en;
			return 0;
		}
		ans = (ans * cnt) % mod;
		c[id]++;
	}
	cout << ans << en;

	return 0;
}



Measured memory_bytes: 4396