akhauriyash/Code-Regression huggingface dataset:
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

X = sorted(range(n), lambda i: A[i])
Y = sorted(range(n), lambda i: B[i])

U = [0] * n; V = [0] * n
for i in range(n): U[X[i]] = i
for i in range(n): V[Y[i]] = i

# 何回やっても無理の場合は無理
for i in range(n):
  if A[X[i]] > B[Y[i]]:
    print("No")
    exit()

# 2通り以上の並べ方がある場合はOK 
for i in range(n - 1):
  if A[X[i + 1]] <= B[Y[i]]:
    print("Yes")
    exit()

# ループが小さいループになっていればOK
cnt = 0
i = 0
while cnt < n - 1:
  j = X[i]
  i = V[j]
  if i == 0:
    print("Yes")
    exit()
  cnt += 1

print("No")

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

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

    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i];

    rep(i, N) {
        if (N - 2 * i - 1 >= 0) B[i] = A[N - 2 * i - 1];
        else B[i] = A[2 * i - N];
    }

    rep(i, N) cout << B[i] << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    cout<<fixed<<setprecision(15);
    
    ll n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            ans+=(a[i]*a[j]);
        }
    }
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  private static class Shop {
    Long price = 0L;
    Long stock = 0L;
    Shop(long price, long stock) {
      this.price = price;
      this.stock = stock;
    }
  }
  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    PriorityQueue<Shop> pq = new PriorityQueue<>((Shop s1, Shop s2) -> s1.price.compareTo(s2.price));
    for (int i = 0; i < n; i++) {
      pq.add(new Shop(sc.nextLong(), sc.nextLong()));
    }
    long sum = 0L;
    while (m > 0) {
      Shop s = pq.poll();
      long buy = Math.min(m, s.stock);
      sum += s.price * buy;
      m -= buy;
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 51776
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int ans = C-(A-B);
        if(ans <0){
            ans = 0;
        }
        System.out.println("" + ans);
    }

}

Measured memory_bytes: 20948
/**
*    created: 08.05.2020 09:17:01
**/

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int inf =1000000000;

int k;
vector<ll> C;


void lunlun(ll A){
    C.push_back(A);
    if(A>=10000000000ll) return;
    //終端条件
    
    for (int i = -1; i < 2; i++)
    {
        int vv = i + A%10;
        if(vv>-1&&vv<10) lunlun(A * 10 + vv);
        //↑次のノードへの遷移
        //再帰呼び出し
        
    }
}

int main() {
    cin >> k;
    
    for (int i = 1; i <= 9;i++)
    {
        lunlun(i);

    }
    sort(C.begin(), C.end());
    cout << C[k-1] << endl;
}

