akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    public void Proc()
    {
        int itemCount = int.Parse(Console.ReadLine());
        string[] inpt = Console.ReadLine().Split(' ');
        int[] numList = new int[itemCount];

        for(int i=0; i<inpt.Length; i++)
        {
            numList[i] = int.Parse(inpt[i]);
        }
        // ??????????????????
        int left = 0;
        int convCount = 0;
        
        while(true)
        {
            bool isMatch = false;
            for(int i=numList.Length -2; i>=left; i--)
            {
                if(numList[i] > numList[i+1])
                {
                    int v = numList[i];
                    numList[i] = numList[i + 1];
                    numList[i + 1] = v;
                    convCount++;
                    isMatch = true;
                    if(i==left)
                    {
                        left++;
                    }
                }
            }
            if(!isMatch)
            {
                break;
            }
        }
        StringBuilder ans = new StringBuilder();
        for(int i=0; i<numList.Length; i++)
        {
            if(ans.Length > 0)
            {
                ans.Append(" ");
            }
            ans.Append(numList[i]);
        }

        Console.WriteLine(ans.ToString());
        Console.WriteLine(convCount);
    }


    static void Main(string[] args)

    {

        Program prg = new Program();
        prg.Proc();

    }
}

Measured memory_bytes: 9080
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	bool ok = 0;
	scanf("%d", &n);
	for (int i = 1; i <= 9; i ++)
		for (int j = 1; j <= 9; j ++)
			if (i * j == n)
				ok = 1;
	puts(ok ? "Yes" : "No");
	return 0;
}


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


long long f(long long x){
    long long n = 1;
    while(1){
        if(n*(n-1)/2 < x and x <=(n+1)*n/2){
            break;
        }
        else{
            n++;
        }
    }
    return n;
}

int main(){
    long long x;
    cin >> x;

    printf("%lld\n", f(x));

    return 0;


}

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

using namespace std;

typedef long long ll;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
        ll n, x;
    cin >> n >> x;
    ll ans = n;
    ll a = x, b = n - x;
    while (b % a != 0)
    {
        ans += 2 * a * (b / a);
        ll tmp = a;
        a = b % a;
        b = tmp;
    }
    ans += a * (2 * (b / a) - 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#[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(std::io::BufReader::new(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, $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")
    };
}

#[allow(unused_must_use)]
#[allow(unused_variables)]
#[allow(unused_mut)]
fn otoshidama(n:i32, y:i32) -> (i32, i32, i32) {
    let mut res10000 = -1;
    let mut res5000 = -1;
    let mut res1000 = -1;
    let mut i_vec = Vec::with_capacity(n as usize);
    let mut j_vec = Vec::with_capacity(n as usize);
    for m in 0..n+1 {
        i_vec.push(m);
        j_vec.push(m);
    }
    let i_itr = i_vec.iter();
    let j_itr = j_vec.iter();
    for i in i_itr.as_ref() {
        for j in j_itr.as_ref() {
            let k = n - *i - *j;
            if k < 0 {
                break;
            }
            let total = 10000*i + 5000*j + 1000*k;
            if total == y {
                res10000 = *i;
                res5000 = *j;
                res1000 = k;
            }
        }
    }
    return (res10000, res5000, res1000);
}

fn main() {
    input!{
        n: i32,
        y: i32
    }
    let (res10000, res5000, res1000) = otoshidama(n, y);
    println!("{} {} {}", res10000, res5000, res1000);
}

Measured memory_bytes: 4476
INF = 10 ** 20

n, k = map(int, input().split())
alst = list(map(int, input().split()))
init_ind = alst.index(1)
left = init_ind
right = n - init_ind - 1

