akhauriyash/Code-Regression huggingface dataset:
#include<iostream> 
using namespace std;

int main(){
  int K;
  int A, B;
  cin >> K >> A >> B;
  bool div = false;
  
  for (int i = A; i <= B; ++i){
    if (i % K == 0) {
      div = true;
      break;
    }
  }
  if (div) cout << "OK" << endl;
  else cout << "NG" << endl;
}
  

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

int n;
long dp[101][4*4*4];
long a[4*4*4][4*4*4];
long ans;
const long MOD = 1e9 + 7;
const string c[4] = {"A", "G", "C", "T"};
string s1, s2;
const vector<string> ng3 = {"AGC", "GAC", "ACG"};
const vector<string> ng4 = {"AGGC", "ACGC", "ATGC", "AGAC", "AGGC", "AGTC"};
vector<string>::const_iterator p;

void quad2dec(long n, long& a1, long& a4, long& a16){
	a16 = n / 16; n %= 16;
	a4 = n / 4; n %= 4;
	a1 = n;
}

string quad2str(long n){
	long i, j, k;
	quad2dec(n, i, j, k);
	return (c[i] + c[j] + c[k]);
}

int main(){
	cin >> n;
	fill(dp[0], dp[101], 0);
	fill(dp[2], dp[2]+sizeof(dp[2])/sizeof(long), 1);
	fill(a[0], a[4*4*4], 0);

	for (int i = 0; i < 4*4*4; ++i){
		s1 = quad2str(i);
		for (int j = 0; j < 4*4*4; ++j){
			s2 = quad2str(j);
			if (s1.substr(1, 2) == s2.substr(0, 2)){
				p = find(ng3.begin(), ng3.end(), s1.substr(1, 2) + s2.substr(2, 1));
				if (p != ng3.end()) continue;
				p = find(ng3.begin(), ng3.end(), s1);
				if (p != ng3.end()) continue;
				p = find(ng3.begin(), ng3.end(), s2);
				if (p != ng3.end()) continue;
				p = find(ng4.begin(), ng4.end(), s1 + s2.substr(2, 1));
				if (p != ng4.end()) continue;
				a[i][j]++;
			}
		}
	}

	for (int i = 0; i < 4*4*4; ++i){
		p = find(ng3.begin(), ng3.end(), quad2str(i));
		dp[3][i] = (p == ng3.end()) ? 1 : 0;
	}

	for (int i = 4; i <= n; ++i){
		for (int j = 0; j < 4*4*4; ++j){
			dp[i][j] = 0;
			for (int k = 0; k < 4*4*4; ++k){
				(dp[i][j] += dp[i-1][k]*a[k][j]) %= MOD;
			}
		}
	}

	ans = 0;
	for (int j = 0; j < 4*4*4; ++j){
		(ans += dp[n][j]) %= MOD;
	}
	cout << ans << endl;

	// for (int i = 0; i < 64; ++i){
	//     for (int j = 0; j < 64; ++j){
	//         cout << a[j][i] << " ";
	//     }
	//     cout << endl;
	// }
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

struct Node {
    ll key;
    Node *parent, *left, *right;
};
Node *NIL, *root;

void insert(ll k){
    Node *y = NIL;   // xの親
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));   // Node分のポインタの容量をとる
    z->key = k; z->left = NIL; z->right = NIL;

    while(x != NIL){
        y = x;  // 親を設定
        if((z->key) < (x->key)){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if(y == NIL) root = z;
    else if(y->key > z->key) y->left = z;
    else y->right = z;
}

Node * treeMinimum(Node * x){
    while(x->left != NIL){
        x = x->left;
    }
    return x;
}

Node * treeSuccessor(Node *z){
    if(z->right != NIL){
        return treeMinimum(z->right);
    }

    Node *y = z->parent;
    while(y != NIL && y->right == z){
        z = y;
        y = y->parent;
    }
    return y;
}

Node * find(ll k){
    Node *x = root;
    while(x != NIL){
        if(x->key == k) break;
        if(x->key < k) x = x->right;
        else x = x->left;
    }
    return x;
}

void deleteNode(ll k){
    // 削除する対象を節点yとする
    Node *z = find(k); Node * y;
    if(z->left == NIL || z->right == NIL){
        y = z;    // zが子を持たないか、子を1つだけ持つ場合は入力節点のz
    }else{
        y = treeSuccessor(z);  // zが2つ子を持つ場合はzの次節点
    }
    // yの子xを決める
    Node * x;
    if(y->left != NIL) x = y->left;
    else x = y->right;

    if(x != NIL) x->parent = y->parent; // xの親を設定
    if(y->parent == NIL) root = x;
    else if(y->parent->left == y) y->parent->left = x;
    else y->parent->right = x;

    if(y != z) z->key = y->key; // zの次節点が削除された場合、yのデータをzにコピーする
}

void preorder(Node *n){
    if(n == NIL) return;
    printf(" %ld", n->key);
    preorder(n->left);
    preorder(n->right);
}

void inorder(Node *n){
    if(n == NIL) return;
    inorder(n->left);
    printf(" %ld", n->key);
    inorder(n->right);
}

int main()
{
    int m; cin >> m;
    rep(i,m){
        string c; cin >> c;
        if(c == "insert"){
            ll k; cin >> k;
            insert(k);
        }else if(c == "print"){
            inorder(root); cout << endl;
            preorder(root); cout << endl;
        }else if(c == "find"){
            ll k; cin >> k;
            if(find(k) != NIL) cout << "yes" << endl;
            else cout << "no" << endl;
        }
        else if(c == "delete"){
            ll k; cin >> k;
            deleteNode(k);
        }
    }
}


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

#define ll long long int
#define uul unsigned long long int
#define ui uint64_t
#define max(a,b) (a>b)?a:b
#define min(a,b) (a<b)?a:b
#define ma 1000000007

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

    return 0;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int lc, dc, mc, n;
int l, d, m;
int F(int h, int mi) {
	if(h < 11) h += 24;
	return h * 60 + mi;
}
int lx, ly, dx, dy, mx, my;
void ins(int h, int mi, int lsm) {
	//cout<<h<<" "<<mi<<" "<<lsm<<endl;
	//if(h == 24) while(1);
	int lsh = h;
	if(lsm < mi) lsh++;
	int s = F(h, mi), e = F(lsh, lsm);
	if(s >= lx && s <= ly) {
		l ++;
		if(e - s <= 8) lc++;
	}
	if(s >= dx && s <= dy) {
		d ++;
		if(e - s <= 8) dc++;
	}
	if(s >= mx && s <= my) {
		m ++;
		if(e - s <= 8) mc++;
	}
	//cout<<lc<<" "<<l<<endl;
}
int main() {
	lx = F(11, 0), ly = F(14, 59);
	dx = F(18, 0), dy = F(20, 59);
	mx = F(21, 0), my = F(1, 59);
	while(~scanf("%d", &n)) {
		if(n == 0) break;
		lc = dc = mc = 0;
		l = d = m = 0;
		for(int i = 0; i < n; i++) {
			int a, b, c;
			scanf("%d:%d%d", &a, &b, &c);
			ins(a, b, c);
		}
		//cout<<lc<<" "<<l<<" "<<dc<<" "<<d<<" "<<mc<<" "<<m<<endl;
		printf("lunch");
		if(l == 0) {
			puts(" no guest");
		} else {
			printf(" %d\n", lc * 100 / l);
		}

		printf("dinner");
		if(d == 0) {
			puts(" no guest");
		} else {
			printf(" %d\n", dc * 100 / d);
		}
		printf("midnight");
		if(m == 0) {
			puts(" no guest");
		} else {
			printf(" %d\n", mc * 100 / m);
		}
	}
	return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>

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

int main()
{
  int x = 1, y = 1, z = 1, a1, a2, a3, m1, m2, m3, cx, cy, cz;
  long long p;

  while(1){
    cx = 0;
    cy = 0;
    cz = 0;
    scanf("%d %d %d %d %d %d", &a1, &m1, &a2, &m2, &a3, &m3);
    if(a1 == 0 && a2 == 0 && a3 == 0 && m1 == 0 && m2 == 0 && m3 == 0){
      break;
    }
    while(1){
      x = (x * a1) % m1;
      cx++;
      if(x == 1){
        break;
      }
    }
    while(1){
      y = (y * a2) % m2;
      cy++;
      if(y == 1){
        break;
      }
    }
    while(1){
      z = (z * a3) % m3;
      cz++;
      if(z == 1){
        break;
      }
    }
    p = cx * cy / gcd(cx, cy);
    printf("%lld\n", p * cz / gcd(p, cz));
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  string S;

  cin >> S;

  if (S[2] == S[3] && S[4] == S[5]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES 
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <unordered_set>
#include <iomanip>
#include <cmath>
#include <set>
#include <locale>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
using Graph = vector<vector<int>>;
//cout << fixed << setprecision(6);
//cout << setfill('0') << right << setw(2);


int main() {
	int ans1 = 0, ans2 = 0;
	string s;
	cin >> s;
	int n = s.length();
	rep(i, n) {
		if ((i % 2 == 0 && s[i] == '1') || (i % 2 && s[i] == '0')) ans1++;
		if ((i % 2 == 0 && s[i] == '0') || (i % 2 && s[i] == '1')) ans2++;
	}
	cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{VecDeque, HashSet, BTreeSet, BinaryHeap};
#[allow(unused_imports)]
use std::io::{stdin, stdout, Write};


fn main() {
    let n: usize = read();
    let colors = read_vector::<usize>();

    let mut former = 0;
    let mut count = 0;
    for i in 0..n {
        if colors[i] == former {
            count += 1;
            former = 0;
        } else {
            former = colors[i];
        }
    }

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

#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .trim()
        .parse()
        .unwrap();
}

#[allow(dead_code)]
fn read_vector<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    return buf
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect();
}

#[allow(dead_code)]
fn read_matrix<T>() -> Vec<Vec<T>> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    use std::io::prelude::*;
    let stdin = stdin();
    return stdin
        .lock()
        .lines()
        .map(|line| line
            .unwrap()
            .split_whitespace()
            .map(|s| s.parse().unwrap())
            .collect())
        .collect();
}

Measured memory_bytes: 4352
import sys, math

class Eratos(object):
    def __init__(self, N):
        self.N = N
        self._primes = {i:True for i in range(2, N+1)}

    def filter(self):
        end = self.N
        if self.N > 5:
            end = math.ceil(self.N**0.5) + 1
        for n in range(2, end):
            if not self._primes[n]:
                continue
            for x in range(n*2, self.N+1, n):
                if x in self._primes:
                    self._primes[x] = False
    
    def primes(self, x):
        return [k for k,v in self._primes.items() if v == True and k <= x]

def run():
    e = Eratos(999999)
    e.filter()
    for _n in sys.stdin:
        N = int(_n)
        print(len(e.primes(N)))

if __name__ == '__main__':
    run()




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

void testCase(){
    long long k;
    cin>>k;
    queue<long long> q;
    for(long long i = 1; i <= 9; i++) q.push(i);
    while(--k){
        long long val = q.front();
        q.pop();

        if(val % 10 != 0) q.push(10 * val + val % 10 - 1);
        q.push(10 * val + val % 10);
        if(val % 10 != 9) q.push(10 * val + val % 10 + 1);
    }
    cout<<q.front()<<endl;
}

int main(){
    int t;
    t = 1;
    // cin>>t;
    while(t--){
        testCase();
    }
}



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

#define REP(i, start, count) for (int i = (start); i < (int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;


string S;
int main(void)
{
    cin >> S;

    if (S[2] == S[3] && S[4] == S[5]) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
	int n; cin>>n;
	int x[200020], y[200020];
	int id[200020];
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i];
		x[i]--; y[i]--;
		id[x[i]]=i;
	}
	vector<P> v;
	unionfind uf(n);
	for(int i=0; i<n; i++){
		int z=y[id[i]];
		if(v.empty() || v.back().first>z){
			v.push_back({z, id[i]});
		}else{
			P p0=v.back();
			while(!v.empty()){
				P p=v.back();
				if(p.first>z) break;
				uf.unite(p.second, id[i]);
				v.pop_back();
			}
			v.push_back(p0);
		}
	}
	for(int i=0; i<n; i++){
		cout<<uf.size(i)<<endl;
	}
	return 0;
}




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

int main(){
  int N,R;
  cin >> N >> R;
  
  if(N >=10){
    cout << R << endl;
  }
  else{
    cout << R + 100 *(10-N) << endl;
  }
  return 0;
}

Measured memory_bytes: 3564
#include<iostream>
using namespace std;
int main(){
	double r;
	cin>>r;
	printf("%.8lf",r*r*3.141592653589793238462643383279);
	cout<<" ";
	printf("%.8lf\n",r*2*3.141592653589793238462643383279);
	return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define print(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    READ(n);
    READARR(a, n);
    
    int o[61] = {}, e[61] = {};
    FOR (i, 1, n)
    {
        FOR (j, 0, 60)
            if ((a[i] >> j) & 1) o[j]++;
            else e[j]++;
    }
    
    int sum = 0;
    FOR (i, 0, 60) sum = (sum + (1LL << i) % mod * o[i] % mod * e[i] % mod) % mod;
    cout << sum;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int H,W; cin>>H>>W;
	int h,w; cin>>h>>w;
	cout <<H*W-(h*W+H*w-h*w)<<endl;
}

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

#define ll long long
#define MOD 1000000007



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

    vector<ll> t(n+1);

    ll v;
    for(int i=0;i<n;i++){
        cin>>v;
        t.at(v)++;
    }

    ll co=0;
    for(int i=0;i<n+1;i++){
        if(t.at(i)==0){
            t.at(i)=200001;
        }else{
            co++;
        }
    }

    sort(t.begin(),t.end());

    ll ans=0;
    for(int i=0;i<(co-k);i++){
        ans += t.at(i);
    }

    cout<<ans<<endl;
}



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

const int MAXN = 1e5 + 10;
int a[MAXN], n, ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++) {
		if (a[i] == i + 1)
			ans++, i++;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include <iostream>
const char mk[4] = { 'S','H','C','D' };
bool q[13][4];
const int CARDS = 13;
const int MARKS = 4;
void insertBool(char a, int b)
{
	for (size_t i = 0; i < MARKS; ++i)
	{
		if (a == mk[i])
		{
			q[b - 1][i] = true;
		}
	}
}
void auth(int i, int j)
{
	for (size_t k = 0; k < MARKS; ++k)
	{
		if (!q[j][i] && i == k)
		{
			std::cout << mk[k] << " " << j + 1 << "\n";
		}
	}
}
int main()
{
	int in;
	char a;
	int b;
	std::cin >> in;
	while (in--) {
		std::cin >> a >> b;
		insertBool(a, b);
	}
	for (int i = 0;i < MARKS;i++)
	{
		for (int j = 0;j < CARDS;j++)
		{
			auth(i, j);
		}
	}
}


Measured memory_bytes: 3076
from math import floor

def main(N, rate=1.08):
    ans = -1
    for x in range(1, N+1):
        if floor(x * 1.08) == N:
            ans = x
    return ans


if __name__ == "__main__":
    N = int(input())
    ans = main(N)
    print(ans if ans > 0 else ':(')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, check;
  cin >> A >> B;
  
  check = A*B;
  if(check%2 ==0){
      cout << "No" <<endl;
  }else{
      cout << "Yes" <<endl;
  }
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using Int = long long;

int main() {

	Int N;
	std::cin >> N;

	std::vector<Int> a(N+1);
	for (Int i = 1; i <= N; i++)std::cin >> a[i];

	Int temp = 1;
	Int count = 0;
	for (Int i = 1; i <= N; i++) {
		temp = a[temp];
		count++;
		if (temp == 2)break;
		if (i == N)count = -1;

	}
	std::cout << count << std::endl;
}

Measured memory_bytes: 1152
def main():
    N, M = map(int, input().split())
    edges = []
    m = [[0 for _ in range(N)] for _ in range(N)]
    for _ in range(M):
        a, b = map(int, input().split())
        edges.append([a-1, b-1])
        m[a-1][b-1] = 1
        m[b-1][a-1] = 1

    ans = 0
    for e in edges:
        m[e[0]][e[1]] = 0
        m[e[1]][e[0]] = 0
        global visited
        visited = [0] * N
        dfs(0, m)
        if sum(visited) != N:
            ans += 1
        m[e[0]][e[1]] = 1
        m[e[1]][e[0]] = 1
    print(ans)


def dfs(node, m):
    global visited
    visited[node] = 1
    for i, edge_flag in enumerate(m[node]):
        if edge_flag == 1 and visited[i] != 1:
            dfs(i, m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 69440
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)

const int MOD = 1000000007;

int modpow(ll a, int n) {
  ll r = 1;
  while(n >= 1) {
    if(n&1) r = (r*a) % MOD;
    a = (a*a) % MOD;
    n >>= 1;
  }
  return r;
}

int choose(int a, int b) {
  ll ret = 1;
  rep(i,b) ret = (ret * (a-i)) % MOD; 
  rep(i,b) ret = (ret * modpow((i+1), MOD-2)) % MOD; 
  return ret;
}

signed main() {
  int x,y; cin >> x >> y;
  if ( ((2*y-x)%3) || ((2*x-y)%3) ) {
    cout << 0 << endl;
    return 0;
  }
  int a = (2*y-x) / 3, b = (2*x-y) / 3;
  if ( a < 0 || b < 0 ) {
    cout << 0 << endl;
    return 0;
  }
  cout << choose(a+b, a) << endl;
}

//x=a+2b
//y=2a+b
//a = x-2b
//y = 2x-3b
//3b = 2x - y
//b = (2x-y) / 3
//x = a + (4x-2y) /3
//3x = 3a + 4x -2y
//3a = 2y-x
//a = (2y-x)/3


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;


int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&b!=a))    cout << "Yes";
    else    cout << "No";
}

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