Measured memory_bytes: 10604
/*************************************************************************
> File Name: test.cpp
> Author: Akira 
> Mail: qaq.febr2.qaq@gmail.com 
************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
#define ALL(a) a.begin(), a.end()
#define mp make_pair
#define pb push_back
using namespace std;                                                                                              

#define MaxN 200005
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
inline int max2(int a, int b) {return ((a > b)? a : b);}
inline int min2(int a, int b) {return ((a < b)? a : b);}
inline int max3(int a, int b, int c) {return max2(a, max2(b, c));}
inline int min3(int a, int b, int c) {return min2(a, min2(b, c));}
template <class T> inline void read(T &ret) {char c; ret=0;while((c=getchar())<'0'||c>'9');while(c>='0'&&c<='9') ret=ret*10+(c-'0'),c=getchar();}
template <class T> inline void out(T x) {if(x>9) out(x/10);putchar(x%10+'0');}

char str[MaxN];
int len,cnt[30];
int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%s", str))
    {
        len = strlen(str);
        CLR(cnt);
        LL ans = 1LL*len*(len-1)/2;
        for(int i=0;i<len;i++)
        {
            cnt[str[i]-'a']++;
        }
        for(int i=0;i<26;i++)
        {
            ans -= 1LL*cnt[i]*(cnt[i]-1)/2;
        }
        ans+=1;
        out(ans);puts("");
    }
    // system("pause");
    //printf("%lld\n", ((x)%mod+mod)%mod );
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
}


Measured memory_bytes: 384
// ref: https://qiita.com/tubo28/items/e6076e9040da57368845
use std::io::{stdin, Read};
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let k: u32 = read();
    let ans = k * (k - 1).pow(n - 1);
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
 
    int k, n;
    cin >> k >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    set<int> s;
    s.insert(k - v[n-1] + v[0]);
    for (int i = 1; i < n; i++) {
        s.insert(v[i] - v[i-1]);
    }
    cout << k - *s.rbegin() << endl;
 
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if(a==b){
		cout << "Draw" << endl;
	}
	else if(a==1){
		cout << "Alice" << endl;
	}
	else if(b==1){
		cout << "Bob" << endl;
	}
	else if(a>b){
		cout << "Alice" << endl;
	}
	else{
		cout << "Bob" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = 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 PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

// O(|V||E|)
struct edge {int from, to, cost;};
bool Bellman_Ford(int V, int E, int s, edge es[], LL dist[]) {
    fill(dist, dist + V, LLINF);
    dist[s] = 0;
    int cnt = 0;
    while (true) {
        bool update = false;
        set<int> se;
        for (int i = 0; i < E; ++i) {
            bool f = (dist[es[i].from] != LLINF && chmin(dist[es[i].to], dist[es[i].from] + es[i].cost));
            if (f) se.insert(es[i].to);
            update |= f;
        }
        if (!update) break;
        if (cnt == V - 1) {
            if (se.count(V - 1)) return true;
            break;
        }
        ++cnt;
    }
    return false;
}

const int MAX_N = 1010;
const int MAX_M = 2020;
int N, M;
edge e[MAX_M];

int main(void) {
    scanf("%d%d", &N, &M);
    REP(i, M) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        e[i] = {a - 1, b - 1, -c};
    }
    vector<LL> dist(N);
    if (Bellman_Ford(N, M, 0, e, dist.data())) {
        cout << "inf" << endl;
        DEBUG(-dist[N - 1])
    } else cout << -dist[N - 1] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	for(;;) {
		int d,n,m;
		scanf("%d",&d);
		if(d==0)break;
		scanf("%d%d",&n,&m);
		vector<int> miss(n);
		miss[0]=0;
		for(int i=1;i<n;i++){
			scanf("%d",&miss[i]);
		}
        sort(miss.begin(),miss.end());
		int sum=0;
		for(int i=0;i<m;i++){
			int ins;
			scanf("%d",&ins);
			int r=-1,l=n;
			while(r+1<l){
				int mid=(r+l)/2;
				if(miss[mid]<=ins) r=mid;
				else l=mid;
			}
			if(r==n-1) sum+=min(ins-miss[r],d-ins);
			else sum+=min(ins-miss[r],miss[l]-ins);
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 1232
#include<iostream>
using namespace std;
#define ll long long
#include<bits/stdc++.h>
int main(){
  int n,m;
  cin>>n>>m;
  int sum1=n*(n-1)/2;
  int sum2=m*(m-1)/2;
  cout<<sum1+sum2<<"\n";
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static final long MOD = (long) 1e9 + 7;
	static final int MAX = (int) 1e5 + 1;

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), m = sc.nextInt();
		long[] fact = new long[MAX];
		fact[0] = fact[1] = 1;
		for (int i = 2; i < MAX; i++)
			fact[i] = (i * fact[i - 1]) % MOD;
		if (n == m)
			out.println((((fact[n] * fact[m]) % MOD) << 1) % MOD);
		else if (n + 1 == m || n - 1 == m)
			out.println((fact[n] * fact[m]) % MOD);
		else
			out.println(0);
		out.flush();
		out.close();
	}

	static class MyScanner {
		StringTokenizer st;
		BufferedReader br;

		public MyScanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public MyScanner(String file) throws IOException {
			br = new BufferedReader(new FileReader(new File(file)));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public boolean ready() throws IOException {
			return br.ready();
		}
	}
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

set<int> g[200001];
int main(){
    fastio;
    //clock_t tm = clock();
    int n;
    cin>>n;
    vi a(n),b(n),na(n+1,0),nb(n+1,0);
    priority_queue<pii>g1;
    f(i,0,n){
        cin>>a[i];na[a[i]]++;
        g[a[i]].insert(i);
    }
    f(i,0,n){
        cin>>b[i];nb[b[i]]++;
    }
    priority_queue<pii>g2;
    f(i,1,n+1){
        if(na[i]+nb[i]>n){
            cout<<"No"<<endl;
            return 0;
        }
        if(nb[i]>0){
            g2.push({nb[i],-i});
        }
        if(na[i]>0){
            g1.push({na[i],i});
        }
    }
    reverse(all(b));
    vi ans(n,0);
    while(!g2.empty()){
        auto pr=g2.top();
        g2.pop();
        if(pr.first>1){
            --pr.first;
            g2.push(pr);
        }
        pr.second*=-1;
        auto qr=g1.top();
        g1.pop();
        if(qr.second!=pr.second) {
            if (qr.first > 1) {
                --qr.first;
                g1.push(qr);
            }
            ans[*g[qr.second].begin()]=pr.second;
            g[qr.second].erase(*g[qr.second].begin());
        }
        else{
            if(g1.empty())break;
            auto qr1=g1.top();
            g1.pop();g1.push(qr);qr=qr1;
            if (qr.first > 1) {
                --qr.first;
                g1.push(qr);
            }
            ans[*g[qr.second].begin()]=pr.second;
            g[qr.second].erase(*g[qr.second].begin());
        }
    }
    cout<<"Yes"<<endl;
    fr(i,ans)cout<<i<<" ";
    cout<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 29052
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

long long e, v;

class pass
{
public:
	long long t;
	long long c;
	long long p;
};

pass p[250000];

long long noded[2000];
pair<long long, long long> nodef[2000];
vector<long long> node[2000];

void add(long long f, long long t, long long c)
{
	p[e].t = t;
	p[e].c = c;
	p[e].p = e + 1;
	p[e + 1].t = f;
	p[e + 1].c = 0;
	p[e + 1].p = e;
	node[f].push_back(e);
	node[t].push_back(e + 1);
	e += 2;
}

void push()
{
	priority_queue<pair<long long, long long>> q;
	for (long long i = 0; i < v; i++)
	{
		noded[i] = 0;
		nodef[i] = make_pair(0, 0);
	}
	noded[0] = v;
	for (auto i : node[0])
	{
		if (p[i].c > 0)
		{
			p[p[i].p].c += p[i].c;
			nodef[p[i].t].first += p[i].c;
			nodef[0].second += p[i].c;
			p[i].c = 0;
			q.push(make_pair(0, p[i].t));
		}
	}
	nodef[v - 1].second = ((long long)1 << 50);
	while (!q.empty())
	{
		long long np = q.top().second;
		q.pop();
		while (1)
		{
			for (auto i : node[np])
			{
				if (p[i].c > 0)
				{
					long long t = p[i].t;
					if (noded[np] == noded[t] + 1)
					{
						long long kae = min(p[i].c, nodef[np].first - nodef[np].second);
						p[i].c -= kae;
						p[p[i].p].c += kae;
						nodef[np].second += kae;
						bool w = (nodef[t].first <= nodef[t].second);
						nodef[t].first += kae;
						if (w && nodef[t].first > nodef[t].second)
						{
							q.push(make_pair(noded[t], t));
						}
						if (nodef[np].first <= nodef[np].second)
						{
							break;
						}
					}
				}
			}
			if (nodef[np].first > nodef[np].second && np != 0)
			{
				long long minw = ((long long)1 << 50);
				for (auto i : node[np])
				{
					if (p[i].c > 0)
					{
						minw = min(minw, noded[p[i].t]);
					}
				}
				noded[np] = minw + 1;
			}
			else
			{
				break;
			}
		}
	}
}

long long dn[2000];
long long dm[2000];

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

int main()
{
	while (1)
	{
		long long n, m;
		scanf("%lld%lld", &n, &m);
		if (n == 0)
		{
			break;
		}
		v = n + m + 2;
		e = 0;
		for (long long i = 0; i < n; i++)
		{
			scanf("%lld", &dn[i]);
			add(0, 1 + i, 1);
		}
		for (long long i = 0; i < m; i++)
		{
			scanf("%lld", &dm[i]);
			add(n + 1 + i, n + m + 1, 1);
		}
		for (long long i = 0; i < n; i++)
		{
			for (long long ii = 0; ii < m; ii++)
			{
				if (1 < gcd(dn[i], dm[ii]))
				{
					add(1 + i, n + 1 + ii, 1);
				}
			}
		}
		push();
		long long all = 0;
		for (auto i : node[0])
		{
			if (i % 2 == 0)
			{
				all += p[p[i].p].c;
			}
		}
		printf("%lld\n", all);
		for (long long i = 0; i < v; i++)
		{
			node[i].clear();
		}
	}
	return 0;
}

Measured memory_bytes: 10952
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,a) repi(i,0,a)
int D, ds[512];
set<tuple<int,int,int>> done;

bool dfs(int cl, int d, int cnt){
    if(d<D and cl&ds[d]) return 0;
    auto v = make_tuple(cl,d,cnt);
    if(done.count(v)) return 0;
    done.insert(v);
    for(int i: {0, 3, 12, 15}){
        int c = (cnt>>(i*3))&7;
        cnt ^= c<<(i*3);
        if(cl&(1LL<<i)) c = 0;
        else c++;
        if(c == 7) return 0;
        cnt ^= c<<(i*3);
    }
    if(d == D) return 1;
    rep(i,2) {
        if(dfs(cl,d+1,cnt)) return 1;
        if(!((4369<<i)&cl) and dfs(cl>>(i+1), d+1, cnt)) return 1; // left
        if(!((34952>>i)&cl) and dfs(cl<<(i+1), d+1, cnt)) return 1; // right
        if(!((15<<(i*4))&cl) and dfs(cl>>((i+1)*4), d+1, cnt)) return 1; // up
        if(!((61440>>(i*4))&cl) and dfs(cl<<((i+1)*4), d+1, cnt)) return 1; // down
    }
    return 0;
}

int solve(){
    done.clear();
    return dfs(1632, 0, 0);
}

bool input(){
    cin >> D;
    if(!D) return 0;
    rep(i,D){
        int b = 0;
        rep(j,16) {
            int a; cin >> a;
            b |= a << j;
        }
        ds[i] = b;
    }
    return 1;
}
signed main(){
    while(input()){ cout << solve() << endl;}
    return 0;
}

Measured memory_bytes: 11152
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>

using namespace std;


int main(void){
    int n,k;

    cin >> n >> k;

    int a[n];

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

    int ans=0;
    if(n==k){
        cout << 1 << endl;
        return 0;
    }

    for(int i=0;i<n;ans++){
        if(i==0){
            i = i +k;
        }
        else{
            i = i + k -1;
        }
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 640
#include<stdio.h> 

int main()
{
	int a,b,c,i,j,k,l,N=0,cnt=0;
scanf("%d",&N);
int A[N];
for(k=0;k<N;k++){
 scanf("%d",&A[k]);
}

	for (i=0;i<N-1;i++)
	{
        c=A[i];
		a=i;
		for (j=i;j<N;j++)
		{
            if (c>A[j]){
		    a=j;
            c=A[j];
            }
		}
        if(A[i]!=c){
        b=A[i];
		A[i]=A[a];
		A[a]=b;
        cnt++;
        }
    }
for(l=0;l<N-1;l++){
    printf("%d ",A[l]);
}
printf("%d\n",A[N-1]);
printf("%d\n",cnt);

	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>

#include <string>
#include <algorithm>

using namespace std;

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

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
	cout << "Possible" << endl;
  } else {
	cout << "Impossible" << endl;
  }
  
  return (0);
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
vl modinv;
void fillModInv(ll n, ll mod){
  modinv = vl(n+1);
  modinv[1] = 1;
  FOR(i,2,n+1){
    modinv[i] = modinv[mod%i] * (mod - mod/i) % mod;
  }
}
/*}}}*/
int main() {
  ll n,m;
  cin >> n >> m;

  if(n%2==1){
    REP(i,m){
      ll a = i+1;
      ll b = n-a;
      cout << a << " " << b << endl;
    }
  }else{
    ll k = min(n/4,m);
    REP(i,k){
      ll a = i+1;
      ll b = 2*k-i;
      cout << a << " " << b << endl;
    }
    ll l = m - k;
    if(l<=0) return 0;
    REP(i,l){
      ll a = 2*k+1+i;
      ll b = n-1-i;
      cout << a << " " << b << endl;
    }
  }
  
  //cout << fixed << setprecision(10);
  return 0;
}


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

