akhauriyash/Code-Regression huggingface dataset:
N, M = map(int, input().rstrip().split(' '))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

print([i for i in make_divisors(M) if i <= M / N][-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)

void solve(){
  int n, y;
  cin >> n >> y;
  y /= 1000;
  FOR(i,0,y/10+1){
    FOR(j,0,(y-10*i)/5+1){
      int z = y - 10*i - 5*j;
      if(z<0) break;
      if(i+j+z==n) {cout << i << " " << j << " " << z << endl; return ;}
    }
  }
  cout << "-1 -1 -1" << endl;
}

int main(void){
  solve();
  return 0;
}

Measured memory_bytes: 256
n_vertex, n_edge = gets.split.map(&:to_i)
#puts "#{n_vertex} #{n_edge}"
edges = n_vertex.times.map { Array.new(n_vertex, -1) }
for i in 0...n_edge do
  u, v, d = gets.split.map(&:to_i)
#  puts "#{u} #{v} #{d}"
  edges[u - 1][v - 1] = d
  edges[v - 1][u - 1] = d
end
#for i in 0...n_vertex do
#  puts edges[i].join(" ")
#end
f = gets.split.map(&:to_i)
#puts f.join(" ")





t_max = gets.to_i
#puts "#{t_max}"
for t in 0...t_max do
  n_new = gets.to_i
#  puts "#{n_new}"
  for i in 0...n_new do
    new_id, dst = gets.split.map(&:to_i)
#    puts "#{new_id} #{dst}"
  end
  n_put = gets.to_i
#  puts "#{n_put}"
  for i in 0...n_put do
    put_id = gets.to_i
#    puts "#{put_id}"
  end
  
  if true
    command = -1
    puts command
    $stdout.flush
  end
  
  verdict = gets.chomp
  break if verdict == "NG"
  n_achieve = gets.to_i
#  puts "#{n_achieve}"
  for i in 0...n_achieve do
    achieve_id = gets.to_i
#    puts "#{achieve_id}"
  end
end


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

using namespace std;

int main(int argc, const char *argv[])
{
    int a, b;
    cin >> a >> b;

    int n = max(a, b);
    string s = to_string(min(a, b));
    string ans;
    for (int i = 0; i < n; i++)
    {
        ans += s;
    }
    cout << ans << endl;
}

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

result = {}
for a in A:
    if a in result:
        result[a] += 1
    else:
        result[a] = 1

count = 0
result = sorted(result.items(), key=lambda x: x[1])
if len(result) > K:
    for key, val in result[:len(result) - K]:
        count += val

print(count)


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

using namespace std;

int main(){
  int N;
  cin >> N;
 
  vector<int> L(N);
  for(int i = 0 ; i < N ; i++)
    cin >> L.at(i);

  int ans = 0;
  for(int i = 0 ; i < N ; i++){
    for(int j = i + 1 ; j < N ; j++){
      if(L.at(i) == L.at(j)) continue;
      for(int k = j + 1 ; k < N ; k++){
	if(L.at(k) == L.at(i)) continue;
	if(L.at(k) == L.at(j)) continue;

	if(L.at(i) + L.at(j) <= L.at(k)) continue;
	if(L.at(j) + L.at(k) <= L.at(i)) continue;
	if(L.at(k) + L.at(i) <= L.at(j)) continue;

	ans++;
      }
    }
  }
 
  cout << ans <<endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;

int main(int argc, char const *argv[]) {
  ll N;
  ll i;
  ll a;
  ll b;

  cin >> N;
  i = 1;
  a = 1;
  b = N;
  while (i <= sqrt(N) + 1) {
    if(N%i == 0){
      if(N/i >= i){
        a = i;
        b = N/i;
      } else {
        break;
      }
    }
    i++;
  }
  cout << a-1+b-1;
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <cstdio>
#include <math.h>
#include <vector>
#include <bitset>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
#define PI 3.14159265
#define INF	9999999999
#define pb push_back
#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
typedef long long int ll; 
typedef vector<ll> vi;
typedef vector<vi> vii;



int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,ans=-1,cnt,maxi=-1;
	cin>>n;
	FOR(i,n+1)
	{
		int x=nearestPowerOfTwo(i);
		if(x<=n) ans=max(ans,x);
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int n,i,j,N;
	int arr[11][11] = { 0 };

	while (1)
	{
		scanf("%d", &n);
		if (n == 0)
		{
			break;
		}


		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				scanf("%d", &arr[i][j]);
				arr[i][n] += arr[i][j];
			}
			arr[n][n] += arr[i][n];
		}

		
		for (i = 0; i < n; i++)
		{
			for (j = 0; j < n; j++)
			{
				arr[n][i] += arr[j][i];
			}
		}


		N = n + 1;
		for (i = 0; i < N; i++)
		{
			for (j = 0; j < N; j++)
			{
				printf("%5d", arr[i][j]);
				arr[i][j] = 0;
			}
			printf("\n");
		}
	}
	

	

	return 0;
}


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

int main(){
	int n;
	std::cin >> n;
	std::vector<int> a(n), b(n);
	for(int i=0; i<n; i++){
		std::cin >> a[i] >> b[i];
	}
	std::sort(a.begin(), a.end());
	std::sort(b.begin(), b.end());

	int ans;
	if(n%2 == 1){
		int l = a[n/2];
		int r = b[n/2];
		ans = r - l + 1;
	}else{
		int l = a[n/2-1] + a[n/2];
		int r = b[n/2-1] + b[n/2];
		ans = r - l + 1;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
typedef long double lb;
// typedef vector<int,vector<int>> vvec;
typedef long double ld;
typedef pair<int,int> P;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0L)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
inline ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }

//----***定数***----
const int MOD=1e9+7;
#define INF 1e9;
#define EPS 1e-9;

//----***入出力***---
#define print(out) cout<< out  << "\n";
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define here  cout<<"Here"<<endl;


//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}initial_;

signed main(){
  int N;cin>>N;
  int ans=0;
  vec(ll,A,N);
  REP(i,0,N){
    cin>>A[i];
  }
  REP(i,0,60){
    int bit=((int)1<<i);
    int cnt=0;
    REP(j,0,N){
      if(A[j]&bit){
        cnt++;
      }
    }
    ans+=((((bit%MOD)*cnt)%MOD)*(N-cnt))%MOD;
    ans%=MOD;
  }
  print(ans)

}


Measured memory_bytes: 2560
import java.util.Scanner;

class Main {
	public static void main(String args[]){	
		Scanner scan = new Scanner(System.in);
				
		int n, ap, bp, a;
		String str, str2;
		
		ap = 0;
		bp = 0;
		
		n = scan.nextInt();
		for(int i = 0; i < n; i++){
			str = scan.next();
			str2 = scan.next();
			
			a = str.compareTo(str2);
			
			if(a > 0){
				ap += 3;
			}else if(a == 0){
				ap++;
				bp++;
			}else{
				bp += 3;
			}
			
		}
			System.out.println(ap + " " + bp);
	}
}

Measured memory_bytes: 29836
#include <iostream>
using namespace std;
#include <algorithm>
#include <string>
#include <vector>
#define ll long long
struct s1
{
    int timu;
    int time;
};
int main()
{

    ll n,m;
    cin>>n;
    int a[n];
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    cin>>m;
    s1 s[m];
    for(int i=0;i<m;i++)
    {
        cin>>s[i].timu>>s[i].time;
    }
    ll t=sum;
    for(int i=0;i<m;i++)
    {
        sum=sum-a[s[i].timu-1]+s[i].time;
        cout<<sum<<endl;
        sum=t;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
n = int(input())
A = [int(x) for x in input().split()]
C = [0] * 10001
B = [0] * (n)
for a in A:
    C[a] += 1
for i in range(1, 10001):
    C[i] += C[i-1]
    if C[i] == n:
        break
for a in A[::-1]:
    B[C[a]-1] = a
    C[a] -= 1
print(*B)


Measured memory_bytes: 227024
using System.Linq;
using static System.Console;

namespace For_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int[][] C = new int[3][];
            C[0] = ReadLine().Split(' ').Select(int.Parse).ToArray();
            C[1] = ReadLine().Split(' ').Select(int.Parse).ToArray();
            C[2] = ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[] sa = new int[12];
            for(int i=0; i < 3; i++)
            {
                sa[i] = C[0][i] - C[1][i];
                sa[i + 3] = C[1][i] - C[2][i];
                sa[i + 6] = C[i][0] - C[i][1];
                sa[i + 9] = C[i][1] - C[i][2];
            }

            string ans = "Yes";
            for(int i = 0; i < 4; i++)
            {
                if (((sa[i * 3] == sa[i * 3 + 1]) & (sa[i * 3 + 1] == sa[i * 3 + 2])) == false)
                {
                    ans = "No";
                }
            }
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define eb(t) emplace_back(t)
typedef long long ll;
typedef long long unsigned int llu;
ll MOD = 1000000007;
ll INF = 1000000009;


void solve(){

    ll n;
    cin >> n;
    ll ans = 0;
    rep(i,n){
        if((i+1)%3==0||(i+1)%5==0) continue;
        else ans+=i+1;
    }

    cout << ans << endl;

}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


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

public class Main{
	public static void main(String[] args)throws IOException{
		int[][] map = new int[10][10];
		BufferedReader br = null;
		int max = 0,num = 0;
		try{
			br = new BufferedReader(new InputStreamReader(System.in));
			String buf;
			while((buf = br.readLine())!=null){

				String[] data = buf.split(",");
				int x = new Integer(data[0]);
				int y = new Integer(data[1]);
				int point = new Integer(data[2]);
				switch(point){
				case 3:
					for(int i = -2; i <=2; i+=4){
							if(check(x+i ,y))
									map[x+i][y]++;
							if(check(x,y+i))
								map[x][y+i]++;
					}
				case 2:
					for(int i = -1 ; i <=1; i+=2){
						for(int j = -1 ; j <=1 ;j +=2){
							if(check(x+i,y+j))
								map[x+i][y+j]++;
						}
					}
				case 1:
					for(int i = -1; i <=1; i+=2){
						if(check(x+i ,y))
								map[x+i][y]++;
						if(check(x,y+i))
							map[x][y+i]++;
					}
					map[x][y]++;
				}
			}
			for(int i = 0; i < map.length;i++){
				for(int j = 0; j < map[i].length;j++){
					if(map[i][j] == 0)num++;
					max = Math.max(max,map[i][j]);
				}
			}

		}finally{
			br.close();
		}
		System.out.println(num);
		System.out.println(max);
	}
		static boolean check(int x , int y){
			if(x > 9 || x < 0 || y > 9 || y < 0)return false;
			return true;
		}
}

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

dp = [0]  * (W + 1)
def knapsack():
  for i in range(N):
    w, v = map(int, input().split())
    for wk in range(W, w - 1, -1):
      tv = dp[wk - w] + v
      if tv > dp[wk]:
        dp[wk] = tv
knapsack()
res = max(dp)
print(res)

Measured memory_bytes: 9716
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/

/**********************************/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    int t[100];
    cin >> N;
    REP(i, N) cin >> t[i];
    cin >> M;
    int sum = 0;
    REP(i, N) sum += t[i];
    REP(i, M) {
        int p, x;
        cin >> p >> x;
        p--;
        cout << sum+x-t[p] << endl;
    }
}


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

int main() {
    int N; cin >> N;
    vector<vector<long long> > C(N, vector<long long>(N));
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) cin >> C[i][j];  
    long long res = 0;
    for (int i = 0; i < N; ++i) {
        for (int j = i+1; j < N; ++j) {
            res += min(C[i][j], C[j][i]);
        }
    }
    cout << res << endl;
}



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

int main(){
  int n=0,a,b,c,d;
  
  cin >> a;
  cin >> b;
  cin >> c;
  d = a- b;
  n = c;
  for( ; ;)
  if(d > 0){
    n = n + c;
    d = d - b;
  }
  else{
	cout << n << endl;
    break;
  }
  
  return 0;
  
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> bool max_self(T & a, const T & b){ 
  return b > a ? a = b, true : false; 
}
template<class T> bool min_self(T & a, const T & b){ 
  return b < a ? a = b, true : false;    
}
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);

int N, M, moves = 0, pos[(int)1e5 + 5];
vector<int> diff;

int main(){
  FAST_IO
  cin >> N >> M;
  for(int rep = 0; rep < M; ++rep) cin >> pos[rep];
  sort(pos, pos + M);

  moves = pos[M - 1] - pos[0];
//  cout << moves << '\n';

  for(int x = 1; x < M; ++x) diff.PB(pos[x] - pos[x - 1]);
  sort(ALLR(diff));

//  for(int ele : diff) cout << ele << " ";

//  cout << SZ(diff) << '\n';

  for(int rep = 0; rep < min(N - 1, SZ(diff)); ++rep){
    moves -= diff[rep];
  }
    
  cout << moves << '\n';
  return 0;
}


Measured memory_bytes: 4164
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue
#define printa(a, L, R)         \
    for (int i = L; i < R; i++) \
    cout << a[i] << (i == R - 1 ? '\n' : ' ')
#define printv(a) printa(a, 0, a.size())
#define print2d(a, r, c)            \
    for (int i = 0; i < r; i++)     \
        for (int j = 0; j < c; j++) \
    cout << a[i][j] << (j == c - 1 ? '\n' : ' ')
#define pb push_back
#define eb emplace_back
#define UB upper_bound
#define LB lower_bound
#define F first
#define S second
#define mem(a, x) memset(a, x, sizeof(a))
#define inf 1e18
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r, n) (int)(log2(n) / log2(r))
#define rev(v) reverse(v.begin(), v.end())
#define srt(v) sort(v.begin(), v.end())
#define grtsrt(v) sort(v.begin(), v.end(), greater<ll>())
#define all(v) v.begin(), v.end()
#define mnv(v) *min_element(v.begin(), v.end())
#define mxv(v) *max_element(v.begin(), v.end())
#define toint(a) atoi(a.c_str())
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)), v.end())
#define fout(x) fixed << setprecision(x)