long long int A[81][81];
bool dp[81][81][13000];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int h,w;
	long long int t;

	cin >> h >> w;

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> A[i][j];
		}
	}

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin >> t;
			A[i][j]-=t;
			A[i][j] = abs(A[i][j]);
		}
	}

	dp[1][1][A[1][1]] = true;

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			for(int k=0;k<13000;k++)
			{
				if(dp[i][j][k]==false)
				{
					continue;
				}
				if(i+1<=h)
				{
					if(abs(k-A[i+1][j])<13000)
					{
						dp[i+1][j][abs(k - A[i+1][j])] = true;
					}
					if(abs(k+A[i+1][j])<13000)
					{
						dp[i+1][j][abs(k + A[i+1][j])] = true;
					}
				}
				if(j+1<=w)
				{
					if(abs(k-A[i][j+1])<13000)
					{
						dp[i][j+1][abs(k-A[i][j+1])] = true;
					}
					if(abs(k+A[i][j+1])<13000)
					{
						dp[i][j+1][abs(k+A[i][j+1])] = true;
					}
				}
			}
		}
	}

	int res = 0;

	for(int i=0;i<13000;i++)
	{
		if(dp[h][w][i])
		{
			res = i;
			break;
		}
	}

	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 82048
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

//??????A[a,b]??¨??????B[c,d]?????¢???
int intervalState(int a, int b, int c, int d){
    if(a < c && b < c) return 0;            //A < B
    else if(a > d && b > d) return 1;       //A > B
    else if(a <= c && d <= b) return 2;     //A -> B
    else if(c < a && b < d) return 3;       //B -> A
    else if(a <= c && b < d) return 4;      //A <= B
    else if(c < a && d <= b) return 5;      //A >= B
    return -1;
}

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

    vector<pair<int, int>> v;
    pair<int,int> in[1005];
    rep(i,m){
        int a, b;
        cin >> a >> b;
        in[i] = make_pair(a,-b);
    }
    sort(in, in + m);
    rep(i,m) in[i].second *= -1;
    rep(i,m){
        if(v.empty()) v.emplace_back(in[i]);
        else{
            pair<int, int> &u = v.back();
            int tmp = intervalState(in[i].first,in[i].second,u.first,u.second);
                switch (tmp){
                    case 0:
                    case 1:
                        v.emplace_back(in[i]);
                        break;
                    case 2:
                        u.first = in[i].first;
                        u.second = in[i].second;
                        break;
                    case 3:
                        break;
                    case 4:
                    case 5:
                        u.first = min(u.first, in[i].first);
                        u.second = max(u.second, in[i].second);
                        break;
                    case -1:
                        assert(0);
                }
        }
    }
    sort(all(v));
    int cur = 0, ans = 0;
    rep(i,v.size()){
        //cout << v[i].first << ' ' << v[i].second << endl;
        ans += v[i].first - cur;
        ans += (v[i].second - v[i].first) * 3;
        cur = v[i].second;
    }
    ans += n + 1 - cur;
    cout << ans << endl;
}

