akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
double solve(double a[], int s, int e, int c, double dp[][3000]){
  if(s > e){
    if(c == 0)
      return 1.0;
    else
      return 0.0;
  }
  if(dp[s][c] > -9.0)
    return dp[s][c];
  double p = (1.0 - a[s]) * solve(a, s + 1, e, c, dp);
  if(c != 0)
  p += a[s] * solve(a, s + 1, e, c-1, dp);
    dp[s][c] = p;
   return dp[s][c];
}
    
int main(){
  ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
  int n;
  cin >> n;
    double a[n];
    for(int i = 0; i < n; i++)
    cin >> a[i];
    double dp[n][3000];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3000; j++)
      dp[i][j] = -10.0;
  }
  double ans = 0;
  for(int j = n /2 + 1; j <= n; j++)
    ans += solve(a, 0, n-1, j, dp);
   cout<< fixed << setprecision(12) << ans ;
  return 0;
}

Measured memory_bytes: 70912
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; }

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int main(){
    int z,o;
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == '0') z++;
        else o++;
    }
    cout << 2 * min(z,o) << endl;
}



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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int convert(string s, char c) {
    bool ok = true;
    forn(i,si(s)-1) ok &= s[i] == s[i+1];
    if (ok) return 0;

    string ns;
    forn(i,si(s)-1) if (s[i] == c || s[i+1] == c) ns += c; else ns += s[i];
    return 1 + convert(ns,c);
}

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

    string s; cin >> s;
    
    int ans = si(s)+2;
    for (char c = 'a'; c <= 'z'; c++) ans = min(ans, convert(s,c));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
//#include <algorithm>
#define ll long long 
#define mod 1000000007
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define umap unordered_map
#define uset unordered_set
#define lb lower_bound
#define ub upper_bound
#define endll "\n";
#define all(x) (x).begin(), (x).end()
#define forr(it,x) for(auto it=x.begin();it!=x.end();it++)
#define for1(i,a,b) for(int i=a;i<b;i++)
#define for2(i,a,b) for(int i=a;i>=b;i--)
#define for3(i,a,b) for(long long int i=a;i<b;i++)
#define for4(i,a,b) for(long long int i=a;i>=b;i--)
#define pp pair<int,int>
#define ld long double
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpp vector<pp>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvpp vector<vpp>
#define I insert
#define mem(a,x) memset(a,x,sizeof(a))
#define p_queue(a) priority_queue<a,vector<a>,greater<a>>
using namespace std;
//const int dx[8]={1,0,-1,0,1,1,-1,-1},dy[8]={0,1,0,-1,-1,1,-1,1};
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1}; 
const int N=2e5+5;
/*vector<bool> p(N+1, true);
void sieve()
{
    p[0] = p[1] = false;
    int i,j;
    for (i = 2; i*i <= N; i++) 
    {
        if (p[i]) 
        {
            for (j = i * i; j <=N; j += i)
            {
                p[j] =false;
            }
        }
    }
}*/
/*int power(int a, int b){
    int res = 1;
    while(b > 0){
        if(b % 2){
            res = 1LL * res * a % mod;
        }
        a = 1LL * a * a % mod;
        b /= 2;
    }
    return res;
}*/
/*int gcd(int a,int b){
    if(a<b) swap(a,b);
    a%=b;
    if(a==0) return b;
    return gcd(b,a);
}*/
/*int lcm(int a,int b){
   return (a*1LL*b)/gcd(a,b);
}*/
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int x,y;cin>>x>>y;
    if(y>=2*x&&y<=4*x&&!(y&1)){
        cout<<"Yes"<<endll;
    }
    else{
        cout<<"No"<<endll;
    }
    return 0;
}

/*

*/




Measured memory_bytes: 3636
import java.util.*;
import java.lang.*;
import java.io.*;

class Main{
	public static void main (String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while((line = br.readLine()) != null){
			String[] strs = line.split(" ", 2);
			int num1 = Integer.parseInt(strs[0]);
			int num2 = Integer.parseInt(strs[1]);
			int num = num1 + num2;
			String str = String.valueOf(num);
			System.out.println(str.length());
		}
	}
}

Measured memory_bytes: 24084
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  cout<<a*b<<endl;


}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

bool dfs(const graph &to, vector<int> &color, const int current) {
  for (auto next : to.at(current)) {
    if (color.at(next) && color.at(next) == color.at(current)) return false;
    if (color.at(next)) continue;
    color.at(next) = -color.at(current);
    if (dfs(to, color, next) == false) return false;
  }
  return true;
}