struct Place
{
  int index;
  int sum;

  bool operator<( const Place& right ) const
  {
    return sum == right.sum ? index < right.index : sum > right.sum;
  }
};

int main(void)
{
  while (true)
  {
    int n, m;
    cin >> n >> m;
    if (n == 0 and m == 0 ) break;
    vector<Place> result(m);
    for (int i = 0; i < m; ++i)
    {
      result[i].index = i + 1;
    }

    for (int i = 0; i < n; ++i)
    {
      for (int j = 0; j < m; ++j)
      {
        int buf;
        cin >> buf;
        result[j].sum += buf;
      }
    }

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

    for (int i = 0; i < m; ++i)
    {
      cout << result[i].index;
      if (i == m - 1)
      {
        cout << endl;
      }
      else
      {
        cout << ' ';
      }
    }
  }
  return 0;
}

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

ll B,N,ans = 0,saidai=0;
string S;
vector<ll> A(100005);

int sei=0,hu=0;

priority_queue<ll> p;
priority_queue<ll> m;

int main(){
	cin>>N;
	A.resize(N);
	
	for(int i=0;i<N;i++){
		cin>>A.at(i);
		saidai += abs(A.at(i));
		if(A.at(i)<0){
			m.push(A.at(i));
			hu++;
		}
		else if(A.at(i)>=0){
			p.push(A.at(i));
			sei++;
		}
	}
	sort(A.begin(),A.end());
	
	if(hu==0 && sei>=1){
		ans -=A.at(0);
		for(int i=1;i<N;i++)
			ans += A.at(i);

		cout<<ans<<endl;//最大値の出力
		B = A.at(0);
		for(int i=1;i<N-1;i++){
			cout<<B<<" "<<A.at(i)<<endl;
			B = B - A.at(i);
		}
		cout<<A.at(N-1)<<" "<<B<<endl;
	}
	else if(hu>=1 && sei==0){
		reverse(A.begin(),A.end());
		ans +=A.at(0);
		for(int i=1;i<N;i++)
			ans -= A.at(i);

		cout<<ans<<endl;//最大値の出力
		B = A.at(0);
		for(int i=1;i<N-1;i++){
			cout<<B<<" "<<A.at(i)<<endl;
			B = B - A.at(i);
		}
		cout<<B<<" "<<A.at(N-1)<<endl;
	}


	else{
		//cout<<sei<<" "<<hu<<endl;
		cout<<saidai<<endl;
		for(int i=0;i<N-1;i++){
			if(sei<=hu){
				cout<<p.top()<<" "<<m.top()<<endl;
				ll xy = p.top()-m.top();
				p.pop();
				m.pop();
				p.push(xy);
				hu--;
			}
			else{
				cout<<m.top()<<" "<<p.top()<<endl;
				ll xy = m.top()-p.top();
				p.pop();
				m.pop();
				m.push(xy);
				sei--;
			}
		}
	}

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
 
#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
 
using namespace std;
#define prime 1000000007
 
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
int n;
string s;

int main(){
	cin >> n >> s;
	int ans = 0;
	for (int i = 1; i < n; ++i){
		if(s[i] != s[i-1])ans++;
	}

	cout << ans+1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD = 1e9+7;
LL dp[50][1<<17];
int n,x,y,z;LL mask;

LL solve(LL a,LL b) {
    if (dp[a][b]!=-1) return dp[a][b];
    if ((b>>(x+y+z-1))&1 && (b>>(y+z-1))&1 && (b>>(z-1))&1) return 0;
    if (a==n) return 1;
    LL ret=0;
    for (int i=1;i<=10;++i) {
        ret+=solve(a+1,((b<<i)+((1<<(i-1))))&mask);
        ret%=MOD;
    }
    return dp[a][b]=ret;
}
int main() {
    scanf("%d%d%d%d",&n,&x,&y,&z);
    mask=(1LL<<(x+y+z))-1;
    LL ans=1;for (int i=1;i<=n;++i) ans=ans*10%MOD;
    memset(dp,0xff,sizeof dp);
    ans-=solve(0,0);while (ans<0) ans+=MOD;
    ans%=MOD;
    printf("%lld\n",ans);
    return 0;
}


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


int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int>> v(n,vector<int>(d));
    rep(i,n)   {
        rep(j,d){
            cin >> v.at(i).at(j);
        }
    }
    int ans =0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            int tot=0;
            for(int k=0;k<d;k++){
                int p =abs(v[i][k]-v[j][k]);
                tot+=p*p;
            }
          
            bool uu =false;
            rep(k,tot+1){
                if(k*k==tot){
                    uu =true;
                }
            }
            if(uu) ans++;
          
        }
    }
    cout << ans <<endl;
}

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

