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

template<class T> inline T gcd(T a, T b) {
    if (b == 0) return a;
    return  gcd(b, a % b);
}

template<class T> inline T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

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

    int n;
    cin >> n;

    ll ans;
    cin >> ans;
    REP(i, n - 1) {
        ll tmp;
        cin >> tmp;
        ll g = gcd(ans, tmp);
        ans /= g;
        ans *= tmp;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<int>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << a[0] << endl;
		return 0;
	}
	if (n % 2 == 0) {
		for (int i = n-1; i >= 1; i -= 2) {
			cout << a[i] << " ";
		}
		for (int i = 0; i < n; i += 2) {
			cout << a[i] << " ";
		}
	}
	else {
		for (int i = n-1; i >= 0; i -= 2) {
			cout << a[i] << " ";
		}
		for (int i = 1; i < n; i += 2) {
			cout << a[i] << " ";
		}
	}
	return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int ans=1;
  
  for(int i=0;i<n;i++){
    ans=min(ans+k,ans*2);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i, alpha[26];
    char s[200], ptn[100];
    int s_length = 0, ptn_length = 0;

    while(1){
        char ch = getchar();
        if(ch == '\n')break;

        s[s_length++] = ch;
    }

    while(1){
        char ch = getchar();
        if(ch == '\n')break;

        ptn[ptn_length++] = ch;
    }

    for(i = 0; i < s_length; i++){
        s[s_length + i] = s[i];
    }
    s_length *= 2;

    int pp;
    for(i = 0; i < s_length - ptn_length; i++){
        if(s[i] == ptn[0]){
            for(pp = 1; pp < ptn_length; pp++){
                if(s[i + pp] != ptn[pp])break;
            }
            if(pp == ptn_length){
                printf("Yes\n");
                break;
            }
        }
    }
    if(i == s_length - ptn_length)printf("No\n");
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,ll>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,k;
string s;
int main()
{
    go;
    cin>>n>>k>>s;
    s[k-1]=s[k-1]-'A'+'a';
    cout<<s;
    return 0;
}


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

using namespace std;

int main()
{
  string s,t;
  int n;

  cin>>n;
  cin>>s>>t;

  for(int i=0;i<n;i++){
    cout<<s[i]<<t[i];
  }
  cout<<endl;

  return 0;
}


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

use itertools::Itertools;
use proconio::marker::{Bytes, Chars};
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        h: usize, w: usize, k: usize,
        c: [Chars; h],
    }
    // annotate for rust-analyzer
    let (h, w, k) = (h as usize, w as usize, k as usize);
    let c: Vec<Vec<char>> = c;

    let mut ans = 0;
    for ib in 0..(1 << h) {
        for jb in 0..(1 << w) {
            let mut cnt = 0;
            for i in 0..h {
                for j in 0..w {
                    if ib >> i & 1 == 0 {
                        continue;
                    }
                    if jb >> j & 1 == 0 {
                        continue;
                    }
                    if c[i][j] == '#' {
                        cnt += 1;
                    }
                }
            }
            if k == cnt {
                ans += 1;
            }
        }
    }

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


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

