akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,Y = 0;
    cin >> N >> Y;

    int count = 0;
    int a = -1;
    int b = -1;
    int c = -1;

    for (int i = 0; i <= N; ++i) {
        for (int j = 0; i + j <= N; ++j) {
            int k = N - i - j;
            int total = 10000*i + 5000*j + 1000*k;
            if(total == Y){
                a = i;
                b = j;
                c = k;
            }
        }
    }
    cout << a << " " << b << " " << c;

    return 0;
}

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

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

int i = 1;

while(1)
{

  int x = i;

  if ( x % 3 == 0 )
  {
    cout << " " << i;
  }

  else
  {
    while(1)
    {
      if ( x % 10 == 3 )
      {
        cout << " " << i;
        break;
      }
      x /= 10;
      if ( x == 0 ) break;
    }
  }
  if ( ++i > n ) break;
}

  cout << endl;

return 0;

}


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

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

	cin >> input_str >> k;
	int len = input_str.length();

	string min_str = "zzzzzz";	// 咬ませ犬
	for( char c = 'a'; c <= 'z'; ++c )
	{
		for( int i = 0; i <= len; ++i )		//文字列の最後まで
		{
			if( input_str[i] == c )
			{
				if( len-i < k )			// [c]からの文字列長が[k]に満たない場合
				{
					k -= (len-i);
					break;
				}
				else
				{
					string tmp_str = input_str.substr(i,k);
					if( min_str > tmp_str )
						min_str = tmp_str;
				}
			}
		}

		if( min_str != "zzzzzz") break;
	}

	cout << min_str << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

static const int MAX = 100;
static const int INFTY = (1 << 21);
int N, d[MAX][MAX], E[MAX][MAX];

void dijkstra(int x) {
	int minv;
	int color[MAX];
	REP(i, N) {
		d[x][i] = INFTY;
		color[i] = 0;
	}

	d[x][x] = 0;
	color[0] = 1;
	while (1) {
		minv = INFTY;
		int u = -1;
		REP(i, N) {
			if (minv > d[x][i] && color[i] != 2) {
				u = i;
				minv = d[x][i];
			}
		}
		if (u == -1)break;
		color[u] = 2;
		REP(v, N) {
			if (color[v] != 2 && E[u][v] != INFTY) {
				if (d[x][v] > d[x][u] + E[u][v]) {
					d[x][v] = d[x][u] + E[u][v];
					color[v] = 1;
				}
			}
		}
	}
}

int main() {
	int M, a, b, c;

	REP(i, MAX) {
		REP(j, MAX) {
			E[i][j] = INFTY;
		}
	}

	cin >> N >> M;
	REP(i, M) {
		cin >> a >> b >> c;
		E[a - 1][b - 1] = c;
		E[b - 1][a - 1] = c;
	}

	REP(i, N) {
		dijkstra(i);
	}

	int ans = 0;
	REP(i, N) {
		REP(j, N) {
			if (E[i][j] != INFTY && d[i][j] < E[i][j]) {
				ans++;
			}
		}
	}

	cout << ans / 2 << endl;


	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int N;
  int cnt;
  int i, max = -1, ans=1;
  
  scanf("%d" , &N);
  for(int i = 1; i <= N; i++) {
    int tmp = i;
    cnt = 0;
    while(tmp % 2 == 0) {
      cnt++;
      tmp /= 2;
    }
    if(max < cnt) {
      ans = i;
      max = cnt;
    }
  }
  
  printf("%d\n", ans);
  
  return 0;
}

Measured memory_bytes: 128
while 1:
    a = list(input())
    if a == ["0", "0", "0", "0"]:break
    if a[0] == a[1] == a[2] == a[3]:print("NA")
    else:
        c = 0
        while 1:
            if a == ["6", "1", "7", "4"]:break
            c += 1
            s = int("".join(sorted(a)))
            l = int("".join(sorted(a, reverse = True)))
            a = list("{:04d}".format(l - s))
        print(c)


Measured memory_bytes: 5632
s = int(input())
digit = lambda s:(digit(s//10) + [s%10]) if s > 0 else []
list = digit(s)
min = 753

for i in range(len(list)-2):
    n = list[i]*100 + list[i+1]*10 + list[i+2]
    if abs(n - 753) < min:
        min = abs(n - 753)

print(min)

Measured memory_bytes: 3060
import sys

def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))
    check = []
    for i in range(2 ** n):
        ans = 0
        for j in range(n):
            if (i >> j) & 1:
                ans += A[j]
        check.append(ans)
    for m in M:
        if m in check:
            print("yes")
        else:
            print("no")


if __name__ == "__main__":
    main()



Measured memory_bytes: 43076
#include<stdio.h>
#include<stdlib.h>