Measured memory_bytes: 3128
#include<iostream>
using namespace std;
int mini=10000;
int n,T,c,t,cnt;
main()
{
    cin>>n>>T;
    for(int i=0;i<n;i++)
    {
        cin>>c>>t;
        if(t<=T && c<mini)mini=c;
        if(t>T)cnt++;
    }
  	if(cnt==n)cout<<"TLE"<<endl;
  	else cout<<mini<<endl;
    
}

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if ((0 <= x - r) && (x + r <= W) && (0 <= y - r) && (y + r <= H)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;

}


Measured memory_bytes: 3104
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();

        char[] c = s.toCharArray();
        char[] c1 = t.toCharArray();

        int n =0;
        for (int i=0; i<3; i++){
            if (c[i]==c1[i]){
                n++;
            }
        }
        System.out.println(n);
    }
}

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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef rsd511
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    #endif
    #ifndef rsd511
    #define trace(...) {}
    #define cotra(...) {}
    #endif
} 

// Code Here

int main()
{
    Fast_IO();
    ll n, x, t; cin >> n >> x >> t;
    ll ans = n / x;
    if(n % x) ans++;
    ans *= t;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3608
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}



public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		FastScanner fs = new FastScanner();
		int K = fs.nextInt();
		int N = fs.nextInt();
		int[] A = new int[N+1];
		A[0] = 0;
		for(int i = 1; i < N+1; i++) {
			A[i] = fs.nextInt();
		}

		int[] dist = new int[N];
		for(int i = 0; i < N; i++) {
			if(i == N-1) {
				dist[i] = (K - A[i+1]) + A[1];
			}else {
				dist[i] = A[i+2] - A[i+1];
			}
		}

		Arrays.sort(dist);
		int Max = 0;
		for(int i = 0; i < dist.length - 1; i++) {
			Max += dist[i];
		}
		System.out.println(Max);
	}

}


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