int main() {
    int N; cin >> N;
    int max_cnt = 0, D[13] = {}; D[0] = 1;
    REP(i, 0, N) {
        int d; cin >> d;
        D[d]++;
        max_cnt = max(max_cnt, D[d]);
    }

    if (D[0] > 1 || D[12] > 1 || max_cnt > 2) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> fixed, unfixed;
    REP(i, 1, 12) {
        if (D[i] == 2) {
            fixed.push_back(i);
            fixed.push_back(24 - i);
        } else if (D[i] == 1) {
            unfixed.push_back(i);
        }
    }
    if (D[0] > 0) fixed.push_back(0);
    if (D[12] > 0) fixed.push_back(12);

    auto fn = [](auto l, auto r) {
        return min({
            abs(l - r),
            min(l, r) + 24 - max(l, r),
        });
    };

    int base = 1 << 30;
    REP(i, 0, fixed.size()) {
        REP(j, i + 1, fixed.size()) {
            base = min(base, fn(fixed[i], fixed[j]));
        }
    }
    // cout << "base : " << base << endl;

    int ans = 0;
    for (int bit = 0; bit < (1 << unfixed.size()); bit++) {
        vector<int> times;
        REP(i, 0, unfixed.size()) {
            if (bit & (1 << i)) {
                times.push_back(unfixed[i]);
            } else {
                times.push_back((24 - unfixed[i]) % 24);
            }
        }

        // cout << "# ";
        // for (auto t : times) cout << t << " ";
        // cout << endl;

        int cur = base;
        REP(i, 0, fixed.size()) {
            REP(j, 0, times.size()) {
                cur = min(cur, fn(fixed[i], times[j]));
            }
        }
        // cout << "--> cur : " << cur << endl;
        REP(i, 0, times.size()) {
            REP(j, i + 1, times.size()) {
                cur = min(cur, fn(times[i], times[j]));
            }
        }
        // cout << "--> cur : " << cur << endl;
        ans = max(ans, cur);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<stack>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
#define MAX 510000
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;}
using namespace std;


int main(){
  int A[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},K;
  cin>>K;
  
  cout<<A[K-1]<<endl;
}

Measured memory_bytes: 764
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
constexpr int SIZE = 16;

int input() {
	int res = 0;
	for(int i = 0; i < SIZE; ++i) {
		int in;
		cin >> in;
		res = (res << 1) | in;
	}
	return res;
}

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

	for(int n, c; cin >> n >> c && n;) {
		vector<int> a(n), b(c);
		for(auto &e : a) e = input();
		for(auto &e : b) e = input();

		b.emplace_back(0);

		unordered_map<int, int> calc(1 << SIZE);
		calc[0] = 0;

		for(const auto &on : a) {
			unordered_map<int, int> next_calc(1 << SIZE);

			for(const auto &current : calc) {
				const int before = (current.first | on);
				const int before_count = __builtin_popcount(before);

				for(const auto &e : b) {
					const int after = (before & ~e);
					const int score = current.second + before_count - __builtin_popcount(after);
					chmax(next_calc[after], score);
				}
			}

			calc = move(next_calc);
		}

		int ans = 0;
		for(const auto &e : calc){
			chmax(ans, e.second);
		}

		cout << ans << endl;
	}

	return EXIT_SUCCESS;
}

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

int main(){
  int N;
  int ans=0;
  cin >> N;
  
  for(int i=0;i<N;i++){
    int l,r;
    cin >> l >> r;
    ans += r-l+1;
  }
  
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;

int n,m;
bool fl;
int l[200001],r[2000001];
ll d[200001];
vector<P> G[200001];
vector<P> rG[200001];
bool flag[200001];
ll dist[200001];

void dfs(int v,int p,ll c){
	flag[v]=true;
	dist[v]=c;
	//printf("%d %lld\n",v,c);
	for(int i=0;i<G[v].size();i++){
		int nv=G[v][i].first;
		ll nc=G[v][i].second;
		if(nv==p)continue;
		if(flag[nv]){
			if(dist[nv]!=dist[v]+nc)fl=false;
		}else{
			dfs(nv,v,c+nc);
		}
	}

	for(int i=0;i<rG[v].size();i++){
		int nv=rG[v][i].first;
		ll nc=rG[v][i].second;
		if(nv==p)continue;
		if(flag[nv]){
			if(dist[nv]!=dist[v]+nc)fl=false;
		}else{
			dfs(nv,v,c+nc);
		}
	}
}

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		scanf("%d%d%lld",&l[i],&r[i],&d[i]);
		l[i]--;
		r[i]--;
		G[l[i]].push_back(P(r[i],d[i]));
		rG[r[i]].push_back(P(l[i],-d[i]));
	}
	fl=true;
	for(int i=0;i<n;i++){
		if(!flag[i]){
			dfs(i,-1,0);
		}
	}
	printf("%s\n",fl?"Yes":"No");
	return 0;
}

Measured memory_bytes: 29824
import sys

input = sys.stdin.readline

