akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
 
 
 
public class Main {
static int n;
static int S[]=new int[500001];
static int count=0;
 
  public static void merge(int left,int mid,int right){
      int i,j;
      mid=(left+right)/2;
 
      
      ;
      int infty=Integer.MAX_VALUE;
 
      int R[]=new int[mid-left+2];
      int L[]=new int[right-mid+2];
 
      for(i=0;i<mid-left+2;i++){
          L[i]=S[left+i];
      }
      for(i=0;i<right-mid;i++){
          R[i]=S[mid+i];
      }
 
      L[mid-left]=infty;
      R[right-mid]=infty;
    i=0;
    j=0;
 
    for(int k=left;k<right;k++){
        count++;
        if(L[i]<=R[j]){
            S[k]=L[i];
            i++;
        }
        else{
            S[k]=R[j];
            j++;
        }
    }
  }
   
  public static void mergesort(int left,int right){
      if(left+1<right){
          int mid=(left+right)/2;
           
          mergesort(left,mid);
          mergesort(mid,right);
          merge(left,mid,right);
          
      }
  }
   
   
    public static void main(String[] args) {
 
         Scanner sc=new Scanner(System.in);
         n=Integer.parseInt(sc.next());
 
          for(int i=0;i<n;i++){
              S[i]=Integer.parseInt(sc.next());
          }
         
          
          mergesort(0,n);
          
 
              for(int i=0;i<n;i++){
                    String s = String.valueOf(S[i]);
					s += (i==n-1) ? '\n' : ' ';
					System.out.print(s);
/*					
                    if(i==n-1){
					  System.out.println("");
                    } else{
                      System.out.print(" ");
              		}
*/
              }
              System.out.println(count);
  }
}

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

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

    int N, D;
    int unit;

    cin >> N >> D;

    unit = 2 * D + 1;

    rep(i, N)
    {
        if (unit >= N)
        {
            cout << i+1;
            break;
        }
        unit += 2 * D + 1;
    }

    return 0;
}

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

using namespace std;

int main() {
    string val;
    cin >> val;
    bool n, s, e, w, f;
    n = s = e = w = f = false;
    for(int i = 0; i < val.size(); i++) {
        if(val[i] == 'N') n = true;
        else if(val[i] == 'S') s = true;
        else if(val[i] == 'E') e = true;
        else if(val[i] == 'W') w = true;
    }

    if(n && s && e && w) f = true;
    if(n && s && (!e && !w)) f = true;
    if(!n && !s && e && w) f = true;

    if(f) cout << "Yes\n";
    else cout << "No\n";
}


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>;

ll dp[(ll)1e5+1][13];
const ll MOD = (ll)1e9 + 7;

void solve() {
    string s;
    cin >> s;

    dp[0][0] = 1;
    int n = s.size();
    int mul = 1;

    int cnt = 0;
    for (int d = n-1; d >= 0; d--) {
        char c = s[d];
        if (c == '?') {
            rep(i, 10) {
                rep(j, 13) {
                    dp[cnt+1][(i * mul + j) % 13] += dp[cnt][j];
                    dp[cnt+1][(i * mul + j) % 13] %= MOD;
                }
            }
        } else {
            int i = c - '0';
            rep(j, 13) {
                dp[cnt+1][(i * mul + j) % 13] += dp[cnt][j];
                dp[cnt+1][(i * mul + j) % 13] %= MOD;
            }
        }

        mul *= 10;
        mul %= 13;
        cnt++;
    }

    cout << dp[n][5] << endl;
}

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


Measured memory_bytes: 10624
main = do
   [n,y] <- (map read) . words <$> getLine
   let ans = take 1 [[a,b,n-(a+b)] |
                        a<-[0..n],
                        b<-[0..n],
                        let c=n-(a+b) in c >=0 && a*10000+b*5000+c*1000==y]
   putStrLn . unwords . map show $ if (length ans) == 0
                                then replicate 3 (-1)
                                else ans !! 0

Measured memory_bytes: 1148
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

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

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