int main() {
  int n, m;
  cin >> n >> m;
  graph to(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    to.at(a - 1).push_back(b - 1);
    to.at(b - 1).push_back(a - 1);
  }
  vector<int> color(n); // 0:unknown 1:black -1:white
  color.at(0) = 1;
  if (dfs(to, color, 0)) {
    int blacks = 0, whites = 0;
    for (int c : color) {
      if (c == 1) {
        blacks++;
      } else {
        whites++;
      }
    }
    cout << (long) blacks * whites - m << endl;
  } else {
    cout << (long) n * (n - 1) / 2 - m << endl;
  }
}


Measured memory_bytes: 6656
fun main(args: Array<String>) {
    val (W, a, b) = readLine()!!.split(" ").map(String::toInt)

    val right = Math.max(a, b)
    val left = Math.min(a, b)

    val calc = right - (left + W)
    if (calc < 0) {
        println(0)
    } else {
        println(calc)
    }
}




Measured memory_bytes: 37780
s = input()

num = len(s)
case1 = ''
case2 = ''
item1 = '1'
item2 = '0'
for item in range(len(s)):
    case1 += item1
    case2 += item2
    if item1 == '1':
        item1 = '0'
    else:
        item1 = '1'

    if item2 == '1':
        item2 = '0'
    else:
        item2 = '1'

count1 = 0
count2 = 0
for i in range(len(s)):
    if case1[i] != s[i]:
        count1 += 1
    if case2[i] != s[i]:
        count2 += 1
ret = min(count1, count2)
print(ret)


Measured memory_bytes: 3444
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, m, v, p;
ll a[100005];

bool f(ll q)
{
    ll cnt = 0;
    if(a[q] + m < a[n - p]) return false;
    for(ll i = q + 1; i <= n - p; i++)
    {
        cnt += a[q] + m - a[i];
    }
    return cnt >= m * (v - p - q);
}

int main()
{
    scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a, a + n);
    ll lt = 0, rt = n - 1, mid = 0, ans = n;
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid)) ans = mid, rt = mid - 1;
        else lt = mid + 1;
    }
    printf("%lld", n - ans);
    return 0;
}


Measured memory_bytes: 1152
#include<iostream>
#include<list>
#include<queue>

using namespace std;

unsigned int c[200001];
bool flag[200001];
unsigned int N, Q;
list<int> e[200001];

int main () {
  cin >> N >> Q;
  for (int i=0; i<N-1; i++) {
    int a,b;
    cin >> a >> b;
    e[a].push_back(b);
    e[b].push_back(a);
  }

  for (int i=0; i<Q; i++) {
    int p, x;
    cin >> p >> x;
    c[p] += x;
  }

  queue<int> q;
  q.push(1);
  flag[1] = true;

  while(!q.empty()) {
    int p = q.front();
    q.pop();

    for (auto itr=e[p].begin(); itr!=e[p].end(); itr++) {
      if (!flag[*itr]) {
        c[*itr] += c[p];
        flag[*itr] = true;
        q.push(*itr);
      }
    }
  }

  for (int i=1; i<=N; i++) {
    cout << c[i] << " ";
  }
  cout << endl;
}

Measured memory_bytes: 19584
using System;

class D {
    class Graph {
        public int[,] A;

        public Graph(int n) {
            A = new int[n, n];
            for (int i = 0; i < n; ++i)
                for (int j = 0; j < n; ++j)
                    A[i, j] = int.MaxValue >> 1;
        }

        public Graph(Graph g) { A = g.A.Clone() as int[,]; }

        public void AddEdge(int s, int t, int c) {
            A[s, t] = A[t, s] = c;
        }

        public void Floyd() {
            for (int i = 0; i < A.GetLength(0); ++i)
                for (int j = 0; j < A.GetLength(0); ++j)
                    for (int k = 0; k < A.GetLength(0); ++k) {
                        var newA = A[j, i] + A[i, k];
                        if (newA < A[j, k]) A[j, k] = newA;
                    }
        }
    }

    public static void Main() {
        var line = Console.ReadLine().Split();
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        var graph = new Graph(n);
        for (int i = 0; i < m; ++i) {
            line = Console.ReadLine().Split();
            var a = int.Parse(line[0]) - 1;
            var b = int.Parse(line[1]) - 1;
            var c = int.Parse(line[2]);
            graph.AddEdge(a, b, c);
        }
        var graph1 = new Graph(graph);
        graph.Floyd();
        var answer = 0L;
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                if (graph1.A[i, j] != int.MaxValue >> 1)
                    if (graph.A[i, j] < graph1.A[i, j]) ++answer;
        Console.WriteLine(answer >> 1);
    }
}


