akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <string>
using namespace std;
int main(){
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(u==s){
    a = a - 1;
  }else{
    b = b - 1;
  }
  cout << a << ' ';
  cout << b;
}

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

#define fi first
#define se second
#define pb push_back
#define mod(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,a,b) for(int i = a; i < b; i++)
#define forr(i,a,b) for(int i = a; i >= b; i--)
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const int maxn = 100+1;
const int maxv = 100000+1;
const int oo = 1000000000+10;
ll N,W,w[maxn],v[maxn];
ll dp[maxn][maxv];


int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	forn(i,0,maxn)forn(j,0,maxv)dp[i][j] = oo;
	cin >> N >> W;
	ll tot = 0;
	forn(i,0,N){
		cin >> w[i] >> v[i];
		tot += v[i];
	}
	dp[0][0] = 0;
	dp[0][v[0]] = w[0];
	forn(i,1,N){
		forn(j,0,tot+1){
			dp[i][j] = dp[i-1][j];
			if(j-v[i] >= 0){
				dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
			}
		}
	}
	forr(i,tot,0){
		if(dp[N-1][i] <= W){
			cout << i << '\n';
			return 0;
		}
	}
	return 0;
}
/*
__builtin_mul_overflow(x,y,&x)
-fsplit-stack
*/


Measured memory_bytes: 79232
#include <algorithm>
#include <cmath>
#include <ctime>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
#include <cstring>
#include <tuple>
#include <bitset>
#include <unordered_map>
using namespace std;
typedef long long ll;

void print(vector<int> v) {
    for (int i=0; i<(int)v.size(); ++i) {
        cout << (i == 0 ? "" : " ") << v[i];
    }
    cout << endl;
}

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

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

    int ans = 0;
    for (int i=0; i<N; ++i) {
        int mini = i;
        bool swapchk = false;
        for (int j=i+1; j<N; ++j) {
            if (A[mini] > A[j]) {
                mini = j;
                swapchk = true;
            }
        }
        if (swapchk) {
            swap(A[i], A[mini]);
            ans ++;
        }
    }

    print(A);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1216
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
//$N=trim(fgets(STDIN));
list($A,$B) = explode(" ",trim(fgets(STDIN)));
if (($A*$B)%2==0) {
  printf("Even\n");
}
else {
  printf("Odd\n");
}


Measured memory_bytes: 3828
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std;

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 nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
        ans %= IMOD;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans * modinv(i, IMOD);
        ans %= IMOD;
    }
    return ans;
}

int main(void)
{
    int x, y;
    cin >> x >> y;

    ll i = (2*x-y);
    ll j = (x-2*y);

    if(i % 3 != 0 || j % 3 != 0 || i < 0 || j > 0) { 
        cout << 0;
        return 0;
    } else {
        i /= 3;
        j /= -3;
    }
    ll n = i + j; 
    ll r = j; 
    
    cout << nCr(n, r) << endl;

    return 0;
}
/** atcoder **/


Measured memory_bytes: 384
N = int(input())
a = list(map(int,input().split()))

a = [i for i in a if i%2==0]
a3 = [i%3!=0 for i in a]
a5 = [i%5!=0 for i in a]
if sum([1*(a3[i] and a5[i]) for i in range(len(a))])==0:
  print('APPROVED')
else:
  print('DENIED')


Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	rep(i,ty-sy) std::cout << "U";
	rep(i,tx-sx) std::cout << "R";
	rep(i,ty-sy) std::cout << "D";
	rep(i,tx-sx) std::cout << "L";
	std::cout << "L";
	rep(i,ty-sy+1) std::cout << "U";
	rep(i,tx-sx+1) std::cout << "R";
	std::cout << "DR";
	rep(i,ty-sy+1) std::cout << "D";
	rep(i,tx-sx+1) std::cout << "L";
	std::cout << "U" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int N, M, X, Y;
  int tmp;

  int max;
  int min;

  int i;

  scanf("%d %d %d %d", &N, &M, &X, &Y);

  max = X;
  min = Y;

  for (i = 0; i < N; i++) {
    scanf("%d", &tmp);
    if (tmp > max) {
      max = tmp;
    }
  }

  for (i = 0; i < M; i++) {
    scanf("%d", &tmp);
    if (tmp < min) {
      min = tmp;
    }
  }

  if (max < min) {
    printf("No War\n");
  } else {
    printf("War\n");
  }
  return 0;
}


Measured memory_bytes: 128
#[allow(unused)]
use proconio::marker::*;
use proconio::{fastout, input};
#[allow(unused)]
use std::cmp::{max, min};
#[allow(unused)]
use std::collections::{HashMap, HashSet, VecDeque};

#[fastout]
fn main() {
    input! {
        n: i64,
    }
    let mut rec = vec![];
    factorization(n, &mut rec);

    let mut ans = 0;
    for r in rec {
        ans += help(r);
    }
    println!("{}", ans);
}