const int mod = 1e9 + 7;
const int N = 3e5 + 9;
const ld eps = 1e-9;
const ld PI = acos(-1.0);
ll gc(ll a, ll b)
{
    while (b)
    {
        ll x = a % b;
        a = b;
        b = x;
    }
    return a;
}
ll lc(ll a, ll b) { return a / gc(a, b) * b; }
ll qpow(ll n, ll k)
{
    ll ans = 1;
    assert(k >= 0);
    n %= mod;
    while (k > 0)
    {
        if (k & 1)
            ans = (ans * n) % mod;
        n = (n * n) % mod;
        k >>= 1;
    }
    return ans % mod;
}

vll g[200000];
vll vis;
ll n, m;

void dfs(ll r)
{
    vis[r]=1;
    for(auto it:g[r])
    {
        if(vis[it]==1) continue;
        dfs(it);
    }
    return;
}

void solve()
{
    cin>>n>>m;
    vis.assign(n+10, 0);
    for(int i=1;i<=m;i++)
    {
        ll a, b;
        cin>>a>>b;
        g[a].pb(b);
        g[b].pb(a);
    }
    ll ct=0;
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==1) continue;
        ct++;
        dfs(i);
    }
    cout<<ct-1<<nl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 13004
N, M = map(int, input().split())

