akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define len(x) (int)x.length()
#define ac(x, i) get<i>(x)
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll ,ll>
#define pli pair<ll, int>
#define ff first
#define ss second
#define trace(x)    cerr << #x << ": " << x << "\n"
#define trav0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trav1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << a[i] << ", "; cerr << "]\n"
#define trap0(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 0; i < n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define trap1(a, n) cerr << #a << "[" << n <<  "] = ["; for (int i = 1; i <= n; i++) cerr << "(" << a[i].ff << ", " << a[i].ss << "), "; cerr << "]\n"
#define travMap(a)  cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << "(" << i.ff << ", " << i.ss << "), "; cerr << "]\n"
#define traverse(a) cerr << #a << "[" << sz(a) <<  "] = ["; for (auto i : a) cerr << i << ", "; cerr << "]\n"
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;
const int infi = 1e9;
const ll infl = 1e18;
const int MOD = 1e9 + 7;
template <typename Map> bool map_compare (Map const &lhs, Map const &rhs) { return lhs.size() == rhs.size() && std::equal(lhs.begin(), lhs.end(), rhs.begin());}
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 mt(seed);
int randint(int p = MOD) { return mt() % p;}
ll randlong(ll p = infl) { return mt() % p;}
#define random_permute(x) shuffle(all(x), mt)
ll log_2 (ll n) { return (n > 1ll)? 1ll + log_2(n/2): 0ll;}
inline void add(ll&a, ll b) {a += b; if (a >= MOD) a -= MOD;}
inline void sub(ll&a, ll b) {a -= b; if (a < 0) a += MOD;}

