akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
ll a[5005],dp[5005][5005],dppos[5005];
int sub[5005];
vector<int>edge[5005];
ll t[2][5005];
void dfs(int v,int u){
	sub[v] = 1;
	rep(i,edge[v].size()){
		int to = edge[v][i];
		if(to == u) continue;
		dfs(to,v);
	}
	int cur = 0, nxt = 1;
	//dp[][]
	rep(i,2)rep(j,5005) t[i][j] = 1e18;
	t[0][0] = 0;
	rep(i,edge[v].size()){
		int to = edge[v][i];
		if(to == u) continue;
		rep(i,sub[v]+sub[to]) t[nxt][i] = 1e18;
		rep(i,sub[v]){
			if(t[cur][i] > 5e17) continue;
			repn(j,sub[to]){
				//cut
				if(dp[to][j] < 0){
					t[nxt][i+j] = min(t[nxt][i+j], t[cur][i]);
				}
				//cut2
				if(dppos[to] <= n){
					t[nxt][i+dppos[to]] = min(t[nxt][i+dppos[to]], t[cur][i]);
				}
				//connect
				t[nxt][i+j-1] = min(t[nxt][i+j-1], dp[to][j]+t[cur][i]);
			}
		}
		sub[v] += sub[to];
		swap(cur,nxt);
	}
	rep(i,sub[v]) dp[v][i+1] = t[cur][i]+a[v];
	if(a[v] > 0){
		dppos[v] = 1;
		//dppos[]
		rep(i,edge[v].size()){
			int to = edge[v][i];
			if(to == u) continue;
			ll add = INF;
			{
				repn(j,sub[to]){
					//cut
					if(dp[to][j] < 0){
						add = min(add,1LL*j);
					}
					//cut2
					if(dppos[to] <= n){
						add = min(add,dppos[to]);
					}
					//connect
					if(dppos[to] <= n){
						add = min(add,dppos[to]-1);
					}
				}
			}
			dppos[v] += add;
		}
	}
}
int main(){
	scanf("%d",&n);
	repn(i,n) scanf("%lld",&a[i]);
	rep(i,n-1){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		edge[b].pb(a);
	}
	rep(i,5005)rep(j,5005){
		dp[i][j] = 1e18;
		dppos[i] = 1e18;
	}
	dfs(1,-1);
	ll ans = dppos[1];
	for(int j=0;j<5005;j++){
		if(dp[1][j] < 0){
			ans = min(ans,1LL*j);
			break;
		}
	}
	cout << --ans << '\n';
}


Measured memory_bytes: 196992
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_B() {}
#else

#endif

int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, K; cin >> N >> K;

    int M = 0x01 << N;

    int x = 1;
    REP(i, N) {
        x = min(x * 2, x + K);
    }

    int ans = x;
    cout << ans << endl;

    return 0;
}

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

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

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  string S;
  cin >> S;

  bool ok = true;
  for (int i=1; i<int(S.size()); i++) {
    if (S[i-1] == S[i]) {
      ok = false;
      break;
    }
  }

  cout << (ok ? "Good" : "Bad") << endl;

  return 0;
}


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

using namespace std;

int main(){

    unsigned int i, counter = 0;
    string serching_word, word_in_sentence;

    cin >> serching_word;

    while(1){

        cin >> word_in_sentence;

        if (word_in_sentence == "END_OF_TEXT") break;

        for( i = 0; i < word_in_sentence.length(); i++){
            if( 'A' <= word_in_sentence[i] && word_in_sentence[i] <= 'Z' ){
                word_in_sentence[i] = word_in_sentence[i] + 32;
            }
        }

        if( word_in_sentence == serching_word ){
            counter++;
        }

    }

    cout << counter << endl;

    return 0;

}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    i64 h, w, n;
    std::cin >> h >> w >> n;
    std::vector<std::pair<i64, i64>> v;
    for (int i = 0; i < n; i++) {
        int x, y;
        std::cin >> x >> y;
        v.emplace_back(x, y);
    }

    std::sort(v.begin(), v.end());
    std::vector<i64> ret(10);
    int p[5][5];
    auto check = [&](i64 x, i64 y) {
        if (x <= 0 || x > h || y <= 0 || y > w) return -1;
        auto it = std::lower_bound(v.begin(), v.end(), std::make_pair(x, y));
        return it != v.end() && it->first == x && it->second == y ? 1 : 0;
    };

    for (const auto &e : v) {
        for (int i = -2; i <= 2; i++) for (int j = -2; j <= 2; j++) {
            p[i + 2][j + 2] = check(e.first + i, e.second + j);
        }
        for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) {
            int cnt = 0;
            for (int r = 0; r < 3; r++) for (int c = 0; c < 3; c++) {
                if (p[i + r][j + c] < 0) goto next;
                cnt += p[i + r][j + c];
            }
            ret[cnt]++;
next:;
        }
    }

    i64 sum = 0;
    for (int i = 1; i < 10; i++) {
        ret[i] /= i;
        sum += ret[i];
    }

    ret[0] = (w - 2) * (h - 2) - sum;

    for (auto e : ret) std::cout << e << std::endl;

    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int c = 0;
	int sol = 0;
	for (int i = 1; i <= n; i += 2)
	{
		for (int j = 1; j <= i; j += 2)
		{
			if (i%j == 0)
			{
				c++;
			}
		}
		if (c == 8)
			sol++;
		else
			c = c-c;
	}
	cout << sol;
}