int main(){

	string str;
	while (getline(cin, str)){
		while (true)
		{
			for (int i = 0; i < str.size(); i++)
			{
				if (str[i] == ' ' || str[i] == '.') continue;

				if (str[i] == 'z'){
					str[i] = 'a';
				}
				else {
					str[i]++;
				}
			}

			if (str.find("the") != -1 || str.find("this") != -1 || str.find("that") != -1)
			{
				cout << str << endl;
				break;
			}
		}
	}
	

	return 0;
}

Measured memory_bytes: 1176
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var n,a,b int
	var arr []int
	var total int

	fmt.Scanf("%d %d %d", &n,&a,&b)

	for i := 0; i < n+1 ; i++ {
		str := strconv.Itoa(i)
		var total int
		for _, st := range str {
			num, _ := strconv.Atoi(string(st))
			total += num
		}

		if a <= total && total <= b {
			arr = append(arr, i)
		}
	}

	for _, num := range arr {
		total += num
	}
	fmt.Println(total)
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  vector<string> c(3);
  for(int i = 0 ; i < 3 ; i++){
    cin >> c[i];
  }
  cout << c[0][0]<<c[1][1]<<c[2][2] << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
typedef long long ll;

int main() {
  ll n, ans = 1;
  cin >> n;

  unordered_map<ll, ll> mp;
  for (int i = 1; i <= n; ++i) {
    int j = 2, t = i;
    while (t > 1) {
      if (t % j == 0) {
        t /= j;
        mp[j]++;
      } else {
        j++;
      }
    }
  }
  for (auto m : mp) ans *= m.second + 1, ans %= MOD;

  cout << ans << endl;
}