int main (){
    int N; cin >> N;
    ll M; cin >> M;
    vector<ll> A(N), B(N);
    REP(i,N) {
        cin >> A[i];
        B[i] = A[i] / 2;
    }
    ll LCMB = B[0];
    bool flg = true;
    FOR(i,1,N) {
        LCMB = lcm(LCMB, B[i]);
        if (LCMB > M) {
            flg = false;
        }
        if (!flg) break;
    }
    if(!flg) cout << 0 << endl;
    else {
        bool flg2 = true;
        REP(i,N) {
            if ((LCMB/B[i])%2==0) flg2 = false;
            if(!flg2) break;
        }
        if (flg2) {
            cout << ((M/LCMB)+1)/2 << endl;
        }
        else cout << 0 << endl;
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define pb push_back
#define ff first 
#define ss second  
typedef pair<int,int> pp;
bool com(pp x,pp y){
    return x.ff<y.ff;
} 
int N=1e5+9;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	ll a[n],sum=0,ans=0;
	for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
	for(int i=0;i<n;i++){
	    sum-=a[i];
	    ans+=((sum%mod)*(a[i]%mod))%mod;
	    ans%=mod;
	}
	cout<<ans;
	return 0; 
	
}


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

int main(){
	char a[20],torikae;
	int len,i;

	scanf("%s",a);
	
	len=strlen(a);

	for(i=0; i<(len/2); i++){
		torikae=a[i];
		a[i]=a[len-i-1];
		a[len-i-1]=torikae;

	}

	printf("%s\n",a);

	return 0;
}

Measured memory_bytes: 524
#include <cstdio>

int main() {
    int a,b,r;
    int re = 0;
    int rh = 0;

    while (scanf("%d,%d,%d", &a, &b, &r) != EOF) {
        if (a == b) {
            rh++;
        } else if ((a * a) + (b * b) == (r * r)) {
            re++;
        }
    }

    printf("%d\n%d\n", re, rh);

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void)
{
  int a,b,max=0,i;
 scanf("%d",&a);
 scanf("%d",&b);
 for(i=0;i<2;i++){
 if(a>=b){
   max+=a;
   a--;
 }
  else{
  max+=b;
  b--;
  }
 }
  printf("%d",max);
 return 0;
}

Measured memory_bytes: 128
def main():
    squares, tolls_number, start = map(int, input().split(" "))
    tolls = list(map(int, input().split(" ")))
    first_toll_index = 0
    for i in range(tolls_number):
        if tolls[i] > start:
            first_toll_index = i
            break
    print(min(len(tolls[:first_toll_index]), len(tolls[first_toll_index:])))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

constexpr ll mod = 1000000007;

ll N;
ll C[200010], S[200010];
ll dp[200010];

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", C+i );

  C[N] = -1;

  dp[0] = 1;

  rep( i, N )
  {
    S[C[i]] = (S[C[i]]+dp[i]) % mod;

    if( C[i] != C[i+1] )
      dp[i+1] = (dp[i+1]+S[C[i]]) % mod;
  }

  printf( "%lld\n", dp[N] );

  return 0;
}

Measured memory_bytes: 4864
import java.util.*;

public class Main{
	public static void main(String[] artgs){
		int N = new Scanner(System.in).nextInt();
		int sn = 0;
		int x = N;
		while (x != 0){
			sn += x%10;
			x /= 10;
		}

		if (N%sn == 0){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 22868
N, A, B = map(int, input().split())

def SumOfDigits(n):
    s = 0
    while n != 0:
        s += n % 10
        n = n // 10
    return(s)


S = 0

for i in range(N+1):
    j = 0
    j = SumOfDigits(i)
    if j >= A and j <= B:
        S += i
    else:
        pass

print(S)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)
int n,a,x[55];ll dp[55][55][2505]={};
bool vis[55][55][2505]={};

ll rec(int i,int j,int k){
  if(i<j||k<0||j<0) return 0;
  if(vis[i][j][k]) return dp[i][j][k];
  if(i==0) return 0;
  vis[i][j][k]=1;
  dp[i][j][k]=rec(i-1,j,k)+rec(i-1,j-1,k-x[i]);
  return dp[i][j][k];
}

int main(){
  cin>>n>>a;
  Fr(i,n) cin>>x[i];
  ll ans=0;
  dp[0][0][0]=1;
  vis[0][0][0]=1;
  Fr(i,n) ans+=rec(n,i,i*a);
  cout<<ans<<endl;
}


Measured memory_bytes: 62080
#include<stdio.h>
         
int main(){
         int N;
          scanf("%d",&N);
         int a[200001];
    int i;
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
    }
     
    int j;
    int max=0;
    int kari;
    for(i=0;i<N;i++){

        if(max<a[i]){
            max=a[i];
            kari=i;
        }
     
    }
int n_max;
        for(i=0;i<N;i++){
            if(i==kari){
                n_max=0;
                for(j=0;j<N;j++){
                
                if(n_max<a[j]&&kari!=j){
                    n_max=a[j];
                }
     
    }printf("%d\n",n_max);
            }
            else{printf("%d\n",max);}
            }
        
        
     
          return 0;
        }

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

int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int m; cin >> m;
	int64_t ans = 0;
	int64_t sum = 0;
	while(m--) {
		int64_t d, c; cin >> d >> c;
		ans += c;
		sum += d * c;
	}
	ans--;
	ans += (sum - 1) / 9;
	cout << ans << endl;
	return 0;
}

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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

const int N = 200005;
const int mod = 998244353;

int bit[N];

void update(int i, int v) {
  for (; i < N; i += i & -i) {
    (bit[i] += v) %= mod;
  }
}

int get(int i) {
  int v = 0;
  for (; i; i -= i & -i) {
    (v += bit[i]) %= mod;
  }
  return v;
}

