akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

int main() {
	int n;
	scanf("%d", &n);
	VLL a(n);
	REP(i, n)scanf("%lld", &a[i]);
	sort(ALL(a));
	LL x[2] = { a[0], a[0] };
	int l = 1, r = n - 1;
	LL ans = 0;
	while (l <= r) {
		VLL d(4);
		d[0] = abs(a[l] - x[0]);
		d[1] = abs(a[r] - x[0]);
		d[2] = abs(a[l] - x[1]);
		d[3] = abs(a[r] - x[1]);
		int maxidx = -1;
		LL maxd = -1;
		REP(i, 4) {
			if (maxd < d[i]) {
				maxd = d[i];
				maxidx = i;
			}
		}
		ans += maxd;
		if (maxidx == 0) x[0] = a[l++];
		else if (maxidx == 1)x[0] = a[r--];
		else if (maxidx == 2)x[1] = a[l++];
		else if (maxidx == 3)x[1] = a[r--];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
kk = list(map(int, input().split()))
A, B = kk
answer = []

for p in range(A):
  pp = list(map(int, input().split()))
  C, D = pp
  leng = C*C + D*D
  if leng > B*B:
    answer.append(0)
  else:
    answer.append(1)
    
print(sum(answer))

Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ans = false;
    int v;
    rrep(i, b) {
        v = a * i;
        if(v % b == c) {
            ans = true;
            break;
        }
    }
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
params = []
for _ in range(N):
    x, y, z = map(int, input().split())
    params.append((x, y, z))

ans = 0
for i in range(8):
    flags = [1] * 3
    for j in range(3):
        if i >> j & 1 == 1:
            flags[j] = -1
    cakes = [0] * N
    for c in range(N):
        cakes[c] = params[c][0] * flags[0] + params[c][1] * flags[1] + params[c][2] * flags[2]
    cakes.sort(reverse=True)
    ans_new = 0
    for k in range(M):
        ans_new += cakes[k]
    ans = max(ans, ans_new)

print(ans)


Measured memory_bytes: 40048
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    lint ret = inf;
    for (lint i = -100; i <= 100; ++i) {
        lint temp = 0;
        for (int j = 0; j < n; ++j) {
            temp += (a[j] - i) * (a[j] - i);
        }
        chmin(ret, temp);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
N,K,Q=map(int,input().split())
li=[]
for i in range(Q):
    A=int(input())
    li.append(A)
score=[K-Q]*N

#print(score)
for i in range(Q):
    score[li[i]-1]+=1
#print(score)
kekka=[]
for i in range(N):
    if score[i]<=0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 11436
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}

using namespace std;
string s;
int flag=0;
int main()
{
    int sum=0;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        sum+=(s[i]-'0');
    }
    if(sum%9==0)
        flag++;
    if(flag==1)
    cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}


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

int main(int argc, char const *argv[])
{
	int n, k; cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];

	int ans = 0;
	rep(i, n) {
		if (h[i] >= k)
			ans++;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

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

  int ans = 1;
  for (int i = 0; i < n; i++) {
    ans = min(ans * 2, ans + k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,m,p,q;
    cin>>n>>m;
    long long int h[n],a[n]={0};
    for(long long int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    for(long long int i=0;i<m;i++)
    {
        cin>>p>>q;
        if(h[p-1]>h[q-1])
        {
            a[q-1]=1;
        }
        else if(h[p-1]<h[q-1])
        a[p-1]=1;
        else
        {
            a[p-1]=1;
            a[q-1]=1;
        }
    }
    long long int count=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]==0)
        count++;
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 5140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int n = Math.min(b / a, c);
		System.out.println(n);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}

class Point {
	int x;
	int y;
	public Point(int x, int y) {
		this.x = x;
		this.y = y;
	}
}

Measured memory_bytes: 21204
// In the name of Allah the Lord of the Worlds.

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

typedef long long ll;

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

    ll a, p;
    cin >> a >> p;
    p+=a*3;
    cout << p/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let A = N.to_string().chars().map(|c| c.to_digit(10).unwrap() as usize).collect::<Vec<_>>();

    let ans = std::cmp::max(A.iter().map(|&a| a).sum::<usize>(), A[0] - 1 + 9 * (A.len() - 1));

    println!("{}", ans);
}


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

using namespace std;
typedef long long ll;

// double dp[110][110][2];
double dp[110][110];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int N, T, L, B;
  while (cin >> N >> T >> L >> B, N) {
    vector<bool> lose(N + 1), back(N + 1);
    int pos;
    for(int i = 0; i < L; i++) {
      cin >> pos;
      lose[pos] = true;
    }
    for (int i = 0; i < B; i++) {
      cin >> pos;
      back[pos] = true;
    }

    fill(dp[0], dp[101], 0);
    dp[0][0] = 1;
    for (int i = 0; i < T; i++) {
      for (int j = 0; j < N; j++) {
        for (int k = 1; k <= 6; k++) {
          int nj = j + k;
          if (nj > N) nj = N - (nj - N);
          if (back[nj]) nj = 0;
          dp[i + 1 + lose[nj]][nj] += dp[i][j] / 6.0;
        }
      }
    }
    double ans = 0;
    for (int i = 0; i <= T; i++) ans += dp[i][N];
    printf("%.10f\n", ans);
  }

  return 0;
}


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