s = []
for i in range(M):
    S = list(map(int, input().split()))
    s.append(S[1:])

p = list(map(int, input().split()))

#print(s)

count = 0
for i in range(2**N):
    b = bin(i)[2:][::-1]
    switch = []
    for j in range(len(b)):
        if b[j] == "1":
            switch.append(j+1)
    #print(switch)
    
    f = 0
    for j in range(M):
        AND = len(list(set(switch) & set(s[j])))
        #print(AND, s[j])
        if (AND % 2 == p[j]):
            f += 1
    #print(f)
    if f == M:
        count += 1
    
                
    
    

print(count)

Measured memory_bytes: 3064
unittest
{
	assert( [ "-13 3" ].parse.expand.solve == -10 );
	assert( [ "1 -33" ].parse.expand.solve == 34 );
	assert( [ "13 3" ].parse.expand.solve == 39 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ab = input.front.split.to!( long[] );
	return tuple( ab[ 0 ], ab[ 1 ] );
}

auto solve( long a, long b )
{
	return max( a + b, a - b, a * b );
}


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

#define ll long long

int main()
{
    int n, k;
    cin >> n >> k;
    vector<ll> p(n);

    for(int i = 0; i< n; i++) cin >> p[i];
    int sum= 0;
    for(int i = 0; i< k; i++) sum += p[i];

    int ans = sum;
    for(int i = 0; i< n-k; i++)
    {
        sum = sum+p[k+i]-p[i];
        ans = max(ans, sum);
    }
    
    double ans2 = (ans+k)*0.5;
    printf("%.10f\n",ans2);
    return 0;
}

/*
double ev(double x)
{
    double mult = 1 / x;
    double ans = 0;
    for (double i = 0; i < x; i++)
    {
        ans += i;
    }
    return mult * ans;
}

int main()
{
    ll n, k, p[1000];
    double ans = 0.000000, prefix[1000];
    cin >> n >> k;
    for (int in = 0; in < n; in++)
    {
        cin >> p[in];
        prefix[in] = ev((double) p[in]) + 1.000000;
    }

    //cout << "******" << endl;
    for (int i = 0, j = i + k - 1; j < n; i++, j++)
    {
        double cur = 0;
        for (int k = i; k <= j; k++)
        {
            cur += prefix[k];
        }
        //cout << i << " " << cur << endl;
        ans = max(ans, cur);
    }

    
    printf("%.10f\n",ans);
}*/

Measured memory_bytes: 4840
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
    static const double pi = 3.141592653589793;
    double a,b,h,m;
    scanf("%lf %lf %lf %lf", &a, &b, &h, &m);
    double sita = (h/12 - m/60 + m/720);
    if(sita < 0) sita = (-1)*sita;
    if(sita > 0.5) sita = 1 - sita;
    sita = sita*2*pi;
    double ans_2 = a*a + b*b - 2*a*b*cos(sita);
    double ans = sqrt(ans_2);
    printf("%1.13lf", ans);
    return 0;
}

