akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  C - Grid Repainting 2
//
//  Created by 张栩浩 on 2018/5/5.
//  Copyright © 2018年 张栩浩. All rights reserved.
//

#include <iostream>
using namespace std;
#define maxn 10001
char map[maxn][maxn];
int h,w;
bool judge(int x,int y)
{
    if(x+1>=0&&x+1<h&&y>=0&&y<w){
        if(map[x+1][y]=='#') return true;
    }
  
    if (x-1>=0&&x-1<h&&y>=0&&y<w) {
        if(map[x-1][y]=='#') return true;
    }
    if (x>=0&&x<h&&y+1>=0&&y+1<w) {
        if(map[x][y+1]=='#') return true;
    }
    if (x>=0&&x<h&&y-1>=0&&y-1<w) {
        if(map[x][y-1]=='#') return true;
    }
    return false;
}
int main()
{
    cin>>h>>w;
    int i,j;
    for(i=0;i<h;i++)
        for(j=0;j<w;j++)
        {
            cin>>map[i][j];
        }
    bool flage=false;
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            if(map[i][j]=='#')
            {
                if(judge(i, j)) continue;
                else
                {
                    flage=true;
                    break;
                }
            }
        }
        if(flage) break;
    }
    if(flage)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}


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

int selectionSort(int A[], int N){
  int i, j,t,sw=0,minj;
  for(i = 0;i<N-1;i++){
    minj = i;
    for(j = i;j<N;j++){
      if(A[j] < A[minj])minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if(i != minj) sw++;
  }
  return sw;  
}



int main(){
  int A[100],N,i,sw;

  scanf("%d", &N);
  for(i = 0;i<N;i++) scanf("%d", &A[i]);

  sw = selectionSort(A,N);
  
  for(i = 0;i<N;i++){
    if( i>0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);
  
 }


Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
#define spn setprecision
#define fr(x,a,b,c) for(int x = a; x <= b; x+=c)
using namespace std;
ll multiply(ll num1, ll num2, ll mod) { // with mod > 1e9
	ll ans = 0;
	num1 %= mod;
	num2 %= mod;
	while (num2) {
		if (num2&1) {
			ans += num1;
			ans %= mod;
		}
		num1 *= 2;
		num1 %= mod;
		num2 /= 2;
	}
	return ans;
}
ll powmod2(ll base,ll exponent,ll mod){ // with mod > 1e9
	ll ans = 1;
	while (exponent) {
		if (exponent&1) {
			ans = multiply(ans, base, mod);
		}
		base = multiply(base, base, mod);
		exponent /= 2;
	}
	return ans;
}
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int main() {
	int n;
	sd(n);
	if(n&1){
		pd(2*n);
	}
	else{
		pd(n);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;

 
int main(){
    string s = "";
    cin >> s;
    long long int n = s.size();
  
    long long int t = 0;    
    long long int tens = 1;

    long long int ans = 0;

    vector<long long int> mod(n);
    mod[0] = 1;
    for(int i=1;i<n;i++){
        mod[i] = 0;
    }
  
    for(int i=n-1;i>=0;i--){
        int tmp = (int)(s[i] - '0');
        t = (t + tens*tmp%2019)%2019;
        ans += mod[t];
        mod[t]++;
        tens = tens*10%2019;
    }

    cout << ans << endl;
}   

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    long alice = 0, bob = 0;
    for(int i = 0; i < n; i++){
        if(i%2==0){
            alice += a[i];
        }else{
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S,T;
    cin>>S>>T;
    int A,B;
    cin>>A>>B;
    string U;
    cin>>U;
    if(U==S){
        A--;
    }
    else{
        B--;
    }
    cout<<A<<" "<<B<<endl;
    return 0;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void solve() {
	ll X;
	cin>>X;
	if (X == 7 or X==5 or X==3)cout<<"YES\n";
	else cout<<"NO\n";
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define SaveTime ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define mx *max_element
#define mi *min_element
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e6+5;
const int INF = 1e18L;
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}
#define pi acos(-1)
int ar[N];
int tree[2*N];
int dp[N];
int bit[N];
signed main(){
 	SaveTime;
	int T=1;
	// cin >> T;
	while(T--){
		double a, b ,x;
		cin >> a >> b >> x;
		double s = x/a;
		double ans ;
		if(s>=(a*b)/2){
			double h = (a*b -s)/a*2;
			ans = atan2(h,a);
		}
		else{
			double w = s*2/b;
			ans = atan2(b,w);
		}
	cout << fixed << setprecision(10) << ans/(2*pi)*360 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int A[1<<20], N;
ll ans = 0;
ll maxm[1<<20];

ll answer_of(ll x, int j, ll y, int i) {
  int l = 0;
  // x*2^l < y : maxl
  while(x*(1LL << l) < y) l++;l--;

  return x*((1LL << (l+1)) - 1) + y*(i-j-l) - x;
}

int main() {

//  freopen("input.in","r",stdin);
//  freopen("output.out","w",stdout);
  cin>>N;N++;
  rep(i, N) cin >> A[i];

  if(N == 1) {
    if(A[0] == 1) {
      cout << 1 << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  if(A[0] != 0) {
    cout << -1 << endl;
    return 0;
  }

  maxm[0] = 1;int i = 0;
  repi(j,1,N-1) {
    if(A[j] != 0) {
      if(j-i >= 45) maxm[j] = 1e13 - A[j];
      else if((1LL << (j-i)) <= (1e13)/maxm[i]) {
        maxm[j] = maxm[i]*(1LL << (j-i)) - A[j];
      } else {
        maxm[j] = 1e13 - A[j];
      }

      if(maxm[j] <= 0) {
        cout << -1 << endl;
        return 0;
      }

      i = j;
    }
  }

  int j = N-2; i = N-1;
  ll val = A[j+1], valf = A[j+1];
  while(j >= 0) {
    val = (val+1)/2;
    if(maxm[j] != 0) {
      if(maxm[j] < val) {
        cout << -1 << endl;
        return 0;
      }
      maxm[j] = min(maxm[j], valf);

      // maxm[j] (j), valf (i)
      ans += answer_of(maxm[j], j, valf, i);
      // debug(ans);

      val = valf = maxm[j] + A[j];
      i = j;
    }

    j-=1;
  }

  // rep(i,N) cout << A[i] << " ";cout<<endl;
  // rep(i,N) cout << maxm[i] << " ";cout<<endl;
  cout << ans+1;




  return 0;
}


Measured memory_bytes: 4800
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = list(s())
S.reverse()
for i in range(10**5):
    if not S:
        break

    if ''.join(S[:7][::-1]) == 'dreamer' :
        S = S[7:]
    elif ''.join(S[:6][::-1]) == 'eraser':
        S = S[6:]
    elif ''.join(S[:5][::-1]) == 'dream':
        S = S[5:]
    elif ''.join(S[:5][::-1]) == 'erase':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 11316
def nbasesum(value,n):
    nbasevalue = 0
    while value >= n:
        nbasevalue += value%n
        value //= n
    nbasevalue += value
    return nbasevalue

N = int(input())
ans = nbasesum(N,9)

for i in range(N+1):
    c6 = i
    c9 = N-i
    ans = min(ans, nbasesum(c9,9)+nbasesum(c6,6))

print(ans)


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
    Scanner sc = new Scanner(System.in);
    StringBuilder out;
 
    void run() {
        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; i++) {
            A[i] = sc.nextInt();
        }
        out = new StringBuilder();
        print(A);
        for (int i = 1; i < N; i++) {
            int v = A[i];
            int j = i - 1;
            while (j >= 0 && A[j] > v) {
                A[j + 1] = A[j];
                j--;
            }
            A[j + 1] = v;
            print(A);
        }
        System.out.print(out);
    }
 
    void print(int[] A) {
        for (int i = 0; i < A.length; i++) {
            out.append((i == 0 ? "" : " ") + A[i]);
        }
        out.append("\n");
    }
 
    void debug(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
 
    public static void main(String[] args) {
        new Main().run();
    }
}


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

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

using namespace std;

int main(){
	int n,m; cin>>n>>m;
	int s[10]={};
	rep(i,m){
		int k; cin>>k;
		rep(j,k){ int a; cin>>a; a--; s[a]|=1<<i; }
	}
	int p[10];
	rep(i,m) cin>>p[i];

	int ans=0;
	rep(S,1<<n){
		int x=0;
		rep(i,n) if(S&(1<<i)) x^=s[i];
		rep(i,m) x^=p[i]<<i;
		if(x==0) ans++;
	}
	cout<<ans<<endl;

	return 0;
}


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

int main() {
  for (int i=0; ; ) {
    int sum = 0;
    string x;
    cin >> x;
    if(x == "0") break;
    for (int j=0; j<1000; j++) {
      char c = x.at(j);
      int number = c - '0';
      sum += number;
      if(j+1 == x.size()) { 
        cout << sum << endl;
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <set>

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> a;

  for (int i = 0; i < n; i++) {
    int _; cin >> _;
    a.push_back(_);
  }

  set<int> x;
  x.insert(a[0]);

  for (int i = 1; i < n; i++) {
    set<int>::iterator it = x.lower_bound(a[i]);

    if (it != x.end())
      x.erase(*it);

    x.insert(a[i]);
  }

  cout << x.size() << endl;
}

Measured memory_bytes: 6028
#include<iostream>
#include<algorithm>
#include<cassert>
#include<cmath>
#include<vector>
#include<iomanip>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

int K;
double L,R,P,E,T;

double dfs(int depth,double l,double r)
{
  double t = (l+r)/2.0;
  if(depth >= K)
    {
      if(fabs(T-t)<E)return 1;
      return 0;
    }  

  if(l < T-E || T+E < r)return 0;
  if(T-E <= r && l <= T+E)return 1;

  if(T <= t)
    {
      return (1-P)*dfs(depth+1,t,r) + P*dfs(depth+1,l,t);
    }
  else 
    {
      return (1-P)*dfs(depth+1,l,t) + P*dfs(depth+1,t,r);
    }

}

int main()
{
  cin >> K >> R >> L >> P >> E >> T;
  cout << setiosflags(ios::fixed) << setprecision(5) << dfs(0,L,R) << endl;
  return 0;
}

Measured memory_bytes: 1292
#include <stdio.h>
//int fib(int);

int Fib[44];
int main() {
  int i,n;
  Fib[0]=1;
  Fib[1]=1;
  for (i = 2; i < 45; i++) {
    Fib[i] = Fib[i-1]+Fib[i-2];
  }
  scanf("%d",&n);
  printf("%d\n",Fib[n]);
  return 0;
}
/* int fib(int n){


} */



Measured memory_bytes: 2108
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,K = map(int,input().split())
A = list(map(int,input().split()))
amax = max(A)
if K>amax:
    print("IMPOSSIBLE")
else:
    a = A[0]
    for i in range(1,N):
        a = gcd(a,A[i])
    if (amax-K)%a == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[5];
  scanf("%s",a);
  if(a[0]==a[1]&&a[0]==a[2]||a[1]==a[2]&&a[1]==a[3]) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 256
a = []
for _ in range(int(input())):
    x, y = map(int, input().split())
    a.append((x, y))

for i in range(2, len(a)):
    if a[i-2][0] == a[i-2][1] and a[i-1][0] == a[i-1][1] and a[i][0] == a[i][1]:
        print('Yes')
        break
else:
    print('No')



Measured memory_bytes: 62372
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second


int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    ll N, x;
    cin >> N >> x;
    vector<ll > A;
    rep (i, N) {
        ll a;
        cin >> a;
        A.pb(a);
    }
    ll ans = 0;
    if (A[0] > x) {
        ll d = A[0] - x;
        ans += d;
        A[0] -= d;
    }
    rep (i, N - 1) {
        if (A[i] + A[i + 1] > x) {
            ll d = A[i] + A[i + 1] - x;
            ans += d;
            A[i + 1] -= d;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
s = input()
sn = len(s)

tmp = 0
for i in range(sn):
    for j in range(i + 1, sn + 1):
        t = s[i : j]
        tn = len(t)
        #print(t)
        cnt_t = 0
        for k in range(tn):
            if t[k] == "A" or t[k] == "G" or t[k] == "C" or t[k] == "T":
                cnt_t += 1
                #print(cnt_t)
                if cnt_t == tn and tmp < j - i:
                    tmp = j - i

print(tmp)


Measured memory_bytes: 8892
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);
    map<int, int> m;
    lint ret = 0;
    FOR(i, 0, N) {
        int v = i - A[i];
        ret += m[v];
        m[i + A[i]]++;
    }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 21048
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int n;
	while(scanf("%d", &n), n){
		vi nums(n, 0);
		reep(i, 1, n)
			nums[(i*i)%n] |= 1;
		reep(i, 1, (n+1)/2){
			int sum = 0;
			rep(j, n)
				sum += nums[j] & nums[(j+i)%n];
			printf("%d\n", sum * 2);
		}
	}
	
	return 0;
}

Measured memory_bytes: 848
import Foundation

let NAB = readLine()!.components(separatedBy: " ")
let S = readLine()!

let N = Int(NAB[0])!
let A = Int(NAB[1])!
let B = Int(NAB[2])!

var curr_passed = 0
var curr_b_rank = 0

for c in S {
    switch c {
    case "a": do {
        if curr_passed < A + B {
            print("Yes")
            curr_passed += 1
        } else {
            print("No")
        }
    }
    case "b": do {
        curr_b_rank += 1
        if curr_passed < A + B, curr_b_rank <= B {
            print("Yes")
            curr_passed += 1
        } else {
            print("No")
        }
    }
    case "c": do {
        print("No")
    }
    default:
        assert(false)
    }
}


Measured memory_bytes: 14288
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int m;
    cin>>m;
    int d,y,n;
    int f,c;
    double p;
    while(m--){
        cin>>d>>y>>n;
        int mx=0;
        rep(i,n){
            int td=d;
            cin>>f>>p>>c;
            if(f==0){
                int cnt=0;
                rep(j,y){
                    cnt+=p*td;
                    td-=c;
                }
                td+=cnt;
            }
            else{
                rep(j,y){
                    td=p*td+td;
                    td-=c;
                }
            }
            mx=max(mx,td);
        }
        cout<<mx<<endl;
    }
    return 0;
}


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

class Bit {
public:
	vector<ll> seg;
	ll segsize;
	// コンストラクタは型指定しちゃダメ
	Bit(ll);
	void add(ll, ll);
	ll sum(ll);
};
Bit::Bit(ll size) {
	segsize = size + 1;
	for (ll i = 0; i < segsize; i++) seg.push_back(0);
}
// その数とLSB(最も低い桁のbit1)を順次加算していったものを更新
// セグメントツリーの左側のみ足していくイメージ
// idx=0だと無限ループする1idx用
void Bit::add(ll idx, ll val) {
	idx++;
	while (idx < segsize) {
		seg[idx] += val;
		// idx|(-idx)がLSBになるらしい。2の補数ってそういうこと？
		idx += (idx & (-idx));
	}
}
// その数とLSB(最も低い桁のbit1)を順次減算していったものを加算
ll Bit::sum(ll idx) {
	idx++;
	ll res = 0;
	while (idx > 0) {
		res += seg[idx];
		idx -= (idx & (-idx));
	}
	return res;
}

ll n, q, lriIdx, lft2, rgt2, idx2;
vector<ll> c, bfr, rgts, ans;
vector<tuple<ll, ll, ll>> lri;

void solver() {
//	cin.tie(0);
//	ios::sync_with_stdio(0);

	cin >> n >> q;
	for (ll i = 0; i < n; i++) {
		ll ci;
		cin >> ci;
		ci--;
		c.push_back(ci);
	}
	for (ll i = 0; i < q; i++) {
		ll l, r;
		cin >> l >> r;
		l--;
		r--;
		lri.push_back( { l, r, i });
	}
	for (ll i = 0; i < n; i++) {
		bfr.push_back(-1);
		rgts.push_back(-1);
	}
	for (ll i = 0; i < n; i++) {
		if (bfr[c[i]] != -1) {
			rgts[bfr[c[i]]] = i;
		}
		bfr[c[i]] = i;
	}
	Bit rbit(n);

	for (ll i = 0; i < q; i++) {
		ans.push_back(-1);
	}
	sort(lri.begin(), lri.end(), greater<tuple<ll, ll, ll>>());
	lriIdx = 0;
	lft2 = get<0>(lri[lriIdx]);
	rgt2 = get<1>(lri[lriIdx]);
	idx2 = get<2>(lri[lriIdx]);
	lriIdx++;
	for (ll lft = n - 1; lft >= 0; lft--) {
		if (rgts[lft] != -1) rbit.add(rgts[lft], 1);
		while (lft == lft2) {
			ans[idx2] = rgt2 - lft2 + 1 - (rbit.sum(rgt2));
			if (lriIdx == q) break;
			lft2 = get<0>(lri[lriIdx]);
			rgt2 = get<1>(lri[lriIdx]);
			idx2 = get<2>(lri[lriIdx]);
			lriIdx++;
		}
	}
	for (auto aaa : ans) cout << aaa << endl;
}

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


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

int main() {
	int N = 0;
	cin >> N;
	int hundred = N / 100;
	int ideal = hundred + hundred * 10 + hundred * 100;
	int answer = ideal;
	if (N > ideal) {
		hundred++;
		answer = hundred + hundred * 10 + hundred * 100;
	}
	cout << answer << endl;
}

Measured memory_bytes: 256
N,M=map(int, raw_input().split())
A=map(int, raw_input().split())

match=[None,2,5,5,4,5,6,3,7,6]

dp=[ None for i in range(N+1) ] 
dp[0]=""


for i in range(N):
	if dp[i] is not None:
		for a in A:
			match_cnt=match[a]
			if 0<=i+match_cnt<=N:
				if dp[i+match_cnt] is None:
					dp[i+match_cnt]=dp[i]+str(a)
				else:
					if len(dp[i+match_cnt]) < len( dp[i]+str(a) ):
						dp[i+match_cnt]=dp[i]+str(a)
					else:
						dp[i+match_cnt]=max( dp[i+match_cnt], dp[i]+str(a) )
									

print dp[N]

Measured memory_bytes: 57372
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>

using namespace std;

int main()
{
	string s, ans = {""};
	for (int i = 0; i < 3; i++) {
		cin >> s;
		s[0] -= 32;
		ans += s[0];
	}
	cout << ans << endl;;
}


Measured memory_bytes: 256
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

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

    target = 1
    for i in A:
        if i == target:
            target += 1
    
    if target == 1:
        print(-1)
        return

    print(N - target + 1)


main()

Measured memory_bytes: 31280
/**
 * @author torith
 * @date 2018-11-01
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;


bool dfs(int start, string S){
    bool rtn = false;
    if(S.size() == start) return true;
    if (start + 4 < S.size() && (S.substr(start, 5) == "dream" || S.substr(start, 5) == "erase")) {
        if(dfs(start+5, S)) return true;
    }
    if (start + 6 < S.size() && S.substr(start, 7) == "dreamer") {
        if(dfs(start+7, S)) return true;
    }
    if (start + 5 && S.substr(start, 6) == "eraser") {
        if(dfs(start+6, S)) return true;
    }
    return false;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;

    if(dfs(0,S)) cout << "YES" << "\n";
    else cout << "NO" << "\n";

    return 0;
}



Measured memory_bytes: 2384
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64)::a, i,j,k,ans
    read*, a

    ans=0
    do i = 1, a
        do j = 1, a
            do k = 1, a
                ans= ans+ gcd(i,gcd(j,k))
            end do
        end do
    end do
    print*, ans


contains
recursive function gcd(x,y) result(ret)
    integer(int64):: x,y,ret

    if (mod(x,y) == 0) then
        ret = y
        RETURN
    end if

    ret = gcd(y,mod(x,y))
    
end function
end program name

Measured memory_bytes: 2796
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int maxn = 540000;
char s[maxn];
int A[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> (s + 1);
    int n = strlen(s + 1) + 1;
    for(int i = 1; i <= n; i += 1) if(s[i] == '<') A[i + 1] = max(A[i + 1], A[i] + 1);
    for(int i = n; i >= 1; i -= 1) if(s[i] == '>') A[i] = max(A[i], A[i + 1] + 1);
    LL ans = 0;
    for(int i = 1; i <= n + 1; i += 1) ans += A[i];
    cout << ans;
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n;
  cin >> n;
  int a[n];
  REP(i,n) cin >> a[i];
  sort(a,a+n);
  if (n & 1) {
    cout << 0 << endl;
    return;
  }
  int ans = 0;
  REP(i,100010) {
    if (upper_bound(a,a+n,i) - a == n/2) ans++;
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){

  /* Regular */
  int case_num = 1;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  
  // /* AOJ */
  // solve();
  return 0;
}

Measured memory_bytes: 640
#include<math.h>
#include<iomanip>
#include<iostream>
using namespace std;


int main()
{
	double x1, x2, y1, y2, d;
	cin >> x1 >> y1 >> x2 >> y2;

	d = pow((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1), 0.5);
	cout << fixed << setprecision(6) << d << endl;
	
	return 0;
}


Measured memory_bytes: 3448
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] w = new int[N];
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }
        long[][] dp = new long[N+1][W+1];
        for (int i = 1; i < N+1; i++) {
            for (int j = 0; j < W+1; j++) {
                dp[i][j] = dp[i-1][j]; //case1: Do not use i-th item
                int diff = j - w[i-1];
                if (diff >= 0) {
                    dp[i][j] = Math.max(dp[i][j], dp[i-1][diff] + v[i-1]);
                }
            }
        }
        long ans = dp[N][W];
        System.out.println(ans);
    }
}

Measured memory_bytes: 125652
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int n,a[maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
    for(int i=1;i<=n;++i)
    if(i+1>a[i+1])
    {
        int ans=0;
        for(int j=i+1;a[j]>i-1;++j)ans^=1;
        ans|=(a[i]-i)&1;
        if(ans)printf("First");
        else printf("Second");
        return 0;
    }
}

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

using namespace std;

namespace {
    int V, E;
    int S, T;

    struct Edge {
        int from, to, cap, rev, index;
        Edge() {}
        Edge(int from, int to, int index, int cap, int rev) : from(from), to(to), index(index), cap(cap), rev(rev) {}
    };
    vector< vector<Edge> > G;
    vector<bool> used;
    void init() {
        G.clear(); G.resize(V);
        used.clear(); used.resize(V);
    }
    void addEdge(int from, int to, int index) {
        G[from].push_back(Edge(from, to, index, 1, G[to].size()));
        G[to].push_back(Edge(to, from, index, 1, int(G[from].size()) - 1));
    }
    int dfs(int v, int t, int f) {
        if (v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            Edge& e = G[v][i];
            if (!used[e.to] && e.cap > 0) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    int maxflow(int s, int t) {
        int flow = 0;
        while (true) {
            fill(used.begin(), used.end(), false);
            int f = dfs(s, t, 1e9);
            if (f == 0) return flow;
            flow += f;
        }
    }

    vector< vector<bool> > U;
    void input() {
        cin >> V >> E;
        init();
        U.clear(); U.resize(V, vector<bool>(V, false));
        for (int i = 0; i < E; i++) {
            int x, y; cin >> x >> y;
            x--; y--;
            U[x][y] = true;
            addEdge(x, y, i);
        }
        cin >> S >> T;
        S--; T--;
    }

    void solve() {
        cout << maxflow(S, T) << endl;
        vector<int> ans;
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < G[i].size(); j++) {
                Edge& e = G[i][j];
                if (e.cap == 0 && U[e.to][e.from]) {
                    ans.push_back(e.index);
                }
            }
        }
        cout << ans.size() << endl;
        for (int i = 0; i < ans.size(); i++) cout << ans[i] + 1 << endl;
    }
}

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

Measured memory_bytes: 1352
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] group = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
        if(group[sc.nextInt()] == group[sc.nextInt()]){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21844
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    l=parseInt(readline())
    println((l/3)^3)
end
main()

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

int main()
{
	ll i,j,n,s,p=0;
	cin>>n;
	vector<ll> v,vv(250000);
	for(i=1;i<n;i++)
	{
		ll a;
		cin>>a;
		v.push_back(a);
		vv[a]++;
		
	}
	for(i=1;i<=n;i++)
	{
		cout<<vv[i]<<"\n";
	}
}

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

int main()
{
  int a, b;
  
  std::cin >> a >> b;
  
  if (b == 100) {
	a *= 1000;
  } else if (b >= 10) {
    a *= 100;
  } else {
    a *= 10;
  }

  int c = a+b;
  int n = (int) std::sqrt(c);
  if (n*n == c) {
   std::cout << "Yes" << std::endl;
  } else {
   std::cout << "No" << std::endl;
  }
  return 0;
}

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

int main(){
  int x,y,a,b,c;
  cin >>x>>y>>a>>b>>c;
  priority_queue<int> A;
  priority_queue<int> B;
  priority_queue<int> C;
  priority_queue<int, vector<int>, greater<int>>eat;
  rep(i,a){
  	int p;
    cin >>p;
    A.push(p);
  }
  rep(i,b){
  	int p;
    cin >>p;
    B.push(p);
  }
  rep(i,c){
  	int p;
    cin >>p;
    C.push(p);
  }
  rep(i,x){
  	int p;
    p=A.top();A.pop();
    eat.push(p);
  }
  rep(i,y){
  	int p;
    p=B.top();B.pop();
    eat.push(p);
  }
  rep(i,x+y){
  	if(i==c){break;}
  	int p,q;
    p=eat.top();eat.pop();
  	q=C.top();C.pop();
    if(q>p){eat.push(q);}
    else{eat.push(p);break;}
  }
  ll ans=0;
  rep(i,x+y){
  	ans+=eat.top();
  	eat.pop();
  }
  cout<<ans;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  vector<char> a;
  rep(i,4){
    a.push_back(s.at(i));
  }
  sort(a.begin(),a.end());
  if(a.at(0) == a.at(1) && a.at(2) == a.at(3) && a.at(0) != a.at(2)) cout << "Yes" << endl;
  else cout << "No" << endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   string arr[3];
   map<string,ll> ma;
   ma["Sunny"] = 0, ma["Cloudy"] = 1, ma["Rainy"] = 2;
   arr[0] = "Sunny";
   arr[1] = "Cloudy";
   arr[2] = "Rainy";
   
   string s;
   cin>>s;
   
   ll temp = ma[s];
   cout<<arr[(temp+1)%3];
   
   return 0;
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

acum1=[0]
for i in range(n):
	acum1.append(acum1[-1]+a[i])
acum2=[0]
for i in range(m):
	acum2.append(acum2[-1]+b[i])
ans = 0
j = m
for i in range(n + 1):
	if acum1[i] > k:
		break
	while (j > 0) and (acum1[i] + acum2[j] > k):
		j -= 1
	ans = max(ans, i + j)
print(ans)


Measured memory_bytes: 47500
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  int count=0,m_count=0;
  for(int i=1;i<=n;i++){
    count=0;
    if(i%2==0) continue;
    //if(i==sqrt(i)*sqrt(i)) continue;
    for(int j=1;j<=i;j++){
      if(i%j==0) count++;
    }
    if(count==8) m_count++;
  }
  cout<<m_count;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;
        return 0;
    }
    string ans = "";
    if(SZ(s) < 26){
        for(char i = 'a'; i <= 'z'; i++){
            bool f = 0;
            rep(j, SZ(s)){
                if(s[j] == i) f = 1;
            }
            if(!f){
                ans = s + i;
                break;
            }
        }
    }else{
        for(int i = SZ(s)-1; i >= 1; i--){
            if(s[i-1] < s[i]){
                ans = s.substr(0, i-1);
                string p = s.substr(i);
                    for(char j = s[i-1]+1; j <= 'z'; j++){
                        bool f = 0;
                        rep(k, SZ(p)){
                            if(p[k] == j) f = 1;
                        }
                        if(f){
                            ans += j;
                            break;
                        }
                    }
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

ll f(ll b, ll n) {
	if (n < b) return n;
	return f(b, n / b) + (n % b);
}

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

	if (n == s) {
		cout << n + 1 << endl;
		return 0;
	}

	ll ans = inf;
	for (ll i = 2LL; i * i <= n; i++) {
		ll res = f(i, n);
		if (res == s) {
			cout << i << endl;
			return 0;
		}
	}

	for (ll i = 1LL; i * i <= n - s; i++) {
		ll b = (n - s) / i + 1;
		if (f(b, n) == s) {
			ans = min(ans, b);
		}
	}
	cout << (ans == inf ? -1 : ans) << endl;
	return 0;
}

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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 998244353
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
    int n,k;
    cin >> n >> k;
    int l[k],r[k];
    for(int i = 0; i < k; i++){
        cin >> l[i] >> r[i];
    }
    int dp[n + 5] = {};
    int pref[n + 5] = {};
    dp[1] = 1;
    pref[1] = 1;
    for(int i = 2; i <= n; i++){
        for(int j = 0; j < k; j++){
            if(i <= l[j])
                continue;

            int left = l[j];
            int right = min(r[j], i - 1);
            int val = (pref[i - left] - pref[i- right - 1] + mod) % mod;
            
            dp[i] = (dp[i] + val ) % mod;
        }
        pref[i] = (pref[i - 1] % mod + dp[i] % mod) % mod;
    }
    cout << dp[n] ;
}

int32_t main()
{
    FLASH
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 6772
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int C[20], A[20][20];
int skill[20];
int main()
{
	int N, M, X;
	cin >> N >> M >> X;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	int ans = mod;
	for (int bit = 0; bit < (1 << N); bit++) {
		for (int i = 0; i < M; i++) skill[i] = 0;
		int tmp = bit;
		int sum = 0;
		bool ok = true;
		for (int i = 0; i < N; i++) {
			if (tmp % 2 == 1) {
				sum += C[i];
				for (int j = 0; j < M; j++) {
					skill[j] += A[i][j];
				}
			}
			tmp /= 2;
		}
		for (int i = 0; i < M; i++) {
			if (skill[i] < X)ok = false;
		}
		if(ok) ans = min(ans, sum);
	}
	if (ans == mod) ans = -1;
	cout << ans << endl;
}

Measured memory_bytes: 3676
#include <iostream>
//#include <bits/stdc++.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb(x) push_back(x)
#define F first
#define S second
using namespace std;
int n;
int l;
const int N=100;
string arr[N];
bool cmp(const string &a,const string& b){
	return lexicographical_compare(a.begin(),a.end(),b.begin(),b.end());
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cin>>n>>l;
	string s;
	loop(i,0,n){
		cin.ignore();
		cin>>s;
		arr[i]=s;
	}
	sort(arr,arr+n,cmp);
	loop(i,0,n){
		cout<<arr[i];
	}
	cout<<endl;
	return 0;
}



Measured memory_bytes: 256
n = gets.strip.to_i
until n == 0
	points = gets.strip.split(" ").map {|i| i.to_f}
	avg = (points.reduce(0.0){|sum, p| sum += p}) / n.to_f
	var = points.reduce(0.0){|sum, p| sum += (p - avg) ** 2} / n.to_f
	std = var ** 0.5
	puts std.floor(4)
	n = gets.strip.to_i
end


Measured memory_bytes: 6964
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 998244353
#define mod 998244353
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi>b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;cin>>n;
    V<ll>a(n);
    ll sum=0;
    map<ll,ll>m;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        m[a[i]]++;
        sum+=a[i];
    }
    ll q;cin>>q;
    while(q--){
        ll b,c;cin>>b>>c;
        sum-=b*m[b];
        sum+=m[b]*c;
        m[c]+=m[b];m[b]=0;
        
        cout<<sum<<endl;
    }
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------






























Measured memory_bytes: 10016
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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 SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll inf = 1e15;
vll dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

int main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    vvll a(h, vll(w, inf)), visited(h, vll(w, 0));;
    queue<P> que;
    char c;
    REP(i, h){
        REP(j, w){
            cin >> c;
            if(c == '#'){
                a[i][j] = 0;
                que.push(P{i, j});
                visited[i][j] = 1;
            }
        }
    }
    while(!que.empty()){
        ll cx = que.front().second, cy = que.front().first;
        que.pop();
        REP(i, 4){
            ll nx = cx + dx[i], ny = cy + dy[i];
            if((nx >= 0 && nx < w && ny >= 0 && ny < h) && !visited[ny][nx]){
                a[ny][nx] = a[cy][cx] + 1;
                visited[ny][nx] = 1;
                que.push(P{ny, nx});
            }
        }
    }
    ll res = 0;
    REP(i, h){
        REP(j, w){
            res = max(res, a[i][j]);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 32308
n,k = (int(i) for i in input().split())
cont = 1/n
ans = 0
for i in range(1,n+1):
    tmp = i
    a_tmp = 0
    while tmp < k:
        a_tmp+=1
        tmp*=2
    ans += cont*(0.5**a_tmp)
print(ans)


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

using namespace std;

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

    bool grid[4][4];
    memset(grid, 0, sizeof(grid));

    vector<pair<int,int>> to(101,{-1,-1});

    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++) {
            int a;
            cin>>a;
            to[a].first = i;
            to[a].second = j;
        }
    
    int n;cin>>n;

    for (int i = 0; i < n; i++) {
        int a; cin>>a;
        if (to[a].first < 0) continue;
        grid[to[a].first][to[a].second] = true;
    }

    bool diag1 = true;
    bool diag2 = true;
    for (int i = 0;i < 3; i++) {
        bool row = true;
        bool col = true;
        for (int j = 0;j < 3;j++) {
            if (!grid[i][j]) row = false;
            if (!grid[j][i]) col = false;
        }
        if (!grid[i][i]) diag1 = false;
        if (!grid[i][2-i]) diag2 = false;
        if (row || col) {
            cout << "Yes" <<endl;
            return 0;
        }
    }

    if (diag1 || diag2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List.Split
main = do
  [a, b] <- (map read . words) <$> getLine
  s <- getLine
  putStrLn $ cho a b s

cho:: Int -> Int -> String -> String
cho a b s = solve a b $ splitOn "-" s
  
solve:: Int -> Int -> [String] -> String
solve a b [] = "No"
solve a b s
  | ls /= 2 = "No"
  | ls1 == a && ls2 == b = "Yes"
  | otherwise =  "No"
  where
    ls = length s
    [s1, s2] = s
    ls1 = length s1
    ls2 = length s2


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=ceil((double)c/b);
    int y=ceil((double)a/d);
    //cout<<x<<" "<<y<<endl;
    if(x<=y)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3652