using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	vector<string> c(h);

	for (int i = 0; i < h; i++)
	{
		string temp;
		cin >> temp;
		cout << temp << endl;
		cout << temp << endl;
	}
	






}

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

using namespace std;

const int N = 1e5 + 5;

int f[N];

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    f[x]++, f[y + 1]--;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    f[i] += f[i - 1];
    if (f[i] == m) ans++;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long int LL;
typedef pair<int, int> PII;
typedef vector<PII> VP;
typedef VP::iterator VPI;
typedef string::iterator STI;
const int DIV = 10000;

int n, k;
int memo[110][5][5][5];
int plan[110];

int search(int day, int status[3])
{
  if(status[0] && status[0] == status[1] && status[1] == status[2]){
    return 0;
  }
  if(day == n + 1){
    return 1;
  }
  if(memo[day][status[0]][status[1]][status[2]] != -1){
    return memo[day][status[0]][status[1]][status[2]];
  }
  
  if(plan[day + 1]){
    int tomorrow[3] = {status[1], status[2], plan[day + 1]};
    return memo[day + 1][status[1]][status[2]][plan[day + 1]] = search(day + 1, tomorrow);
  }
  else{
    int sum = 0;
    for(int i = 1; i <= 3; i++){
      int tomorrow[3] = {status[1], status[2], i};
      sum += memo[day + 1][status[1]][status[2]][i] = search(day + 1, tomorrow);
    }
    return sum % DIV;
  }
}	     
	        
int main()
{
  cin >> n >> k;
  for(int i = 0; i < k; i++){
    int a, b;
    cin >> a >> b;
    plan[a] = b;
  }
  memset(memo, -1, sizeof memo);
  plan[n + 1] = 4;

  int status[3] = {0, 0, 0};
  cout << search(0, status) % DIV << endl;
  
  return 0;
}

Measured memory_bytes: 1224
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
    string s;cin>>s;
    map<char,int>mp;
    int n = s.size();
    rep(i,n){
        mp[s[i]]++;
    }
    bool f = true;
    for(auto p:mp){
        if(p.second%2==1)f = false;
    }
    cout<<(f?"Yes":"No");
}



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

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


Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	ll a, b, k;
	cin >> a >> b >> k;
	if (a == 0) {
		if (b == 0) {
			cout << 1 << endl;
		} else {
			cout << b / k + 1 << endl;
		}
	} else {
		cout << b / k - ((a - 1) / k) << endl;
	}
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    cout << (N+1)/2 << ln;
}

Measured memory_bytes: 256
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long N = nextLong();
        for(int i=(int)Math.sqrt(N); i>=1; i--){
            if(N%i == 0){
                println(String.valueOf(N/i).length());
                break;
            }
        }
    }

    static long gcd (long a, long b) {
        long temp;
        while ((temp = a % b) != 0) {
            a = b;
            b = temp;
        }
        return b;
    }

    static long a(long n){
        return n < 2L ? 1L : n*a(n-2);
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21844
fn main() {
    ioset! { inp, buf }
    macro_rules! scan {
        ($($r:tt)*) => {
            input! { inp, $($r)* }
        }
    }
    macro_rules! print {
        ($($t:expr),*) => {
            write!(buf, $($t),*).unwrap();
        } 
    }
    scan! {
        mut x: i64,
        mut k: i64,
        d: i64,
    }
    if x > 0 {
        let t = x / d;
        let t = std::cmp::min(t, k);
        x -= t * d;
        k -= t;
    }
    else {
        let t = - x / d;
        let t = std::cmp::min(t, k);
        x += t * d;
        k -= t;
    }
    if k % 2 == 1 {
        if x > 0 {
            x -= d;
        }
        else {
            x += d;
        }
    }
    print!("{}\n", std::cmp::max(x, -x));
}

use std::io::{ stdout, BufWriter, Write };

#[macro_export]
macro_rules! ioset {
    ($inp:ident, $buf:ident) => {
        inset!($inp);
        outset!($buf);
    }
}

#[macro_export]
macro_rules! inset {
    (source = $s:expr, $iter:ident) => {
        let mut $iter = $s.split_whitespace();
    };
    ($iter:ident) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut $iter = s.split_whitespace();
    }
}