Measured memory_bytes: 2624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    int a[3][3];
    vector<vector< bool> > v(3,vector<bool> (3,0));
    for(int i=0;i<3;i++)for(int j=0;j<3;j++)cin>>a[i][j];
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int yay;cin>>yay;
        for(int k=0;k<3;k++)for(int j=0;j<3;j++){
            if(a[k][j]==yay){v[k][j]=1;break;}
        }
    }
    if(v[0][0]&&v[1][1]&&v[2][2]){cout<<"Yes";return 0;}
    if(v[2][0]&&v[1][1]&&v[0][2]){cout<<"Yes";return 0;}
    for(int i=0;i<3;i++){
        if(v[i][0]&&v[i][1]&&v[i][2]){cout<<"Yes";return 0;}
        if(v[0][i]&&v[1][i]&&v[2][i]){cout<<"Yes";return 0;}
    }
    cout<<"No";return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
write = sys.stdout.write
sys.setrecursionlimit(2*10**6)
class UF():
    def __init__(self, num):
        self.par = [-1]*num
        self.size = [1]*num
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx != ry:
            if self.par[rx] < self.par[ry]:
                self.par[ry] = rx
                self.size[rx] += self.size[ry] 
            elif self.par[rx] > self.par[ry]:
                self.par[rx] = ry
                self.size[ry] += self.size[rx]
            else:
                self.par[rx] -= 1
                self.par[ry] = rx
                self.size[rx] += self.size[ry]
            return True
        return False