Measured memory_bytes: 256
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=set()
c=[[0,0,0] for _ in range(3)]
for i in range(n):
    b.add(int(input()))
for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            c[i][j]=1
for i in range(3):
    if sum(c[i])==3:
        print("Yes")
        exit()
    elif c[0][i]+c[1][i]+c[2][i]==3:
        print("Yes")
        exit()

if c[0][0]+c[1][1]+c[2][2]==3:
    print("Yes")
elif c[0][2]+c[1][1]+c[2][0]==3:
    print("Yes")
else:
    print("No")

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


sum_a = [0]
for i in range(n):
    sum_a.append(sum_a[i] + a[i])

sum_b = [0]
for i in range(m):
    sum_b.append(sum_b[i] + b[i])


a_i = 0
b_i = 0
for i in range(n+1):
    if sum_a[i] > k:
        break
    else:
        a_i = i

for i in range(m+1):
    if sum_a[a_i] + sum_b[i] > k:
        break
    else:
        b_i = i


ans = a_i + b_i
for i in range(a_i, -1, -1):
    for j in range(b_i, m+1):
        if sum_a[i] + sum_b[j] > k:
            b_i = j - 1
            break
        else:
            ans = max(ans, i+j)

print(ans)


Measured memory_bytes: 47416
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cstring>
#include <set>
#include <map>
using namespace std;
#define ld long double
#define F first
#define S second
#define ll long long
#define int ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define p 1000000007
#define p1 998244353
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL)
const int N=1e2+10;
const int inf=1e15+10;
int arr[N];
int dp[100005];
int mn=-1;
int n,k;
bool f=0;
/*void rec(int i=0,int sum=0,int v=-1,int c=0)
{
    if(i==n)
    {
        if(k-sum<mn&&v==-1&&sum>0&&c%2==1)
        {
            f=1;
            cout<<i<<" "<<sum<<" "<<v<<" "<<c<<endl;
        }
        return ;
    }
    if(sum+arr[i]<=k)
    rec(i,sum+arr[i],v^arr[i],c+1);
    rec(i+1,sum,v,c);
}*/
bool WL(int pos)
{

    if(dp[pos]!=-1) return dp[pos];
   
    for(int i=0;i<n;i++)
        if(pos-arr[i]>=0&&!WL(pos-arr[i])) return dp[pos]=true;
    return dp[pos]=false;
}
int32_t main()
{
    memset(dp,-1,sizeof(dp));
    
    cin>>n>>k;
    
    for(int i=0;i<n;i++)
        cin>>arr[i];
    for(int i=0;i<n;i++)
        dp[arr[i]] =true;
    dp[0]=0;
    mn=*min_element(arr, arr+n);
    
    f=WL(k);
    
    if(f) cout<<"First";
    else cout<<"Second";
    
}


Measured memory_bytes: 4096
import java.util.*;
public class Main {
    private static int N;
    private static int M;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        M = sc.nextInt();
        int X = sc.nextInt();
        int[] C = new int[N];
        int[][] A = new int[N][M];
        for(int i=0;i<N;i++){
            C[i] = sc.nextInt();
            for(int j=0;j<M;j++){
                A[i][j] = sc.nextInt();
            }
        }
        int minP = Integer.MAX_VALUE;
        for(int key=0;key<Math.pow(2, N);key++){
            int price = decodePrice(key, C);
            if(decodeAndIsOverX(key, A, X)){
                minP = Math.min(minP, price);
            }
        }
        if(minP == Integer.MAX_VALUE){
            minP = -1;
        }
        System.out.println(minP);
    }
    private static int decodePrice(int key, int[] C){
        int res=0;
        for(int i=0;i<N;i++){
            if(((key >> i) & 0x01) == 1){
                res += C[i];
            }
        }
        return res;
    }

    private static boolean decodeAndIsOverX(int key, int[][] A, int X){
        int[] sumA = new int[M];
        for(int i=0;i<N;i++){
            if(((key >> i) & 0x01) == 1) {
                for (int j = 0; j < M; j++) {
                    sumA[j] += A[i][j];
                }
            }
        }
        for(int i=0;i<M;i++){
            if(sumA[i] < X){
                return false;
            }
        }
        return true;
    }
    private static void showArr(int[] a){
        for(int p:a){
            System.out.print(p);
        }
        System.out.println();
    }

}