typedef struct{
    int needtime;
    int deadline;
} work_t;

int cmp(const void *p, const void *q){
    return ((work_t*)p)->deadline - ((work_t*)q)->deadline;
}

int main(void){
    int n;
    long raptime;
    scanf("%d", &n);

    work_t a[n];
    for(int i=0; i<n; i++){
        scanf("%d %d", &a[i].needtime, &a[i].deadline);

    }
    qsort(a, n, sizeof(work_t), cmp);

    for(int i=0; i<n; i++){
        raptime += a[i].needtime;
        if(raptime > a[i].deadline){
            printf("No\n");
            break;
        }else if(i==n-1){
            printf("Yes\n");
        }

    }
    return 0;
}

Measured memory_bytes: 3324
n = int(input())
a, b = list(map(int, input().split()))
p = list(map(int, input().split()))

t = [0, 0, 0]
for i in range(n):
    if(p[i] <= a):
        t[0] += 1
    elif(p[i] >= a+1 and p[i] <= b):
        t[1] += 1
    else:
        t[2] += 1

print(min(t))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Long R;
        Scanner sc = new Scanner(System.in);
        R = sc.nextLong();
        double Chu_vi =+R*2*Math.PI;
        //String.format("%.25g%n", Chu_vi);
        System.out.println(Chu_vi);

    }
}


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

using namespace std;

