akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

signed main(){
	int n;
	cin>>n;
	int a[n],s[n];
	rep(i,n){
		cin>>a[i];
		s[i]=((i+1)-a[i]);
	}
	int l=-1e10-1,r=1e10+1;
	while(l<r){
		int m=(l+r)/2;
		int s0=0,s1=0,s2=0;
		rep(i,n){
			s0+=abs((i+1+m)-a[i]);
		}
		rep(i,n){
			s1+=abs((i+1+m-1)-a[i]);
		}
		rep(i,n){
			s2+=abs((i+1+m+1)-a[i]);
		}
		if(s1<s0&&s0<s2)r=m;
		else l=m+1;
		if(s1>=s0&&s0<=s2)break;
	}
	int ans=1e17;
	for(int i=-10;i<10;i++){
		int sum=0;
		//_///cout<<l+i<<endl;
		rep(j,n){
			sum+=abs((j+1+l+i)-a[j]);
		}
		ans=min(sum,ans);
	}
	cout<<ans<<endl;
}

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

long long gcd(long long a, long long b) {
    long long x,y;
    if(a > b){
        y = b;
        x = a;
    }else{
        y = a;
        x = b;
    }

    return ((y==0)? x : gcd(y,x%y));
}

int main(){
    long long A,B;
    cin >> A >> B;

    cout << A*B/gcd(A,B) << endl;
}



Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
#include <assert.h>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };


int n, k, d;
int t[1111];