void Main() {
  int n, k;
  cin >> n >> k;
  vector<ii> a(k);
  for (auto &i : a) cin >> i.fi >> i.sc;
  update(1, 1);
  for (int i = 2; i <= n; i++) {
    for (auto &j : a) {
      int u = get(max(0ll, i - j.sc - 1));
      int v = get(max(0ll, i - j.fi));
      update(i, (v - u + mod * mod) % mod);
    }
  }
  cout << (get(n) - get(n - 1) + mod * mod) % mod << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "i love ------- <3 \n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 5212
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n;
double a[55];

int main(){
    cout << setprecision(10) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    double d = 1, res = 0;
    for (int i = n - 1; i > 0; i--){
        d *= 2;
        res += a[i] / d;
    }
    cout << res + a[0] / d;
    return 0;
}


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

#define REP(i,n) for (int i=0;i<(n);++i)
#define MOD 1000000007

using namespace std;

using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    int sqrtN;
    for (ll i = 1; i <= N + 1; ++i) {
        if (i * i > N) {
            sqrtN = i - 1;
            break;
        }
    }

    vector<ll> a(2 * sqrtN, 0);
    REP(i, sqrtN) {
        a[i] = i + 1;
        a[sqrtN + i] = N / (sqrtN - i);
    }
    REP(_, K - 1) {
        vector<ll> old_a(a.begin(), a.begin() + sqrtN);
        REP(i, sqrtN) {
            a[i] = (i > 0 ? a[i - 1] : 0) + a[a.size() - 1 - i];
        }
        REP(i, sqrtN) {
            int left = i > 0 ? N / (sqrtN - i + 1) : sqrtN;
            int right = N / (sqrtN - i);
            a[sqrtN + i] = (a[sqrtN + i - 1] + (right - left) * old_a[sqrtN - 1 - i] % MOD) % MOD;
        }
    }
    cout << a[a.size() - 1] << endl;
    return 0;
}