ans = INF
for l in range(k):
  r = k - l - 1
  if l <= init_ind and init_ind + r <= n - 1:
    left2 = left - l
    right2 = right - r
    ans = min(ans, 1 + left2 // (k - 1) + bool(left2 % (k - 1)) + right2 // (k - 1) + bool(right2 % (k - 1)))
print(ans)


Measured memory_bytes: 13880
//
//  main.cpp
//  1
//
//  Created by RISHAV SINGH MEHTA on 08/12/19.
//  Copyright © 2019 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    long long int i,j,k,l,m;
    cin>>i>>j>>k;
    long long int sum;
    sum=i+j+k;
    if (sum>=22) {
        cout<<"bust";
    }else{
        cout<<"win";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <map>


using namespace std;
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
typedef int status;
typedef long long ll;
typedef unsigned long long ull;
const ull base = 343;
const int INF = int(1e9);
const ll INF1 = ll(1e18);
const int MAX = 1000002;

long long a,b,c;
long long k;
int flag = 1;

int main()
{
    ios_base::sync_with_stdio(0);
    cin>>a>>b>>c>>k;
    if(k%2==0){
        cout<<a-b<<endl;
    }else{
        cout<<b-a<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
/*inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}*/
#define gc getchar
#define pc putchar
#define fi first
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RANK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
int n,cnt;
vector<int> V;
int main(){
    n=rd();
    rep(i,0,n){
    	int x = rd();
    	V.push_back(x);
    	if(V.size()>0 && V[i-1]==x) cnt++,V[i]=0; 
	} 
	writeln(cnt);
    return 0;
}

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

using namespace std;

using ll = long long;

const int MX = 57;

ll dp[MX][2];
int a[MX];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, p;
    cin >> n >> p;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            if (a[i] % 2 == 0) {
                dp[i + 1][j] += 2ll * dp[i][j];
            } else {
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j ^ 1] += dp[i][j];
            }
        }
    }
    cout << dp[n][p] << endl;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] x = new int[m];
        for (int i = 0; i < m; i++) {
            x[i] = sc.nextInt();
        }
        Arrays.sort(x);
        int[] diff = new int[m - 1];
        for (int i = 0; i < m - 1; i++) {
            diff[i] = Math.abs(x[i + 1] - x[i]);
        }
        Arrays.sort(diff);
        int sum = 0;
        for (int i = 0; i < m - n; i++) {
            sum += diff[i];
        }
        System.out.println(sum);
    }

}


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

int main()
{
    string arr[5]= {"AC","WA","TLE","RE"};
    int C0=0,C1=0,C2=0,C3=0;
    int N;
    cin>>N;
    string arr_2[N];
    for(int i=0; i<N; i++)
    {
        cin>>arr_2[i];

        if(arr_2[i]=="AC")
            C0+=1;
        else if(arr_2[i]=="WA")
            C1+=1;
        else if(arr_2[i]=="TLE")
            C2+=1;
        else if(arr_2[i]=="RE")
            C3+=1;
    }

    cout<<"AC  x"<<" "<<C0<<endl;
    cout<<"WA  x"<<" "<<C1<<endl;
    cout<<"TLE  x"<<" "<<C2<<endl;
    cout<<"RE  x"<<" "<<C3<<endl;




    return 0;
}




Measured memory_bytes: 6720
#include <iostream>
using namespace std;
int main(void){
    int x;
    cin >> x;
    if(x <= 9){
        int y;
        y = (9-x) % 7;
        if(y == 0){
            cout << "sat" << endl; 
        }else if(y == 1){
            cout << "fri" << endl;
        }else if(y == 2){
            cout << "thu" << endl;
        }else if(y == 3){
            cout << "wed" << endl;
        }else if(y == 4){
            cout << "tue" << endl;
        }else if(y == 5){
            cout << "mon" << endl;
        }else{
            cout << "sun" << endl;
        }
        
        
    }else{
        int y;
        y = (x-9) % 7;
        if(y == 0){
            cout << "sat" << endl; 
        }else if(y == 1){
            cout << "sun" << endl;
        }else if(y == 2){
            cout << "mon" << endl;
        }else if(y == 3){
            cout << "tue" << endl;
        }else if(y == 4){
            cout << "wed" << endl;
        }else if(y == 5){
            cout << "thu" << endl;
        }else{
            cout << "fri" << endl;
        }
        
    }
}


Measured memory_bytes: 3112
#[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(std::io::BufReader::new(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, $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")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
use std::collections::HashMap;

fn main() {
    input!{
      n: usize,
      aa: [usize; n],
    }
    let mut h: HashMap<usize, bool> = HashMap::new();
    for a in &aa {
        if h.contains_key(a) {
            h.remove(a);
        } else {
            h.insert(*a, true);
        }
    }
    println!("{}", h.len());
}


Measured memory_bytes: 12540
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
int main() {
	string s;
	cin >> s;
	if (s[s.size() - 1] == 's') {
		cout << s;
		cout << "es";
	}
	else {
		cout << s;
		cout << 's';
	}
	return 0;
}

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

int main() {
    int n;
    cin >>n;
    string s;
    cin >> s;
    ll r=0;
    ll g=0;
    ll b=0;
    vector<string> color(n);
    for (int i=0;i<n;i++){
        color.at(i) = s.at(i);
        if(s.at(i)=='R') r++;
        if(s.at(i)=='G') g++;
        if(s.at(i)=='B') b++;
     }
    ll all = r*g*b;
    ll count_b=0;
    for (int i=0;i<n;i++){
        for (int j=i+1;j<n;++j){
            if(color.at(i)==color.at(j)) continue;
            int k=2*j-i;
            if (k>=n) continue;
            if(color.at(i)==color.at(k) || color.at(j)==color.at(k)){
                continue;
            }
            count_b++;
        }
    } 
    cout << all-count_b << endl;
    return 0;
}