def main():
    N, K = [int(i) for i in input().split()]
    a_list = [int(i) for i in input().split()]
    cnt = 0
    cnt = sum([a_list[i] > a_list[j] for i in range(N) for j in range(i, N)])
    second_cnt = sum([a_list[i] > a_list[j] for i in range(N) for j in range(i)])
    if K > 1:
        second_cnt *= (K * (K - 1)) // 2
    cnt = cnt * ((K * (K + 1)) // 2)
    print((cnt + second_cnt) % (10 ** 9 + 7))


if __name__ == "__main__":
    main()


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N, 0);
    vector<int> B(N, 0);
    rep(i, N){
        cin >> A[i] >> B[i];
    }
    vector<pair<int, int>> p;
    rep(i, N){
        p.emplace_back(make_pair(B[i], A[i]));
    }
    sort(p.begin(), p.end());

    ll sum = 0;
    rep(i, N){
        sum += p[i].second;
        if(sum>p[i].first){
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 3956
import numpy as np

lst=input().split(" ")
A=int(lst[0])
B=int(lst[1])
K=int(lst[2])
lst=[]

for i in range(1,min(A,B)+1):
    if A%i==0 and B%i==0:
        lst.append(i)

print(lst[len(lst)-K])


Measured memory_bytes: 12396
#include <iostream>

using namespace std;

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

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,k,x,y=[int(input()) for i in range(4)]
k=min(n,k)
print(k*x+(n-k)*y)


Measured memory_bytes: 63980
#include <stdio.h>

int main() {
	long long int L, R, i, j, min = 2020;

	scanf("%lld %lld", &L, &R);
	for (i = L; i < R && i < L + 2019; i++) {
		for (j = L + 1; j <= R && j <= L + 2019; j++) {
			if ((i * j) % 2019 < min) {
				min = (i * j) % 2019;
			}
		}
	}

	printf("%lld", min);
	
	return 0;
} 

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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 700;
    for(int i = 0;i < 3;i++){
        if(s.at(i) == 'o'){
            ans += 100;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <map>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

int main()
{
    ll N;
    std::cin >> N;

    std::vector<ll> capacities(5);
    auto min = 10000000000000000;
    for (auto i=0; i<5; ++i)
    {
        std::cin >> capacities[i];
        if (capacities[i] < min)
            min = capacities[i];
    }

    ll result = N / min + 4;
    auto mod = N % min;
    if (mod != 0)
        result++;

    std::cout << result << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int n,k,mx=0;
int main() {
    n=gi(),k=gi();
    int gg=0;
    for(int i=1,v;i<=n;i++) v=gi(),gg=__gcd(gg,v),mx=max(mx,v);
    if(k%gg==0&&k<=mx) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}


Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}

void main() {
  auto cin = new Scanner;
  string s = cin.next!string;
  writeln("2018" ~ s[4 .. $]);
}


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

int main() {
    ll N, D; cin >> N >> D;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        ll x, y; cin >> x >> y;
        if (x * x + y * y <= D * D) ans++;
    }
    cout << ans << endl;
}

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

const int INF = 1e9 + 7;

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

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	vector<int> dp(n, INF);
	for (int i = 0; i < n; i++)
		cin >> h[i];
	dp[0] = 0;
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j <= min(i, k); j++)
		{
			dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
		}
	}
	cout << dp[n - 1];

	return 0;
}

Measured memory_bytes: 3980
k = int(input())
count = 0
for i in range(1, k):
    for j in range(i+1, k+1):
        if i % 2 == 1 and j % 2 == 0:
            count += 1
        elif i % 2 == 0 and j % 2 == 1:
            count += 1
print(count)

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

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

    int ans = -1;
    for(int i = 1; i <= 1250; i++) {
        int ta = i * 8 / 100;
        int tb = i * 1 / 10;
        if(ta == a && tb == b) {
            ans = i;
            break;
        }
    } 

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

string s;
ll cnt[512];
ll ans;

