akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int A, B, C; cin >> A >> B >> C;

    int res = 0;
    int sum = A + B + C;
    for(auto e : {A, B, C}){
        chmax(res, sum + 9 * e);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
typedef long long ll;
const int maxn=55;
ll C[maxn][maxn];
void init(){
  for(int i=0;i<maxn;++i){
    C[i][0]=1;
    for(int j=1;j<=i;++j)C[i][j]=C[i-1][j-1]+C[i-1][j];
  }
}
int cnt[2];

int main(){
  init();
  int n,p;scanf("%d%d",&n,&p);
  int x;
  for(int i=1;i<=n;++i){
    scanf("%d",&x);cnt[x&1]++;
  }
  long long ans=0;
  if(p==1){
    if(cnt[1])printf("%lld\n",1ll<<(n-1));
    else printf("0\n");
  }else{
    if(cnt[1])printf("%lld\n",1ll<<(n-1));
    else printf("%lld\n",1ll<<n);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define ll long long
#define pii pair<int,int> 
#define v(T) vector<T>
#define all(x) (x).begin(), (x).end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
const int INF = 1001001001;
//int 2×10の9乗
//vector<vector<int>> a(n, vector<int>(m));
  //rep(i,n) rep(j,m) cin >> a[i][j]; 
//cout << fixed << setprecision(10);
//int gcd(int x, int y){
  //if(y==0) return x;
  //return gcd(y, x%y);
//}
//sort小さい順(昇順)
 
int main(){
  int n;
  cin >> n;
  v(int) a(n),ans(n);
  rep(i,n){
    cin >> a[i];
    ans[a[i]-1]=i+1;
  }
  rep(i,n) cout << ans[i] << endl;    
}

Measured memory_bytes: 1664
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = sorted(LI(),reverse=True)[:X]
q = sorted(LI(),reverse=True)[:Y]
r = sorted(LI(),reverse=True)[:X+Y]

pq = sorted(p + q)
ans = sum(pq)

for i in range(len(r)):
    if pq[i] < r[i]:
        ans += r[i] - pq[i]
    else:
        break

print (ans)

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

int A[1000][1000]={{}};
int b[1000]={};

int main(void){
   int n,m,i,j;
   int sum;
   cin >> n >> m;
   for(i=0; i<n; i++){
       for(j=0;j<m;j++){
           cin >> A[i][j];
       }
   }
   for(i=0; i<m; i++){
       cin >>b[i];
   }
   
   for(i=0; i<n; i++){
       sum = 0;
       for(j=0;j<m; j++){
           sum += A[i][j] * b[j];
       }
       cout << sum << endl;
   }
}



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

int main() {
    string S;
    cin >> S;
    int N = S.size();

    vector<int> ans(N, 0), A(N, 0);
    int m = 0, n = 0, keep = 0;
    while (m < N) {
        keep++;
        if (m + 1 < N) {
            if (S.at(m) != S.at(m + 1)) {
            A.at(n) = keep;
            n++;
            keep = 0;
            }
        }
        if (m + 1 == N) {
            A.at(n) = keep;
            break;
        }
        m++;
    }
    
    int i = 0;
    keep = 0;
    while (i + 1 < N) {
        if (A.at(i) != 0) {
            int a = A.at(i), b = A.at(i + 1);
            ans.at(keep + a - 1) = (a - 1) / 2 + b / 2 + 1;
            ans.at(keep + a) = a + b - ((a - 1) / 2 + b / 2 + 1);
            keep += a + b;
            }
        i += 2;
    }

    cout << ans.at(0);
    for (int i = 1; i < N; i++) {
        cout << " " << ans.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    ll sum=a[n-1];
    ll i=1,x=0;
    while((n-1-i)>=0&&x<(n-2))
    {
        sum+=a[n-1-i];
        x++;
        if(x%2==0)
        i++;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 5176
//
//  main.cpp
//  dp
//
//  Created by 贾皓翔 on 2019/11/26.
//  Copyright © 2019 贾皓翔. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>
#include <unordered_set>
#define ll long long
using namespace std;

int main(){
    string sa,sb;
    int a,b;
    cin>>a>>b;
    for(int i=0;i<b;i++){
        sa.append(to_string(a));
    }
    for(int i=0;i<a;i++){
        sb.append(to_string(b));
    }
    if (sa.compare(sb)<0) {
        cout<<sa<<endl;
    }else{
        cout<<sb<<endl;
    }
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,k;
  cin >> n >> k;
  
  int ans = k; 
  for(int i = 1;i < n;i++){
    ans *= k-1;
  }
  
  cout << ans;
  
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (N, M) = readInputLine().split(" ").map { it.toLong() }
    
    val divisors = mutableSetOf<Long>()
    
    for (i in 1..M) {
        if (i * i > M) {
            break
        }
        if (M % i == 0L) {
            divisors.add(i)
            divisors.add(M / i)
        }
    }
    
    var ans = 1L
    
    for (i in divisors.sorted()) {
        if (N > M / i) {
            break
        }
        
        ans = i
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37696
#include "bits/stdc++.h"
using namespace std;

#define ul unsigned long int
#define ull unsigned long long
#define li long long int

int main()
{
  string s;
  getline(cin,s);

  for (unsigned i=0;i<s.length();i++) {
    if (s[i]>='a' && s[i]<='z') {
      s[i]=(char)((int)'A'+(int)s[i]-(int)'a');
    } else if (s[i]>='A' && s[i]<='Z') {
      s[i] = (char)((int)'a' + (int)s[i] - (int)'A');
    }
  }

  cout << s << endl;

  return 0;
}



Measured memory_bytes: 3180
import java.util.*;

class Main {
   static long gcd(long a, long b)
   {
      if(a % b == 0){
         return(b);
         }
      return(gcd(b, a % b));
   }

   public static void main(String[] args)
   {
      Scanner scan = new Scanner(System.in);
      long    X    = scan.nextLong();
      long    Y    = scan.nextLong();
      int     a    = -1;

      if(X % Y == 0){
         System.out.println(a);
         return;
         }

      for(int i = 2;; i++){
          if(Y % i != 0 && gcd(Y, i) == 1){
             System.out.println(i * X);
             return;
             }
          }
   }
}


Measured memory_bytes: 21844
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        a: i64, b: i64, d: i64,
    }

    let mut res = 0;
    for i in a..=b {
        if i % d == 0 {
            res += 1;
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2076
/**
    And in the end, the love you take is equal to the love you make.

        I LOVE YOU LAURA.
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_DISABLE_PERFCRIT_LOCKS

#define findOrder find_by_order
#define orderKey order_of_key

#define isOn(mask, i) (mask & (1 << i))
#define turn(mask, i) (mask |= (1 << i))
#define switch(mask, i) (mask &= ~(1 << i))
#define change(mask, i) (mask ^= (1 << i))
#define lowbit(mask) (mask & (-mask))
#define turnAll(mask, n) (mask = (1 << n) - 1)
#define switchLastBit(mask) (mask & (mask - 1))
#define turnLastZero(mask) (mask | (mask + 1))
#define modulo(x, mod) ((x) & (mod - 1))
#define log2(x) (31 - __builtin_clz(x))

#define mkp make_pair
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define ins insert
#define rsz resize
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) ((int)x.size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define debug(x) (cerr << x << " ")

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdb;
typedef pair<int, ii> tri;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vdb;
typedef vector<cd> vcd;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vll> matrix;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_tree;

const ll mod = 1e9+7;
const int maxn = 2e5+2;
const int pi = 2 * acos(0.0);
const db eps = 1e-9;

int arr[22][22], dp[1 << 22];

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

    int n; cin >> n;

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

    dp[0] = 1;
    for (int mask = 1; mask < (1 << n); mask++){
        int k = __builtin_popcount(mask);
        for (int i = 0; i < n; i++){
            if (mask & (1 << i) && arr[k - 1][i]){
                dp[mask] = (dp[mask] + dp[mask ^ (1 << i)]) % mod;
            }
        }
    }

    cout << dp[(1 << n) - 1] << "\n";

    return 0;
}


Measured memory_bytes: 10496
import java.util.Scanner;
import java.util.Arrays;

class Main {
    private static void solve() {
        final Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            final int n = scanner.nextInt();
            int[] minutes = new int[n];
            for (int i = 0; i < n; i++) {
                minutes[i] = scanner.nextInt();
            }
            Arrays.sort(minutes);
            int result = 0;
            int sum = 0;
            for (int i = 0; i < n; i++) {
                result += sum + minutes[i];
                sum += minutes[i];
            }
            System.out.println(result);
        }
    }

    public static void main(String... args) {
        solve();
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string s;
  cin>>s;
  int al[26];
  rep(i,0,26) al[i]=0;
  rep(i,0,s.length()){
    al[s[i]-'a']++;
    }
  int ans=-1;
  rep(i,0,26){
    if(al[i]==0){
      ans=i;
      break;
    }
  }
  if(ans==-1) cout<<"None";
  else cout<<char('a'+ans);

    
}

// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 512
s = input()

def f():
    m = dict([(x, 0) for x in 'abcdefghijklmnopqrstuvwxyz'])
    m[' '] = 1
    m[s[0]] = 1
    p0, p1 = ' ', s[0]
    for i, x in enumerate(s[1:]):
        m[x] += 1
        if m[x] > 1:
            print(max(1, i),i + 2)
            return
        m[p0] -= 1
        p0, p1 = p1, x
    print(-1, -1)
    return
f()

Measured memory_bytes: 3316
<?php
$N=trim(fgets(STDIN));

function saiki($str){
        if(is_numeric($str)){
                return ($str+1)/2;
        }
        $array=array();
        $d=0;
        $memo;
        for ($i=0; $i < strlen($str); $i++) {
                if($str[$i]=='['){
                        if($d==0){
                        $memo=$i;
                        }
                        $d++;
                }else if($str[$i]==']'){
                        $d--;
                        if($d==0){
                                array_push($array,saiki(substr($str,$memo+1,$i-$memo-1)));
                        }
                }
        }
        sort($array);
        $size=(sizeof($array)+1)/2;
        $sum=0;
        for ($i=0; $i < $size; $i++) {
                $sum+=$array[$i];
        }
        return $sum;
}

for ($i=0; $i < $N; $i++) {
        $str=trim(fgets(STDIN));
        echo saiki($str).PHP_EOL;
}

Measured memory_bytes: 7164
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    ll N, M;
    cin >> N >> M;
    combination comb = combination(M);
    mint tmp = mint(0);
    FOR(k, 1, N) {
        if(k % 2 == 1)
            tmp += comb.operator()(N, k) * comb.operator()(M - k, N - k) * comb.fact[N-k];
        else
            tmp -= comb.operator()(N, k) * comb.operator()(M - k, N - k) * comb.fact[N-k];
        
    }
    // cerr << "tmp : "<< tmp.x << endl;
    mint ans = comb.operator()(M, N) * comb.fact[N] - tmp;
    ans *= comb.operator()(M, N) * comb.fact[N];
    // cerr << comb.operator()(M, N).x * comb.fact[N].x << endl;
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 11060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		char[][] a = new char[100][100];
		char[][] b = new char[100][100];
		for (int i = 1; i <= n; i++) {
			String c;
			c = sc.next();
			for (int j = 1; j <= n; j++) {
				a[i][j] = c.charAt(j-1);
			}
		}
		for (int i = 1; i <= m; i++) {
			String c;
			c = sc.next();
			for (int j = 1; j <= m; j++) {
				b[i][j] = c.charAt(j-1);
			}
		}
			int y = 1;
			for (int i = 0; i <=  n-m; i++) {
				for (int j = 0; j<= n-m; j++){
					int x = 1;
					for (int k = 1; k <= m; k++) {
						for (int t = 1; t <= m; t++) {
							if (a[i+k][j+t] != b[k][t] ) {
								x = 0;
								break;
							}
						}
						if (x == 0) {
							break;
						}
					}
					if (x == 1) {
						System.out.println("Yes");
						y = 0;
						break;
					}
				}
				if (y == 0) {
					break;
				}
			}
			if (y == 1) {
				System.out.println("No");
			}
	}
}
	

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

using namespace std;

#define pb            push_back
#define mp            make_pair
#define po            pop_back
#define fi            first
#define se            second
#define mxn           100005
#define ll            long long int
#define ldb           long double
#define fr(i,a,b,k)   for(int i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(int i=a ; i>b ; i-=k)
#define all(v)        v.begin(),v.end()
#define endl          "\n"
#define deg(x)        cout<<endl<<#x<<" = "<<(x)<<endl;
#define casep(x)      cout<<"Case #"<<(x)<<": ";
#define fast          ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<int> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = 1e9+7;
const int minf = (-1)*(1e9+7);

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}


void solve(int test){

    int n;
    cin >> n;

    string s;
    cin >> s;
    queue<ll> q;
    frr(i,n-1,-1,1){
        if(s[i] == 'R')
            q.push(i);
    }

    ll ans = 0;
    fr(i,0,n,1){
        if(s[i] == 'W'){
            if(q.empty())
                break;
            ll index = q.front();
            if(index < i)
                break;
            swap(s[index],s[i]);
            q.pop();
            ans++;
        }
    }

    // deg(s);

    cout << ans;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 5000
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}


int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    multiset<ll> s;
    
    rep(i,N){
        ll now = A[i];
        auto itr = s.lower_bound(now);
        if(itr != s.begin()) s.erase(--itr);
        s.insert(now);
    }
    pr(s.size());
    
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <atcoder/maxflow>
using namespace std;
using namespace atcoder; 
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N, M; cin>>N>>M;
    vector<string> S(N);
    rep(i,N)cin>>S.at(i);
    
    mf_graph<int> graph(N*M+2);


    int start = N*M;
    int end = N*M+1;
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            if(S.at(i).at(j)=='#')continue;
            if((i+j)%2==0){
                int aaa=graph.add_edge(i*M+j,end, 1);
                continue;
            }
            int aaa=graph.add_edge(start, i*M+j, 1);
            for(int a=-1;a<2;a++){
            for(int b=-1;b<2;b++){
                if(abs(a)+abs(b)!=1)continue;
                 if(a+i<0||a+i>=N||b+j<0||b+j>=M)continue;
                 if(S.at(a+i).at(b+j)=='#')continue;
                    int aaaa=graph.add_edge(i*M + j, (i+a)*M + (j+b), 1);
                }
            }
        }
    }
    cout<<graph.flow(start,end)<<endl;

    for(auto edge: graph.edges()){
        if(edge.flow==0)continue;
        int from = edge.from;
        int to = edge.to;
        if(from==start || to==end)continue;

        int from_i = from/M;
        int from_j = from%M;
        int to_i = to/M;
        int to_j = to%M;
        //cout<<from_i<<" "<<from_j<<endl;
        //cout<<to_i<<" "<<to_j<<endl;
        if(from_i==to_i){
            if(from_j<to_j){
                S.at(from_i).at(from_j) = '>';
                S.at(from_i).at(from_j+1) = '<';
            }else{
                S.at(from_i).at(from_j) = '<';
                S.at(from_i).at(from_j-1) = '>';
            }
        }else if(to_j==from_j){
            if(from_i<to_i){
                S.at(from_i).at(from_j) = 'v';
                S.at(from_i+1).at(from_j) = '^';
            }else{
                S.at(from_i-1).at(from_j) = 'v';
                S.at(from_i).at(from_j) = '^';
            }
        }
    }
    rep(i,N){
        cout<<S.at(i)<<endl;
    }











    return 0;
}

Measured memory_bytes: 6300
#include <bits/stdc++.h>
using namespace std;
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();}
template<class T> inline T sqr(T x) {return x*x;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(v.begin(), v.end())
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 999999999
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    int n, m;
    int arr0[200001], arr1[200001];
    int a1, a2;
    cin >> n >> m;
    REP(i,n) {
        arr0[i] = 0;
        arr1[i] = 0;
    }
    REP(i,m) {
        cin >> a1 >> a2;
        if(a1 == 1 && a2 != 1) arr1[a2 - 1] = 1;
        else if(a2 == 1 && a1 != 1) arr1[a1 - 1] = 1;
        else if(a1 == n && a2 != n) arr0[a2 - 1] = 1;
        else if(a2 == n && a1 != n) arr0[a1 - 1] = 1;
    }
    REP(i,n) {
        if(arr1[i] == 1 && arr0[i] == 1) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE"<<endl;
    return 0;
}



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

import fileinput
import math

def main():

    while True:
        m, f, r = map(int, input().split())
        if ((m == -1) and (f == -1) and (r == -1)):
            break

        score = m + f
        if ((m == -1) or (f == -1)):
            print('F')
        elif (score >= 80):
            print('A')
        elif (score >= 65):
            print('B')
        elif (score >= 50):
            print('C')
        elif (score >= 30):
            if (r >= 50):
                print('C')
            else:
                print('D')
        else:
            print('F')

if __name__ == '__main__':
    main()

Measured memory_bytes: 7876
s = input()
n = int(input())
re = 1
head = ''
tail = ''

for i in range(n):
    q = input().split()
    if q[0] == '1':
        re = re * -1
    else:
        if re == 1:
            if q[1] == '1':
                head = q[2] + head
            else:
                tail = tail + q[2]
        else:
            if q[1] == '1':
                tail = tail + q[2]
            else:
                head = q[2] + head

print(head+s+tail) if re == 1 else print((head+s+tail)[::-1])

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

int main()
{
	const int N = 10000;
	int x = 0;
	for(int i = 1; i <= N ; i++)
	{
	    cin >> x;
		if ( x == 0 ){ break; }
		cout << "Case " << i << ": " << x << endl;
	}
	return 0;
}

Measured memory_bytes: 3004
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
    int n;

    cin>>n;

    vi w(n);

    rep(i, n) cin>>w[i];

    int ans=1e9;
    rep(t, n-1){
        int s1=0, s2=0; 
        rep(j, n){
            if(j<=t){
                s1+=w[j];
            }else{
                s2+=w[j];
            }
        }
        ans=min(ans, abs(s1-s2));
    }
    cout<<ans<<endl;
}


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

#include <stdio.h>
using namespace std;

int main(void) {
	string w, t;
	int count = 0;
	cin >> w;
	while (1) {
		cin >> t;
		if (t == "END_OF_TEXT") break;
		for (int i = 0; i < t.length(); i++) {
			if ('A' <= t[i] && t[i] <= 'Z')
				t[i] += 'a' - 'A';
		}
		if (w == t) count++;
	}
	cout << count << endl;
	return 0;
}



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

int main()
{
    cin >> N;
    if (N % 1000 == 0)
        cout << 0 << endl;
    else
    {
        cout << (N / 1000 + 1) * 1000 - N << endl;
    }
}


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

#define MAX 60

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

    vector<int> c_sum(n, 0);
    c_sum[0] = a[0][0];
    for(int i = 1; i < n; i++) {
        c_sum[i] = c_sum[i - 1] + a[0][i];
    }

    int sum = 0;
    for(int i = 0; i < n; i++) {
        int tmp_sum = c_sum[i];
        for(int j = i; j < n; j++) {
            tmp_sum += a[1][j];
        }
        sum = max(sum, tmp_sum);
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
/*
  AOJ 1136
  Polygonal Line Search
  
*/

#include<stdio.h>
#define LINE_MAX 51
#define LINE_PAT_MAX 8
struct point
{
  int x, y;
};

struct line
{
  int n;
  struct point points[10];
};


struct line lines_lot_pat[LINE_PAT_MAX];
/* 
   lot_and_rev_lines
   0 --> original
   1 --> left 90 lot
   2 --> left 180 lot
   3 --> left 270 lot
   4 --> reverse
   5 --> reverse 90 lot
   6 --> reverse 180 lot
   7 --> reverse 270 lot
*/

void make_patterns(void)
{
  int bias_x, bias_y, i, j, k, original_points_n = lines_lot_pat[0].n;
  for(i = 1; i < 4; i++)
    /* make original lot*/
    {
      lines_lot_pat[i].n = original_points_n;
      for(j = 0; j < original_points_n; j++)
	{
	  lines_lot_pat[i].points[j].x = lines_lot_pat[i - 1].points[j].y * (-1);
	  lines_lot_pat[i].points[j].y = lines_lot_pat[i - 1].points[j].x;
	}
    }

  for(j = original_points_n - 1, k = 0; j >= 0,  k < original_points_n; j--, k++)
    /* make reverse */
    {
      lines_lot_pat[i].n = original_points_n;
      lines_lot_pat[i].points[k].x = lines_lot_pat[0].points[j].x;
      lines_lot_pat[i].points[k].y = lines_lot_pat[0].points[j].y;
      if(k == 0)
	{
	  bias_x = lines_lot_pat[i].points[k].x;
	  bias_y = lines_lot_pat[i].points[k].y;
	}

      lines_lot_pat[i].points[k].x -= bias_x;
      lines_lot_pat[i].points[k].y -= bias_y;
    }


  for(j = i + 1; j < LINE_PAT_MAX; j++)
    {
      lines_lot_pat[j].n = original_points_n;
      for(k = 0; k < original_points_n; k++)
	{
	  lines_lot_pat[j].points[k].x = lines_lot_pat[j - 1].points[k].y * (-1);
	  lines_lot_pat[j].points[k].y = lines_lot_pat[j - 1].points[k].x;
	}
    }
}

void print_if_same(struct line l, int n)
{
  int i, j, f = 1;
  for(i = 0; i < LINE_PAT_MAX; i++)
    {
      if(l.n != lines_lot_pat[i].n)
	return ;
      for(j = 0; j < l.n; j++)
	{
	  if(l.points[j].x != lines_lot_pat[i].points[j].x || l.points[j].y != lines_lot_pat[i].points[j].y)
	    {
	      f = 0;
	      break;
	    }
	}
      if(f)
	{
	  printf("%d\n", n);
	  return ;
	}
      f = 1;
    }
  return ;
}


int main(voide)
{
  int line_n, point_n, i, j, k, bias_x, bias_y;
  struct line l;
  while(scanf("%d", &line_n), line_n)
    {
      scanf("%d", &lines_lot_pat[0].n);
      for(i = 0; i < lines_lot_pat[0].n; i++)
	{
	  scanf("%d %d", &lines_lot_pat[0].points[i].x, &lines_lot_pat[0].points[i].y);
	  if(i == 0)
	    {
	      bias_x = lines_lot_pat[0].points[i].x;
	      bias_y = lines_lot_pat[0].points[i].y;
	    }
	  lines_lot_pat[0].points[i].x -= bias_x;
	  lines_lot_pat[0].points[i].y -= bias_y;
	}

      make_patterns();

      for(j = 1; j <= line_n; j++)
	{
	  scanf("%d", &l.n);
	  for(i = 0; i < l.n; i++)
	    {
	      scanf("%d %d", &l.points[i].x, &l.points[i].y);
	      if(i == 0)
		{
		  bias_x = l.points[i].x;
		  bias_y = l.points[i].y;
		}
	      l.points[i].x -= bias_x;
	      l.points[i].y -= bias_y;
	    }
	  print_if_same(l, j);
	}
      printf("+++++\n");
    }
  return 0;
}

Measured memory_bytes: 612
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	ll ans = 0;
	rep(i, 1, N + 1){
		ll temp = i;
		ll sum = 0;
		while (temp != 0){
			sum += (temp - (temp / 10) * 10);
			temp /= 10;
		}
		if (A <= sum && sum <= B){
			ans += i;
		}
	}
	cout << ans << endl;
 	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    while(true){
        val (n, a, b, c, x) = readLine()!!.trim().split(' ').map(String::toInt)
        if (n == 0) return
        val lastCount = IntArray(c){-1}
        lastCount[x] = 0
        var current = x
        while(lastCount[(current * a + b) % c] == -1){
            lastCount[(current * a + b) % c] = lastCount[current] + 1
            current = (current * a + b) % c
        }
        val loopStart = lastCount[(current * a + b) % c]
        val loopLength = lastCount[current] + 1 - loopStart
        println(
                readLine()!!.trim().split(' ').map(String::toInt).fold(-1 as Int?){prev, target ->
                    prev?.let{frame ->
                        target.takeIf { target < c && lastCount[target] != -1}?.let{count ->
                            when {
                                lastCount[count] > frame -> lastCount[count]
                                lastCount[count] >= loopStart ->  (frame - lastCount[count] + loopLength) / loopLength * loopLength + lastCount[count]
                                else -> null
                            }
                        }
                    }
                }?.takeIf{it <= 10000} ?: -1
        )

    }
}


Measured memory_bytes: 42760
#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: 2740
#include <bits/stdc++.h>
using namespace std;

int main() {
int N,M;
  cin >> N >> M;
  vector<int> H(N);
  vector<int> A(M);
  vector<int> B(M);
  vector<int> C(N);
  int result = 0;
  for(int a = 0;a < N;a++)cin >> H[a];
  for(int a = 0;a < N;a++)C[a] = 1;
  for(int a = 0;a < M;a++){
   cin >> A[a];
    cin >> B[a];
    if(H[A[a] - 1] < H[B[a] - 1])C[A[a] - 1] = 0;
    if(H[A[a] - 1] > H[B[a] - 1])C[B[a] - 1] = 0;
    if(H[A[a] - 1] == H[B[a] - 1]){
      C[A[a] - 1] = 0;
      C[B[a] - 1] = 0;
    }
  }
  for(int a = 0;a < N;a++){
   if(C[a] == 1)result++;
  }
  cout << result << endl;
}

Measured memory_bytes: 4840
n=int(input())
a=[0]*4
for i in range(3,-1,-1):
    a[i]=n%10
    n=n//10
if a[0]+a[1]+a[2]+a[3]==7:
    print("{0}+{1}+{2}+{3}=7".format(a[0],a[1],a[2],a[3]))
elif a[0]+a[1]+a[2]-a[3]==7:
    print("{0}+{1}+{2}-{3}=7".format(a[0],a[1],a[2],a[3]))
elif a[0]+a[1]-a[2]+a[3]==7:
    print("{0}+{1}-{2}+{3}=7".format(a[0],a[1],a[2],a[3]))
elif a[0]-a[1]+a[2]+a[3]==7:
    print("{0}-{1}+{2}+{3}=7".format(a[0],a[1],a[2],a[3]))
elif a[0]+a[1]-a[2]-a[3]==7:
    print("{0}+{1}-{2}-{3}=7".format(a[0],a[1],a[2],a[3]))
elif a[0]-a[1]-a[2]+a[3]==7:
    print("{0}-{1}-{2}+{3}=7".format(a[0],a[1],a[2],a[3]))
elif a[0]-a[1]+a[2]-a[3]==7:
    print("{0}-{1}+{2}-{3}=7".format(a[0],a[1],a[2],a[3]))
else:
    print("{0}+{1}+{2}+{3}=7".format(a[0],a[1],a[2],a[3]))

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
 
int main(){
  int N,K;
  cin>>N>>K;
  double p[N];
  for(int i=0;i<N;i++){
    cin>>p[i];
    p[i]=(p[i]+1)/2;
  }
  
  double ans=0;
  for(int i=0;i<K;i++){
    ans=ans+p[i];
  }
  double d=ans;
  for(int i=0;i<N-K;i++){
    d=d-p[i]+p[K+i];
    ans=max(ans,d);
  }
  cout<<fixed<<setprecision(10);
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))


n = ni()
G = [list() for _ in range(n)]
for _ in range(n-1):
  a, b = nm()
  a -= 1; b -= 1
  G[a].append(b)
  G[b].append(a)
  
  
mod = 10**9 + 7
dub = [1]*(n+1)
for i in range(n):
  dub[i+1] = dub[i] * 2
  if dub[i+1] > mod:
    dub[i+1] -= mod
    
size = [-1]*n
q = [0]
while q:
  v = q[-1]
  if size[v] < 0:
    for x in G[v]:
      if size[x] < 0:
        q.append(x)
    size[v] = 0
  else:
    size[v] = 1
    for x in G[v]:
      size[v] += size[x]
    q.pop()

ans = 0
for v in range(n):
  c = 0
  res = 1
  for x in G[v]:
    if size[x] < size[v]:
      c += size[x]
      res += dub[size[x]] - 1
  res += dub[n-1-c] - 1
  res %= mod
  ans = (ans + dub[n-1] - res) % mod
print(ans * pow(dub[n], mod-2, mod) % mod)

Measured memory_bytes: 54648
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
typedef long long ll;
typedef unsigned long long ull;

void IO(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("test.txt","r",stdin);
    #endif
}

const int N=1e6+3,M=1e3+5,mod=1e9+7,dx[]={1,-1,0,0},
                                    dy[]={0,0,1,-1};
const double eps=1e-9;

int n,a,b,c;

int& get(char cc){
    if (cc == 'A')
        return a;
    else if (cc == 'B')
        return b;
    else
        return c;
}

vector<int> nxt[3];

int main(){
    IO();
    cin >> n >> a >> b >> c;
    int zeros = (a == 0) + (b == 0) + (c == 0);
    vector<char> v;
    vector<string> ss(n);
    for(int i = 0 ; i < n ; i++){
        cin >> ss[i];
        nxt[ss[i][0] - 'A'].push_back(i);
        nxt[ss[i][1] - 'A'].push_back(i);
    }
    for(int i = 0 ; i < n ; i++){
        string& s = ss[i];
        int& x = get(s[0]);
        int& y = get(s[1]);
        if (x == 1 && y == 1){
            int p = s[0] - 'A';
            int nxt_x = upper_bound(nxt[p].begin(),nxt[p].end(),i) - nxt[p].begin();
            if (nxt_x == sz(nxt[p]))
                nxt_x = 1e9;
            else
                nxt_x = nxt[p][nxt_x];
            p = s[1] - 'A';
            int nxt_y = upper_bound(nxt[p].begin(),nxt[p].end(),i) - nxt[p].begin();
            if (nxt_y == sz(nxt[p]))
                nxt_y = 1e9;
            else
                nxt_y = nxt[p][nxt_y];
            if (nxt_x < nxt_y){
                x++;
                y--;
                v.push_back(s[0]);
            }
            else{
                x--;
                y++;
                v.push_back(s[1]);
            }
        }
        else if (x < y){
            x++;
            y--;
            v.push_back(s[0]);
        }
        else{
            x--;
            y++;
            v.push_back(s[1]);
        }
        
        if (a < 0 || b < 0 || c < 0){
            assert(zeros >= 2);
            return !printf("No\n");
        }
    }
    printf("Yes\n");
    for(auto c : v)
        printf("%c\n",c);
}


Measured memory_bytes: 7752
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a := nextFloat()
	b := nextFloat()
	fmt.Printf("%v %v %f\n", int(a)/int(b), int(a)%int(b), a/b)
}



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

int main(){
    ll n,k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i=k; i<=n+1; i++){
      ll mn = i*(i-1)/2;
      ll mx = (n+(n-i+1))*i/2;
      ans += (mx-mn+1)%1000000007;
      //cout << mx-mn+1 << endl;
    }
    cout << ans%1000000007 << endl;
}

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

int main(){
  int k;
  cin>>k;
  int n,m;
  cin>>n>>m;
  for(int i=0;i<1e3;i++){
    if(n<=i*k&&i*k<=m){
      cout<<"OK"<<endl;
      return 0;
    }
  }
  cout<<"NG"<<endl;
  return 0;
}

Measured memory_bytes: 3636
use std::collections::VecDeque;
use std::io::*;
struct Io<'a> {
    r: BufReader<StdinLock<'a>>,
    w: BufWriter<StdoutLock<'a>>,
    buf: VecDeque<String>,
    buf_str: String,
}
impl<'a> Io<'a> {
    fn r<T: std::fmt::Debug, S: std::str::FromStr<Err = T>>(&mut self) -> S {
        if self.buf.len() == 0 {
            self.r.read_line(&mut self.buf_str).unwrap();
            for w in self.buf_str.split_whitespace() {
                self.buf.push_back(w.to_owned());
            }
        }
        self.buf.pop_front().unwrap().parse().unwrap()
    }
    fn w<T: std::fmt::Display>(&mut self, v: T) {
        writeln!(self.w, "{}", v).unwrap();
    }
    fn iter<'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>>(
        &'b mut self,
    ) -> IoIter<'a, 'b, T, S> {
        IoIter {
            io: self,
            p: std::marker::PhantomData,
            q: std::marker::PhantomData,
        }
    }
}
struct IoIter<'a: 'b, 'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>> {
    io: &'b mut Io<'a>,
    p: std::marker::PhantomData<T>,
    q: std::marker::PhantomData<S>,
}
impl<'a, 'b, T: std::fmt::Debug, S: std::str::FromStr<Err = T>> Iterator for IoIter<'a, 'b, T, S> {
    type Item = S;
    fn next(&mut self) -> Option<S> {
        Some(self.io.r())
    }
}
fn main() {
    let stdin = stdin();
    let stdout = stdout();
    let r = BufReader::new(stdin.lock());
    let w = BufWriter::new(stdout.lock());
    let io = Io {
        r: r,
        w: w,
        buf: VecDeque::new(),
        buf_str: String::new(),
    };
    problem(io);
}

fn problem(mut io: Io) {
    let x: usize = io.r();
    let y: usize = io.r();
    let z: usize = io.r();
    println!("{} {} {}", z, x, y);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
using namespace std;
 
int num[100005];
 
int main() {
    int n;
    cin >> n;
 
    fill(num, num+100005, 0);
 
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        num[a] ++;
        num[a+1] ++;
        num[a+2] ++;
    }
 
    cout << *max_element(num, num+100005) << endl;
    return 0;
}

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

int main(){
  ll i,N,K,a,b;
  cin>>N>>K;
  vector<data> v(N);
  rep(i,N)cin>>v[i].first>>v[i].second;
  sort(v.begin(),v.end());
  rep(i,N){
    K-=v[i].second;
    if(K<=0){cout<<v[i].first;return 0;}
  }
  return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <iostream>
int main(void) {
	int n;
	while (std::cin >> n) {
		const int mod = 1000000007;
		int stack = 0, *arr;
		long long ans = 1;
		arr = new int[n];
		for (int i = 0; i < n; ++i) {
			std::cin >> arr[i];
		}
		for (int i = 0; i < n; ++i) {
			if (arr[i] < 2 * ++stack - 1) {
				ans *= stack--;
				ans %= mod;
	   		}
		}
		for (int i = 0; i < stack; ++i) {
			ans *= i + 1;
			ans %= mod;
		}
		std::cout << ans << std::endl;
		delete[] arr;
	}
	return EXIT_SUCCESS;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    int h,w;
    cin>>h>>w;
    map<char,int> mp;
    rep(i,h){
        rep(j,w){
            char c;
            cin>>c;
            mp[c]++;
            mp[c]%=4;
        }
    }

    int cnt2=0,cnt13=0;
    for(auto p : mp){
        if(p.second==2) cnt2++;
        if(p.second==1 || p.second==3) cnt13++;
    }

    if(h%2==0 && w%2==0){
        if(cnt2>0 || cnt13>0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    else if(h%2==1 && w%2==1){
        if(cnt13>1 || cnt2>(w/2+h/2)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    else{
        if(w%2!=0) swap(w,h);
        if(cnt2>w/2 || cnt13>0){
            cout<<"No"<<endl;
            return 0;
        }
    }


    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
void solve(){
    int k;
   string s;
   cin>>k>>s;
   if(s.length()<=k){
       cout<<s<<endl;
   }else{
       for(int i=0;i<k;i++){
           cout<<s[i];
       }
       cout<<"...";
       cout<<endl;
   }
}
int main(){
    int t;
    t = 1;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
int main(){
    long long a,m=1000000000000005,n,x;
    cin>>n;
    REP(i,5){
        cin>>a;
        m=min(m,a);
    }
    x=n/m;
    if(n%m>0) x++;
    cout<<x+4<<endl;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll n, a, b, c, d;

int main(){
    cin >> n >> a >> b >> c >> d;
    ll x = abs(b-a);
    for(ll i = 0; i <= n-1; i++) {
        if(d*(n-1-i)-i*c >= x && c*(n-1-i)-i*d <= x) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}
































Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;
const int maxn=10015,inf=0x3f3f3f3f;
typedef pair<int,int>P;
struct edge{
	int to,dis,cost;
	edge(){}
	edge(int to,int dis,int cost):to(to),dis(dis),cost(cost){}
};
vector<edge>g[maxn];
int d[maxn],n,m,ans;

void dij(int s){
	priority_queue<P,vector<P>,greater<P> > que;
	fill(d,d+n,inf);
	d[s]=0;
	que.push(P(0,s));
	while(!que.empty()){
		P p=que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(int i=0;i<g[v].size();i++){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.dis){
				d[e.to]=d[v]+e.dis;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}
int main()
{
	//freopen("read.txt", "r", stdin);
	while(cin>>n>>m&&n){
		for(int i=0;i<n;i++){
			g[i].clear();
		}
		for(int i=0;i<m;i++){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			a--;b--;
			g[a].push_back(edge(b,c,d));
			g[b].push_back(edge(a,c,d));
		}
		dij(0);
		ans=0;
		for(int i=1;i<n;i++){
			int min_cost=inf;
			for(int j=0;j<g[i].size();j++){
				if (d[g[i][j].to] + g[i][j].dis == d[i] && g[i][j].cost < min_cost)
				{
					min_cost = g[i][j].cost;
				}
			}
			ans+=min_cost;
		}
		cout<<ans<<endl;
	}
	//fclose(stdin);
	return 0;
}

Measured memory_bytes: 4956
lines = []
for i in range(2):
    lines.append(input())
num = int(lines[0])

out = 1
split = lines[1].split()
if "0" in split:
    out = 0
for i in range(num):
    out = int(split[i]) * out 
    if out > 1000000000000000000:
        out = - 1    
        break
print(out)

Measured memory_bytes: 19344