def getpar(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[0] = -1
    par[p]  -1
    stack = [p]
    visited = set([p])
    while stack:
        vn = stack.pop()
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            stack.append(vf)
    return par

def topological_sort_tree(E, r):
    Q = [r]
    L = []
    visited = set([r])
    while Q:
        vn = Q.pop()
        L.append(vn)
        for vf in E[vn]:
            if vf not in visited:
                visited.add(vf)
                Q.append(vf)
    return L

N, M = map(int, readline().split())

Edge = []
for _ in range(M):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge.append((a, b))

tr = [[] for _ in range(N)]
ans = []
eo = [0]*N
T = UF(N)
for a, b in Edge:
    if T.union(a, b):
        tr[a].append(b)
        tr[b].append(a)
    else:
        ans.append((a+1, b+1))
        eo[a] ^= 1

L = topological_sort_tree(tr, 0)
P = getpar(tr, 0)
for l in L[1:][::-1]:
    if eo[l]:
        ans.append((l+1, P[l]+1))
    else:
        ans.append((P[l]+1, l+1))
        eo[P[l]] ^= 1
if M % 2 == 0:
    for a, b in ans:
        write('{} {}\n'.format(a, b))
else:
    write('-1\n')

Measured memory_bytes: 115800
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	long long int x, y;
	cin >> x >> y;
	long long int ans;
	if(x >= 0 && y >= 0){
		if(y >= x) ans = y - x;
		else if (y == 0) ans = x + 1;
		else ans = x - y + 2;
	} else if(x >= 0 && y < 0){
		if(-y >= x) ans = -y - x + 1;
		else ans = x + y + 1;
	} else if(x < 0 && y >= 0){
		if(y >= -x) ans = min(y - x, y + x + 1);
		else if(y == 0) ans = -x;
		else ans = - x - y + 1;
	} else {
		if(y >= x) ans = y - x;
		else ans = -y + x + 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author rahdirigs
 */

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

template <typename T> void add(T& a, T b, int mod) {
	a += b;
	if (a >= mod)
		a -= mod;
}

template <typename T> void sub(T& a, T b, int mod) {
	a -= b;
	if (a < 0)
		a += mod;
}

const int mod = 1e9 + 7;

class TaskT {
public:
	int N;
	string s;
	void solve(std::istream& in, std::ostream& out) {
		in >> N >> s;
		vector<vector<ll>> dp(N + 1, vector<ll> (N + 1, 0));
		dp[1][1] = 1;
		for (int i = 2; i <= N; i++) {
			vector<ll> pref(i, 0);
			pref[0] = dp[i - 1][0];
			for (int j = 1; j < i; j++) add(pref[j], pref[j - 1] + dp[i - 1][j], mod);
			for (int j = 1; j <= i; j++) {
				int l, r;
				if (s[i - 2] == '<')
					l = 1, r = j - 1;
				else
					l = j, r = i - 1;
				ll t = pref[r];
				sub(t, pref[l - 1], mod);
				dp[i][j] = t;
			}
		}
		ll ans = 0;
		for (int i = 1; i <= N; i++)
			add(ans, dp[N][i], mod);
		out << ans;
	}
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	TaskT solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main()
{
  int N;
  double v[8];
   
  while(cin >> N, N) {
    for(int i = 0; i < N + 3; i++) cin >> v[i];
 
    int ret = N + 2;
    for(int i = 0; i <= N + 1; i++) {
      double c = 0;
      for(int j = 0; j <= N + 1; j++) {
        if(i == j) continue;
        double tmp = 1;
        for(int k = 0; k <= N + 1; k++) {
          if(i == k || j == k) continue;
          tmp *= (N + 2 - k) * 1.0 / (j - k);
        }
        c += tmp * v[j];
      }
      if(fabs(c - v[N + 2]) < 1e-3) {
        ret = i;
        break;
      }
    }
    cout << ret << endl;
  }
}

Measured memory_bytes: 1232
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long (int)1e18+1
#define MAX 200001
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;
	
int main() {
	int n;
	cin >> n;
	rep(i, 0, n)cout << "ACL";
	cout << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>
int a[26];
int main() {
    for (char c = getchar(); c != EOF; c = getchar()) {
        if (c >= 'A' && c <= 'Z') {
            c -= 'A' - 'a';
        }
        if (c >= 'a' && c <= 'z') {
            a[c - 'a']++;
        }
    }
    for (int i = 0; i < 26; i++) {
        printf("%c : %d\n", 'a' + i, a[i]);
    }
}


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

int main(){
  int a;
  cin >> a;
  if(a >= 64) cout << 64 << endl;
  else if(a >= 32) cout << 32 << endl;
  else if(a >= 16) cout << 16 << endl;
  else if(a >= 8) cout << 8 << endl;
  else if(a >= 4) cout << 4 << endl;
  else if(a >= 2) cout << 2 << endl;
  else cout << a << endl;
}

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

int main(){
  
  long int k,x,i;
  cin>>k>>x;
  
  for(i=x-k+1;i<=x;i++)
    cout<<i<<" ";
  
  for(i=x+1;i<x+k;i++)
    cout<<i<<" ";
  
  return 0;
}

Measured memory_bytes: 256
#! /usr/bin/python3
# X: Yet Another Die Game

""" サイコロの5と6をの面を交互に回し続ける """

x = int(input())

def answer(n):
    """ 答えを返す """
    a = n // 11
    b = n % 11

    if b > 6:  # 11で割った余りが6より大きい場合
        return a*2 + 2
    if b > 0:  # 11で割った余りが1~5の場合
        return a*2 + 1
    return a*2 # 11で割り切れる場合


def main():
    """ 答えを出力する """
    print(answer(x))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n,t=map(int,input().split())
a=list(map(int,input().split()))


ans=0

for i in range(n):
    if i==0:
        s=0
        l=a[i]+t
        continue

    if a[i]<=l:
        l=a[i]+t
    else:
        ans+=l-s
        s=a[i]
        l=a[i]+t


ans+=l-s
print(ans)

Measured memory_bytes: 30796
#include <iostream>
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  int ans = 0;
  for (int i = A; i <= B; i++) {
    if ((i/10000==i%10) && (i/1000%10==i%100/10)) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int MAX_N = 100;

int main()
{
    int S,W;

    cin >> S >> W;

    if (S>W)
    {
        cout << "safe" << endl;
    }else
    {
        cout << "unsafe" << endl;
    }
    
    
    return 0;
}

// cout << "Yes" << endl;
// cout << "No" << endl;
// long double pi = 3.14159265358979323;

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

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

    int n;
    long long k;
    cin >> n >> k;
    map<int, long long> mp;
    REP(i, n){
        int a, b;
        cin >> a >> b;
        mp[a] += b;
    }
    long long c = 0;
    for(auto x : mp){
        c += x.second;
        if(c >= k){
            cout << x.first << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 4224
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();   
        if(a>b){
            System.out.println("a > b");
        }else if(a<b){
            System.out.println("a < b");
        }else if(a==b){
            System.out.println("a == b");
       }

    }
}


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

using namespace std ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int prv = 0 , x = 0 , y = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		int t , x2 , y2 ;
		cin>>t>>x2>>y2 ;
		int dist = abs(x2 - x) + abs(y2 - y) ;
		if(dist <= (t - prv) && dist % 2 == (t - prv) % 2)
		{
			prv = t ;
			x = x2 , y = y2 ;
		}
		else
			return cout<<"No\n" , 0 ;
	}
	return cout<<"Yes\n" , 0 ;
}

Measured memory_bytes: 256
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').some(function(i){j=i.split(' ');if(j[1])a=j[0],b=j[1],c=j[2],d=j[3],e=j[4],f=j[5],g=a*a,h=b*b,k=c*c,l=d*d,m=e*e,n=f*f,p=((b-f)*(h-l+g-k)-(b-d)*(h-n+g-m))/(2*(b-f)*(a-c)-2*(b-d)*(a-e)),q=((a-e)*(g-k+h-l)-(a-c)*(g-m+h-n))/(2*(a-e)*(b-d)-2*(a-c)*(b-f)),console.log(p.toFixed(3),q.toFixed(3),Math.sqrt((a-p)*(a-p)+(b-q)*(b-q)).toFixed(3))})

Measured memory_bytes: 7908
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
using namespace std;

int main(){
    unsigned int L,R;

    cin >> L >> R;

    unsigned int m = 2019; 
    for (unsigned int i = L; i < R && i<=L+2019; i++)
    {
        for (unsigned int j = i+1; j <= R && i<=j+2019; j++)
        {
            unsigned int d = ((i%2019)*(j%2019))%2019;
            if(d<m) m=d;
            if(m==0) break;
        }
    }

    cout << m << endl << flush;

    return 0;
}


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

int main() {
    int a;
    int b;
    int c;
    cin >> a;
    cin >> b;
    cin >> c;
    if(a<b && b<c){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<string>
using namespace std;
int a[100001];
int gcd(int a,int b)
{
	if(b==0) return a;
	return gcd(b,a%b);
}
int main()
{
	int n,x;
	cin>>n>>x;
	for(int i=1;i<=n;i++)
	{
		int b;
		cin>>b;
		a[i]=x<b?b-x:x-b;
	}
	for(int i=2;i<=n;i++)
	{
		a[i]=gcd(a[i],a[i-1]);
	}
	cout<<a[n];
	return 0;
}

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


int main(){

int p,q,r;
cin >> p >> q >> r;
int ans ;
ans = min(p+q,min(p+r,q+r));

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, K, q;
    cin >> n >> K >> q;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    vi b = a;
    zip(b);
    int ans = INF;
    rep(i,len(b)){
        vvi vec;
        vi hoge;
        rep(j,n){
            if(a[j] < b[i]){
                if(len(hoge)){
                    vec.pb(hoge);
                    hoge.clear();
                }
            }else{
                hoge.pb(a[j]);
            }
        }
        if(len(hoge)){
            vec.pb(hoge);
        }
        // if(len(vec)){
        //     cout << b[i] << "\n";
        //     rep(j,len(vec)){
        //         svec(vec[j]);
        //     }
        // }
        vi bue;
        rep(j,len(vec)){
            sort(all(vec[j]));
            rep(k,len(vec[j])-K+1){
                bue.pb(vec[j][k]);
            }
        }
        if(len(bue) < q){
            continue;
        }
        sort(all(bue));
        cmn(ans, bue[q-1]-b[i]);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;

int main(){
    int mod=1000000007;
    int n,s,ans;
    int dp[11][101]={0};
    dp[0][0]=1;
    for (int i=0;i<10;++i) {
        for (int j=i;j>=0;--j) {
            for (int k=0;k+i<=100;++k) {
                dp[j+1][k+i]+=dp[j][k];
            }
        }
    }
    for (;;) {
        scanf("%d %d",&n,&s);
        if (n==0 && s==0) break;
        printf("%d\n",dp[n][s]);
    }
    return 0;
}

Measured memory_bytes: 3224
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
double x[100],y[100],r[100];
int size[100];
pair<double,int> e[100][40000];
int d[100];
double DIST[100][100];
inline double HYP(double a,double b){
	return sqrt(a*a+b*b);
}
double PI=3.14159265359;
double EPS=1e-5;
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf%lf%lf",x+i,y+i,r+i);
		for(int i=0;i<a;i++){
			size[i]=0;
			d[i]=1;
		}
		for(int i=0;i<a;i++)
			for(int j=0;j<a;j++)
				DIST[i][j]=HYP(x[i]-x[j],y[i]-y[j]);
		for(int i=0;i<a;i++){
			for(int j=0;j<a;j++){
				if(i==j)continue;
				if(DIST[i][j]<(double)r[j]-r[i]+EPS)d[i]=0;
				else if(DIST[i][j]<(double)r[i]-r[j]+EPS);
				else if(DIST[i][j]+EPS<(double)r[i]+r[j]){
					double c=atan2(y[j]-y[i],x[j]-x[i]);
					double p=acos(0.5*(DIST[i][j]*DIST[i][j]+r[i]*r[i]-r[j]*r[j])/DIST[i][j]/r[i]);
					double t1=c-p;
					double t2=c+p;
					if(t2<0){
						t1+=PI*2;
						t2+=PI*2;
					}
					if(t2>PI*2){
						t1-=PI*2;
						t2-=PI*2;
					}
					if(t1<0){
						e[i][size[i]++]=make_pair(t1+PI*2,1);
						e[i][size[i]++]=make_pair(PI*2,2);
						t1=0;
					}
					e[i][size[i]++]=(make_pair(t1,1));
					e[i][size[i]++]=(make_pair(t2,2));
				}
			}
		}
		for(int i=0;i<a;i++)std::sort(e[i],e[i]+size[i]);
		double ret=0;
		for(int i=0;i<a;i++){
			if(d[i]){
				int now=0;
				double at=0;
				for(int j=0;j<size[i];j++){
					if(!now)ret+=(e[i][j].first-at)*r[i];
					if(e[i][j].second==1)now++;
					else now--;
					at=e[i][j].first;
				}
				ret+=(PI*2-at)*r[i];
			}
		}
		printf("%.9f\n",ret);
	}
}

Measured memory_bytes: 63752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PB push_back
#define REP(i, x, n) for(int i=x; i<n; i++)

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

        ll n, a = 1, t;
        cin >> n;
        REP(i, 0, n) {
                cin >> t;
                if (t == 0) {
                        cout << 0 << endl;
                        return 0;
                }
                if ((ll)1e18 / a < t) {
                        a = -1;
                }
                if (a != -1) a *= t;
        }
        cout << a << endl;

        return 0;
}

Measured memory_bytes: 3544
#include<stdio.h>

int main()
{
    int w,h,x,y,r;
    scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);

    if(x==w || y==h)
        printf("No\n");
    else if(x<=0 || y<=0)
        printf("No\n");
       else if(x>w-r || y>h-r)
        printf("No\n");

    else
        printf("Yes\n");





}



Measured memory_bytes: 2136
#include<bits/stdc++.h>
#define pb push_back
//#define int long long
#define mod 1000000007
#define fi first
#define se second
#define ll long long
#define scan() ll n; cin>>n ; ll a[n]; for(ll i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
using namespace std;
typedef vector<int>vi ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<ll,ll> pll ;
int main()
{
	fast;
	ll n,k;
	cin>>n>>k;
	if(n==k)
		cout<<"0";
	else
	{
		if(n>k)
		{
			ll y=n/k-1;
			n-=y*k;
			ll x;
	for(ll i=0;i<2*k;i++)
	{
		x=abs(n-k);
		if(x<n)
			n=x;
		else
		{
			cout<<n;
			break;
		}

	}
		}
		else
		{
					ll x;
	for(ll i=0;i<2*k;i++)
	{
		x=abs(n-k);
		if(x<n)
			n=x;
		else
		{
			cout<<n;
			break;
		}

	}
		}
	}
	return 0;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		BigInteger[] A = new BigInteger[N];
		BigInteger ans = new BigInteger("1");
		for (int i = 0; i < N;i++) {
			A[i] = new BigInteger(reader.next());
			BigInteger gcd = A[i].gcd(ans);
			BigInteger mul = A[i].multiply(ans);
			ans = mul.divide(gcd);
		}

		System.out.println(ans);
		reader.close();

	}
}

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

using namespace std;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(17);
	string odd, even;
	cin >> odd >> even;
	int n = odd.size(), m = even.size();
	int i = 0, j = 0;
	string pass = "";
	while(i < min(n, m)){
		pass += odd[i];
		pass += even[i++];
	}
	if(i < n) pass += odd[i];
	if(i < m) pass += even[i];
	cout << pass << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	ll arr[n];
	for(auto& i:arr)
	cin>>i;
	sort(arr,arr+n,greater<ll>());
	ll ans=0;
	int id=0;
	for(int i=0;i<n-1;i++)
	{
		ans+=(ll)arr[id];
		if(i%2==0)
		id++;
	}
	cout<<ans<<endl;
}
	


Measured memory_bytes: 5192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  string s;
  cin>>n;
  while(n){
    ll r=n%26;
    if(!r){
      s+='z';
      n=(n/26)-1;
    }else{
      s+='a'+r-1;
      n/=26;
    }
  }
  reverse(s.begin(),s.end());
  cout<<s;
  return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        int n;
        cin>>n;
        int a[n+1];
        for(int i = 1; i<=n;i++){
            cin>>a[i];
        }
        int cnt = 0;
        int mx = a[1];
        for(int i = 2; i<=n;i++){
            if(mx>a[i]){
                mx = a[i];
                    cnt++;
            }
        }
        cout<<++cnt<<endl;




return 0;
}







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

