akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiramekun at 20:44 on 2019-12-08.
 */
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    ll h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w)), b(h, vector<int>(w));
//    int a[h][w], b[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    rep(i, h) rep(j, w) cin >> b[i][j];

    ll max_diff = 2 * 80 * 160;
    vector<vector<vector<bool>>> dp(h, vector<vector<bool>>(w, vector<bool>(max_diff)));
//    bool dp[h][w][max_diff];
    rep(i, h) rep(j, w) rep(l, max_diff) dp[i][j][l] = false;

    ll mid = max_diff / 2;
    dp[0][0][b[0][0] - a[0][0] + mid] = true;
    dp[0][0][-b[0][0] + a[0][0] + mid] = true;

    rep(i, h) {
        rep(j, w) {
            rep(l, max_diff) {
                if (!dp[i][j][l]) continue;
                if (i + 1 <= h - 1) {
                    dp[i + 1][j][l + b[i + 1][j] - a[i + 1][j]] = true;
                    dp[i + 1][j][l - b[i + 1][j] + a[i + 1][j]] = true;
                }
                if (j + 1 <= w - 1) {
                    dp[i][j + 1][l + b[i][j + 1] - a[i][j + 1]] = true;
                    dp[i][j + 1][l - b[i][j + 1] + a[i][j + 1]] = true;
                }
            }
        }
    }
    ll ans = 1e18;
    rep(i, max_diff) {
        if (dp[h - 1][w - 1][i]) ans = min(ans, abs(i - mid));
    }
    cout << ans << '\n';
}

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