bool trySolve(ll l, ll r, pair<ll, ll>& ans) {
  // a-b == l
  // b = a - l
  for(ll a = -1000; a <= 1000; a++) {
    ll b = a - l;
    ll x = a*a*a*a+a*a*a*b+a*a*b*b+a*b*b*b+b*b*b*b;
    if (x == r) {
      ans = {a, b};
      return true;
    }
  }
  return false;
}

int main() {
  ll X;
  cin >> X;
  for(ll l = 1; l*l <= X; l++) {
    if (X % l == 0) {
      pair<ll, ll> ans;
      if(trySolve(l, X/l, ans)) {
        cout << ans.first << " " << ans.second << endl;
        exit(0);
      }
    }
  }
  exit(1);
}

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

using namespace std;

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

   int gooyen = 1000;
   int gyen = 5;
   long int hpcot = 0;

   while(X >= 500) {
      X -= 500;
      hpcot += gooyen;
   }

   while(X >= 5) {
      X -= 5;
      hpcot += gyen;
   }

   cout << hpcot << endl;
}


Measured memory_bytes: 256
#![allow(unused)]

use std::{cell, cmp, collections, convert, fmt, io, iter, ops, str};

use cell::{Cell, RefCell};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($($args: tt)*) => { eprint!($($args)*) };
}