#[macro_export]
macro_rules! input {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt, $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, mut $var:ident : $t:tt, $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
    ($iter:expr, ($var:expr) : $t:tt, $($r:tt)*) => {
        $var = read_value!($iter, $t);
        input! { $iter, $($r)* }
    };
}

#[macro_export]
macro_rules! read_value {

    // tuple
    ($iter:expr, ( $($t:tt), * )) => {
        ( $(read_value!($iter, $t)), * )
    };
    
    // array
    ($iter:expr, [ $t:tt; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    
    // string
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        $iter.next().unwrap().parse::<usize>().expect("Parse error") - 1
    };
    
    // any other
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[macro_export]
macro_rules! outset {
    ($buf:ident) => {
        let sout = stdout();
        let mut $buf = BufWriter::new(sout.lock());
    }
}

#[macro_export]
macro_rules! output {
    ($buf:expr, $($t:expr),*) => {
        write!($buf, $($t),*).unwrap();
    }
}

struct Chars<'a>(&'a Vec<char>);

impl<'a> std::fmt::Display for Chars<'a> {
    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
        write!(f, "{}", self.0.iter().collect::<String>())
    }
}


Measured memory_bytes: 2184
/*
  AOJ 0560
  Title:Planetary Exploration
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
#define joi2n(x) (x=='J')?0:((x=='O')?1:2)

int m,n,k;
int a,b,c,d;
int count[1000][1000][3];
char area[1000][1001];



main()
{
  int i,j,l;
  int joicount[3],cnt[3];

  memset(count,0,sizeof(int)*1000*1000*3);
  scanf("%d %d",&m,&n);
  scanf("%d",&k);

  for(i=0;i<m;i++)
    {
      cnt[0]=cnt[1]=cnt[2]=0;
      scanf("%s",&area[i][0]);
      for(j=0;j<n;j++)
	{
	  cnt[joi2n(area[i][j])]++;
	  if(i==0)
	    {
	      for(l=0;l<3;l++)
		count[i][j][l]=cnt[l];
	    }
	  else
	    {
	       for(l=0;l<3;l++)
		 count[i][j][l]=cnt[l]+count[i-1][j][l];
	    }
	}
    }
#if DEBUG
  printf("%d %d: %d %d %d\n",i,j,
	 count[m-1][n-1][0],count[m-1][n-1][1],count[m-1][n-1][2]);
  printf("INIT END\n");
#endif
  for(j=0;j<k;j++)
    {
      scanf("%d %d %d %d",&a,&b,&c,&d);
      a--;b--;c--;d--;
      for(l=0;l<3;l++)
	{
	  joicount[l] =count[c][d][l];
	  if(a>0)
	    joicount[l]-=count[a-1][d][l];
	  if(b>0)
	  joicount[l]-=count[c][b-1][l];
	  if(a>0 && b>0)
	  joicount[l]+=count[a-1][b-1][l];
	}
      for(l=0;l<3;l++)
	{
	  printf("%d",joicount[l]);
	  if(l<2)
	    printf(" ");
	  else
	    printf("\n");
	}
    }
  return(0);
}

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

int main(){ 
  int N; cin >> N;
  int a[300100];
  for (int i = 0; i < N * 3; i++){
    cin >> a[i];
  }
  sort (a, a + N*3);
  reverse (a, a + N*3);
  long long ans;                      //答えが非常に大きくなる可能性がある
  for (int i = 0; i < N; i++){  
    //cout << a[i] << endl;
    ans += a[i*2+1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
)

func main() {
	var a, b int64
	fmt.Scanf("%d %d", &a, &b)

	if (a + b) % 2 == 0 || (a + b) == 0 {
		fmt.Printf("%d\n", (a + b) / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


Measured memory_bytes: 1832
import java.util.*;
import java.util.Map.Entry;


public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n= sc.nextInt();
			if(n==0) break;
			Map<Integer,ArrayList<Integer>> map = new TreeMap<Integer,ArrayList<Integer>>();
			int h,r;
			//ArrayList<Integer> temp = new ArrayList<Integer>();
			int[] hArray = new int[n];
			for(int i=0;i<n;i++){
				h = sc.nextInt();
				r=sc.nextInt();
				ArrayList<Integer> temp = new ArrayList<Integer>();
				temp.add(r);
				map.put(h, temp);
				hArray[i] = h;
			}
			int m= sc.nextInt();
			int[] hArray2 = new int[n+m];
			for(int i=0;i<n;i++){
				hArray2[i] = hArray[i];
			}
			for(int i=n;i<n+m;i++){
				h=sc.nextInt();
				r=sc.nextInt();
				hArray2[i] = h;
				if(map.containsKey(h)){
					ArrayList<Integer> a = map.get(h);
					a.add(r);
					map.put(h, a);
				}else{
					ArrayList<Integer> temp = new ArrayList<Integer>();
					temp.add(r);
					map.put(h,temp);
				}
			}
			int[] rArray = new int[n+m];
			Iterator<Entry<Integer, ArrayList<Integer>>> entries = map.entrySet().iterator();
			int i=0;
			while(entries.hasNext()) {
				@SuppressWarnings("rawtypes")
				Map.Entry entry = entries.next();
				//int keyName = (Integer) entry.getKey();
				@SuppressWarnings("unchecked")
				ArrayList<Integer> valName = (ArrayList<Integer>)entry.getValue();
				for(int value : valName){
					rArray[i] = value;
					i++;
				}
			}
			Arrays.sort(hArray2);
			
			int[] dp = new int[rArray.length+1];
			int max;
			for(int j=1;j<dp.length;j++){
				max = 0;
				for(int k=1;k<=j;k++){

					if(hArray2[j-1]>hArray2[k-1]&&rArray[j-1]>rArray[k-1]){
						if(dp[k]>max){
							max = dp[k];
						}
					}
				}
				dp[j] = max + 1;
			}
			max = -1;
			for(int j=0;j<dp.length;j++){
				if(max<dp[j]){
					max = dp[j];
				}
			}
			System.out.println(max);
		}
	}
}

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

int main() {
	int a1, a2, a3, a4, a5;
    cin >> a1 >> a2 >> a3 >> a4 >> a5;
    if (a1 + a2 + a3 + a4 + a5 == 14) {
    	cout << 1 << endl;
        }
        
	if (a1 + a2 + a3 + a4 + a5 == 13) {
    	cout << 2 << endl;
        }
        
	if (a1 + a2 + a3 + a4 + a5 == 12) {
    	cout << 3 << endl;
        }
        
	if (a1 + a2 + a3 + a4 + a5 == 11) {
    	cout << 4 << endl;
        }
        
	if (a1 + a2 + a3 + a4 + a5 == 10) {
    	cout << 5 << endl;
        }
}

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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

	int ans = 1 << 30;
	REP(i,100001){
		ans = min(ans, i*2*C+max(0, X-i)*A+max(0,Y-i)*B);
	}
	cout << ans << endl;

	return 0;

	// int ans = 0;
	// if(A+B > C*2){
	// 	if(X < Y){
	// 		int cnt = X;
	// 		ans += C*cnt*2;
	// 		ans += (Y-X)*B;
	// 	}else{
	// 		int cnt = Y;
	// 		ans += C*cnt*2;
	// 		ans += (X-Y)*A;
	// 	}
	// }else{
	// 	ans += A*X+B*Y;
	// }
	//
	// cout << ans << endl;
	// return 0;

}


Measured memory_bytes: 256
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//                                                                              NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first 
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define LINF 98765432123456789
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define debug4(w,x,y,z) cout<<#w<<" "<<w<<" "<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
#define sz(x) (ll)((x).size())
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	double r;
	cin>>r;
	cout<<setprecision(20)<<(44*r)/7;
	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#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()
{
  vi v = {1, 1, 1, 2, 1, 2, 1, 5,
          2, 2, 1, 5, 1, 2, 1, 14,
          1, 5, 1, 5, 2, 2, 1, 15,
          2, 2, 5, 4, 1, 4, 1, 51};
  int n;
  cin >> n;

  cout << v[n-1] << endl;

  return 0;
}


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

constexpr double eps = 1e-10;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    for (auto&& e : a) {
      cin >> e;
    }
    double mn = numeric_limits<double>::max();
    int rs = -1, rp = -1, rq = -1;
    for (int s = 0; s <= 15; ++s) {
      for (int p = 0; p <= 15; ++p) {
        for (int q = 0; q <= 15; ++q) {
          vector<int> c(256);
          int r = s;
          for (int i = 0; i < n; ++i) {
            r = (p * r + q) & 0xff;
            ++c[(a[i] + r) & 0xff];
          }
          double cur = 0;
          for (double e : c) {
            if (e > eps) {
              cur -= (e / n) * log(e / n);
            }
          }
          if (cur + eps < mn) {
            mn = cur;
            rs = s, rp = p, rq = q;
          }
        }
      }
    }
    cout << rs << ' ' << rp << ' ' << rq << '\n';
  }
}



Measured memory_bytes: 3348
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
s = sum(A)

for i in reversed(range(N)):
    b = B[i]
    if A[i+1] >= b:
        A[i+1] -= b
    else:
        b -= A[i+1]
        A[i+1] = 0
        if A[i] >= b:
            A[i] -= b
        else:
            A[i] = 0
    

print(s-sum(A))

Measured memory_bytes: 81892
using System;

namespace B___Iroha_Loves_Strings__ABC_Edition_
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var l = int.Parse (input[1]);
            var a = new string[n];
            for (var i = 0; i < n; i++)
            {
                a[i] = Console.ReadLine ();
            }
            Array.Sort (a);
            for (var i = 0; i < a.Length; i++)
            {
                Console.Write (a[i]);
            }
            Console.WriteLine ();
        }
    }
}

Measured memory_bytes: 13408
#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;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];

  ll res = 0;
  rep(i, n) {
    if (p[i] == i + 1) {
//      if (i != n - 1) {
        swap(p[i], p[i + 1]);
//      }
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 640
H, W, K = map(int, input().split())
c_list = [input() for _ in range(H)]

from copy import deepcopy
ans = 0
for i in range(pow(2, H + W)):
    c_copy = deepcopy(c_list)
    for w in range(W):
        if (i & pow(2, H + w)) > 0:
            for h in range(H):
                c_copy[h] = c_copy[h][:w] + 'x' + c_copy[h][w+1:]
    cnt = 0
    for h in range(H):
        if (i & pow(2, h)) > 0:
            c_copy[h] = 'x' * W
        cnt += c_copy[h].count('#')
    if cnt == K:
        ans += 1
print(ans)

Measured memory_bytes: 9344
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7,k,ans;
void dfs(ll src ,vector<ll> adj[] ,vector<bool>&visited)
{
    visited[src]=true;
    ll cur = k-2;
    for(ll i=0;i<adj[src].size();i++)
    {
        if(!visited[adj[src][i]])
        {
            ans = (ans*cur)%mod;
            cur--;
            dfs(adj[src][i] , adj,visited);
        }
    }
}
int main()
{
    fast();
    ll n;
    cin>>n>>k;

    vector<ll> adj[n];
    for(ll i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    ll root=0;
    for(ll i=1;i<n;i++){
        if(adj[i].size() > adj[root].size())
            root=i;
    }

    if(adj[root].size() > k )
    {
        cout<<"0";
        return 0;
    }

    vector<bool> visited(n,false);
    visited[root]=true;

    ans = k;
    ll cur=k-1;
    for(ll i=0;i<adj[root].size();i++)
    {
        ans = (ans*cur)%mod;
        cur--;
        dfs(adj[root][i] , adj ,visited);
    }
    cout<<ans;
}


Measured memory_bytes: 10368
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String[] firstLineValues = sc.nextLine().split(" ");

      	List<String> list = new ArrayList<String>();
      	for(int i = 0; i < Integer.parseInt(firstLineValues[0]); i++) {
      		list.add(sc.nextLine());
      	}
      	StringBuilder sb = new StringBuilder();
      	while(list.size() > 0) {
      		String tag = "";
      		for(String str: list) {
      			if(tag.isEmpty()) {
      				tag = str;
      				continue;
      			}
      			for(int i = 0; i < str.length(); i++) {
      				if(tag.charAt(i) > str.charAt(i)) {
      					tag = str;
      					break;
      				}
      				if(tag.charAt(i) < str.charAt(i)) {
      					break;
      				}
      			}
      		}
      		sb.append(tag);
      		list.remove(tag);
      	}
      	System.out.println(sb.toString());

	}

}


Measured memory_bytes: 21844
n=int(input())
a=list(map(int,input().split()))
def gcd(x,y):
  if x%y==0:
    return y
  else:
    return gcd(y,x%y)
  
b=a[0]
  
for i in range(1,n):
  b=gcd(b,a[i])
  
print(b)  
  

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
class Segtree {
private:
	vector<T> seg;
	LL RN;
	typedef function<T(T, T)> TT;
	TT f;
	T te;
public:
	Segtree(LL N, TT _f,T e):te(e) {
		RN = 1;
		while (RN < N)RN *= 2;
		seg.resize(2 * RN, te);
		f = _f;
	}
	Segtree(vector<T>& V, T(*_f)(T, T),T e):te(e) {
		LL N = V.size();
		RN = 1;
		while (RN < N)RN *= 2;
		seg.resize(2 * RN, te);
		f = _f;
		for (LL n = 0; n < N; n++) seg[RN + n] = V[n];
		for (LL k = RN - 1; k >= 1; k--) {
			seg[k] = f(seg[2 * k], seg[2 * k + 1]);
		}
	}
	//set n-th as x(0 index!!!!!)
	void set(LL n, T x) {
		seg[RN + n] = x;
		n = (RN + n) / 2;
		while (n >= 1) {
			seg[n] = f(seg[2 * n], seg[2 * n + 1]);
			n /= 2;
		}
	}
	//change n-th number p to x*p(0 index!!!!!)
	void addl(LL n, T x) {
		seg[RN + n] = f(x, seg[RN + n]);
		n = (RN + n) / 2;
		while (n >= 1) {
			seg[n] = f(seg[2 * n], seg[2 * n + 1]);
			n /= 2;
		}
	}
	//change n-th number p to p*x(0 index!!!!!)
	void addr(LL n, T x) {
		seg[RN + n] = f(seg[RN + n], x);
		n = (RN + n) / 2;
		while (n >= 1) {
			seg[n] = f(seg[2 * n], seg[2 * n + 1]);
			n /= 2;
		}
	}
	//get [l,r] (0 index!!!!!)
	T get(LL l, LL r) {
		T ansl = te, ansr = te;
		r++;
		l += RN;
		r += RN;
		while (l < r) {
			if (l & 1) {
				ansl = f(ansl, seg[l]);
				l++;
			}
			if (r & 1) {
				r--;
				ansr = f(seg[r], ansr);
			}
			l >>= 1;
			r >>= 1;
		}
		return f(ansl, ansr);
	}
	//get n-th number(0 index!!!!!)
	T get(LL n) {
		return seg[RN + n];
	}
	T operator[](LL n) {
		return seg[RN + n];
	}
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, M;
	cin >> N >> M;
	if (N & 1) {
		for (LL t = 1; t <= M; t++) {
			cout << t << " " << N - t << "\n";
		}
	}
	else {
		for (LL t = 1; t <= min(M, (N + 2) / 4-1); t++) {
			cout << t << " " << N - t << "\n";
		}
		for (LL t = (N + 2) / 4; t <= M; t++) {
			cout << t << " " << N - t - 1 << "\n";
		}
	}
	return 0;
}


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


int main(){
    string S; cin >> S;
    int g = 0, p = 0, w=0, l=0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'g'){
            if(p+1 <= g) {p++; w++;}
            else g++;
        }
        if(S[i] == 'p'){
            if(p+1 <= g) {p++;}
            else {g++; l++;}
        }
    }
    cout << w-l << endl;
}

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

int main() {
  int64_t N, W;
  cin >> N >> W;
  
  vector<vector<int64_t>> dp(N+1, vector<int64_t>(100001, 0));
  vector<int64_t> weight(N);
  vector<int64_t> value(N);
  
  for (int i=0; i<N; i++) {
    cin >> weight.at(i) >> value.at(i);
  }
  
  for (int i=0; i<N; i++) {
    for (int w=0; w<=W; w++) {
      if(w-weight.at(i)<0) {
        dp.at(i+1).at(w)=dp.at(i).at(w);
      }
      else {
        dp.at(i+1).at(w)=max(dp.at(i).at(w-weight.at(i))+value.at(i), dp.at(i).at(w));
      }
    }
  }
  
  cout << dp.at(N).at(W) << endl;
}

Measured memory_bytes: 80256
from collections import Counter


def resolve():
    n = int(input())
    s = input()
    cnt = Counter(s)
    ans = cnt['R'] * cnt['G'] * cnt['B']

    for i in range(n - 1):
        for j in range(i + 1, n):
            ken = j * 2 - i
            if (ken >= n):
                continue
            if (s[i] != s[j] and s[j] != s[ken] and s[i] != s[ken]):
                ans -= 1

    print(ans)

resolve()

Measured memory_bytes: 9460
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int n,m;
P p[40];
double calc(P a, P b, P c) {
  return cross(b-a, c-a) / 2;
}
double memo[40][40][40];
double solve(int start, int pre, int num) {
  
  if (num == m) {
    return 0;
  }
  if (memo[start][pre][num] != -1) return memo[start][pre][num];
  double res = 0;
  if (num == 1) {
    for (int i=pre+1; i<n-(m-num-1); ++i) {
      res = max(res, solve(start, i, num+1));
    }
  } else {
    for (int i=pre+1; i<n-(m-num-1); ++i) {
      
      res = max(res, calc(p[start], p[pre], p[i]) + solve(start, i, num+1));
    }
  }
  return memo[start][pre][num] = res;
}

int main() {
  while(cin>>n>>m,n||m) {
    double d;
    REP(i, n) {
      cin >> d;
      p[i] = P(cos(d*2*M_PI), sin(d*2*M_PI));
    }
    REP(i,n)REP(j,n)REP(k,n)memo[i][j][k] = -1;
    double ans = 0;
    REP(i, n-m+1) {
      ans = max(ans, solve(i, 0, 1));
    }
    printf("%.6lf\n", ans);
  }
}

Measured memory_bytes: 0
#include<cstdio>
#include<algorithm>
using namespace std;
char p[201000];
int Nxt[201000][26];
int n, D[201000];
int main(){
    int i, j;
    scanf("%s",p+1);
    for(i=1;p[i];i++);
    n=i-1;
    for(i=1;i<=n;i++){
        Nxt[i][p[i]-'a'] = i;
    }
    for(i=n;i>=1;i--){
        for(j=0;j<26;j++)if(!Nxt[i][j])Nxt[i][j]=Nxt[i+1][j];
    }
    D[n+1] = 1;
    for(i=n;i>=1;i--){
        int r = n+1;
        for(j=0;j<26;j++){
            if(!Nxt[i][j])r = min(r,1);
            else r = min(r, D[Nxt[i][j]+1] + 1);
        }
        D[i] = r;
    }
    int x = 1;
    while(x){
        for(i=0;i<26;i++){
            if(Nxt[x][i]==0)break;
        }
        if(i!=26){
            printf("%c",i+'a');
            break;
        }
        for(i=0;i<26;i++){
            if(D[Nxt[x][i]+1] + 1 == D[x])break;
        }
        printf("%c",i+'a');
        x = Nxt[x][i]+1;
    }
    printf("\n");
}

Measured memory_bytes: 21504
def main():
  
  n,*d=map(int,open(0).read().split())
  d=tuple(sorted(d))
  l=len(d)
  s=n//2
  if d[s-1]==d[s]:
    print(0)
  else:
    print(d[s]-d[s-1])
      
if __name__=="__main__":
  main()

Measured memory_bytes: 13956
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
int mod = 1e9 + 7;
int INF = 2e18;

signed main() {
    int N;
    string S;
    cin >> N >> S;
    if (S.substr(0, N / 2) == S.substr(N / 2, N)) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
 }

Measured memory_bytes: 256
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    n = [int(c) for c in "0" + input()]
    I = len(n)
    ans = 0
    for i in range(I-1, -1, -1):
        b = n[i]
        if b < 5:
            ans += b
        elif b == 5:
            for j in range(2):
                c = n[i-j-1]
                cn = 5 - j
                if c < cn:
                    ans += b
                    break
                elif c > cn:
                    ans += b
                    n[i-1] += 1
                    break
            else:
                ans += b
                n[i-1] += 1
        else:
            ans += 10 - b
            n[i-1] += 1
    print(ans)

if __name__ == "__main__":
    resolve()


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

using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

#ifndef DEBUG
	#pragma GCC optimize ("Ofast")
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
auto mapf(auto a, auto f){for(auto& x:a)x=f(x); return a;}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1);
#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

int gcd(int a, int b){
	if(!b)
		return a;
	return gcd(b, a%b);
}
int lcm(int a, int b){return a/gcd(a,b)*b;}

signed main(){
	int n, m; cin>>n>>m;
	int a[n];
	int z=1;
	rep(i,n){
		cin>>a[i];
		if(z>m)
			continue;
		z=lcm(z,a[i]/2);
	}
	rep(i,n)
		if(z/(a[i]/2)%2==0){
			cout<<0<<endl;
			return 0;
		}

	cout<<m/z/2+m/z%2<<endl;

	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define optimize ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long
#define ld long double
#define vi vector<int>
#define si set<int>
#define pb push_back
#define lp(i,a,b) for(int i = a ; i <= b ; i ++)
#define rlp(i,a,b) for(int i = b ; i >= a ; i --)
#define a_sort(v) sort(v.begin(), v.end())
#define d_sort(v) sort(v.rbegin(), v.rend())
#define pii pair<int,int>
#define pi 3.14159265358979323846264338327950
using namespace std ;
// #define debug

const int MOD = 1E9 + 7 ;
const int N = 100 ;

int main() {
    #ifdef debug
    freopen("input.txt", "r", stdin) ;
    freopen("output.txt", "w", stdout) ;
    #endif // debug
    optimize

    int x , n ; cin >> x >> n ;
    vi a(N + 5, 0) , in(n) ;
    lp(i, 0, n-1) {
        cin >> in[i] ;
        a[in[i]] ++ ;
    }
    if(n == 0) cout << x << endl ;
    else {
        int mn = *min_element(in.begin(), in.end()) , mx = *max_element(in.begin(), in.end()) ;
        int mnDis = 0 , mxDis = 0 , mnAns = -1 , mxAns = -1 ;
        for(int i = x ; i >= mn ; i --) {
            mnDis ++ ;
            if(a[i] == 0) {
                mnAns = i ;
                break ;
            }
        }

        for(int i = x ; i <= mx ; i ++) {
            mxDis ++ ;
            if(a[i] == 0) {
                mxAns = i ;
                break ;
            }
        }
        if(mnAns == -1 && mxAns == -1) cout << (mnDis <= mxDis ? mn - 1 : mx + 1) << endl ;
        else if(mnAns == -1 && mxAns != -1) cout << mxAns << endl ;
        else if(mnAns != -1 && mxAns == -1) cout << mnAns << endl ;
        else cout << (mnDis <= mxDis ? mnAns : mxAns) << endl ;

        // testing
//        cout << "mnAns = " << mnAns << endl ;
//        cout << "mxAns = " << mxAns << endl ;
//        cout << "mnDis = " << mnDis << endl ;
//        cout << "mnDis = " << mxDis << endl ;
    }
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n,m,k;
ll b[35];
ll a[35][35];
ll ans;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>a[i][j];
            b[a[i][j]]++;
        }
    }
    for(int i=1;i<=m;i++){
        if(b[i]==n){
            ans++;
        }
    }
    cout<<ans<<endl;

}



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

int comp( const void *c1, const void *c2 );

int main( void )
{
	int i, x[10];
	
	for( i = 0; i < 10; i++ ){
		scanf( "%d", &x[i] );
	}
	
	qsort( x, 10, sizeof(int), comp );
	
	for( i = 0; i < 3; i++ ){
		printf( "%d\n", x[i] );
	}
	
    return 0;
}

int comp( const void *c1, const void *c2 )
{
	int tmp1 = *(int*)c1;
	int tmp2 = *(int*)c2;
	
	if( tmp1 < tmp2 )	return 1;
	if( tmp1 == tmp2 )	return 0;
	if( tmp1 > tmp2 )	return -1;
}

Measured memory_bytes: 604
#include<stdio.h>
int main()
{
	int a, b;
	char c;
	int ans;
	for (;;)
	{
		scanf("%d %c %d", &a, &c, &b);
		if (c == '?')
			break;
		if (c == '+')ans = a + b;
		if (c == '-')ans = a - b;
		if (c == '*')ans = a * b;
		if (c == '/')ans = a / b;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 2040
N, M = map(int, input().split())
H = [int(i) for i in input().split()]
A = [0] * M
B = [0] * M
for i in range(M):
    A[i], B[i] = map(int, input().split())
d = {}
for i in range(M):
    if A[i] not in d:
        d[A[i]] = set()
    if B[i] not in d:
        d[B[i]] = set()
    d[A[i]].add(B[i])
    d[B[i]].add(A[i])

ans = 0
for i in range(N):
    if i+1 not in d:
        ans += 1
        continue

    val = d[i+1]
    flag = True
    for c in val:
        if H[i] <= H[c-1]:
            flag = False
            break
    if flag:
        ans += 1
print(ans)

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

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

    divisors.sort()
    return divisors

test=make_divisors(m,n)
print(m//min(test))




Measured memory_bytes: 38640