Measured memory_bytes: 3732
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int seg_len;
int seg[10000000] = {0};

//1-indexedのl,rを入れる
//区間は[l,r)であることに注意
void add(int l, int r, int x){
	l += seg_len-1;
	r += seg_len-1;
	while(l<r){
		if(l % 2 == 1){seg[l] += x; ++l;}
		l /= 2;
		if(r % 2 == 1){seg[r-1] += x; --r;}
		r /= 2;
	}
}

//1-indexedで入れる
int get(int i){
	int k = i+seg_len-1;
	int res = 0;
	while(k>0){
		res += seg[k];
		k /= 2;
	}
	return res;
}

int main(){
	int N, C, s, t, c;
	cin >> N >> C;
	seg_len = 1;
	while(seg_len < 200100)seg_len *= 2;
	rep(i,N){
		cin >> s >> t >> c;
		s *= 2; t *= 2;
		--s;
		add(s, t, 1);
	}
	int ans = -1; 
	rep(i,200050){
		ans = max(ans, get(i));
	}
	ans = min(ans, C);
	cout << ans << endl;
	return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  int A, B, M;
  cin >> A >> B >> M;
  vector<ll> a(A), b(B);

  ll minA = INF;
  ll minB = INF;
  rep(i, A){
    cin >> a[i];
    chmin(minA, a[i]);
  }
  rep(i, B){
    cin >> b[i];
    chmin(minB, b[i]);
  }

  ll ans = INF;

  int x, y, c;
  rep(i, M){
    cin >> x >> y >> c;
    x--;
    y--;
    
    chmin(ans, a[x] + b[y] - c);

  }

  chmin(ans, minA + minB);

  cout << ans << endl;




  return 0;
}


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

string s[110], t[110];