int n, a[100100];
vector<int> f[100100];

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

  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];

  long long ans = 0;
  for (int i = 1; i < n - 1; i++)
  {
    long long score = 0;
    for (int j = 1; i * j < n - 1 && n - 1 - i * j > i; j++)
    {
      score += a[i * j] + a[n - 1 - i * j];
      if ((n - 1) % i == 0 && (n - 1) / i <= j * 2)
        break;
      ans = max(ans, score);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2944
import numpy as np
N,K,Q = list(map(int,input().split(" ")))
A = np.full(N,K)
A -= Q
for i in range(Q):
    B = int(input())
    A[B - 1] += 1
for i in A:
    if i < 1:
        print("No")
    else:
        print("Yes")

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

int main() {
  int H, W;
  string a;
  cin >> H >> W;
  
  for(int i = 0; i < H + 2; i++){
    if(i == 0 || i == H + 1){
      for(int j = 0; j < W + 2; j++){
        cout << '#';
      }
      cout << endl;
      continue;
    }
    for(int j = 0; j < 3; j++){
      if(j == 0 || j == 2){
        cout << '#';
      }else{
        cin >> a;
        cout << a;
      }
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
int N, M, sum, num, cnt;
cin >> N >> M;
int a[N+1], b[N+1];
int c[M+1], d[M+1];
  for(int i = 0;i < N;i++) {cin >> a[i] >> b[i];}
  for(int i = 0;i < M;i++) {cin >> c[i] >> d[i];}
  
  for(int i = 0; i < N;i++){
    sum = 400000001;
    cnt = 0;
   for(int j = 0;j < M;j++){
   num = abs(a[i] - c[j]) + abs(b[i] - d[j]);
     if(sum > num){
     sum = num;
     cnt = j + 1;  
     }
   } 
    cout << cnt << endl;
  }
    
  return 0;
}

Measured memory_bytes: 256
n, w_max = gets.split.map(&:to_i)
items = Array.new(n){gets.split.map(&:to_i)}
dp = Array.new(100001, Float::INFINITY)
dp[0] = 0
items.each do |w, v|
  prev = dp.dup
  prev.each_with_index do |pw, pv|
    nw = pw + w
    nv = pv + v
    dp[nv] = nw if nw <= w_max && nw < prev[nv]
  end
end
puts dp.rindex{|v| v != Float::INFINITY}


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

using namespace std;
using ll = long long;


int main()
{
    ll a, v, b, w; cin >> a >> v >> b >> w;
    ll t; cin >> t;
    ll z = abs(a - b);
    if(v <= w) {
        cout << "NO" << endl;
        return 0;
    }
    cout << (z <= abs(v - w) * t ? "YES" : "NO") << endl;
}

Measured memory_bytes: 3636
#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>;


int main() {
    ll x;
    cin >> x;
    ll a, b;
    for (a = -120; a <= 120; a++)
        for (b = -120; b <= 120; b++)
            if (pow(a, 5)-pow(b, 5) == x) {
                cout << a << " " << b << endl;
                return 0;
            }
    return 0;
}

Measured memory_bytes: 4096
//一般p在1e6以下
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int p;

inline LL exp_mod(LL a,int b){
    LL ret=1;
    while(b){
        if(b&1){
            ret=ret*a%p;
        }
        a=a*a%p;
        b>>=1;
    }
    return ret;
}
LL comb(int n, int m){
    if(m==0)return 1;
    LL x=1, y=1;
    m=min(m,n-m);
    for(int i=0;i<m;++i){
        x=x*(n-i)%p;
        y=y*(m-i)%p;
    }
    return x*exp_mod(y,p-2)%p;
}
LL lucas(int n, int m){
	if(m==0) return 1;
    if(n<m)return 0;
    if(n < p && m < p)return comb(n, m);
    return lucas(n % p, m % p) * lucas(n / p, m / p) % p;
}
int main(){
   
    
        LL n,a,b;cin>>n>>a>>b;
        p=1000000007;
        LL ans=(exp_mod(2,n)-1)-lucas(n,a)-lucas(n,b);
        while(ans<0) ans=(ans+p);
        printf("%lld\n", (ans)%p);
    
    return 0;
}


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

def solve():
    N = int(input())
    K = int(input())
    X = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        ans += min(X[i]*2, (K-X[i])*2)
    
    print(ans)

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
bool poss(int pref[], string &s, int n, int x, int k){
    
    for(int i = x - 1; i < n; i++){
        int r = pref[i-x+1];
        if(s[i-x+1] == '0')
        r--;
        if(pref[i] - r <= k){
        return true;
        }
    }
    return false;
}
int main() {
    int n, k;
    string s;
    cin >> n >> k;
    cin >> s; 
    int pref[n];
    pref[0] = 0;
    int l = 0;
    if(s[0] == '0')
    pref[0] = ++l;
    else
    pref[0] = 0;
    //cout << pref[0] << " "; 
    for(int i = 1; i < n; i++){
        if(s[i] == '0' && s[i-1] == '0')
        pref[i] = l;
        else if(s[i] == '0' && s[i-1] == '1')
        pref[i] = ++l;
        else
        pref[i] = pref[i-1];
        //cout << pref[i] << " ";
    }
   // cout << endl;
    int low = 1, high = n, ans = 1;
    while(low <= high){
        int mid = (low + high) / 2;
        //cout << high << " " << low << " " << mid << endl;
        if(poss(pref, s, n, mid, k)){
            ans = mid;
            low = mid + 1;
        }
        else
            high = mid - 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
map<int, int> mp;
int main()
{
	int r, d, x;
	cin >> r >> d >> x;
	for (int i = 0; i < 10; i++) {
		cout << r * x - d << endl;
		x = r * x - d;
	}
	return 0;
}

Measured memory_bytes: 256
import math
import sys
from collections import deque
import copy
def mi() : return map(int,input().split())
a,b=mi()
c,d=mi()
e=int(input())
if d>=b:
  print("NO")
else:
  if (b-d)*e>=abs(a-c):
    print("YES")
  else:
    print("NO")

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

int main() {
  int N;
  cin >> N;
  int c = 0;
  for (int i = 0; i < N; i++){
    
    string color;
    cin >> color;
    if (color == "Y")
      c += 1;
  }
    
  if (c>0)
    cout << "Four" <<endl;
  else
    cout << "Three" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<regex>
#include<ctype.h>
using namespace std;

int main(void) {
	
	int a, b, k;
	cin >> a >> b >> k;

	int min_n = min(a, b), cnt = 0, i;
	
	for (i = min_n; 0 < i; i--) {
		if (a%i == 0 && b%i == 0) {
			cnt++;
			if (cnt == k) break;
		}
	}

	cout << i << endl;

	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
ans = [0] * n
det = [400000001]*n
for i in range(m):
    c, d = map(int, input().split())
    for p in range(n):
        dif = abs(c-x[p][0])+abs(d-x[p][1])
        if det[p] > dif:
            ans[p] = i
            det[p] = dif
for i in ans:
    print(i+1)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int H, N;
int A[1010], B[1010];
ll dp[1010][10101];

int main()
{
    cin >> H >> N;
    rep(i, 0, N)
    {
        cin >> A[i] >> B[i];
    }
    rep(i, 0, 1010)
    {
        rep(j, 0, 10101)
        {
            dp[i][j] = inf;
        }
    }

    dp[0][0] = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= H; ++j)
        {
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
            dp[i + 1][min(j + A[i], H)] = min(dp[i + 1][min(j + A[i], H)], dp[i + 1][j] + B[i]);
        }
    }
    cout << dp[N][H] << endl;
}


Measured memory_bytes: 80000
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		
		int n = stdIn.nextInt(); 
		
		long[] a = new long[n];
		long[] b = new long[n];
		
		long max = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextLong();
			b[i] = stdIn.nextLong();
			
			max = Math.max(max, a[i]);
			
		}
		
		
		for(int i = 0; i < n; i++) {
			if(max == a[i]) {
				System.out.println(max + b[i]);
				return;
			}
		}
		
		
		
	}

}


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

int main(){

    int ans;

    for(int i = 0;i < 5;i++){
        int x;
        cin >> x;
        if(x == 0){
            ans = i + 1;
            break;
        }
    }

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

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, mini = 1000000000000001, a;
  cin >> N;
  for(int i = 0; i < 5; i++){
    cin >> a;
    mini = min(a, mini);
  }
  N--;
  cout << 5 + (N / mini) << endl;
  return 0;
}


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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int a, b;
  cin >> a >> b;

  int c = 0;
  for (int i = a; i <= b; ++i) {
    string s = to_string(i);
    if (s[0] == s[4] && s[1] == s[3]) {
      c++;
    }
  }
  p(c);
}

Measured memory_bytes: 256
N,K = map(int, input().split())
R,S,P = map(int, input().split())
T = input()



dp = [[0 for _ in range(3)] for _ in range(N+1)]

#マシン-高橋君の手の組で得られる点
plus = [[0,0,P],[R, 0,0],[0,S,0]]
mhand = {}
mhand["r"] = 0
mhand["s"] = 1
mhand["p"] = 2

order_p = [[] for _ in range(N+1)]

for i in range(N):
    for j in range(3):
        # まだK回やってないのでなんでも出せる
        if (i+1) <= K: 
            dp[i+1][j] = max(dp[i]) + plus[mhand[T[i]]][j]
        else:
            # 基本的には一回前の勝負の最大の部分から今の勝負に映るのが良い
            # 一方で、K回前と同じ手が出せないので、K回前と今回勝ちとなる手がおなじならその手は出せないので-INFとかでいいと思う
            # 例外的に、K回前の３個の得点のうち、最大得点がふたつあるなら、どちらからでも派生できるので、勝ちの手を出せる

            # 最大が二つなので、いずれにせよ最大から派生できる
            if order_p[i+1-K][-1][0] == order_p[i+1-K][-2][0]:
                dp[i+1][j] = max(dp[i]) + plus[mhand[T[i]]][j]
            # 今回勝てる手とK回目に出した手が被る場合、二番目に大きいところから派生
            else:
                if j == order_p[i+1-K][-1][1]:
                    dp[i+1][j] = -float("inf")
                else:
                    dp[i+1][j] = max(dp[i]) + plus[mhand[T[i]]][j]


    # K回前にどの手を出すと最大か分かるようにしておく
    order_p[i+1] = [(dp[i+1][0], 0), (dp[i+1][1], 1), (dp[i+1][2], 2)]
    order_p[i+1].sort()
            
             


print(max(dp[-1]))




Measured memory_bytes: 53536
function main(input) {
	var lines = input.split("\n").slice(0,200);
	for (var i = 0; i < lines.length; i++) {
		var digits = lines[i].split(" ").map(function(value) {return parseInt(value);});
		var digit = digits[0] + digits[1]; 
		if (!isNaN(digit)) {console.log((digit + '').length);}
	}
}
main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 16028
while input=gets do
  a,b=input.split(" ").collect do |x|
    x.to_i
  end
  ac=a
  bc=b
  if ac<bc
    mem=ac
    ac=bc
    bc=mem
  end
  until bc==0 do
    mem=ac%bc
    ac=bc
    bc=mem
  end
  print ac," ",a*b/ac,"\n"
end

Measured memory_bytes: 6096
def frame(h,w):
    m,b,p = "#","\n","."
    print m*w+b + (m+p*(w-2)+m+b)*(h-2) + m*w+b

while 1:
    h,w=map(int,raw_input().split())
    if h==w==0:break
    frame(h,w)

Measured memory_bytes: 4236
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    cin >> n;
    vector<lli> v;
    for (lli i = 0; i < n; i++) {
        cin >> a;
        v.pb(a);
    }

    sort(v.rbegin(), v.rend());

    lli ans = v[0];
    lli beg = 1;
    lli cnt = 0;
    for (lli i = 2; i < n; i++) {
        ans += v[beg];
        cnt++;
        if (cnt == 2) {
            cnt = 0;
            beg++;
        }
    }

    cout << ans << endl;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

void io_set() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

ll n;
ll a[100005];
ll dp[100005];

ll func(ll i) {
	if (i <= 1) {
		return 0;
	}
	if (i == 2) {
		dp[i] = abs(a[2] - a[1]);
		return dp[i];
	}
	if (dp[i] != -1) {
		return dp[i];
	}
	return dp[i] = min(func(i - 1) + abs(a[i] - a[i - 1]),  func(i - 2) + abs(a[i] - a[i - 2]));
}

void solve() {
	cin >> n;
	fo(i, 1, n) {
		cin >> a[i];
	}
	mem(dp, -1);
	cout << func(n);

}

int main() {
	IOS;
	//io_set();
	ll tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll a,b,h,m; cin >> a >> b >> h >> m;
  double shita = 0;
  if(60*h+m>12*m){
    shita = (60*h-11*m)*M_PI/360;
  }else{
    shita = (11*m-60*h)*M_PI/360;
  }
  if(debug){
    printf("%.12f",shita);
    cout << endl;
    printf("%.12f",cos(shita));
    cout << endl;
  }
  double ans=sqrt(abs((double)a*a+(double)b*b-(double)2*a*b*cos(shita)));
  printf("%.12f",ans);
  return 0;
}

Measured memory_bytes: 4196
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

using Graph=vector<vector<int>>;
Graph G;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  if(n%2!=0) cout<<0<<endl;
  else{
    n/=10;
    n*=10;
    ll num=n/10;
    ll sum=0;
    while(num>0){
      sum+=num;
      num/=5;
    }
    cout<<sum<<endl;
  }
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <set>
#define N 100005
using namespace std;
struct edge{
	int k,next;
}e[N<<1];
int w[N],home[N],n,m,cnt=-1,L[N],R[N],D=1;
const int inf=1<<28;
void add(int x,int y){
	cnt++;
	e[cnt].k=y;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void dfs(int k,int F){
	if(w[k]!=inf) L[k]=R[k]=w[k];
	else L[k]=-inf,R[k]=inf;
	for(int i=home[k];~i;i=e[i].next) if(e[i].k!=F){
		dfs(e[i].k,k);
		L[k]=max(L[k],L[e[i].k]-1);
		R[k]=min(R[k],R[e[i].k]+1);
	}
	if(L[k]>R[k]) D=0;
}
int vis[400005];
void dfs1(int k,int F){
	if(F){
		if(w[F]-1>=L[k]&&w[F]-1<=R[k]) w[k]=w[F]-1;
		else w[k]=w[F]+1;
	}
	if(w[k]<L[k]||w[k]>R[k]) D=0;
	for(int i=home[k];~i;i=e[i].next) if(e[i].k!=F){
		dfs1(e[i].k,k);
	}
}
int main(){
	//freopen("test.in","r",stdin);
	memset(home,-1,sizeof(home));
	scanf("%d",&n);
	for(int i=1;i<=n;i++) w[i]=inf;
	for(int i=1,x,y;i<n;i++){
		scanf("%d%d",&x,&y);
		add(x,y);add(y,x);
	}
	scanf("%d",&m);
	int rt;
	for(int i=1,x,y;i<=m;i++){
		scanf("%d%d",&x,&y);
		w[x]=y;
		rt=x;
	}
	dfs(rt,0);
	dfs1(rt,0);
	if(!D) puts("No");
	else{
		puts("Yes");
		for(int i=1;i<=n;i++) printf("%d\n",w[i]);
	}
	return 0;
}

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

int a, b;

void out(int a, int b) {
	for (int i = 1; i <= b; i++) printf("%d", a);
}

int main()
{
	scanf("%d%d", &a, &b);
	if (a < b) out(a, b);
	else  out(b, a);
	return 0;
}

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

ll n;
vector <ll> v[1000010];

int main() {
	cin>>n;
	ll a[n+1];
	bool b[n+1];
	memset(b, 0, sizeof(b));
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		v[a[i]].push_back(i);
	}
	for (int i=1; i<1000010; i++) {
		if (!v[i].empty()) {
			for (int j=2; i*j<1000010; j++) {
				for (auto k: v[i*j]) {
					b[k]=1;
				}
				v[i*j].clear();
			}
			if (v[i].size()>1) {
				for (auto j: v[i]) {
					b[j]=1;
				}
				v[i].clear();
			}
		}
	}
	ll ans=0;
	for (int i=1; i<=n; i++) {
		if (!b[i]) ans++;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 35016
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;


int main() {
 
  int64_t N;
  long double M,ans;
  cin>>N>>M;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  
  ans=N*M;
  //cout<<floor(ans)<<endl;
  cout <<setprecision(18) <<floor(ans) << endl;
}

Measured memory_bytes: 3800
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll A, B, C;
  cin >> A >> B >> C;

  string ans = "No";
  if (A + B >= C) ans = "Yes";

  cout << ans << endl;

  return 0;
}


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

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

    for (;n--;) {
        string s, r;
        int a, b;
        cin >> s >> a >> b;
        if (s == "replace") {
            cin >> r;
            for (int i = a; i <= b; i++) {
                str[i] = r[i - a];
            }
        }
        if (s == "reverse") {
            string t = str.substr(a, b - a + 1);
            reverse(t.begin(), t.end());
            for (int i = a; i <= b; i++) {
                str[i] = t[i - a];
            }
        }
        if (s == "print") {
            for (int i = a; i <= b; i++) {
                cout << str[i];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <cmath>
#include <cstdio>
#include  <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)
typedef long long lint;
#define SZ(x) ((int)(x).size())
int main()
{
	int a, b;
	cin >> a >> b;
	if (b < a) {
		cout << a-1 << endl;
	}
	else cout << a << endl;

	return 0;
}

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

int n, m, a, b;
int d[1000];

int main(){
    int x = 0;
    cin >> n >> m >> a >> b;
    rep(i,n) cin >> d[i];
    int cnt = 0;
    rep(i,n){
        if(d[i] >= a){
            x = i;
            cnt++;
        } else break;
    }
    if(n-cnt < m) for(int i = x; i >= 0; i--){
        if(d[i] >= a && d[i] <= b){
            cnt--;
            continue;
        }
        if(d[i] >= a) break;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1168
n = gets.to_i
meta = []
# 全部zero3つ埋めの文字列にしてソートする
# hogestr_001_020
n.times do |i|
    s, p = gets.split.map(&:chomp)
    meta.push("#{s}_#{format('%03d', p.to_i)}_#{format('%03d', i+1)}")
end

# cityでソート
meta.sort!
res = []
city = []
s_o = meta[0].split('_')[0]
# puts ("s_o: #{s_o}")
meta.each do |m|
    s_n, p, j = m.split('_')
    # 違うcityになるまで追加
    # puts(s_n, p, j)
    if s_n == s_o then
        # 同じなら、同じmetaに追加
        city.push(p+'_'+j)
        # puts city
    else
        city = city.sort.reverse
        # 次のcityになったら前のcityを追加して新規作成
        city.each do |c|
            res.push(c.split('_')[1].to_i)
        end
        # リセット
        s_o = s_n
        city = []
        city.push(p+'_'+j)
    end
end
city = city.sort.reverse
# 次のcityになったら前のcityを追加して新規作成
city.each do |c|
    res.push(c.split('_')[1].to_i)
end
puts res

Measured memory_bytes: 1788
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <functional>
#include <map>
using namespace std;

int N, A[100009], cnt = 0;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3112
n=int(input())
length=len(str(n))
def f(x):
    return 3**x-3*(2**x)+3
answer=0
for i in range(1,length):
    answer=answer+f(i)
def g(i,s):
    if i==length:
        if int(s)<=n and '3' in s and '5' in s and '7' in s:
            return 1
        else:
            return 0
    else:
        return g(i+1,s+'3')+g(i+1,s+'5')+g(i+1,s+'7')
answer=answer+g(0,'')
print(answer)
    


Measured memory_bytes: 42472
fn gcd(a: usize, b: usize) -> usize {
    let r = a % b;
    if r > 0 { gcd(b, r) } else { b }
}

fn main() {
    let x: usize = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        buf.trim_end().parse().unwrap()
    };

    let ans = 360 / gcd(x, 360);
    println!("{}", ans);
}

Measured memory_bytes: 2072
#include<stdio.h>
#include<math.h>

int Distance_Integer(int A[10][10],int N ,int D){
    float Distance;
    int counter = 0;
    int i,j,d;
    for(i = 0;i<N-1;i++){
        for(j = i+1;j<N ; j++){
            Distance = 0;
            for(d = 0 ; d<D;d++)
                Distance += pow(A[i][d] - A[j][d],2);
            if(pow(Distance,0.5) == (int)(pow(Distance,0.5)))
                counter++;
        }
    }
    return counter;
}


int main(){
    int N,D,A[10][10];
    int counter = 0;
    int i,j;
    
    //Nの取得
    scanf("%d %d",&N,&D);
    
    for(i = 0 ; i< N ;i++){
        for(j = 0 ; j<D ; j++){
            scanf("%d",&A[i][j]);
        }
    }
    counter = Distance_Integer(A,N,D);
    printf("%d",counter);
    
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for (v = 0; v < n; ++v) {
		if (!M[u][v]) continue;
		if (color[v] == WHITE) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs() {
	for (int u = 0; u < n; ++u) color[u] = WHITE;
	tt = 0;

	for (int u = 0; u < n; ++u) {
		if (color[u] == WHITE) dfs_visit(u);
	}
	for (int u = 0; u < n; ++u) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}

int main() {
	int u, v, k;

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

	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &u, &k);
		u--;
		for (int j = 0; j < k; ++j) {
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

	dfs();
}


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

int main(){
    long long N;
    cin >> N;
    
    long long x,l;
    vector<pair<long long , long long>> a;
    for(long long i = 0; i < N; i++){
        cin >> x >> l;
        a.push_back(make_pair(x + l, x - l));
    }
    sort(a.begin(),a.end());
    long long now = -(1LL<<60);
    long long ans = 0;
    for(int i = 0; i < N; i++){
        if(a[i].second < now) continue;
        ans++;
        now = a[i].first;
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
using namespace std;

const int N = 110;
const int K = 3;
int dp[5][N][K];
int n, k;
char str[N];
int ans;

int dfs(int m, int u, int limit) {
	if (u > k)
		return 0;
	if (m > n)
		return (u == k);
	if (dp[u][m][limit] != -1)
		return dp[u][m][limit];

	int t = limit == 1 ? str[m] - '0' : 9, ans = 0;

	for (int i = 0; i <= t; i++)
		ans += dfs(m + 1, u + (i != 0), limit && i == t);
	return dp[u][m][limit] = ans;
}

int main() {
	cin >> (str + 1) >> k;
	n = strlen(str + 1);
	memset(dp, -1, sizeof dp);
	cout << dfs(1, 0, 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (2e9)
#define EPS (1e-6)
#define int ll
#define NATHANLEE_IS_EVIL true
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<endl;}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL);
	cin.tie(0);
}

ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

bool check(int l,vector<int> &v,int k){
	int cnt=0;
	for(auto &i:v) cnt+=(i-1)/l;
	return cnt<=k;
}

int32_t main() {
	INIT();
	//code...
	int n,k; cin>>n>>k;
	vector<int> v(n);
	for(auto &i:v) cin>>i;
	int hi=1000000100,lo=0;
	while(hi-lo>1){
		int m=(hi+lo)/2;
		if(check(m,v,k)) hi=m;
		else lo=m;
	}
	cout<<hi<<"\n";
	return 0;
}

Measured memory_bytes: 4672
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int binSearch(int* a, int l, int r, int x) {
    if(l == r) return l;
    if(r - l == 1) {
        if(a[l] >= x) return l;
        return r;
    }
    int pivot = (l + r) / 2;
    if (a[pivot] == x) return binSearch(a, l, pivot, x);
    else if(a[pivot] < x) return binSearch(a, pivot + 1, r, x);
    else return binSearch(a, l, pivot, x);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    int ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            int d = a[i] - a[j] + 1;
            int smallestOkIndex = binSearch(a, j, i, d);
            // cout << i << " : " << j << "\n" << smallestOkIndex << "\n";
            ans += i - smallestOkIndex;
            if (smallestOkIndex == j) --ans;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

#define endl "\n"
//a#define ll unsigned long long
#define int long long int
#define vi vector <int >
#define vvi vector < vector < int >  >
#define vii vector < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define fore(i,c) for(int i = 1; i <= (int)c; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
//#define double long double
#define a first
#define b second


int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);

   int n, a, b;
   cin >> n >> a >> b;
   cout << a*(n/(a + b)) + min(a, n%(a + b)) << endl;

    return 0;
}


Measured memory_bytes: 256
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

m = max(a)
d = [0] * (m + 1)
d[1] = 1
for i in range(2, m + 1):
    for j in range(i, m + 1, i):
        if d[j] == 0:
            d[j] = i

def prime_factorize(n):
    res = []
    if n == 1:
        return res
    while n > 1:
        res.append(d[n])
        n //= d[n]
    return res

def is_pairwise_coprime():
    exists = [0] * (m + 1)
    for ai in a:
        for p in set(prime_factorize(ai)):
            if exists[p]:
                return False
            exists[p] = 1
    return True

def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)

def is_setwise_coprime():
    return reduce(gcd, a) == 1


if is_pairwise_coprime():
    print('pairwise coprime')
elif is_setwise_coprime():
    print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 193516
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var m = sc.nextInt();
		var a = new SortedList();
		for (var i = 0; i < n; i++) {
			a.add(sc.nextInt());
		}
		sc.close();

		for (var i = 0; i < m; i++) {
			var av = a.get(n -1);
			a.remove(n -1);
			a.add(av / 2);
		}

		var sum = 0L;
		for (var i = 0; i < n; i++) {
			sum += a.get(i);
		}
		System.out.println(sum);
	}

	public static class SortedList {
		List<Integer> list;

		public SortedList() {
			this.list = new ArrayList<Integer>();
		}

		public SortedList(List<Integer> list) {
			this.list = list;
		}

		public int get(int index) {
			return list.get(index);
		}

		public void add(int value) {
			list.add(search(value), value);
		}

		public int remove(int index) {
			return list.remove(index);
		}

		private int search(int value) {
			var min = 0;
			var max = list.size();
			while (max - min > 1) {
				var mid = min + (max - min) / 2;
				if (list.get(mid) <= value) {
					min = mid;
				} else {
					max = mid;
				}
			}

			if (max - min == 1 && list.get(min) <= value) {
				min++;
			}
			return min;
		}
	}
}


Measured memory_bytes: 60932
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		int sum = 0, ave = 0, c=0;
		for(;sc.hasNext();c++) {
			String[] vals = sc.next().split(",");
			sum += Integer.parseInt(vals[0]) * Integer.parseInt(vals[1]);
			ave += Integer.parseInt(vals[1]) * 10;
		}
		ave /= c; ave += 5;
		ave /= 10;
		System.out.println(sum);
		System.out.println(ave);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace __gnu_pbds;
tree<P,null_type,less<P>,rb_tree_tag,tree_order_statistics_node_update>tr;


int a[200000];

signed main(){
	int n;scanf("%d",&n);
	rep(i,n){
		scanf("%d",&a[i]);
		tr.insert(P(a[i],i));
	}
	rep(i,n){
		tr.erase(P(a[i],i));
		int l=0,r=1000000000;
		int A=n/2;
		while(l!=r){
			int t=(l+r)/2;
			if(tr.order_of_key(P(t,INT_MAX))>=A)r=t;
			else l=t+1;
		}
		printf("%d\n",l);
		tr.insert(P(a[i],i));
	}
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

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

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int c = 0,f = 0;
  rep(i,s.size()){
    if(s[i] == 'C'){
      ++c;
    }
    if(s[i] == 'F'){
      if(c)
      ++f;
    }
  }
  if(f)
    cout << "Yes" << endl;
  else{
    cout << "No" << endl;
  }
  return 0;
}



Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n');
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr('time : ' + end + 'ms');
  myerr('memory : ' + Math.round(process.memoryUsage().heapTotal / 1024) + 'KB');
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var N =nextInt();
  var s = nextCharArray();
  var list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for(var i = 0; i < s.length; i++){
  	var newV = list.indexOf(s[i]) + N;
  	newV %= 26;
  	s[i] = list[newV];
  }
  myout(myconv(s,0));
}

Measured memory_bytes: 33736
n=int(input())
s=input()
w,e=[],[]
a,b=0,0
for i in range(n):
    if s[i]=='W':
        a+=1
    else:
        b+=1
    w.append(a)
    e.append(b)
x=n
for i in range(n):
    if s[i]=='W':
        if x>e[-1]-e[i]+w[i]-w[0]:
            x=e[-1]-e[i]+w[i]-w[0]
    else:
        if x>e[-1]-e[i]+w[i]:
            x=e[-1]-e[i]+w[i]
print(x)

Measured memory_bytes: 17968
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int i, N, l, r, cou = 0;
   
   cin >> N;
   
   for(i = 0; i < N; i++){
       cin >> l >> r;
       
       cou = cou + (r - l + 1);
       
   }
   cout << cou << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 200005
using namespace std;

int main() {
  int n ,k;
  cin >> n >> k;
  if(n%k==0) cout << 0 << endl;
  else cout << 1 << endl;
  return 0;
}

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

#define rep(i,beg,end)   for (auto i=(beg);i<(end);i++)
#define rep2(name,container) for(auto name=begin(container); name != end(container);name++)
#define all(cont)           begin(cont), end(cont)
#define rall(cont)           rbegin(cont), rend(cont)
using ll = long long;
using vi = vector<ll>;
const ll INFMAX = LLONG_MAX;
const ll INFMIN = LLONG_MIN;
const ll MOD = 1000000007;


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

	ll n; string s;
	cin >> n >> s;
	rep(i, 0, s.length()) {
		int letter_idx = s[i] - 'A';
		s[i] = 'A' + (letter_idx + n) % 26;
	}
	cout << s << endl;

	return 0;
}


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  ll x;
  cin >> x;
  dump(x);
  vl p(1001);
  vl m(1001);
  rep(i, 1001) p[i] = i;
  rep(i, 1001) m[i] = -i;
  rep(j, 4) {
    rep(i, 1001) {
      p[i] *= i;
      m[i] *= i;
    }
  }
  // dump(p);
  // dump(m);
  // return;
  rep(i, 1001) rep(j, 1001) {
    // dump(p[i], m[j], x);
    if (p[i] - m[j] == x) {
      cout << i << " " << -j << endl;
      return;
    }
    if (m[i] - p[j] == x) {
      cout << -i << " " << j << endl;
      return;
    }
    if (p[i] - p[j] == x) {
      cout << i << " " << j << endl;
      return;
    }
    if (m[i] - m[j] == x) {
      cout << -i << " " << -j << endl;
      return;
    }
  }
  cout << 0 << " " << 0 << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

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

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

int main()
{
	int X, A, B;
	cin >> X >> A >> B;
	int n = (X - A) / B;
	cout << X - A - B*n << endl;
	return 0;
}

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

int main(){
  string N;
  cin >> N;
  
  int n = N.size();
  char a;
  int b;
  int s = 0;
  for (int i=0 ; i<n ; i++){
    a = N.at(i);
    b = a - '0';
    s += b;
    s %= 9;
  }
  
  if (s == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3708
#include <stdio.h>
int a[1000001];
int main(){
    int K;
    scanf("%d",&K);
    a[1]=7%K;
    for(int i=2;i<=K;i++)a[i]=(a[i-1]*10+7)%K;

    for(int i=1;i<=K;i++)if(a[i]==0){
        printf("%d\n",i);
        return 0;
    }
    printf("-1\n");
}

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

int main(){
  string S;
  cin >> S;
  string T=S.substr(0,2);
  string U=S.substr(2,2);
  int A=stoi(T);
  int B=stoi(U);
  if(0<A && A<13 && 0<B && B<13){
    cout << "AMBIGUOUS" << endl;
  }
  else if(0<A && A<13){
    cout << "MMYY" << endl;
  }
  else if(0<B && B<13){
    cout << "YYMM" << endl;
  }
  else{
    cout << "NA" << endl;
  }
}
  

Measured memory_bytes: 3632
N, S = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
dp = [[0 for j in range(S + 1)] for i in range(N + 1)]
dp[0][0] = 1
for i in range(N) : 
    for j in range(S + 1) : 
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= mod 
        if j + A[i] <= S : 
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod
print(dp[N][S])

Measured memory_bytes: 147648
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main()
{
	string a,b,c;
	cin >> a >> b >> c;
	int sa=a.size(),
	sb=b.size(),
	sc=c.size();
	int ai=0,bi=0,ci=0;
	char next = a[0];
	ai++;
	while (1)
	{
		if(next=='a')
		{
			if(ai==sa)
			{
				cout<<'A'<<endl;
				return 0;
			}
			next=a[ai];
			ai++;
			continue;
		}
		if(next=='b')
		{
			if(bi==sb)
			{
				cout<<'B'<<endl;
				return 0;
			}
			next=b[bi];
			bi++;
			continue;
		}
		if(next=='c')
		{
			if(ci==sc)
			{
				cout<<'C'<<endl;
				return 0;
			}
			next=c[ci];
			ci++;
			continue;
		}
	}

	return 0;
		
	return 0;
}

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

inline int read()
{
	int x=0, w=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*w;
}
int cnt;

int gcd(int a,int b);

//int a[250];
//map<char>f[250];
int f[250];

int main()
{
	int n,k,a;cin>>n>>k>>a;
	int ap=a;
	for(int i=2;i<=n;i++){
		int p=read();
		a=gcd(a,p);
		ap=max(ap,p);
	}
	if(k%a==0&&k<=ap){
			cout<<"POSSIBLE\n";
			return 0;
	}
	cout<<"IMPOSSIBLE\n";
	return 0;
}

int gcd(int a,int b)
{
	if(a%b==0)return b;
	return gcd(b,a%b);
}

Measured memory_bytes: 256