akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a+b;
    if(c%2!=0){
      System.out.println(c/2+1);
    }else{
      System.out.println(c/2);
    }
  }
}


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(K);
    double result_temp = 0;
    for (int n = 1; n <= N; ++n){
        if (K <= n){
            result_temp += 1.0;
        }else{
            result_temp += 1.0 / pow(2.0, ceil(log2(1.0 * K / n)));
        }
    }
    printf("%.9f\n", result_temp / N);
}


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

int n;
int m;
double dp[17][(1 << 16) + 1];
double P[17][17];

int main() {
  scanf("%d%d", &m, &n);
  for (int i=0; i<m; i++) {
    for (int j=0; j<n; j++) {
      scanf("%lf", &P[i][j]);
    }
  }

  int lim = 1 << m;
  for (int i=n-1; i>=0; --i) {
    for (int st=0; st<lim; ++st) {
      for (int j=0; j<m; j++) {
        if (!(st >> j & 1)) continue;
        double p = 1.0;
        double cand = 0.0;
        int nst = st & ~(1 << j);
        for (int k=i; k<n; k++) {
          cand += dp[k][nst]*p*(1-P[j][k]);
          p *= P[j][k];
        }
        cand += p;
        dp[i][st] = max(dp[i][st], cand);
      }
    }
  }
  printf("%.20f\n", dp[0][lim-1]);
}

Measured memory_bytes: 11372
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

D, K =  map(int, sys.stdin.readline().split())

if K == 100:
    print(100 ** (D + 1) + 100 ** D)
else:
    print(100 ** D * K)

Measured memory_bytes: 64112
#include <bits/stdc++.h>
using namespace std;
struct point{double x;double y;};
int i,j,k,count1=0,count2=0;