int main(){
  cin >> s;
  for(ll i = 0;i < 4;i++) cnt[s[i]]++;
  for(ll i = 0;i < 512;i++){
    if(cnt[i] == 2) ans++;
  }
  if(ans == 2) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
import numpy as np
N,W = map(int, input().split())
# np.maximum https://www.sejuku.net/blog/69175
# 第一引数と第二引数の大小関係を要素ごとに比較して、大きい方を格納した配列を返す
dp = np.zeros(W+1, dtype=np.int64)
# その重さでの最大valueが保存されている
for i in range(N):
    w,v = map(int,input().split())
    # updating dp[w:]
    # total value of dp[k] when i-1 VS total value of dp[k-w]+v when i 

    np.maximum(dp[:W-w+1]+v,dp[w:],out=dp[w:])
print(dp[-1])


Measured memory_bytes: 14588
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n,k,c;
  cin>>n>>k>>c;
  string s;
  cin>>s;
  vector<int> workable;
  set<int> mustwork;
  for(int i=0;i<s.size();i++){
    if(s[i]=='o'){
      workable.push_back(i+1);
      mustwork.insert(i+1);
    }
  }

  vector<int> workday_end(workable.size()),workday_begin(workable.size());
  int itr_end=0;
  workday_end[0]=1;
  for(int i=1;i<workable.size();i++){
    while(workable[i]-workable[itr_end+1]>c){
      itr_end++;
    }
    if(workable[i]-workable[itr_end]>c){
      workday_end[i]=workday_end[itr_end]+1;
    }else{
      workday_end[i]=workday_end[i-1];
    }
  }
  int itr_begin=workable.size()-1;
  workday_begin[workable.size()-1]=1;
  for(int i=workable.size()-2;i>=0;i--){
    while(-workable[i]+workable[itr_begin-1]>c){
      itr_begin--;
    }
    if(-workable[i]+workable[itr_begin]>c){
      workday_begin[i]=workday_begin[itr_begin]+1;
    }else{
      workday_begin[i]=workday_begin[i+1];
    }
  }


  for(int i=0;i<workable.size();i++){
    int workday=0;
    if(i-1>=0){
      workday+=workday_end[i-1];
    }
    if(i+1<workable.size()){
      workday+=workday_begin[i+1];
    }
    if(workday>=k){
      mustwork.erase(workable[i]);
    }
  }


  int outcount=0;
  for(auto d:mustwork){
    cout<<d;
    outcount++;

      cout<<endl;

  }




  return 0;
}




Measured memory_bytes: 13452
#include <stdio.h>
#define SQ(x) ((x) * (x))

typedef struct{
	double x;
	double y;
	double r;
} CIRCLE;