fn factorization(n: i64, rec: &mut Vec<i64>) {
    fn factor_sub(n: i64, m: i64) -> (i64, i64) {
        let mut c = 0;
        let mut x = n;
        while x % m == 0 {
            c += 1;
            x /= m;
        }
        (c, x)
    }

    let (c, n) = factor_sub(n, 2);
    if c > 0 {
        rec.push(c);
    }
    let mut x = 3;
    let mut m = n;
    while x * x <= m {
        let (c, n) = factor_sub(m, x);
        if c > 0 {
            rec.push(c);
        }
        m = n;
        x += 2;
    }
    if m > 1 {
        rec.push(1);
    }
}

fn help(n: i64) -> i64 {
    if n <= 2 {
        1
    } else if n <= 5 {
        2
    } else if n <= 9 {
        3
    } else if n <= 14 {
        4
    } else if n <= 20 {
        5
    } else if n <= 27 {
        6
    } else if n <= 35 {
        7
    } else if n <= 44 {
        8
    } else {
        9
    }
}


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

int main(){

    int A,B;


    cin >>A>>B;

    if(A<=5)cout <<0<<endl;
    else if(6<=A && A<=12)cout <<B/2<<endl;
    else cout <<B<<endl;

    return 0;
}

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

#define int long long

int n, x;
int a[3000];
int b[3000];

