akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N;
  cin >> N;
  int N_MAX=110;
  int h[N_MAX];
  int mi=111;
  int ma=0;
  int ans=0;
  for(int i=1;i<=N;i++){
    cin >> h[i];
    mi=min(mi,h[i]);
  }
  if(mi!=0){
    for(int i=1;i<=N;i++){
      h[i]-=mi;
    }
    ans+=mi;
  }
  h[N+1]=0;
  h[0]=0;
  int l=1,r=1;
  bool flag=true;
  bool plus=false;
  bool minus=false;
  mi=110;
  ma=0;
  while(l<=N){
    if(h[l]==0 && flag){
      l++;
      r=l;
      continue;
    }else if(h[r]==0 && !flag){
      if((plus && !minus) || (!plus && minus)){
        ans+=ma;
        l=r+1;
        r=l;
        mi=110;
        ma=0;
        flag=true;
        plus=false;
        minus=false;
        //cout << "A" << endl;
        //cout << ans << endl;
        continue;
      }
      for(int i=l;i<=r-1;i++){
        h[i]-=mi;
      }
      ans+=mi;
      mi=110;
      ma=0;
      flag=true;
      plus=false;
      minus=false;
      //cout << "B" << endl;
      r=l;
      //cout << ans << endl;
      continue;
    }else{
      if(h[r-1]<h[r]){
        plus=true;
      }else if(h[r-1]>h[r]){
        minus=true;
      }
      mi=min(mi,h[r]);
      ma=max(ma,h[r]);
      r++;
      flag=false;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a_list = list(map(int, input().split()))

ans = a_list[0]
count = a_list.count(0)

if count == 0:
    for i in range(1, n):
        ans *= a_list[i]
        if ans > 10**18:
            ans = -1
            break
else:
    ans = 0

print(ans)

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;

int main()
{
    string s;
    unordered_map<string, int> mmp;
    mmp["SUN"] = 7, mmp["MON"] = 6, mmp["TUE"] = 5; 
    mmp["WED"] = 4, mmp["THU"] = 3, mmp["FRI"] = 2, mmp["SAT"] = 1;
    cin >> s;
    cout << mmp[s] << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
def calc_0711(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x*y + y*z + z*x

def main():
    ans_list = [0] * 10010
    for i in range(1,100):
        for j in range(i, 100):
            for k in range(j, 100):
                c = calc_0711(i,j,k)
                #print('({:},{:},{:}) => {:}'.format(i,j,k, c))
                if c < 10010:
                    if i == j:
                        if j == k:
                            ans_list[c] += 1
                        else:
                            ans_list[c] += 3
                    else:
                        if j == k:
                            ans_list[c] += 3
                        else:
                            ans_list[c] += 6
    
    n = int(input())
    for i in range(1, n + 1):
        print(ans_list[i])
    
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 27256
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
	int n;
	cin>>n;

	int mat[n+1][5]={};
	for(int i=1;i<=n;i++)
		for(int j=1;j<=3;j++)
			cin>>mat[i][j];

	int dp1[n+1]={},dp2[n+1]={},dp3[n+1]={};
	dp1[1]=mat[1][1];
	dp2[1]=mat[1][2];
	dp3[1]=mat[1][3];
	for(int i=2;i<=n;i++)
	{
		dp1[i]=mat[i][1]+max(dp2[i-1],dp3[i-1]);
		dp2[i]=mat[i][2]+max(dp1[i-1],dp3[i-1]);
		dp3[i]=mat[i][3]+max(dp2[i-1],dp1[i-1]);
	}
	cout<<max({dp1[n],dp2[n],dp3[n]});
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
using namespace std;

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

const int MN = 1e5 + 5;
int n, k;
int h[MN], dp[MN];

int f(int x)
{
	if (x == n) return 0;
	int &ret = dp[x];
	if (ret != -1) return ret;
	ret = INT_MAX;
	for (int s = 1; s <= k; s++)
	{
		if (x + s > n) break;
		ret = min(ret, f(x + s) + abs(h[x] - h[x + s]));
	}
	return ret;
}

int main()
{
	fastio;
	cin >> n >> k;
	rep(i, 1, n + 1) cin >> h[i];
	mem(dp);
	cout << f(1);
}

Measured memory_bytes: 4224
Q=int(input())
lr=[list(map(int,input().split()))for _ in range(Q)]

N=10**5
A=[1]*(N+1)
A[0]=A[1]=0
i=2
while i*2<=N:
    if A[i]:
        j=2
        while i*j<=N:
            A[i*j]=0
            j+=1
    i+=1

S=[0]*(N+1)
for i in range(N+1):
    if A[i] and A[(i+1)//2]:
        S[i]=1
    S[i]+=S[i-1]

for l,r in lr:
    print(S[r]-S[l-1])

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

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1;i*i <= n;++i){
        if( n%i != 0 )continue;
        res.push_back(i);
        if(i*i !=n ) res.push_back(n/i);
    }
    return res;
}
int main()
{
    ll n;
    cin >> n;
    int ans = 0;
    for(ll x: divisor(n)){
        if( x== 1) continue;
        ll tmp = n;
        while (tmp%x == 0 ) tmp/=x;
        tmp %= x;
        if(tmp == 1) ++ ans;
    }
    ans += divisor(n-1).size() -1;
    cout << ans << endl;
    return 0;

    /*
    for(auto itr=begin(v1);itr != end(v1);++itr)
        cout << *itr << endl;
    */
    return 0;
}

Measured memory_bytes: 384
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   A.c                                                :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: kotaro666 <kotaro0726@gmail.com>           +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/03/02 11:03:21 by kotaro666         #+#    #+#             */
/*   Updated: 2020/03/02 11:17:28 by kotaro666        ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <stdio.h>
#include <math.h>

void swap(double *x1, double *y1, double *x2, double *y2)
{
    double temp;
    temp = *x1;
    *x1 = *x2;
    *x2 = temp;

    temp = *y1;
    *y1 = *y2;
    *y2 = temp;
}

int main(void)
{
    double x1, x2, y1, y2;
    double diagonal;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

    if (x1 >= x2 && y1 >= y2)
    {
        swap(&x1, &y1, &x2, &y2);
    }
    diagonal = sqrt(((x2 - x1) * (x2 - x1)) + ((y2 - y1) * (y2 - y1)));
    printf("%.8lf\n", diagonal);
    return (0);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; FOR(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;
 
// template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
// template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
// ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
// ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
// ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
// template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
// ostream &operator<<(ostream &os, vb &v) {
//     bool first = true;
//     os << '[';
//     for (const bool &x : v) {
//         if (!first) os << ", ";
//         first = false;
//         os << x;
//     }
//     os << ']';
//     return os;
// }
// template <class C> ostream &operator<<(ostream &os, C &v) {
//     bool first = true;
//     os << '[';
//     for (auto &x : v) {
//         if (!first) os << ", ";
//         first = false;
//         os << x;
//     }
//     os << ']';
//     return os;
// }
// int powa(int base, int exp) {
//     int res = 1;
//     while (exp) {
//         if (exp&1) res = res*base % MOD;
//         base = base*base % MOD;
//         exp >>= 1;
//     }
//     return res;
// }

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int n;
    cin >> n;
    vs strings(n);
    map<string, int> occ;
    FOR(i, 0, n) {
        cin >> strings[i];
        ++occ[strings[i]];
    }
    int mx = 0;
    for (auto pr : occ) mx = max(mx, pr.second);
    for (auto pr : occ) if (pr.second == mx) {
        cout << pr.first << '\n';
    }
}

Measured memory_bytes: 25472
#ifdef __GNUC__
#pragma GCC target("avx2")
#pragma GCC optimize ("O25")
#pragma GCC optimize ("tree-vectorize")
#pragma GCC optimize("unroll-loops")
#define iss std::cin
#endif
#include "bits/stdc++.h"
#define rep(i, times) for(ll i = 0; i < (times); ++i)
#define p(x) (cout << x << "\n")
using ll = uint16_t; using ld = long double; using namespace std;

#ifndef __GNUC__
string text =
R"X(
8
7 3 5 4 2 1 6 8
3 8 2 5 4 6 7 1
)X";
stringstream iss{text};
#endif

class CountOrder
{
	ll N{0};
	vector<ll> p, q;
	void inp( ) {
		iss >> N; p.resize(N); q.resize(N);
		rep(n, N) { iss >> p[n]; }
		rep(n, N) { iss >> q[n]; }
		//for_each(begin(p), end(p), [](auto x) { cout << x << "\n"; });
	}
	void change( ) {
		long long sa{0};
		auto it0{begin(p)}, it1{end(p)};
		if (p > q) { it0 = begin(q); it1 = end(q); }
		do {
			if (p == q) break;
			++sa;
		} while (next_permutation(it0, it1));
		p(sa);
	}
public:
	void procedures( ) {
		inp( );
		change( );
	}
};
//https://atcoder.jp/contests/abc145/tasks/abc145_c
int main( ) {
	cin.tie(0);	ios::sync_with_stdio(0);
	class CountOrder a; a.procedures( );
}

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

int main(int argc, char *argv[])
{
    std::string s, t;

    std::cin >> s;
    std::cin >> t;

    const auto slen = s.length();
    const auto tlen = t.length();

    int ans = tlen;
    for (int i = 0; i <= slen - tlen; i++) {
        int count = 0;
        for (int j = 0; j < tlen; j++) {
            if (t[j] != s[i + j]) {count++;}
        }
        ans = std::min(ans, count);
    }

    std::cout << ans << std::endl;

    return 0;
}


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

const int mod = 1000000007;
struct Mint {
// typedef long long LL;
    LL x; 
    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 {
        Mint res(*this);
        return res+=a;
    }
    Mint operator-(const Mint a) const {
        Mint res(*this);
        return res-=a;
    }
    Mint operator*(const Mint a) const {
        Mint res(*this);
        return res*=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 {
        Mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream&i,Mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const Mint&a){o<<a.x;return o;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> mask(n);
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            int foo;
            cin >> foo;
            mask[i] |= foo<<j;
        }
    }

    vector<Mint> dp(1<<n);
    dp[0] = 1;
    for(int i = 0; i < (1<<n)-1; i++) {
        int k = __builtin_popcount(i);
        for(int j = 0; j < n; j++) {
            if( (mask[k] & (1<<j)) && !(i & (1 << j)) ) {
                dp[i | (1 << j)] += dp[i];
            }      
        }
    }
    cout << dp.back() << '\n';
    return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
const int MAXN=82;
bool dp[MAXN][MAXN][MAXN*MAXN*2];
int n,m,a[MAXN][MAXN],b[MAXN][MAXN];
int main () {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {scanf("%d",&a[i][j]);}
	}
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {scanf("%d",&b[i][j]);}
	}
	dp[1][1][abs(a[1][1]-b[1][1])]=1;
	for (int i=1;i<=n;i++) {
		for (int j=1;j<=m;j++) {
			for (int k=0;k<=80*(i+j);k++) {
				dp[i+1][j][abs(k+a[i+1][j]-b[i+1][j])]|=dp[i][j][k];
				dp[i+1][j][abs(k+b[i+1][j]-a[i+1][j])]|=dp[i][j][k];
				dp[i][j+1][abs(k+a[i][j+1]-b[i][j+1])]|=dp[i][j][k];
				dp[i][j+1][abs(k+b[i][j+1]-a[i][j+1])]|=dp[i][j][k];
			}
		}
	}
	for (int i=0;i<=80*80*2;i++) {
		if (dp[n][m][i]) {
			printf("%d\n",i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 87040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;


ll dfs(ll x, vector<ll> &memo){
    if(memo[x]!=-1) return memo[x];
    return memo[x]=dfs(x-1,memo)+dfs(x-2,memo);
}

int main(){
    ll n; cin>>n;
    vector<ll> memo(100,-1);    
    memo[0]=2; memo[1]=1;
    cout<<dfs(n,memo)<<endl;
}

Measured memory_bytes: 256
//............Created by:- Arth Raj...........................//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<pair<int,int>>
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=b;i>=a;i--)
#define ld long double
#define tl tuple<ll,ll,ll>
#define all(x) (x).begin(),(x).end()
#define bs(x,b) binary_search(all(x),b)
#define vip vector<pair<int,pair<int,int>>>
#define pip pair<int,pair<int,int>>
#define INF 1e18
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll abm(ll a, ll b, ll m) {ll ans = 1; a = a % m; while (b > 0) {if (b & 1)ans = (ans * a) % m; a = (a * a) % m; b = b / 2;} return ans % m;}
ll ncr(ll n, ll r, ll m) {if (r == 0)return 1; ll fac[n + 5]; fac[0] = 1; lp(i, 1, n + 1) {fac[i] = fac[i - 1] * i % m;} return (((fac[n] * abm(fac[r], m - 2, m)) % m) * (abm(fac[n - r], m - 2, m))) % m;}
ll mod = 1e9 + 7;
int main()
{
	int h, w;
	char ch;
	cin >> h >> w;
	int arr[h][w];
	lp(i, 0, h)
	{
		lp(j, 0, w)
		{
			cin >> ch;
			// cout << ch << endl;
			if (ch == '.')
				arr[i][j] = 0;
			else
				arr[i][j] = -1;
		}
	}
	ll dp[h][w];
	dp[0][0] = 0;
	int p = 1;
	lp(i, 1, h)
	{
		if (arr[i][0] == 0)
		{}
		else
			p = 0;
		dp[i][0] = p;
	}
	p = 1;
	lp(i, 1, w)
	{
		if (arr[0][i] == 0)
		{}
		else
			p = 0;
		dp[0][i] = p;
	}
	// cout << dp[0][3] << endl;
	lp(i, 1, h)
	{
		lp(j, 1, w)
		{
			if (arr[i][j] == -1)
				dp[i][j] = 0;
			else
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
			// cout << dp[i][j] << " " << i << " " << j << endl;
		}
	}
	// lp(i, 0, h)
	// {
	// 	lp(j, 0, w)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
	cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 15220
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int l=s.length();
  int cnt=0;
  for(int i=0;i<l;i++)
    if(s[i]=='x')
      cnt++;
  if(cnt<=7)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3588
fn main() {
    let abx = read_vec::<f64>();
    let a = abx[0];
    let b = abx[1];
    let x = abx[2];

    let vol = a * a * b;

    if vol == x {
        println!("0");
        return;
    }

    let theta;
    if vol / 2.0 <= x {
        theta = (2.0 * (a * a * b - x) / (a * a * a)).atan();
    } else {
        theta = (a * b * b / (2.0 * x)).atan();
    }

    println!("{}", theta * 180.0 / std::f64::consts::PI);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <map>
#define ll long long 

using namespace std;

int main(){
	string s;
	cin >> s;
	map<string, int> hash;

	for (int i = 0; i < s.length(); ++i)
	{
		if(i+1 < s.length() && s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
		if(i+2 < s.length() && s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << "-1 -1" << endl;
}


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

int main(void){
    string s;
    cin >> s;

    ll mi = 1000;
    rep(i, s.size()-2){
        ll tmp = (s[i] - '0') * 100;
        tmp += (s[i+1] - '0') * 10;
        tmp += (s[i+2] - '0') * 1;
        mi = min(abs(753 - tmp), mi);
    }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
l=sorted(list(map(int,input().split())))
if len(set(l))==3:
  h=sorted(list(set(l)),reverse=1)
  ff=len(bin(h[0]))
  p=["0"*(ff-len(bin(s)))+bin(s)[2:] for s in h]
  y=p[0]
  dfg,dgf=p[1],p[2]
  for i in range(ff-2):
    q,w=dfg[i],dgf[i]
    if (q!=w and y[i]=="0") or (q==w and y[i]=="1"):print("No");exit()
  else:
    from collections import Counter as cou
    if len(set(cou(l).values()))==1:print("Yes")
    else:print("No")
elif len(set(l))>=4 or 0 not in set(l):
  print("No")
elif set(l)==set([0]):
  print("Yes")
else:
  if n%3:print("No");exit()
  from collections import Counter as cou
  fl,fll=0,0
  for g,gh in cou(l).items():
    if g==0 and gh==n//3:fl=1
    if g!=0 and gh==2*n//3:fll=1
  print("Yes" if fl and fll else "No")

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

using namespace std;

int main()
{
    int n,k,result=0;
    cin>>n>>k;
    int arr[n];
    for(int i=0 ; i<n ; i++)
        cin>>arr[i];
    sort(arr , arr+n);

    for(int i=0 ; i<k ; i++)
    {
        result+=arr[i];
    }

    cout<<result;
    return 0;
}


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

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

    string ans;
    
    if (n == 0) {
        ans = "0";
    } else {
        while (n != 0) {
            int r = n % -2;
            n /= -2;
            if (r < 0) n++;
            ans.push_back('0' + (r + 2) % 2);
        }
    }

    reverse(begin(ans), end(ans));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define buf 1001

int a,b,top,S[buf];

void push(int x);
int pop(void);
int main(void){
	int a,b,y=0,top=0;
	char s[buf],*line;

	fgets(s,sizeof(s),stdin);
	line=strtok(s," ");
	sscanf(line,"%d",&y);
	push(y);
	for( ; ; ){
		line=strtok(NULL," ");
		if(line==NULL)
			break;
		if(*line=='+'){
			b=pop();
			a=pop();
			push(a+b);
		}
		else if(*line=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}		
		else if(*line=='*'){
			b=pop();
			a=pop();
			push(a*b);
		}
		else{
			sscanf(line,"%d",&y);
			push(y);
		}
	}
	printf("%d\n",S[1]);
	return 0;
}
void push(int x){
	S[++top]=x;
}
int pop(void){
	return S[top--];
}

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

int main() {
	ios :: sync_with_stdio(false);
	int x, y;
	while(cin >> x >> y) {
		cout << __gcd(x, y) << ' ';
		cout << x / __gcd(x, y) * y << '\n';
	}
	return 0;
}

Measured memory_bytes: 3104
# 2019/03/24
# AtCoder Beginner Contest 122 - B

# Input
s = input()

ans = 0
wcnt = 0
for idx in range(len(s)):
    if s[idx] == "A" or s[idx] == "C" or s[idx] == "T" or s[idx] == "G":
        wcnt += 1
        if ans < wcnt:
            ans = wcnt
    else:
        wcnt = 0

# Output
print(ans)


Measured memory_bytes: 2940
t,s=open(0)
n,k=map(int,t.split())
l=2*k+1
x=[0]*2+[i for i in range(1,n)if s[i]!=s[i-1]]+[n]*l
print(max(x[i+l]-x[i]for i in range(s>'1',len(x)-l,2)))

Measured memory_bytes: 8676
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int x1 = sc.nextInt();
        int x2 = sc.nextInt();
        int x3 = sc.nextInt();
        int x4 = sc.nextInt();
        int x5 = sc.nextInt();
        
        if (x1 != 1) {
            System.out.println(1);
        } else if (x2 != 2) {
            System.out.println(2);
        } else if (x3 != 3) {
            System.out.println(3);
        } else if (x4 != 4) {
            System.out.println(4);
        } else if (x5 != 5) {
            System.out.println(5);
        }
    }
}

Measured memory_bytes: 35744
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
    int n,a,b,i,flg;
    cin>>n;
	flg=0;
	a=n;
	for(i=0;i<=100;i++){
		if(a%4==0) flg=1;
		if(a==0) flg=1;
		a=a-7;
		if(a<0) break;
	}
	if(flg==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    i64 i , j , k , l , m , n ;
    i64 a , b , c , d , dif ;

    scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d) ;

    if(a>b) swap(a,b) ;

    dif = b-a ;

    for(i=0 ; i<n ; i++)
    {
        i64 r1 = i*c , r2 = i*d ;
        i64 r3 = dif + (n-1-i)*c , r4 = dif + (n-1-i)*d ;
// printf("%lld %lld %lld %lld\n",r1,r2,r3,r4) ;
        if( r2 < r3 || r1 > r4 ) continue ;
        else{
            printf("YES\n") ;
            return 0 ;
        }
    }
    printf("NO\n") ;
    return 0 ;
}


Measured memory_bytes: 256
import java.math.*

fun main(args: Array<String>) {
    val (H, W, D) = readInputLine().split(" ").map { it.toInt() }
    
    val pos = Array(H * W) { Pair(-1, -1) }
    
    for (i in 0 until H) {
        readInputLine().split(" ").forEachIndexed {
            j, a -> pos[a.toInt() - 1] = Pair(i, j)
        }
    }
    
    val ans = Array(D) { mutableListOf<Int>() }
    
    for (i in 0 until D) {
        ans[i].add(0)
        for (j in i + D until H * W step D) {
            ans[i].add(ans[i].last() + Math.abs(pos[j].first - pos[j - D].first) + Math.abs(pos[j].second - pos[j - D].second))
        }
    }

    val Q = readInputLine().toInt()
    
    for (i in 1..Q) {
        val (L, R) = readInputLine().split(" ").map { it.toInt() - 1 }
        println(ans[L % D][R / D] - ans[L % D][L / D])
    }
}

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


Measured memory_bytes: 81696
#include<bits/stdc++.h>
typedef long long int ll;
#define mod 1000000007
#define sz 100009
ll n,m,i,j,k,l,t,arr[sz];
long long binpow(long long a,long long b){
  if(b==0)
    return 1;
  long long res=binpow(a,b/2)%mod;
if(b%2){
    return ((((res%mod)*(res%mod))%mod)*a)%mod;
}
else
    return (res*res)%mod;
}
int main()
{
    scanf("%lld %lld",&n,&m);
    for(i=1;i<=m;i++)
    {
        j=m/i;
        l=binpow(j,n);
        arr[i]=l;
    }
    for(i=m;i>0;i--)
    {
        for(j=i+i;j<=m;j+=i){
            arr[i]-=arr[j];
            if(arr[i]<0)
                arr[i]+=mod;
                }
           // if(arr[i]<0)
             //   arr[i]+=mod;
    }
    for(i=m;i>0;i--)
    {
       l=arr[i]*i;
       l=l%mod;
       k+=l;
       k=k%mod;
    }
    printf("%lld\n",k);
    return 0;
}


Measured memory_bytes: 4528
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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


VB freeRow(8, true), freeCol(8, true);
//DiaToLeft x: i + j      DiaToRight x : i - j + 7
VB freeDiaToLeft(15, true), freeDiaToRight(15, true);
vector<VB> freeSq(8, VB(8, true));

void printBoard(){
    REP(i, 8){
        REP(j, 8)
            cout << (freeSq[i][j] ? '.' : 'Q');
        cout << "\n";
    }
}

bool search(int i){
    if(i == 8){
        printBoard(); return true;
    }
    if(!freeRow[i]) return search(i + 1);
    bool okay = false;
    REP(j, 8){
        if(!freeCol[j] || !freeDiaToLeft[i+j] 
           || !freeDiaToRight[i-j+7])
            continue;
        freeCol[j] = false;
        freeDiaToLeft[i+j] = freeDiaToRight[i-j+7] = false;
        freeSq[i][j] = false;
        okay = search(i+1);
        freeCol[j] = true;
        freeDiaToLeft[i+j] = freeDiaToRight[i-j+7] = true;
        freeSq[i][j] = true;
    }
    return okay;
}

int main(){
    int k; cin >> k;
    REP(i, k){
        int r, c; cin >> r >> c;
        freeSq[r][c] = false;
        freeRow[r] = freeCol[c] = false;
        freeDiaToLeft[r+c] = freeDiaToRight[r-c+7] = false;
    }
    search(0);
    return 0;
}



Measured memory_bytes: 3104
#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)
using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;

    if (ans < a * d){
        ans = a * d;
    }
    if (ans < b * c){
        ans = b * c;
    }
    if (ans < b * d){
        ans = b * d;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

vector<int> g[606];
long double dp[606];
long double ans;
int main() {
  int n,m;
  cin >> n >> m;
  for(int i = 0; i < m; i++) {
    int s,t;
    cin >> s >> t;
    --s; --t;
    g[s].push_back(t);
  }

  for(int i = n - 2; i >= 0; i--) {
    long double nn = g[i].size();
    long double tmp = 0;
    for(int j = 0; j < g[i].size(); j++) {
      tmp += dp[g[i][j]];
    }
    dp[i] = tmp / nn + 1;
  }

  ans = dp[0];
  
  for(int i = 0; i < n; i++) {
    vector<long double> dp2(n,0);
    for(int j = n - 2; j >= 0; j--) {
      long double nn = g[j].size();
      long double tt = 0;
      long double ma = 0;
	  
      for(int k = 0; k < g[j].size(); k++) {
	tt += dp2[g[j][k]];
	ma = max(ma,dp2[g[j][k]]);
      }
      if(i == j && nn >= 2) {
	nn--;
	tt -= ma;
      }
      dp2[j] = tt / nn + 1;
    }
  
    ans = min(ans,dp2[0]);
  }

  cout << fixed << setprecision(10) << ans << endl;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 20:59:27 2019

@author: doppe
"""
N, M = map(int, input().split())
listA = []
listB = []

for i in range (0, N):
    A, B = map(int, input().split())
    listA.append(A)
    listB.append(B)

li2 = sorted(range(len(listA)), key=lambda k: listA[k])

count = 0
cost = 0
for i in li2:
    if listB[i] + count > M:
        cost += (M - count) * listA[i]
        break
    else:
        cost += listA[i] * listB[i]
        count += listB[i]
print(cost)
        

Measured memory_bytes: 16536
#include <cstdio>
#include <cstring>
#define N 10050
using namespace std;
int ans=1;

int main()
{
	char ch[200];
	scanf("%s",ch+1);
	for(int i=1;i<=(int) strlen(ch+1)&&ans;i++)
		if(i&1){
			if(ch[i]=='L') ans=0;
		}
		else{
			if(ch[i]=='R') ans=0;
		}
	if(ans) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
  char a[2];
  
  fgets(a,sizeof(a),stdin);
  
  if('a'<=a[0]&&a[0]<='z')
  {
    printf("a");
  }else if('A'<=a[0]&&a[0]<='Z')
  {
    printf("A");
  }
  
  return 0;
}

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

int main(void) {
	char w[100];
	int i, j;
	int count, no;
	scanf("%s", w);
	no = strlen(w);


	for (i = 0; i < no; i++) {
		for (j = 0; j < no; j++) {
			if (w[i] == w[j]) count++;
		}
			if (count % 2 != 0) {
				printf("No");
				return 0;
			}
		}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new java.util.Scanner(System.in);
    String[] inputs = sc.nextLine().split(" ");
    int N = Integer.parseInt(inputs[0]);
    int A = Integer.parseInt(inputs[1]);
    int B = Integer.parseInt(inputs[2]);
    List<Integer> answer = new ArrayList<>();

    for (int n = 1; n <= N; n++) {
      if (n < 10) {
        if (n >= A && n <= B) {
          answer.add(n);
        }
      } else {
        String[] nString = String.valueOf(n).split("");
        int sum = 0;
        for (String ns: nString) {
          sum += Integer.parseInt(ns);
        }
        if (sum >= A && sum <= B) {
          answer.add(n);
        }
      }
    }
    Integer sum = 0;
    for (Integer ans: answer) {
      sum += ans;
    }
    System.out.println(sum);
  }
}


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

using namespace std;
using ll = long long;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int m1, d1, m2, d2;
  cin >> m1 >> d1 >> m2 >> d2;
  m1 = (m1 + 1) % 12;
  if(m1 == 0) m1 = 12;
  if(m1 == m2) cout << 1 << '\n';
  else cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 10;
char s[N];
int val[2][N], sum[2];
int add(int a, int b, int mod){
	a += b;
	a %= mod;
	if(a < 0) a += mod;
	return a;
}
int pop_cnt(int num, int mod){
	if(mod == 1) return 1;
	int ans = 1;
	while(num != 0){
		int cnt = 0;
		for(int i = 0; (1 << i) <= num; i++){
			if(num & (1 << i)) cnt++;
		}
		num %= cnt;
		ans ++;
	}
	return ans;
}
int main(){
	int n, cnt = 0;
	scanf("%d %s", &n, s + 1);
	for(int i = n; i > 0; i--){
		if(s[i] == '1') cnt++;
	}
	if(cnt == 0){
		for(int i = 1; i <= n; i++){
			printf("%d\n", 1);
		}
		return 0;
	}
	if(cnt == 1){
		for(int i = 1; i <= n; i++){
			if(s[i] == '0'){
				if(i != n && s[n] != '1') printf("1\n");
				else printf("2\n");
			}
			else{
				printf("0\n");
			}
		}
		return 0;
	}
	int m[2] = {cnt - 1, cnt + 1};
	for(int i = n; i > 0; i --){
		for(int j =0 ; j < 2; j++){
			if(i != n) val[j][i] = (2LL * val[j][i + 1]) % m[j];
			else val[j][i] = 1;
			if(s[i] == '1') sum[j] = add(sum[j], val[j][i], m[j]);
		}
	}

	for(int i = 1; i <= n; i ++){
		if(s[i] == '0') printf("%d\n", pop_cnt(add(sum[1], val[1][i], m[1]), m[1]));
		else printf("%d\n", pop_cnt(add(sum[0], -val[0][i], m[0]), m[0]));
	}


}

Measured memory_bytes: 5564
#include<stdio.h>

int solve(int,int);

int A[2000];
int n;

int main()
{
  int q,i;
  int m;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m)!=0) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}
  



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // K回ごとのジャンケンでdp、状態は前回勝ったか負けたか、r, s, p を数字に変換
  int N, K;
  cin >> N >> K;
  vector<int> RSP(3);
  rep(i, 3) cin >> RSP[i];
  string T;
  cin >> T;
  vector<int> ctoi(256);
  ctoi['r'] = 2;
  ctoi['s'] = 0;
  ctoi['p'] = 1;
  int ans = 0;
  rep(i, K) {
    vector<int> X;
    for (int j = i; j < N; j = j + K) {
      X.push_back(ctoi[T[j]]); // 勝つ出し方をXに入れる
    }
    int last = -1;
    vector<int> dp(2);
    for (int x : X) {
      vector<int> prev(2);
      swap(dp, prev);
      dp[0] = max(prev[0], prev[1]);  // 負けた状態
      if (x == last) {
        dp[1] = prev[0] + RSP[x];
      } else {
        dp[1] = max(prev[0], prev[1]) + RSP[x];
      }
      last = x;
    }
    ans += max(dp[0], dp[1]);
  }
  cout << ans << '\n';  
  return 0;
}

Measured memory_bytes: 4052
import java.util.*;

public class Main {
  public static int forward = 5;
  public static int back = 2;
  public static int right = 3;
  public static int left = 4;
  public static int up = 1;
  public static int down = 6;

  public static void north() {
    int a = forward;
    forward = up;
    up = back;
    back = down;
    down = a;
  }
  public static void east() {
    int a = right;
    right = up;
    up = left;
    left = down;
    down = a;
  }
  public static void south() {
    int a = back;
    back = up;
    up = forward;
    forward = down;
    down = a;
  }
  public static void west() {
    int a = left;
    left = up;
    up = right;
    right = down;
    down = a;
  }
  public static void assign(int a, int b, int c, int d, int e, int f) {
    up = a;
    back = b;
    right = c;
    left = d;
    forward = e;
    down = f;
  }
  public static int returnRight(int a, int b) {
    if((a == left && b == back) || (a == forward && b == left) || (a == right && b == forward)
      || (a == back && b == right)) {
      return up;
    } else if((a == up && b == left) || (a == right && b == up) || (a == down && b == right)
      || (a == left && b == down)) {
      return back;
    } else if((a == up && b == back) || (a == forward && b == up) || (a == down && b == forward)
      || (a == back && b == down)) {
      return right;
    } else if((a == up && b == forward) || (a == back && b == up) || (a == down && b == back)
      || (a == forward && b == down)) {
      return left;
    } else if((a == up && b == right) || (a == left && b == up) || (a == down && b == left)
      || (a ==right && b == down)) {
      return forward;
    } else {
      return down;
    }
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] dice = new int[6];
    for(int i = 0; i < 6; i++) {
      dice[i] = sc.nextInt();
    }
    int q = sc.nextInt();
    assign(dice[0], dice[1], dice[2], dice[3], dice[4], dice[5]);
    for(int i = 0; i < q; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      System.out.println(returnRight(a, b));
    }
  }
}



Measured memory_bytes: 26168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll d,n,m,x,y,z,h,w,k,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;


// mod_tools
ll fact[500000];

ll mpow(ll x, ll y){
    //d(x)
    if(y==0) return 1;
    if(y%2==0){
        return mpow(x*x%mod,y/2)%mod;
    }
    else{
        return x*mpow(x,y-1)%mod;
    }
}

ll minv(ll x){
    // only available for mod=10^9+7
    return mpow(x,mod-2);
}

// Please run this func for preparation
void mfact(){
    //prepare fact-array
    fact[0]=1;
    rep(i,1,500000){
        fact[i]=fact[i-1]*i%mod;
    }
}

//combiの呼び出しが大きいときはこれを使う
ll combi(ll n, ll k){
    return (fact[n]*minv(fact[k])%mod)*minv(fact[n-k])%mod;
}

//combiを一回呼び出すだけなら直接計算

ll a[1000000]; 

int main(void){
    cin>>st;
    rep(i,st.size()){
        a[st[i]-'a']++;
    }
    rep(i,26){
        if(a[i]>0)continue;
        else{
            p((char)('a'+i));
            return 0;
        }
    }  
    p("None");
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <list>
#include <math.h>

using namespace std;

int main()
{
    int n, ans;
    cin >> n;
    if(n >= 100 && n <= 111){
        ans = 111;
    }
    else if(n > 111 && n <= 222){
        ans = 222;
    }
    else if(n > 222 && n <= 333){
        ans = 333;
    }
    else if(n > 333 && n <= 444){
        ans = 444;
    }
    else if(n > 444 && n <= 555){
        ans = 555;
    }
    else if(n > 555 && n <= 666){
        ans = 666;
    }
    else if(n > 666 && n <= 777){
        ans = 777;
    }
    else if(n > 777 && n <= 888){
        ans = 888;
    }
    else if(n > 888 && n <= 999){
        ans = 999;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math

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

if N>=K:
	ans = (N-K+1)/N
	for k in range(1, K):
		n = math.ceil(math.log2(K/k))
		ans += (1/N)*(1/2**n)
else:
	ans = 0
	for k in range(1, N+1):
		n = math.ceil(math.log2(K/k))
		ans += (1/N)*(1/2**n)

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  REP(i, h) cin >> s[i];
  cout << string(w+2, '#') << endl;
  REP(i, h) cout << '#'+s[i]+'#' << endl;
  cout << string(w+2, '#') << endl;
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
template <class T>
using VVV = V<V<V<T>>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

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

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    while (1) {
        int n, m;
        cin >> n >> m;
        if (!n && !m) return 0;

        V<int> c(n);
        rep(i, 3) {
            int a;
            cin >> a;
            rep(j, a) {
                int b;
                cin >> b;
                b--;
                c[b] = i;
            }
        }
        // ３進数に割り振り
        int p = 1;
        int x = 0;  //ここに割り振る
        rep(i, n) {
            x += c[i] * p;
            p *= 3;
        }

        const int l = p - 1;  // ３進数のmax．
        const int z = 15000000;
        V<bool> memo(z);
        // memo[x] = true;  !!! ここでtrueにしたらアカン！！

        queue<pii> q;
        q.emplace(x, 0);
        while (!q.empty()) {
            pii P = q.front();
            q.pop();
            int xx = P.first, t = P.second;
            if (t > m) {
                cout << -1 << endl;
                break;
            }
            if (memo[xx]) continue;
            memo[xx] = true;
            if (xx == 0 || xx == l) {
                cout << t << endl;
                break;
            }
            V<int> ch(3, -1);
            int xc = xx;
            int nc = 0;
            int g = 1;
            while (nc < n) {
                ch[xc % 3] = g;
                xc /= 3;
                g *= 3;
                nc++;
            }
            t++;
            if (ch[0] > ch[1]) {
                q.emplace(xx + ch[0], t);
            } else {
                q.emplace(xx - ch[1], t);
            }
            if (ch[1] > ch[2]) {
                q.emplace(xx + ch[1], t);
            } else {
                q.emplace(xx - ch[2], t);
            }
        }
    }
    return 0;
}



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

int main()
{
	int S;
	cin >> S;
	int h,m,s;
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S - h * 3600 - m * 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int n;

void dfs(string s, char mx){
	if(s.length() == n){
		cout << s << endl;
		return;
	}

	for(char c = 'a'; c <= mx+1; c++){
		if(c==mx+1) dfs(s+c, mx+1);
		else dfs(s+c, mx);
	}
}


int main(){
	cin >> n;
	dfs("a", 'a');
}

Measured memory_bytes: 1536
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	int x,y;
	scanf("%d%d",&x,&y);
	if(x+y>=10)
	{
		puts("error");
	 } 
	 else
	 {
	 	printf("%d",x+y);
	 }
	return 0;
}



Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        S = input().rstrip()

        ans = 0
        for i in range(N - 2):
            if str(S[i:i + 3]) == "ABC":
                ans += 1

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long l[n+5];
	l[0]=2LL;l[1]=1LL;
	for (int i = 2; i <= n; ++i)
	{
		l[i]=l[i-1]+l[i-2];
	}
	cout<<l[n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main (){
  int x;

  for(int i = 1; i <= 10000; i++){
    cin >> x;

    if(x == 0) break;
    else{
      cout << "Case " << i << ": " << x << endl;
    }

    //cout << "Case " << i << ": " << x << endl;
    //if(x == 0) break;
    
  }
}



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

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

    for (int i = 0; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 and A[j] > v) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;

        for (int i = 0; i < N - 1; i++)
        {
            cout << A[i] << " ";
        }
        cout << A[N - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 3116