Measured memory_bytes: 37168
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N;
  cin >> N;
  vector<ll> X(N), Y(N), H(N);
  REP(i, 0, N) cin >> X[i] >> Y[i] >> H[i];

  REP(y, 0, 101) REP(x, 0, 101) {
    vector<ll> s;
    REP(i, 0, N) if (H[i] > 0) {
      ll h = H[i] + abs(X[i] - x) + abs(Y[i] - y);
      s.push_back(h);
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    if (s.size() == 1) {
      ll h = s[0];
      bool ok = true;
      REP(i, 0, N) {
        ll t = max(h - abs(X[i] - x) - abs(Y[i] - y), 0LL);
        ok = ok && H[i] == t;
      }
      if (ok) {
        cout << x << " " << y << " " << h << endl;
        exit(0);
      }
    }
  }
  assert(false);
}

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

int main() {
  int N, K; cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  sort(H.begin(), H.end(), greater<int>());

  if (K >= N) {
    cout << 0 << endl; 
    return 0;
  }

  long long cnt = 0;
  for (int i = K; i < N; i++) cnt += H.at(i);
  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int min=1000, max=0;
    int N, buf;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> buf;
        if(buf < min)min=buf;
        if(buf > max)max=buf;
    }
    cout << max- min << endl;
}


Measured memory_bytes: 384
// https://atcoder.jp/contests/abc171/tasks/abc171_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q;
    cin >> N;
    int sum = 0;
    unordered_map<int, int> mp;
    REP(i, N) {
        int t;
        cin >> t;
        mp[t]++;
        sum += t;
    }
    cin >> Q;
    vector<int> ans;
    while (Q--) {
        int B, C;
        cin >> B >> C;
        int cnt = mp[B];
        sum += C * cnt - B * cnt;
        mp.erase(B);
        mp[C] = mp[C] + cnt;
        ans.emplace_back(sum);
    }
    for (auto &x : ans) {
        cout << x << "\n";
    }

    return 0;
}


Measured memory_bytes: 7584
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 100015
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int par[SIZE]; //親
int rnk[SIZE]; //木の深さ
 
//初期化(n要素0オリジン)
void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i;
		rnk[i] = 0;
	}
}
 
//xの根を求める
int find(int x){
	if(par[x] == x){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}
 
//x,yの属する集合を併合
void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y)return;
 
	if(rnk[x] < rnk[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rnk[x] == rnk[y])rnk[x]++;
	}
}

int n,m;
 