int main(void) {
	int N, M;
	cin >> N;
	for (int i = 0; i < N; i++)cin >> s[i];
	cin >> M;
	for (int i = 0; i < M; i++)cin >> t[i];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int score = 0;
		for (int j = 0; j < N; j++)if (s[j] == s[i])score++;
		for (int j = 0; j < M; j++)if (t[j] == s[i])score--;
		ans = max(ans, score);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
listL = list(map(int, input().split()))

index=0
current = 0
count = 0
while index < len(listL):
    if current <= x:
        count+=1
    current += listL[index]
    index+=1
if current <= x:
    count+=1
print(count)

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

int main(){

double x1,x2,y1,y2;
cin >> x1 >> y1 >> x2 >> y2;

double dx = x1-x2;
double dy = y1-y2;

double ans =  sqrt(dx*dx + dy*dy);

cout << setprecision(16) << ans << endl;
}


Measured memory_bytes: 3268
using System;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        for (int i = 1; i <= n; ++i)
        {
            int x = i;

            if (x % 3 == 0)
            {
                Console.Write(" {0}", i);
            }
            else
            {
                while (x > 0)
                {
                    if (x % 10 == 3)
                    {
                        Console.Write(" {0}", i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#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()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, r; cin >> n >> r;
	if (n >= 10) dunk(r);
	else {
		dunk(r + 100 * (10 - n));
	}
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

ll gcd(ll a,ll b){
  if(a < b) swap(a,b);
  if(b == 0) return a;
  return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return a*b/ gcd(a,b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a1,m1,a2,m2,a3,m3;
  int x = 1, y = 1, z = 1;
  while(cin >>a1>>m1>>a2>>m2>>a3>>m3){
    if(a1+m1+a2+m2+a3+m3 == 0)break;
    ll cnt = 0;
    ll xc = -1,yc=-1,zc=-1;
    while(1){
      x = a1*x % m1;
      ++cnt;
      if(x == 1){
        xc = cnt;
        break;
      }
    }
    cnt = 0;
    while(1){
      y = a2*y % m2;
      cnt++;
      if(y == 1){
        yc = cnt;
        break;
      }
    }
    xc = lcm(xc,yc);
    cnt=0;
    while(1){
      z = a3*z % m3;
      ++cnt;
      if(z == 1 ){
        zc = cnt;
        break;
      }
    }
    cout << lcm(xc,zc)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3116
n, m = map(int, input().split())
points = list(map(int, input().split()))
points = points[:m]

if m <= n:
    print(0)
else:
    points.sort()
    dx = [ abs(points[i]-points[i+1]) for i in range(0,len(points)-1) ]
    dx.sort()
    dx.reverse()
    print(sum(dx[n-1:]))


Measured memory_bytes: 13968
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
static const int MAX = 500000;

class Node {
public:
  int location;
  int right, left;
  Node() {}
};

struct Range {
  int sx, tx, sy, ty;
};

class Point {
public:
  int id, x, y;
  Point() {}
  Point(int id, int x, int y) : id(id), x(x), y(y) {}
  void print() { printf("id:%d (%d, %d)\n", id, x, y); }
  bool inRange(Range r) {
    return r.sx <= x && x <= r.tx && r.sy <= y && y <= r.ty;
  }
};

bool compX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
bool compY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

Point P[MAX];
Node T[MAX];

int IDX = 0;
int makeTree(int l, int r, int depth) {
  if (!(l < r))
    return -1;
  int n = IDX;
  IDX++;
  int m = (l + r) / 2;

  if (depth % 2 == 0) {
    sort(P + l, P + r, compX);
  } else {
    sort(P + l, P + r, compY);
  }
  T[n].location = m;
  T[n].left = makeTree(l, m, depth + 1);
  T[n].right = makeTree(m + 1, r, depth + 1);
  return n;
}

vector<int> answer;

int find(int idx, Range range, int depth) {
  Point p = P[T[idx].location];
  if (p.inRange(range))
    answer.push_back(p.id);

  if (depth % 2 == 0) {
    if (T[idx].left != -1 && range.sx <= p.x)
      find(T[idx].left, range, depth + 1);
    if (T[idx].right != -1 && range.tx >= p.x)
      find(T[idx].right, range, depth + 1);
  } else {
    if (T[idx].left != -1 && range.sy <= p.y)
      find(T[idx].left, range, depth + 1);
    if (T[idx].right != -1 && range.ty >= p.y)
      find(T[idx].right, range, depth + 1);
  }
}

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    P[i] = Point(i, x, y);
    T[i].right = T[i].left = -1;
  }
  makeTree(0, n, 0);

  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int sx, tx, sy, ty;
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
    Range r = {sx, tx, sy, ty};
    find(0, r, 0);
    sort(answer.begin(), answer.end());
    for (int j = 0; j < answer.size(); j++)
      printf("%d\n", answer[j]);
    printf("\n");
    answer.clear();
  }
}

Measured memory_bytes: 14472
#include<bits/stdc++.h>
using namespace std;
#define N 100005
struct edge{
	int to,next;
}e[N*2];
int n,m,tot,head[N];
int a[N],b[N],id[N],fa[N];
long long qd[N],S[N];
bool cmp(int x,int y){
	return a[x]<a[y];
}
void add(int x,int y){
	e[++tot]=(edge){y,head[x]};
	head[x]=tot;
}
int get(int x){
	return fa[x]==x?x:fa[x]=get(fa[x]);
}
int vis[N];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		a[i]=max(a[i]-b[i],0);
	}
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	for (int i=1;i<=n;i++)
		id[i]=i,fa[i]=i,qd[i]=a[i],S[i]=b[i]; 
	sort(id+1,id+n+1,cmp);
	for (int i=1;i<=n;i++){
		int x=id[i]; vis[x]=1;
		for (int j=head[x];j;j=e[j].next)
			if (vis[e[j].to]){
				int X=get(x),Y=get(e[j].to);
				if (X==Y) continue;
				fa[Y]=X; S[X]+=S[Y];
				qd[X]=min(qd[X],qd[Y]+max(0ll,a[x]-S[Y]-qd[Y]));
			}
	}
	int x=get(1);
	printf("%lld",qd[x]+S[x]);
}

Measured memory_bytes: 5760
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		// ------------------------------------------------

		int a, b, c, d;
		a = Integer.parseInt(sc.next());
		b = Integer.parseInt(sc.next());
		c = Integer.parseInt(sc.next());
		d = Integer.parseInt(sc.next());

		boolean takaWin = false;
		while (true) {
			c -= b;
			if (c <= 0) {
				takaWin = true;
				break;
			}
			a -= d;
			if (a <= 0) {
				takaWin = false;
				break;
			}
		}
		if (takaWin) {
			out.println("Yes");
		} else {
			out.println("No");
		}

		// ------------------------------------------------
		sc.close();
		out.flush();
	}
}

Measured memory_bytes: 27056
N = int(input())
s = []
for i in range(N):
    s.append(''.join(sorted(input())))

sortedS = sorted(s)
i = 1
isSame = False
count = []
tmpS = sortedS[0]
while i < N:
    if isSame:
        if sortedS[i] == tmpS:
            count[-1] += 1
        else:
            isSame = False
            tmpS = sortedS[i]
    else:
        if sortedS[i] == tmpS:
            count.append(2)
            isSame = True
        else:
            tmpS = sortedS[i]
    i += 1

output = 0
for i in range(len(count)):
    output += count[i]*(count[i]-1)/2
print(int(output))


Measured memory_bytes: 11408
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <math.h>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;
typedef long long int lli;

int main() {
    int N, res;
    cin >> N;
    if (N % 111 == 0) {
        res = N;
    } else {
        res = 111 * (N / 111 + 1);
    }
    cout << res << endl;
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in) ;
        int n = sc.nextInt() ;
        BigInteger ans = BigInteger.ONE ;
        BigInteger b[] = new BigInteger[n] ;
        BigInteger cmp = new BigInteger("1000000000000000000") ;
        Boolean zero = false ;
        for (int i = 0 ; i < n ; i ++) {
            b[i] = sc.nextBigInteger() ;
            if(b[i].compareTo(BigInteger.ZERO) == 0) zero = true ;
        }
        if(zero) System.out.println(0);
        else {
            Boolean con = true ;
            for (int i = 0 ; i < n ; i ++) {
                ans = ans.multiply(b[i]) ;
                if(ans.compareTo(cmp) == 1) {
                    con = false ;
                    break ;
                }
            }
            if(con) System.out.println(ans);
            else System.out.println(-1);
        }
    }
}