signed main()
{
  cin >> n >> x;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i];
  }

  int ans = 1e18;
  for (int i = 0; i < n; i++){
    int po = 0;
    for (int j = 0; j < n; j++){
      b[j] = min(b[j], a[(j + n - i) % n]);
      po += b[j];
    }

    ans = min(ans, po + i * x);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin>>N;
    for(int n=1;n<=N;n++){
        int ans=0;
        for(int i=1;i*i<n;i++){
            for(int j=i;i*i + j*j<n;j++){
                for(int k=j;i*i+ j*j+k*k<n;k++){
                    if(n==i*i+ j*j+k*k +i*j+j*k+k*i){
                        if(i==j||j==k||k==i){

                            if(i==j&&j==k){
                                ans+=1;



                            }else{
                                ans+=3;
                            }
                        }else{
                            ans+=6;
                        }
                        
                    }

                }
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll h, w, k;
vvll c;

void input() {
  cin >> h >> w >> k;
  c.resize(h);
  rep(i, h) { c[i].resize(w); }
  rep(i, h) {
    string s;
    cin >> s;
    rep(j, w) {
      if (s[j] == '.') {
        c[i][j] = 0;
      } else {
        c[i][j] = 1;
      }
    }
  }
}

void solve() {
  ll ans = 0;
  vll tate(h), yoko(w);
  rep(i, pow(2, h)) {
    ll ii = i;
    rep(kk, h) {
      ll temp = (ll)pow(2, h - kk - 1);
      if (ii >= temp) {
        ii -= temp;
        tate[kk] = 1;
      } else {
        tate[kk] = 0;
      }
    }
    rep(j, pow(2, w)) {
      ll jj = j;
      rep(kk, w) {
        ll temp = (ll)pow(2, w - kk - 1);
        if (jj >= temp) {
          jj -= temp;
          yoko[kk] = 1;
        } else {
          yoko[kk] = 0;
        }
      }

      /*
      cout << "i:" << i << " j:" << j << endl;
      cout << "tate: ";
      rep(a, h) { cout << tate[a] << " "; }
      cout << endl;
      cout << "yoko: ";
      rep(b, w) { cout << yoko[b] << " "; }
      cout << endl;
      */
      ll black = 0;
      rep(a, h) {
        rep(b, w) {
          if (tate[a] == 0 && yoko[b] == 0 && c[a][b] == 1) { black++; }
        }
      }
      if (black == k) {
        ans++;
        // cout << "i:" << i << " j:" << j << endl;
      }
    }
  }
  cout << ans << endl;
  /*
  rep(i,h){
    rep(j,w){
      cout << "c[" << i << "]" << "[" << j << "] = " << c[i][j] << endl; 
    }
  }
  */
}

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


Measured memory_bytes: 4104
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

vector<int> v[222222];
void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) {
    R a[i];
    v[a[i]].pb(i);
  }
  ll dp[n+1];
  mem(dp);
  dp[0]=1;
  rep(i,n) {
    dp[i+1]+=dp[i];
    dp[i+1]%=MAX;
    ll k=lower_bound(all(v[a[i]]),i)-v[a[i]].begin();
    k++;
    if(k!=v[a[i]].size()&&v[a[i]][k-1]+1<v[a[i]][k]) {
      dp[v[a[i]][k]]+=dp[i];
      dp[v[a[i]][k]]%=MAX;
    }
  }
  pr(dp[n]);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 14848
N, K = gets.split.map(&:to_i)

array = Hash.new(0)

N.times do
	a, b = gets.split
	array[a] += b.to_i
end

bb = 0
array.to_a.sort {|(a1, b1), (a2, b2)| a1.to_i <=> a2.to_i}.each do |a, b|
	bb += b
	
	if K <= bb
		puts a
		break
	end
end

Measured memory_bytes: 13064
N, T = map(int, input().split())
c_t = [list(map(int, input().split())) for _ in range(N)]
cost = 2000000
TLE_flg = True
for i in range(N):
    if c_t[i][1] <= T:
        cost = min(cost, c_t[i][0])
        TLE_flg = False
print('TLE' if TLE_flg else cost)


Measured memory_bytes: 2940
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = input().strip()
  n = len(s)
  def is_palindrome(s):
    n = len(s)
    for i in range(len(s)):
      if s[i] != s[n-(i+1)]:
        return False
    return True
  
  if is_palindrome(s) and is_palindrome(s[:(n-1)//2]) and is_palindrome(s[(n+3)//2-1:]):
    print('Yes')
  else:
    print('No')

if __name__=='__main__':
  main()



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int n;
string str;

bool parser(int ch)
{
	bool a, b;
	switch (str[n]) {
	case 'a':
	case 'b':
	case 'c':
	case 'd':
	case 'e':
	case 'f':
	case 'g':
	case 'h':
	case 'i':
	case 'j':
	case 'k':
		return (ch >> (str[n++] - 'a')) & 1;
	case '(':
		n++;
		a = parser(ch);
		if (str[n] == '+') {
			n++;
			b = parser(ch);
			n++;
			return a||b;
		}
		else if(str[n] == '*') {
			n++;
			b = parser(ch);
			n++;
			return a&&b;
		}
		else {
			n++;
			n++;
			b = parser(ch);
			n++;
			if (a == true){
				if (b == true)
					return true;
				else
					return false;
			}
			else
				return true;
		}
		break;
	case '-':
		n++;
		return !parser(ch);
		break;
	case 'T':
		n++;
		return true;
	case 'F':
		n++;
		return false;
	default :
		exit(EXIT_FAILURE);
	}
}

int main()
{
	while (cin >> str, str != "#") {
		bool res = true;
		for (int i = 0; i < 0x800; i++) {
			n = 0;
			bool p1 = parser(i);
			n++;
			if (p1 != parser(i)) {
				res = false;
				break;
			}
		}
		if (res)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<int> get_prime(int n){
    if(n <= 1) return vector<int>();
    vector<bool> is_prime(n+1, true);
    vector<int> prime;
    is_prime[0] = is_prime[1] = 0;
    for (int i = 2; i <= n; ++i) {
        if(is_prime[i]) prime.emplace_back(i);
        for (auto &&j : prime){
            if(i*j > n) break;
            is_prime[i*j] = false;
            if(i % j == 0) break;
        }
    }
    return prime;
}

int main() {
    auto v = get_prime(120000);
    int n;
    while(cin >> n, n){
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            ans += v[i];
        }
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 3272
#include <stdio.h>
const int N=1e3+10;
int main(){
    int a,b,n,l,r;
    bool in[N];
    for(int i=0;i<N;i++)in[i]=false;
    scanf("%d%d%d",&a,&b,&n);
    while(n--){
        scanf("%d%d",&l,&r);
        for(int i=l;i<r;i++)in[i]=true;
    }
    for(int i=a;i<b;i++)if(in[i]){
        printf("1\n");
        return 0;
    }
    printf("0\n");
}


Measured memory_bytes: 2664
# -*- coding utf-8 -*-

N, K = map(int, input().split())
S = input()

counts = [0] if S[0] == '0' else []
s = '1' if S[0] == '1' else '0'
c = 0
for i in range(N):
    if S[i] != s:
        counts.append(c)
        c = 0
        if s == '1':
            s = '0'
        else:
            s = '1'
    c += 1
counts.append(c)

ans = 0
cumsum = [0] * (len(counts) + 1)
for i in range(len(counts)):
    cumsum[i + 1] = cumsum[i] + counts[i]
for i in range(len(counts)):
    if i % 2 == 1:
        continue
    # ans = max(ans, sum(counts[i: i + 2 * K + 1]))
    r = min(i + 2 * K + 1, len(counts))
    l = i
    if r == l:
        ans = max(ans, counts[i])
    else:
        ans = max(ans, cumsum[r] - cumsum[l])
    # ans = max(ans, cumsum[r] - cumsum[l])
    # print(l, r, cumsum[r] - cumsum[l])
print(ans)



Measured memory_bytes: 7884
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
import math
def readInts():
  return list(map(int,input().split()))
def main():
    a,b,h,m = readInts()
    h = h-12 if h >=12 else h

    h_ = 30 * h + 30 * m / 60
    m_ = 360 * m / 60

    kakudo = min(abs(m_-h_),360-abs(m_-h_))
    #print(kakudo)
    c = pow(a**2 + b**2 - 2*a*b*math.cos(math.radians(kakudo)),.5)
    print(c)
if __name__ == '__main__':
  main()


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

int main() {
    string S;
    cin >> S;

    int num_0 = 0, num_1 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0')
            num_0++;
        else
            num_1++;
    }
    cout << min(num_0, num_1) * 2 << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fr first
#define sc second
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
int n,i;
ll h[nmax],a,b,l,r,mid,mx;
int check(ll nr)
{
	int i;
	ll cnt=0;
	for(i=1;i<=n;i++)if(h[i]-nr*b>0)cnt+=(h[i]-nr*b)/(a-b)+((h[i]-nr*b)%(a-b)!=0);
	return cnt<=nr;
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	//freopen("sol.in","r",stdin);
	cin>>n>>a>>b;
	for(i=1;i<=n;i++)cin>>h[i],mx=max(mx,h[i]);
	r=mx/b+(mx%b!=0);
	while(l<=r)
	{
		mid=(l+r)/2;
		if(check(mid))r=mid-1;
		else l=mid+1;
	}
	cout<<r+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{

  char str[4];
  int i;
  int flag=0;
  for(i=0;i<4;i++){
    scanf("%s", &str[i]);
    if(i>=1){
      if(str[i-1]==str[i])
      flag = 1;
  }
}

  if(flag == 1)
  printf("Bad\n");
  else printf("Good\n");

  return 0;

}


Measured memory_bytes: 128
#pragma GCC optimiz(O2)

#include <bits/stdc++.h>

#define rg register
using namespace std;
typedef long long ll;

template<typename T>
inline bool read(T &n) {
    T ans = 0, flag = 1;
    char ch;
    while ((ch = getchar()) < '0' || ch > '9') if (ch == '-') flag = -1; else if (ch == EOF) return false;
    ans = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9') ans = ans * 10 + ch - '0';
    n = ans * flag;
    return true;
}

inline ll read() {
    ll ans = 0, flag = 1;
    char ch;
    while ((ch = getchar()) < '0' || ch > '9') if (ch == '-') flag = -1;
    ans = ch - '0';
    while ((ch = getchar()) >= '0' && ch <= '9') ans = ans * 10 + ch - '0';
    return ans * flag;
};
const int maxn = 100005;
struct NODE {
    ll val, ord;
    bool operator<(NODE b) const {
        return val < b.val;
    }
} node[maxn];
struct EDGE{
    int nex,t;
}edge[maxn<<1];

int ecnt,head[maxn],siz[maxn],fa[maxn];
unordered_map<ll,int> unM;
inline void addedge(int u,int v){
    edge[++ecnt].nex=head[u];head[u]=ecnt;edge[ecnt].t=v;
    edge[++ecnt].nex=head[v];head[v]=ecnt;edge[ecnt].t=u;
}
ll dfs(int rt,int fa,int dis){
    ll ans=dis;
    for(rg int i=head[rt];i;i=edge[i].nex){
        int y=edge[i].t;
        if(y==fa) continue;
        ans+=dfs(y,rt,dis+1);
    }
    return ans;
}
int main() {
    int n;
    read(n);priority_queue<NODE> pq;
    for (rg int i = 1; i <= n; ++i) {
        siz[i] = 1;read(node[i].val);
        node[i].ord = i;
        pq.push(node[i]);
        unM[node[i].val]=i;
    }
    for(rg int i=n;i>=2;i--){
        NODE now=pq.top();pq.pop();
        if(unM.find(now.val+2*siz[now.ord]-n)==unM.end()){
            puts("-1");return 0;
        }
        fa[now.ord]=unM[now.val+2*siz[now.ord]-n];
        siz[fa[now.ord]]+=siz[now.ord];
        addedge(now.ord,fa[now.ord]);
    }
    if(siz[pq.top().ord]!=n||dfs(pq.top().ord,0,0)!=pq.top().val) puts("-1");
    else for(rg int i=1;i<=n;i++){
        if(fa[i]) cout<<i<<' '<<fa[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 13716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		System.out.println(a * b + " " + 2 * (a + b));
		sc.close();
	}
}

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

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

   int n,m;
   cin >> n >> m;

   string s[n];
   
   rep(i,n) cin >> s[i];
   
   sort(s, s+n);

   rep(i,n) cout << s[i];

   cout << endl;

   return 0;
}

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

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

	vector<int> A;
	rep(i, N) {
		int x;
		cin >> x;
		x--;
		A.push_back(x);
	}

	int next = 0, cnt = 0;
	bool flag = true;
	rep(i, N) {
		next = A[next];
		cnt++;
		if (next == 1) {
			cout << cnt << endl;
			flag = false;
			break;
		}
	}
	if (flag) cout << -1 << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

int f(int n){int s=0;while(n!=0){s+=n%10;n/=10;}return s;}

signed main() {
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  int ct=1;
  Vi a(n);
  int ans = 0;
  rep(i,0,n) cin >> a[i];
  rep(i,0,n-1){
    if(a[i]==a[i+1]) {
      ct++;
      continue;
    }
    else{
      ans += ct/2;
      ct=1;
    }
  }
  ans += ct/2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    vvl v(n, vl(26));
    rep(i, n) {
        string s;
        cin >> s;
        rep(j, s.size()) {
            v[i][s[j] - 'a']++;
        }
    }

    vl w(26, 100);
    rep(i, 26) {
        rep(j, n) {
            chmin(w[i], v[j][i]);
        }
    }

    for(char c = 'a'; c <= 'z'; c++) {
        rep(j, w[c - 'a']) {
            cout << c;
        }
    }

    cout << endl;

    /*cout << "\n";
    rep(i, 4) {
        cout << w[i] << " ";
    }*/

    /*cout << "\n";
    rep(i, n) {
        rep(j, 4) {
            cout << v[i][j] << " ";
        }
        cout << "\n";
    }*/

    re0;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        try (
                Scanner in = new Scanner(System.in);
                PrintWriter out = new PrintWriter(System.out))
        {
            final int N = in.nextInt();
            final int M = in.nextInt();

            final int[] P = new int[M];
            final int[] Y = new int[M];
            Map<Integer, Integer> yearIdxMap = new TreeMap<>();
            for (int i = 0; i < M; ++i) {
                P[i] = in.nextInt();
                Y[i] = in.nextInt();
                yearIdxMap.put(Y[i], i);
            }

            final String[] cityId = new String[M];
            final int[] seq = new int[N];
            for (int year : yearIdxMap.keySet()) {
                int i = yearIdxMap.get(year);
                cityId[i] = String.format("%06d%06d", P[i], ++seq[P[i] - 1]);
            }

            for (int i = 0; i < M; ++i) {
                out.println(cityId[i]);
            }
        }
    }
}


Measured memory_bytes: 150588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;



int main() {
    int n;double m; cin >> n >> m;
    int total = 0;
    vector<int> v;
    for(int i = 0;i < n;i++){
        int a;cin >> a;
        v.push_back(a);
        total += a;
    }
    
    int cnt = 0;
    double aa = total * 1/(4*m);
    for(int i = 0;i < n;i++){
        if(v[i] >= aa) cnt++;
    }
    if(cnt >= m){
        cout << "Yes";
    }else{
        cout << "No";
    }
}


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

int main()
{
    int n,m;
    cin>>n>>m;
    vector<pair<int,int > > a;
    int x,y;
    for (int i = 0; i < n; ++i) {
        cin>>x>>y;
        a.push_back(make_pair(x,y));
    }
    sort(a.begin(),a.end());
    long long int s=0;
    int count=0;

    long long int z=1;
    auto i=a.begin();
    while(count<m && i!=a.end() )
    {
     if(m-count > i->second)
        {   z=1;
        z=i->first;
        z*=i->second;
            s += z;
            count += i->second;
        }

     else{
         z=1;
         z=i->first;
         z*=(m-count);
            s+=z;
            count += (m-count);
        }
        i++;
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
#define index Index
using namespace std;
const int inf=1e9+10;
const ll llinf=1e17+10;
const int maxn=2e5+10;
const int maxm=1e6+10;
const int maxk=100;
const int mod=1e9+7;
int A,B;
int num[maxn];
char str[maxk][maxk];
char s1[10][10]={"###.","#.#.","###.","...."};//1#1.
char s2[10][10]={"....","..#.","....","...."};//1#
char s3[10][10]={"...#",".#.#","...#","####"};//1#1.
char s4[10][10]={"####","##.#","####","####"};//1.
int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    while (~scanf("%d %d",&A,&B))
    {
        if(B>=A-1)
        {
            fill(str[0],str[0]+maxk*maxk,'.');
            A--;
            for(int i=0;i<maxk;i+=4)
                for(int j=0;j<maxk;j+=4)
                {
                    if(A>=1)
                    {
                        for(int k1=0;k1<4;k1++)
                        for(int k2=0;k2<4;k2++)
                        str[i+k1][j+k2]=s1[k1][k2];
                        A--;
                        B--;
                    }
                    else if(B>=1)
                    {
                        for(int k1=0;k1<4;k1++)
                        for(int k2=0;k2<4;k2++)
                        str[i+k1][j+k2]=s2[k1][k2];
                        B--;
                    }
                }
        }
        else if(A>=B-1)
        {
            fill(str[0],str[0]+maxk*maxk,'#');
            B--;
            for(int i=0;i<maxk;i+=4)
                for(int j=0;j<maxk;j+=4)
                {
                    if(B>=1)
                    {
                        for(int k1=0;k1<4;k1++)
                        for(int k2=0;k2<4;k2++)
                        str[i+k1][j+k2]=s3[k1][k2];
                        A--;
                        B--;
                    }
                    else if(A>=1)
                    {
                        for(int k1=0;k1<4;k1++)
                        for(int k2=0;k2<4;k2++)
                        str[i+k1][j+k2]=s4[k1][k2];
                        A--;
                    }
                }
        }
        printf("%d %d\n",maxk,maxk);
        for(int i=0;i<maxk;i++)
            for(int j=0;j<maxk;j++)
            printf("%c%s",str[i][j],j==maxk-1?"\n":"");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
 
/*                        [Template]                        */
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define let auto
#define of :
#define all(y) y.begin(), y.end()
#define present( x, y ) x.find( y ) != x.end()
#define _matrix(T) vector<vector<T>>
template<class T>
auto matrix( int r, int c, T v ){
	return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
const int mod = (int)1e9 + 7 ;
const int inf = (int)1e9 ;
/************************************************************/

 
signed main(){
	int H, W, M ; cin >> H >> W >> M ;
	vector<pair<int,int>> targets(M) ;
	vector<int> row( H + 1, 0 ), col( W + 1, 0 ) ;
	for( let &[ x, y ] of targets ) {
		cin >> x >> y ;
		row[x]++ ;
		col[y]++ ;	
	}
	int mxr = 0, mxc = 0 ;
	for( int x of row ) mxr = max( mxr, x ) ;
	for( int x of col ) mxc = max( mxc, x ) ;
	int cntr = 0, cntc = 0 ;
	for( int x of row ){
		if( x == mxr ) cntr++ ;
	}
	for( int x of col ){
		if( x == mxc ) cntc++ ;
	}
	int cntb = 0 ;
	for( let [x, y] of targets ) {
		if( row[x] == mxr && col[y] == mxc ) {
			cntb++ ;
		}
	}
	int totalIntersections = cntr * cntc ;
	if( totalIntersections > cntb ) cout << mxr + mxc ;
	else cout << mxr + mxc - 1 ;
	return 0 ;
}
  


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  if(n%2 == 1){
    cout << "No" << endl;
    return 0;
  }
  for(int i=0; i<n/2; i++){
    if(s.at(i) != s.at(i+n/2)){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
N=int(input())
A=sorted(int(input())for _ in [0]*N)
n=N//2
print(A[n]+2*sum(A[n+1:])-2*sum(A[:n-1])-A[n-1]if N%2==0 else max(A[n]+A[n+1]+2*sum(A[n+2:])-2*sum(A[:n]),2*sum(A[n+1:])-2*sum(A[:n-1])-A[n-1]-A[n]))

Measured memory_bytes: 7852
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int n,m;
	cin >> n >> m;
	ll x[Nmax],y[Nmax],ans1=0,ans2=0;
	REP(i,n) cin >> x[i];
	REP(i,m) cin >> y[i];
	REP(i,n) ans1 = (ans1+((i)*x[i]-(n-i-1)*x[i]))%MOD;
	REP(i,m) ans2 = (ans2+((i)*y[i]-(m-i-1)*y[i]))%MOD;
	cout << fixed << (ans1*ans2)%MOD << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#include <cassert>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

int Nctoi(char c) {
    if ('0' <= c && c <= '9') {
        return c - '0';
    }
    else {
        return 0;
    }
}

int main() {
    string s; cin >> s;
    int M = s.size();
    int K; cin >> K;
    
    //前処理
    vector<vector<vector<ll>>> dp(M, vector<vector<ll>>(10, vector<ll>(K+1)));
    for (int i = 0; i < 10; i++) {
        if (i == 0) {
            dp[0][i][0] = 1;
        }
        else {
            dp[0][i][1] = 1;
        }
    }

    for (int d = 1; d < M; d++) {
        //d桁目を考える際はd-1桁目を見る
        for (int k = 0; k <= K; k++) {
            //impurityの数
            for (int top = 0; top < 10; top++) {
                //最上位桁の値をtopとする
                for (int ptop = 0; ptop < 10; ptop++) {
                    if (top == 0) {
                        dp[d][top][k] += dp[d - 1][ptop][k];
                    }
                    else {
                        if (k > 0) {
                            dp[d][top][k] += dp[d - 1][ptop][k - 1];
                        }
                    }
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < M; i++) {
        int cur = Nctoi(s[i]);
        if (i == 0 && M != 1) {
            for (int top = 0; top < cur; top++) ans += dp[M-i-1][top][K];
        }
        else if (i == M - 1 || M == 1) {
            for (int top = 0; top <= cur; top++) ans += dp[M-i-1][top][K];
        }
        else {
            for (int top = 0; top < cur; top++) ans += dp[M-i-1][top][K];
        }
        if (cur > 0) K--;
        if (K < 0) break;
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void)
{
  string input_S;
  string input_T;
  
  cin >> input_S;
  cin >> input_T;
  
  if(input_S == input_T.substr(0,input_S.size()) )
  {
    if( (input_T.size() - input_S.size()) == 1)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main() {
    int MOD=pow(10,9)+7;
    string s;
    cin>>s;
    int l=s.size();
    long dp[l+1][13];
    int table10[7];
    table10[1]=1;
    rep(i,5){
        table10[i+2]=(10*table10[i+1])%13;
    }
    table10[0]=4;
  
    if (s.at(l-1)=='?'){
        rep(i,10){
            dp[1][i]=1;
        }
        rep(i,3){
          dp[1][i+10]=0;
        }
    }
    else{
        int num=s.at(l-1)-'0';
        rep(i,13){
            dp[1][i]=0;
        }
        dp[1][num]=1;       
    }
    for (int i=2;i<l+1;i++){
        if (s.at(l-i)=='?'){
            for (int j=0;j<13;j++){
                dp[i][j]=0;
                for (int k=0;k<10;k++){
                    int mod1=(table10[i%6]*k)%13;
                    dp[i][j]+=dp[i-1][(13+j-mod1)%13];
                    dp[i][j]%=MOD;
                }
            }

        }
        else{
            int num=s.at(l-i)-'0';
            int mod1=(table10[i%6]*num)%13;
            for (int j=0;j<13;j++){
                 dp[i][j]=dp[i-1][(13+j-mod1)%13];
                }
            
        }
    }
    cout<<dp[l][5]<<endl;

    return 0;
}


Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    char b;
    cin >> b;
    
    if(b == 'A')cout << 'T';
    else if(b == 'T')cout << 'A';
    else if(b == 'C')cout << 'G';
    else cout << 'C';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){long long int n,k,s,i,c;
cin>>n>>k>>s;
long long int a[n];
c=1000000000;
if(s==c){c=1;}
for(i=0;i<n;i++){a[i]=c;}
for(i=0;i<k;i++){a[i]=s;}
for(i=0;i<n;i++){cout<<a[i]<<" ";}
    return 0;}

Measured memory_bytes: 2048
#include <cstdio>
#include <utility>
#include <algorithm>

int n;
int X[100000];
int L[100000];
std::pair<int, int> A[100000];
int dp[100000];

int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++) scanf("%d%d", X+i, L+i);

  for(int i = 0; i < n; i++){
    A[i].first = i;
    A[i].second = X[i] + L[i];
  }

  std::sort(A, A+n, [](auto x, auto y){ return x.second < y.second; });

  dp[0] = 1;
  for(int i = 1; i < n; i++){
    int lb = -1;
    int ub = i;
    while(ub - lb > 1){
      int mid = (lb + ub) / 2;
      if(A[mid].second <= X[A[i].first] - L[A[i].first]) lb = mid;
      else ub = mid;
    }
    if(lb<0) dp[i] = dp[i-1];
    else     dp[i] = std::max(dp[i-1], dp[lb] + 1);
  }
  printf("%d\n", dp[n-1]);

  return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    string a, b;
    cin >> a >> b;
    if(a.size() < b.size()){
        cout << "LESS" << endl;
        return 0;
    }else if(a.size() > b.size()){
        cout << "GREATER" << endl;
        return 0;
    }

    for(int i = 0; i < a.size(); ++i){
        if(a.at(i) < b.at(i)){
            cout << "LESS" << endl;
            return 0;
        }else if(a.at(i) > b.at(i)){
            cout << "GREATER" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
int main()
{
    double a,b,c,d,e,f,y,x;
    while(std::cin >> a >> b >> c >> d >> e >> f) 
    {
        x = (double)((e*c-b*f) / (a*e-b*d));
        y = (double)((-(d*c)+a*f) / (a*e-b*d)); 
        if(x==0)x=0;
        if(y==0)y=0;
        printf("%.3lf %.3lf\n",x,y);
    }  
    return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    cout << s.substr(0, 4) << " " << s.substr(4) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
         
        int main(){
            int n;
            bool ans=0;
            scanf("%d",&n);
            while(n>0){
                if(n%10==9) ans = true;
                n = n / 10;
            }
            if(ans) printf("Yes\n");
            else printf("No\n");
        }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,m;
    cin>>n>>m;
    vector<int> v(n);
    map<int,int> mp;
    mp[0] = -1;
    mp[1] = -1;
    mp[2] = -1;
    int tmpa, tmpb;
    REP(i,m){
        cin >> tmpa >> tmpb;
        if(mp[tmpa-1]==-1||mp[tmpa-1]==tmpb){
            mp[tmpa-1] = tmpb;
        }else{
            cout << -1 << endl;
            return 0;
        }
    }
    if((n==2||n==3)&&mp[0]==0){
            cout << -1 << endl;
            return 0;
        
    }
    REP(i,n){
        if(mp[i]==-1){
            if(n!=1&&i==0){
                mp[i] = 1;
            }else{
                mp[i] = 0;
            }
        }
        cout << mp[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
<?php
fscanf(STDIN, "%d %d", $lake_length, $house_num);
$houses=explode(' ',trim(fgets(STDIN)));
$last = $house_num-1;
$distance = $lake_length;

for($i=0;$i<$house_num;$i++) {
  if($i==0) {
    $r = $houses[$last] - $houses[0];
  } else {
    $r = $lake_length - ($houses[$i]-$houses[$i-1]);
  }

  if($i == $last) {
    $l = $houses[$last] - $houses[0];
  } else {
    $l = $lake_length - ($houses[$i+1] - $houses[$i]);
  }
  $length    = ($r>=$l)?$l:$r;
  if($length < $distance) {
    $distance = $length;
  }
}
echo $distance;

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

int main() {
  int N;
  cin >> N;
  bool flag = false;
  for (int i = 1; i <= 9; i++) {
    if (N % i == 0) {
      if ((1 <= N / i)&&(N / i <= 9)) {
        flag = true;
      }
    }
  }
  
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a; cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto it = mp.begin();it!=mp.end();it++) {
        int f = it->first;
        int s = it->second;
        if(f > s) ans += s;
        else ans += s - f; 
    }
    cout << ans;
}


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

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

  string s;
  cin >> s;

  string a = "abcdefghijklmnopqrstuvwxyz";

  vector<bool> isPresent(a.size(), false);
  for (char c : s) {
    if (a.find(c) != a.npos) {
      int i = a.find(c);

      isPresent.at(i) = true;
    }
  }

  string ans = "None";
  for (int i = 0; i < a.size(); i++) {
    if (!isPresent.at(i)) {
      ans = a.at(i);
      break;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#define REP(i,a,n) for(int i = 0;i < n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
void func(int num);
int in(){int n;scanf("%d",&n); return n;};
 
int flag[10] = {0};
int num2,ans;
int main(void){
 while(1){
  ans = 0;
  int num = in(); num2 = in();
  if(num == 0 && num2 == 0) break;
  func(num);
  printf("%d\n",ans);
 }
 return 0;
}
 
void func(int num){
 if(num == 0){
  int n = 0;
  rep(i,10){if(flag[i]) n+= i;}
  if(n == num2) ans++;
  return;
 }
 rep(i,10){
  if(flag[i] == 1) return;
  flag[i] = 1;
  func(num-1);
  flag[i] = 0;
 }
 return;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
using namespace std;
long long N;
long long mod=998244353;
long long power(long long a,long long b)
{
	return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;
}
int main()
{
	cin>>N;
	long long ans=0;
	for(int k=1;k<=N;k++)
	{
		int xx;scanf("%d",&xx);
		long long x=xx;
		(ans+=power(2,N-k)*x%mod*power(1+x,k-1)%mod)%=mod;
	}
	cout<<ans<<endl;
}



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

const int kN = 100'000 + 5;
vector<int> s[kN], d[kN];
int fw[kN], ans[kN];

void Modify(int p) {
    for (int i = p; i < kN; i += i & -i) fw[i]++;
}

int Query(int p) {
    int res = 0;
    for (int i = p; i > 0; i -= i & -i) res += fw[i];
    return res;
}

int main() {
    int n, m; scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) {
        int l, r; scanf("%d%d", &l, &r);
        s[r].push_back(l);
    }
    for (int i = 1; i <= m; ++i) {
        for (int j = i; j <= m; j += i) d[j].push_back(i);
    }
    int sum = 0;
    for (int i = 1; i <= m; ++i) {
        for (int v : s[i - 1]) {
            Modify(v);
            sum += 1;
        }
        for (int v : d[i]) ans[v] += sum - Query(i - v);
    }
    for (int v : s[m]) {
        Modify(v);
        sum += 1;
    }
    for (int i = 1; i <= m; ++i) ans[i] += sum - Query(m / i * i);
    for (int i = 1; i <= m; ++i) printf("%d\n", n - ans[i]);
    return 0;
}


Measured memory_bytes: 17536
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n, k;
  cin >> n >> k;
  vector<ll> s(n + 1);
  for (int i = 0; i < n; ++i) {
    ll a;
    cin >> a;
    s[i + 1] = s[i] + a;
  }

  vector<ll> x;
  for (int l = 1; l <= n; ++l) for (int r = l; r <= n; ++r) {
    x.push_back(s[r] - s[l - 1]);
  }

  ll result = 0;
  for (ll b = 40; b >= 0; --b) {
    ll cur = 1LL << b;
    vector<ll> y;
    for (ll t : x) if (t & cur) y.push_back(t);
    if (y.size() >= k) {
      result |= cur;
      x = y;
    }
  }

  cout << result << endl;

  return 0;
}


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

#ifdef ARTEM
	#define deb(x) x
#else
	#define deb(x)
	const int LIMIT = 2 * int(1e5) + 123;
#endif

void solve();

int main() {
	solve();
}

/* ================ actual code starts here ================ */

void solve() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for(int i = 0; i < n; i++)
		cin >> s[ i ];
	sort(s.begin(), s.end());

	for(string i : s)
		cout << i;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    s.erase(unique(s.begin(), s.end()), s.end());
    string ans = "Yes";
    if(s.size() == 1) ans = "No";
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main
{
	public static void main (String[] arg)throws IOException
	{
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String line,up;
		line=input.readLine();
		up=line.toUpperCase();
		System.out.println(up);
	}
}	
		

Measured memory_bytes: 16832