int main(){
  cin >> n >> m;
  init(n);
  rep(i,0,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--;y--;
    unite(x,y);
  }
  set<int> s;
  rep(i,0,n){
    s.insert(find(i));
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 5760
using System;
using System.Collections.Generic;
using System.Linq;

class PrimeNumber 
{
    static void Main()
    {
        var cp = new bool[1000000];
        cp[2] = true;
        var count = 1;

        var odds = Enumerable.Range( 0, 500000 )
            .Select( n => n * 2 + 1 );
        var pre =
            from n in odds.Skip( 1 )
            let cmp = !cp[n]
                ? odds.Skip( 1 )
                    .Select( m => n * m )
                    .TakeWhile( nm => nm < 1000000 )
                    .Select( nm => cp[nm] = true )
                    .ToArray()
                : Enumerable.Empty<bool>()
                    .ToArray()
            let acc = count += !cp[n] ? 1 : 0
            select Enumerable.Repeat( acc, 2 );
        var primeCount = new[] { 0, 0, 1 }
            .Concat( pre.SelectMany( _ => _ ) )
            .ToArray();
        var q = Enumerable.Repeat( 0, 30 )
            .Select( _ => Console.ReadLine() )
            .TakeWhile( _ => !string.IsNullOrEmpty( _ ) )
            .Select( _ => primeCount[int.Parse( _ )] + "\n" );
        Console.Write( new string( q.SelectMany( _ => _ ).ToArray() ) );
    }
}

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

int main(){
    int n;
    cin >> n;
    vector<ll> x(n);
    vector<ll> l(n);
    rep(i,n) cin >> x[i] >> l[i];
    vector<P> temp(n);
    rep(i,n) {
        temp[i].first = x[i] + l[i];
        temp[i].second = x[i] - l[i];
    }
    sort(all(temp));
    ll sum = -1001001001;
    int ans = 0;
    rep(i,n) {
        if(sum<=temp[i].second){
            ++ans;
            sum = temp[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

string ans(ll n) {
	if (n == 0) {
		return "";
	}
	n--;
	return ans(n / 26) + string(1, 'a' + n % 26);
}

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	cout << ans(n) << endl;
	return 0;
}


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

#define INF ((1<<31)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){
    bool flag=true;
    ll ans=1,sum=0;
    
    ll n,p;
    cin >>n>>p;
    ll div=p;

    if(n == 1){
        std::cout << p << '\n';
        return 0;
    }

    for (int i = 2; i <= (int)sqrt(p); i++)
    {
        ll count=0;

        while (div % i==0)
        {
            div /= i;
            count++;
            
            if(count >= n){
                ans *= i;
                count = 0;
            }
        }
        if(div <= 1)break;
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

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

	for(int i=0;i<=100;++i){
		if(A*i%B == C){
			std::cout<<"YES";
			return 0;
		}	
	}
	std::cout<<"NO";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()

void solve(ll n, ll m){
    set<ll> used_len;
    // set<pair<ll, ll>> p;
    ll e = n;
    REP(i, m){
        while(1){
            const ll l = e - (1 + i);
            assert(1 + i < e);
            assert(l >= 1 && n > l);
            if(!used_len.count(l) && !used_len.count(n - l) &&
               l * 2 != n){
                cout << 1 + i << ' ' << e << endl;
                used_len.insert(l);
                used_len.insert(n - l);
                e--;
                // assert(p.count(make_pair(1 + i, e)) == 0);
                // p.emplace(1 + i, e);
                break;
            }else{
                e--;
            }
        }
    }
}

int main(){
    ll n, m;
    cin >> n >> m;
    solve(n, m);

    // for(ll n2 = 100000; n2 >= 3; --n2){
    //     cerr << n2 << endl;
    //     solve(n2, (n2 - 1) / 2);
    // }

    return 0;
}


Measured memory_bytes: 11860
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	double L; cin >> L;
	printf("%.10f\n", L / 3 * L / 3 * L / 3);
	return 0;
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; i++) {
        cin >> p[i];
    }
    sort(p, p + N);
    int sum = 0;
    for (int i = 0; i < K; i++) {
        sum += p[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3564
use std::io::Read;

mod enumeration {
    #[derive(Clone, Debug)]
    pub struct Enumeration {
        fact: Vec<u64>,
        finv: Vec<u64>,
        modulo: u64,
    }

    impl Enumeration {
        pub fn new(n: usize, modulo: u64) -> Enumeration {
            let mut fact: Vec<u64> = vec![1; n];
            let mut inv: Vec<u64> = vec![1; n];
            let mut finv: Vec<u64> = vec![1; n];
            for i in 2..n {
                fact[i] = fact[i - 1] * (i as u64) % modulo;
                inv[i] = modulo - (modulo / (i as u64)) * inv[(modulo as usize % i)] % modulo;
                finv[i] = inv[i] * finv[i - 1] % modulo;
            }
            Enumeration {
                fact: fact,
                finv: finv,
                modulo: modulo,
            }
        }

        pub fn nck(&self, n: usize, k: usize) -> u64 {
            if n < k {
                return 0;
            }
            self.fact[n] * self.finv[n - k] % self.modulo * self.finv[k] % self.modulo
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let h: usize = itr.next().unwrap().parse().unwrap();
    let w: usize = itr.next().unwrap().parse().unwrap();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();

    const MOD: u64 = 1_000_000_007;
    let comb = enumeration::Enumeration::new(200010, MOD);

    let mut ans: u64 = 0;
    for i in b..w {
        ans = (ans + comb.nck(h - 1 - a + i, i) * comb.nck(a - 1 + w - 1 - i, a - 1) % MOD) % MOD
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;
int main(){
	scanf("%d",&n);
	if(n%2==0)puts("0.5000000000");
	else printf("%.7lf\n",1.0*(n+1)/2.0/n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long check(int j,int k){
  long long m=50;
  if(j<0&&k>0)
     m=k-j+min(k,-j);
  else{
    if(j>=0)
      m=k;
    else 
      m=-j;
  }
  return m;
}

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i=0;i<n;i++)
    cin >> p[i];
  long long ans=300000000;
  for(int i=0;i<n-k+1;i++){
    ans=min(ans,check(p[i],p[i+k-1]));
   // cout << check(p[i],p[i+k-1]) << endl;
  }
  cout << ans << endl;
}
  

Measured memory_bytes: 640
def examA():
    K = I()
    A, B = LI()
    for i in range(A,B+1):
        if i%K==0:
            print("OK")
            return
    print("NG")
    return

def examB():
    ans = 0
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examA()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 76556
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    M,K=MI()
    N=pow(2,M)
    if K>=N:
        print(-1)
        exit()
    elif M==1 and K==0:
        print(0,0,1,1)
    else:
        ans=[]
        temp=0
        for i in range(N):
            if i!=K:
                ans.append(i)
                temp=temp^i
        ans.append(K)
        for i in range(N-1,-1,-1):
            if i!=K:
                ans.append(i)
        ans.append(K)
        if temp!=K:
            print(-1)
        else:
            print(' '.join(map(str, ans)))        

                

main()


Measured memory_bytes: 101668
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  REP(i, N) cin >> a[i];
  vector<int> dp(K + 1, false);

  // dp[i]: のこりの石がiこのとき先手が勝てるか
  FOR(i, 0, K + 1) {
    if(!dp[i]) {
      REP(j, N) {
        if(i + a[j] > K) { continue; }
        dp[i + a[j]] = true;
      }
    }
  }
  if(dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

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

    ll d = c-a-b;

    ll dd = pow(d,2);// powを使うとWA(?)

    if( c-a-b > 0 && 4*a*b < d*d ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mx=1e10;
ll n,hh,a[200010],v[200010],pr[200010],now,ans,fr[200010][2];
map<ll,ll>mp,b;
void ycl(){
	ll i,j;
	for(i=2;i<=hh;i++)if(!v[i]){
		pr[++pr[0]]=i;
		for(j=i;j<=hh;j+=i)v[j]=1;
	}
}
int main(){
	ll i,j,x,y,sz;
	scanf("%lld",&n);
	hh=2200;
	ycl();
	for(i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		x=y=1;
		for(j=1;j<=pr[0];j++)if(a[i]%pr[j]==0){
			sz=0;
			while(a[i]%pr[j]==0)a[i]/=pr[j],sz++;
			sz%=3;
			if(!sz)continue;
			if(sz==1)x*=pr[j],y*=pr[j]*pr[j];
			 else x*=pr[j]*pr[j],y*=pr[j];
		}
		if(a[i]>1){
			now=sqrt(a[i]);
			if(now*now==a[i])x*=now*now,y*=now;
			 else x*=a[i],y*=a[i]*a[i];
		}
		fr[i][0]=x;fr[i][1]=y;
		b[x]++;
	}
	for(i=1;i<=n;i++){
		if(mp[fr[i][0]]||mp[fr[i][1]])continue;
		mp[fr[i][0]]=mp[fr[i][1]]=1;
		if(fr[i][0]==1){
			ans++;
		}
		 else ans+=max(b[fr[i][0]],b[fr[i][1]]);
	}
	printf("%lld",ans);
	return 0;
}
/*
大于1e5没有意义 
'1 1'型
‘1’型
‘2’型
‘1’型和‘2’型能配对
‘1 1’不能配对 
*/

Measured memory_bytes: 31744
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main(void){
    int N;
    cin >> N;
    if(N % 2 == 0){
        cout << ((N-2)*N)/2 << endl;
    }else{
        cout << pow(N/2, 2) * 2 << endl;
    }
    for(int cnt = 1; cnt < N; ++cnt){
       for(int column = cnt + 1; column <= N; ++column){
           if(N % 2 == 0){
               if(N + 1 - cnt != column){
                   cout << cnt << " " << column << endl;
               }
           }else{
               if(N - cnt != column){
                   cout << cnt << " " << column << endl;
               }
           }
       }
    }

    return 0;
}


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

string fixString( int a )
{
    string zero = "";
    for( int i = 0; i < a; i++ )
        zero += "0";
    return zero;
}

int main()
{
    int n;

    while( cin >> n )
    {
        if( !n )
            break;

        string s[n], res[n];

        //入力+一番右のドットをプラスに変換処理+文字列で一番長いものを保存
        int max = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> s[i];
            res[i] = s[i];

            for( int j = s[i].size() - 1; j >= 0; j-- )
                if( s[i][j] == '.' )
                {
                    s[i][j] = '+';
                    break;
                }
            if( s[i].size() > max )
                max = s[i].size();
        }

        //文字列をすべて同じ要素数に調整
        for( int i = 0; i < n; i++ )
            s[i] += fixString( max - s[i].size() );

        //縦から見て+で囲まれる領域を'|'で置き換える
        for( int i = 0; i < max; i++ )
        {
            int j = 0;
            while( j < n )
            {
                if( s[j][i] == '+' && j != n - 1 )
                {
                    int k = j + 1;
                    while( k < n && s[k][i] == '.' )
                        k++;
                    if( k < n && s[k][i] == '+' )
                    {
                        int l = k - 1;
                        while( s[l][i] == '.' )
                        {
                            s[l][i] = '|';
                            l--;
                        }
                    }
                    j = k - 1;
                }
                j++;
            }
        }

        for( int i = 0; i < n; i++ )
        {
            for( int j = 0; j < res[i].size(); j++ )
            {
                if( s[i][j] != '.' )
                    res[i][j] = s[i][j];
                else
                    res[i][j] = ' ';
            }
            cout << res[i] << endl;
        }

    }

    return 0;
}


Measured memory_bytes: 5728
package main

import (
	"fmt"
)

func main() {
	var s int
	fmt.Scan(&s)

	if s == 4 || s == 2 || s == 1 {
		fmt.Println(4)
		return
	}

	M := 1000000
	a := make([]int, M)
	a[1] = s
	for i := 2; i < M; i++ {
		if a[i-1]%2 == 0 {
			a[i] = a[i-1] / 2
		} else {
			a[i] = 3*a[i-1] + 1
		}
		if a[i] == 4 {
			fmt.Println(i + 3)
			break
		}
	}
}


Measured memory_bytes: 2816
def abc099_c():
    ''' 解説PDF通り '''
    n = int(input())
    ans = n  # 初期値：ぜんぶ1円で引き出した最悪値

    # 6の乗数で支払う金額iを全探索
    for i in range(n+1):
        cc = 0
        t = i  # 6の乗数で支払う金額i
        while t > 0:
            cc += t % 6  # 最初に端数が入る、最後に6で割り切った倍数か乗数(なら1)が入る
            t //= 6
        t = n - i  # i以外を9の乗数で支払うとする
        while t > 0:
            cc += t % 9
            t //= 9
        ans = min(cc, ans)

    print(ans)

abc099_c()

Measured memory_bytes: 3064
N, K = map(int, input().split())
p = list(map(lambda x: (int(x) + 1)/2, input().split()))

asum = [p[0]]
for i in range(1, N, 1):
	asum.append(asum[i - 1] + p[i])

tsum = [asum[K - 1]]
for i in range(K, N, 1):
	tsum.append(asum[i] - asum[i - K])

print(max(tsum))

Measured memory_bytes: 23588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		String str =br.readLine();
		String[] stra = str.split(" ");
		
		int a = Integer.parseInt(stra[0]);
		int b = Integer.parseInt(stra[1]);
		int c = Integer.parseInt(stra[2]);
		int cnt = 0;
		for (int i = a ;i <= b ; i++){
			if(c%i == 0){
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 17092
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		ArrayList<int[]> arrayList = new ArrayList<int[]>();
		
		while (in.hasNextLine())
		{
			int lineNumber = in.nextInt();
			int[] array = new int[lineNumber];
			in.nextLine();
			
			int i = 0;
			
			while (i < lineNumber && in.hasNextInt())
			{
				array[i] = in.nextInt();
				i++;
			}
			
			arrayList.add(array);
			
			if (in.hasNextLine())
			{
				in.nextLine();
			}
		}
		
		int[] qArray = arrayList.get(1);
		int[] sArray = arrayList.get(0);
		int count = 0;
		
		for (int i = 0; i < qArray.length; i++)
		{
			int l = 0;
			int r = sArray.length - 1;
			while (l <= r)
			{
				int mid = (l + r) / 2;
				if (qArray[i] > sArray[mid]) {
					l = mid + 1;
				} else if (qArray[i] < sArray[mid]) {
					r = mid - 1;
				} else if (qArray[i] == sArray[mid]){
					count++;
					break;
				}
			}
		}
		
		System.out.println(count);
	}

}


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

using ll = long long;
const ll INF = (ll)1e17 + 1;

int main()
{
  ll N;
  std::cin >> N;

  std::vector<ll> va(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  ll ans = 0LL;
  for (ll i = 1; i < N-1; i++) {
    if (va[i-1] == va[i] && va[i] == va[i+1]) {
      va[i] = INF;
      ans++;
    }
  }

  for (ll i = 0; i < N-1; i++) {
    if (va[i] == va[i+1]) {
      ans++;
    }
  }

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


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

int main(){
  int a;
  scanf("%d",&a);
  int L=a/100;
  int R=a%100;
  if(1<=L&&L<=12){
    if(1<=R&&R<=12)printf("AMBIGUOUS\n");
    else printf("MMYY\n");
  }else{
    if(1<=R&&R<=12)printf("YYMM\n");
    else printf("NA\n");
  }
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main() {
  string status = "APPROVED";
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] % 2 == 0 && !(a[i] % 3 == 0 || a[i] % 5 == 0)) {status = "DENIED";
    break;}
  }
  cout << status << '\n';
}

Measured memory_bytes: 256
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
$N=trim(fgets(STDIN));
for($i=0;$i<$N;$i++) {
  list($T[],$X[],$Y[]) = explode(" ",trim(fgets(STDIN)));
}
for($i=0;$i<$N;$i++) {
  if ($T[$i]<$X[$i] || $T[$i]<$Y[$i]) {
    printf("No\n");
    exit;
  }
  if ($T[$i]<$X[$i]+$Y[$i]) {
    printf("No\n");
    exit;
  }
  if ($T[$i]%2!=($X[$i]+$Y[$i])%2) {
    printf("No\n");
    exit;
  }
}
printf("Yes\n");


Measured memory_bytes: 56692
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,k;
  cin>>n>>k;
  vecint h(n);
  for(auto&& e:h)cin>>e;
  constexpr int INF = 1000000000;
  vecint dp(n, INF);
  dp[0] = 0;
  for(auto&& i:irange(1,n)) {
    for(auto&& j:irange(1,k+1)) {
      if (i >= j) {
        dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
      }
    }
  }
  cout<<dp.back()<<endl;
  return 0;
}


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#include <sstream>
#include <complex>
#define BIT(nr) (1ULL << (nr))
#define int long long
#define ll long long
#define double complex<long double>
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	
#define LL_HALFMAX 9223372036854775807 / 2	
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }

using namespace std;

void solve(int n, int x){
	int ans = 0;
	REPS(i, n) REP(j, i+1, n+1) REP(k, j+1, n + 1) {
		if (i + j + k == x) {
			ans++;
		}
	}
	cout << ans << "\n";
}

signed main() {
	for (;;) {
		int n, x;
		cin >> n >> x;
		if (n == 0 && x == 0) {
			break;
		}
		solve(n, x);
	}
}


Measured memory_bytes: 3044
integer N
integer(16),allocatable,dimension(:)::A
integer(16) median,ans
read*,N
allocate(A(N))
read*,A
do i=1,N
  A(I)=A(I)-i
end do
call heapsort(N,A)
if(mod(N,2)==1)then
  median=A(N/2+1)
else
  median=(A(N/2)+A(N/2+1))/2
endif
ans=0
do i=1,N
  ans=ans+abs(median-A(i))
end do
print"(I0)",ans
contains
subroutine heapsort(n,array)
  implicit none
!ここの入力は状況に応じて変更すること
  integer,intent(in) :: n
  integer(16),intent(inout) :: array(1:n)
  integer::i,k,j,l
  integer(16):: t

  l=n/2+1
  k=n
  do while(k /= 1)
     if(l > 1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k == 1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j<=k)
        if(j < k)then
           if(array(j) < array(j+1))j=j+1
        endif
        if (t < array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo
  return
end subroutine heapsort
end

Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5;
#define mst(a) memset(a,0,sizeof a)
int main(){
	ll n;
	while(cin>>n){
	ll a,b;
	a=n/500*1000;
	ll tmp=n-n/500*500;
	b=tmp/5*5;
	cout<<a+b<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int A, B;
string s;
int main(){
  cin >> A >> B;
  cin >> s;
  bool flag =true;
  for( int i=0; i<A+B; i++){
    if (i== A){
      if (s[i] != '-') flag = false;
    }
    else {
      flag = false;
      for(int j=0; j<=9; j++){
        if ( s[i] - '0' == j) flag =true;
        if (flag) break;
      }
    }
    if (!flag) break;
  }
  if (flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

# A_sort = A
A_str = map(str, A)
print(" ".join(A_str))

for i in range(1, N, 1):
    # for j in range(i):
    #     if A[i] < A_sort[j]:
    #         A_sort[j+1] = 1
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j = j - 1
    A[j+1] = v

    A_str = map(str, A)
    print(" ".join(A_str))



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

const int INF = 1001001001;

int main(void){
  int n, i;
  cin >> n >> i;
  cout << n-i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{

	std::ios::sync_with_stdio(false);
	int t = 1;
	// cin>>t;
	while (t--) {
		int n, k;
		cin >> n >> k;
		vector<int> arr(n);
		for (int i = 0; i < n; i++) {
			cin >> arr[i];
		}
		sort(arr.begin(), arr.end());
		ll ans = 0;
		for (int i = 0; i < k; i++) {
			ans += arr[i];
		}
		cout << ans;
	}

	return 0;
}

Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<bool> vb;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	int N; cin >> N;
	int Lo = 101, Hi = -101;
	vi A(N); FOR(i, 0, N) {
		cin >> A[i];
		Lo = min(Lo, A[i]);
		Hi = max(Hi, A[i]);
	}
	
	ll ans = INF;
	for (int n = Lo; n <= Hi; n++) {
		ll cost = 0;
		FOR(i, 0, N) {
			cost += (A[i] - n)*(A[i] - n);
		}
		ans = min(ans, cost);
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
while True:
    n = input()
    if n==0:
        break
    k = map(int, raw_input().split())
    s = raw_input()
    print "".join(station[(station.find(s[i])-k[i%n]+52)%52] for i in xrange(len(s)))

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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const int INF = 1'000'000'000;
using State = pair<int, int>;

int H, W;
int Ch, Cw;
int Dh, Dw;
vector<string> S;

bool valid(int h, int w){
    if(h < 0 || w < 0 || h >= H || w >= W || S[h][w] == '#') return false;
    return true;
}

int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    
    cin >> H >> W;

    cin >> Ch >> Cw;
    Ch--; Cw--;
    
    cin >> Dh >> Dw;
    Dh--; Dw--;
    
    REP(h, 0, H){
        string line;
        cin >> line;
        S.push_back(line);
    }

    deque<State> q;
    int dist[H][W];
    REP(i, 0, H)REP(j, 0, W) dist[i][j] = INF;
    dist[Ch][Cw] = 0;
    q.emplace_front(Ch, Cw);
    State moves[] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
    while(! q.empty())
    {
        State cur = q.front(); q.pop_front();
        if(cur.first == Dh && cur.second == Dw) break;
        for(const auto& move : moves){
            int newH = cur.first + move.first;
            int newW = cur.second + move.second;
            if(!valid(newH, newW)) continue;
            if(dist[cur.first][cur.second] < dist[newH][newW]){
                q.emplace_front(newH, newW);
                dist[newH][newW] = dist[cur.first][cur.second];
            }
        }
        for(int h = -2; h <= 2; h++)
        for(int w = -2; w <= 2; w++){
            int newH = cur.first + h;
            int newW = cur.second + w;
            if(!valid(newH, newW)) continue;
            if(dist[cur.first][cur.second] + 1 < dist[newH][newW]){
                q.emplace_back(newH, newW);
                dist[newH][newW] = dist[cur.first][cur.second] + 1;
            }
        }
    }

    int ans = -1;
    if(dist[Dh][Dw] != INF) ans = dist[Dh][Dw];
    cout << ans << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s;
	cin >>n >>s >>q;
	
	vector<Bitree> dt(26, Bitree(500100));
	rep(i, n){
		int zs = s[i] - 'a';
		dt[zs].add(i, 1);
	}
	
	rep(gq, q){
		int x; cin>>x;
		if(x==1){
			int y; char z;
			cin >>y >>z;
			y--;
			if(s[y]==z) continue;
			dt[s[y]-'a'].add(y, -1);
			dt[z-'a'].add(y, 1);
			s[y] = z;
		}else{
			int l, r;  ll ans = 0;
			cin >>l >>r;
			l--; r--;
			rep(j, 26) if(dt[j].sum(l, r) > 0) ans++;
			cout << ans <<"\n";
		}
		
	}
	return 0;
}


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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll MODNUM=1000000007;
    ll N, ans;
    scanf("%lld", &N);
    ll A;
    vector<ll> OneC(60),ZeroC(60);
    REP(int,i,0,60){
        OneC.at(i) = 0;
        ZeroC.at(i) = 0;
    }
    REP(int,i,0,N){
        scanf("%lld", &A);
        REP(int,j,0,60){
            if ( A % 2 ) OneC.at(j)++;
            else ZeroC.at(j)++;
            A /= 2;
        }
    }
    ans = 0;
    REP(int,j,0,60){
        ll BitN = ( OneC.at(j) % MODNUM ) * ( ZeroC.at(j) % MODNUM ) % MODNUM;
        ans += ((ll)pow(2,j) % MODNUM) * BitN;
        ans = ans % MODNUM;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256