Measured memory_bytes: 66136
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
B=map(x->parse(Int,x),split(readline()))
C=map(x->parse(Int,x),split(readline()))
p=-1
ans=0
for a=A
	ans+=B[a]
	if p+1==a
		ans+=C[p]
	end
	p=a
end
println(ans)


Measured memory_bytes: 165916
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <set>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

const int MOD = 1000*1000*1000+7;
int add(int a, int b) { return ((ll)a+b)%MOD; }
void chadd(int& a, int b) { a = ((ll)a+b)%MOD; }
int mul(int a, int b) { return ((ll)a*b)%MOD; }

ll power(ll a,ll b,ll mod) {
  if (b==0) return 1LL;
  if (b%2) return (a*power(a,b-1,mod))%mod;
  else {
    ll x=power(a,b/2,mod);
    return (x*x)%mod;
  }
}
ll inv(ll a, ll p) {
  return ( a == 1 ? 1 : (1 - p*inv(p%a, a)) / a + p );
}

int dp[5002][5002];

int main() {
  int N;
  string mofumofu;
  while (cin >> N >> mofumofu) {
    int M = mofumofu.size();

    // M <= N
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i : range(N)) {
      for (int j : range(i + 1)) {
        // B
        chadd(dp[i + 1][max(0, j - 1)], dp[i][j]);
        // 01
        chadd(dp[i + 1][j + 1], mul(2, dp[i][j]));
      }
    }

    int mofumofumofumofu = (int)inv(power(2, M, MOD), MOD);
    int res = mul(dp[N][M], mofumofumofumofu);
    cout << res << endl;
  }
}


Measured memory_bytes: 98048
n,m=map(int,input().split())
s=[0]*m
c=[0]*m
for k in range(m):
    s[k],c[k]=map(int,input().split())
g=[[0,0] for x in range(n)]

d=0
for k in range(m):
    if n>1 and s[k]==1 and c[k]==0:
        d=-1
    if g[s[k]-1][1]==1 and g[s[k]-1][0]!=c[k]:
        d=-1
    g[s[k]-1][0]=c[k]
    g[s[k]-1][1]=1
if n>1 and g[0][0]==0:
    g[0][0]=1

if d==-1:
    print(-1)
elif n==1:
    print(g[0][0])
elif n==2:
    print(str(g[0][0])+str(g[1][0]))
else:
    print(str(g[0][0])+str(g[1][0])+str(g[2][0]))

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