int main(void)
{
	CIRCLE a, b;
	int n;
	
	scanf("%d", &n);
	
	while (n-- != 0){
		scanf("%lf%lf%lf%lf%lf%lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
		
		if (SQ(a.x - b.x) + SQ(a.y - b.y) > SQ(a.r + b.r)){
			printf("0\n");
		}
		
		else if (SQ(a.r + b.r) > SQ(a.x - b.x) + SQ(a.y - b.y) && SQ(a.x - b.x) + SQ(a.y - b.y) > SQ(a.r - b.r)){
			printf("1\n");
		}
		
		else if (SQ(a.x - b.x) + SQ(a.y - b.y) < SQ(a.r - b.r)){
			if (a.r > b.r){
				printf("2\n");
			}
			else {
				printf("-2\n");
			}
		}
		else {
			printf("1\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cin(int, c);
    Cout((10*b+c) % 4 == 0 ? "YES" : "NO");
}

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

int main()
{
    long long n;
    cin >> n;
    long long cnt = 0;
    for (long long i = 2; i * i <= n; i++)
    {
        long long e = 0, z = 0;
        while (n % i == 0)
        {
            e++;
            if (e > z)
            {
                cnt++;
                z = e;
                e = 0;
            }
            n /= i;
        }
    }
    if (n > 1)
    {
        cnt++;
    }
    cout << cnt << endl;
}


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

int h, w;

int main()
{
	cin >> h >> w;

	for (int i=0; i < h; i++) {
		for (int j=0; j < w; j++) {
			string s;
			cin >> s;
			if (s == "snuke")
				cout << (char)((int)'A' + j) << i+1 << endl;
		}
	}

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
  int n, x, i;
  scanf("%d", &n);
 
  if (n >= 3 && n <= 10000) {
    for (i = 1; i <= n; i++) {
      if (i % 3 == 0) {
        printf(" %d", i);
      } else {
        x = i;
        while(x != 0) {
          if (x % 10 == 3) {
            printf(" %d", i);
            break;
          }
          x /= 10;
        }
      }
    }
    putchar('\n');
  }
  return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int a,b,c;
    cin>>a>>b>>c;
    if (a>b) swap(a,b);
    if (c>=a && c<=b) out("Yes");
    out("No");
    
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int s,d,m;cin>>s>>d>>m;){
    int k[100];
    int w[100][50],p[100][50];
    for(int i=0;i<s;i++){
      cin>>k[i];
      for(int j=0;j<k[i];j++){
	cin>>w[i][j]>>p[i][j];
      }
    }
    int dp[301]={};
    for(int i=0;i<d;i++){
      int f;
      cin>>f;
      for(int j=0;j<k[f];j++){
	for(int l=m;l-p[f][j]>=0;l--){
	  dp[l]=max(dp[l],dp[l-p[f][j]]+w[f][j]);
	}
      }
    }
    cout<<dp[m]<<' '<<(lower_bound(dp,dp+m+1,dp[m])-dp)<<endl;
  }
}

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

#define dump(...) do{print_vars(cout<<"# "<<#__VA_ARGS__<<'=',__VA_ARGS__);cout<<endl;}while(0)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

void print_vars(ostream&){}
template<typename Car,typename... Cdr>
void print_vars(ostream& os,const Car& car,const Cdr&... cdr){
	print_vars(os<<car<<(sizeof...(cdr)?",":""),cdr...);
}

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<int I,typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<int I,typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	os<<get<I>(t)<<(sizeof...(Cdr)?",":"");
	print_tuple<I+1,Cdr...>(os,t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<0,Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int main()
{
	#ifndef _GLIBCXX_DEBUG
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	constexpr char endl='\n';
	#endif

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

		set<int> s;
		rep(i,n)
			if(s.count(a[i]))
				s.erase(a[i]);
			else
				s.insert(a[i]);
		cout<<s.size()<<endl;
	}
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int
main()
{
  ll a,b;
  cin>>a>>b;
 /*if((a-b)<=d&&(b-c)<=d||(a-c)<=d)
    cout<<"Yes"<<endl;
 else cout<<"No"<<endl;*/
int c[4];
c[0]=a+b;
c[1]=a-b;
c[2]=a*b;
sort(c,c+3);
cout<<c[2]<<endl;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI A(n);
        int mi = inf, mx = -inf;
        FOR(i,0,n) {
            cin >> A[i];
            mi = min(mi,A[i]);
            mx = max(mx,A[i]);
        }
        int ans = inf;
        FOR(x,mi,mx+1) {
            int res = 0;
            FOR(j,0,n) 
                res += (x-A[j])*(x-A[j]);
            ans = min(ans,res);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll INF = 1LL << 62;
const int inf = 1 << 30;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;
    int n = in.size();
    vector<string> T = {"dreamer", "dream", "eraser", "erase"};
    vi dp(n + 1, false);
    dp[0] = true;
    rep(i, n){
        if(not dp[i]) continue;
        for(auto& e : T){
            int m = e.size();
            if(in.substr(i, m) == e){
                dp[i + m] = true;
            }
        }
    }
    cout << (dp[n] ? "YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 848
import java.util.Scanner;	
public class Main {
    public static void main(String[] args) throws Exception {
    Scanner stdIn= new Scanner(System.in);
    int n=stdIn.nextInt();
    int a=n%10;
    int [] hon={2,4,5,7,9};
    int [] pon={0,1,6,8};
    for(int t=0;t<hon.length;t++){
      if(a==hon[t])System.out.println("hon");
    }
    for(int t=0;t<pon.length;t++){
      if(a==pon[t])System.out.println("pon");
    }
    if(a==3)System.out.println("bon");
  }
}
 

    
      
    
    

Measured memory_bytes: 35748
#include <iostream>

using namespace std;

int main(){
	int year[7]={},n,f,num;
	while(cin>>n,n!=0){
		for(int i=0;i<7;i++)year[i]=0;
		for(int i=0;i<n;i++){
			cin>>num;
			f=num/10;
			if(f>6)year[6]++;
			else year[f]++;
		}
		for(int i=0;i<7;i++)cout<<year[i]<<endl;
	}
}

Measured memory_bytes: 1156
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		if(n<=5) {
			System.out.println(0);
		}else if(n<=12){
			System.out.println(s.nextInt()/2);
		}else {
			System.out.println(s.nextInt());
		}
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0; i<N; i++){
        cin >> a.at(i);
    }
    vector<int> b(N);
    b = a;
    sort(a.begin(),a.end());
    int med_0 = a.at(N/2 -1);
    int med_1 = a.at(N/2);
    for(int i=0; i<N; i++){
        if(b.at(i) <=  med_0){
            cout << med_1 << endl;
        }
        else if(b.at(i) >=  med_1){
            cout << med_0 << endl;
        }
    }
}


Measured memory_bytes: 3712
#include<iostream>

void insertionSort(int A[],int N){

  int v,j;

  for(int i=0;i<N;i++){
    v=A[i];
    j=i-1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
      A[j+1]=v;
    }

    for(int k=0;k<N;k++){
      if(k>0) std::cout<<' ';
      std::cout<<A[k];
    }
    
    std::cout<<'\n';

  }
}

int main(){
  int N;
  int A[1000];
  
  std::cin>>N;

  for(int i=0;i<N;i++){
    std::cin>>A[i];
  }

  insertionSort(A,N);

  return 0;
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

signed main() {
  int N; 
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));

  int MAX = A[N-1];
  int MID = 0;
  REP(i, N-1){
    if(abs(MAX-MID*2) > abs(MAX-A[i]*2)) MID = A[i];
  }

  cout << MAX << " " << MID << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 100005
#define ll long long
#define inf 0x3f3f3f3f
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,-1,sizeof(x))
using namespace std;
ll n,ans[N];
void dfs(ll m,ll k)
{
	if(k==10)
	{
		if(m>3234566667)
		return;
		ans[n]=m;
		n++;
		return;
	}
	if(!k)
	{
		for(m=1;m<10;m++)
		dfs(m,1);
		return;
	}
	ans[n]=m;
	n++;
	ll t=m%10;
	if(t)
	dfs(m*10+t-1,k+1);
	dfs(m*10+t,k+1);
	if(t<9)
	dfs(m*10+t+1,k+1);
	return;
}
int main()
{
	dfs(0,0);
	sort(ans,ans+100000);
	cin>>n;
	cout<<ans[n-1];
	return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin >> n;
    ll d;
    cin >> d;
    int ans = 0;
    for(int i=0; i<n; i++)
    {
        ll x, y;
        cin >> x >> y;
        ans += (x*x+y*y) <= d*d;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3600
N, M = map(int, input().split())
mod = 10**9 + 7

def comb(n, r, mod):
    if r<0 or r>n:
        return 0
    r = min(r, n-r)
    return fac[n] * (finv[r] * finv[n-r] % mod) % mod

def perm(n, r, mod):
    if r<0 or r>n:
        return 0
    return (fac[n] * finv[n-r]) % mod

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
for i in range(2, max(N + 1, M + 1)):
    fac.append((fac[-1] * i) % mod)
    inv.append((-inv[mod%i] * (mod//i)) % mod)
    finv.append((finv[-1] * inv[-1]) % mod)
c = comb(M, N, mod)
ans = ((fac[N] * c % mod) ** 2) % mod

for i in range(1, N+1):
    ans += (-1)**i * ((comb(N, i, mod) * perm(M, i, mod))%mod * (perm(M-i, N-i, mod)**2)%mod)%mod
    ans %= mod
print(ans)

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

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

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int w,h,n;
  cin>>w>>h>>n;
  vi p(n);
  REP(i,n)cin>>p[i];
  int ax,ay,bx,by;
  ax = bx = 1;
  ay = 1;
  by = 2;
  int res = 0;
  REP(i,n){
    if(p[i]==0){
      // outer
      if(ay==h){
        --ax;
      }else if(ax==w){
        ++ay;
      }else if(ay==1){
        ++ax;
      }
    }else{
      // inner
      if(by==h-1){
        --bx;
      }else if(bx==w-1){
        ++by;
      }else if(by==2){
        ++bx;
      }
    }
    int dist = abs(bx-ax)+abs(by-ay);
    if(dist==1)++res;
  }
  cout<<res<<endl;
  return 0;
}

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

int main(){
	ll a,b,c,k; cin>>a>>b>>c>>k;
	rep(i,k){
		ll ta, tb,tc;
		ta=b+c; tb=a+c; tc=a+b;
		a=ta; b=tb; c=tc;
	}
	if(a-b>1e18) cout<<"Unfair"<<endl;
	else cout<<a-b<<endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<math.h>
 
int main(){
  long n,i=0,flag=0,j;
  scanf("%ld",&n);
  if(n!=0)
  i=(int)log10(n);
  j=pow(10.0,i);
  if(n/j!=(n+1)/j) flag=1;
  n/=j;
  if(!i) printf("%ld\n",n);
  else printf("%ld\t",i*9-1+flag+n);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int a = 0;
  int b = 0;
  int count = 0;
  cin >> N;
  priority_queue<int> pq;
  for (int i=0; i<N; i++) {
    int x;
    cin >> x;
    pq.push(x);
  }
  for (int i=0; i<N; i++) {
    count++;
    if(count % 2 == 1) {
      a += pq.top();
      pq.pop();
    }
    if(count % 2 == 0) {
      b += pq.top();
      pq.pop();
    }
  }
  cout << a - b << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
vector<int>vec1;
const int INF=1e9+5;
int main(){
    int n,k;
    cin>>n>>k;
    int a;
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        vec1.push_back(a);
    }
    vector<int>dpp(n,INF);
    dpp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<i+k+1;j++){
            if(j<n){
                dpp[j]=min(dpp[j],dpp[i]+abs(vec1[i]-vec1[j]));
            }
        }
    }
    cout<<dpp[n-1]<<endl;
}



Measured memory_bytes: 1144
import math

list = input().split()

A = int(list[0])
B = int(list[1])
H = int(list[2])
M = int(list[3])

# 長針
r1 = 90 - (H * 30) - (M * 0.5)
if r1 < 0:
	r1 = 360 + r1

# 短針
r2 = 90 - (M * 6)
if r2 < 0:
	r2 = 360 + r2

# 差分
rdiff = r1 - r2
if rdiff < 0:
	rdiff = r2 - r1
if rdiff > 180:
	rdiff = 360 - rdiff

# 長さ
l = math.sqrt((A*A) + (B*B) - (2*A*B*math.cos(math.radians(rdiff))))

print(l)

Measured memory_bytes: 9528
#include <iostream>
#include <queue>
#include <algorithm>
#include <utility>
using namespace std;

#define fi first
#define se second

typedef pair<int,int> pii;
const int INF = 1e9;

struct edge {
	int x, y;
	int d;

	edge(int x_, int y_, int d_) {
		x = x_; y = y_; d = d_;
	}
};

int main() {
	int N, M, C, S, G;
	while(cin >> N >> M >> C >> S >> G) {
		if(!(N||M||C||S||G)) break;
		vector<vector<edge> > v_company;
		v_company.resize(C);
		for(int i = 0; i < M; i++) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			v_company[c-1].push_back(edge(x-1, y-1, d));
		}
		vector<int> ps;
		vector<vector<pii> > cost;
		ps.resize(C);
		cost.resize(C);
		for(int i = 0; i < C; i++)
			cin >> ps[i];
		for(int i = 0; i < C; i++) {
			cost[i].resize(ps[i]);
			for(int j = 0; j < ps[i]-1; j++)
				cin >> cost[i][j].fi;
			cost[i].back().fi = INF;
			for(int j = 0; j < ps[i]; j++)
				cin >> cost[i][j].se;
		}
		vector<vector<vector<int> > > dist;
		dist.resize(C);
		for(int i = 0; i < C; i++) {
			dist[i].resize(N);
			for(int j = 0; j < dist[i].size(); j++) {
				dist[i][j].resize(N);
				for(int k = 0; k < dist[i][j].size(); k++) {
					dist[i][j][k] = INF;
				}
				dist[i][j][j] = 0;
			}
			for(int j = 0; j < v_company[i].size(); j++) {
				edge a = v_company[i][j];
				dist[i][a.x][a.y] = dist[i][a.y][a.x]
					= min(dist[i][a.x][a.y], a.d);
			}
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					for(int l = 0; l < N; l++) {
						dist[i][k][l] = min(dist[i][k][l],
								dist[i][k][j] + dist[i][j][l]);
					}
				}
			}
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					if(dist[i][j][k] >= INF)
						continue;
					int a = dist[i][j][k];
					int money = 0;
					int l = 0;
					for(int m = 1; m <= a; m++) {
						if(cost[i][l].fi < m) {
							l++;
						}
						money += cost[i][l].se;
					}
					dist[i][j][k] = money;
				}
			}
		}
		vector<vector<int> > ans;
		ans.resize(N);
		for(int i = 0; i < N; i++) {
			ans[i].resize(N);
			for(int j = 0; j < N; j++)
				ans[i][j] = INF;
			ans[i][i] = 0;
		}
		for(int i = 0; i < C; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					ans[j][k] = min(ans[j][k], dist[i][j][k]);
				}
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < N; j++) {
				for(int k = 0; k < N; k++) {
					ans[j][k] = min(ans[j][k], ans[j][i] + ans[i][k]);
				}
			}
		}
		int res = ans[S-1][G-1];
		if(res < INF)
			cout << res << endl;
		else
			cout << -1 << endl;
	}
}