int main(void){
    string str;
    cin>>str;
    int n=0,w=0,s=0,e=0,ans=0;
    for(i=0;i<str.length();i++){
        if(str[i]=='N')n++;
        if(str[i]=='W')w++;
        if(str[i]=='S')s++;
        if(str[i]=='E')e++;
    }
    if(n>=1&&s>=1&&w==0&&e==0)ans=1;
    if(n>=1&&s>=1&&w>=1&&e>=1)ans=1;
    if(n==0&&s==0&&w>=1&&e>=1)ans=1;
    cout<<(ans? "Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){
    long long X;

    cin >> X;

    for(long long i=-200; i<=200; ++i){
        for(long long j=-200; j<=200; ++j){
            //long long calc = (i*i*i*i*i) - (j*j*j*j*j);
            long long calc = pow(i, 5) - pow(j, 5);
            if(calc == X){
                cout << i << ' ' << j << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4084
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};




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

    vector<int> vec(32);
    vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << vec[k-1] <<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define watch(x) cout<<#x<<" : "<<x<<endl;
typedef  long long ll;
using namespace std;

int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(NULL),cout.tie(NULL);

    ll n,m,k,i,j,ans=0;
    cin>>n>>m>>k;
    vector<ll>a(n+1),b(m+1);
    vector<ll>::iterator it;
    for(i=1; i<=n; i++)
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(i=1; i<=m; i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    for(i=0;i<=n;i++)
    {
        ll x=k-a[i];
        if(x<0)
        {
            continue;
        }
        it=upper_bound(all(b),x);
        it--;
        x=it-b.begin();
        ans=max(ans,i+x);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 6428
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  A = list(map(int, input().split()))
  if C + sum(A[j] * B[j] for j in range(M)) > 0:
    ans += 1

print(ans)

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

int main(void) {
	int n, m;
	int i,k,ans,q,mod;
	scanf("%d%d", &n, &m);
	mod = m %n ;
	q = m / n;
	if (mod == 0) {
		printf("%d",q);
	}
	else {
		for (i = q; i > 0; i--) {
			vector<int> v(n, i);
			v[n - 1] = m - (n - 2)*i;
			if (v[n - 1] % i == 0) {
				ans = i;
				break;
			}
		}
		printf("%d",ans);
	}
	return 0;
 }

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int N, K;
    cin >> N >> K;
    ll sum = 0;
    REP(i, N)
    {
        int x;
        cin >> x;
        sum += std::min(x, K - x) * 2;
    }
    cout << sum << endl;
    return 0;
}

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

const int S = 2e5 + 10;
int n, k, a[S];
ll ans = 0;

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) 
		scanf("%d", a + i);
	sort(a + 1, a + n + 1);
	k = n - k;
	for (int i = 1; i <= k; i++)
		ans += a[i];
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 110
#define INF 1e9
typedef pair<int,int> pii;
 
bool a[MAX];
int N,G[MAX];
 
int dijkstra(){
  int res = INF;
  int dist[MAX];
  fill(dist,dist+MAX,INF);
  dist[0] = 0;
  priority_queue<pii,vector<pii>,greater<pii> > Q;
  Q.push(pii(0,0));
  while(!Q.empty()){
    pii now = Q.top(); Q.pop();
    int v = now.second;
    if(dist[v] < now.first) continue;
    if(v == N-1){
      if(a[N-1]){
        res = min(res,dist[N-1]);
      }else{
        res = min(res,dist[N-1]+1);
      }
      continue;
    }
    if(a[v]){
      if(dist[v] < dist[v+1]){
        dist[v+1] = dist[v];
        Q.push(pii(dist[v+1],v+1));
      }
    }else{
      if(dist[v] + 1 < dist[v+1]){
        dist[v+1] = dist[v] + 1;
        Q.push(pii(dist[v+1],v+1));
      }
      if(dist[v] < dist[G[v]]){
        dist[G[v]] = dist[v];
        Q.push(pii(dist[G[v]],G[v]));
      }
    }
  }
  return res;
}
 
int main(){
  string in,s[MAX];
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> in;
    if(in == "goto"){
      a[i] = false;
      cin >> in;
      s[i] = in;
    }else{
      a[i] = true;
      s[i] = in;
    }
    s[i].resize(s[i].size()-1);
  }
 
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      if(i == j) continue;
      if(s[i] == s[j]){
        if(!a[i] && a[j]){
          G[i] = j;
        }else if(a[i] && !a[j]){
          G[j] = i;
        }
      }
    }
  }
  cout << dijkstra() << endl;
  return 0;
}

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


int main()
{
    int k,a,b;
    cin >> k >> a >> b;
    int ans = 0;

    //int num_1,num_2; 
    //num_1  = a / k;
    //num_2 = b / k;
    for (int i = a;i <= b; i++)
    {
        if(i % k == 0){
            cout <<"OK" << endl;
            ans = 1;
            break;
        }

    }

    if(ans != 1){
        cout << "NG" << endl;
    }
    



    return 0;
    

}

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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second
#define int long long

const int N = 5005;

int n, a, b;
int p[N];
int coor[N];
int notMove[N];
int dp[N][N], mn[N][N];

main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        coor[p[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n + 1; j++) {
            int foo = mn[i - 1][j];
            if (coor[i - 1] < j) foo = min(foo, notMove[i - 1]);
            if (coor[i] >= j) {
                dp[i][j] = foo + b; 
            } else {
                dp[i][j] = foo + a;
            }
        }
        int foo = mn[i - 1][coor[i]];
        if (coor[i - 1] < coor[i]) {
            foo = min(foo, notMove[i - 1]);
        }
        notMove[i] = foo;
        mn[i][1] = dp[i][1];
        for (int j = 2; j <= n + 1; j++) {
            mn[i][j] = min(mn[i][j - 1], dp[i][j]);
        }
    }
    cout << min(mn[n][n + 1], notMove[n]);
    return 0;
}

Measured memory_bytes: 391552
use std::cmp;
use std::io;

fn main() {
	let ln = read_line();
	let nk: Vec<_> = ln.split_whitespace().collect();
	let n: i32 = nk[0].parse().unwrap();
	let k: i32 = nk[1].parse().unwrap();
	let ans =
		if n % k == 0 {
			0
		}
		else {
			1
		};
	println!("{}", ans);
}

fn read_line() -> String {
	let mut ln = String::new();
	io::stdin().read_line(&mut ln).ok();
	ln.pop();
	return ln;
}


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

using namespace std;

int main()
{
    int n;
    string s;
    cin>>n>>s;
    map<char,int> m;
    map<char,int>::iterator it;
    int i,l;
    l=s.size();
    if(l%2!=0){

        cout<<"No"<<endl;
        return 0;

    }
    else{
    for(i=0;i<l;++i){

        ++m[s[i]];

    }
    for(it=m.begin();it!=m.end();++it){

        if((it->second)%2!=0){

            cout<<"No"<<endl;
            return 0;

        }

    }
    cout<<"Yes"<<endl;
    }

    return 0;

}


Measured memory_bytes: 256
s = input()
for i in range(97, 97+26):
    if chr(i) not in s:
        print(s + chr(i))
        exit()