int main() {
  int H, W;
  cin >> H >> W;
  string Su, S, Sd;
  int count;
  
  //H==1対策
  if (H==1) {
    cin >> S;
    for (int w=0; w<W; w++) {
    if (S.at(w) == '.') {
      count=0;
      if (w!=W-1) {
        if (S.at(w+1) == '#')
        count++;
      }
      if (w!=0) {
        if (S.at(w-1) == '#')
        count++;
      }
      cout << count;
    }
    else
      cout << "#";
  }
  cout << endl;
  }
  
  else {
  cin >> S >> Sd;
  for (int w=0; w<W; w++) {
    if (S.at(w) == '.') {
      count=0;
      if (w!=W-1) {
        if (S.at(w+1) == '#')
        count++;
        if (Sd.at(w+1) == '#')
        count++;
      }
      if (w!=0) {
        if (S.at(w-1) == '#')
        count++;
        if (Sd.at(w-1) == '#')
        count++;
      }
      if (Sd.at(w) == '#')
        count++;
      cout << count;
    }
    else
      cout << "#";
  }
  cout << endl;
  for (int h=1; h<H-1; h++) {
    Su = S;
    S = Sd;
    cin >> Sd;
    for (int w=0; w<W; w++) {
      if (S.at(w) == '.') {
        count=0;
        if (w!=W-1) {
          if (S.at(w+1) == '#')
          count++;
          if (Su.at(w+1) == '#')
          count++;
          if (Sd.at(w+1) == '#')
          count++;
        }
        if (w!=0) {
          if (S.at(w-1) == '#')
          count++;
          if (Su.at(w-1) == '#')
          count++;
          if (Sd.at(w-1) == '#')
          count++;
        }
        if (Su.at(w) == '#')
          count++;
        if (Sd.at(w) == '#')
          count++;
        cout << count;
      }
      else
        cout << "#";
    }
    cout << endl;
  }

  for (int w=0; w<W; w++) {
    if (Sd.at(w) == '.') {
      count=0;
      if (w!=W-1) {
        if (S.at(w+1) == '#')
        count++;
        if (Sd.at(w+1) == '#')
        count++;
      }
      if (w!=0) {
        if (S.at(w-1) == '#')
        count++;
        if (Sd.at(w-1) == '#')
        count++;
      }
      if (S.at(w) == '#')
        count++;
      cout << count;
    }
    else
      cout << "#";
  }
  cout << endl;
  }
}


Measured memory_bytes: 256
package main

import(
  "fmt"
  "bufio"
  "os"
  "strconv"
)

func main(){
  var a, b, c int
  var e error
  var sc = bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords) //スペースでトークンを分けるようになってる
  
  if sc.Scan(){
  	a, e = strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
  }
  if sc.Scan(){
  	b, e = strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
  }
  if sc.Scan(){
  	c, e = strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
  }

  
  if a*c <= b{
    fmt.Printf("%d", c)
  }else{ //elseの前に改行入れたら怒られる
    fmt.Printf("%d", b/a)
  }
}

Measured memory_bytes: 640
#include <cstdio>

using namespace std;

int table[501][501];

int main() {
  int N, M, Q;
  scanf("%d %d %d", &N, &M, &Q);

  for (int i = 0; i < M; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    table[l][r]++;
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      table[i][j] += table[i - 1][j] + table[i][j - 1] - table[i - 1][j - 1];
    }
  }
  for (int i = 0; i < Q; i++) {
    int p, q;
    scanf("%d %d", &p, &q);
    const int ans =
        table[q][q] - table[p - 1][q] - table[q][p - 1] + table[p - 1][p - 1];
    printf("%d\n", ans);
  }

  return 0;
}


Measured memory_bytes: 2672
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;

const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string s;
    ll cnt=0;
    cin >> s;
    for(int i=1;i<s.size();i++){
        if(s[i]==s[i-1]){
            if(s[i]=='0') s[i]='1';
            else s[i]='0';
            cnt++;
        }
    }
    cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	cout<<read()-read()+1<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i,j,p,a[10005],q;
    while(scanf("%d",&n)!=EOF)
    {
        p=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
            q=a[i];
            while(q%2==0)
            {
                q=q/2;
                p++;
            }
        }
        printf("%d\n",p);
    }return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] H = new int[N];
		Arrays.setAll(H, i -> sc.nextInt());
		Map<Integer, HashSet<Integer>> edge = new HashMap<>();
		for(int i = 1; i <= N; i++)
		        edge.put(i,  new HashSet<>());
		for (int i = 1; i <= M; i++) {
		        int a = sc.nextInt();
		        int b = sc.nextInt();
		        edge.get(a).add(b);
		        edge.get(b).add(a);
		}
		int ans = 0;
		for(int i = 1; i <= N; i++) {
			boolean ok = true;
			for(int j : edge.get(i)) {
				if(H[j-1] >= H[i-1]) {
					ok = false;
					break;
				}
			}
			if(ok)
				ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 93804
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e6 + 5;
ll res[maxn];
int main()
{
    ios::sync_with_stdio(false);
    ll a , b , n; cin >> a >> b >> n;
    ll x = min(n , b - 1);
    cout << (a * x) / b - a * (x / b) << endl;
   /*for (ll i = 1 ; i <= n ; i++){
        ll l = a * i / b;
        ll r = a * (i / b);
        cout << i << " " << l - r << endl;
    }*/
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  int n;
  cin>>n;
  bool ok=true;
  while(n--){
    int a;
    cin>>a;
    if((a%2==0 && a%3!=0 && a%5!=0)){
      ok=false;
    }
  }
  cout<<(ok ? "APPROVED" : "DENIED")<<'\n';
  return 0;
}


Measured memory_bytes: 256
def main():
    H, N = map(int, input().split())
    magic = [list(map(int, input().split())) for _ in range((N))]
    dp = [float('inf')] * (H + 1)
    dp[0] = 0
    for h in range(H):
        for dmg, cst in magic:
            next = min(h + dmg, H)
            dp[next] = min(dp[next], dp[h] + cst)
    print(dp[h+1])
main()


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

using namespace std;
using ll = long long;

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    sort(res.begin(),res.end());
    return res;
}