Measured memory_bytes: 11220
import java.util.Scanner;
								
public class Main{
			public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			while(n--!=0){
				int[] ball = new int[11];
				for(int i=0;i<10;i++) {
					ball[i] = sc.nextInt();
				}
				
				boolean can = true;
				
				for(int i=0;i<(1<<10);i++) {
					can = true;
					int s1 = 0;
					int s2 = 0;
					for(int j=0;j<10;j++) {
						if((i>>j)%2==0) {
							if(s1<ball[j]) {
								s1 = ball[j];
							}
							else{
								can = false;
							}
							
						}
						else {
							if(s2<ball[j]) {
								s2=ball[j];
							}
							else {
								can = false;
							}
							
						}
					}
					if(can)break;
				}
				
				String ans = "YES";
				if(!can)ans = "NO";
				System.out.println(ans);
			}
	}
}



Measured memory_bytes: 26040
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 2000 + 5;

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

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int DP[N][N];
ordered_set S[N];
int W[N], B[N];

int main() {

	boost;

	int n; cin>>n;
	for(int i=1; i<=2*n; i++) {
		char ch; int a; cin>>ch>>a;
		if(ch == 'B') {
			B[a] = i;
		}
		else {
			W[a] = i;
		}
	}

	for(int i=n; i>=0; i--) {

		for(int j=i+1; j<=n; j++) {
			S[i].insert(B[j]);
		}

		for(int j=n; j>=0; j--) {

			if(j < n) S[i].insert(W[j+1]);

            if(i == n and j == n) continue;
            else if(i == n) DP[i][j] = S[i].order_of_key(W[j+1]) + DP[i][j+1];
            else if(j == n) DP[i][j] = S[i].order_of_key(B[i+1]) + DP[i+1][j];
            else DP[i][j] = min(S[i].order_of_key(B[i+1]) + DP[i+1][j], 
                                S[i].order_of_key(W[j+1]) + DP[i][j+1]);
		}
	}

	cout<<DP[0][0]<<"\n";
	return 0;
}

Measured memory_bytes: 299520
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	int N;
    vector<int> v;
    priority_queue<int> q;
	cin >> N;
    for (int i = 0; i < N; ++i){
        int t;
        cin >> t;
        v.push_back(t);
    }
    sort(v.begin(), v.end(), greater<int>());

    ll sum = 0;
    q.push(v[0]);
    for (int i = 1; i < N; ++i){
        sum += q.top();
        q.pop();
        q.push(v[i]);
        q.push(v[i]);
    }

    cout << sum << endl;
	return 0;
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int H, W, K;
bool field[6][6];