a = set()
for i in range(24, -1, -1):
    if s[i] > s[i+1]:
        continue
    else:
        for j in range(ord(s[i])-97+1,26):
            a.add(chr(j+97))
        temp = min(a & set(s[i+1:]))
        print(s[:i] + temp)
        exit()
print(-1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(ll i = (n) ; i >= 0 ; i -- )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  ll a,b,n;
  cin>>a>>b>>n;
  
  ll m=min(n,b-1);
  ll ans=0;
  
    ll w=m/b;
    ll s=(a*m)/b;
    ll d=s-a*w;
    
    ans=d;
    
  cout<<ans<<endl;
}

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

A, B, C = map(str, input().split())

print(max(eval(A + '+' + B + C), eval(A + B + '+' + C), eval(B + '+' + C + A),
        eval(A + '+' + C + B), eval(B + A + '+' + C), eval(B + '+' + A + C)))

Measured memory_bytes: 3064
/*author : Yashvardhan
Saturday, May 30, 2020
6:11 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a);
		b /= 2;
		a = (a * a);
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n;
	cin >> n;

	n++;

	vi arr(n + 1);
	for(int i = 1; i <= n; i++) cin >> arr[i];

	if((arr[1] == 1 && n != 1) || arr[1] > 1 || (n == 1 && arr[1] != 1)){
		cout << -1 << endl;
		return 0;
	}

	if(n == 1){
		cout << 1 << endl;
		return 0;
	}
	
	int pref[n + 1];
	pref[0] = 0;
	for(int i = 1; i <= n; i++) pref[i] = pref[i - 1] + arr[i];

	int anc = 1;
	int lst = arr[n];
	int ans = 1;
	for(int i = 2; i <= n; i++){
		int curr = arr[i];
		int maxi = 2 * anc;
		if(curr > maxi){
			cout << - 1 << endl;
			return 0;
		}
		if(i == n){
			ans += curr;
			break; 
		}
		int pref_val = pref[n - 1] - pref[i - 1];
		int a = min(pref_val + lst, maxi);
		ans += a;
		anc = a - curr;
	}

	cout << ans << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define ll long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
#define all(v) v.begin(), v.end()
#define rall(x) (x).rbegin(), (x).rend()
#define pll pair<long long, long long>
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define vc vector<char>
#define vvc vector<vc>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
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;}
//snippets:tmp,cl,cvl,cs,co,coy,con,cov,setp

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<math.h>

using namespace std;

int main()
{
	long long n,ans,a;
	cin >> n;
	ans = 1;
	a = pow(10, 9) + 7;
	for (long long i = 1; i <= n; i++)
	{
		ans = ans *  i % a;

	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int n, m, c[4][300], dp[301]; string buf;
int main() {
	while(cin >> n >> m) {
		for(int i = 0; i < n; i++) {
			buf = ""; while(buf == "") getline(cin, buf);
			cin >> c[3][i] >> c[0][i] >> c[1][i] >> c[2][i];
		}
		int ret = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j <= m; j++) dp[j] = 0;
			for(int j = 1; j <= m; j++) {
				for(int k = 0; k < n; k++) {
					if(j - c[3][k] >= 0) dp[j] = max(dp[j], dp[j - c[3][k]] + c[i][k]);
				}
				ret = max(ret, dp[j]);
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 3132
A, B = list(map(int, input().split()))

l8 = []
l10 = []
for i in range(100):
  p8 = round((A+0.01*i)/0.08, 10)
  p10 = round((B+0.01*i)/0.1, 10)
  if p8.is_integer():
    l8.append(p8)
  if p10.is_integer():
    l10.append(p10)

p = sorted(list(set(l8) & set(l10)))
if p == []:
  print(-1)
else:
  print(int(p[0]))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,f,e) for(int (i)=(f); (i)<(e); (i)++)
#define repr(i,e,f) for(int (i)=(e-1); (i)>=(f); (i)--)

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

double dp[3001][3001];

int main(){
    int N;
    cin >> N;
    double p;
    cin >> p;
    dp[1][0] = 1.0-p;
    dp[1][1] = p;
    rep(i,2,N+1){
        cin >> p;
        dp[i][0] = dp[i-1][0] * (1.0-p);
        rep(j,1,N+1){
            dp[i][j] = dp[i-1][j] * (1.0-p) + dp[i-1][j-1] * p;
        }
    }

    // rep(j, 0, N+1){
    //     cout << j << "/" << N << " : " << dp[N][j] << endl;
    // }

    double ans = 0.0;
    rep(j, (N+1)/2, N+1){
        ans += dp[N][j];
    }
    cout << setprecision(10) << ans;

    return 0;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    string S; cin >> S;
    string ans = "AC";

    if (S.at(0) != 'A') ans = "WA";

    ll cnt = 0;
    for (int i = 1; i < len(S); i++) {
        if (isupper(S.at(i))) {
            if (i == 1 || i == len(S) - 1 || S.at(i) != 'C') {
                ans = "WA";
            }
            cnt++;
        }
    }
    if (cnt != 1) ans = "WA";
    cout << ans << endl;
}

Measured memory_bytes: 3628
x,y=map(int,input().split())
s=[list(input())for i in range(x)]
dx=[1,1,0,-1,-1,-1,0,1]
dy=[0,1,1,1,0,-1,-1,-1]
for i in range(x):
    for j in range(y):
        if s[i][j]==".":
            cnt=0
            for k in range(8):
                x_p=i+dx[k]#点i,jからの移動先のx座標
                y_p=j+dy[k]#y座標
                if 0<=x_p and x_p<x and 0<=y_p and y_p<y and s[x_p][y_p]=="#":#範囲をはみ出さないように
                    cnt+=1
            s[i][j]=cnt
for i in s:
    print(*i,sep="")

Measured memory_bytes: 3444
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;
int power(int x,int y)
{
	if(y<0)return 0;
	int ret=1;
	while(y)
	{
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return ret;
}
int getcomb(int x,int y)
{
	if(x<y||y<0)return 0;
	int ret=1;
	for(int i=1;i<=y;i++)ret=1ll*ret*(x-i+1)%mod*power(i,mod-2)%mod;
	return ret;
}
int n,k;
int main()
{
	get2(n,k);
	printendl(1ll*(getcomb(n+k-2,k-1)-getcomb(n+k-2,k-2)+mod)*power(2,max(0,n-k-1))%mod);
	return 0;
}

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

int main(){
  int A, a, b, c;
  cin >> A >> b >> c;
  a = A%b;
  for (int i = 0; i<b;i++){
    if (a*i%b == c){
      cout << "YES" << endl;
      break;
    }
    else if (i == b-1){
      cout << "NO" << endl;
      
    }
    
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        int count = 1;
        long thres = K;
        while(true) {
            if(thres > N) break;
            thres *= K;
            count++;
        }

        System.out.println(count);
        return;
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  string s; cin >> s;
  VV<> g(n);
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b, a--, b--;
    g[a].push_back(b);
    if (a != b) g[b].push_back(a);
  }
  V<> vis(n, -1);
  auto f = [&](int v) {
    bool fa = false, fb = false;
    for (int i : g[v]) if (vis[i]) (s[i] == 'A' ? fa : fb) = true;
    return fa and fb;
  };
  for (int i = 0; i < n; i++) if (vis[i] == -1 and !f(i)) {
    queue<int> q;
    vis[i] = 0; q.push(i);
    while (!q.empty()) {
      int v = q.front(); q.pop();
      for (int j : g[v]) if (vis[j] == -1 and !f(j)) {
        vis[j] = 0; q.push(j);
      }
    }
  }
  cout << (accumulate(vis.begin(), vis.end(), 0) ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 10960
/*
B - Guía

Límite de tiempo: 2 segundos / Límite de memoria: 1024 MB

Puntuación: 200 puntos

Planteamiento del problema

Has decidido escribir un libro introduciendo buenos restaurantes. No hay Restaurantes que
desea introducir: Restaurante 1, Restaurante 2, ..., Restaurante N. El restaurante i está
en la ciudad Si, y el puntaje de evaluación de ese restaurante en una escala de 100 puntos
es Pi. No hay dos restaurantes que tengan la misma puntuación.

Quieres introducir los restaurantes en el siguiente orden:

. Los restaurantes están ordenados por orden lexicográfico de los nombres de sus ciudades.
. Si hay varios restaurantes en la misma ciudad, se ordenan en orden descendente de
  puntuación.

Imprima los números de identificación de los restaurantes en el orden en que aparecen en
el libro.

Restricciones

1 ≤ N ≤ 100
S Es una cadena de longitud entre 1 y 10 (inclusive) que consiste en letras inglesas
minúsculas.
0 ≤ Pi ≤ 100
Pi es un entero
Pi ≠ Pj (1 ≤ i < j ≤ N)

Entrada

La entrada se da desde la entrada estándar en el siguiente formato:
N
S1 P1
..
SN PN


Salida

Imprimir N líneas. La línea i-th (1≤i≤N) debe contener el número de identificación
del restaurante que se presenta i-th en el libro.

Muestra de entrada 1
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

Salida de muestra 1
3
4
6
1
5
2

El orden lexicográfico de los nombres de las tres ciudades es kazan < khabarovsk < moscú.
Para cada una de estas ciudades, los restaurantes se introducen en orden descendente de
puntuación. Así, los restaurantes se introducen en el orden 3,4,6,1,5,2.

Muestra de entrada 2
10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100

Salida de muestra 2
10
9
8
7
6
5
4
3
2
1

*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
 //freopen ("d.in", "r", stdin);
 //freopen ("d.out", "w", stdout);
 int n;
 cin >> n;
 int lis[n+1], punt[n+1];
 string cad[n+1];
 for (int i = 1; i <= n; i++){
    lis[i] = i;
    cin >> cad[i] >> punt[i];
 }

 for (int i = 1; i < n; i++)
    for (int j = i+1; j <= n; j++){
       if (cad[i] == cad[j] && punt[j] > punt[i]){
          swap (punt[i], punt[j]);
          swap (lis[i], lis[j]);
          swap (cad[i], cad[j]);
      }
      else if (cad[i] > cad[j]){
          //cout << "entra" << '\n';
          swap (punt[i], punt[j]);
          swap (lis[i], lis[j]);
          swap (cad[i], cad[j]);
      }
    }
  /*for (int i = 1; i < n; i++){
    if (cad[i] == cad[i+1]){
        if (punt[i] < punt[i+1]){
            swap (punt[i], punt[i+1]);
            swap (lis[i], lis[i+1]);
            swap (cad[i], cad[i+1]);
        }
    }
  }*/

 for (int i = 1; i <= n; i++)
    cout << lis[i] << '\n';
 return 0;
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
def solve(A, B, X):
	if A > X:
		print("NO")
		return
	if A+B >= X:
		print("YES")
		return
	print("NO")

