akhauriyash/Code-Regression huggingface dataset:
N, K = [int(x) for x in input().split()]
H = [int(input()) for _ in range(N)]

def main():
    h = H
    h.sort()
    length = len(h)
    ans = float('inf')
    for i in range(length):
        end_index = i + K - 1
        if end_index > length - 1:
            break
        ans = min(ans, h[end_index] - h[i])

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7384
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class B0Or1Swap {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<int> P(n);
    for (auto &p: P) cin >> p;

    int cnt = 0;

    for (int i = 0; i < n; i++){
        if (P[i] != i + 1) cnt++;
    }

    cout << (cnt == 0 || cnt == 2 ? "YES" : "NO") << endl;
}
};

int main() {
	B0Or1Swap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n,m;
ll x,y,z;  //石头 剪刀 布 
string s;
ll res;
bool visit[100010];
int main()
{
	cin >>n>>m;
	cin >>x>>y>>z;
	cin >>s;
	for (int i=0;i<n;i++)
	{
		if (visit[i]) continue;
		ll t=1;
		int j=i;
		while (j<n && (j+m<n && s[j]==s[j+m])) visit[j]=1,j+=m,t++;
		visit[j]=1;
		if (s[i]=='r') res+=(t+1)/2*z;
		if (s[i]=='s') res+=(t+1)/2*x;
		if (s[i]=='p') res+=(t+1)/2*y;
	}
	cout <<res;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
int main(){
    int cases;
    scanf("%d", &cases);
    int ac = 0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    for(int i = 0; i < cases ; i++){
        char verdict[100];
        scanf("%s", verdict);
        int length = strlen(verdict);
        if(verdict[0] == 'A'){
            ac++;
        }
        else if(verdict[0] == 'W'){
            wa++;
        }
        else if(verdict[0] == 'T'){
            tle++;
        }
        else if (verdict[0] == 'R'){
            re++;
        }
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tle);
    printf("RE x %d\n", re);
    return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1,s2;
	cin>>s1>>s2;
	int t=0;
	for(int i=0;i<3;i++)
	if(s1[i]==s2[i]) t++;
	cout<<t;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

class Main{

	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num = Integer.parseInt(br.readLine());
		int[] data = new int[num];
		String[] input = br.readLine().split(" ");

		for(int i = 0; i < num; i++){
			data[i] = Integer.parseInt(input[i]);
		}


		Main m = new Main();
		m.output(data, num);
		m.insertionSort(data, num);

	}

	public void insertionSort(int[] data, int num){

		for(int i = 1; i < num; i++){

			int temp = data[i];
			int j = i - 1;

			while(j >= 0 && data[j] > temp){
				data[j + 1] = data[j];
				j--;
			}

			data[j + 1] = temp;

			output(data, num);

		}

	}

	public void output(int[] data, int num){

		for(int i = 0; i < num; i++){

			System.out.print(data[i]);

			if(i != num - 1){
				System.out.print(" ");
			}else{
				System.out.print("\n");
			}

		}

	}

}

Measured memory_bytes: 32016
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         int[] arr = new int[N];
         st = new StringTokenizer(infile.readLine());
         for(int i=0; i < N; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         long res = 0L;
         long max = arr[0];
         for(int i=1; i < N; i++)
         {
            if(arr[i] >= max)
               max = arr[i];
            else
               res += max-arr[i];
         }
         System.out.println(res);
      }
   }

Measured memory_bytes: 54844
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

typedef string::const_iterator State;
int p,q,r;


class ParceError {};

int number(State &begin){
  int ret = 0;
  if(isdigit(*begin)){
    ret += *begin - '0';
    begin++;
  }
  else if(*begin == 'P'){
    ret = p;
    begin++;
  }
  else if(*begin == 'Q'){
    ret = q;
    begin++;
  }
  else if(*begin == 'R'){
    ret = r;
    begin++;
  }
  return ret;
}

int factor(State &begin);

int term(State &begin){
  int ret;
  if(*begin == '-'){
    int count = 0;
    while(*begin == '-'){
      count++;
      begin++;
    }
    ret = factor(begin);
    for(int i = 0; i < count ; i++){
      ret = -1 * (ret - 1) + 1;
    }
  }
  else ret = factor(begin);
  return ret;
}

int expression(State &begin){
  int ret = term(begin);
  if(*begin == '*'){
//    cout << *begin;
    begin++;
    int a = term(begin);
    if(ret == 2 && a == 2) ret = 2;
    else if(ret == 0 || a == 0) ret = 0;
    else ret = 1;
  }
  else if(*begin == '+'){
//    cout << *begin;
    begin++;
    int a = term(begin);
    if(ret == 2 || a == 2) ret = 2;
    else if(ret == 0 && a == 0) ret = 0;
    else ret = 1;
  }
  return ret;
}

int factor(State &begin){
  if(*begin == '('){
//    cout << *begin;
    begin++;
    int ret = expression(begin);
//    cout  << *begin;
    begin++;
    return ret;
  }
  else{
    return number(begin);
  }
}


int main(){
  string s;
  while(cin >> s && s[0] != '.'){
    int count = 0;
    for(p = 0; p < 3; p++){
      for(q = 0; q < 3; q++){
        for(r = 0; r < 3; r++){
          State begin = s.begin();
          int ans = expression(begin);
//          cout << endl;
          if(ans == 2) count++;
        }
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3144
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int64_t N;
int64_t A[300000];
std::map<int64_t, int64_t> countl;
std::map<int64_t, int64_t> countr;
int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);

    in >> N;
    for (size_t i = 0; i < N; i++)
    {
        in >> A[i];
    }

    for (int64_t i = 0; i < N; i++)
    {
        countr[i - A[i]] += 1;
        countl[i + A[i]] += 1;
    }

    int64_t res = 0;
    for (auto& posp : countr)
    {
        auto pos = posp.first;
        res += countl[pos] * posp.second;
    }
    out << res << endl;


    return 0;
}
#endif


Measured memory_bytes: 38888
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int a, b;
    cin >> a >> b;
  
  	if(a*b % 2 == 0)
      cout << "Even" << endl;
    else
      cout << "Odd" << endl;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 18 + 2;
long long mask[(1 << N)], dp[N][N], n;
long long ans;
string s, a, b;
void update(int x, int y) {
	if ((int) a.size() >= x + 1 && a[x] == s[x + y]) {
		dp[x + 1][y] += dp[x][y];
	}
	if ((int) b.size() >= y + 1 && b[y] == s[x + y]) {
		dp[x][y + 1] += dp[x][y];
	}
	return;
}
void reset() {
	memset(dp, 0, sizeof(dp));
	a.clear(), b.clear();
	reverse(s.begin(), s.end());
}
long long cal(int x) {
	for (int i = 0; i < n; i++) {
		if ((x >> i) & 1) 
			a += s[i];
		else 
			b += s[i];
	}
//	cout << "a == " << a << " b == " << b << endl;
	reverse(s.begin(), s.end());
	dp[0][0] = 1;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (i + j >= n)
				continue;
//			cout << "i = " << i << " j = " << j << " : " << dp[i][j] << endl;
			update(i, j);
		}
	}
	long long rtr = 0;
	for (int i = 0; i <= n; i++) {
//		cout << "i = " << i << " j = " << n - i << " : " << dp[i][n - 1] << endl;
		rtr += dp[i][n - i];
	}
	reset();
	return rtr;
}
int main() {
	cin >> n >> s;
	for (int i = 0; i < (1 << n); i++) {
		ans += cal(i);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
/*
#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=100010;
const int MAXK=110;
const int MOD=1e9+7;
int a[MAXN],f[MAXN][MAXK];

int main(){
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<=a[1];i++)
		f[1][i]=1;
	for(int i=2;i<=n;i++){
		for(int j=0;j<=m;j++)
			for(int k=0;k<=a[i]&&j-k>=0;k++)
				f[i][j]=(f[i][j]+f[i-1][j-k])%MOD;
	}
	printf("%d\n",f[n][m]);
	return 0;
}*/

#include<cstdio>
#include<cstring>
#include<algorithm>
const int MAXN=110;
const int MAXK=100010;
const long long MOD=1e9+7;
int a[MAXN];
long long f[MAXN][MAXK];
long long g[MAXN][MAXK];

int main(){
	int n,m;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=0;i<=a[1];i++){
		f[1][i]=1;
		if(i)
			g[1][i]=g[1][i-1]+1;
		else
			g[1][0]=1;
		// printf("*%lld*\n",g[1][i]);
	}
	for(int i=a[1]+1;i<=m;i++)
		g[1][i]=g[1][i-1];
	for(int i=2;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(j-a[i]-1<0)
				f[i][j]=g[i-1][j];
			else
				f[i][j]=(g[i-1][j]-g[i-1][j-a[i]-1]+MOD)%MOD;
			g[i][j]=(g[i][j-1]+f[i][j])%MOD;
			// printf("%d %d %lld\n",i,j,f[i][j]);
		}
	}
	printf("%lld\n",(g[n][m]-g[n][m-1]+MOD)%MOD);
	return 0;
}


Measured memory_bytes: 159104
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
ll gcd( ll a, ll b )
{
	if(b==0)
	{
		return a;
	}
	else
	{
		return gcd( b, a%b );
	}
}
ll lcm (ll a, ll b)
{
	return (a*b)/gcd(a,b);
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	ll a,b; cin>>a>>b;
	ll ans=lcm(a,b);
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
# ABC150 D
from math import gcd

N,M=map(int,input().split())
A=list(map(int,input().split()))

g=A[0]
check=g&-g
for a in A:
    if check!=a&-a:
        check=-1
        break
    g=g*a//gcd(a,g)
if check>=0:
    g//=2
    print((M//g+1)//2)
else:
    print(0)

Measured memory_bytes: 85292
package main

import (
	"fmt"
	"sort"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	p := make([]int, N)
	s := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &p[i])
	}
	copy(s, p)
	sort.Ints(s)

	var count int
	for i := 0; i < N; i++ {
		if s[i] != p[i] {
			count++
		}
	}

	if count <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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


int main(void) {
	int n, i, j, k, a[23][23], dp[2100000] = {}, qs, p, s, t;
	const int mod = 1e9 + 7;
	queue<int> q;

	cin >> n;
	for (i = 0; i < n; i++) for (j = 0; j < n; j++) {
		cin >> a[i][j];
	}

	dp[0] = 1;
	q.push(0);
	for (i = 0; i < n; i++) {
		qs = q.size();
		for (j = 0; j < qs; j++) {
			p = q.front();
			q.pop();
			for (k = 0; k < n; k++) {
				s = p & (1 << k);
				t = p | (1 << k);
				if (a[i][k] == 1 && s == 0) {
					if (dp[t] == 0) q.push(t);
					dp[t] = (dp[t] + dp[p]) % mod;
				}
			}
		}
	}

	cout << dp[(1 << n) - 1] << endl;

	return 0;
}

Measured memory_bytes: 10112
#include <stdio.h>

int main(){
  int N,R;
  scanf("%d %d", &N, &R);
  
  int naibu;
  if(N >= 10){
    naibu = R;
  }else{
    naibu = R + (100*(10-N));
  }
  printf("%d",naibu);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>

template <typename Tp>
inline void read(Tp &x) {
    x = 0;
    bool f = true; char ch = getchar();
    for ( ; ch < '0' || ch > '9'; ch = getchar()) f ^= ch == '-';
    for ( ; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + (ch ^ 48);
    x = f ? x : -x;
}

const int N = 1e3 + 7;

int Cnt;
std::map<int, int> Mp;
std::vector<long long> V;

int main() {
    int n;
    read(n);
    for (int i = 1; i <= n; ++i) {
        int x;
        read(x);
        int Cur = x;
        for (int j = 2; j * j <= Cur; ++j) {
            if (Cur % j) continue;
            if (Mp.find(j) == Mp.end()) {
                Mp[j] = ++Cnt;
                V.push_back(x);
            }
            else V[Mp[j] - 1] += x;
            while (Cur % j == 0) Cur /= j;
        }
        if (Cur > 1) {
            if (Mp.find(Cur) == Mp.end()) {
                Mp[Cur] = ++Cnt;
                V.push_back(x);
            }
            else V[Mp[Cur] - 1] += x;
        }
    }
    long long Ans = 0;
    for (int i = 0; i < (int)V.size(); ++i) Ans = std::max(Ans, V[i]);
    printf("%lld\n", Ans);
    return 0;
}


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

#define ll long long int

int main()
{
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n,k=0;
    cin >> n;
    ll a[n+1];
    for(ll j=1;j<=n;j++)
       cin>>a[j];
    for(ll i=1;i<=n;i++)
    {
           if(i%2==1  &&  a[i]%2==1)
             k++;
    }
    cout<<k;

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    int tmp;
    vector<int> P;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        P.emplace_back(tmp);
    }

    int min = P[0];
    int cnt = 1;
    for (int i = 1; i <= N - 1; i++)
    {
        if (P[i] <= min)
        {
            cnt += 1;
            min = P[i];
        }
        
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N,M,X,tp;
int main(){
    cin >> N >> M >> X;
    vector<int> A(N);
    rep(i,M) cin >> tp, A[tp]++;
    pr(min(accumulate(A.begin(),A.begin()+X,0),accumulate(A.begin()+X,A.end(),0)));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 2e5 + 9, MOD = 998244353;

int fact[N];

int mul(int a, int b) {
	return (1ll * a * b) % MOD;
}

int add(ll a, int b) {
	a += b;
	while( a >= MOD) a -= MOD;
	while(a < 0) a += MOD;
	return a;
}

int sub(ll a, ll b) {
	return (a - b + MOD) % MOD;
}

int pow(int x, int y) {
	int ret = 1;
	while(y) {
		if(y & 1)
			ret = mul(ret, x);
		y /= 2;
		x = mul(x, x);
	}
	return ret;
}

int modInv(int x) {
	return pow(x, MOD - 2);
}

int ncr(int n, int r) {
	if(r > n) assert(0);
	return mul(fact[n], modInv(mul(fact[r], fact[n- r])));
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	fact[0] = 1;
	for (int i = 1; i < N; ++i)
		fact[i] = mul(fact[i - 1], i);
	int n, m, k;
	cin >> n >> m >> k;
	k = n - k - 1;
	int total = 0;
	for (int i = k; i < n; ++i) {
		int cur = mul(m, ncr(n - 1, i));
		cur = mul(cur, pow(m - 1, i));
		total = add(total, cur);
	}
	cout << total;
	return 0;
}


Measured memory_bytes: 4440
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <functional>
#include <map>
#include <math.h>



using namespace std;

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

	int k, a, b;
	cin >> k >> a >> b;
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 5e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	int k;
	cin >> k;
	for (int i = a; i >= 1; i--)
	{
		if (a % i) continue;
		if (b % i) continue;
		k--;
		if (k == 0)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  int F[N+100][M+100];
  int A[M];
  int K;
  int temp;
  for (int i=0;i<N;i++){
    for (int j=0;j<M;j++){
      F[i+1][j+1]=0;
    }
  }
  
  for(int i=1;i<N+1;i++){
    
    cin>>K;
    for(int j=1;j<K+1;j++){
      int m;
      cin>>m;
      F[i][m]=1;
    }
  }
  
  int count=0;
  
  for(int i=1;i<M+1;i++){
    A[i]=1;
  }
  
  for(int i=1;i<M+1;i++){
   for(int j=1;j<N+1;j++){
     A[i]=A[i]*F[j][i];
   }
  }
  
  
  for(int i=1;i<M+1;i++){
    if(A[i]==1){
      count++;
    }
  }


  cout<<count<<endl;

  return 0;
}
    

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N,M;
  cin >> N >> M;
  
  long A[M+1] = {0};
  long sum = 0;
  for(long i=1; i<M+1; i++){
    cin >> A[i];
    sum += A[i];
  }
  
  long ans=0;
  if(sum>N){
  	ans = -1;
  }else{
    ans = N - sum;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int sum=0,a[10000],k,i,n;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(i=0;i<k;i++)
        sum+=a[i];
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3652
from collections import deque
n=int(input())
A=list(input().split())
B=deque([])
if n%2==0:
    for i in range(n//2):
        B.append(A[i*2])
        B.appendleft(A[i*2+1])
    print(" ".join(B))
else:
    for j in range((n-1)//2):
        B.append(A[j*2])
        B.appendleft(A[j*2+1])
    B.append(A[n-1])
    B.reverse()
    print(" ".join(B))

Measured memory_bytes: 26816
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
#define VECIN(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define MOD 1000000007
int a[100006]={0};
int main(){
	int n;
    cin>>n;
    vector<int> an(n);
    REP(i,n) cin>>an[i];
    a[0]=3;
    ll ans=1;
    REP(i,n){
        a[an.at(i)+1]++;
        ans*=a[an.at(i)];
        a[an.at(i)]--;
        ans%=MOD;
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <vector>
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
    while (n >= 10){
        if (n > 99){
            n -= 100;
        }
        else{
            n -= 10;
        }
    }
    if (n == 3){
        cout << "bon";
    }
    else if (n == 0 ||n == 1 ||n == 6 ||n == 8){
        cout << "pon";
    }
    else
    {
        cout << "hon";
    }
    cout << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define forit(it, st) for(auto it : st)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

bool used[N];

vector<int> g[N];

int deg[N];

map<pair<int, int>, int> xx, w;

int cnt[N];

void solve(){
	int n;
	cin >> n;
	int st = 1;
	rep(i, n - 1){
		int a, b;
		cin >> a >> b;
		cnt[a] = 1;
		cnt[b] = 1; 
		g[a].pb(b);
		g[b].pb(a);
		xx[{a, b}] = i;
		xx[{b, a}] = i;
		++deg[a];
		++deg[b];
		if(deg[a] > deg[st]) st = a;
		if(deg[b] > deg[st]) st = b; 
	}
	int res[n];
	cout << deg[st] << endl;
	queue<int> q;
	used[st] = 1;
	q.push(st);
	while(!q.empty()){
		int v = q.front();
		q.pop();
		for(int to : g[v]){
			if(!used[to]){
				used[to] = 1;
				while(w.count({v, cnt[v]})) {
					// cout << v << " " << to << endl;	 
					++cnt[v];
				}
				w[{v, cnt[v]}] = 1;
				w[{to, cnt[v]}] = 1;
				res[xx[{v, to}]] = cnt[v];
				q.push(to);
			}
		}
	}
	for(int i = 0; i < n - 1; ++i) cout << res[i] << endl;

}	

 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


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

template <size_t N, typename T, typename U = T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz, T t) {
  return std::vector<U>(sz, t);
}
template <size_t N, typename T, std::enable_if_t<
  N == 1, std::nullptr_t> = nullptr>
auto make_vector(size_t sz) {
  return std::vector<T>(sz);
}
template <size_t N, typename T, typename... Args, std::enable_if_t<
  N != 1, std::nullptr_t> = nullptr>
auto make_vector(size_t a, Args... args) {
  return make_vector<1>(a, make_vector<N - 1, T>(args...));
}
template <typename T, typename Size_t>
auto& at(T& t, Size_t i) {
  return t.at(i);
}
template <typename T, typename Size_t, typename... Args>
auto& at(T& t, Size_t i, Args... args) {
  return at(t.at(i), args...);
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; long long k; std::cin >> n >> k;
  std::vector<int> a(n);
  for (auto& x : a) {std::cin >> x; x--;}
  constexpr int max = 2e5;

  auto m = [&] {
    auto m = make_vector<2, int>(max, 0);
    for (int i = 0; i < n; i++) {
      m.at(a.at(i)).push_back(i);
    }
    return m;
  }();

  auto add = [&] {
    auto add = std::vector<int>(n);
    for (auto& v : m) {
      if (v.empty()) continue;
      int sz = v.size();
      v.push_back(n + v.front());
      for (int i = 0; i < sz; i++) {
        auto crr = v.at(i), nxt = v.at(i + 1);
        assert(0 <= crr && crr < n && crr < nxt);
        add.at(crr) = nxt - crr + 1;
      }
    }
    return add;
  }();

  auto moved = [&] (auto x) {
    return x + add.at(x % n);
  };

  k %= [&] {
    long long ret = 0;
    for (int i = 0; i < n; i++) {
      ret = moved(ret);
      if (ret % n == 0) break;
    }
    assert(ret % n == 0);
    return ret / n;
  }();

  auto ans = [&] {
    long long crr = 0, goal = n * k;
    std::vector<int> ans;
    while (crr < goal) {
      auto nxt = moved(crr);
      if (nxt <= goal) {
        crr = nxt;
        continue;
      }
      ans.push_back(a.at((crr++ % n)));
    }
    return ans;
  }();

  int sz = ans.size();
  for (int i = 0; i < sz; i++) {
    std::cout << (i > 0 ? " " : "") << ans.at(i) + 1;
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 14968
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
unsigned XorShift(void){static unsigned x = 123456789;static unsigned y = 362436069;static unsigned z = 521288629;static unsigned w = 88675123;unsigned t;t = x ^ (x << 11);x = y; y = z; z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

main(){
	int n;
	cin>>n;
	dump(2*n-1);
	int a[n];
	rep(i,n)cin>>a[i];
	int mx=-MOD,itr=1;
	rep(i,n){
		if(mx<abs(a[i])){
			itr=i+1;
			mx=abs(a[i]);
		}
	}
	if(a[itr-1]>0){
		rep(i,n)dump(itr,i+1);
		rep(i,n-1){
			dump(i+1,i+2);
		}
	}else{
		rep(i,n)dump(itr,n-i);
		rep(i,n-1){
			dump(n-i,n-i-1);
		}
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt(); //n????????\?????????????????????
        StringBuilder NewBuilder = new StringBuilder(); 
        
        int x = 0;
        
        //?????????????????????????????????????????????
        for (int j = 3; j <= n; j++) {
            if (j % 3 == 0) {
            	NewBuilder .append(" " + j);
            } else {
                x = j;
                while (x != 0) {
                    if (x % 10 == 3) {
                    	NewBuilder .append(" " + j);
                        break;
                    } else {
                        x = x / 10;
                    }
                }
            }
 
        }
        //???????????????????????§???
        System.out.println(NewBuilder );
        
        sc.close();
    }
}

Measured memory_bytes: 27900
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var v = new double[N];
            for(int i = 0; i < N; i++)
            {
                v[i] = cin.ReadDouble;
            }
            Array.Sort(v);
            for(int i = 0; i < N - 1; i++)
            {
                v[1] = (v[0] + v[1]) / 2;
                v = v.Skip(1).Select(a => a).ToArray();
                Array.Sort(v);
            }
            WriteLine(v[0]);
        }

        public long C(int X, int Y)
        {

            if (Y == 0 || Y == X)
            {
                return 1;
            }
            if (X < Y)
            {
                return 0;
            }
            var Pascal = new long[X + 1, X + 1];
            for (int i = 0; i <= X; i++)
            {
                Pascal[i, 0] = 1L;
                Pascal[i, i] = 1L;
            }
            for (int i = 2; i <= X; i++)
            {
                for (int j = 1; j < i; j++)
                {
                    Pascal[i, j] = Pascal[i - 1, j] + Pascal[i - 1, j - 1];
                }
            }
            return Pascal[X, Y];
        }

        public class ConsoleInput
        {
            private readonly System.IO.TextReader _stream;
            private char _separator = ' ';
            private Queue<string> inputStream;
            public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
            {
                this._separator = separator;
                this._stream = stream;
                inputStream = new Queue<string>();
            }
            public string Read
            {
                get
                {
                    if (inputStream.Count != 0) return inputStream.Dequeue();
                    string[] tmp = _stream.ReadLine().Split(_separator);
                    for (int i = 0; i < tmp.Length; ++i)
                        inputStream.Enqueue(tmp[i]);
                    return inputStream.Dequeue();
                }
            }
            public string ReadLine { get { return _stream.ReadLine(); } }
            public int ReadInt { get { return int.Parse(Read); } }
            public long ReadLong { get { return long.Parse(Read); } }
            public double ReadDouble { get { return double.Parse(Read); } }
            public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
            public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
            public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
        }
    }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<pair<string,bool> >v;
    string a,b;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      v.push_back(make_pair(a,1));
      v.push_back(make_pair(b,0));
    }
    sort(v.begin(),v.end());
    int ans=0,k=0;
    string ts;
    for(int i=0;i<v.size();i++){
	if(!k)ts=v[i].first;
	if(v[i].second)k++;
	else k--;
	ans=max(k,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4044
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
using namespace std;
int n;
int left(int i) { return i * 2; }
int right(int i) { return i * 2 + 1; }
void maxHeapify(int *p, int i) {
	int l = left(i);
	int r = right(i);
	int lg;
	if (l <= n && p[i] < p[l]) 
			lg = l;
	else lg = i;
	if (r <= n && p[lg] < p[r]) 
		lg = r;
	if (lg != i) {
		swap(p[i], p[lg]);
		maxHeapify(p, lg);
	}
}
int main() {
	cin >> n;
	int *pt;
	pt = new int[n];
	for (int i = 1; i <= n; i++)
		cin >> pt[i];
	for (int i = n/2; i >= 1; i--) maxHeapify(pt, i);
	for (int i = 1; i <= n; i++) cout << " " << pt[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 5000
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstring>
#include<functional>
#include<cmath>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)

using namespace std;

int main(){
	int k;
	vector<int> a(5);
	rep(i,0,5) cin >> a[i];
	cin >> k;
	rep(i,0,5){
		rep(I,i + 1,5){
			if(k < abs(a[i] - a[I])){
				cout << ":(" << endl;
				a[i] = -1;
				break;
			} 
		}
		if(a[i] == -1) break;
		if(i == 4) cout << "Yay!" << endl;
	}
}

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

int main(){
	int abcd;
	cin >> abcd;
	int a = abcd / 1000;
	abcd %= 1000;
	int b = abcd / 100;
	abcd %= 100;
	int c = abcd / 10;
	int d = abcd % 10;

	for (int i = 0;i < 2;i++) {
		for (int j = 0;j < 2;j++) {
			for (int k = 0;k < 2;k++) {
				if (a + b * pow(-1, i) + c * pow(-1, j) + d * pow(-1, k) == 7) {
					cout << a << (i ? '-' : '+') << b << (j ? '-' : '+') << c << (k ? '-' : '+') << d << "=7" << endl;
					return 0;
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a;
  int n,c=0;
  cin>>n;
  for(int i=11;i<=55555;i+=10){
    bool f=true;
    for(int j=3;j<i;j+=2){
      if(i%j==0){
        f=false;
        break;
      }
    }
    if(f){
      a.push_back(i);
      c++;
    }
    if(c==n)
      break;
  }
  for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
  }
}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, sum = 0; cin >> n >> a;
	if (n <= 5) {
		cout << 0 << endl;
	}
	else if (n < 13) {
		cout << a / 2 << endl;
	}
	else {
		cout << a << endl;
	}
	cin >> n;
}

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

using namespace std;

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int t = 1;
	// cin >> t;
	while (t--) { 
		solve();
	}
	return 0;
}
bool in[105] = {false};
int a[5][5];
void solve() {
	for (int i = 0; i < 3; ++i)
		for (int j = 0; j < 3; ++j)
			cin >> a[i][j];
	int n;
	cin >> n;
	rep(i, 0, n) {
		int x;
		cin >> x;
		in[x] = true;
	}
	bool got = false;
	rep(row, 0, 3) {
		int here = 0;
		for (int j = 0; j < 3; ++j) 
			here += in[a[row][j]];
		if (here == 3)
			got = true;
	}
	rep(row, 0, 3) {
		int here = 0;
		for (int j = 0; j < 3; ++j) 
			here += in[a[j][row]];
		if (here == 3)
			got = true;
	}
	if (in[a[0][0]] and in[a[1][1]] and in[a[2][2]])
		got = true;
	if (in[a[2][0]] and in[a[1][1]] and in[a[0][2]])
		got = true;
	if (got)
		cout << "Yes";
	else
		cout << "No";
}	
	

Measured memory_bytes: 256
N, P = map(int, input().split())
A = list(map(int, input().split()))

def nCr(n, r):
    r = min(r, n-r)

    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i

    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

x = sum(A) % 2

o = 0
e = 0

for a in A:
    if a % 2 == 0:
        e += 1
    else:
        o += 1

z = 2**e

y = 1
if P == 0:
    y = 0
if x:
    y ^= 1
res = 0
for i in range(y, o+1, 2):
    res += nCr(o, i)
    
print(res*z)

Measured memory_bytes: 9148
#include <iostream>

using namespace std;

int main(){

  int a,b;
  while(1){
    cin >> a;
    if(cin.eof()){
      break;
    }
    cin >> b;
    int sum = a + b;
    int cnt = 1;
    while(sum /= 10){
      cnt++;
    }
    cout << cnt << endl;
  }

  return 0;
}

Measured memory_bytes: 0
(defvar alist nil)

(let ((ht (make-hash-table)))
     (mapc (lambda (x)
                   (if #1=(gethash x ht)
                       (incf #1#)
                       (setf #1# 1) ))
           (loop :repeat (read) :collect (read)) )
     (maphash (lambda (k v) (push (cons k v) alist)) ht)
     ;(princ alist) 
     )

(defvar alist-max 
  (reduce (lambda (x y) (max x (cdr y)))
          alist :initial-value 0) )

(setq alist (remove-if-not 
             (lambda (x) (= (cdr x) alist-max))
             alist))

(setq alist
      (sort (mapcar 
             (lambda (x) (string-downcase (car x)))
             alist)
            #'string<))

(format t "~{~A~^~%~}" alist)


Measured memory_bytes: 106472
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = list(iss())
    T = list(iss())
    ans = 0
    if S[0] == T[0]: ans += 1
    if S[1] == T[1]: ans += 1
    if S[2] == T[2]: ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#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 rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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;
#define PI 3.14159265369;
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 h, n;
	cin >> h >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	ll sum = 0;
	rep(i,n) sum += a[i];
	if(sum >= h) cout <<"Yes";
	else cout << "No";
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define sz(a) (int)(a).size()

using namespace std;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	
	int n,m;
	cin>>n>>m;
	vector<pair<int,int>> arr(n);
	long long ans=0;
	for(int i=0; i<n; i++){
		cin>>arr[i].first>>arr[i].second;
		ans += arr[i].second;
	}
	vector<long long>dp(ans+1,1e18);
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int v = ans-arr[i].second ; v>=0 ;--v){
			uin(dp[v+arr[i].second],dp[v]+arr[i].first);
		}
	}
	ans=0;
	for(long long v = sz(dp)-1 ; v>=0; v-- ){
		//cout<<dp[v]<<" "<<v<<endl;
		if(dp[v]<=m)
			uax(ans,v);
	}

	cout<<ans<<endl;

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif	
	return 0;
}

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

// UnionFind (Disjoint set)
struct unionfind {
    vector<int> d;  // 親：連結のサイズ×(-1)、子：親のID（非負）
    unionfind(int n = 0) : d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    unionfind g(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g.unite(a, b);
    }
    int ans = 0;
    rep (i, n) {
        int now = g.size(i);
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}
/*
g++ -std=c++17 -Wall -Wextra -g -O0 -fsanitize=undefined,address main.cpp && oj t
*/

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

struct e{int a,b;};
int A=500,n,a[20],b[20],R,p,q;
e v[20];
stack<int> s;
#define rep(i,n) for(int i=0;i<(n);i++)

signed main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n)cin>>b[i];
  rep(i,1<<n){
    R=0;
    rep(j,n)v[j]={(i>>j)&1?b[j]:a[j],j};
    rep(j,n){
      p=j;
      while(p&&v[p].a<v[p-1].a)swap(v[p],v[p-1]),R++,p--;
    }
    rep(j,n)if(((i>>v[j].b)+v[j].b-j)&1)s.push(v[j].a*500+j);
    if(s.size()&1)R=500,s.pop();
    while(s.size()){
      p=s.top();s.pop();q=s.top();s.pop();
      R+=((p-q)&1?p-q:500);
    }
    if(A>R)A=R;
  }
  cout<<(A<500?A:-1)<<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 <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1001001001
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h)
  cin >> s[i];
  int ans = 0;
  REP(si, h)
  REP(sj, w)
  {
    if (s[si][sj] == '#')
      continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF)
        return;
      dist[i][j] = x;
      q.push(P(i, j));
    };
    update(si, sj, 0);
    while (!q.empty())
    {
      int i = q.front().first;
      int j = q.front().second;
      q.pop();
      REP(dir, 4)
      {
        int ni = i + di[dir], nj = j + dj[dir];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w)
          continue;
        if (s[ni][nj] == '#')
        {
          continue;
        }
        update(ni, nj, dist[i][j] + 1);
      }
    }
    REP(i, h)
    REP(j, w)
    {
      if (dist[i][j] == INF)
        continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define fi first
#define se second

using ll = long long;
#define INF 1000000000000000000

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

    int n,m;cin>>n>>m;

    vector<pair<int,int>> a(n),b(m);

    for(int i=0;i<n;i++)
    {
        int ia,ib;cin>>ia>>ib;
        a[i]=make_pair(ia,ib);
    }

    for(int i=0;i<m;i++)
    {
        int ic,id;cin>>ic>>id;
        b[i]=make_pair(ic,id);
    }

    for(int i=0;i<n;i++)
    {
        int ans=0;
        ll mindist=INF;
        for(int j=0;j<m;j++)
        {
            ll dist=abs(a[i].fi-b[j].fi)+abs(a[i].se-b[j].se);
            if(mindist>dist)
            {
                mindist=dist;
                ans=j+1;
            }
        }

        cout<<ans<<"\n";
    }

    return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <climits>
using namespace std;
void solve()
{
	int n;
	cin >> n;
	int h[n];
	for(int i=0;i<n;i++)
	{
		cin >> h[i];
	}
	int dp[n]={0};
	for(int i=1;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),(i-2>=0)?(dp[i-2]+abs(h[i]-h[i-2])):(INT_MAX));
	}
	cout << dp[n-1] << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t=1;
	// cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 4376
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long x; cin >> x;
    long long ans = x / 11 * 2;
    if (x % 11 > 0 && x % 11 <=6) ans++;
    else if (x % 11 > 6) ans+=2;
    cout << ans << '\n';
}

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

    solve();

    return 0;
} 

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

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    int pro=1;

    for(int i=1;i<=k;i++){
        pro *= 2;       
    }
    int sum = a + b + c +(pro-1)*max(max(a,b),c);
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int N, D, X;
	int A[100];
	int ans = 0;
	cin >> N >> D >> X;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 1; j <= D; j += A[i]) {
			ans++;
		}
	}
	cout << ans+X << endl;

	return(0);
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    if op == '?':
        break
    elif op == '+':
        print(int(a) + int(b))
    elif op == '-':
        print(int(a) - int(b))
    elif op == '*':
        print(int(a) * int(b))
    elif op == '/':
        print(int(int(a) / int(b)))
    else:
        print(int(a) % int(b))


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

int main()
{
    string s,t;
    cin >> s >> t;
    int ans = 0;
    rep(i,s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3912