#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main(void){

    int n, k, l[55];
    cin >> n >> k;

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

    sort(l, l+n, greater<int>());
    int ans = 0;
    for(int i = 0; i < k; ++i){
        ans += l[i];
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<limits>
#include<math.h>
#include<bits/stdc++.h>

using namespace std;

#define make_graph(m,G) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b;G[a-1].push_back(b-1); G[b-1].push_back(a-1);}
#define make_dir_graph(m,G) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b;G[a-1].push_back(b-1);}
#define make_weighted_graph(m,G,w) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b; cin>>w[a-1][b-1];w[b-1][a-1]=w[a-1][b-1];G[a-1].push_back(b-1); G[b-1].push_back(a-1);}
#define make_weighted_dir_graph(m,G,w) for (int i = 0; i<m; i++) { int a,b; cin>>a>>b; cin>>w[a-1][b-1]; G[a-1].push_back(b-1);}

int main()
{
	int t=1;
	// cin>>t;
	while (t--)
	{
		// code
		int n; cin>>n;
		int h[n+1];
		for (int i = 1; i<n+1; i++)
		{
			cin>>h[i];
		}

		int dp[n+1] = {};
		dp[2] = abs(h[2] - h[1]);
		dp[3] = min(
			abs(h[3] - h[2]) + dp[2],
			abs(h[3] - h[1])
			);
		for (int i = 4; i<=n; i++)
		{
			dp[i] = min(
				abs(h[i] - h[i-1]) + dp[i-1],
				abs(h[i] - h[i-2]) + dp[i-2]
				);
		}
		cout<<dp[n];
		cout<<endl;	
	}
}

Measured memory_bytes: 1024
#include<stdio.h>

 int main()
 {
 	int n, h, m, s;
 	scanf("%d",&n);
 	h = n / 3600;
 	m = (n - h*3600 )/60;
 	s = n - ((h*3600)+(m*60));
 	printf("%d:%d:%d\n", h, m, s);
 	return 0;
 	
 }


Measured memory_bytes: 2080
#include <stdio.h>

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

int main(){
  int i, j, n, k, answer=0;
  scanf("%d%d",&n,&k);
  int d[k], a[k][n], ans[n];
  rep(i,n) ans[i]=0;
  rep(i,k) {
    scanf("%d",&d[i]);
    rep(j,d[i]) {
      scanf("%d",&a[i][j]);
      if(ans[a[i][j]-1]==0) ans[a[i][j]-1]++;
    }
  }
  rep(i,n) if(ans[i]==0) answer++;
  printf("%d",answer);
}

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

class Program
{
    private int N;
    private int[]T,A;
    private void Scan()
    {
        N=int.Parse(Console.ReadLine());
        T=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        A=Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
    
    public void Solve()
    {
        Scan();
        bool[]flag=new bool[N];
        for(int ti=0;ti<N;ti++)
        {
            int ai=N-1-ti;
            if(ti==0||T[ti-1]<T[ti])
            {
                if(A[ti]>=T[ti])
                {
                    flag[ti]=true;
                }
                else
                {
                    //Console.WriteLine($"{ti}");
                    Console.WriteLine(0);
                    return;
                }
            }
            
            if(ai==N-1||A[ai+1]<A[ai])
            {
                if(T[ai]>=A[ai])
                {
                    flag[ai]=true;
                }
                else
                {
                    //Console.WriteLine($"{ai}");
                    Console.WriteLine(0);
                    return;
                }
            }
        }
        long ans=1;
        for(int i=0;i<N;i++)
        {
            if(flag[i])continue;
            ans*=Math.Min(A[i],T[i]);
            ans%=1000000007;
        }
        Console.WriteLine(ans);
    } 
    
    static void Main()
    {
        new Program().Solve();
    }
}

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

using namespace std;

int main() {

    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;

    for(int i = 0; i < N; i++) {
        cout << S.at(i) << T.at(i);
    }
    cout << endl;

    return 0;
}

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

int main() {
    char moji;
    while(1){
        scanf ("%c", &moji);
        if (isalpha(moji)){
            if(islower(moji)){
                printf("%c", toupper(moji));
            }else{
                printf("%c", tolower(moji));
            }
        }else{
            printf("%c", moji);
        }
        if(moji == '\n') break;
    }
    
    return 0;
}

Measured memory_bytes: 2568
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string S;
  cin >> S;
  if(isupper(S[0])){
    cout << "A";
  }else{
    cout << "a";
  }
  
  return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<math.h>
int main(void){
  int i,j=0,k=0;
  unsigned long a,b,n;

  scanf("%ld",&n);

  for(i=1;i<=sqrt(n);i++){
    if(n%i==0){
      j++;
    }
  }
  
  for(i=1;k<j;i++){
    if(n%i==0){
      a=i;
      b=n/i;
      k++;
    }
  }
  printf("%ld\n",a+b-2);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}

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

int main() {
  while (true) {
    int H, W;
    cin >> H >> W;
    if (H == 0 and W == 0) break;
    for (int j = 0; j < W; j++) cout << '#'; cout << endl;
    for (int i = 1; i < H-1; i++) {
      cout << '#';
      for (int j = 1; j < W-1; j++) {
        cout << '.';
      }
      cout << '#' << endl;
    }
    for (int j = 0; j < W; j++) cout << '#'; cout << endl;
    cout << endl;
  }
}


Measured memory_bytes: 3088
#!/usr/bin/env python3
import sys
import math

def solve(H: int, W: int):
    count = 0
    if H == 1 or W == 1:
        print(1)
        return
    if H % 2 == 0:
        count += (H / 2) * math.ceil(W/2) 
        count += (H / 2) * math.floor(W/2) 
    else:
        count += (1 + (H // 2)) * math.ceil(W/2)
        count += (H // 2) * math.floor(W/2) 

    count = int(count)
    assert type(count) == int
    print(count)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    solve(H, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int calc(int x){
    int res = 1;
    while(x > 0){
        x %= __builtin_popcount(x);
        res++;
    }
    return res;
}

int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<int> x(n);
    rep(i,n) x[i] = s[i] - '0';
    int cnt = 0;
    rep(i,n){
        if(x[i] == 1) cnt++;
    }
    vector<int> pow1(n), pow2(n);
    if(cnt >= 2){
        pow1[0] = 1;
        rep(i,n-1) pow1[i+1] = (pow1[i] * 2) % (cnt-1);
    }
    if(cnt < n && cnt >= 1){
        pow2[0] = 1;
        rep(i,n-1) pow2[i+1] = (pow2[i] * 2) % (cnt+1);
    }

    int mod1 = 0, mod2 = 0;
    if(cnt >= 2) {
        rep(i,n){
            if(x[i] == 1) {
                mod1 += pow1[n-i-1];
                mod1 %= (cnt-1);
            }
        }
    }

    if(cnt < n){
        rep(i,n){
            if(x[i] == 1){
                mod2 += pow2[n-i-1];
                mod2 %= (cnt+1);
            }
        }
    }

    rep(i,n){
        int tmp = 0;
        if(x[i] == 1){
            if(cnt == 1){
                cout << 0 << endl;
                continue;
            }
            else{
                tmp = (mod1 - pow1[n-i-1] + cnt-1) % (cnt-1);
            }
        }
        else{
            tmp = (mod2 + pow2[n-i-1]) % (cnt+1);
        }
        cout << calc(tmp) << endl;
    }
}


Measured memory_bytes: 5956
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int n,ans;
map<int,int>mp;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int x;
		cin>>x;
		mp[x]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++)
	{
		ans+=it->second%2;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4864
#include <stdio.h>

int main()
{
int n,i,c,count=0;
scanf("%d",&n);
for(i=0;i<2;i++)
    {
        c=n%10;
        if(c==9) count++;
        n=n/10;
    }
if(count==2 || count==1) printf("Yes");
else printf("No");
}

Measured memory_bytes: 1688
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;
int a,p;
int n,r;
int l;
int main()
{
	scanf("%d",&n);
	l=sqrt(n);
	p=floor(l);
	printf("%d",p*p);
	return 0;
}

Measured memory_bytes: 256
from math import factorial,sqrt,ceil #,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,K = map(int,input().split())
arrA = list(map(int,input().split()))
ans = ceil((N-1)/(K-1))
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 1e12

#define PB push_back
#define PF push_front
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vpi vector<pii>
#define vll vector<ll>
#define vpl vector<pll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
#define ios ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pr_d(x) cout << fixed << setprecision(15) << x << endl
#define ud(c, x) distance(c.begin(), upper_bound(all(c), x))
#define ld(c, x) distance(c.begin(), lower_bound(all(c), x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep3(i, n) for (int i = (n - 1); i >= 0; --i)
#define rep4(i, a, b) for (int i = (a); i > (b); --i)
#define pb push_back
#define out(x) cout << x << "\n"
bool odd(int i) { return i % 2; }

#define all(v) v.begin(), v.end()
#define size(x) int(x.size())

int gcd(int a, int b) { return __gcd(a, b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
void Yes_No(bool f) {
  if (f)
    printf("Yes\n");
  else
    printf("No\n");
}

void deb_p(pii p) { printf("pair = %d %d\n", p.fi, p.se); }
void deb_i(int i) { printf("i = %d\n", i); }
void deb_v(vector<int> v) {
  printf("v = ");
  for (auto i : v) printf("%d ", i);
  printf("\n");
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
//-------------------ここから回答する-----------------------

void solve(void) { int n, m;
  cin >> n >> m;
  out(--n * --m);
}
int main(void) { solve(); }


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

signed main(){
    
    int n, k; cin >> n >> k;
    cout << n - k + 1 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define N 5000
 
typedef struct list
{
  int x, y;
  char ground;
  struct list *prev;
  struct list *next;
} list;
 
list head;
list tail;
     
void Insert(char);
list *FarSide(list *);
int PubbleArea(list *, list *);
 
int main()
{
  int i;
  char c;
  list *p;
  list *farSide;
  int pubbleCount = 0;
  int pubble[N];
  int sumPubble = 0;
     
  head.next = &tail;
  tail.prev = &head;
     
  // Input
  while(1)
    {
      c = getchar();
      if(c == '\n') break;
 
      Insert(c);
    }
 
  for(p = head.next; p != &tail; p = p->next)
    {
      if(p->ground == '\\' &&
	 (farSide = FarSide(p)) != NULL)
        {
	  pubble[pubbleCount] = PubbleArea(p, farSide);
	  sumPubble += pubble[pubbleCount];
	  p = farSide;
	  pubbleCount++;
        }
         
    }
 
  printf("%d\n%d", sumPubble, pubbleCount);
  for(i = 0; i < pubbleCount; i++)
    {
      printf(" %d", pubble[i]);
    }
  printf("\n");
     
  return 0;
}
 
void Insert(char c)
{
  static int xCount = 0;
  static int yCount = 0;
  list *p;
 
  p = (list*)malloc(sizeof(list));
  p->prev = tail.prev;
  tail.prev->next = p;
  p->next = &tail;
  tail.prev = p;
 
  xCount++;
  if(c == '\\') yCount--;
  if(c == '/' ) yCount++;
  p->x = xCount;
  p->y = yCount;
  p->ground = c;
}
 
list *FarSide(list *s)
{
  list *i_p;
  int height;
  height = s->y + 1;
 
  for(i_p = s->next; i_p != &tail; i_p = i_p->next)
    {
      if(i_p->y == height) return i_p;
    }
  return NULL;
}
 
int PubbleArea(list *pS, list *pE)
{
  list *i_p;
  list *farSide;
  int area = 0;
     
  for(i_p = pS; i_p != pE; i_p = i_p->next)
    {
      if(i_p->ground == '\\')
        {
	  farSide = FarSide(i_p);
	  area += farSide->x - i_p->x;
        }
    }
  return area;
}

Measured memory_bytes: 1488
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

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

cnt = [0]*9
for a in A:
    for i in range(9):
        if i == 8: cnt[i] += 1
        else:
            if a < 400*(i+1):
                cnt[i] = 1
                break

Min = max(sum(cnt[:8]),1)
Max = sum(cnt[:8]) + cnt[8]

print(Min, Max)

Measured memory_bytes: 12212
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a=scan.next();
		if(a.equals("a")||a.equals("e")||a.equals("u")||a.equals("i")||a.equals("o")) {
			System.out.println("vowel");
		}
		else {
			System.out.println("consonant");
		}
	}
	}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

#if DEBUG && !ONLINE_JUDGE
    ifstream input_from_file("input.txt");
    #define cin input_from_file
#else

#endif


const int MAXN = 1e5+10;

vector<int> aa[MAXN];


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); // Togliere nei problemi con query online

    int N, M;
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int u, v;
        cin >> u >> v;
        aa[u].push_back(v);
        aa[v].push_back(u);
    }
    priority_queue<pair<int,int>> bfs;
    vector<int> dist(N+1, MAXN);
    vector<int> segn(N+1, 0);
    vector<bool> done(N+1, false);
    dist[1] = 0;
    bfs.push({0, 1});
    while (!bfs.empty()) {
        int u = bfs.top().second;
        bfs.pop();
        if (done[u]) continue;
        done[u] = true;
        for (int a : aa[u]) {
            //~ cout << u << " " << a << endl;
            if (done[a]) continue;
            if (dist[a] > dist[u] + 1) {
                //~ cout << a << endl;
                dist[a] = dist[u] + 1;
                segn[a] = u;
                bfs.push({-dist[a], a});
            }
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= N; i++) cout << segn[i] << "\n";
}


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

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

int main(){
    int h,w;
    cin>>h>>w;
    vector<string>a(h);
    vector<vector<int>>dist(h,vector<int>(w,1e9));
    vector<pair<int,int>>p;
    rep(i,h)cin>>a[i];
    rep(i,h)rep(j,w)if(a[i][j]=='#')p.push_back(make_pair(i,j));
    queue<pair<int,int>>q;
    auto update=[&](int i, int j, int x){
        if(dist[i][j]!=1e9)return;
        dist[i][j]=x;
        q.push(make_pair(i,j));
    };
    rep(i,p.size()){
        update(p[i].first,p[i].second,0);
    }
    while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second;
        q.pop();
        rep(dir,4){
            int ni=i+di[dir];
            int nj=j+dj[dir];
            if(ni<0||ni>=h||nj<0||nj>=w)continue;
            update(ni,nj,dist[i][j]+1);
        }
    }
    int ans=0;
    rep(i,h)rep(j,w){
        ans=max(ans,dist[i][j]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 21224
#include<bits/stdc++.h>
using namespace std;
 
int frog(int n, int dp[], int a[], int k){
    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++){
        int o1=INT_MAX, o2;
        for(int j=1; j<=k; j++){
            if(j<=i)
        o1=min(o1,dp[i-j]+abs(a[i]-a[i-j]));
       
        }dp[i]=o1;
    }return dp[n-1];
}
 
int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    int dp[n]={0};
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    cout<<frog(n, dp,a,k );
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define maxn 101
#define Max 10000 
using namespace std;
int n,ans=0;
int map[maxn][maxn];

//struct edge
//{
//	int u;
//	int w;
//	edge(int u=0,int w=Max):u(u),w(w){}
//	bool operator <???(const node& rhs) const
//	{
//		return w>rhs.w;
//	} 
//};

void prim()
{
	int d[maxn];
	bool vis[maxn];
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;++i)
	{
		d[i]=Max;
		vis[i]=0;
	}
	d[1]=0;
	while(1)
	{
		int MIN=Max;
		int u=-1;
		for(int i=1;i<=n;++i)
			if(MIN>d[i]&&!vis[i])
			{
				MIN=d[i];
				u=i;
			}
		if(u==-1) break;
		vis[u]=1;
		ans+=d[u];
		for(int i=1;i<=n;++i)
		{
			if(!vis[i] && map[u][i]!=Max)
			  if(d[i]>map[u][i])
			  	d[i]=map[u][i];
		}
	}
	return;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  for(int j=1;j<=n;++j)
	  {
	  	int x;
	  	scanf("%d",&x);
	  	if(x!=-1)
	  	  map[i][j]=x;
	  	else
	  	  map[i][j]=Max;
	  }
	prim();
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 3216
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/soundhound2018-summer-qual/tasks/soundhound2018_summer_qual_d

//ポイント：
//どこかの点を境にして2つに分ける
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N,M,S,T;
//i->jに、a円、bスヌークで到達できるとき、
//集合adj[i]は(j,a,b)を含む
vector<vector<tuple<LL,LL,LL>>> adj;

LL ans[100000];

void solve(){
    //pair(円,頂点番号)
    priority_queue<pair<LL,LL>,vector<pair<LL,LL>>,greater<pair<LL,LL>>> q;
    q.push(pair<LL,LL>(0,S));
    //円だけを使ってSからiまで行くとき、コストの最小値をyen_cost[i]とする
    vector<LL> yen_cost(N+1,INF);
    yen_cost[S] = 0;
    while(!q.empty()){
        LL now_yen = q.top().first;
        LL now_node = q.top().second;
        q.pop();
        for(auto next:adj[now_node]){
            LL next_yen = now_yen + get<1>(next);
            LL next_node = get<0>(next);
            if(yen_cost[next_node]>next_yen){
                yen_cost[next_node] = next_yen;
                q.push(pair<LL,LL>(next_yen,next_node));
            }
        }
    }

    //pair(スヌーク,頂点番号)
    //priority_queue<tuple<LL,LL>,vector<tuple<LL,LL>>,greater<tuple<LL,LL>>> q;
    q.push(pair<LL,LL>(0,T));
    //スヌークを使ってTからiまで行くとき、コストの最小値をsunuke_cost[i]とする
    vector<LL> sunuke_cost(N+1,INF);
    sunuke_cost[T] = 0;
    while(!q.empty()){
        LL now_sunuke = q.top().first;
        LL now_node = q.top().second;
        q.pop();
        for(auto next:adj[now_node]){
            LL next_sunuke = now_sunuke + get<2>(next);
            LL next_node = get<0>(next);
            if(sunuke_cost[next_node]>next_sunuke){
                sunuke_cost[next_node] = next_sunuke;
                q.push(pair<LL,LL>(next_sunuke,next_node));
            }
        }
    }

    ans[N-1] = yen_cost[N]+sunuke_cost[N];
    for(int i=N-2;i>=0;i--){
        ans[i] = min(ans[i+1],yen_cost[i+1]+sunuke_cost[i+1]);
    }

    for(int i=0;i<N;i++) ans[i] = 1e15 - ans[i];
}
 
int main(){
	cin >> N >> M >> S >> T;
    adj = vector<vector<tuple<LL,LL,LL>>>(N+1);
    for(int i=0;i<M;i++){
        LL u,v,a,b;
        cin >> u >> v >> a >> b;
        adj[u].push_back(tuple<LL,LL,LL>(v,a,b));
        adj[v].push_back(tuple<LL,LL,LL>(u,a,b));
    }
 
    solve();

	for(int i=0;i<N;i++) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 14672
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int k, a, b;
    cin >> k;
    cin >> a >> b;
    
    if(int(b/k)*k >= a){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3604
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
const long long INF = 1LL << 60;
typedef pair<int, int> P;

int main() {
    int l,r;
    cin >> l >> r;

    if (r - l >= 2019) {
        cout << 0 << "\n";
        return 0;
    }

    int l2 = l % 2019;
    int r2 = r % 2019;
    
    if (l2 >= r2) {
        cout << 0 << "\n";
        return 0;
    }

    int min = 10000;
    for (int i = l2; i <= r2; i++) {
        for (int j = i+1; j<=r2; j++) {
            chmin(min, (i * j) % 2019);
        }
    }
    cout << min << "\n";
    


}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

string mem[10010];
int use[10] = {0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6};
bool can[10];

string go(int a) {
  if (mem[a] != "") return mem[a];
  if (a == 0) {
    return "";
  }
  string res = "";
  for(int i = 9; i >= 1; i--) {
    if(can[i] && a >= use[i]) {
      string under = go(a-use[i]);
      if (under != "x") {
        string tmp = to_string(i) + under;
        if (SZ(tmp) > SZ(res)) res = tmp;
      }
    }
  }
  if (res == "") res = "x";
  mem[a] = res;
  return res;
}

void init() {

}

void input() {

}

void solve() {
  int n, m;
  cin >> n >> m;
  REP(i, 10010) mem[i] = "";
  REP(i, 10) can[i] = false;
  REP(i, m) {
    int a;
    cin >> a;
    can[a] = true;
  }
  cout << go(n) << endl;
}

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


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int S=a*100+b*10+c;
  if(S%4==0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
// finish date: 2018/09/13
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>>
        vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>>
        vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int H, W;
    cin >> H >> W;
    vvi a(H, vi(W));
    int N = 0;
    rep(i, H) {
        rep(j, W) {
            cin >> a[i][j];
        }
    }
    vi y1, x1, y2, x2;
    int x, y;
    int dir;
    rep(y, H) {
        rep(j, W) {
            if (y == H - 1 && j == W - 1) break;
            if (y % 2 == 0) x = j, dir = 1;
            else x = W - 1 - j, dir = -1;
            if (a[y][x] != 0 && a[y][x] % 2 == 1) {
                N++;
                if (j == W - 1) {
                    a[y + 1][x] += 1;
                    a[y][x] -= 1;
                    y1.emplace_back(y);
                    x1.emplace_back(x);
                    y2.emplace_back(y + 1);
                    x2.emplace_back(x);
                } else {
                    a[y][x + dir] += 1;
                    a[y][x] -= 1;
                    y1.emplace_back(y);
                    x1.emplace_back(x);
                    y2.emplace_back(y);
                    x2.emplace_back(x + dir);
                }
            }
        }
    }
    cout << N << endl;
    rep(i, N) {
        cout << y1[i]+1 << " " << x1[i]+1 << " " << y2[i]+1 << " " << x2[i]+1 << endl;
    }

    return 0;
}



Measured memory_bytes: 5224
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>

using namespace std;

long long int a = 0, b = 0, c =0, d = 0, e = 0, n = 0, maxy = 0, mini = 9999, ans = 0, counter = 0, sur = 0;
std::vector<int> vec{};
std::vector<std::string>str{};
std::vector<std::string>str2{};

int arraykun[2300] = {}, nyan[1001] = {}, koji[50][50];
std::string output, output2, input,nyahhoi;
int kakunou[50][50] = { 53 }, moji[50];

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
int dp(int i, int j) {
	bool okada = true;
	if (i == 0 || j == 0) {
		okada = false;
		return 0;
	}
	if (koji[i][j] == -1) {
		okada = false;
		return 0;
	}
	if (i == 1 && j == 1) {
		okada = false;
		return 1;
	}
	if (okada) {
		return dp(i - 1, j) + dp(i, j - 1);
	}

}
int main()
{

	cin >> a;
	for (int i = 0; i < a; i++) {
		cin >> input;
		str.push_back(input);
	}
	cin >> b;
	for (int i = 0; i < b; i++) {
		cin >> input;
		str2.push_back(input);
	}
	for (int i = 0; i < a; i++) {
		counter = 0;
		nyahhoi = str[i];
		for (int j = 0; j < a; j++) {
			if (nyahhoi == str[j]) {
				counter++;
			}
	    }
		for (int k = 0; k < b; k++) {
			if (nyahhoi == str2[k]) {
				counter--;
			}
		}
		if (maxy < counter) {
			maxy = counter;
		}
	}
	cout << maxy << endl;
}






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

    typedef long long int ll;
    #define pb         push_back
    #define mp         make_pair
    #define F          first
    #define S          second
    #define fl(i,a,b)  for(ll i=a;i<b;i++)
    #define pll        pair<ll,ll>
    #define pii        pair<int,int>
    #define all(v)     v.begin(),v.end()
    #define M 1000000007
    #define tr(v, it) for(auto it = v.begin(); it != v.end(); it++)
    using namespace std;



    int main()
    {

        ios_base::sync_with_stdio(false);
    	cin.tie(NULL);

          int n,k;
          cin>>n>>k;
          int arr[n];
          for(int i=0;i <n; i++)
          {
              cin>>arr[i];
          }
          int dp[n];
          dp[0]=0;
          dp[1]=abs(arr[0]-arr[1]);
          for(int i=2; i<n; i++)
            dp[i]=INT_MAX;
          for(int i=2; i<n; i++)
          {
              int t;
              if(k>=i)
              t=i;
              else
              t=k;
              for(int j=t; j>0; j--)
              dp[i]=min((dp[i-j]+abs(arr[i]-arr[i-j])), dp[i]);
          }
          cout<<dp[n-1];
       return 0;
    }


Measured memory_bytes: 4408
#define DBG 0 //submit 0
#define ll long long
#if DBG
    #include <algorithm>
    #include <array>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <unordered_map>
    #include <iostream>
    #include <cmath>
    #include <numeric>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;


int main(){
    int i,N;
    ll ans = 0;
    cin >> N;
    vector<int> a(N+1),b(N);
    for(i=0;i<N+1;i++) cin >> a[i];
    for(i=0;i<N;i++) cin >> b[i];

    for(i=0;i<N;i++){
        if(a[i] > b[i]){
            ans+=b[i];
        }else{
            ans+=a[i];
            b[i]-=a[i];
            if(b[i] > a[i+1]){
                ans+=a[i+1];
                a[i+1]=0;
            }else{
                ans+=b[i];
                a[i+1]-=b[i];
            }
        }
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>

int main() {
  char buf[201];
  char s[101], p[101];

  scanf("%s\n", s);
  scanf("%s\n", p);

  buf[0] = 0;
  strcpy(buf, s);
  strcat(buf, s);

  if (strstr(buf, p) != NULL) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}



Measured memory_bytes: 2720
#include<stdio.h>
#define MAX 100
#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2
int n,M[MAX][MAX],d[MAX],color[MAX];

void dij(void);

int main(){
  int i,j,k,c,u,v;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
 M[u][v]=c;
    }
  }
  dij();
  for(i=0;i<n;i++){
    printf("%d ",i);
    if(d[i]==INFTY)printf("%d\n",-1);
    else printf("%d\n",d[i]);
  }
  return 0;
}
void dij(void){
  int minv,i,u,v;
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    u=-1;
    for(i=0;i<n;i++){
      if(minv>d[i] && color[i]!=BLACK){
        u=i;
        minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK && M[u][v]!=INFTY){
 if(d[v]>d[u]+M[u][v]){
          d[v]=d[u]+M[u][v];
          color[v]=GRAY;
        }
      }
    }
  }
}

Measured memory_bytes: 640
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          ABC092-C
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,x,n) for(int i=x;i<(n);i++)
typedef pair<int,int> ii;
#define vii vector<ii>
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+5;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// Criba de Eratostenes ------------------------------------
const int pr=10000;
map<int,int>isp;
void criba(){
    for(int i=0;i<=pr;i++)isp[i]=i;
    isp[0]=isp[1]=-1;
    for(int i=2;i*i<=pr;i++){
        if(isp[i]==i){
        for(int j=2*i;j<=pr;j+=i)
            isp[j]=i;
        }
    }
}
/// My Code ------------------------------------------------

int a[maxn],b[maxn];

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);
    ///criba();
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    int mid=b[n/2];
    for(int i=0;i<n;i++){
        if(a[i]>=mid)cout<<b[n/2-1]<<enl;
        else cout<<mid<<enl;
    }

    return 0;
}


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

#define IOS          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl         "\n"
#define int          long long
#define all(v)       v.begin(),v.end()
#define sz(v)        (int)v.size()
#define pii          pair<int,int>
#define fi           first
#define se           second
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define deb(x)       cout << #x << ' ' << x << endl
#define clock        cerr << 1000 * (double)clock() / (double)CLOCKS_PER_SEC << "ms" << endl;

void INPUT() {
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

const int N = 1e5 + 5;
int a[N][3], n;
int cache[N][3];

int dp(int idx, int prev) {
	if (idx >= n) return 0;
	if (cache[idx][prev] != -1) return cache[idx][prev];
	int ans = 0;
	forn(i, 0, 3) {
		if (i != prev) ans = max(ans, a[idx][i] + dp(idx + 1, i));
	}
	cache[idx][prev] = ans;
	return ans;
}

int32_t main(){
    IOS //INPUT();
    cin >> n;
    memset(cache, -1, sizeof(cache));
    forn(i, 0, n) {
    	forn(j, 0, 3) cin >> a[i][j];
    }
    int ans = 0;
    forn(i, 0, 3) {
    	ans = max(ans, a[0][i] + dp(1, i));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    for(char c : s) {
        ans += (c == '+' ? 1 : -1);
    }
    cout << ans << '\n';
}


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

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int check[26]={0};
    int count=0;
    int max=0;
    int i,j,k;

    for(i=0; i<N-1; i++){
        count=0;
        for(j=0; j<i+1; j++){
            for(k=0; k<26; k++){
                if(S[j]=='a'+k) check[k]=1;
            }
        }
        for(j=i+1; j<N; j++){
            for(k=0; k<26; k++){
                if(S[j]=='a'+k){
                    if(check[k]==1) check[k]++;
                }
            }
        }
        for(k=0; k<26; k++){
            if(check[k]==2) count++;
        }
        if(max<count) max=count;
        count=0;
    }

    cout << max << endl;
}

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

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

    int N;
    cin >> N;

    pair<int, int> global_min{INT_MAX, -1},
                   global_max{INT_MIN, -1};
    vector<pair<int, int>> balls(N);

    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        if (x > y) swap(x, y);

        balls[i] = {x,y};
        global_min = min(global_min, {x,i});
        global_max = max(global_max, {y,i});
    }

    long long ans = LLONG_MAX;

    // put the global min and global max on opposite colors, minimize both ranges greedily
    int min_side_high = INT_MIN, max_side_low = INT_MAX;
    for (int i = 0; i < N; i++) {
        min_side_high = max(min_side_high, balls[i].first);
        max_side_low = min(max_side_low, balls[i].second);
    }
    ans = (long long)(min_side_high - global_min.first)
        * (global_max.first - max_side_low);

    // put the global min and global max on the same color, minimize range of the other color
    if (global_min.second != global_max.second) {
        multiset<int> other;
        other.insert(balls[global_min.second].second);
        other.insert(balls[global_max.second].first);

        int rem1 = global_min.second, rem2 = global_max.second;
        if (rem1 < rem2) swap(rem1, rem2);
        balls.erase(balls.begin() + rem1);
        balls.erase(balls.begin() + rem2);

        // initially assume that other's min is at minus infinity: just give it the lower of each pair
        for (pair<int, int> p : balls)
            other.insert(p.first);
        ans = min(ans, (long long)(global_max.first - global_min.first)
                * (*other.rbegin() - *other.begin()));

        // now to increase other's min, we need to switch some prefix of the balls from
        // contributing their lower to contributing their heigher
        sort(balls.begin(), balls.end());
        for (int i = 0; i < int(balls.size()); i++) {
            other.erase(other.find(balls[i].first));
            other.insert(balls[i].second);
            ans = min(ans, (long long)(global_max.first - global_min.first)
                    * (*other.rbegin() - *other.begin()));
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 11264