signed main() {
#ifdef HP
  freopen("input.txt", "r", stdin);
#endif
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int k, n;
  cin >> k >> n;
  int first;
  int p, q, s = 0, m = 0;
  cin >> first;
  p = first;
  first += k;
  for (int i = 2; i <= n; i++) {
    cin >> q;
    s += q - p;
    if (m < q - p) m = q - p;
    p = q;
  }
  s += first - p;
  if (m < first - p) m = first - p;
  s -= m;
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 256
from math import floor, ceil
n = int(input())
f = floor(n/1.08)
c = ceil(n/1.08)
n2 = floor(f*1.08)
n3 = floor(c*1.08)
if n == n2:
    print(f)
elif n == n3:
    print(c)
else:
    print(':(')

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

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

	long long ans = A - B;
	if( K % 2 ) {
		long long a = A, b = B, c = C;
		A = b + c;
		B = a + c;
		C = a + b;
		ans = A - B;
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string t[]={"qazwsxedcrfvtgb","yhnujmikolp"};
int tp(string s){
  int rl,cnt=0;
  for(int i=0;i<2;++i)
    if(t[i].find(s[0])!=string::npos) rl=i;
  for(int i=1;i<s.size();++i)
    for(int j=0;j<2;++j)
      if(t[j].find(s[i])!=string::npos)
        if(j!=rl) cnt++, rl=j;
  return cnt;
}
int main(){
  string s;
  while(cin>>s, s!="#"){
    cout<<tp(s)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3120
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL 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; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

double a, b;

int main(){
    INIT;
    cin >> a >> b;
    cout << fixed << setprecision(13) << a/b << endl;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int h,w,i,j,x,y,fac,graph[505][505],cnt=0,seq[250005][4];
int main()
{
	fac=1;
	scanf("%d%d",&h,&w);
	for(i=1;i<=h;i++)for(j=1;j<=w;j++)scanf("%d",&graph[i][j]);
	x=1;y=1;
	while(x<=h)
	{
		while(y+fac>0&&y+fac<=w)
		{
			if(graph[x][y]%2)
			{
				cnt++;
				seq[cnt][0]=x;
				seq[cnt][1]=y;
				seq[cnt][2]=x;
				seq[cnt][3]=y+fac;
				graph[x][y]--;
				graph[x][y+fac]++;
			}
			y+=fac;
		}
		if(graph[x][y]%2&&x<h)
		{
			cnt++;
			seq[cnt][0]=x;
			seq[cnt][1]=y;
			seq[cnt][2]=x+1;
			seq[cnt][3]=y;
			graph[x][y]--;
			graph[x+1][y]++;
		}
		fac*=-1;
		x++;
	}
	printf("%d\n",cnt);
	for(i=1;i<=cnt;i++)printf("%d %d %d %d\n",seq[i][0],seq[i][1],seq[i][2],seq[i][3]);
	return 0;
}

Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
void output(int x){
	if(x==0)
	return;
	if(x%2==0)
	{
		output(x/(-2));
		putchar('0');
	}
	else
	{
		output((x-1)/(-2));
		putchar('1');
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	if(n==0)
	puts("0");
	else
	{
		output(n);
		puts("");
	}
	return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  string s;

  void solve() {
    cin >> s;
    n = s.length() + 1;
    DBG(s)
    s = '>' + s + '<';
    DBG(s)
    vector<int> a(n + 2, 0);
    for (int i = 1; i <= n; ++i) {
      if (s[i - 1] == '<') {
        a[i] = a[i - 1] + 1;
      }
    }
    DBG(a)
    for (int i = n; i >= 1; --i) {
      if (s[i] == '>') {
        a[i] = max(a[i], a[i + 1] + 1);
      }
    }
    DBG(a)
    LL ans = 0;
    for (int i = 1; i <= n; ++i) {
      ans += a[i];
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);

  Problem::Solver sol;
  sol.solve();
  return 0;
}


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

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

    std::vector<int> array(n);
    for (int i=0; i<n; i++) {
        cin >> array[i];
    }

    std::vector<size_t> indices(array.size());
    std::iota(indices.begin(), indices.end(), 0);

    std::sort(indices.begin(), indices.end(), [&array](size_t i1, size_t i2) {
        return array[i1] < array[i2];
    });

    for (auto v : indices)
        std::cout << v + 1 << " ";
    std::cout << std::endl;

    return 0;
}

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

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

    int x[n], y[n], c[n];
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        c[i] = i;
    }
    double ans = 0;
    double sum;
    int cou = 0;
    do{
        sum = 0;
        for(int i = 1; i < n; i++){
            sum += sqrt(pow(x[c[i - 1]] - x[c[i]], 2) + pow(y[c[i - 1]] - y[c[i]], 2));
        }

        ans += sum;
        cou++;
    }while(next_permutation(c, c + n));

    cout << fixed << setprecision(10) << ans / cou << endl;
}

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

int main(){
    int n,m;
    cin >> n;
    int first = 0;
    m = 0;
    vector<int> out;
    vector<int> a(n+1);
    vector<int> ans(n+1);
    for(int i = 1;i <= n;i++)cin >> a[i];
    for(int j = 1;j <= n;j++){
        for(int i = n/j;i >= n/(j+1)+1;i--){
            int t = 0;
            for(int k = 2;k <= j;k++){
                t += ans[i*k];
            }
            ans[i] = (a[i]+t)%2;
            if(ans[i] == 1){
                m++;
                out.push_back(i);
            }
            first += ans[i];
        }
    }
    sort(out.begin(),out.end());
    cout << m << endl;
    for(int i = 0;i < m;i++){
        cout << out[i] << " ";
    }
}

Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%s", $s);

$x = $s;
$p = strlen($s) - 1;
$n = 2 ** $p;
for ($i = 1; $i < $n; $i++) {
	$b = sprintf("%0". $p . "b", $i);
	$a = $s[0];
	for ($j = 0; $j < $p; $j++) {
		if ($b[$j]) {
			$x += $a;
			$a = null;
		}
		$a .= $s[$j+1];
	}
	$x += $a;
}
echo $x, "\n";

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

int A[20];
int X[20][20];
int Y[20][20];

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

    for (int i = 1; i <= N; ++i) {
        cin >> A[i];

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

    int Z[20];
    int a;

    for (a = N; a > 0; --a) {
        memset(Z, 0, sizeof(Z));
        for (int k = N; k >= N - a + 1; --k) Z[k] = 1;
        
        do {
            for (int i = 1; i <= N; ++i) {
                if (Z[i]) {
                    for (int j = 1; j <= A[i]; ++j) {
                        if (Y[i][j] != Z[X[i][j]]) goto CONTINUE_Z;
                    }
                }
            }
            goto BREAK_Z;
            CONTINUE_Z:;
        } while (next_permutation(&Z[1], &Z[N + 1]));
    }
    BREAK_Z:;

    cout << a << endl;

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int l = S.length();
  
  char i;
  for(i = 'a'; i <= 'z'; i++){
    if(S.find(i) < l) continue;
    else break;
  }
  
  if(i-1 == 'z') cout << "None";
  else cout << i;
  return 0;
}

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

struct Node {int p, l, r;};

Node T[MAX];
int n, D[MAX];

void print(int u) {
    int i, c;
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";

    for (i = 0, c = T[u].l; c != NIL; ++i, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

//再帰的に深さを求める
int rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p); // 右の兄弟に同じ深さを設定
    if (T[u].l != NIL) rec(T[u].l, p+1); // 最も左の子に自分の深さ+1を設定
}

int main() {
    int i, j, d, v, c, l, r;
    cin >> n;
    for (i = 0; i < n; ++i) T[i].p = T[i].l = T[i].r = NIL;

    for (i = 0; i < n; ++i) {
        cin >> v >> d;
        for (j = 0; j < d; ++j) {
            cin >> c;
            if (j == 0) T[v].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = v;
        }
    }
    for (i = 0; i < n; ++i) {
        if (T[i].p == NIL) r = i;
    }

    rec(r, 0);

    for (i = 0; i < n; ++i) print(i);

    return 0;
}


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

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

    int m = A / K;
    int min = m * K;//minはA以下の最大のKの倍数
    
    int M = min + K;

    if(min == A){
        cout << "OK" << endl;
        return 0;
    }

    if(M >= A && M <= B) cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include<iomanip>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll mx,sum,mn=1e8,cnt;

int main(){
	ll w,h,x,y;
	cin>>w>>h>>x>>y;
	double ans=(w*h)/2.0;
	if(w-x==x && h-y==y){
		cout<<fixed<<setprecision(6)<<(double)x*h;
		cout<<" 1"<<endl;
	}
	
	else if(w-y==y){
		cout<<fixed<<setprecision(6)<<(double)y*h;
		cout<<" 0";
	}
	else {
		cout<<fixed<<setprecision(6)<<(double)ans;
		cout<<" 0";
	}
	
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    long long x;
    cin >> x;
    
    long long n = 2*(x/11);
    
    if(x%11 >=1) n++;
    if(x%11 >=7) n++;
    
    cout << n << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int K;
    cin >> K;
    int odd = (K + 1) / 2;
    int even = K / 2;
    cout << odd * even << endl;
}


Measured memory_bytes: 3624
from collections import Counter

S = input()

p = 2019
N = len(S)

# p は 10 と互いに素なのであんまり桁のずれは関係ないはずなので、とりあえず位は大きいのに合わせる
m = [(int(S[i]) * pow(10, N-i, p)) % p for i in range(N)]# m は各桁の mod

# m の mod 累積和をもとめる
r = [0] * N
r[0] = m[0]
for ri in range(1, N):
    r[ri] = (r[ri-1] + m[ri]) % p

# この r[i] が一致するような区間が答えになるのでこれをもとめる（0は別途対応）
c = Counter(r)

ans = 0
for ci in [cv for cv in c.values() if cv >= 2]:
    ans += ci * (ci-1) // 2

if 0 in c.keys():
    ans += c[0]

print(ans)


Measured memory_bytes: 23832
N=int(input())
S=[]
for _ in range(N):
  s=input()
  S.append(s)
  
C0=S.count("AC")
C1=S.count("WA")
C2=S.count("TLE")
C3=S.count("RE")

ans=[C0,C1,C2,C3]
moji=["AC","WA","TLE"," RE"]

for i in range(4):
    print(moji[i]+" x "+str(ans[i]))
  

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

const int maxn=100+10;
const double eps=1e-9;

#define pi 3.14159
#define num 30000 //迭代次数
double k=0.1;
double r=0.9; //用于控制降温的快慢
double T=2000; //系统的温度，系统初始应该要处于一个高温的状态
double T_min =20;//温度的下限，若温度T达到T_min，则停止搜索
struct Point{
    double x,y;
}p[maxn];
double get_distance(Point a,Point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int n;
double func(Point O){
    double ans=0.0;
    for(int i=1;i<=n;i++){
        double dist=get_distance(O,p[i]);
        ans=max(ans,dist);
    }
    return ans;
}
double rnd(double dbLow,double dbUpper)
{
    double dbTemp=rand()/((double)RAND_MAX+1.0);
    return dbLow+dbTemp*(dbUpper-dbLow);
}
signed main(){
    int n;
    scanf("%d",&n);
    Point now;
    now.x=now.y=0;
    for(int i = 1 ; i <= n ;++i){
        scanf("%lf %lf",&p[i].x,&p[i].y);
        now.x+=p[i].x; now.y+=p[i].y;
    }
    now.x/=n; now.y/=n;
    double T = 100;
    double ans = 1e9;
    while(T > eps){
        int k = 1;
        for(int i = 1;i <= n ;++i){
            if(get_distance(now,p[i]) > get_distance(now,p[k]) ){
                k = i;
            }
        }
        double tem = get_distance(p[k],now);
        ans = min(ans,tem);
        now.x += ( (p[k].x - now.x)/tem )*T;
        now.y += ( (p[k].y - now.y)/tem )*T;
        T *= 0.98;
    }
    printf("%.10f\n",ans);
    return 0;
}


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

int compare(const void *a, const void *b) {
    return strcmp((char *)a, (char *)b);
}

int main(void) {
    int n;
    unsigned long long count = 0;

    scanf("%d", &n);
    char s[n][11];

    for (int i = 0; i < n; i++) {
        scanf("%s", s[i]);
        qsort((void *)s[i], 10, sizeof(char), compare);
    }

    qsort((void *)s, n, sizeof(s[0]), compare);

    unsigned long long tmp = 0;
    for (int i = 1; i < n; i++) {
        if (strcmp(s[i - 1], s[i]) == 0) {
            tmp++;
        } else {
            count += tmp * (tmp + 1) / 2;
            tmp = 0;
        }
    }

    count += tmp * (tmp + 1) / 2;

    printf("%llu\n", count);

    return 0;
}

Measured memory_bytes: 2428
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		long N = long.Parse(Console.ReadLine());
		int ix = 0;
		int iy = 0;
		long m = 2;
		long t = m;
		long h = 1;
		long[,]A = new long[500,500];
		long[,]B = new long[500,500];
		long[,]C = new long[500,500];
		long at = 0;
		var list = GeneratePrime(10000);
		while(true){
			if((ix+iy)%2==0){
				B[ix,iy] = list[249+(ix-iy)/2];
				C[ix,iy] = list[500];
				if(ix+iy>500){
					C[ix,iy] = list[((ix+iy)-500)/2*2+499];
				} else if(ix+iy<500){
					C[ix,iy] = list[(500-(ix+iy))/2*2+500];
				}
				A[ix,iy]=(long)B[ix,iy] * (long)C[ix,iy];
			}
			ix += 1;
			if(ix>=500){
				iy += 1;
				ix = 0;
				if(iy==500){
					break;
				}
			}
		}
		ix = 0;
		iy = 0;
		while(true){
			if((ix+iy)%2==1){
				long aa = 1;
				if(ix==0){
					if(iy<499){
						aa *= B[ix,iy+1];
					}
				} else {
					aa *= B[ix-1,iy];
				}
				if(ix==499){
					if(iy>0){
						aa *= B[ix,iy-1];
					}
				} else {
					aa *= B[ix+1,iy];
				}
				if(ix==499){
					if(iy<499){
						aa *= C[ix,iy+1];
					}
				} else {
					aa *= C[ix+1,iy];
				}
				if(ix==0){
					if(iy>0){
						aa *= C[ix,iy-1];
					}
				} else {
					aa *= C[ix-1,iy];
				}
				A[ix,iy] = aa + 1;
			}
			ix += 1;
			if(ix>=500){
				iy += 1;
				ix = 0;
			}
			if(iy>=500){
				break;
			}
		}
		for(var i=0;i<N;i++){
			string str = "";
			str += A[0,i];
			for(var j=1;j<N;j++){
				str += " " + A[j,i];
			}
			Console.WriteLine(str);
		}
	}
	
	public static List<int> GeneratePrime(int max)
	{
		System.Diagnostics.Debug.Assert(max >= 2);
		int prime;
		double sqrtMax = Math.Sqrt(max);
		var primeList = new List<int>();
		var searchList = Enumerable.Range(2, max - 1).ToList();
		do
		{
			prime = searchList.First();
			primeList.Add(prime);
			searchList.RemoveAll(n => n % prime == 0);
		} while (prime < sqrtMax);
		primeList.AddRange(searchList);
		return primeList;
	}
}

Measured memory_bytes: 45932
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
static const int MAX_N = 2000;
static const int MAX_A = 1000000000;
 
int N, K, Q;
int A[MAX_N];
 
int main(){
	cin >> N >> K >> Q;
	for(int i = 0; i < N; i++) cin >> A[i];
	int ans = MAX_A + 1;
	for(int i = 0; i < N; i++){
		int Y = A[i];
		int cnt = 0;
		vector<int> va, vb;
		for(int j = 0; j < N; j++){
			if(A[j] >= A[i] && j != N - 1){
				va.push_back(A[j]);
			}else{
				if(A[j] >= A[i] && j == N - 1) va.push_back(A[j]);
				if(va.size() < K){
					va.clear();
					continue;
				}
				sort(va.begin(), va.end());
				for(int l = 0; l < va.size() - K + 1; l++){
					vb.push_back(va[l]);
				}
				va.clear();
			}
		}
		sort(vb.begin(), vb.end());
		if(vb.size() >= Q) ans = min(ans, vb[Q - 1] - Y);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

double PI = acos(-1);

int main() {
	double a, b, x; cin >> a >> b >> x;
	double max = PI/2.0, min = 0;
	while (max-min > pow(10,-15)) {
		double mid = (max + min) / 2.0;
		if (a*tan(mid) > b ) {
			if (x< b*b*a / (2.0 * tan(mid)))min = mid;
			else max = mid;
		}
		else {
			if (x < a*a*(b -(a* tan(mid) )/ 2.0))min = mid;
			else max = mid;
		}
		//cout << max/PI*180 << " " <<min/PI*180 << endl;
	}
	max *= 180 / PI;
	printf("%4.10f\n", max);


}





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

typedef pair<int,int>P;
#define fi first
#define se second

inline int dist(P a,P b){
    return abs(a.fi-b.fi)+abs(a.se-b.se);
}

struct Data{
    P p;
    int type;

    Data(P p,int type):p(p),type(type){}
    Data(){}

    bool operator<(const Data &d)const{
        if(p!=d.p)return p<d.p;
        return type<d.type;
    }
};
int H,W;
char fld[1001][1001];
int dp[5][5][1000];
void solve(){

    P Start,Goal;
    vector<P>Monster[5];
    fill_n(**dp,25000,INT_MAX);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            char c=fld[i][j];
            P p(i,j);
            if(c=='S')Start=p;
            else if(c=='G')Goal=p;
            else{
                for(int k=0;k<5;k++){
                    if(c==k+'1'){
                        Monster[k].push_back(p);
                        break;
                    }
                }
            }
        }
    }

    for(int i=0;i<5;i++){
        for(int j=0;j<Monster[i].size();j++){
            P p=Monster[i][j];
            dp[0][i][j]=dist(p,Start);
        }
    }

    for(int k=0;k<3;k++){
        for(int i=0;i<5;i++){
            int to=(i+1)%5;
            for(int j=0;j<Monster[i].size();j++){
                if(dp[k][i][j]==INT_MAX)continue;
                P prev=Monster[i][j];
                for(int l=0;l<Monster[to].size();l++){
                    P next=Monster[to][l];
                    dp[k+1][to][l]=min(dp[k+1][to][l],dp[k][i][j]+dist(prev,next));
                }

            }

        }

    }
    P ans(INT_MAX,0);
    for(int i=0;i<5;i++){
        for(int j=0;j<Monster[i].size();j++){
            if(dp[3][i][j]==INT_MAX)continue;
            ans=min(ans,P(dist(Monster[i][j],Goal)+dp[3][i][j],(i+1)%5));
        }
    }

    if(ans.first==INT_MAX)cout<<"NA"<<endl;
    else cout<<ans.second+1<<" "<<ans.first<<endl;
}

int main(){
    while(scanf("%d%d",&W,&H),W||H){
        for(int i=0;i<H;i++)scanf("%s",fld[i]);
        solve();
    }
}

Measured memory_bytes: 2344
#include <bits/stdc++.h>
 
#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))
 
using namespace std;
 
typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;
 
template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
 
const int N = 100000 + 10;
int a[N];
 
vector<int> g[N];
 
bool is_leaf(int n)
{
  return g[n].size() == 1;
}
 
lli f(int curr, int prev)
{
  if (is_leaf(curr)) return a[curr];
 
  vector<lli> b;
  each (next, g[curr]) {
    if (next == prev) continue;
    b.emplace_back(f(next, curr));
  }
 
  lli sum = accumulate(b.begin(), b.end(), 0LL);
  if (b.size() == 1) {
    if (a[curr] != b[0]) throw "";
    return b[0];
  }

  lli mx = *max_element(b.begin(), b.end());
  lli n = sum - a[curr];
  if (n > sum - mx) throw "";
  if (sum < a[curr]) throw "";

  lli passed = a[curr] * 2 - sum;
  if (passed < 0 || (curr == prev && passed)) throw "";
  return passed;
}
 
int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
 
  int n;
  while (cin >> n) {
    fill(g, g + N, vector<int>());
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      g[a].push_back(b);
      g[b].push_back(a);
    }
    int r = 0;
    for (int i = 0; i < n; ++i) {
      if (!is_leaf(i)) { r = i; break; }
    }
    if (n == 1) {
      puts(a[0] ? "NO" : "YES");
    } else if (n == 2) {
      puts(a[0] == a[1] ? "YES" : "NO");
    } else try {
      f(r, r);
      cout << "YES" << endl;
    } catch (const char* e) {
      cout << "NO" << endl;
    }
  }
 
  return 0;
}


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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;


int main(){
  int n;
  cin >> n;
  ll res = 0;
  vector<ll> v(n, 0);
  rep(i, n){
    cin >> v[i];
    res += v[i];
  }
  int m;
  cin >> m;
  rep(i, m){
    int p;
    ll x;
    cin >> p >> x;
    p--;
    cout << res - v[p] + x << endl;
  }
  return 0;
}



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

int main() {
    string S; cin >> S;
    int win = 0, g = 0;
    for(char c : S) {
        if(g > 0) {
            g--;
            win += c == 'g';
        } else {
            g++;
            win -= c == 'p';
        }
    }
    cout << win << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
	ll n; cin >> n;
	for (ll i = 1; i <= 3500; i++) {
		for (ll j = 1; j <= 3500; j++) {
			ll u = i * j * n;
			ll d = 4 * i * j - i * n - j * n;
			if (d > 0 && u % d == 0) {
				cout << i << " " << j << " " << u / d;
				return 0;
			}			
		}
	}
}

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

typedef pair<int, int> P;
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define ALL(x) x.begin(), x.end()

int main() {
#ifdef LOCAL
    std::ifstream in("../arg.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    vector<P> D;
    REP(i, M){
        int a,b;
        cin >> a >> b;
        D.emplace_back(P(a,b));
    }
    sort(ALL(D));

    int ans = 0;
    auto it = D.begin();
    while (it < D.end()){

        auto min_it = min_element(it, D.end(), [](const P& lhs, const P& rhs) { return lhs.second < rhs.second; });
        while (it < D.end() && (*it).first < (*min_it).second){
            it++;
        }
        ans++;
    }

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




Measured memory_bytes: 1400
from heapq import heappop, heappush


def solve(field, s, t, k):
    INF = 10 ** 18
    ans = [[INF, INF] for _ in field]
    ans[s][0] = ans[s][1] = 0
    MOVE = [(-w2, 0), (-1, 1), (1, 1), (w2, 0)]

    q = [(0, 0, s, 0)]
    while q:
        cost, straight, v, direction = heappop(q)
        if v == t:
            return (cost - 1) // k + 1

        ceiling = ((cost - 1) // k + 1) * k + 1
        for di, ax in MOVE:
            u = v + di
            if field[u] == '@':
                continue
            if di == direction:
                nc = cost + 1
                ns = straight + 1
                if ns > k:
                    ns -= k
            else:
                nc = ceiling
                ns = 1
            if ans[u][ax] <= nc:
                continue
            ans[u][ax] = nc
            heappush(q, (nc, ns, u, di))

    return -1


h, w, k = map(int, input().split())
x1, y1, x2, y2 = map(int, input().split())
h2 = h + 2
w2 = w + 2

field_tmp = [input() for _ in range(h)]
field = ['@' * w2]
for row in field_tmp:
    field.append('@')
    field.append(row)
    field.append('@')
field.append('@' * w2)
field = ''.join(field)
s = x1 * w2 + y1
t = x2 * w2 + y2
print(solve(field, s, t, k))


Measured memory_bytes: 294876
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<iomanip>
using namespace std;

int main() {
	string S;
	cin >> S;
	if(S[0]==S[1] || S[0]==S[2] || S[1]==S[2]){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <math.h>
using namespace std;

int n;

struct Point { double x, y; };

void koch(int n, Point p1, Point p2) {
  if (n == 0) return;
  Point s, u, t;
  double th = M_PI * 60 / 180.0;
  
  s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
  s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
  t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
  t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
  u.x = (t.x - s.x) * cos(th)  - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th)  + (t.y - s.y) * cos(th) + s.y;
  
  koch(n - 1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(n - 1, t, p2);
}

int main(void){
  Point a, b;
  int n;
  
  cin >> n;
  
  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;
  
  printf("%.8f %.8f\n", a.x, a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n", b.x, b.y);
  
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <iomanip>
#include <math.h>
#include <map>
#include <list>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>
#include <string.h>
// #include <limits.h>

#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define INTMAX  99999999

#define DEBUG 0

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;

int H,W;
#define MAX_HW 8
string A[MAX_HW];

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

	cin >> H >> W;

	FOR(h,H) {
		cin >> A[h];
	}

	int h=0;
	int w=0;
	bool result = true;
	while(true) {
		DOUT << "A["<<h<<"]["<<w<<"]=="<<A[h][w]<<endl;
		int nh = -1;
		int nw = -1;
		A[h][w] = '*';
		if(h>0) {
			if(A[h-1][w]=='#') {
				DOUT << "FALSE: A[h-1][w]=="<<A[h-1][w]<<endl;
				result = false;
				break;
			}
		}
		if(w>0) {
			if(A[h][w-1]=='#') {
				result = false;
				DOUT << "FALSE: A[h-1][w]=="<<A[h][w-1]<<endl;
				break;
			}
		}
		if(h<H-1) {
			if(A[h+1][w]=='#') {
				DOUT << "TRUE: A[h+1][w]=="<<A[h+1][w]<<endl;
				nh = h+1;
				nw = w;
			}
		}
		if(w<W-1) {
			if(A[h][w+1]=='#') {
				DOUT << "TRUE: A[h][w+1]=="<<A[h][w+1]<<endl;
				if(nh>=0 || nw>=0) {
					DOUT << "false: DOUBLE#"<<endl;
					result = false;
					break;
				}
				nh = h;
				nw = w+1;
			}
		}
		if(nh>=0&&nw>=0) {
			h=nh;
			w=nw;
			continue;
		}
		if(h==H-1&&w==W-1) {
			break;
		}
		result = false;
		break;
	}

	if(result) {
		cout << "Possible"<<endl;
	}
	else {
		cout << "Impossible"<<endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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

int main() {
	int A, B;
	cin >> A >> B;
	if (A <= 8 && B <= 8)cout << "Yay!";
	else cout << ":(";
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = list(list(map(int, input().split())) for i in range(q))
dic = {}
for i in range(n):
    if a[i] not in dic.keys():
        dic[a[i]] = 1
    else:
        dic[a[i]] += 1
su = sum(a)
for i in range(q):
    if b[i][0] not in dic.keys():
        pass
    else:
        su += (b[i][1]-b[i][0])*dic[b[i][0]]
        if b[i][1] not in dic.keys():
            dic[b[i][1]] = 0
        dic[b[i][1]] += dic[b[i][0]]
        dic[b[i][0]] = 0
    print(su) 

Measured memory_bytes: 35916
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        x: usize,
        y: usize,
        a: usize,
        b: usize,
        c: usize,
        ps: [usize; a],
        qs: [usize; b],
        rs: [usize; c]
    }
    let mut ap = vec![];
    for &p in &ps {
        ap.push((p, 0));
    }
    for &q in &qs {
        ap.push((q, 1));
    }
    for &r in &rs {
        ap.push((r, 2));
    }
    ap.sort_by(|x, y| y.0.cmp(&x.0));
    let mut ans = 0;
    let mut cr = 0;
    let mut cg = 0;
    let mut ct = 0;
    for &(n, col) in &ap {
        if ct == x + y {
            break;
        }
        if col == 0 && cr < x {
            ans += n;
            cr += 1;
            ct += 1;
        } else if col == 1 && cg < y {
            ans += n;
            cg += 1;
            ct += 1;
        } else if col == 2 {
            ans += n;
            ct += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 17004
#include <stdio.h>
#include <string.h>

int main(void)
{
    char line[90];
    int length, i, j;

    
    while(fgets(line, 81, stdin) != NULL){
        length = strlen(line) - 1;
        while(1){
            if(strstr(line, "the ") != 0|| strstr(line, "this ") != 0 || strstr(line, "that ") != 0){
                
                break;
            }else {
                for (i = 0; i < length; i++){
                    if(line[i] == 'z') line[i] = 'a';
                    else if(line[i] >= 'a' && line[i] <= 'y') line[i]++;
                    //printf("   %d", i);
                }
            }
            
        }
        printf("%s", line);
    }

    return (0);
}



Measured memory_bytes: 2076
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
    int p, l, r;
};
struct Node T[MAX];
int dep,hileft,hiright;

main(){
  int i, j, d, v, c, l, n,tmp;
      
    scanf("%d", &n);
      
    for ( i = 0; i < n; i++ ) {
        T[i].p = T[i].l = T[i].r = NIL;
    }
    for (i = 0; i <n ; i++){
      scanf("%d %d %d", &v, &d, &c);
             T[d].p=v;
         T[c].p=v;
             T[v].l=d;
             T[v].r=c;
  
    }
      
    for ( i = 0; i < n; i++ ) print(i);
    return 0;
}

int depth(int u){
  if(T[u].p == NIL)return 0;
   if(T[u].p != NIL){
     dep++;
    depth(T[u].p);
  }
  return dep;
}
  
int degree(int u){
    if (T[u].l == NIL && T[u].r == NIL)return 0;
    else if(T[u].l != NIL && T[u].r != NIL)return 2;
    else  return 1;
}
int sibling(int u){
  if(T[u].p == NIL) return NIL;
  else if(T[T[u].p].l==u)return T[T[u].p].r;
  else return T[T[u].p].l;
}
 
int hight(int u){
  int hileft = 0, hiright = 0;
  if(T[u].l != -1) {
hileft = hight(T[u].l) + 1;
  }
  if(T[u].r != -1){
 hiright = hight(T[u].r) + 1;
  }
  if(hileft < hiright) return hiright;
  else return hileft;
}

  
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",sibling(u));
  printf("degree = %d, ",degree(u));
  dep=0;
  printf("depth = %d, ",depth(u));
  //hileft=hiright=0;
  printf("height = %d, ",hight(u));
  
  if(T[u].p == NIL)printf("root\n");
  else if(T[u].l == NIL && T[u].r == NIL)printf("leaf\n");
  else printf("internal node\n");
}

Measured memory_bytes: 616
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

pqr = sorted(p[:X] + q[:Y] + r, reverse=True)
ans = sum(pqr[:X + Y])

print(ans)



Measured memory_bytes: 114028
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mod 1000000007ll
const ll maxn = 9e18;
using namespace std;

ll find_power(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b & 1) (res *= a)%= mod;
		(a *= a) %= mod;
		b >>= 1;
		}
		return res%mod;
	}

void solve() {
	int n;
	cin >> n; 
	vector<int> arr(n + 1, 0);
	for(int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		arr[x]++;
		}
		for(int i = 1; i <= n; ++i) {
			if(arr[i] % 2) {
				cout << 0 << endl;
				return;
				}
			}	
		int ans = n / 2;
		cout << find_power(2, ans) << endl;
}

int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout.precision(35);
	solve();
	return 0;
	}


Measured memory_bytes: 3724
N, K = list(map(int, input().split()))
d = []
A = []
for i in range(K):
  d.append(int(input()))
  for a in list(map(int, input().split())):
    A.append(a)
A = sorted(A)
count = 1
for i in range(len(A)-1):
  if A[i] != A[i+1]:
    count += 1
print(N-count)

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define INF 999999999
#define MOD 1000000007
#define sp ' '


//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef pair<long, long> pll;
typedef map<int, int> mint;
typedef set<int> sint;
typedef vector<int> vint;
typedef vector<char> vchr;
typedef vector<long long> vll;
typedef vector<string> vstr;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b, ll c){ll ans=1; rep(i, b){ans=ans*a%c;} return ans;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
template<typename T>
void vpp(T a){rep(i,a.size()){cout << a[i] << endl;}}
template<typename T>
void vdp(T a){rep(i,a.size()){cerr << a[i];}cerr << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m;
    cin >> n >> m;
    ppp((1800*m+100*n)*pow(2LL, m));


    return 0;
}


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

//ooo,oo,oo,o
void solve(long long N, long long K, std::vector<long long> A){
  cout << ((N-K)/(K-1))+(((N-K)%(K-1)) == 0 ? 1 : 2) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
//import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
	public static void main(String[] args) throws IOException {
		//System.setIn(new FileInputStream("./ALDS1_6_D-in15.txt"));
		
		// Input an array
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
	
		Baggage[] a = new Baggage[n];
		String[] strs = br.readLine().split(" ");
	    for(int i = 0; i < n; ++i){
	        a[i] = new Baggage(i, Integer.parseInt(strs[i]));
	    }
	    
	    // Number the array
	    mergeSort(a, 0, n);
	    /*
	    for(int i = 0; i < n; ++i) {
	    	System.out.printf(" %3d", i);
	    }
	    System.out.println();
	    for(int i = 0; i < n; ++i) {
	    	System.out.printf(" %3d", a[i].weight);
	    }
	    System.out.println();
	    for(int i = 0; i < n; ++i) {
	    	System.out.printf(" %3d", a[i].org);
	    }
	    System.out.println();*/
	    
	    // Calc. cost
	    int cost = 0;
	    int minw = a[0].weight;
	    for(int i = 0; i < n; ++i) {
	    	if(a[i].flag == true){
		    	// search group key i
	    		continue;
	    	}
	    	//System.out.print("key " + i + " " + a[i].weight + ": ");
    		
	    	// count cost for group i
	    	int cnt = 0; // swap count
	    	int j = a[i].org;
	    	while(j != i) {
	    		// swap a[j] and a[i]
	    	    cost += a[j].weight + a[i].weight;
	    		cnt += 1;

	    		//System.out.print(" " + a[j].weight);
	    	    a[j].flag = true;
		    	j = a[j].org;
	   	    }
	    	int loss = (a[i].weight * cnt) - minw * cnt - 2 * (minw + a[i].weight);
	    	if(loss > 0){
	    		cost -= loss;
	    	}
	    	//System.out.println(" ; cost " + cost);
	    }
	    
	    System.out.println(cost);
	}
	
	public static void mergeSort(Baggage[] s, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(s, left, mid);
			mergeSort(s, mid, right);
			merge(s, left, mid, right);
		}
	}
	public static void merge(Baggage[] s, int left, int mid, int right) {
		Baggage[] s1 = Arrays.copyOfRange(s, left, mid + 1);
		Baggage[] s2 = Arrays.copyOfRange(s, mid, right + 1);
		
		s1[mid - left] = new Baggage(-1, Integer.MAX_VALUE);
		s2[right - mid] = new Baggage(-1, Integer.MAX_VALUE);
		int i = 0;
		int j = 0;
		for(int k = left; k < right; ++k) {
			if(s1[i].weight <= s2[j].weight){
				s[k] = s1[i];
				i += 1;
			}else{
				s[k] = s2[j];
				j += 1;
			}
		}
		
	}
}

class Baggage {
	public int org;
	public int weight;
	public boolean flag;
	public Baggage(int o, int w) {
		org = o;
		weight = w;
		flag = false;
	}
}

Measured memory_bytes: 25304
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main()
{
int n;
cin>>n;
   call(n);
    return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <stack>

using namespace std;

#define INFint (1<<30)
#define BOUND 27182818284
#define MAT 2

typedef long long ll;
typedef long long int lli;
typedef pair<ll, ll> P;

ll MOD = 1000000007;
const ll INF = (1ll<<60);
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

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

int findGCD(vector<int> arr) {
    int result = arr[0];
    for (auto a: arr) {
        result = gcd(a, result);
    }
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N; cin >> N;
    vector<ll>D(N);
    ll maximum=0LL;
    multiset<ll>ms;
    rep(i,N){
        cin >> D[i];
        maximum=max(maximum, D[i]);
        ms.insert(D[i]);
    }
    
    if(ms.count(0)!=1 || D[0]!=0){
        cout << 0 << endl;
        return 0;
    }

    for(int i=0; i<=maximum; i++){
        if(ms.count(i)==0){
            cout << 0 << endl;
            return 0;
        }
    }

    int pre=1;
    ll ans=1LL;
    for(ll i=1; i<=maximum; i++){
        for(int j=0; j<ms.count(i); j++){
            ans*=pre;
            ans%=998244353;
        }
        pre=ms.count(i);
    }

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

Measured memory_bytes: 5760
#include<cstdio>

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

using namespace std;

const int dx[]={1,0,0,1, 1,0, 0,1,-1,1, 1, 1, 1};
const int dy[]={0,1,0,1,-1,1, 1,0, 0,1, 1,-1,-1};
const int dz[]={0,0,1,0, 0,1,-1,1, 1,1,-1, 1,-1};
char n,m,peg[10][10][10];

#define	inrange(x,y,z)	(0<=(x) && (x)<n && 0<=(y) && (y)<n && 0<=(z) && (z)<n)

bool isWinner(int x,int y,int z,char c){
	rep(i,13){
		int len[2]={m,m};
		rep(k,2){
			int sgn=(k%2?1:-1);
			rep(j,m){
				int xx=x+sgn*j*dx[i],yy=y+sgn*j*dy[i],zz=z+sgn*j*dz[i];
				if(!inrange(xx,yy,zz) || peg[zz][yy][xx]!=c){ len[k]=j; break; }
			}
		}
		if(m<=len[0]+len[1]-1)	return true;
	}
	return false;
}

int main(){
	for(int p;scanf("%d%d%d",&n,&m,&p),n;){
		rep(z,n)rep(y,n)rep(x,n)	peg[z][y][x]=' ';

		int end=-1;
		rep(i,p){
			int x,y,z;	scanf("%d%d",&x,&y);
			x--,y--;
			if(~end)	continue;
			for(z=0;;z++){
				if(peg[z][y][x]==' '){
					peg[z][y][x]=(i%2?'W':'B');
					break;
				}
			}
			if(isWinner(x,y,z,i%2?'W':'B'))	end=i;
		}

		if(~end)	printf("%s %d\n",end%2?"White":"Black",end+1);
		else		puts("Draw");
	}

	return 0;
}

Measured memory_bytes: 0
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,ei
    integer(int32), allocatable:: a(:)
    integer(int64):: edge(2)
    read*, n
    allocate(a(n))
    read*, a(:)
    call merge_sort(a,1,n)
    edge(:) = 0
    ei=0
    i=n
    do while(i>1)
        if (a(i) == a(i-1))then
            ei=ei+1
            edge(ei) = a(i)
            i=i-1
        end if
        i=i-1

        if (ei == 2) exit
    end do

    print'(i0)', product(edge)
contains
recursive subroutine merge_sort(ar, fst, lst)
integer(int32),intent(inout):: ar(:)
integer(int32),intent(in):: fst,lst
integer(int32):: mdl

if (lst-fst < 2) then
    if (ar(fst) > ar(lst)) call swap(ar(fst),ar(lst))
    return
end if

mdl = (fst+lst)/2
call merge_sort(ar, fst, mdl)
call merge_sort(ar, mdl+1, lst)
call merge_(ar, fst, mdl, lst)
end subroutine

subroutine merge_(ar, fst, mdl, lst)
integer(int32),intent(inout):: ar(:)
integer(int32),intent(in):: fst, mdl, lst
integer(int32),allocatable:: tmp(:)
integer(int32):: li, ri, ti

allocate(tmp(lst-fst+1))

li=fst
ri=mdl+1   
ti=1

do while (li <= mdl .and. ri <= lst)
    if (ar(li) <= ar(ri)) then
        tmp(ti) = ar(li)
        li=li+1
    else
        tmp(ti) = ar(ri)
        ri=ri+1
    end if
    ti=ti+1
end do

if (li <= mdl) then
    tmp(ti:) = ar(li:mdl)
else
    tmp(ti:) = ar(ri:lst)
end if

ar(fst:lst) = tmp(:)
deallocate(tmp)
end subroutine

subroutine swap(x,y)
integer(int32),intent(inout):: x,y
integer(int32):: tmp
tmp = x
x = y
y = tmp
end subroutine
end program name

Measured memory_bytes: 1724