Measured memory_bytes: 256
# 素因数分解
def fac(n):
    arr = [1]
    temp = n 
    for i in range(2, int(-(-n**0.5//1)) + 1):
        if temp%i == 0:
            while temp%i == 0:
                temp //= i 
            arr.append(i)
    if temp != 1:
        arr.append(temp)
    if len(arr) == 1:
        arr.append(n)
    return set(arr)


A, B  = map(int, input().split())
ans =  fac(A) & fac(B)
print(len(ans))


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramC
    {
        static void Main()
        {
            int n = NextInt;
            var h = LongList;
            
            for (int i = n - 2; i >= 0 ; i--)
            {
                if (h[i + 1] < h[i]) h[i]--;

                if (h[i + 1] < h[i])
                {
                    System.Console.WriteLine("No");
                    return;
                }
            }

            System.Console.WriteLine("Yes");
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 30428
A = int(input())
B = int(input())
C = int(input())
X = int(input())

a_list = [i for i in range(A+1)]
b_list = [i for i in range(B+1)]
c_list = [i for i in range(C+1)]

count = 0
for a in a_list:
    for b in b_list:
        for c in c_list:
            if X == 500*a+100*b+50*c:
                count += 1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int m, len[MAXN];
char s[MAXN], t[MAXN];
int main() {
	scanf("%s", s + 1);
	int n; n = strlen(s + 1);
	ll ans = 0, k; read(k);
	for (int i = 1; i <= n; i++)
		if (s[i] == t[m]) len[m]++;
		else t[++m] = s[i], len[m] = 1;
	if (m == 1) ans = n * k / 2;
	else if (t[1] == t[m]) {
		ans += len[1] / 2;
		ans += len[m] / 2;
		ans += (len[1] + len[m]) / 2 * (k - 1);
		for (int i = 2; i <= m - 1; i++)
			ans += len[i] / 2 * k;
	} else {
		for (int i = 1; i <= m; i++)
			ans += len[i] / 2 * k;
	}
	writeln(ans);
	return 0;
}

Measured memory_bytes: 256
n=int(input())
s=input()

def z_algo(n,s):
    x=[0]*n
    j=0
    for i in range(1,n):
        if i+x[i-j]<j+x[j]:
            x[i]=x[i-j]
        else:
            k=max(0,j+x[j]-i)
            while i+k<n and s[k]==s[i+k]:
                k+=1
            x[i]=k
            j=i
    ans=0
    for i in range(n):
        if x[i]>i:
            continue
        else:
            ans=max(ans,x[i])
    return ans

ans=0
for i in range(n):
    ans=max(ans,z_algo(n-i,s[i:]))

print(ans if ans<=n//2 else n//2)


Measured memory_bytes: 50012
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <assert.h>

inline void swap(std::vector<uint64_t>& prices, int32_t idx1, int32_t idx2){
    uint64_t tmp = prices[idx1];
    prices[idx1] = prices[idx2];
    prices[idx2] = tmp;
    return;
}

inline void down_heap(std::vector<uint64_t>& prices, int32_t start, int32_t end){
    assert(end <= int(prices.size()));
    int32_t child_idx = 2 * start + 1;
    while(child_idx < end){
        // compare left child with right child
        if(child_idx + 1 < end){
            if(prices[child_idx] < prices[child_idx + 1]){
                child_idx++;
            }
        }
        // compare parent and child
        if(prices[start] >= prices[child_idx]){
            break;
        }
        swap(prices, start, child_idx);
        start = child_idx;
        child_idx = 2 * start + 1;

    }
    return;
}

void heap_init(std::vector<uint64_t>& prices){
    int32_t idx = std::max(int(prices.size() / 2 - 1), 0);
    while(idx >= 0){
        down_heap(prices, idx, prices.size());
        idx--;
    }
    return;
}

inline void insert_sort(std::vector<uint64_t>& prices){
    for(auto itr = prices.begin(); itr < prices.end() -1; itr++){
        if(*itr <= *(itr + 1)){
            uint64_t tmp = *itr;
            *itr = *(itr + 1);
            *(itr + 1) = tmp;
        }
        else{
            break;
        }
    }
    return;
}

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

    int32_t N,M;
    std::cin >> N >> M;
    std::vector<uint64_t> prices(N);
    for(int32_t i = 0; i < N; i++){
        std::cin >> prices.at(i);
    }

    // quick sort prices[] from high to low
    //std::sort(prices.begin(), prices.end(), std::greater<uint64_t>());

    // init_heap
    heap_init(prices);

    for(int32_t j = 0; j < M; j++){
        // Use ticket for the most expencive item
        prices[0] /= 2;

        // insert sort
        // worst order M * N = 10^10
        // insert_sort(prices);

        // down_heap
        // worst order M * log(N) = 10^8
        down_heap(prices, 0, prices.size());
    }

    // sum all items
    uint64_t sum = 0;
    for(auto& price : prices) sum += price;
    std::cout << sum;

    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
int n;
  scanf("%d",&n);
  int p[n+1];
  for(int i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  int min=p[0],ans=n;
  for(int i=0;i<n;i++){
	if(min>p[i])
           min=p[i];
    if(p[i]>min)ans--;
                
  }
printf("%d",ans);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B; cin>>A>>B;
  int ans=0;
  if(A%2==1){
    ans=A;
    A++;
    }
  if(B%2==0){
    ans=ans^B;
    B--;
    }
  int K=B-A+1;
  K/=2;
  ans=ans^(K%2);
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <bitset>
#include <climits>
#include <queue>
using namespace std;

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

	set<int> stamp;
	for(int i=0; i<n; ++i){
		int h, w;
		cin >> h >> w;
		for(int j=-3; j<4; ++j){
			for(int k=-3; k<4; ++k){
				bitset<16> bs;
				for(int y=j; y<j+h; ++y){
					for(int x=k; x<k+w; ++x){
						if(0 <= y && y <4 && 0 <= x && x < 4)
							bs[y*4+x] = true;
					}
				}
				if(bs.any())
					stamp.insert(bs.to_ulong());
			}
		}
	}

	vector<bitset<16> > color(3);
	for(int i=0; i<16; ++i){
		char c;
		cin >> c;
		if(c == 'R')
			color[0][i] = true;
		else if(c == 'G')
			color[1][i] = true;
		else
			color[2][i] = true;
	}

	vector<int> memo(1<<16, -1);
	queue<int> q;
	memo[0] = 0;
	q.push(0);
	for(;;){
		bitset<16> bs = q.front();
		q.pop();

		set<int>::iterator it;
		for(it=stamp.begin(); it!=stamp.end(); ++it){
			for(int i=0; i<3; ++i){
				bitset<16> bs2 = color[i] & bitset<16>(*it);
				if(bs2.none())
					continue;
				bs2 |= bs & ~bitset<16>(*it);
				if(memo[bs2.to_ulong()] == -1){
					memo[bs2.to_ulong()] = memo[bs.to_ulong()] + 1;
					q.push(bs2.to_ulong());
					if(bs2.all()){
						cout << memo[bs2.to_ulong()] << endl;
						return 0;
					}
				}
			}
		}
	}
}

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

using namespace std;

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

const int MAX_N = 100005;

ll v[MAX_N], w[MAX_N];
ll dp[MAX_N+5];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, W;
    cin >> n >> W;
    rep(i,n){
        cin >> w[i] >> v[i];
    }
    rep(i,MAX_N){
        dp[i] = (1LL << 60);
    }
    dp[0] = 0;
    rep(i,n){
        rrep(j,MAX_N){
            cmn(dp[j+v[i]], dp[j]+w[i]);
        }
    }
    ll ans = 0;
    rep(i,MAX_N){
        if(dp[i] <= W){
            ans = i;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1024
<?php 
 $num = intval(fgets(STDIN));
 $array = [];
 $int = explode(' ',fgets(STDIN));
 foreach ($int as $v){
     $array[] = intval($v);
 }
 
 $count = count($array);
 $change_count =0; 
 
 
 for($i = 0; $i < $count ; $i++){
     $min = $i;
     for($j = $i + 1  ; $j < $count; $j++){
         if($array[$j] < $array[$min]){
           $min = $j;
     }
    }
      $tmp = $array[$i];
      $array[$i] = $array[$min];
      $array[$min] = $tmp;
      if($i != $min){
      $change_count++;
    }

 }
 echo implode(" ", $array)."\n";
 echo $change_count."\n";
?>


Measured memory_bytes: 9316
#include<bits/stdc++.h>
#define endl '\n'
#define eps 1e-6
#define oo 1e7+5

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef vector<pair<int,pair<int,int>>> dirgraph;
typedef vector<vector<int>> graph;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n,m;
	cin>>n>>m;
	if(n==m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [int(input()) for i in range(n)]

sum_s = sum(s)

s.sort()

if sum_s % 10 != 0:
    print(sum_s)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            print(sum_s-s[i])
            exit()

print(0)

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

int main() {
	int a {}, b {};
	cin >> a >> b;

	string x {('0' + a--)};
	string y {'0' + b--};

	const string x_val {x};
	const string y_val {y};
	while (b--) {
		x += x_val;
	}
	while (a--) {
		y += y_val;
	}
	cout<<((x < y) ? x : y)<<endl;
	return 0;
}

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

int main() {
  int n, cnt = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int p; cin >> p;
    if (p != i) cnt++;
  }
  
  if (cnt == 0 || cnt == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    ll ans=0;

    rep(i,N){
        if(i!=0 and A[i-1]%2==1 and A[i]!=0){
            ans+=1;
            --A[i-1];
            --A[i];
        }
        ans+=A[i]/2;
        A[i]%=2;
    }
    cout<< ans <<"\n";

}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main() {
  string S,T;
  cin>>S>>T;
  int N=S.size();
  if(S[N-1]=='s'){
    S+="es";
  }
  else{
    S+="s";
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, x;
    cin >> n >> x;
    cout << (500*n>=x?"Yes":"No");
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split()]
s = input() + 'E'
top = int(s[0])
now = s[0]
idx = 0
ranges = []
for i, v in enumerate(s):
	if now != v:
		ranges.append(i - idx)
		idx = i
		now = v
zero = (k * 2) * [0]
ranges = zero + ranges + zero
targetIdx = 1 if top % 2 == 0 else 0 
ret = 0
tmp = 0
for i, v in enumerate(ranges):
	tmp += v
	if i > (k * 2 + 1):
		tmp -= ranges[i - (k * 2 + 1)]
	if i % 2 == targetIdx:
		ret = max(tmp, ret)
print(ret)

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

#define int long long

#define MOD 1000000007
#define maxlen 1000005

int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
vector<int> primeFact(int n){vector<int> ans;for(int t=2;t<=sqrt(n);t++){if(n%t==0){ans.push_back(t);while(n%t==0){n=n/t;}}}if(n>2)ans.push_back(n);return ans;}
vector<int> fact(int n){vector<int> ans;for(int i=1;i<=sqrt(n);i++){if(n%i==0){if( i*i == n ){ans.push_back(i);}else{ans.push_back(i);ans.push_back(n/i);}}}return ans;}
int powerr(int base,int exp,int mod) { if(exp==0)return 1;int t = powerr(base,exp/2,mod)%mod;if(exp%2==0){return (t%mod*t%mod)%mod;}else{return (t%mod*t%mod*base%mod)%mod;}} 
void fastio(){ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}

int32_t main(){
	fastio();

	int n,a,b;
	int ans;

	cin >> n >> a >> b;

	if(abs(a-b)%2==0){
		ans = abs(a-b)/2;
	}else{
		//cout << a-1 << " " << b-1 << " " << n-a << " " << n-b << "\n";
		ans = min( min( a-1LL ,b-1LL)+1+(abs(b-a)-1)/2 , min(n-a ,n-b)+1+(abs(b-a)-1)/2 );
	}
	cout << ans << "\n";
	return 0;
}






Measured memory_bytes: 256
import java.util.*;

public class Main{
	void solve(){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] h = new int[n];
		for(int i = 0; i < n; i++) h[i] = scan.nextInt();
		int[] dp = new int[n];
		dp[0] = 0;
		for(int i = 1; i < n; i++) dp[i] = dp[i - 1] + Math.abs(h[i] - h[i - 1]);
		for(int i = 1; i < n; i++) {
			for(int j = 1; j <= k; j++) {
				if(i - j >= 0) dp[i] = Math.min(dp[i], dp[i - j] + Math.abs(h[i - j] - h[i]));
			}
		}
		System.out.println(dp[n - 1]);
		scan.close();
	}

	public static void main(String[] args){
		new Main().solve();
	}
}
 

Measured memory_bytes: 59564
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        String input;
 
        while ((input = br.readLine()) != null) {
            StringBuilder result = new StringBuilder();
            int n = Integer.parseInt(Integer.toBinaryString(Integer.parseInt(input)));
            int weight = 1;
            while (n != 0) {
                if (n % 10 == 1) {
                    result.append(weight + " ");
                }
                n /= 10;
                weight *= 2;
            }
            System.out.println(result.substring(0,result.length()-1));
        }
 
    }
}


Measured memory_bytes: 24184