Measured memory_bytes: 2196
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;

int main(void){
	string w;
	int cnt[26]{};

	cin >> w;

	for (int i = 0; i < w.length(); i++){
		cnt[w[i] - 'a']++;
	}

	for (int i = 0; i < 26; i++){
		if (cnt[i] % 2 != 0){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

int main(){
	ll n,W,i,j;
	cin>>n>>W;
	vector<ll> w(n), v(n);
	for(i=0; i<n; ++i)
		cin>>w[i]>>v[i];
	vector<vector<ll>> dp(n+1, vector<ll>(W+1));
	for(i=0; i<=n; ++i){
		for(j=0; j<=W; ++j){
			if (i==0 || j==0)
				dp[i][j]=0;
			else if (w[i-1]<=j)
				dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1], dp[i-1][j]);
			else 
				dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][W]<<"\n";
	return 0;
}


Measured memory_bytes: 80256
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res%=m;
		}
		a*=a;a%=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
LP extGcd(lint a,lint b) {
	if(b==0)return {1,0};
	LP s=extGcd(b,a%b);
	std::swap(s.first,s.second);
	s.second-=a/b*s.first;
	return s;
}
LP ChineseRem(const lint& b1,const lint& m1,const lint& b2,const lint& m2) {
	lint p=extGcd(m1,m2).first;
	lint tmp=(b2-b1)*p%m2;
	lint r=(b1+m1*tmp+m1*m2)%(m1*m2);
	return std::make_pair(r,m1*m2);
}
template<typename F>
inline constexpr decltype(auto) lambda_fix(F&& f){
	return [f=std::forward<F>(f)](auto&&... args){
		return f(f,std::forward<decltype(args)>(args)...);
	};
}
#line 2 "main.cpp"
int N;
int main(){
	std::cin>>N;
	int cnt=0;
	rep(i,N){
		int d1,d2;
		std::cin>>d1>>d2;
		if(d1==d2){
			cnt++;
			if(cnt==3){
				puts("Yes");
				return 0;
			}
		}
		else cnt=0;
	}
	puts("No");
	return 0;
}

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

// Shortening code
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;

// Macros
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = a; i >= b; i--)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    // Your code
    int n, m;
    cin >> n >> m;
    vi a(m);
    int res = 0;
    
    REP(i, 0, m){
        int a;
        cin >> a;
        n -= a;
    }

    cout << (n >= 0 ? n : -1) << endl;
    return 0;
}

Measured memory_bytes: 3660