int main(){
  cin >> H >> W >> K;
  rep(h, H) rep(w, W){
    char c; cin >> c;
    if(c == '#') field[h][w] = true;
  }

  int ans = 0;
  rep(tmp, 1<<12){
    bitset<12> s(tmp);
    int cnt = 0;
    rep(h, H){
      if(s.test(h)) continue;
      rep(w, W){
        if(s.test(6+w)) continue;
        if(field[h][w]) cnt++;
      }
    }
    if(cnt == K) ans++;
  }

  rep(i, 12-(H+W)) ans /= 2;
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
N = gets.to_i
a = gets.split.map(&:to_i)

#   (x - a1)^2 + ... + (x - aN)^2
# = N * x^2 - 2 * (a1 + ... + aN) * x + a1^2 + ... aN^2
# 
# x = (a1 + ... + aN) / N のときコスト最小

minx = (a.inject(:+) / N.to_f).round
cost = a.map { |i| (minx - i) ** 2 }.inject(:+)
p cost


Measured memory_bytes: 3836
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( stdin . lock ( ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        a: u64, b: u64, c: u64
    }
    let set = vec![a,b,c] .into_iter().collect::<std::collections::HashSet<_>>();
    println!("{}", set.len());
}

Measured memory_bytes: 4352
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

S = raw_input()
T = raw_input()

sz = len(S)
S += S

for i in range(sz):
    if S[i : i + sz] == T:
        print "Yes"
        exit()

print "No"

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
long f[10000000],a[10000000],n;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for (long i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    f[1]=0;
    f[2]=abs(a[2]-a[1]);
    for (long i=3;i<=n;i++)
    {
        f[i]=min(f[i-1]+abs(a[i-1]-a[i]),f[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<f[n];
}


Measured memory_bytes: 3072
#-*- coding:utf-8 -*-
import sys
rolls1 = raw_input().split()
rolls2 = raw_input().split()
testpare = (rolls1[0],rolls1[5])
testparerev = (rolls1[5],rolls1[0])
rolls2pare = [(rolls2[0],rolls2[5]),(rolls2[2],rolls2[3]),(rolls2[1],rolls2[4])]
#??????????????¢????????¢??§?????´??????????????????????????????????¢????
#??¨??¨????????¢?????£????????????????????´???????????¢???3????????¨??????????¢????????????????????????????
if testpare in rolls2pare:
    pareps = rolls2pare.index(testpare)
    revflag = False
elif testparerev in rolls2pare:
    pareps = rolls2pare.index(testparerev)
    revflag = True
else:
    print "No"
    sys.exit(0)
#?¬???????????????¢??\????????¨????????????????????£??????????¢????
#??????????????????????????????
li1 = [rolls1[1],rolls1[2],rolls1[4],rolls1[3]]
# print pareps
if pareps==0:
    if revflag:
        tmp = rolls2[2]
        rolls2[2] = rolls2[3]
        rolls2[3] = tmp
    li2 = [rolls2[1],rolls2[2],rolls2[4],rolls2[3]]
elif pareps==1:
    if revflag:
        tmp = rolls2[1]
        rolls2[1] = rolls2[4]
        rolls2[4] = tmp
    li2 = [rolls2[0],rolls2[1],rolls2[5],rolls2[4]]
elif pareps==2:
    if revflag:
        tmp = rolls2[0]
        rolls2[0] = rolls2[5]
        rolls2[5] = tmp
    li2 = [rolls2[0],rolls2[3],rolls2[5],rolls2[2]]
else:
    print "No"
    sys.exit(0)
#?????????????????´?¢????
# print li1
# print li2
i=0
j=li2.index(li1[0])
matchflag = True#else??\??£???????????´?????????
for x in xrange(4):
    # print "%s : %s"%(li1[i],li2[j])
    if li1[i]==li2[j]:
        j+=1
        i+=1
    else:
        matchflag =False
        break
    if i>3:
        i=0
    if j>3:
        j=0
if matchflag:
    print "Yes"
else:
    print "No"

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	priority_queue<ll> div;
	for (ll ii = 1; ii*ii <= M; ++ii){
		if (M % ii == 0){
			div.push(ii);
			if (M / ii != ii){
				div.push(M / ii);	//重複しないなら相方も追加
			}
		}
	}

	ll ans = 1;
	while(!div.empty()) {
		ll val = div.top();
		div.pop();
		if (M / val >= N){
			ans = val;
			break;
		}		
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import math
A, B = [int(s) for s in input().split()]
max_price = 100000
found = False
for i in range(max_price):
  ii = i+1
  priceA = math.floor(ii*0.08)
  priceB = math.floor(ii*0.1)
  if priceA == A and priceB == B:
    print(ii)
    found = True
    break
if found == False:
  print(-1)

Measured memory_bytes: 3188
n = int(input())

taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()
    
    if t < h :
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1
        
print(taro, hanako)

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

int main(){
 int n;
 cin >>n;
 int i=1;
 while(1){
 int x=i;
 if(x%3==0){
 cout<<" "<<i;
}
 else{
 while(1){
 if(x%10==3){
cout<<" "<<i;
 break;
}
 x/=10;
if(x==0)break;
}

}
if(++i>n)break;
}
cout<<endl;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int a,b;
    cin>>a>>b;
    if(b==1){
        cout<<0<<endl;
        return 0;
    }
    int ans=a;
    int kai=1;
    if(b<=ans){
        cout<<1<<endl;
        return 0;
    }
    while(1){
        ans+=a-1;
        kai++;
        if(b<=ans){
            cout<<kai<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    for mask in range(60):
        cnt1 = sum([1 if a & (1 << mask) else 0 for a in A])
        cnt0 = n - cnt1
        res += (pow(2, mask, mod) * cnt1 * cnt0) % mod
        res %= mod
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 50948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const ll MAX_N = ll(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, a[MAX_N], ans = 0, ans2 = 0;
    cin >> n;
    REP(i, n) cin >> a[i];
    sort(a, a + n);
    ans += abs(a[n - 1] - a[0]);

    int pr = 0;
    for (int i = 0; i < n / 2; i++) {
        int j = i/2 + 1;
        int nx = (i%2 == 0 ? n - j*2 : j*2);
        if (nx == pr) break;
        if (nx == n/2 && n%2 == 1) break;
        ans += abs(a[nx] - a[pr]);
        pr = nx;
    }
    pr = n - 1;
    for (int i = 0; i < n / 2; i++) {
        int j = i / 2 + 1;
        int nx = (i % 2 == 1 ? n - j * 2 : j * 2) - 1;
        if (nx == n / 2 && n % 2 == 1) break;
        if (nx == pr) break;
        ans += abs(a[nx] - a[pr]);
        pr = nx;
    }
    if (n % 2 == 1)
        ans += max(abs(a[n / 2 + 1] - a[n / 2]), abs(a[n / 2 - 1] - a[n / 2]));



    cout << max(ans,0ll) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int i;
    int n;
    ll R[200000];
    ll maxv = -1000000000;
    ll minv;
    
    
    cin >> n;
    for(i=0;i<n;i++){
        cin >> R[i];
        if(i==0)
          minv = R[0];
        else
          maxv = max(maxv,R[i]-minv);
          minv = min(minv,R[i]);
    }
    
    cout << maxv << endl;
    
    
    
}


Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  string a,b="CODEFESTIVAL2016";
  cin>>a;
  int c=0;
  fo(i,16){
    if(a[i]!=b[i])
      c++;
  }
  cout<<c<<endl;
}

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

typedef long long ll;
typedef long double ld;

int dp[6005][6005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
            }
            dp[i][j] = max(dp[i][j], dp[i][j-1]);
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
        }
    }
    string res = "";
    int i = n, j = m;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            i--;
            j--;
            res += s[i];
        }
        else if(dp[i-1][j] == dp[i][j]) i--;
        else j--;
    }
    reverse(res.begin(), res.end());
    cout << res;
    return 0;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
#include <fstream>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=3e5+5;
ll mod=998244353 ;
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}

int main()
{
    FIO
    string s;
    cin>>s;
    int co1=0,co2=0;
    for(int i=0;i<s.size();i++)
    {
        if(i%2==0)
        {
            if(s[i]=='1')
                co2++;
            else
                co1++;
        }
        else
        {
            if(s[i]=='1')
                co1++;
            else
                co2++;

        }

    }
    cout<<min(co1,co2);


    return 0;
}


Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    int l, r;
    cin >> n >> m;
    int r_min=n, l_max=0;
    for (int i = 0; i < m; ++i) {
        cin >> l >> r;
        r_min = r_min>r ? r : r_min;
        l_max = l_max<l ? l : l_max;
    }
    if(l_max>r_min){
        cout << 0 << endl;
    }else{
        cout << r_min-l_max+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var sum = ary.Sum();

        for(int i=0; i<n; i++) {
            var x = sum - ary[i];
            if(ary[i] >= x) return No;
        }

        return Yes;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define parr[1] push_back
#define pii pair<int,int>
#define pob pop_back
#define all(a) a.begin(),a.end()
#define fio ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define i64 long long int
#define mem(x,y) memset(x,y,sizeof(x))
#define fill(arr,b) fill(arr, arr+sizeof(arr)/sizeof(arr[0]), b)

const double pi = acos(-1.0);
const int maxn = (i64)2e5+5;

int main()
{
    //freopen("input.txt","r",stdin);
    int n,r;
    cin >> n >> r;
    if(n>10) cout<<r;
    else cout<<r+(100*(10-n));



return 0;
}



Measured memory_bytes: 256
//AOJ 0557
#include <iostream>
#include <vector>
#include <cstring>
#include <cstddef>
using namespace std;

intmax_t n;
vector<intmax_t> nums;
intmax_t dp[101][21];

intmax_t getExpr(intmax_t pos, intmax_t val) {
	if (pos == n-1) return val == nums.back();
	intmax_t& res = dp[pos][val];
	if (res != -1) return res;
	res = 0;
	if (val+nums[pos] <= 20) res += getExpr(pos+1, val+nums[pos]);
	if (val-nums[pos] >= 0) res += getExpr(pos+1, val-nums[pos]);
	return res;
}

int main() {
	cin>>n;
	nums.resize(n);
	for (auto& i : nums) cin>>i;
	memset(dp,-1,sizeof dp);
	cout << getExpr(1,nums.front()) << endl;
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <chrono>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#include <atcoder/all>
using namespace atcoder;
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return -1;
}

int h;

bool f(ll a) {
    return h > a;
}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> z(n);
    vector<ll> x(m);
    for (int i = 0; i < n; i++) {
        cin >> z[i];
    }
    for (int j = 0; j < m; j++) {
        cin >> x[j];
    }
    vector<ll> d = convolution<998244353>(z, x);
    for (int i = 0; i < n + m - 1; i++) {
        cout << d[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 27252
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define MOD 1000000007;//1e9+7

long long sub_solve(map<char, long long>getScore, string T) {
    int score = getScore[T[0]];
    for (int i = 1; i < T.size(); i++) {
        if (T[i] != T[i - 1])score += getScore[T[i]];
        else T[i] = 'q';
    }
    return score;
}

void solve() {
    long long N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;

    map<char, long long>getScore = { { 'r',P },{ 's',R },{ 'p',S } };

    vector<string>subT(K);
    for (int i = 0; i < K; i++){
        for (int j = 0; i+j < N; j += K)subT[i] += T[i + j];
    }

    long long ans = 0;
    for (int i = 0; i < K; i++)ans += sub_solve(getScore, subT[i]);

    cout << ans;
    return;
}

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

Measured memory_bytes: 5120
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005


ll fact[SIZE],inverse_fact[SIZE];


ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll &e){
	e = 0;
	if(n == 0)return 1;

	int res = mod_fact(n/p,p,e);
	e += n/p;

	if(n/p%2 != 0)return res*(p-fact[n%p])%p;
	return res*fact[n%p]%p;
}

ll nCm(ll n,ll m,ll p){
   if(n < m) return 0;
   ll e1,e2,e3;
    ll a1 = mod_fact(n,p,e1),a2 = mod_fact(m,p,e2),a3 = mod_fact(n-m,p,e3);
    if(e1 > e2+e3)return 0;
    return a1 * mod_inverse(a2*a3%p,p)%p;
}

int main(){

	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}

	inverse_fact[SIZE-1] = mod_inverse(fact[SIZE-1],MOD);
	for(ll i = SIZE-1; i >= 1; i--){

		inverse_fact[i-1] = inverse_fact[i]*i;
		inverse_fact[i-1]%= MOD;
	}

	ll N;
	scanf("%lld",&N);

	ll EX = 0,EX2 = 0;

	for(int k = 1; k <= N; k++){

		EX += (nCm(N-1,k-1,MOD)*inverse_fact[k])%MOD;
		EX %= MOD;
	}

	for(int k = 1; k <= N; k++){

		EX2 += (nCm(N+k-1,2*k-1,MOD)*inverse_fact[k])%MOD;
		EX2 %= MOD;
	}

	ll ans = EX2-EX*EX;
	while(ans < 0){

		ans += MOD;
	}
	ans %= MOD;

	printf("%lld\n",ans);

	return 0;
}



Measured memory_bytes: 6340
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define mod (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
int gcd(int A,int B) {if(!B)return A;return gcd(B,A%B);}
int a[200005];
int main()
{
	ll sum = 0;
	int n;
	cin>>n;
	map<int,ll>cnt;
	for(int i=0;i<n;i++){
		cin>>a[i];
		cnt[a[i]]++;
	}
	for(auto x:cnt)sum+=(x.se-1)*(x.se)/2;  //n choose 2
	for(int i=0;i<n;i++)
	{
		ll ans = sum - (cnt[a[i]]-1); //from n-1*n ro (n-2)*n-1
		cout<<ans<<endl;
		
	}
		
}

Measured memory_bytes: 10240
#include<iostream>
using namespace std;
int main()
{
    long long n,i,ans=0;
    cin>>n;
    for(i=1;i<n+1;i++)
    {
        if(i%3&&i%5)
            ans=ans+i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3648
# coding: utf-8

N = int(input())
A = input().split()

count = 0
count_a = 0
flag = 0

while flag == 0:

    for i in A:
        if int(i) % 2 == 0:
            count += 1

    if count == N:
        count_a += 1
        count = 0
        for i in range(N):
            A[i] = int(A[i]) // 2
    else:
        flag = 1

print(count_a)


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

int main(){
  int a, b;
  cin>> a>> b;
  int ans =b*2;
  if(a<=b)cout<< 0<< endl;
  else if(ans>=a)cout<< 0<< endl;
  else cout<< a-ans<< endl;
}

Measured memory_bytes: 256
def primesbelow(N):
    # http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
    #""" Input N>=6, Returns a list of primes, 2 <= p < N """
    correction = N % 6 > 1
    N = {0:N, 1:N-1, 2:N+4, 3:N+3, 4:N+2, 5:N+1}[N%6]
    sieve = [True] * (N // 3)
    sieve[0] = False
    for i in range(int(N ** .5) // 3 + 1):
        if sieve[i]:
            k = (3 * i + 1) | 1
            sieve[k*k // 3::2*k] = [False] * ((N//6 - (k*k)//6 - 1)//k + 1)
            sieve[(k*k + 4*k - 2*k*(i%2)) // 3::2*k] = [False] * ((N // 6 - (k*k + 4*k - 2*k*(i%2))//6 - 1) // k + 1)
    return [2, 3] + [(3 * i + 1) | 1 for i in range(1, N//3 - correction) if sieve[i]]

k=primesbelow(10000000)
ones=[]
twos=[]
threes=[]
fours=[]
for i in k:
    if i%5==1:
        ones.append(i)
    if i%5==2:
        twos.append(i)
    if i%5==3:
        threes.append(i)
    if i%5==4:
        fours.append(i)

n=int(input())
print(*fours[5:5+n])

Measured memory_bytes: 199200
#include<iostream>
using namespace std;
int main(){
  string s; cin >> s;
  int n = static_cast<int>(s.size());
  int s_cnt = 0;
  int erase_cnt = 0;
  for(int i = 0; i < n; ++i){
   	if(s[i] == 'S'){
      s_cnt++;
    } else if(s_cnt > 0){
      s_cnt--;
      erase_cnt+=2;
    }
  }
  cout << n - erase_cnt << endl;
  return 0;
}

Measured memory_bytes: 640
n=int(input())
alist=list(map(int,input().split()))
import math
mini=min(alist)
if mini==0:
    ans=0
else:
    ans=1
    for i in range(n):
        ans*=alist[i]
        if ans>pow(10,18):
            ans=-1
            break


print(ans)

Measured memory_bytes: 21656
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define rrepSE(i,s,e) for (int i = (s); i > (e); i--)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
#define DEBUG_PRINT(var) std::cout << #var << " = " << var << "\n";

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    ll sa = 0, sb = 0;
    rep(i,n) { cin >> a[i]; sa += a[i]; }
    rep(i,n) { cin >> b[i]; sb += b[i]; }
    ll mx = sb - sa;
    bool ans = (mx >= 0);
    if (ans) {
        ll cnt1 = 0, cnt2 = 0;
        rep(i, n) {
            if (a[i] < b[i]) {
                cnt1 += ((b[i] - a[i] + 1) / 2);
                cnt2 += (b[i] - a[i]) % 2;
            }
            if (a[i] > b[i]) cnt2 += (a[i] - b[i]);
        }
        ans = (cnt1 <= mx) && (cnt2 <= mx);
    }
    cout << (ans? "Yes" : "No") << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <map>

int main()
{
  int n;
  scanf("%d", &n);
  std::map<int, bool> m;
  for (int i = 0; i < n; ++i)
  {
    int a;
    scanf("%d", &a);
    m[a] = !m[a];
  }
  int ans = 0;
  for (auto &p : m)
  {
    if (p.second) ++ans;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 4864
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		List<Integer> numbers = new ArrayList<>();
		
		for (int i = 0; i < n; i++) {
			numbers.add(stdIn.nextInt());
		}
		stdIn.close();
		
		getCommonDivisors(numbers).stream().forEach(System.out::println);
	}

	private static List<Integer> getCommonDivisors(List<Integer> numbers) {
		List<Integer> commonDivisors = new ArrayList<>();
		int min = numbers.stream().min(Comparator.naturalOrder()).get();

		for(int i = 1; i <= min; i++) {
			if(isAllDivided(numbers,i)) {
				commonDivisors.add(i);
			}
		}
		
		return commonDivisors;
	}

	private static boolean isAllDivided(List<Integer> numbers, int divisor) {
		return numbers.stream().allMatch(n -> n % divisor == 0);
	}
}



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

#define int long long



int gcd(int a, int b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 

signed main(){
	int n;
	cin>>n;
	int sum=0;
	for(int f=1;f<=n;f++){
		for(int g=1;g<=n;g++){
			for(int h=1;h<=n;h++){
				sum=sum+gcd(gcd(f,g),h);
			}
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 3608
from itertools import accumulate


def main():
    cells, moves = [int(x) for x in input().split()]
    jumps_from = [int(x) - 1 for x in input().split()]
    score_on = [int(x) for x in input().split()]

    ans = - 10**10
    for start in range(cells):
        route = []
        route_append = route.append
        position = start
        while True:
            route_append(score_on[position])
            position = jumps_from[position]
            if position == start:  # Looped
                break

        length = len(route)
        total = sum(route)
        accum_tmp = 0
        for i, score in enumerate(route):
            accum_tmp += score
            if i + 1 > moves:
                break
            accum = accum_tmp
            if total > 0:
                accum += total * ((moves - (i + 1)) // length)
            ans = max(ans, accum)

        # if total > 0:
        #     q, mod = divmod(moves, length)
        #     if mod == 0:
        #         candidate = total * q
        #     else:
        #         candidate = max(list(accumulate(route))[:mod]) + total * q
        # else:
        #     candidate = max(list(accumulate(route))[:min(moves, length)])
        # ans = max(ans, candidate)
    return ans


if __name__ == '__main__':
    ans = main()
    print(ans)


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

#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    char c;
    char ans;
    scanf("%c",&c);
    switch(c){
        case 'A':ans='T';break;
        case 'T':ans='A';break;
        case 'C':ans='G';break;
        case 'G':ans='C';break;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define N 500001
#define NIL NULL

void insert(int);
void Preorder(Node );
void Inorder(Node );

struct node{
    int key;
    struct node *parent;
    struct node *left;
    struct node *right;
};

typedef struct node *Node;

Node root;

int main ()
{
    int n,i,x;
    char s[10];

    scanf("%d",&n);

    for(i=0;i<n;i++){
        scanf("%s",s);
        if(strcmp(s,"insert")==0){
            scanf("%d",&x);
            insert(x);
        }
        else if(strcmp(s,"print")==0){
            Inorder(root);
            printf("\n");
            Preorder(root);
            printf("\n");
        }
    }

    return 0;
}

void insert(int k){
    Node z;
    Node y=NIL;
    Node x=root;

    z=malloc(sizeof(struct node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL){
        y=x;
        if(z->key < x->key) x=x->left;
        else x=x->right;
    }

    z->parent=y;

    if(y==NIL) root=z;
    else if(z->key < y->key) y->left=z;
    else y->right=z;
}

void Preorder(Node u){
    if(u!=NIL){
    printf(" %d",u->key);
    if(u->left != NIL) Preorder(u->left);
    if(u->right != NIL) Preorder(u->right);
    }
}

void Inorder(Node u){
    if(u!=NIL){
        Inorder(u->left);
        printf(" %d",u->key);
        Inorder(u->right);
    }
}

Measured memory_bytes: 24040
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
count = 0
for i in range(N):
    s = C
    for j in range(M):
        s += A[i][j] * B[j]
    if s > 0:
        count += 1
print(count)

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

int keta(int num){
  int ans= 0 ;
  int rem;

  for (int i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}


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

  int i,j,k,tmp;

  bool flag = false;

  for(i=0; i <= N; i++){
    for(j=0; j <= N-i; j++){
      for(k=0; k <= N-i-j; k++){
        tmp = 10000 * i + 5000 * j + 1000 * k;
        if (tmp == Y && (i + j + k) == N) {
          cout << i << " " << j << " " << k << endl;
          flag = true; 
          goto OUT;
        }
      }
    }
  }

  OUT:
  if (flag == false){
    cout << "-1 -1 -1" << endl;
  }
}


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

int main() {
	long long N, D, M, T;
	map<long long, int> mp;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> D, mp[D]++;
	cin >> M;
	for (int i = 0; i < M; i++) {
		cin >> T;
		if (mp[T] == 0) {
			cout << "NO" << endl;
			return 0;
		}
		mp[T]--;
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h> 
using namespace std; 
bool compare(string a, string b) 
{ 
    return (a+b < b+a); 
} 
  
string lexSmallest(string a[], int n) 
{ 
    sort(a, a+n, compare); 
  
    
    string answer = ""; 
    for (int i = 0; i < n; i++) 
        answer += a[i]; 
  
    return answer; 
} 
  

int main() 
{ 
    int k,l;
    cin>>k>>l;
    string a[k];
    for(int i=0;i<k;i++)
    {
        cin>>a[i];
    }
    int n = sizeof(a)/sizeof(a[0]); 
    cout << lexSmallest(a, n); 
    return 0; 
} 

Measured memory_bytes: 256