if __name__ == "__main__":
	A, B, X = list(map(int, input().split()))
	solve(A, B, X)


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(long long i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  LL l,r;
  cin >> l >> r;
  LL ans=IINF;
  repp(i,l,r+1){
    if(i-l>2019) break;
    repp(j,i+1,r+1){
      if(j-l>2019) break;
      ans=min(ans,i*j%2019);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
function main(input) {
  var digits = input.toString().length;
  var input = parseInt(input, 10);
 
  var divisor = Math.pow(10, digits - 1);
  var arr = [];
  for (var i = 0; i < digits; i++) {
  	arr.push(Math.floor(input / divisor))
  	input = input % divisor;
  	divisor /= 10;
 
  }
  var answer = arr.reduce((a, b) => a + b);
  if(answer == 1) {answer = 10;}
 
  console.log(answer);
 
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

void Main() {
    // input
    u_int64_t X;
    cin >> X;


    // translate
    u_int64_t LOOP_NUM = 1000000;
    for (u_int64_t D = 1; D < LOOP_NUM; D++) {
        for (long long A = -118; A <= 119; A++) {
            long long B = A - D;
            // cout << A << " " << B << endl;
            long long Apower5 = 1;
            long long Bpower5 = 1;
            for (int i = 0; i < 5; i++) {
                Apower5 *= A;
                Bpower5 *= B;
            }

            if (Apower5 - Bpower5 == X) {
                cout << A << " " << B << endl;
                return;
            }
        }
    }


    // output

}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
    #include <string>
    #include <vector>
    using namespace std;
     
    int main() {
    	int H,W;
    	cin >> H >> W;
    	vector<string> board(H);
    	for (int i = 0; i < H; i++) {
    		cin >> board[i];
    	}
     
    	vector<bool> row(H, false);
    	vector<bool> col(W, false);
    	for (int i = 0; i < H; i++) {
    		for (int j = 0; j < W; j++) {
    			if (board[i][j] == '#') {
    				row[i] = true;
    				col[j] = true;
    			}
    		}
    	}
     
    	for (int i = 0; i < H; i++) {
    		if (row[i]) {
    			for (int j = 0; j < W; j++) {
    				if (col[j]) {
    					cout << board[i][j];
    				}
    			}
    			cout << endl;
    		}
    	}
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int n;
  string s;
  cin >> n >> s;
  ll rcnt = 0;
  ll gcnt = 0;
  ll bcnt = 0;
  vector<int> r;
  vector<int> g;
  vector<int> b(10000);
  rep(i, n) {
    if (s[i] == 'R') {
      r.push_back(i);
      rcnt++;
    } else if (s[i] == 'G') {
      gcnt++;
      g.push_back(i);
    } else if (s[i] == 'B') {
      bcnt++;
      b[i] = true;
    }
  }
  ll m = 0;
  for (ll i = 0; i < rcnt; i++) {
    for (ll j = 0; j < gcnt; j++) {
      if (abs(r[i] - g[j]) + max(r[i], g[j]) >= 0) {
        if (b[abs(r[i] - g[j]) + max(r[i], g[j])] == true) m++;
      }
      if (min(r[i], g[j]) - abs(r[i] - g[j]) >= 0) {
        if (b[min(r[i], g[j]) - abs(r[i] - g[j])] == true) m++;
      }
      if (abs(r[i] - g[j]) % 2 == 0) {
        if (b[abs(r[i] - g[j]) / 2 + min(r[i], g[j])] == true) m++;
      }
    }
  }
  if (rcnt * gcnt * bcnt - m >= 0)
    cout << rcnt * gcnt * bcnt - m << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld  double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define getfiles    ifstream cin("birch.in");ofstream cout("birch.out");
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//const ll to[5]={0,4,6,7,9};
const ll N=1e6;
const ll R=1e4;
const ll to[7]={1,2,3,1,3,2,1};
signed main(){
    fast_io;
    ll a;
    cin>>a;
    ll ans=0;
    ans+=(a/500)*1000;
    a-=(a/500)*500;
    ans+=5*(a/5);
    cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n,sum=0;
      cin>>n;
      int a[n];
      for(int i=0;i<n;i++)
      {
        cin>>a[i];
        sum+=a[i];
      }
      sort(a,a+n);
      sum -=a[n-1];
      if(sum>a[n-1])
        cout<<"Yes";
      else cout<<"No";
    }

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
ld n,s[100],t[100],x,y,a;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i]>>t[i];
    }
    for(int i=0;i<360;i++){
        x=0.0,y=0.0;
        for(int j=0;j<n;j++){
            if(cos(i*M_PI/180)*s[j]+sin(i*M_PI/180)*t[j]>0){
                x+=s[j],y+=t[j];
            }
        }
        a=max(a,x*x+y*y);
    }
    cout<<setprecision(15)<<sqrt(a)<<endl;
}

Measured memory_bytes: 896
N = int(input())
 
input_list = []
 
for i in range(N):
  input_list.append(int(input())) 
  
input_list.sort()
 
input_list[-1] = int(input_list[-1] / 2)
 
ans = 0
for i in input_list:
  ans += i
  
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int main(){
    long long int a,b,c;
    cin>>a>>b>>c;  
    long long int result;
    result = c-a-b;  
    if( result*result > 4*a*b && result>0 )
        cout<<"Yes";
    else 
        cout<<"No";

}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut ans = n;
    for i in 1..n {
        if i * i > n {
            break;
        }
        let t = n / i;
        if i * t == n {
            ans = std::cmp::min(ans, i + t - 2);
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2132
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let mut n: i32 = read(&mut stdin_lock, &mut buf, b'\n');

    let mut cv = Vec::new();
    if n == 0 {
        cv.push('0');
    } else {
        while n != 0 {
            if n % 2 == 0 {
                cv.push('0');
                n = n / -2;
            } else {
                cv.push('1');
                n = (n - 1) / -2;
            }
        }
        cv.reverse();
    }
    let ans = cv.iter().map(|&c| c).collect::<String>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] A = new int[3];
    A[0] = sc.nextInt();
    A[1] = sc.nextInt();
    A[2] = sc.nextInt();
    Arrays.sort(A);
    System.out.println((A[2]-A[1]) + (A[1]-A[0]));
  }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e5+17;
vector<pair<int,int > > G[MAXN];
int in[MAXN],out[MAXN],plc[MAXN],vis[MAXN];
int main(int argc ,char const *argv[])
{
   	 #ifdef GoodbyeMonkeyKing
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n,m;
    cin>>n>>m;
    for (int i = 0; i < m; ++i)
    {
    	int u,v,d;
    	scanf("%d%d%d",&u,&v,&d);
    	G[u].push_back({v,d});
    	G[v].push_back({u,-d});
    	in[v]++;
    	out[u]++;
    }
    for (int i = 1; i <= n; ++i)
    {
    	plc[i] = -19990317;
    	vis[i] = 0;
    }
    queue<int > q;
    bool can = true;
    for (int i = 1; i <= n; ++i)
    {
    	if(out[i]||in[i]&&!vis[i])
    	{
    		q.push(i);
		    while(q.size()&&can)
		    {
		    	int u = q.front();
		    	q.pop();
		    	vis[u] = 1;
		    	if(plc[u]==-19990317) plc[u] = 317;
		    	debug(u);
		    	debug(plc[u]);
		    	for (int i = 0; i < G[u].size(); ++i)
		    	{
		    		int v = G[u][i].first,c = G[u][i].second;
		    		if(plc[v]==-19990317) 
		    		{
		    			plc[v]=plc[u]+c;
		    			if(!vis[v])
		    				q.push(v);
		    		}
		    		else 
		    			if(plc[v]!=plc[u]+c) 
		    				can = false;
		    	}
		    }
    	}
    }
    if(can) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 11520
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int n,a,b;
vector<long long> h;

bool solve(long long num){
    vector<long long> v=h;
    for(int i=0;i<n;i++)v[i]-=num*b;
    long long cnt=0;
    for(int i=0;i<n;i++){
        if(v[i]<=0)continue;
        cnt+=(v[i]+a-b-1)/(a-b);
    }
    return cnt<=num;
}

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

    cin>>n>>a>>b;
    h.resize(n);
    for(int i=0;i<n;i++)cin>>h[i];
    long long l=0,r=INF;
    for(int i=0;i<100;i++){
        long long mid=(l+r)/2;
        if(solve(mid))r=mid;
        else l=mid;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define vec vector<ll>
#define p pair<ll,ll>
#define vecp vector<p>
#define f(i,k,n,l) for(ll i=k;i<n;i+=1)
#define fn(i,k,n,l) for(ll i=k;i<=n;i+=1)
#define in(p) scanf("%lld",&p)
#define out(p) printf("%lld\n",p)
#define outs() printf("\n")
using namespace std;
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll x;
    cin>>x;
    if(x==0)
    {
        cout<<1<<endl;
    }
    else
    {
        cout<<0<<endl;
    }
}



Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#define M 100+5
int main(){
	char s[M],t[M],c;
	scanf("%s%s",s,t);
	int l=strlen(s),i,j;
	for(j=1;j<=l;j++){
		c=s[l-1];
		for(i=l-1;i>0;i--){
			s[i]=s[i-1];
		}
		s[i]=c;
		if(strcmp(t,s)==0)break;
	}
	if(strcmp(t,s)==0)printf("Yes");
	else printf("No");
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}
int comb(int n, int k) {
	k = min(k, n - k);
	int x = 1, y = 1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	string s;
	int q;
	deque<char> que;
	int front = 1;
	cin >> s >> q;

	rep(i, s.size()) {
		que.push_back(s[i]);
	}
	rep(i, q) {
		int x;
		cin >> x;
		if (x == 1) {
			front *= -1;
		}
		else {
			int f;
			char c;
			cin >> f >> c;
			if (f == 2) {
				if (front == 1) que.push_back(c);
				else que.push_front(c);
			}
			else {
				if (front == -1) que.push_back(c);
				else que.push_front(c);
			}
		}
	}
	string now;
	for (auto x : que) {
		now += x;
	}
	if (front == 1) {
		rep(i, now.size()) {
			cout << now[i];
		}
		cout << endl;
	}
	else {
		for (int i = now.size() - 1; i >= 0; i--) {
			cout << now[i];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const long long INF=200000000000000;
double pi=3.141592653589793;

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


ll digit(ll num){
	ll ret=0;
	string s=to_string(num);
	return s.length();
}
	
class Edge{
public:
	ll num;
	ll a;
	ll b;
	ll color=0;
	Edge(ll _num,ll _a,ll _b){
		num=_num;
		a=_a;
		b=_b;
	}
};
	
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll N,M;
	cin>>N>>M;
	string s;
	cin>>s;
	reverse(s.begin(),s.end());
	ll now=0;
	vector<ll>ans;
	while(now<N){
		bool isOK=false;
		for(int i=M;i>0;i--){
			if(now+i>N)continue;
			if(s[now+i]=='0'){
				ans.push_back(i);
				now+=i;
				isOK=true;
				//cout<<i<<endl;
			}
			if(isOK)break;
		}
		if(isOK==false){
			cout<<-1<<endl;
			return 0;
		}
	}
	
	reverse(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		cout<<ans[i]<<endl;
	}
	
}



Measured memory_bytes: 1480
def is_exp(num):
	for b in range(2, 33):
		num_copy = num
		counter = 0
		while not num_copy % b:
			num_copy /= b
			counter += 1
		if num_copy == 1:
			if counter == 1:
				return False
			else:
				return True
	else:
		return False

N = int(input())
if N <= 3:
	print(1)
else:
	for num in range(N,0,-1):
		if is_exp(num):
			print(num)
			break

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

int main()
{
  int64_t N, a, ans = 0;
  cin >> N;
  priority_queue<int64_t> pq;
  for (int i = 0; i < N * 3; i++)
  {
    cin >> a;
    pq.push(a);
  }
  while (pq.size() > N)
  {
    pq.pop();
    ans += pq.top();
    pq.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 6128
// Factors of Factorial
#include <iostream>
using namespace std;
const int mod=1e9+7;
const int p[168]={
    2,3,5,7,11
    ,13,17,19,23,29
    ,31,37,41,43,47
    ,53,59,61,67,71
    ,73,79,83,89,97
    ,101,103,107,109,113
    ,127,131,137,139,149
    ,151,157,163,167,173
    ,179,181,191,193,197
    ,199,211,223,227,229
    ,233,239,241,251,257
    ,263,269,271,277,281
    ,283,293,307,311,313
    ,317,331,337,347,349
    ,353,359,367,373,379
    ,383,389,397,401,409
    ,419,421,431,433,439
    ,443,449,457,461,463
    ,467,479,487,491,499
    ,503,509,521,523,541
    ,547,557,563,569,571
    ,577,587,593,599,601
    ,607,613,617,619,631
    ,641,643,647,653,659
    ,661,673,677,683,691
    ,701,709,719,727,733
    ,739,743,751,757,761
    ,769,773,787,797,809
    ,811,821,823,827,829
    ,839,853,857,859,863
    ,877,881,883,887,907
    ,911,919,929,937,941
    ,947,953,967,971,977
    ,983,991,997
};

int n,ans;

int main(){
    cin>>n;
    long long ANS=1;
    for(int i=0;i<168;i++){
        int N=n;
        ans=0;
        while(N){
            ans+=N/p[i];
            N/=p[i];
        }
        ANS=((ans+1)*ANS)%mod;
    }
    cout<<ANS<<endl;
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::min;


#[fastout]
fn main() {
    input! {
    n: usize,
    a: usize,
    b: usize
    }
    let ans = min(n * a, b);
    println!("{}", ans);
}



Measured memory_bytes: 2104
#include <iostream>

using namespace std;

int main() {
  size_t N, D;
  cin >> N >> D;

  size_t count = 0;
  for (size_t i = 1; i <= N;) {
    count++;
    i += D * 2 + 1;
  }

  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
def i_input(): return int(input())


def i_map(): return map(int, input().split())


def i_list(): return list(i_map())


def i_row_list(N): return [i_list() for _ in range(N)]


n = i_input()
abc = i_row_list(n)
dp=[]
for i in range(n):
    dp.append([0]*3)
dp[0] = abc[0]
for i in range(n):
    if i!=0:
        for j in range(3):
            for k in range(3):
                if j!=k:
                    dp[i][k]=max(dp[i][k],dp[i-1][j]+abc[i][k])

print(max(dp[n-1]))





Measured memory_bytes: 50356
N, M = map(int, input().split())
Coins = list(map(int, input().split()))

DP = [10 ** 9 for _ in range(N + 1)]
DP[0] = 0

for i in range(N):
    for c in Coins:
        if i + c <= N:
            DP[i + c] = min(DP[i + c], DP[i] + 1)

print(DP[N])



Measured memory_bytes: 7380
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL H, W, K;
LL dp[102][9];

bool valid(const bitset<8>& b) {
  for (int i = 0; i < W - 1; ++i) {
    if (b.test(i) && b.test(i + 1)) return false;
  }
  return true;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  cin >> H >> W >> K; --K;

  vector<vector<LL>> dp(H + 2, vector<LL>(W, 0));
  dp[0][0] = 1;

  for (int h = 0; h < H; ++h) {
    for (int w = 0; w < W; ++w) {
      for (int i = 0; i < (1 << (W-1)); ++i) {
        bitset<8> b(i);
        if (!valid(b)) continue;

        if (w > 0 && b.test(w-1)) {
          dp[h + 1][w - 1] += dp[h][w];
          dp[h + 1][w - 1] %= kMod;
        } else if (b.test(w)) {
          dp[h + 1][w + 1] += dp[h][w];
          dp[h + 1][w + 1] %= kMod;
        } else {
          dp[h + 1][w] += dp[h][w];
          dp[h + 1][w] %= kMod;
        }
      }
    }
  }
  cout << dp[H][K] << endl;
}


Measured memory_bytes: 3668