akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

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

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  char s; cin>>s;
  char t = s+'b'-'a';
  cout << t << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp61 {
    class Program {
        static void Main(string[] args) {
            string N = Console.ReadLine();

            int N_0 = int.Parse(N[0].ToString());
            int N_1 = int.Parse(N[1].ToString());
            int N_2 = int.Parse(N[2].ToString());

            if (N_1 <= N_0 && N_2 <= N_0) {
                Console.WriteLine(N_0.ToString() + N_0.ToString() + N_0.ToString());
            } else {
                if (N_0 == 9) {
                    Console.WriteLine(1111);
                } else {
                    Console.WriteLine((N_0 + 1).ToString() + (N_0 + 1).ToString() + (N_0 + 1).ToString());
                }
                
            }


        }
    }
}


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

int main() {
  int H, W, i, j;
  
  //input
  cin >> H >> W;
  vector<vector<char>> bomb(H + 2, vector<char>(W + 2));
  vector<vector<int>> cnt(H + 2, vector<int>(W + 2));
  for (i = 1; i < H + 1; i++){
    for (j = 1; j < W + 1; j++){
      cin >> bomb.at(i).at(j);
    }
  }
  
  
  //カウントの初期化
  for (i = 0; i < H + 2; i++){
    for (j = 0; j < W + 2; j++){
      cnt.at(i).at(j) = 0;
    }
  }
  
  //カウント
  for (i = 1; i < H + 1; i++){
    for (j = 1; j < W + 1; j++){
      if(bomb.at(i).at(j) == '#'){
        cnt.at(i - 1).at(j - 1)++;
        cnt.at(i - 1).at(j)++;
        cnt.at(i - 1).at(j + 1)++;
        cnt.at(i).at(j - 1)++;
        cnt.at(i).at(j + 1)++;
        cnt.at(i + 1).at(j - 1)++;
        cnt.at(i + 1).at(j)++;
        cnt.at(i + 1).at(j + 1)++;
      }
    }
  }
  
  //出力
  for (i = 1; i < H + 1; i++){
    for (j = 1; j < W + 1; j++){
      if(bomb.at(i).at(j) == '.'){
        cout << cnt.at(i).at(j);
      } else if (bomb.at(i).at(j) == '#'){
        cout << "#";
      }
    }
    cout << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    sort(ALL(s));
    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    string str;
    
    getline(cin, str);
    for (int i = 0; i < str.length(); i++)
    {
        if (isupper(str[i]))
        {
            str[i] = tolower(str[i]);
        }
        else if (islower(str[i]))
        {
            str[i] = toupper(str[i]);
        }
    }
    
    cout << str << endl;
    
    return 0;
}



Measured memory_bytes: 3156
n,a,b = map(int,input().split())
ans = 0
for i in range(1,n+1):
    s = list(str(i))
    p = 0
    for j in range(len(s)):
        p += int(s[j])
    if (p >= a) and (p <= b):
        ans += i

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
const int N = 1e4 + 5;
ll n, p, ans, cnt[N];
string s;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> p >> s;
    if(p == 2 || p == 5)
    {
        for(int i = 0;i < n;++i)
            if((s[i] - '0') % p == 0)
                ans += (i + 1);
    }
    else
    {
        reverse(s.begin(), s.end());
        ll cum = 0, ten = 1;
        ++cnt[0];
        for(int i = 0;i < n;++i)
            ans += cnt[(cum += (s[i] - '0') * ten) %= p]++, (ten *= 10) %= p;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)N;i++)
int main()
{
  int N,M;
  int64_t sum=0,count=0;
  cin>>N>>M;
  vector<int> A(N,0);
  rep(i,N){cin>>A.at(i);sum+=A.at(i);}
  rep(i,N){count+=(A.at(i)<(double)(sum/(double)(4*M)))?1:0;if(count>(N-M)){cout<<"No"<<endl;return 0;}}
  cout<<"Yes"<<endl;
}

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

using namespace std;

int main()
{
    long long n, a[1010], t[1010];
    cin >> n;
    for (int i = 0; i < n; ++i)
    {
        cin >> t[i] >> a[i];
    }
    long long x = 1ll;
    for (int i = 1; i < n; ++i)
    {
        x = max( (t[i-1]*x + t[i] - 1) / t[i], (a[i-1] * x + a[i] - 1) / a[i]);
    }
    cout << x * t[n-1] + x*a[n-1];
    return 0;
}


Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 5e5+5;
const ll M = 1e9+7;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
ll qpow(ll a,ll b) {ll s=1;while(b){if(b&1)s=(s*a)%M;a=(a*a)%M;b>>=1;}return s; }
int n,m;
ll fac[maxn],inv[maxn],f[maxn];