ll sqint(ll num){

    ll l = 0;
    ll r = 1e10;

    while(r - l > 1){
        ll mid = (r + l) / 2;
        (mid * mid <= num ? l : r) = mid;
    }
    return l;
}

//a(n) = Sum_{m=1..floor(sqrt(n))} m*(m+floor(n/m))*(floor(n/m)+1-m)
//a（n）= n *（n + 1）*（2 * n + 1）/ 6 = binomial（n + 2、3）+ binomial（n + 1、3）

ll f(ll n) {
    return n * (n + 1) * (2 * n + 1) / 6;
}

int main()
{
    ll n; cin >> n;
    ll ans = 0;
    const ll sq = sqint(n);
    for(ll m = 1; m <= sq; m++) {
        ans += m * (m + n / m) * (n / m + 1 - m);
    }
    cout << ans - f(sq) << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int point1 = 0, point2 = 0;
		String animal1, animal2;
		for (int i = 0; i < n; i++) {
			animal1 = sc.next();
			animal2 = sc.next();
			if (0 < animal1.compareTo(animal2)) {
				point1 += 3;
			} else if (0 > animal1.compareTo(animal2)) {
				point2 += 3;
			} else if (0 == animal1.compareTo(animal2)) {
				point1 += 1;
				point2 += 1;
			}
		}
		System.out.println(point1 + " " + point2);
		sc.close();
	}
}


Measured memory_bytes: 29968
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI=acos(-1);
const int INF = numeric_limits<int>::max();

int main(){
    ll a, b, n;
    cin >> a >> b >> n;

    ll maxans = 0;

    if (b>n){
        maxans = (a * n) / b - a * (n / b);
    }

    else{ 
        maxans = (a * (b - 1)) / b - a * ((b - 1) / b);
    }

    cout << maxans << endl;

    return 0;
    
}

Measured memory_bytes: 3596
b1,b2,b3=map(int,input().split())

if b1==1 and b2==0 and b3==0:
    print("Close")
elif b1==0 and b2==1 and b3==0:
    print("Close")
elif b1==1 and b2==1 and b3==0:
    print("Open")
elif b1==0 and b2==0 and b3==1:
    print("Open")
else:
    print("Close")


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

using namespace std;