#[cfg(feature = "debug")]
macro_rules! debugln {
    ($($args: tt)*) => { eprintln!($($args)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($($args:tt)*) => {};
}

#[cfg(not(feature = "debug"))]
macro_rules! debugln {
    ($($args:tt)*) => {};
}

macro_rules! vmax {
    ($x: expr, $y: expr) => { cmp::max($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::max($x, vmax!($($args),*)) };
}

macro_rules! vmin {
    ($x: expr, $y: expr) => { cmp::min($x, $y) };
    ($x: expr, $($args: expr),*) => { cmp::min($x, vmin!($($args),*)) };
}

fn main() {
    let n = parse_line::<usize>();
    let a = parse_vec::<u32>();

    let pow2_cnt = |mut x: u32| {
        let mut cnt = 0;
        while x % 2 == 0 {
            cnt += 1;
            x /= 2;
        }
        cnt
    };

    println!("{}", a.iter().map(|&e| pow2_cnt(e)).sum::<u32>());
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if !buf.is_empty() {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn next_prime(x: i32) -> i32 {
    for i in (x + 1).. {
        if is_prime(i) {
            return i;
        }
    }

    panic!("attempt to add with overflow");
}

fn is_prime(x: i32) -> bool {
    let ceil = f64::from(x).sqrt().ceil() as i32;
    x == 2 || (2..(ceil + 1)).all(|i| x % i != 0)
}


Measured memory_bytes: 4352
n,y = map(int,input().split())

for i in range(n+1):
  for j in range(n+1):
    if i*10000+j*5000+(n-i-j)*1000==y and n-i-j>=0:
      print(i,j,n-i-j)
      exit()
print(-1,-1,-1)

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

int main() {
  int X;
  cin >> X;
  for (int A = -118; A <= 119; ++A) {
    for (int B = -118; B <= 119; ++B) {
      if (A * A * A * A * A - B * B * B * B * B == X) {
        cout << A << ' ' << B << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3552
#include <iostream>
using namespace std;
int main(){
	int n;
	int m;
	while( cin >> n >> m && n ){
		int a[11] = {};
		for( int i = 0; i < n; i++ ){
			int d, p;
			cin >> d >> p;
			a[p] += d;
		}
		int result = 0;
		for( int i = 10; i > 0 && m; i-- ){
			while( m ){
				if( a[i] > 0 ){
					a[i]--;
					m--;
				}else{
					break;
				}
			}
		}

		for( int i = 1; i <= 10; i++ ){
			result += a[i] * i;
		}
		cout << result << endl;
	}
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i, n) for(long int i = 0; i < n; i++)

long int bi(long int x){
    long int c = 0;
    while(x % 2 == 0){
        x /= 2;
        c++;
    }
    return c;
}

long int gcd(long int x, long int y){
    if(y == 0) return x;
    return gcd(y, x % y);
}

long int lcm(long int x, long int y){
    return (x/ gcd(x, y)) * y ;
}

int main(){
    long int n;
    long int m;
    cin >> n >> m;
    long int a[n];
    rep(i, n) {
        cin >> a[i];
        a[i] /= 2;
    }
    long int b = bi(a[n-1]);
    rep(i, n){
        if(bi(a[i]) != b){
            cout << 0 << endl;
            return 0;
        }
    }
    
    long int num = a[0];
    // cout << -1 << endl;
    for(int i = 1; i < n; i++){
        num = lcm(num, a[i]);
        if(num > 1000000000){
            cout << 0 << endl;
            return 0; 
        }
    }
    long int ans = ((m / num) / 2) + ((m / num) % 2);
    // cout << num << endl;
    cout << ans << endl;
}

Measured memory_bytes: 1024
//
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ar array
#define vec vector 


void solve(){
    int k; cin >> k;
    queue<ll> qu;
 
    for(ll i = 1; i < 10;i++) qu.push(i);
 
    while(k > 0){
        ll n = qu.front();
        qu.pop();
        k--;
        if(k==0) cout << n << endl;
        ll m = n%10;
        if(m != 0) qu.push(n*10+m-1);
        qu.push(n*10+m);
        if(m != 9) qu.push(n*10+m+1);
    }
}

int main(){
    solve();
}



Measured memory_bytes: 1792
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    double x;cin>>x;
    double ans = 1;
    ans *= x/3;
    ans *= x/3;
    ans *= x/3;
    
    printf("%.10f", ans);
    return 0;
}


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

#define _max(_x, _y) ((_x)>(_y)?(_x):(_y))
#define _min(_x, _y) ((_x)>(_y)?(_y):(_x))

int main(void)
{
  char S[100];
  int i, len, partlen, maxpartlen;
  scanf("%s", S);
  len=strlen(S);
  partlen=0;
  maxpartlen=0;

  for (i=0; i<len; ++i) {
    if (S[i]=='A' ||
        S[i]=='C' ||
        S[i]=='G' ||
        S[i]=='T') {
      partlen++;
      maxpartlen=_max(partlen, maxpartlen);
    } else {
      partlen=0;
    }
  }
  printf("%d\n", maxpartlen);
  return 0;
}

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

namespace ABC087a
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;

            // キーボードから数値を読み込む
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());

            // 出力値を計算
            c = (x - a) % b;

            // 結果を表示
            Console.WriteLine(c);

            Console.ReadKey();
        }
    }
}


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

int n;
vector<int> X, Y;

double g(double x, double y) {
    double ma = 0;
    rep(i, n) {
        ma = max(ma, sqrt((X[i] - x) * (X[i] - x) + (Y[i] - y) * (Y[i] - y)));
    }
    return ma;
}

double f(double x) {
    double low_y = 0, high_y = 1000;
    while (high_y - low_y > 1e-8) {
        double c1 = (low_y * 2 + high_y) / 3, c2 = (high_y * 2 + low_y) / 3;
        if (g(x, c1) < g(x, c2)) high_y = c2;
        else low_y = c1;
    }
    return g(x, high_y);
}

int main() {
    cin >> n;
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        X.push_back(a), Y.push_back(b);
    }
    double low_x = 0, high_x = 1000;
    while(high_x - low_x > 1e-8) {
        double c1 = (low_x * 2 + high_x) / 3, c2 = (high_x * 2 + low_x) / 3;
        if (f(c1) < f(c2)) high_x = c2;
        else low_x = c1;
    }
    cout << fixed << setprecision(8) << f(low_x) << endl;
    return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int N,ans=0;
  cin >> N;
  int a[N+10];
  for(int i=1; i<=N; i++) cin >> a[i];
  for(int i=1; i<=N; i++){
    if(a[a[i]]==i) ans+=1;
  }cout << ans/2 << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

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

    //value -> index
    map<int,int> m;
    vector<int> a(n);
    rep(i,n)
    {
        scanf(" %d", &a[i]);
        m[a[i]]=i;
    }

    //sorted_a
    vector<int> b(a);
    sort(all(b));

    int ans=0;
    rep(i,n)
    {
        // printf("%d %d\n",i,m[b[i]]);
        if(i%2 != m[b[i]]%2) ++ans;
    }
    cout << ans/2 << endl;
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	ll fpow(ll base, ll power, ll MOD) {
    ll result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	ll modinv(ll x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n,k;
		ll pr=1;
		cin>>n>>k;
		vll A(n);
		forn(i,n)
		{
			cin>>A[i];
			if(i<k)
			{
				pr=(pr*A[i]);
			}
		}		
		forab(i,k,n-1)
		{
			ll temp=pr;
			//temp=(temp*modinv(A[i-k]))%mod;
			temp/=A[i-k];
			temp=(temp*A[i]);
			if((A[i])>(A[i-k]))
			{
				cout<<"Yes"<<endl;
			}
			else
			{
				cout<<"No"<<endl;
			}
			pr=temp;
		}
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		///cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int a[200000];
int main(int argc, const char * argv[])
{
    int n;
    cin>>n;
    bool found=true;
    for(int i=0;i<n;i++)
        cin>>a[i];
    sort(a, a+n);
    for(int i=1;i<n;i++)
    {
        if(a[i-1]==a[i])
        {
            found=false;
            break;
        }
    }
    if(found)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int pare[2*100000+1];
int treerank[2*100000+1];
int num[2*100000+1];

int parev[2*100000+1];
int rankv[2*100000+1];

bool strsort(const pair<int,int> &a,pair<int,int> &b){
    return a.first==b.first ? a.second<b.second : a.first<b.first;
}

int find(int p){
    if(p==pare[p])return p;
    return pare[p]=find(pare[p]);
}

void unite(int p,int q){
    p=find(p);
    q=find(q);
    if(p==q)return;
    if(treerank[p]>treerank[q]){
        pare[q]=p;
    }else{
        pare[p]=q;
        if(treerank[p]==treerank[q]){
            treerank[q]++;
        }
    }
}

int findv(int p){
    if(p==parev[p])return p;
    return parev[p]=findv(parev[p]);
}
void unitev(int p,int q){
    p=findv(p);
    q=findv(q);
    if(p==q)return;
    if(rankv[p]>rankv[q]){
        parev[q]=p;
    }else{
        parev[p]=q;
        if(rankv[p]==rankv[q]){
            rankv[q]++;
        }
    }
}

int main(){

    int N,K,L;
    cin>>N>>K>>L;
    REP(i,N){
        pare[i+1]=i+1;
        num[i+1]=1;
        treerank[i+1]=0;
        parev[i+1]=i+1;
        rankv[i+1]=0;
    }

    REP(i,K){
        int p,q;
        cin>>p>>q;
        unite(p,q);
    }
    REP(i,L){
        int r,s;
        cin>>r>>s;
        unitev(r,s);
    }
    vector < pair <int,int> > v;
    REP(i,N){
        v.push_back(pair<int,int>(find(i+1),findv(i+1)));
    }
    sort(ALL(v),strsort);

    pair<int,int> bef(-1,-1);
    REP(i,N){
        int ans=upper_bound(ALL(v),pair<int,int>(find(i+1),findv(i+1)))-lower_bound(ALL(v),pair<int,int>(find(i+1),findv(i+1)));
        cout<<ans;
        if(i==N-1)cout<<endl;
        else cout<<' ';
    }
    cout<<endl;


    return 0;
}

Measured memory_bytes: 6260
n, m = gets.to_s.split.map{|i| i.to_i }

# bits = Array.new(n){|i| 2**i }
# p bits = Array.new(12){|i| 2**i } #=> [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048]
shops = Array.new(m) do
  a = gets.to_s.to_i
  c = gets.to_s.split.map{|i| i.to_i - 1 }
  [c.reduce(0){|s,t| s + (1 << t) }, a]
end.sort_by{|(bit, _)| bit }

inf = 10 ** 10
state_size = 2 ** n
d = Array.new(state_size, inf)
d[0] = 0

state_max = 0
shops.each do |(bit, a)|
  state_max |= bit
  state_max.times do |k|
    new = k | bit
    d[new] = d[k] + a if d[new] > d[k] + a
  end
  
end

puts d[-1] == inf ?  -1 : d[-1]

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

int main(){
  ll h;
  cin >> h;
  ll coeff = 1;
  ll ans = 0;
  while(h > 0){
    ans += coeff;
    coeff *= 2;
    h /= 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

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

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

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: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <math.h>
#include <map>
#include <stack>
using namespace std;
static const int INF = 1e9+7;
// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i =a; i < b; i++)
#define all(a) a.begin(), a.end()
#define PI 3.14159265359

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int x = 0;
    int max_x = 0;
    rep(i, n){
        if(s[i] == 'I'){
            x++;
        }else{
            x--;
        }
        if(x > max_x) max_x = x;

    }

    cout << max_x << endl;

    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] b = new int[n-1];
			long[] c = new long[n];
			long sum = 0;
			
			for(int i=0;i<n;i++){
				sum += sc.nextInt();
			}
			for(int i=0;i<n-1;i++){
				b[i] = sc.nextInt();
			}
			Arrays.sort(b);
			
			long p = 0;
			for(int i=0;i<n;i++){
				c[i] = (sum+p)*(n-i);
				if(i!=n-1)p+=b[n-2-i];
			}
			Arrays.sort(c);
			
			System.out.println(c[n-1]);
		}
	
	}	
}

Measured memory_bytes: 161368