Measured memory_bytes: 1032
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    mod = pow(10,9) + 7
    ans = pow(10,n,mod)
    ans -= pow(9,n,mod)*2
    ans += pow(8,n,mod)

    print(ans%mod)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9096
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); sc.nextLine();
        Set<String> set = new HashSet<>();
        
        for(int i=0; i<n; i++){
            set.add(sc.next());
        }
        
        if(set.size() == n){
            System.out.println("YES");
        }
        else{
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 78032
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
#define rreps(i, n) for(int i=((int)(n)); i>0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pl(s) cout << (s) << "\n";
#define pls(...) {bool space = false; for(auto i : __VA_ARGS__) (cout << (space?" ":"") << i), space = true; cout << "\n";}
#define plexit(s) {cout << (s) << "\n"; exit(0);}
#define yes(s) cout << ((s)?"Yes":"No") << "\n";
#ifdef __LOCAL
#include <dump.hpp>
#define dump(...) DUMPOUT << "  " << string(#__VA_ARGS__) << ": " << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl << "    ", dump_func(__VA_ARGS__)
#else
#define dump(...)
#endif
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct IOInit { IOInit() { cin.tie(nullptr); ios::sync_with_stdio(false); dump("READY"); /*cout << unitbuf;*/} } IO_INIT;
using ll = long long; using ull = unsigned long long; using ld = long double;
template<typename T = int> using V = vector<T>; template<typename T = int> using P = pair<T, T>;
using Vi = V<int>; using Vl = V<ll>; using Vd = V<ld>; using VVi = V<Vi>; using VVl = V<Vl>; using Pi = P<int>; using Pl = P<ll>; using Pd = P<ld>;
constexpr ll MOD = 1000000007; constexpr int INF = (1 << 30) - 1; constexpr ll INFL = 1LL << 60; constexpr ld EPS = 1e-12; constexpr ld PI = 3.141592653589793238462643383279;



signed main(void) {
  int n, m; cin >> n >> m;

  scc_graph g(n);
  rep(i,m) {
    int u, v; cin >> u >> v;
    g.add_edge(u, v);
  }

  auto scc = g.scc();
  pl(scc.size());
  for (auto v: scc) {
    cout << v.size();
    for (int x : v) {
      cout << " " << x;
    }
    cout << "\n";
  }
  return 0;
}


Measured memory_bytes: 40112
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int b, r, g, c, s, t;
        cin >> b >> r >> g >> c >> s >> t;
        if(b+r+g+c+s+t == 0)
            return 0;

        int ret = 100;
        ret -= (b * 5 + r * 3) * 2;
        ret -= (t - (b * 5 + r * 3) - s) * 3;
        ret += (b + r) * 15;
        ret += (b * 5 + r * 3) * 15;
        ret += g * 7;
        ret += c * 2;
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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(){
    ll n, a, b, c, d, e; cin >> n >> a >> b >> c >> d >> e;
    ll mn = min({a,b,c,d,e});
    ll res = (n + mn - 1)/mn + 4;
    cout << res << ln;
}


Measured memory_bytes: 3604
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(1)

N = I()
AB = [LI() for _ in range(N)]

AB = sorted(AB, key=lambda x: x[1])
T = int(0)
for i in range(N):
    T += AB[i][0]
    if T>AB[i][1]:
        ans = -1

if ans>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 84828
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
set<pair<ll,ll>> st;
map<pair<ll,ll>,int> pt;
ll ans[100000];
int main() {
	
	ll h,w,n,x,y;
	cin>>h>>w>>n;
	for(int i=0;i<n;i++){
	    cin>>x>>y;
	    pt[make_pair(x,y)]++;
	    st.insert({x,y});
	    st.insert({x,y-1});
	    st.insert({x,y-2});
	    st.insert({x-1,y});
	    st.insert({x-1,y-1});
	    st.insert({x-1,y-2});
	    st.insert({x-2,y});
	    st.insert({x-2,y-1});
	    st.insert({x-2,y-2});
	}
	ll Tot=max(0ll,h-2)*max(0ll,w-2);
	for(set<pair<ll,ll>>::iterator it=st.begin();it!=st.end();it++){
	    x=(*it).first;
	    y=(*it).second;
	    int cnt=0;
	    if(x<1||x>h-2||y<1||y>w-2){
	        continue;
	    }
	    for(int i=0;i<=2;i++){
	        for(int j=0;j<=2;j++){
	            if(pt.find({x+i,y+j})!=pt.end()){
	              cnt++;       
	            }
	        }
	    }
	    ans[cnt]++;
	}
	ll tot=0;
	for(int i=1;i<=9;i++){
	    tot+=ans[i];
	}
	ans[0]=Tot-tot;
	for(int i=0;i<=9;i++){
	    cout<<ans[i]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 64768
#include <stdio.h>
#include <math.h>
int main(){
    while(1){
        int n,i,cnt=0,sw=1,sosuu[100000],t;
        if(scanf("%d",&n)==EOF) break;
        if(n<=1){
            cnt=0;
        }else{
            sosuu[cnt]=2;
            cnt++;
            for(i=3;i<=n;i+=2){
                sw=1;
                for(t=0;t<cnt&&sosuu[t]*sosuu[t]<=i;t++){
                    if(i%sosuu[t]==0){
                        sw=0;
                        break;
                    }
                }
                if(sw==1){
                    sosuu[cnt]=i;
                    cnt++;
                }
            }
             
             
        }
        printf("%d\n",cnt);
         
    }
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        ans += x;
    }
    ans -= N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,X,T;
    cin >>N>>X>>T;
    if(N%X==0){
        cout<<N/X*T<<endl;
    }else{
        cout<<(N/X + 1)*T<<endl;
    }



    return 0;
    

}

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

int main() {
    int H, W;
    cin >> H >> W;
    int a[H][W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) cin >> a[i][j];
    }

    int N = 0, x1[H * W], y1[H * W], x2[H * W], y2[H * W];
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W - 1; ++j) {
            if (a[i][j] % 2) {
                --a[i][j]; ++a[i][j + 1];
                y1[N] = i + 1; x1[N] = j + 1;
                y2[N] = i + 1; x2[N] = j + 2;
                ++N;
            }
        }
    }
    for (int i = 0; i < H - 1; ++i) {
        if (a[i][W - 1] % 2) {
            --a[i][W - 1]; ++a[i + 1][W - 1];
            y1[N] = i + 1; x1[N] = W;
            y2[N] = i + 2; x2[N] = W;
            ++N;
        }
    }

    cout << N << endl;
    for (int i = 0; i < N; ++i) {
        cout << y1[i] << ' ' << x1[i] << ' ' << y2[i] << ' ' << x2[i] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define LL long long
#define ffor(i,s,n) for(int i=(s);i<(n);i++)
#define efor(i,s,n) for(int i=(s);i<=(n);i++)
using namespace std;


LL k;
LL n;
LL a[100000];

int main(){
	cin>>n>>k;
	LL out;
	n--;
	k--;
	cout<<n/k+(n%k==0?0:1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include <string>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
#include<math.h>
#include <ctype.h>
#include <algorithm> // sort
#include <map> // pair
using namespace std;
#define nin(n) int n; cin >> n;
#define kin(k) int k; cin >> k;
int main() {
  double n; 
  cin >> n;
  double k;
  cin >> k;
 int count=0;
   double ans=0;
  for(int i=1;i<n+1;i++){
    count=0;
     double tmp=i;
    while(tmp<k){
     tmp=tmp*2;
      count++;
    }
    ans+=pow(0.5,count)/n;
  }
  cout <<std::setprecision(13)  <<  ans  << endl;
}
      

Measured memory_bytes: 512
#pragma once
#include <stdio.h>
#include <sstream>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const ll MAX = 210000;
const ll MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string & S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
vector<int> es[100010];
map<vector<int>, int> ma;
ll calc(int f,int x, int de) {

	if (de == 3) {
		if (ma.count({ f,x })) return 0;
		ma[{f, x}] = 1;
		ma[{x, f}] = 1;
		return 1;
	}

	for (auto v : es[x]) {
		
	}
}
struct mov {
	int fx, fy, tx, ty;
	mov(int fx,int fy,int tx,int ty) : fx(fx),fy(fy),tx(tx),ty(ty){}
};
void solv() {
	int h, w;
	cin >> h >> w;
	int tb[501][501];
	for (size_t i = 1; i <= h; i++)
	{
		for (size_t j = 1; j <= w; j++)
		{
			cin >> tb[i][j];
		}
	}
	
	vector<mov> v;
	for (size_t i = 1; i <= h; i++)
	{
		for (size_t j = 1; j < w; j++)
		{
			if (tb[i][j] % 2 == 1) {
				tb[i][j + 1] += 1;
				tb[i][j] -= 1;
				v.push_back(mov(i, j, i, j + 1));
			}
		}
	}

	for (size_t i = 1; i < h; i++)
	{
		if (tb[i][w] % 2 == 1) {
			tb[i + 1][w] += 1;
			tb[i][w] -= 1;
			v.push_back(mov(i, w, i + 1, w));
		}
	}
	cout << v.size() << endl;
	for (auto vi : v)
	{
		cout << vi.fx << " " << vi.fy << " " << vi.tx << " " << vi.ty << endl;
	}
}

int main() {
	//COMinit();
	solv();

	return 0;
}


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

int main()
{
    int a, b;
    int k;

    cin >> a >> b;

    k = (a + b) / 2;

    if(abs(a -k) == abs(b - k))
    {
        cout << k << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
m = map(int, read().split())
A, B = zip(*zip(m, m))

A, B = A[::-1], B[::-1]

x = 0
for a, b in zip(A, B):
    a += x
    y = (-a) % b
    x += y
print(x)

Measured memory_bytes: 34020
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cout << #x << " = " << (x) << endl
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

long long modPow(long long a, long long x, long long p) {
    long long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

long long modInverse(long long a, long long p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}

long long modFactorial(long long a, long long p) {
    long long fact = 1;
    for (long long i=2; i<=a; i++) {
        fact *= i;
        fact %= p;
    }
    return fact;
}

long long combination(long long n, long long k, long long p) {
    // calculates C(n,k) mod p (assuming p is prime).

    long long numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (int i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    long long denominator = 1; // k!
    for (int i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}


class EMaxMinSums {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll N, K;
        in >> N >> K;
        vector<ll> A(N);
        REP(i,0,N) in >> A[i];
        sort(all(A));
        ll answer = 0;
        ll comb = combination(N-1, K-1, MOD);
        REP(i,0,N) {
            if (N-i-1 < K-1) break;
            ll add = 2 * MOD + A[N-i-1] - A[i];
            add %= MOD;
            add *= comb;
            add %= MOD;
            answer += add;
            answer %= MOD;
            comb *= modInverse(N-i-1, MOD);
            comb %= MOD;
            comb *= (N-i-K);
            comb %= MOD;
        }
        out << answer << "\n";
    }
};


signed main() {
    EMaxMinSums solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
#![allow(non_snake_case)]
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;


#[fastout]
fn solve() {
    const MOD: usize = 1_000_000_007;
    const INF: usize = std::usize::MAX;
    
    input!{
        v: [isize; 3],
    }

    let mut ans = 0;
    for &i in v.iter() {
        if v.iter().filter(|x| **x == i).count() == 1 {
            ans = i
        }
    }

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

fn main() {
    solve()
}

#[cfg(test)]
mod test {
    use super::solve;
}


Measured memory_bytes: 2200
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;

function main(input) {
  var o = new I(input);

  var R = o.a();
  var G = o.a();
  var B = o.a();
  var N = o.a();

  var count = 0;
  for (var r = 0; r <= N / R; r++) {
    for (var g = 0; g <= (N - r * R) / G; g++) {
      if ((N - r * R - g * G) % B === 0) count += 1;
    }
  }

  console.log(count);
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
N, M = gets.chomp.split(" ").map(&:to_i)

def fact(n)
  return 1.0 if n <= 1
  return fact(n - 1) * n
end

def c(n, r)
  return (fact(n) / (fact(r) * fact(n - r))).to_i
end

sum = c(M, 2)
sum += c(N, 2)
puts sum

Measured memory_bytes: 1788
require "set"
n,k = gets.chomp.split(" ").map(&:to_i)
p_arr = [0] + gets.chomp.split(" ").map(&:to_i)
c_arr = [0] + gets.chomp.split(" ").map(&:to_i)

arr = []
set = Set.new
(1..n).each do |i|
  next if set.include?(i)
  p = i
  tmp_arr = []
  tmp_set = Set.new
  while true do
    break if tmp_set.include?(p)
    tmp_set << p
    set << p
    p_next = p_arr[p]
    tmp_arr << c_arr[p_next]
    p = p_next
  end
  arr << tmp_arr
end

max = (10 ** 9) * (-1)
arr.each do |tmp_cycle|
  cycle = tmp_cycle + tmp_cycle
  (0..tmp_cycle.length-1).each do |i|
    l = [tmp_cycle.length, k].min
    tmp_max = (10 ** 9) * (-1)
    tmp_sum = 0
    l.times do |j|
      tmp_sum += cycle[i+j]
      tmp_max = tmp_sum if tmp_sum > tmp_max
    end
    if l == k
      max = tmp_max if tmp_max > max
    else
      l2 = (k / tmp_cycle.length)
      r = k % tmp_cycle.length
      if r == 0
        l2 -= 1
        r = tmp_cycle.length
      end
      tmp_sum2 = tmp_sum * l2
      tmp_max = tmp_sum2 if tmp_sum2 > tmp_max
      r.times do |j2|
        tmp_sum2 += cycle[i+j2]
        tmp_max = tmp_sum2 if tmp_sum2 > tmp_max
      end
      max = tmp_max if tmp_max > max
    end
  end
end

puts max


Measured memory_bytes: 15572
#include <iostream>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
using namespace std;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		cout << "Alice" << endl;
	}
	else {
		cout << "Borys" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int n,i,score,count,j;
	char s;
	int c[1000];

	while (1) {
		n = 0;
		score = 0;
		count=0;
		do{
			scanf("%d", &c[n++]);
		} while (scanf("%c", &s), s != '\n');
		if (c[0]==0)break;

		for (i = 0; i < n; i++) {
			if (c[i] >= 2 && c[i] <= 9) {
				score += c[i];
				c[i] = 0;
			}
			else if (c[i] >= 10 && c[i] <= 13) {
				score += 10;
				c[i] = 0;
			}else{
			  count++;
			}
		}
		j=1;
		for (i = 0; i < n; i++) {
			if (c[i] != 0) {
			  if (score + (count-j)+11 <= 21) {
					score += 11;
				}
				else score += 1;
			  j++;
			}
		}
		if (score > 21)printf("0\n");
		else printf("%d\n",score);
	}
	return 0;
}

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

using namespace std;

#pragma GCC optimize "-O3"

#define watch(x) cout << (#x) << " is " << (x) << endl

#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repd(i,a,b) for(int i=a-1;i>=b;i--)
#define nl          cout<<endl;
#define test()      lli t;cin>>t;while(t--)
#define sp(n)       setprecision(n)

#define lli     long long int
#define ulli    unsigned long long int
#define ld      long double
#define uld     unsigned long double
#define S       string
#define C       char
#define elif    else if
 
#define pb      push_back
#define pp      pop_back
#define plli    pair<lli,lli>
#define vlli    vector<lli>
#define vulli   vector<ulli>
#define vld     vector<ld>
#define vs      vector<string>

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define vsort(v) sort(v.begin(),v.end())

// #define max1 1000001    //10^6 + 1
// #define max2 10000001   //10^7 + 1
// #define max3 1000000007 //10^9 + 7
#define inf  1000000009 //10^9 + 9

const int N = 1e5+5;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
 	cin >> n;
 	// lli a[n],b[n],c[n];
 	vector<int> dp(3); // store the value if i th task on last day
 	for (int days = 0; days < n; ++days)
 	{
 		vector<int> val(3);
 		cin >> val[0] >> val[1] >> val[2];
 		vector<int> dp_n(3, 0);
 		for (int i = 0; i < 3; ++i)
 		{
 			for (int j = 0; j < 3; ++j)
 			{
 				if(i!=j){
 				 dp_n[j] = max(dp_n[j], dp[i]+ val[j]);
 				 	// watch(j);
 				 	// watch(dp_n[j]);
 				 	// watch(val[j])
 				}
 			}
 		}
 		dp = dp_n;
 	}
 	printf("%d\n", max(max(dp[0],dp[1]),dp[2]));
 	// lli ite[n];
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
struct Point{
    int x, y;
};

int main(void){
    // Your code here!
   Point p1,p2,p3,p4;
   Point vec12,vec23,vec34,vec41;
   cin >> p1.x >> p1.y >> p2.x >> p2.y;
   vec12.x = p2.x - p1.x;
   vec12.y = p2.y - p1.y;
   vec23.x = -vec12.y;
   vec23.y = vec12.x;
   vec34.x = -vec12.x;
   vec34.y = -vec12.y;
   vec41.x = -vec23.x;
   vec41.y = -vec23.y;
   p3.x = p2.x + vec23.x;
   p3.y = p2.y + vec23.y;
   p4.x = p3.x + vec34.x;
   p4.y = p3.y + vec34.y;
   cout << p3.x << ' ' << p3.y << ' ' << p4.x << ' ' << p4.y;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter

def main():
	n = int(input().strip())
	res = []
	for i in range(n):
		S, P = input().strip().split()
		res.append((S, int(P), i+1))
	res_sed = sorted(res, key=itemgetter(1), reverse=True)
	res_ans = sorted(res_sed, key=itemgetter(0))
	for tup in res_ans:
		print(tup[2])

if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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 ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double d=h*30+m*0.5-m*6;
  if(d<0)d=-d;
  d*=pi/180;
  
  double ans=a*a+b*b-2*a*b*cos(d);
  cout << fixed << setprecision(10) << sqrt(ans) << endl;
  return 0;     
}


Measured memory_bytes: 4244
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;



int main(){
    int N;
    cin >> N;
    vector<int> retu(N);
    for(int i = 0;i<N;i++){
        cin >> retu.at(i);
    }
    bool ok = true;
    int count = 0;
    
    for(int j = 1;j<50;j++){
        for(int k = 0;k<N;k++){
            if(retu.at(k)%2 != 0){
                ok = false;
                break;
            }
            else{
            }
        }
        if(ok == true){
            for(int l=0;l<N;l++){
                    retu.at(l) = retu.at(l)/2;
                }
            //cout << retu.at(0) << retu.at(1) << retu.at(2) << endl;
            count++;
        }
        else{
            break;
        }
        
    }
    
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define P 1000000007
long perm(long x){
  return (x==0?1:perm(x-1)*x%P);
}
int main(){
  long N,M;cin>>N>>M;
  if(abs(N-M)>1){cout<<0<<endl;return 0;}
  cout<<perm(N)*perm(M)*((N==M)+1)%P;
}



Measured memory_bytes: 5052
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> array = new ArrayList<>();
		long sum=0;

		for(int i=0; i<n; i++) {
			array.add(sc.nextInt());
			sum +=array.get(i);
		}
		Collections.sort(array);
		System.out.println(array.get(0) + " "+ array.get(n-1) + " " + sum);
	}
}


Measured memory_bytes: 41656
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n;i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b;i++)
#define repv(x, arr) for (auto& x:arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a,b) make_pair(a,b)
#define op(i) cout << (i) << endl;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;



int main(){
    ll N,x;
    cin >> N >> x;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll ans = 0;
    ans=max(0LL, A[0] - x);
    A[0] = min(A[0], x);
    repf(i,1,N){
        ans += max(0LL, A[i - 1] + A[i] - x);
        A[i] = min(A[i], x - A[i - 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll x, y;
    cin >> x >> y;
    if(x <= 1 && y <= 1)cout << "Brown" << endl;
    else{
        if(abs(x - y) < 2)cout << "Brown" << endl;
        else cout << "Alice" << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ans = 0;
        if(n < 112) ans = 111;
        else if(n < 223) ans = 222;
        else if(n < 334) ans = 333;
        else if(n < 445) ans = 444;
        else if(n < 556) ans = 555;
        else if(n < 667) ans = 666;
        else if(n < 778) ans = 777;
        else if(n < 889) ans = 888;
        else ans = 999;
        System.out.println(ans);
    }
}

Measured memory_bytes: 35844
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
using namespace std;
long long max(long long a ,long long b){
  if(a>b)return a;
  else return b;
}
int main(){
  int n; cin>>n;
  int a[210000],b[210000];
  for(int i=0;i<n;i++){
  cin>>a[i];
  b[i]=a[i];
  }

  sort(b,b+n);

  if(b[n-2]==b[n-1]){
    for(int i=0;i<n;i++)
    cout<<b[n-1]<<endl;;
  }
  else{
    for(int i=0;i<n;i++){
      if(a[i]==b[n-1]) cout<<b[n-2]<<endl;
      else cout<<b[n-1]<<endl;
    }
  }
}


Measured memory_bytes: 3200
import sys
input = sys.stdin.readline

N,M=map(int,input().split())
E=[list(map(int,input().split())) for i in range(M)]
S,G=map(int,input().split())

ELIST=[[] for i in range(N+1)]

for x,y in E:
    ELIST[x].append(y)

DIS=[[-1,-1,-1] for i in range(N+1)]
DIS[S][0]=0

from collections import deque

S=deque([S])
i=1

while S:
    #print(S)
    NEWS=deque()
    while S:     
        x=S.pop()

        for to in ELIST[x]:
            if DIS[to][i%3]==-1:
                DIS[to][i%3]=i
                NEWS.append(to)

    i+=1
    S=NEWS

print(DIS[G][0]//3)
            
        
    


Measured memory_bytes: 54740
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[n],b[n];
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  int aa=0,bb=0;
  rep(i,n){
    aa+=max((int)0,((b[i]-a[i])/2));
    bb+=max((int)0,(a[i]-b[i]) );
  }
  //cout<<aa<<" "<<bb<<endl;
  if(aa>=bb) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
int n,k;
int a[11111];
signed main(){
	cin>>n>>k;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	int ans=0;
	rep(i,k)ans+=a[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define see(x) cerr<<#x<<"="<<x<<endl;
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll fast(ll x,ll n) {ll ans=1;for(;n;n>>=1,x=x*x%mod) if(n&1) ans=ans*x%mod; return ans;}
const int N=1e6+100;

ll c(ll x) {
    return x*(x+1)/2;
}
ll ans[N],siz[N],temp[N],a[N],n;
vector<int>edge[N];

void dfs(int x,int f) {
    ll t=temp[a[x]];
    siz[x]=1;
    for(auto v:edge[x]) if(v!=f) {
        ll pre=temp[a[x]];
        dfs(v,x);siz[x]+=siz[v];
        ans[a[x]]-=c(siz[v]-(temp[a[x]]-pre));
    }
    temp[a[x]]=t+siz[x];
}
int main() {
    cin>>n;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    for(int i=1;i<n;i++) {
        int u,v;
        scanf("%d%d",&u,&v);
        edge[u].push_back(v);
        edge[v].push_back(u);
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) {
        ans[i]+=c(n)-c(n-temp[i]);
        printf("%lld\n",ans[i]);
    }
}


Measured memory_bytes: 58408
#include<iostream>
#include<bitset>
#include<sstream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<iomanip>
#include<stdio.h>

using namespace std;
long gcd(long x, long y){ if (x > y){ return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; } return x; }
long lcm(long x, long y){ return (x / gcd(x, y) * y); }

int main(void){

	long N; cin >> N;
	long res = 1;
	long mod = 1000000007;
	string S1, S2; cin >> S1 >> S2;

	for (int i = 0; i < N; i++){
		if (S1[i] == S1[i + 1]) {
			if (i == 0) res *= 6;
			if (i == 1) res *= 2;
			if (i > 1){
				if (S1[i - 1] == S1[i - 2]) res *= 3;
				else res *= 2;
			}
			i++; 
		}
		if (S1[i] == S2[i]){
			if (i == 0) res *= 3;
			if (i == 1) res *= 2;
			if (i > 1){
				if (S1[i - 1] == S1[i - 2]) res *= 1;
				else res *= 2;
			}
		}
		res %= mod;
	}

	cout << res << endl;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int array[3];
	for(int i = 0; i < 3; i++) scanf("%d",&array[i]);
	for(int i = 2; i > 0; i--){
		for(int j = 0; j < i; j++){
			if(array[j] > array[j+1])swap(array[j],array[j+1]);
		}
	}
	printf("%d %d %d\n",array[0],array[1],array[2]);
}


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

int main() {
    int n;
    int N, M, X;
    cin >> N >> M >> X;
    n=N;

    int A[N+1][M+1]={},C[N+1]={}, Skill[M+1]={};
    int i, j, k, p;

        for (i = 1; i <= N; ++i)
    {
        cin >> C[i];
        for (j = 1; j <=M; ++j)
        {
            cin >> A[i][j];
        }
    }

    int B[N+1][M+1]={}, sum=0, frag=0;
    for (j = 1; j <= M; ++j)
    {
        for (i = 1; i <=N; ++i)
        {
            sum += A[i][j];
        }
        if(sum<X) frag = -1;
        if(frag == -1) break;
        sum=0;
    }


    int cheap = INT32_MAX;
    if(frag==-1){
        cout << -1 << endl;
    }else{
    // {0, 1, ..., n-1} の部分集合の全探索
        for (int bit = 0; bit < (1<<n); ++bit)
        {   frag = 1;
            sum=0;
            for(p = 1; p <=M; p++)
            {
                Skill[p] = 0;
            }

            /* bit で表される集合の処理を書く */


            /* きちんとできていることを確認してみる */
            // bit の表す集合を求める
            vector<int> S;
            for (int i = 0; i < n; ++i) {
                if (bit & (1<<i)) { // i が bit に入るかどうか
                    S.push_back(i);
                }
            }

            // bit の表す集合の出力
            //cout << bit << ": {";
            for (int i = 0; i < (int)S.size(); ++i) {
                for (p = 1; p <=M; p++)
                {
                    Skill[p] += A[S[i]+1][p];
                }
                sum += C[S[i]+1];
                //cout << S[i]+1 << " ";
            }
            //cout << "}" << endl;

            for (p = 1; p <=M; p++)
            {
                //cout << "bad" << endl;
                if(Skill[p]<X && frag!=-1){
                    frag = -1;
                }
            }
            //cout << frag << endl;
            //cout <<"sum = "<< sum << endl;
            if(frag!=-1){
                if(cheap>sum && sum!=0) cheap=sum;
            }
            //cout <<"cheap = "<<  cheap << endl;
           
        }
         cout << cheap << endl;
        
    }
    
}

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

int	main() {
	int H, W, A, B;
	cin >>H >>W >>A >>B;
	for (int i=0; i<H; i++) {
		for (int j=0; j<W; j++) {
			if (i<B) {
				if (j<A)
					cout <<'0';
				else
					cout <<'1';
			} else {
				if (j<A)
					cout <<'1';
				else
					cout <<'0';
			}
		}
		cout <<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
int main(void){
    int n, a[20],count=0;
    scanf("%d",&n);
    for(int i = 0; i < n; i++)
    {
        scanf("%d",&a[i]); 
    }
    
    for(int i = 1; i < n-1; i++)
    {
        if( (a[i-1]<a[i] && a[i]<a[i+1]) || (a[i-1]>a[i] && a[i]>a[i+1]))
        {
            count++;
        }
    }
    printf("%d\n",count);
}


Measured memory_bytes: 128
N = input()
n = [0]*(len(N) + 1)
ans = 0
for i in range(len(N)):
    n[i] = int(N[len(N) - 1 - i])
for i in range(len(n)):
    if n[i] < 5:
        ans += n[i]
    elif n[i] == 5:
        if n[i+1] >= 5:
            ans += 10 - n[i]
            n[i+1] += 1
        else:
            ans += 5
    else:
        ans += 10 - n[i]
        n[i+1] += 1
print(ans)

Measured memory_bytes: 11972