int solve(int N, const vector<int>& xs)
{
    int a = 0, b = 0;

    for (int i = 0; i < N; ++i)
        b += xs[i];

    int ans = b, L = 0;

    while (L < N)
    {
        int R = L;

        while (R < N and xs[R] == xs[L])
        {
            a += xs[R];
            b -= xs[R];
            ++R;
        }

        ans = min(ans, abs(b - a));
        L = R;
    }
 
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<int> xs(N);

    for (int i = 0; i < N; ++i)
        cin >> xs[i];

    auto ans = solve(N, xs);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int x,y;
  while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0)break;
    if(x>y)printf("%d %d\n",y,x);
    else{
      printf("%d %d\n",x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 600
# coding=UTF-8
from collections import deque
from operator import itemgetter
from bisect import bisect_left, bisect
import itertools
import sys
import math
import numpy as np
import time


def main():

    N = int(input())
    A = [int(i) for i in input().split()]
    D = set()
    S = set()
    for i in range(N):
        if A[i] in S:
            D.add(A[i])
        else:
            S.add(A[i])
    M = max(S)
    X = [1 for i in range(M+1)]
    for a in S:
        if a in D:
            X[a] = 0
        for i in range(2*a, M+1, a):
            X[i] = 0
    ans = 0
    for i in range(N):
        if X[A[i]] == 1:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 58288
#include <stdio.h>

int main(){

  int i, n, x, flag = 0;

  scanf("%d", &n);
 
  for(i = 3; i <= n; i++){
    x = i;
    if(x % 3 == 0){
      printf(" %d", i);
      flag = 1;
    }
    while(x != 0 && flag == 0){
      if (x % 10 == 3){
	printf(" %d", i);
	break;
      }
      x = x / 10;
    }
    flag = 0;
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 600
N=int(input())
A=list(map(int,input().split()))
from collections import Counter
counter=Counter(A)

odd=0
eve =0

for k  in counter.keys():
  if counter[k]%2==0:
    eve+=1
  else:
    odd+=1
ans=0
if eve%2==0:
  ans=eve+odd
else:
  ans=eve+odd-1
print(ans)

Measured memory_bytes: 18528
<?php
fscanf(STDIN,"%d",$a);
fscanf(STDIN,"%d",$b);
fscanf(STDIN,"%d",$c);
fscanf(STDIN,"%d",$x);
$count = 0;
for($i = 0; $i <= $a; $i++){
    for($j = 0; $j <= $b; $j++){
        $result = $x - ($i * 500 + $j * 100);
        if($result / 50 <= $c && $result >= 0){
           $count++;
        }
 }
}
print($count);
?>

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define mod 1000000007
#define MAX 20000000009
using namespace std;

int main(){
    cout << fixed << setprecision(15);
    // cout << 22.0 / 7.0 << endl;
    long double r;
    cin >> r;
    cout << 2.0 * (22.0 / 7.0) * r << endl;
}



Measured memory_bytes: 3788
#include <algorithm>
#include <cmath>
#include <iostream>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(void)
{

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

    long long n;
    cin >> n;

    vector<long> vec;
    long long inp;
    rep(i, n)
    {
        cin >> inp;
        vec.push_back(inp - 1 - i);
    }

    sort(vec.begin(), vec.end()); // vector

    long size = vec.size();
    long toru;
    long mid;

    if (size % 2 == 1) {
        mid =  vec[(size - 1) / 2];
    } else {
        mid = (vec[(size / 2) - 1] + vec[size / 2]) / 2;
    }

    //cout << mid;


    long sum = 0;
    rep(i,n){
        vec[i] -= mid;
        if(vec[i]<0) vec[i] *= -1;
        sum += vec[i];
    }

    cout << sum;

    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  int n;
  cin >> n;
  vector<int> b(n),ans(n);
  REP(i,n) cin >> b[i];
  int cnt=0;
  while(b.size()){
    bool flag= true;
    REPR(i,(int)b.size()-1){
      if(i+1==b[i]){
        ans[cnt]=b[i];
        b.erase(b.begin()+i);
        cnt++;
        flag = false;
        break;
      }
    }
    if(flag){
      cout << -1 << '\n';
      return 0;
    }
  }
  REPR(i,n-1) cout << ans[i] << '\n';
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int H = scan.nextInt();
			int W = scan.nextInt();

			if(H == 0 && W == 0){
				break;
			}else{
				for(int i = 1; i <= H; i++){
					String str = "";
					for(int j = 1; j <= W; j++){
						if((i == 1 || i == H) || (j == 1 || j == W)){
							str += "#";
						}else{
							str += ".";
						}
					}
					System.out.println(str);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 49880
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int S[1001];
int main()
{
	int n,m,ans;
	while(cin>>n>>m&&(n!=0||m!=0)){
		for(int i=1;i<=n;i++)cin>>S[i];
		int pos=1;
		for(ans=1;ans<=m;ans++){
			int d;cin>>d;
			pos+=d;
			if(pos>=n)break;
			pos+=S[pos];
			if(pos>=n)break;
		}
		for(int i=ans;i<m;i++)cin>>n;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
def main():
    N, A, B = map(int, input().split())
    s = 0
    for i in range(1, N+1):
        ss = 0
        num = str(i)
        for j in range(len(num)):
            ss += int(num[j])
        if A <= ss <= B:
            s += i
    print(s)
main()

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <string>
#include <memory>
#include <cmath>
#include <vector>
int main() {
	int n; std::cin >> n;
	std::vector<int> heights(n);
	for (auto& h : heights) std::cin >> h;
	std::vector<int> max_left(n, 0);
	for (auto i = 1; i < max_left.size(); ++i) max_left[i] = std::max(heights[i  - 1], max_left[i - 1]);
	auto count = 0;
	for (auto i = 0; i < n; ++i) {
		if (heights[i] >= max_left[i]) ++count;
	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,m,ans=1,max,num;
  cin >> n >> m;
  max = m/n;
  for(ll i=max;i>=1;i--){
    num = m - i*n;
    if(num%i==0){
      ans = i;
      break;
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256