void init()
{
    int n = 5e5;
    fac[0] = 1;
    rep(i,1,n) fac[i] = fac[i-1]*i%M;
    inv[n] = qpow(fac[n],M-2);
    per(i,n-1,0) inv[i] = inv[i+1]*(i+1)%M;
}

ll C(int a,int b) {return a<b?1:fac[a]*inv[b]%M*inv[a-b]%M;}
ll A(int a,int b) {return fac[a]*inv[a-b]%M;}

int main()
{
    fastio();
    init();
    cin>>n>>m;
    ll ans = 0;
    rep(i,0,n){
        ans = (ans + ((i&1)?-1:1)*C(n,i)*A(m-i,n-i)%M +M)%M;
    }
    ans = ans*A(m,n)%M;
    cout<<ans<<endl;
    return 0;
}


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

int main() {

  string S; cin >> S; // 入力文字列：４桁
  vector<int> N(4);   // 入力文字列の数値化配列
  rep(i,4){N.at(i)=S.at(i) - '0';}

  rep(i,(1<<3)){      // 符号が入る３桁の全探索
    bitset<3> b(i);   // 符号のビットセット：1が＋／0が－
    int wk = N.at(0); // 判定用数値

    rep(j,3){   // フラグ位置を前からチェックしていく。
      // １なら加算。０なら減算
      wk += ( b.test(j) ? N.at(j+1) : - N.at(j+1) );
    }
    // 計算結果判定
    if (wk == 7 ){
      cout << N.at(0);
      rep(j,3){   // フラグ位置を前からチェックしていく。
        cout << ( b.test(j) ? "+" : "-" ) ;
        cout << N.at(j+1);
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;

}


Measured memory_bytes: 256
//C
#include <cassert>
//#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//ここまで標準include

using namespace std;

long aCb(long a, long b) {
	long out = 1;
	for (long i = 1; i <= b; i++) {
		out = out * (a + 1 - i) / i;
	}
	return out;
}

long long gcd(long long a, long long b) {
	long long r = -1;
	if (a < b) {
		swap(a, b);
	}
	while (r != 0) {
		r = a % b;
		if (r == 0) {
			return b;
		}
		else {
			a = b;
			b = r;
		}
	}
}

long long lcm(long long a, long long b) {
	return a * b / gcd(a, b);
}

int main() {
	vector<char>data(19);
	for (int i = 0; i < 19; i++) {
		cin >> data[i];
		if (data[i] == ',') {
			data[i] = ' ';
		}
		cout << data[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashMap;

fn helper(
  map: &mut HashMap<usize, usize>,
  val: usize,
  count: usize
) -> usize {
  if val == 1 {
    return 1
  }
  
  if let Some(memo_val) = map.get(&val) {
    *memo_val
  } else {
    let result = count + 2 * helper(map, val / 2, 1);
    map.insert(val, result);
    result
  }
}

fn main() {
  input! {
    h: usize,
  }

  let mut map: HashMap<usize, usize> = HashMap::new();
  println!("{}", helper(&mut map, h, 1));
}

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

using ll = long long;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    vector<vector<int>> edge(N, vector<int>(0)), from(N, vector<int>(0));
    rep(i, M) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        edge[A[i]].push_back(B[i]);
        from[B[i]].push_back(A[i]);
    }
    int pmin = 1001, ans;
    rep(i, N) {
        queue<vector<int>> q;
        q.push({i, 0});
        bool f = false;
        vector<bool> done(N, false);
        while (!q.empty()) {
            auto p = q.front();
            q.pop();
            if (p[1] + 1 >= pmin) break;
            done[p[0]] = true;
            rep(j, edge[p[0]].size()) {
                if (edge[p[0]][j] == i) {
                    pmin = p[1] + 1;
                    ans = i;
                    f = true;
                    break;
                }
                if (done[edge[p[0]][j]]) continue;
                q.push({edge[p[0]][j], p[1] + 1});
            }
            if (f) break;
        }
    }
    if (pmin == 1001) {
        cout << "-1" << endl;
    } else {
        cout << pmin << endl;
        queue<vector<int>> q;
        q.push({ans, 0});
        vector<bool> done(N, false);
        vector<int> d(N, -1);
        d[ans] = 0;
        while (!q.empty()) {
            auto p = q.front();
            q.pop();
            done[p[0]] = true;
            d[p[0]] = p[1];
            rep(j, edge[p[0]].size()) {
                if (edge[p[0]][j] == ans) {
                    break;
                }
                if (done[edge[p[0]][j]]) continue;
                q.push({edge[p[0]][j], p[1] + 1});
            }
        }
        for (int i = pmin - 1; i >= 0; i--) {
            rep(j, from[ans].size()) {
                if (d[from[ans][j]] == i) {
                    cout << from[ans][j] + 1 << endl;
                    ans = from[ans][j];
                    break;
                }
            }
        }
    }
}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>

using namespace std;

long long dp[51][2501];
int x[51];

int main(){
	int n, a;
	scanf("%d%d", &n, &a);
	for(int i = 0; i < n; i++){
		scanf("%d", &x[i]);
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++){
		int tx = x[i - 1];
		for(int j = i; j > 0; j--){
			for(int k = tx; k <= 2500; k++){
				if(dp[j - 1][k - tx] != 0){
					dp[j][k] += dp[j - 1][k - tx];
				}
			}
		}
	}
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		ans += (long long)dp[i][i * a];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 640
while 1:
    z=int(input())**3
    if z==0:break
    m,x=0,0
    while 1:
        x+=1
        xx=x**3
        y=int((z-xx)**(1/3))
        if y<x:break
        m=max(m,y**3+xx)
    print(z-m)

Measured memory_bytes: 7748
#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 trep(i, n) for(int i = 0; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)

int d[114514];

int main() {
  int n;
  cin >> n;
  rep(i, 114514) {
    d[i] = 0;
  }
  rep(i, n) {
    int w;
    cin >> w;
    d[w]++;
  }
  int ma = 0;
  mfor(i, 1, 114513) {
    ma = max(ma, d[i - 1] + d[i] + d[i + 1]);
  }
  cout << ma << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

int main(){
  llong ans = 0;
  llong A, B, C, K;
  cin >> A >> B >> C >> K;
  if(K<=A) ans = K;
  else if(K <=A+B) ans = A;
  else ans = A - K+(A+B);
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int  main(){
	ll n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0)continue;
		else ans+=i; 
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<stdio.h>


void Swap( int *a ,int *b )
{
	*a += *b ;
	*b = *a - *b ;
	*a = *a - *b ;
}

void Cut( int K ,int N ,int *num )
{
	N *= 2 ;

	int i ,j ;
	for( i = 1 ; i <= K ; ++i )
	{
		for( j = K - i + 1 ; j < N - i + 1 ; ++j )
		{
			Swap( num + j - 1 ,num + j ) ;
		}
	}
}

void reFulShuffle( int N ,int *num )
{
	int numB[ 200 ] ;

	N ;
	int i ,A ,B ;
	for( i = 0 ; i < N * 2 ; ++i )
	{
		numB[ i ] = num[ i ] ;
	}

	A = B = 0 ;
	for( i = 0 ; i < N * 2 ; ++i )
	{
		if( i % 2 == 0 )
		{
			num[ i ] = numB[ A ] ;

			++A ;
		}

		else
		{
			num[ i ] = numB[ N + B ] ;

			++B ;
		}
	}
}

void Choose( int K ,int N ,int *num )
{
	if( K == 0 )
	{
		reFulShuffle( N ,num ) ;
	}

	else
	{
		Cut( K ,N ,num ) ;
	}
}


int main( void )
{
	int N ;
	scanf( "%d" ,&N ) ;

	int M ,K ;
	scanf( "%d" ,&M ) ;

	int num[ 200 ] ;

	int i ;
	for( i = 0 ; i < N ; ++i )
	{
		num[ i * 2 ] = ( i * 2 ) + 1 ;
		num[ i * 2 + 1 ] = ( i * 2 ) + 2 ;
	}
	
	for( i = 0 ; i < M ; ++i )
	{
		scanf( "%d" ,&K ) ;

		Choose( K ,N ,num ) ;
	}

	N *= 2 ;
	for( i = 0 ; i < N ; ++i )
	{
		printf( "%d\n" ,num[ i ] ) ;
	}

	return 0 ;
}


Measured memory_bytes: 2100
void main()
{
    long n = rdElem;
    string s = rdStr;

    long len = s.length;
    foreach (i; 0 .. 4)
    {
        string t;
        t ~= (i & 1 ? 'S' : 'W'), t ~= ((i >> 1) & 1 ? 'S' : 'W');
        foreach (j; 1 .. len+1)
        {
            if ((t[j] == 'S') == (s[j%len] == 'o')) t ~= t[j-1];
            else t ~= (t[j-1] == 'S' ? 'W' : 'S');
        }

        if (t[0..2] != t[len..len+2]) continue;
        t[0..len].writeln;
        return;
    }

    writeln(-1);
}

enum long mod = 10L^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <queue>
#include <iomanip>

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

int H, W;

int main() {
  cin >> H >> W;
  string mat[H];
  int c[26];
  rep(i, 26) {
    c[i] = 0;
  }
  rep(i, H) {
    cin >> mat[i];
    rep(j, W) {
      c[mat[i].at(j) - 'a']++;
    }
  }

  int numodd = 0;
  int sumrem = 0;
  rep(i, 26) {
    int rem = c[i]%4;
    sumrem += rem;
    if (rem%2 == 1) {
      numodd++;
    }
  }
  if (H%2 == 0 || W%2 == 0) {
    if (numodd > 0) {
      cout << "No" << endl;
      return 0;
    }
  } else {
    if (numodd > 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  int tolerant = 0;
  if (H%2 == 1) {
    tolerant += W;
  }
  if (W%2 == 1) {
    tolerant += H;
  }
  if (H%2 == 1 && W%2 == 1) {
    tolerant--;
  }
  if (sumrem > tolerant) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>	
#define pb push_back
#define mp make_pair
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;

const int inf = int(2e9);
const int mod = inf + 7;
using namespace std;

void solve()
{
	int a[5];
	int mx = 10;
	int idx = 0;
	rep(i, 5) {
		cin >> a[i];
		if(a[i] % 10 != 0 && a[i] % 10 < mx) {
			mx = a[i] % 10;
			idx = i;
		}
	}
	ll sum = a[idx];
	rep(i, 5){
		if(i == idx) continue;
		int cur = 0;
		if(a[i] % 10 != 0) cur++;
		cur += a[i] / 10;
		sum += cur * 10;
	}
	cout << sum;
}

int main()
{
	Red;
	solve();
	return 0;
}


Measured memory_bytes: 256
def resolve():
    def is_ok(mid):
        cnt = 0
        for a in A:
            cnt += (a-1)//mid
        return cnt <= K

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

    ok = max(A)
    ng = 0
    while ok - ng > 1:
        mid = (ok+ng)//2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    print(ok)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 30880
H, W, A, B = input().strip().split()
H, W, A, B = [int(H), int(W), int(A), int(B)]

for i in range(B): # i = 0, 1, ..., B-1
    print('1' * A + '0' * (W - A))

for i in range(H-B):
    print('0' * A + '1' * (W - A))

Measured memory_bytes: 3956
def GCD(x,y):
    a = x%y
    while a != 0:
        x = y
        y = a
        a = x%y
    return y

L = input().split()
L = [int(L[0]),int(L[1])]
L = sorted(L)
x = L[0]
y = L[1]

print(GCD(x,y))


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
//ll memo[2001];
//ll dfs(ll now){
//    ll& ret = memo[now];
//    if(ret != -1) return ret;
//    ret = 0;
//    if(now < 3) return ret;
//    ret = 1;
//    for(int i = 3; i <= now; i++){
//        ll L = i, R = now-i;
//        if(R < 3) break;
//
//        cout << now << " " << L << " " << R << endl;
//
//        ret *= dfs(L)*dfs(R)%MOD;
//        ret %= MOD;
//    }
//    ret += 1;
//
//    return ret;
//}
       
template<class Type>
Type solve(Type res = Type()){
    ll S; cin >> S;
//    fill(memo,memo+2001,-1);
//
//    res = dfs(S);
//    for(int i = 0; i <= S;i++){
//        cout << i << " : " << memo[i] << endl;
//    }
    
    ll N = (S+2)/3;
    auto dp = make_v<ll>(N+1,S+1);
    dp[0][0] = 1;
    for(int i = 0; i < N;i++){
        for(int j = 0; j <= S; j++){
            if(dp[i][j] == 0) continue;
            for(int k = 3; j+k <= S; k++){
                dp[i+1][j+k] += dp[i][j];
                if(dp[i+1][j+k]>=MOD) dp[i+1][j+k]-=MOD;
            }
        }
    }
    
    for(int i = 0; i <= N;i++){
        (res += dp[i][S])%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 13752
ONE = '1'.freeze
MOD = (10**9) + 7

def inv(x)
  res = 1 # 最終的に x^(MOD-2) になる変数
  beki = x # x^2^n を格納する変数
  # MOD-2の２進数展開を下位のbitから見る
  (MOD - 2).to_s(2).reverse.chars do |digest|
    # bitが立っている <=> digest == ONE 
    # なら resにbekiを掛る
    # ここで、掛け算は計算の都度MODを取る
    res = (beki * res) % MOD if digest == ONE
    # 次のループに備えて、自乗を計算する
    # 計算の都度MODを取る
    beki = (beki * beki) % MOD
  end
  res
end


# 0 となる部屋の組み合わせ * 重複組合せ
n, k = gets.chomp.split(" ").map(&:to_i)
a = 1
ans = 1
k = k >= n ? n - 1 : k

(1..k).each do |i|
   	a *= (n - i) * (n + 1 - i)
    a %= MOD
    a *= inv(i)**2
    a %= MOD
    ans += a
    ans %= MOD
end

puts ans



Measured memory_bytes: 1916
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <set>
#include <string>
#include <queue>

using namespace std;

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> order(N + 1);
    set<int> s = {0, N + 1};
    rep(i, N){
        int a;
        cin >> a;
        order[a] = i + 1;
    }
    ll ans = 0;

    for(int i = 1; i <= N; i++){
        auto r = s.lower_bound(order[i]);
        auto l = r --;
        ans += i * 1L * (*r - order[i]) * (order[i] - *l);
        s.insert(order[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static final int MAX = 300000;
	public static final int S_MAX = (int) (Math.ceil(Math.sqrt(MAX)));
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		boolean[] is_16prime = new boolean[MAX + 1];
		
		for(int i = 2; i <= MAX; i++){
			is_16prime[i] = (i % 7 == 1 || i % 7 == 6);
		}
		
		for(int i = 6; i <= S_MAX; i++){
			if(is_16prime[i]){
				for(int j = 2 * i; j <= MAX; j += i){
					is_16prime[j] = false;
				}
			}
		}
		
		ArrayList<Integer> p_list = new ArrayList<Integer>(); 
		for(int i = 0; i <= MAX; i++){
			if(is_16prime[i]){
				p_list.add(i);
			}
		}
		
		while(true){
			final int n = sc.nextInt();
			
			if(n == 1){
				break;
			}
			
			System.out.print(n + ":");
			
			for(int i = 0; i < p_list.size(); i++){
				final int tmp = p_list.get(i);
				
				if(tmp > n){
					break;
				}
				
				if(n % tmp == 0){
					System.out.print(" " + tmp);
				}
			}
			
			System.out.println();
		}
	}

}

Measured memory_bytes: 26364
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void){
  char w[11],t[1001];
  int l,i,c=0;
  scanf("%s",w);
  for(i=0;w[i]!='\0';i++){
    w[i]=tolower(w[i]);
  }
  while(1){
    scanf("%s",t);
    if(strcmp(t,"END_OF_TEXT")==0)
      break;
    for(i=0;t[i]!='\0';i++){
      t[i]=tolower(t[i]);
    }
    if(strcmp(t,w)==0)
    c++;
  }
  printf("%d\n",c);
  return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int main(void){
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    int a[q];
    for (int i = 0; i < q; i++){
        scanf("%d", &a[i]);
    }

    int count[n];
    for (int i = 0; i < n; i++){
        count[i] = k - q;
    }
    
    for (int i = 0; i < q; i++){
        count[a[i] - 1] += 1;
    }
    for (int j = 0; j < n; j++){
        if (count[j] <= 0){
            printf("%s\n", "No");
        }
        else {
            printf("%s\n", "Yes");
        }
    }

    return 0;
}


Measured memory_bytes: 1280
# 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] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
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)
# pragma warning(disable:4996)

struct node {
	LL val;
	node *lch, *rch;
};

//数xを追加
node *insert(node *p, int x) {
	if (p == NULL) {
		node *q = new node;
		q->val = x;
		q->lch = q->rch = NULL;
		return q;
	}
	else {
		if (x < p->val)p->lch = insert(p->lch, x);
		else p->rch = insert(p->rch, x);
		return p;
	}
}

//値xを検索
bool find(node *p, int x) {
	if (p == NULL)return false;
	else if (x == p->val)return true;
	else if (x < p->val)return find(p->lch, x);
	else return find(p->rch, x);
}

//値xを削除
node *remove(node *p, int x) {
	if (p == NULL)return NULL;
	else if (x < p->val)p->lch = remove(p->lch, x);
	else if (x > p->val)p->rch = remove(p->rch, x);
	else if (p->lch == NULL) {
		node *q = p->rch;
		delete p;
		return q;
	}
	else if (p->lch->lch == NULL) {
		node *q = p->lch;
		q->rch = p->rch;
		delete p;
		return q;
	}
	else {
		node *q;
		for (q = p->lch; q->rch->rch != NULL; q = q->rch);
		node *r = q->rch;
		q->rch = r->lch;
		r->lch = p->lch;
		r->rch = p->rch;
		delete p;
		return q;
	}
}

node *root = NULL;

void inorder(node *p) {
	if(p->lch!=NULL)inorder(p->lch);
	cout << " " << p->val;
	if(p->rch!=NULL)inorder(p->rch);
}

void preorder(node *p) {
	cout << " " << p->val;
	if (p->lch != NULL)preorder(p->lch);
	if (p->rch != NULL)preorder(p->rch);
}

int main() {
	int n;
	cin >> n;
	REP(qqq, n) {
		string s;
		cin >> s;
		if (s == "insert") {
			LL num;
			cin >> num;
			root = insert(root, num);
		}
		else {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
	//system("pause");
}


Measured memory_bytes: 18796
#include <stdio.h>
#include <math.h>

int main(void){
        int n, t, a, i, minp;
        double ans, h[1000], tmp[1000];

        scanf("%d %d %d", &n, &t, &a);
        for(i=0; i<n; i++){
                scanf("%lf", &h[i]);
        }
        for(i=0; i<n; i++){
                tmp[i] = t - h[i]*0.006;
        }
        ans = 1000.0;
        for(i=0; i<n; i++){
                if(ans > fabs(tmp[i] - a)){
                        ans = fabs(tmp[i] - a);
                        minp = i+1;
                }
        }
        printf("%d\n", minp);
        return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define oo 666666666
#define ll long long
#define ld long double

int A[25][25];
ll DP[1<<21];
ll mod = 1e9+7;
int n;

ll solve(ll mask)
{
    if(mask == (1<<n)-1)return 1;
    bitset<21>M(mask);
    int man = M.count();
    if(man >= n)return 0;
    if(DP[mask]!=-1)return DP[mask];

    DP[mask]=0;

    for(int i=0; i<n; i++)
        if(!M[i] && A[man][i])
            {
                DP[mask]+=solve(mask|(1<<i));
                DP[mask]%=mod;
            }

    return DP[mask];
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    memset(DP, -1, sizeof DP);
    cin>>n;
    for(int i=0; i<n; i++)
        for(int j=0; j<n; j++)
        cin>>A[i][j];

    cout<<solve(0);
}


Measured memory_bytes: 16640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Console.ReadLine().ToInt();
            Console.WriteLine((int)(N/2) + N % 2);
            Console.ReadLine();
        }
    }

    public static class Extentions
    {
        public static int ToInt(this object obj)
        {
            return int.Parse(obj.ToString());
        }

        public static decimal ToDecimal(this object obj)
        {
            return decimal.Parse(obj.ToString());
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(ll i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
map<ll,ll> prime_factor(ll x){
    map<ll,ll> m;
    ll sq=(ll)sqrt(x) + 1;
    vector<ll> v_prime=vectorprime(sq);
    
    ll tmp=x;
    rep(i,sz(v_prime)){
        ll count=0;
        while(tmp % v_prime[i] == 0){
            tmp /= v_prime[i];
            count++;
        }
        if(count != 0) m[v_prime[i]]=count;
        if(tmp==1) break;
    }
    
    if(tmp != 1) m[tmp]=1;
    return m;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    if(N==1) cout<<1<<endl;
    else{
        map<ll,ll> m;
        FOR(i,2,N+1){
            map<ll,ll> tmp=prime_factor(i);
            for(auto x:tmp){
                m[x.a]+=x.b;
            }
        }
        ll ans=1;
        for(auto x:m){
            ans*=x.b+1;
            ans%=MOD;
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 3684
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
} 

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	int n,k;
	cin >> n >> k;
	vector<int> v(n);
	vector<double> pref(n+1);
	double sol = -1;
	for(int i = 0; i< n; ++i)
	{
		cin >> v[i];
		pref[i+1] = 1.0 / v[i] * ((v[i] * (v[i]+1))/2.0);
		if(i)
			pref[i+1]+=pref[i];

		if(i+1 >= k)
		{
			sol = max(sol, pref[i+1] - pref[i-k+1]);	
		}
	}
	cout << fixed << setprecision(7) << sol;

    return 0;
}

Measured memory_bytes: 2560
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)*}
    };
}

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, 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")
    };
}

fn main() {
    input! {
        c: chars,
    }
    let res = match c[0] {
        'A' => 'T',
        'C' => 'G',
        'T' => 'A',
        'G' => 'C',
        _ => 'a',
    };
    // println!("{} {} {} {}",H, W, h, w);

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


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

struct num {
	int ord; int number;
};
int const MAX = 200003;
num a[MAX];
int b[MAX];
bool order(num x, num y) {
	return x.number < y.number;
}
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		a[i].ord = i;
		cin >> a[i].number;
	}
	sort(a + 1, a + n + 1, order);
	for (int i = 1; i <= n / 2; i++) {
		b[a[i].ord] = n / 2 + 1;
	}
	for (int i = n / 2 + 1; i <= n; i++) {
		b[a[i].ord] = n / 2;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[b[i]].number << endl;
	}
}

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

int a, b, t, r;

int main(){
	while (cin >> a >> b && a|b != 0) {
		t = a + b;
		r = 0;
		for (int i = 1; i < 5; i++) {
			cin >> a >> b;
			if (t < a + b) {
				r = i;
				t = a + b;
			}
		}
		char c = 'A' + r;
		cout << c << " " << t << endl;
	}

	return 0;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
#define all(x) (x).begin(),(x).end()
using namespace std;
vector<string> v;
signed main(){
	int n;
	cin>>n;
	f(i,n){
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		v.push_back(s);
	}
	sort(v.begin(),v.end());
	int cnt=1,ans=0;
	f(i,n-1){
		f(j,10){
			if(v[i][j]!=v[i+1][j]){
				ans+=cnt*(cnt-1)/2;
				cnt=1;
				goto loop;
			}
		}
		cnt++;
		loop:;
	}
	ans+=cnt*(cnt-1)/2;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5748
X, Y, Z, K = [int(n) for n in input().strip().split(' ')]
A = sorted([int(s) for s in input().strip().split(' ')], reverse=True)
B = sorted([int(s) for s in input().strip().split(' ')], reverse=True)
C = sorted([int(s) for s in input().strip().split(' ')], reverse=True)

ABC = []
for i, a in enumerate(A):
    for j, b in enumerate(B):
        if (i + 1) * (j + 1) > K:
            break

        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break

            ABC.append(a + b + c)

ABC.sort(reverse=True)

for s in ABC[:K]:
    print(s)


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

#define INF 1.1e9
#define LINF 1.1e18
#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 pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

//-----------------------------------------------------------------------------

int H,W,K;
string A[900];
int sx,sy;
bool used[900][900];

bool ok(int x,int y) {
	return (x>=0&&x<W&&y>=1&&y<H&&A[y][x]=='.'&&!used[y][x]);
}

int calc(int y,int x) {
	return min(min(x,y),min(W-x-1,H-y-1));
}

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

	cin>>H>>W>>K;
	REP(i,H) {
		cin>>A[i];
		REP(j,W) if(A[i][j]=='S') sx=j,sy=i;
	}
	queue<P> Q;
	Q.push(P(sx,sy));
	REP(i,K+1) {
		int sz=Q.size();
		REP(j,sz) {
			P p=Q.front();Q.pop();
			if(used[p.se][p.fi]) continue;
			used[p.se][p.fi]=true;
			REP(d,4) {
				int nx=p.fi+dx[d],ny=p.se+dy[d];
				if(ok(nx,ny)) {
					Q.push(P(nx,ny));
				}
			}
		}
	}
	int ans=INF;
	REP(i,H) {
		REP(j,W) {
			if(used[i][j]) ans=min(ans,calc(i,j));
		}
 	}

	cout<<(ans/K)+!!(ans%K)+1<<endl;

	return 0;
}


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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<bool> prime(55555, true);
    for(long i=2; i<300; ++i){
        bool initial = true;
        for(long j=2; j<55555; ++j){
            if(prime[j] == true && j % i == 0){
                if(initial == true){
                    initial = false;
                }else{
                    prime[j] = false;
                }
            }
        }
    }

    int i = 2;
    int c = 0;
    while(c<N){
        if(prime[i] == true && i % 5 == 1){
            cout<<i<<" ";
            c++;
        }
        i++;
    }

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {
	int i, j, n, temp;
	int c = 0;
	int x = 0;
	vector<int> a(100005,0);

	cin >> n;

	for (i = 0;i < n;i++) {
		cin >> temp;
		if (temp < 100001) {
			a[temp]++;
		}
		else {
			x++;
		}
	}

	for (i = 0;i < 100001;i++) {
		if (a[i] < i) {
			x += a[i];
		}
		else {
			x += a[i] - i;
		}
	}

	cout << x << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cmath>

using namespace std;
int main (){
    int n,k;
    cin >> n >>k;
    int x[n];
    for (int i = 0; i < n; i++){
        cin >> x[i];
    }
    int l=0;
    for (int i = 0; i < n; i++){
        l+=min(x[i],k-x[i]);
    }
    cout << l*2 << "\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  vector<ll> p(7);
  p[0]=1;
  repo(i,7){
    p[i]=9*p[i-1];
  }
  vector<ll> q(8);
  q[0]=1;
  repo(i,8){
    q[i]=6*q[i-1];
  }

  vector<ll> ans(100005,INF);
  ans[0]=0;
  rep(i,100005){
    chmin(ans[i+1],ans[i]+1);
    repo(j,7){
      if(i+p[j]<100005) chmin(ans[i+p[j]],ans[i]+1);
    }
    repo(j,8){
      if(i+q[j]<100005) chmin(ans[i+q[j]],ans[i]+1);
    }  
  }

  cout << ans[n] << endl;
}

Measured memory_bytes: 1024
def main():
    k = int(input())
    a, b = map(int, input().split())
    flg = False
    for i in range(a, b+1):
        if i % k == 0:
            print('OK')
            flg = True
            break
    if not flg:
        print('NG')


if __name__ == "__main__":
    main()


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const int mod=1e9+7;
    int n;
    string s;
    cin>>n>>s;
    vector dp(n,vector(n,0));
    dp[0][0]=1;
    for(int i=1;i<n;i++){
        vector<int> sum(n+1);
        for(int j=1;j<=n;j++) sum[j]=(sum[j-1]+dp[i-1][j-1])%mod;
        for(int j=0;j<=i;j++){
            if(s[i-1]=='<') dp[i][j]=(sum.back()-sum[j]+mod)%mod;
            else dp[i][j]=sum[j];
        }
    }
    int ans=0;
    for(auto it:dp[n-1]) (ans+=it)%=mod;
    cout<<ans;
    return 0;
}



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

struct square{
	int ind;
	int x,y;
	square(int ind,int x,int y):ind(ind),x(x),y(y){}
};

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

int main(void){
int n;
int tn,td;
int i,j,k;
int ans=0;
vector<square> blocks;

while(true){
cin>>n;
if(n==0)return 0;
blocks=vector<square>(1,square(0,0,0));
for(i=1;i<n;i++){
	cin>>tn>>td;
	blocks.push_back(square(i,blocks[tn].x+dx[td],blocks[tn].y+dy[td]));
}
int maxx=0,minx=0,maxy=0,miny=0;
for(i=0;i<n;i++){
	maxx=max(maxx,blocks[i].x);
	minx=min(minx,blocks[i].x);
	maxy=max(maxy,blocks[i].y);
	miny=min(miny,blocks[i].y);
}

cout<<maxx-minx+1<<" "<<maxy-miny+1<<endl;
}
return 0;
}



Measured memory_bytes: 3092