const int maxi=2e5+5;
ll fac[maxi],inv[maxi],finv[maxi];
void cominit(){
  fac[0]=fac[1]=finv[0]=inv[1]=finv[1]=1;
  for(int i=2;i<maxi;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
ll com(int n,int k){
  if(n<k||n<0||k<0)return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cominit();
  ll n,m,k;cin>>n>>m>>k;
  ll ans=0,tmp=m;
  for(int x=n-1;x>=0;x--){
      ll now=tmp*com(n-1,x)%mod;
      if(x<=k)ans+=now;
      ans%=mod;
      tmp=tmp*(m-1)%mod;
  }
  cout<<ans<<endl;
  return 0;
  }


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

struct Node { int p, l, r;};
struct Node T[MAX];
int n;

//先行順巡回
void preParse(int u) {
    if (u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

//中間巡回
void inParse(int u) {
    if (u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

//後行順巡回
void postParse(int u) {
    if (u == NIL) return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main() {
    int i, v, l, r, root;

    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        T[i].p = NIL;
    }

    for (i = 0; i < n; ++i) {
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (i = 0; i < n; ++i) if (T[i].p == NIL) root = i;

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}


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

int main(){
    int a,b;
    cin>>a>>b;
    if(abs(a-b)>=2)cout <<(a<b?b*2-1:a*2-1);
    else cout<<a+b<<endl;

    return 0;
}

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

int main()
{
	string s[3] = { "Sunny", "Cloudy", "Rainy" };
	string ins;
	cin >> ins;
	int j;
	for (int i = 0; i < 3; i++)
	{
		if (s[i] == ins)
		{
			j = (i + 1) % 3;
			break;
		}
	}

	cout << s[j];
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  string s;
  cin >> n >> s;

  if(n % 2 == 1) {
    cout << "No" << endl;
  } else {
    if(s.substr(0,s.size()/2) == s.substr(s.size()/2)) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
using pint = pair<ll, ll>;

int main(){
    ll N;
    bool check = true;
    cin >> N;
    ll cnt_4 = 0, cnt_2 = 0, other = 0;
    for (int i = 0; i < N; i++) {
      ll tmp = 0;
      cin >> tmp;
      if (tmp % 4 == 0) cnt_4++;
      else if(tmp%2==0){
        cnt_2++;
      }
      else{
        other++;
      }
    }
    if (cnt_2 == 0) {
      if (cnt_4 >= other - 1) check = false;
    } else {
      if (cnt_2 % 2 == 0) {
        if (cnt_4 >= other - 1) check = false;
      } else {
        if (cnt_4 >= other) check = false;
      }
    }
    if (check) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int min(int a,int b){
    return (a<b) ? a : b ;
}

int main() {

int n,T ;
cin >> n >> T ;
int t[n] ;
for(int i=0;i<n;++i) cin >> t[i] ;

int s = T ;

if(n>1){
for(int i=1;i<n;++i)
{
    s+= min(t[i]-t[i-1],T) ;
} 
}

cout << s << endl ;

return 0 ;
}  

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;

int main(){
    long long N, K;
    cin >> N >> K;
    vector<double> p(N);
    int l;
    for(int i=0; i<N; i++){
        cin >> l;
        p[i] = ((1+l)/2.0) * 10;
    }
    double sum = 0;
    double max = 0;
    for(int i=0; i<K; i++){
        sum += p[i];
    }
    max = sum;
    //cout << sum << endl;
    //cout << "---" << endl;
    for(int i=K; i<N; i++){
        sum -= p[i-K];
        sum += p[i];
        //cout << sum <<endl;
        if(max < sum){
            max = sum;
        }
    }
    double ld = 1.0 * max / 10.0;
    cout << fixed << setprecision(10) << ld << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){

  int n = 0;
  scanf("%d\n", &n);
  int a[n];
  int i = 0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int buf = 0;
  int count = 0;
  int ans = 0;
  for(i=0;i<n;i++){
    if(buf == a[i]){
      count++;
    }else{
      buf = a[i];
      ans = ans + count/2;
      count = 1;
    }
  }
  ans = ans + count/2;
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
def min(a,b) a<b ? a:b end
N=gets.to_i
W=gets.split.map(&:to_i)

sum = W.inject(:+)
ans = sum
N.times do |i|
    sum -= 2 * W[i]
    if ans > sum.abs
        ans = sum.abs
    end
end

p ans


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

using namespace std;

int main(void) {
	long long N, M;
	cin >> N >> M;
	vector<long long> A;
	for(int i = 0; i < N; ++i) {
		long long a;
		cin >> a;
		A.push_back(a);
	}
	sort(A.begin(), A.end());
	vector<pair<long long, long long> > CB;
	for(int j = 0; j < M; ++j) {
		long long b, c;
		cin >> b >> c;
		CB.push_back(make_pair(c, b));
	}
	sort(CB.begin(), CB.end(), greater<pair<long long, long long> >());
	int j = 0, cnt = 0;
	for(int i = 0; i < N; ++i) {
		if(cnt == CB[j].second) {
			cnt = 0;
			++j;
		}
		if(A[i] > CB[j].first) break;
		A[i] = CB[j].first;
		++cnt;
	}
	long long ans = 0;
	for(int i = 0; i < N; ++i) {
		ans += A[i];
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3188