int main() {
	cin >> n >> k;
	rep(i, k) {
		int d;
		cin >> d;
		rep(j, d) {
			int tmp;
			cin >> tmp;
			t[tmp - 1]++;
		}
	}
	int cnt = 0;
	rep(i, n) {
		if (t[i] == 0)cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

int main(){
  int N, K;
  cin >>N>>K;
  int num[N] = {};

  for (int i = 0; i < N; i++) {
    int ball = 0;
    cin >> ball;
    num[ball-1]++;
  }

  sort(num, num + N, greater<int>());
  int ans = 0;
  for (int i = K; i < N; i++)ans += num[i];
  cout<<ans<<endl;

}



Measured memory_bytes: 1024
threeNums :: String -> [Int]
threeNums s@(x:xs)
  | length s >= 3 = (read $ take 3 s) : threeNums xs
  | otherwise = []

nearest :: [Int] -> Int
nearest = foldr1 min . map (abs . (753 - ))

calc :: String -> Int
calc = nearest . threeNums

main = do
  line <- getLine
  print $ calc line


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vii = vector<pair<int, int>>;

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 GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];

	for (int i = 0; i < n; ++i) {
		if (a[i] % 2 == 0) {
			if (a[i] % 3 == 0 || a[i] % 5 == 0) continue;
			else {
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	string a, b, c;
	cin >> a >> b >> c;
	string ans = a + b + c;
	if (ans == "557" || ans == "575" || ans == "755") {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n;
	int i;
	double money = 100000.0;
	double a;

	scanf("%d", &n);

	for (i = 1; i <= n; i++){
		money = money*1.05;
		a = (int)money % 1000;
		if (a != 0){
			money += 1000;
			money -= a;
		}
	}

	printf("%d\n", (int)money);

	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)
#include "string"

const int inf = 1e9;
int32_t main() { 
	boost;
	int n,m;
	cin>>n>>m;
	int N = (1<<n);
	int a[m];
	int msk[N];
	fill_n(msk,N,inf);
	for(int i=0;i<m;i++){
		cin>>a[i];
		int b,tt;
		cin>>b;
		int mask = 0;
		for(int j=0;j<b;j++){
			cin>>tt;
			tt--;
			mask |= (1<<tt);
		}
		msk[mask] = min(msk[mask],a[i]);
	}
	
	for(int mask = N-1;mask>=0;mask--){
		for(int i=0;i<n;i++){
			if(mask&(1<<i))
				msk[mask^(1<<i)] = min(msk[mask^(1<<i)],msk[mask]);
		}
	}
	msk[0]=0;

	for(int mask =1;mask<N;mask++){
		for(int i=1;i<mask;i++)
			msk[mask] = min(msk[mask],msk[i]+msk[mask^i]);
	}

	if(msk[N-1] == inf)
		cout<<-1<<endl;
	else
		cout<<msk[N-1]<<endl;
}	

Measured memory_bytes: 256
#include<stdio.h>
typedef unsigned long long int llu;
int main(void){
  llu a;
  llu x=(llu)0;
  scanf("%llu",&a);
  for(llu i=(llu)1;i<=a;i++){
    x=x+i;
    if(i%(llu)3==0){
      x=x-i;
    }
    else if(i%(llu)5==0){
      x=x-i;
    }else{
      x=x;
    }
  }
      printf("%llu\n",x);
  
  return 0;
}

Measured memory_bytes: 1732
MOD=10**9+7
N,K=map(int,input().split())

inv_table = [0]+[1]
for i in range(2,K+2):
  inv_table.append(-(MOD//i)*inv_table[MOD%i]%MOD)
  
term1=N-K+1
term2=1
for i in range(1,K+1):  
  #print(term1,term2)  
  print((term1*term2)%MOD)

  term1=term1*(N-K+1-i)*inv_table[i+1]%MOD
  term2=term2*(K-i)*inv_table[i]%MOD

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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int a[100];
int cells[100][100]; // r * c

ll GCD(ll x, ll y) {
  if (y == 0) return x;
  else return GCD(y, x % y);
}

int main() {
  ll A, B;
  cin >> A >> B;

  ll g = GCD(A, B);
  ll s = sqrt(g) + 1;
  ll ans = 1;
  ll temp = g;

  for(ll i = 2; i * i <= g; i++) {
    if (temp % i == 0) {
      while (temp % i == 0) {
        temp /= i;
      }
      ans++;
    }
    if (temp == 1) break;
  }
  if (temp != 1) ans++;

  cout << ans << BR;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

constexpr int LIM = 10000001;
char h[LIM];
int sh[LIM];

bool solve() {
    int m, n;
    cin >> m;
    if (m == 0) { return false; }
    cin >> n;
    cout << (sh[n] - sh[m-1]) << endl;
    return true;
}

int main() {
    h[1] = 1;
    sh[0] = 0;
    for (int j = 1; j < LIM; ++j) {
        if (j % 2 == 0) { h[j] |= h[j/2]; }
        if (j % 3 == 0) { h[j] |= h[j/3]; }
        if (j % 5 == 0) { h[j] |= h[j/5]; }
        sh[j] = sh[j-1] + h[j];
    }
    while(solve());
    return 0;
}

Measured memory_bytes: 51924
#include <iostream>
#include <cstdio>

using namespace std;

int main(void) {

    int a, b;
    cin >> a >> b;

    if (a < b) {
        puts("a < b");
    }
    else if (a > b) {
        puts("a > b");
    }
    else {
        puts("a == b");
    }

    return 0;
}

Measured memory_bytes: 1116
from heapq import heapify, heappushpop

N, *A = map(int, open(0).read().split())

Q = A[:N]
heapify(Q)

R = [sum(Q)]
for a in A[N:2 * N]:
    R.append(R[-1] + a - heappushpop(Q, a))

Q = [-a for a in A[2 * N:]]
heapify(Q)

B = [sum(Q)]
for a in reversed(A[N:2 * N]):
    B.append(B[-1] - a - heappushpop(Q, -a))

print(max(r + b for r, b in zip(R, reversed(B))))


Measured memory_bytes: 36308
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int  n;
double a[100005],last;
//bool cmp(double a,double b){
//	return a<b;
//}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	last=a[1];
	for(int i=2;i<=n;i++){
		last= (double) (a[i]+last)/2;
	}
	cout<<last;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
s = [tuple(map(int, input().split())) for _ in range(N)]
c = [tuple(map(int, input().split())) for _ in range(M)]
for i in range(N):
    mn = [abs(s[i][0]-c[j][0])+abs(s[i][1]-c[j][1]) for j in range(M)]
    print(mn.index(min(mn))+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

int main(){
    string N;
    cin>>N;
    if(N[N.size()-1]=='3'){cout<<"bon";}
    else if(
    N[N.size()-1]=='0'
    ||N[N.size()-1]=='1'
    ||N[N.size()-1]=='6'
    ||N[N.size()-1]=='8'){cout<<"pon";}
    else cout<<"hon";
    return 0;
}

Measured memory_bytes: 3628
b = int(input())

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

co = 0
s = 0
ss = 0

for i in range(len(a)):
  while a[i] % 2 == 0:
    co += 1
    a[i] //= 2
  if co == 1:
    s += 1
  elif co >= 2:
    ss += 1
  co = 0
  
b -= s

if b % 2 == 1 and s > 0:
  b += 1
elif b % 2 == 1 and s == 0:
  b -= 1
b //= 2

if ss >= b:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i*4 <= n; i++) {
    if ((n-i*4)%7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <limits>
typedef long long ll;
#define REP(i,n)   for(int i=0; i<(int)(n); ++i)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); ++i)

#define in cin
#define out cout
#define pb push_back
using namespace std;

int main(){
	int a, b, c, d, e;
	in >> a >> b >> c >> d >> e;
	int ac = a*e,bc=b;
	if (e > c)bc += (e - c)*d;


	
	out << min(ac,bc) << endl;
	return 0;

}

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

using namespace std;

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

  long left = 0;
  long ans = 0;
  for (int i = 0; i < n; i++) {
    long a;
    cin >> a;
    if (a < left)
      ans += left - a;
    left = max(left, a);
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		int[] A = new int[50];
		int[] B = new int[50];
		int[] C = new int[50];
		while (sc.hasNext()) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			for (int i = 0; i < n; ++i) {
				C[i] = n - i - 1;
			}
			for (int i = 0; i < r; ++i) {
				int c = sc.nextInt();
				for (int j = 0; j < (n + 1) / 2; ++j) {
					A[j] = C[j];
				}
				for (int j = 0; j < n / 2; ++j) {
					B[j] = C[(n + 1) / 2 + j];
				}
				int ap = (n + 1) / 2;
				int bp = n / 2;
				int cp = n;
				while (ap > 0 || bp > 0) {
					for (int j = 0; j < c && ap > 0; ++j) {
						C[--cp] = A[--ap];
					}
					for (int j = 0; j < c && bp > 0; ++j) {
						C[--cp] = B[--bp];
					}
				}
			}
			System.out.println(C[0]);
		}
	}

}

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

using namespace std;

struct proc {
    int time;
    string name;
};

int head = 0, tail = 0;
struct proc queue[1000000];

struct proc dequeue() {
    return queue[head++];
}

void enqueue(proc p) {
    queue[tail++] = p;
}

int count(){
    return tail - head;
}

int main() {
    int n, q, i;
    scanf("%d", &n);
    scanf("%d", &q);

    for(i=0;i<n;i++){
        proc p;
        cin >> p.name;
        cin >> p.time;
        enqueue(p);
    }

    int time = i = 0;
    while (count()>0) {
        proc p = dequeue();
        if(p.time<=q){
            time += p.time;
            cout << p.name << " " << time << endl;
        }else{
            p.time -= q;
            enqueue(p);
            time += q;
        }
    }

}


Measured memory_bytes: 21184
#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int a[2020];
bool ok(int M) {
	for (int i = 0; i < n; i++) {
		int z = 0, c = 0;
		for (int j = 0, k; j < n; j = k + 1) {
			for (k = j; k < n; k++) {
				if (a[k] < a[i]) {
					break;
				}
				if (a[k] <= a[i] + M) {
					c++;
				}
			}
			if (k - j >= m) {
				z += min(k - j - m + 1, c);
			}
			c = 0;
		}
		if (z >= q) {
			return true;
		}
	}
	return false;
}
int main() {
	scanf("%d%d%d", &n, &m, &q);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int L = -1, R = 1e9;
	while (L < R - 1) {
		int M = (L + R) / 2;
		if (ok(M)) {
			R = M;
		} else {
			L = M;
		}
	}
	printf("%d\n", R);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

int main(){
	int ans=0;
	for(int i=0; i<5; ++i){
		int tmp;
		cin >> tmp;
		if(tmp<40) tmp=40;
		ans+=tmp;
	}
	cout << ans/5 << "\n";
	return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s1, s2;

    while(true){
        //scanf("%s %s", s1, s2);
        cin >> s1 >> s2;
        if(s2 == "X") break;

        if(s2 == "D"){
            for(int i = 1; i < s1.size(); i++){
                if(isupper(s1[i])) s1.insert(i++, "_");
            }
            for(int i = 0; i < s1.size(); i++){
            s1[i] = tolower(s1[i]);
            } 
            cout << s1 << endl;
        }
        else{
            for(int i = 0; i < s1.size(); i++){
                if(s1[i] == '_'){
                    s1[i + 1] = toupper(s1[i + 1]);
                    s1.erase(i, 1);
                }
            }     
            if(s2 == "U"){
                s1[0] = toupper(s1[0]);
                cout << s1 << endl;
            }
            else{
                s1[0] = tolower(s1[0]);
                cout << s1 << endl;
            }
        }
    }
}


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


int main(){


    string t, f;

 
    cin >> t >> f;


    if( t.at(0) == f.at(2) && t.at(1) == f.at(1) && t.at(2) == f.at(0) ) cout << "YES" << endl;

    else cout << "NO" << endl;
         

    return 0;


    }

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
  int i;
  char S[3][7]={"Sunny","Cloudy","Rainy"};
  char s[7];
  scanf("%s", s);
  for(i=0; i<3; i++){
    if(strcmp(s,S[i])==0 && strcmp(S[2],s)!=0){
      printf("%s",S[i+1]);
    }
    else if(strcmp(S[2],s)== 0){
      printf("%s",S[0]);
      break;
  }
  }
  return 0;
}

Measured memory_bytes: 128
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.List (unfoldr, sort, foldl1')
import Control.Monad
import qualified Data.ByteString.Char8 as BS

main = do
  n <- readLn :: IO Int
  xs <- sort . unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let result :: Double
      result = foldl1' (\x y -> (x + y) / 2) $ map fromIntegral xs
  print result


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


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

	int ans = 0;
	for (int i = 0; i < n - 2; i++) {
		if (p[i] < p[i + 1] and p[i + 1] < p[i + 2]) ans++;
		else if (p[i + 2] < p[i + 1] and p[i + 1] < p[i]) ans++;
	}

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


Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>
#define _USE_CMATH_DEFINES

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

//gcd(Euclid's algorithm)
long gcd(long num1, long num2){
	if(num2 > num1){
		std::swap(num1, num2);
	}
	if(num2 == 0){
		return num1;
	}else{
		return gcd(num2, num1 % num2);
	}
}
long lcm(long x, long y){
    return x * y / gcd(x, y);
}

int main(){
    long n;
    scanf("%ld", &n);
    long l = 1;
    for(int i = 0; i < n; i++){
        long a;
        scanf("%ld", &a);
        l = lcm(l, a);
    }
    printf("%ld\n", l);
}



Measured memory_bytes: 3232
from itertools import product as pr
n,m,x=[int(i) for i in input().split()]
l=[[int(i) for i in input().split()]for j in range(n)]
p=list(pr([0,1],repeat=n))
suml=[[sum([l[j][k]*i[j] for j in range(n)])for k in range(m+1)]for i in p]
ans=[i[0] for i in suml if all([i[j] >=x for j in range(1,m+1)])]
if len(ans)==0:
  print(-1)
else:
  print(min(ans))

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

using namespace std;

int main()
{
  int n;

  while(cin >> n, n){
    int mini = 114514, maxi = -114514;
    int sum = 0;

    for(int i = 0; i < n; i++){
      int s;
      cin >> s;
      sum += s;
      mini = min(mini, s);
      maxi = max(maxi, s);
    }
  
    cout << (sum - mini - maxi) / (n - 2) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,m;
  cin >> n >> m;
  vector<int> a(m);
  rep(i,m) cin >> a.at(i);
  ll sum = 0;
  rep(i,m) sum+=a.at(i);
  if(n-sum>=0){
    cout << n-sum << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a.at(i);
 
	sort(a.begin(), a.end());

 	int i = 0;
	int sum = 0;
	while (i < n) {
		sum += a.at(i);
		if (sum > x) break;
		i++;
	}

	if (sum >= x) cout << i << endl;
	else cout << i - 1 << endl;

 	return 0;
 }

Measured memory_bytes: 256
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)

A.sort()
B.sort()

if N % 2 == 0:
    l = A[N // 2 - 1] + A[N // 2]
    u = B[N // 2 - 1] + B[N // 2]
    print(u - l + 1)
else:
    l = A[N // 2]
    u = B[N // 2]
    print(u - l + 1)


Measured memory_bytes: 104864
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
int main() {
	int n;
	cin >> n;
	cout << (1 + n) * n / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c, d = map(int, input().split())

if b <= c or d <= a:
    print(0)
elif a <= c and d <= b:
    print(d - c)
elif c <= a and b <= d:
    print(b - a)
elif a <= c:
    print(b - c)
else:
    print(d - a)

Measured memory_bytes: 61780
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    string S;
    cin >> S;
    vector<int> dp1(SZ(S), 0), dp2(SZ(S), 0);
    dp1[SZ(S) - 1] = S[SZ(S) - 1] - '0';
    dp2[SZ(S) - 1] = 10 - (S[SZ(S) - 1] - '0');
    for (int i = SZ(S) - 2; i >= 0; --i) {
        int n = S[i] - '0';
        dp1[i] = min(n + dp1[i + 1], n + 1 + dp2[i + 1]);
        dp2[i] = min(10 - n + dp1[i + 1], 9 - n + dp2[i + 1]);
    }
    cout << min(dp1[0], dp2[0] + 1) << "\n";
    return 0;
}


Measured memory_bytes: 12072
#include<bits/stdc++.h>
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
   //freopen("in.txt", "r", stdin);
#endif
   int i, j, k;

   while (cin >> i >> j) {
      if (i % j == 0)
         cout << -1 << endl;
      else {
         for (k = 2 * i; ; k += i) {
            if (k % j != 0) {
               cout << k << endl;
               break;
            }
         }
      }
   }

   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Odds_of_Oddness(void) {

	int N; cin >> N;
	
	cout << setprecision(20) << (double)((N + N % 2) / 2) / (double)N << flush;
	return;
}

int main(void) {

	A_Odds_of_Oddness();
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static char[] s;
    static int w;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        int n = s.length;
        int i = 1;
        int cnt = 1;

        System.out.print(s[0]);
        while(true) {
            cnt = i*w;
            i++;
            if(cnt >= n) break;
            System.out.print(s[cnt]);
        }

        print("");
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        s = in.next().toCharArray();
        w = in.nextInt();
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

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

class E {
    int from, to;
    long w;
    E(int from, int to, long w) {
        this.from = from;
        this.to = to;
        this.w = w;
    }
}


Measured memory_bytes: 21972
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[10000][10000],a[200000], b[2000000];
string str;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		a[i] -= i;
	}
	sort(a, a + n);
	if (n % 2) {
		rep(i, n) {
			cnt += abs(a[i] - a[n / 2]);
		}
		ans = cnt;
	}
	else {
		ans = INF;
		rep(i, n) {
			cnt += abs(a[i] - (a[n / 2]+a[n/2+1])/2);
		}
		ans = min(cnt, ans);
		rep(j, 3) {
			cnt = 0;
			rep(i, n) {
				cnt += abs(a[i] - (a[n / 2] + a[n / 2 -1]) / 2 - j + 1);
			}
			ans = min(cnt, ans);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Util{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		int[] xArray = ria();

        for (int i = 0; i < 5; i++)
        {
            if(xArray[i] == 0) {
		        Console.WriteLine(i + 1);
		        Console.ReadLine();
                return;
            }
        }
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
    static int[] generateNums(int num, int N){return Enumerable.Repeat(num, N).ToArray();}
    static int[] generateSuretsu(int N){return Enumerable.Range(0, N).ToArray();}
}

public static class Combination {
	//使い方:int[][] Is = Combination.Enumerate(nums, k, withRepetition:false).ToArray();
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition) {
        if (k == 1) {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items) {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition)) {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}


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

string Reverse(string s)
{
  string ans;
  for(int i = s.size()-1; i >= 0; i--)
    ans += s.at(i);
  return ans;
}

bool kaibun(string s)
{
  string s_rev = Reverse(s);
  if(s == s_rev) return true;
  else return false;
}

int main()
{
  string S; cin >> S;
  int N = S.size();
  string str1 = S.substr(0, (N-1)/2);
  string str2 = S.substr((N+3)/2-1, (N-1)/2);
  if(kaibun(str1) && kaibun(str2) && kaibun(S))
    cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int n;
	cin >> n;
	set<int> s;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		s.insert(a);
	}

	if (s.size() % 2 == 1) {
		cout << s.size() << endl;
	} else {
		cout << s.size() - 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main(void){

    int x[5];

    scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
    // printf("%d %d %d %d %d\n",x[0],x[1],x[2],x[3],x[4]);

    for (int i=0;i<5;i++){
        if (x[i]==0){
            printf("%d\n",i+1);
            break;
        }
    }

    return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    print(x, y, z);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <iomanip>
#include <random>
#include <ctime>
#include <bitset>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <cstring>
#include <queue>
#include <deque>
#include <list>
#include <stack>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define ld long double
#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define fast_io cout.tie(0), cin.tie(0), ios_base::sync_with_stdio(0)
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ll fnd(ll a, ll n)
{
    ll i, s = 1, t = 1;
    for (i = n - a + 1; i <= n; i++)
        s *= i, s %= mod1;
    for (i = 1; i <= a; i++)
        t *= i, t %= mod1;
    t = binpow(t, mod1 - 2, mod1);
    return (t * s) % mod1;
}

int main()
{
    //freopen("race.in", "r", stdin), freopen("race.out", "w", stdout);
    fast_io;
    ll n, a, b, tm, t1, t2;
    cin >> n >> a >> b;
    tm = binpow(2, n, mod1);
    tm = (tm - 1 + mod1) % mod1;
    t1 = fnd(a, n);
    t2 = fnd(b, n);
    cout << (tm - t1 - t2 + 2 * mod1) % mod1;
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

int main() {
  ioinit();
  int n; cin >> n;
  vi32 v(n), c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  int ans = 0;
  rep(i, n) ans += max(0, v[i] - c[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
($H,$W)=glob<>;
$$_++for`dd`=~/./g;
${$$_-=4,$F++while$$_>=4}for a..z;
${$$_-=2,$T++while$$_>=2}for a..z;
${$$_-=1,$O++while$$_>=1}for a..z;
if($H%2&&$W%2){
	print$O==1&&$F>=($H-1)*($W-1)/4?Yes:No
}elsif($H%2){
	print$O==0&&$F>=($H-1)*$W/4?Yes:No
}elsif($W%2){
	print$O==0&&$F>=$H*($W-1)/4?Yes:No
}else{
	print$O==0&&$T==0?Yes:No
}


Measured memory_bytes: 1864
#include <stdio.h>

void bubble(int n,int A[]);

int count=0;

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

  bubble(n,&A[0]);

  for(i=0;i<n;i++){
  if(i!=0)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d",count);
  printf("\n");
  
  return 0;
}

void bubble(int n,int A[]){
  int i,j;
  int key;
  
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j] < A[j-1]){
	key = A[j];
	A[j] = A[j-1];
	A[j-1] = key;
	++count;
      }
    }
  }
return 1;
}

Measured memory_bytes: 604
N=int(input())
S=input()

ans=0

for i in range(10):
  if str(i) in S:
    a = S.find(str(i))
    for j in range(10):
      if str(j) in S[a+1:]:
      	b = S[a+1:].find(str(j))
      	for k in range(10):
          if str(k) in S[a+b+2:]:
            ans+=1

print(ans)

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

int main()
{
    int k, n, i, ans;
    cin >> k;
    cin >> n;
    int km[n];
    for(i = 0;i < n;i++){
        cin >> km[i];
    }
    int max = 0;
    for(i = 0;i < n-1;i++){
        if(max < km[i+1] - km[i]){
            max = km[i+1] - km[i];
        }
    }
    if(max < k + km[0] - km[n-1]){
        max = k + km[0] - km[n-1];
    }

    ans = k - max;

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

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <queue>

using namespace std;

bool solve(const vector<int>& a){
	const int N = a.size();
	vector<int> cnt(N+1, 0);
	for(auto& t : a) ++cnt[t];
	for(int c=1;c<=N;c++){
		if(cnt[c]+cnt[c-1] != N) continue;
		int restColor = c - cnt[c-1];
		if(restColor < 0) continue;
		if(cnt[c] > 0){
			if(restColor == 0) continue;
			if(cnt[c] < 2 * restColor) continue;
		}
		return true;
	}
	return false;
}

int main(){
	int N;
	while(cin >> N){
		vector<int> a(N);
		for(auto& t : a) cin >> t;
		cout << (solve(a) ? "Yes" : "No") << endl;
	}
}


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


int main() {
  long long int n,k;cin>>n>>k;
  long long msum=0;
  vector<pair<long long,long long>> ab(n);
  for(long long int i=0;i<n;i++){
    long long int a,b;cin>>a>>b;
  	ab[i]=make_pair(a,b);
  }
  
  sort(ab.begin(),ab.end());
  for(long long int i=0;i<n;i++){
  	msum+=ab[i].second;
    if(msum>=k){
    	cout<<ab[i].first<<endl;
      	return 0;
    }
  }
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,c;
int d[40][40];
int x;
int cnt[3][40];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>c;
	for(int i=1;i<=c*c;i++){
		cin>>d[(i+c-1)/c][(i-1)%c+1];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>x;
			cnt[(i+j)%3][x]++;
		}
	}
	int res=1e9;
	for(int i=1;i<=c;i++){
		for(int j=1;j<=c;j++){
			for(int k=1;k<=c;k++){
				if(i==j||i==k||j==k)
					continue;
				int cand=0;
				for(int l=1;l<=c;l++){
					cand+=cnt[0][l]*d[l][i];
				}
				for(int l=1;l<=c;l++){
					cand+=cnt[1][l]*d[l][j];
				}
				for(int l=1;l<=c;l++){
					cand+=cnt[2][l]*d[l][k];
				}
				res=min(res,cand);
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int main() {
	
	scanf("%d",&n);
	
	int maxx=0;
	for(int i=1;i<=n;i++) {
		int x;
		scanf("%d",&x);
		if (x>=maxx) ans++;
		maxx=max(maxx,x);
	}
	
	printf("%d",ans);
	return 0;
}

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

int main() {
    int n,T;
    ll ans=0;
    cin>>n>>T;
    vector<int> t(n);
    rep(i,n) {
        cin>>t[i];
    }
    int before=t[0];
    int end=before+T;
    for (int i=1; i<n; i++) {
        if (t[i]-t[i-1]<=T) {
            end=t[i]+T;
        }
        else {
            ans+=end-before;
            before=t[i];
            end=before+T;
        }
    }
    ans+=end-before;
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a,b,c;
	string s="NO";
	cin >> a; cin >> b; cin >> c;
	//a[0]==a[2]?cout << "Yes"<< endl: cout << "No" << endl;
	if ((a * 100 + b * 10 + c) % 4 == 0)s = "YES";
	cout << s << endl;
	
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(r, g, b, n int) int {
        c := 0
        for i := 0; i <= n; i++ {
                for j := 0; j <= n; j++ {
                        v := r*i + g*j
                        if n >= v && (n-v)%b == 0 {
                                c++
                        }
                }
        }
        return c
}

func main() {
        var r, g, b, n int
        fmt.Scan(&r, &g, &b, &n)
        fmt.Println(solution(r, g, b, n))
}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,m,l,s,t,d[301][301],x[20],tim[20],dl[20][20],dp[1<<16][16],a,b,c;
main(){
  while(cin>>n>>m>>l>>s>>t,n){
    r(i,(1<<l))r(j,16)dp[i][j]=1e8;
    int ans=0;s--;
    r(i,n)r(j,n)d[i][j]=1e8;
    r(i,m){
      cin>>a>>b>>c;
      d[--a][--b]=d[b][a]=c;
    }
    r(i,l)cin>>x[i]>>tim[i],x[i]--;
    r(k,n)r(i,n)r(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    r(i,l)r(j,l)dl[i][j]=d[x[i]][x[j]]+tim[j];
    r(i,l)dp[(1<<i)][i]=d[s][x[i]]+tim[i];
    r(i,(1<<l))r(j,l)if((1<<j)&i)r(k,l)if(j!=k&&dl[j][k]&&((1<<k)&i)==0)
      if(dl[j][k]+dp[i][j]<=t)dp[i|(1<<k)][k]=min(dp[i|(1<<k)][k],dp[i][j]+dl[j][k]);
    r(i,(1<<l))r(j,l)if(dp[i][j]+d[x[j]][s]<=t)ans=max(ans,__builtin_popcount(i));
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 7444
def hersCode(L, n):
  if n >= L[-1]:
    return -1
  ok = len(L) - 1
  ng = -1
  while abs(ok - ng) > 1:
    mid = abs(ok + ng) // 2
    if L[mid] > n:
      ok = mid
    else:
      ng = mid
  return ok


s = list(input())
t = list(input())

R = {}

for i in t:
  if i not in R:
    R[i] = []
    flag = True
    for j in range(len(s)):
      if i == s[j]:
        R[i].append(j)
        flag = False
    if flag:
      print(-1)
      exit()

num = -1
cnt = 0

for i in t:
  t = hersCode(R[i], num)
  if t == -1:
    num = -1
    cnt += 1
    t = hersCode(R[i], num)
  num = R[i][t]
print(cnt * len(s) + num + 1)

Measured memory_bytes: 8692
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
using namespace std;
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

bool vector_find(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) {
        return true;
    }
    else {
        return false;
    }
}


int main(void){
    double result;
    double T, X;
    cin >> T >> X;
    result = T / X;
    
    cout << result << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class SWAG:
  def __init__(self,func,ide):
    self.ide = ide
    self.func = func
    self.front = []
    self.back = []
  
  def push(self,x):
    # 累積の結果を残す
    if self.back: y = self.func(self.back[-1][1],x)
    else: y = x
    self.back.append((x,y))
  
  def pop(self):
    if not self.front:
      while self.back:
        x,y = self.back.pop()
        if self.front: y = self.func(self.front[-1][1],x)
        else: y = x
        self.front.append((x,y))
    return self.front.pop()[1]
  
  def fold_all(self):
    y = self.ide
    if self.front: y = self.func(self.front[-1][1],y)
    if self.back: y = self.func(self.back[-1][1],y)
    return y
ans = []
n,l = map(int,input().split())
data = list(map(int,input().split()))
swag = SWAG(min,inf)
for i in range(l-1):
  swag.push(data[i])
for i in range(l-1,n):
  swag.push(data[i])
  ans.append(swag.fold_all())
  swag.pop()
print(*ans)



Measured memory_bytes: 120596