akhauriyash/Code-Regression huggingface dataset:
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
 
//const long long INF = 1LL << 55;
 
#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
 
#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define MAX_N 300030

int n,m,q;
int grid[600][600];
int grid_cumrative[600][600];
void precalc(){
   for(int i = 1;i < 550;i++){
      for(int j = 1;j < 550;j++){
         grid_cumrative[i][j]
            = grid_cumrative[i][j-1] + grid_cumrative[i-1][j] - grid_cumrative[i-1][j-1] + grid[i-1][j-1];
      }
   }
   // rep(i,10){
      // rep(j,10)cout << grid[i][j] << " ";
      // cout << endl;
   // }
}
void query(int p,int q){
   int ans = 0;
   ans += grid_cumrative[q+1][q+1];
   ans -= (grid_cumrative[p][q+1] + grid_cumrative[q+1][p]);
   ans += grid_cumrative[p][p];
   cout << ans << endl;
}
int main(void){
   ioboost;
   cin >> n >> m >> q;
   rep(i,m){
      int l,r;cin >> l >> r;
      grid[--l][--r]++;
   }
   precalc();
   rep(i,q){
      int p,q;cin >> p >> q;
      query(--p,--q);
   }
}

Measured memory_bytes: 3456
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int N = 50 + 5;

priority_queue<int, vector<int>, greater<> > pri;

int main() {
    int n, ans = 1;
    cin >> n;
    int t;
    cin >> t;
    pri.push(t);
    for (int i = 1; i < n; i++) {
        cin >> t;
        if (pri.top() >= t)
            ans++;
        pri.push(t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sat = 0
beforeA = -1
for i in A:
    sat += B[i - 1]
    if i == beforeA+1:
        sat += C[beforeA - 1]
    beforeA = i

print(sat)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<sstream>
#define fo(i,w,n) for(i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define ct continue
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int main(){
	int a,b,c;
	cin>>a;
	if(a==1)cout<<"Hello World"<<endl;
	else{
		cin>>b>>c;
		cout<<b+c<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left
A,B,Q=map(int,input().split())
s=[int(input()) for _ in range(A)]
t=[int(input()) for _ in range(B)]
x=[int(input()) for _ in range(Q)]
for i in x:
    si = bisect_left(s,i)
    ti = bisect_left(t,i)
    try:
        s1 = s[si-1]
    except:
        s1 = 10**11
    try:
        s0 = s[si]
    except:
        s0 = 10**11
    try:
        t1 = t[ti-1]
    except:
        t1 = 10**11
    try:
        t0 = t[ti]
    except:
        t0 = 10**11
    s0t0=abs(s0-i)+abs(t0-s0)
    s0t1=abs(s0-i)+abs(t1-s0)
    s1t0=abs(s1-i)+abs(t0-s1)
    s1t1=abs(s1-i)+abs(t1-s1)
    t0s0=abs(t0-i)+abs(t0-s0)
    t0s1=abs(t0-i)+abs(t0-s1)
    t1s0=abs(t1-i)+abs(t1-s0)
    t1s1=abs(t1-i)+abs(t1-s1)
    ans = min(s0t0,s0t1,s1t0,s1t1,t0s0,t0s1,t1s0,t1s1)
    print(ans)

Measured memory_bytes: 16168
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    while (1) {
        int n, t, l, b, st[105] = {};
        cin >> n >> t >> l >> b;
        if (n == 0 && l == 0 && b == 0 && t == 0) return 0;
        for (int i = 0; i < l; i++) {
            int lose;
            cin >> lose;
            st[lose] = 1;
        }
        for (int i = 0; i < b; i++) {
            int back;
            cin >> back;
            st[back] = -1;
        }
        
        // turn数, そのマスにいる確率, 休みがあるか
        double dp[105][105];
        for (int i = 0; i <= 102*102; i++) {
            dp[i/101][i%101] = 0.0;
        }
        dp[0][0] = 1.0;
        
        for (int i = 0; i < t; i++) {
            for (int j = 0; j < n; j++) {
                // サイコロの出目
                for (int v = 1; v <= 6; v++) {
                    int next = j + v;
                    if (next > n) next = n - (next - n);
                    
                    if (st[next] == 1) dp[i + 2][next] += dp[i][j] / 6.0;
                    else if (st[next] == -1) dp[i + 1][0] += dp[i][j] / 6.0;
                    else dp[i + 1][next] += dp[i][j] / 6.0;
                }
            }
            dp[i + 1][n] += dp[i][n];
            
            /*
            cout << "Turn " << i + 1 << endl;
            for (int j = 0; j <= n; j++) {
                cout << j << " " << setprecision(8) << dp[i + 1][j] << " " << dp[i + 2][j]<< endl;
            }
            cout << endl;*/
            
            /*
            for (int j = 1; j < n; j++) {
                dp[i + 1][j][0] += dp[i][j][1];
                dp[i + 1][j][1] = dp[i + 1][j][2];
                //cout <<setprecision(8) << dp[i + 1][j][0] << " ";
            }*/
            //cout << endl;
        }
        
        cout << fixed <<setprecision(10) << dp[t][n] << endl;
    }
}



Measured memory_bytes: 3196
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

vector<int> G[202020];
int A[202020];
vector<int> dp;
pii pre[202020];
int ans[202020];
void dfs(int v, int pv) {
    int k = lower_bound(all(dp),A[v]) - dp.begin();
    pre[v] = pii(k,dp[k]);
    dp[k] = A[v];
    int num = lower_bound(all(dp),MOD) - dp.begin();
    ans[v] = num-1;
    for (auto nv : G[v]) {
        if (nv==pv) continue;
        dfs(nv,v);
    }
    dp[pre[v].first] = pre[v].second;
}
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    dp.assign(N+3,MOD);
    dp[0] = 0;
    rep(i,N) cin >> A[i];
    rep(i,N-1) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }
    dfs(0,-1);
    rep(i,N) cout << ans[i] << ln;
}




Measured memory_bytes: 29508
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll m1, d1, m2, d2;
int main(){
    cin>>m1>>d1>>m2>>d2;

    if(m1<12){
        if(m1<m2 && d2==1) cout<<1<<endl;
        else cout<<0<<endl;
    }
    else{
        if(m2==1 && d2==1) cout<<1<<endl;
        else cout<<0<<endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

struct UnionFind {
    vector<int> data;
   
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
   
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
   
    int find(int k) {
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
   
    int size(int k) {
        return (-data[find(k)]);
    }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    rep(i,M) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        uf.unite(A, B);
    }
    int ans = 0;
    rep(i,N) {
        ans = max(ans, uf.size(i));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4048
import java.util.Scanner;
public class Main
{
	public static void main(String args[])
	{
		int a, b, c;
		Scanner input = new Scanner(System.in);
		a = input.nextInt();
		b = input.nextInt();
		c = input.nextInt();
		if(a < b && b < c){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");	
		}
	}
}

Measured memory_bytes: 26108
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 9084
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ans = 0;
    for (int x : a) {
        ans += 2 * min(x, k - x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   vector<int> a(n);
   int sm = 0;
   f(i,0,n){
      cin >> a[i];
      sm += a[i];
   }
   vector<int> fact;
   for(int i=1;i*i<=sm;i++){
      if(sm%i==0){
         fact.pb(i);
         if(sm/i != i) fact.pb(sm/i);
      }
   }
   sort(all(fact));
   int ans = 1;
   vector<int> temp;
   f(i,0,fact.size()){
      temp.clear();
      int c1=0,c2=0;
      f(j,0,n){
         temp.pb(a[j]%fact[i]);
         c1 += fact[i]-(a[j]%fact[i]);
      }
      sort(all(temp));
      f(j,0,n){
         c2 += temp[j];
         c1 -= fact[i]-temp[j];
         if(c1 == c2 and c1<=k) ans = max(ans,fact[i]);
      }
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100003;
ll i,n;
ll a[N],dp[N];
ll solve(ll i)
{
    if(dp[i] != -1) return dp[i];
    
    if(i == 1)
        return dp[i] = 0;
    
    ll res = solve(i - 1) + llabs(a[i] - a[i - 1]);
    if(i > 2)
        res = min(res,solve(i - 2) + llabs(a[i] - a[i - 2]));
    return dp[i] = res;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    memset(dp,-1,sizeof(dp));
    cin>>n;
    rep(i,1,n + 1) cin>>a[i];
    cout<<solve(n);
    return 0;
}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n;
vll a;
lli mem,x;

int main(){
  cin >> n;
  a = vll(n);
  for(lli i = 0;i < n;i++) cin >> a[i];
  sort(a.begin(),a.end());
  for(lli i = 0;i < n;i++){
    if(mem < min(a[n-1]-a[i],a[i])){
      x = a[i];
      mem = min(a[n-1]-a[i],a[i]);
    }
  }
  cout << a[n-1] << " " << x << endl;
  return 0;
}


Measured memory_bytes: 1024
x=int(input())
def money(x):
    if x==0:
        return 0
    cnt500=0
    cnt5=0

    while x>=500:
        x-=500
        cnt500+=1
    if x==0:
        return cnt500*1000
    
    while x>=5:
        x-=5
        cnt5+=1
    return cnt500*1000+cnt5*5
print(money(x))

Measured memory_bytes: 9132
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m,h,k,s[1000],a[100000],b[100000];
vector<P> edge;
int d[1001][1000];
int u[1000];

int main(){
	while(scanf("%d%d%d%d",&n,&m,&h,&k),n){
		for(int i=0;i<n;i++) scanf("%d",&s[i]);
		for(int i=0;i<m;i++) scanf("%d%d",&a[i],&b[i]);
		vector<P> ppp;
		edge=ppp;
		for(int i=0;i<m;i++) edge.push_back(P(b[i],a[i]));
		sort(edge.begin(),edge.end());
		for(int i=0;i<n;i++) d[0][i]=i;
		int cnt=0;
		for(int i=1;i<=h;i++){
			for(int j=0;j<n;j++) d[i][j]=d[i-1][j];
			while(cnt<m){
				P p=edge[cnt];
				if(p.first!=i) break;
				cnt++;
				swap(d[i][p.second-1],d[i][p.second]);
			}
		}
		int res=0;
		for(int i=0;i<n;i++) u[d[h][i]]=s[i];
		for(int i=0;i<k;i++) res+=u[i];
		int out=res;
		for(int i=0;i<m;i++){
			int x=d[b[i]][a[i]],y=d[b[i]][a[i]-1];
			if(x<k&&y>=k) out=min(out,res+u[y]-u[x]);
			if(x>=k&&y<k) out=min(out,res+u[x]-u[y]);
		}
		printf("%d\n",out);
	}
}

Measured memory_bytes: 6712
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio> 
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct note
{
	string s;
	int k,num;
}a[105];
bool cmp(note a,note b)
{
	if(a.s==b.s) return a.k>b.k;
	else return a.s<b.s;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i) 
	{
		cin>>a[i].s;
		cin>>a[i].k;
		a[i].num=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;++i) cout<<a[i].num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    string s;cin>>s;
    if(s[0]!=s[1] || s[1]!=s[2] || s[2]!=s[0]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n, d = map(int, readline().split())
ans = 0
for i in range(n):
    x, y = map(int, readline().split())
    if (x ** 2 + y ** 2) ** 0.5 <= d:
        ans += 1
print(ans)


Measured memory_bytes: 9668
from math import gcd

class segtree:
    def __init__(self,n,op,e):
        self.e=e
        self.op=op
        self.size=1<<(n-1).bit_length()
        self.SEG=[self.e]*(self.size*2)
    
    def update(self,i,x):
        i+=self.size
        self.SEG[i]=x
        
        while i>0:
            i>>=1
            self.SEG[i]=self.op(self.SEG[i*2],self.SEG[i*2+1])
    
    def get(self,i):
        return self.SEG[i+self.size]
    
    def query(self,l,r):
        l+=self.size
        r+=self.size
        
        lres,rres=self.e,self.e
        
        while l<r:
            if l&1:
                lres=self.op(lres,self.SEG[l])
                l+=1
            
            if r&1:
                r-=1
                rres=self.op(rres,self.SEG[r])
            
            l>>=1
            r>>=1
            
        res=self.op(lres,rres)
        return res
 

N=int(input())
seg=segtree(N,gcd,0)
A=list(map(int,input().split()))
for i in range(N):
    seg.update(i,A[i])
ans=1
for i in range(N):
    l,r=seg.query(0,i),seg.query(i+1,N)
    ans=max(ans,gcd(l,r))
print(ans)

Measured memory_bytes: 86464
#include<stdio.h>

int Adj[101];

int main()
{
  int i,j,n,u,k,c;

  scanf("%d",&n);

  for(i=1; i<=n; i++){
    c=0;
    scanf("%d%d",&u,&k);

    for(j=0; j<k; j++){
      scanf("%d",&Adj[j]);
    }

    for(j=1; j<=n; j++){
      if(j!=1)
	printf(" ");
      if(Adj[c] == j && c != k){
	printf("1");
	c++;
      }
      
      else
	printf("0");
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2112
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef long long ll;

int main() {
    ll A, B, C;
    scanf("%lld%lld%lld", &A, &B, &C);
    if(C <= A + B + 1) printf("%lld\n", B + C);
    else printf("%lld\n", B + (1 + A + B));
    return 0;
}


Measured memory_bytes: 256
b = []
n = int(input())
m = 0
for i in range(n):
  a = int(input())
  b.append(a)
  if m < a:
    m = a
    c = [i]
  elif m == a:
    c.append(i)

if len(c) != 1:
  for i in range(n):
    print(m)
else:
  del b[c[0]]
  for i in range(n):
    if i == c[0]:
      print(max(b))
    else:
      print(m)

Measured memory_bytes: 20376
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int mm=998244353;
ll c[510001];
ll t1,t2,n,m,a,b,ans;
int i,j,k;
ll pw(ll b,ll p){
	ll res=1;
	for (;p;p>>=1,b=b*b%mm)
	 if (p&1) res=res*b%mm;
	return res;
}
int main(){
	scanf("%lld%lld%lld%lld",&n,&a,&b,&m);
	for (c[0]=i=1;i<=n;i++) c[i]=c[i-1]*(ll)(n-i+1)%mm*pw(i,mm-2)%mm;
	for (i=ans=0;i<=n;i++){
		t1=(m-a*i);
		if (t1<0) continue;
		t2=t1/b;
		if (t1%b||t2>n) continue;
		ans=(ans+c[i]*c[t2]%mm)%mm;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2560
n = gets.to_i
weigh = gets.chomp.split.map(&:to_i)
hevy = 0
ligh = 0
weigh.length.times do
  if hevy <= ligh
    hevy += weigh.pop
  elsif hevy > ligh
    ligh += weigh.shift
  end
end
puts((hevy-ligh).abs)

Measured memory_bytes: 1788
#include<iostream>
#include<string>
using namespace std;
string s;
int k;
char a[110];
int main(){
	cin>>k>>s;
	if(s.size()<=k){
		cout<<s<<endl;return 0;
	}
	for(int i=0;i<s.size();i++)a[i]=s[i];
	for(int i=0; i<k; i++){
		cout<<a[i];
		if(i==k-1)cout<<"..."<<endl;
	}
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define     bolt     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     text     freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define     F        first
#define     S        second
#define     pb       push_back
#define     lb       lower_bound
#define     ub       upper_bound
#define     endl     "\n"
typedef long long ll;
typedef long double ld;
const ll mod = 1e9+7 ;
const ld pi=3.1415926535897932384626433;
const ll inf = 1e18;
ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}

int main ()
{
   bolt;
   ll a,b;
   cin>>a>>b;
   if (a<b)
   {
      for (ll i=0;i<b;i++)
      {
         cout<<a;
      }
   }
   else 
   {
      for (ll i=0;i<a;i++)
      {
         cout<<b;
      }
   }
   

}


Measured memory_bytes: 256
n, m = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(m)]

cont_1 = set()
cont_n = set()

for ab in AB:
  a, b = ab
  if 1 in ab:
    cont_1.add(a)
    cont_1.add(b)
  if n in ab:
    cont_n.add(a)
    cont_n.add(b)

if cont_1 & cont_n:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 58884
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  REP(i, N) cin >> h[i];
  sort(ALL(h));
  int ans = 1e9;
  for (int i = 0; i + K - 1 < N; ++i) {
    ans = min(ans, h[i + K - 1] - h[i]);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
//organize and stay in moment
//Abhinav - IIITA
#include<bits/stdc++.h>
using namespace std;
#define int long long
void merge(int arr[],int brr[], int l, int m, int r) 
{ 
  int i, j, k; 
  int n1 = m - l + 1; 
  int n2 = r - m; 
  int L[n1], R[n2]; 
  int l1[n1] ,r1[n2];
  for (i = 0; i < n1; i++) 
    {L[i] = arr[l + i];l1[i]=brr[l+i];} 
  for (j = 0; j < n2; j++) 
    {R[j] = arr[m + 1+ j];r1[j]=brr[m+1+j];} 
  i = 0;  
  j = 0; 
  k = l;  
  while (i < n1 && j < n2) 
  { 
    if (L[i] <= R[j]) 
    { 
      arr[k] = L[i];
      brr[k]=l1[i]; 
      i++; 
    } 
    else
    { 
      arr[k] = R[j];
      brr[k]=r1[j]; 
      j++; 
    } 
    k++; 
  } 
  while (i < n1) 
  { 
    arr[k] = L[i]; 
    brr[k]=l1[i];
    i++; 
    k++; 
  } 
  while (j < n2) 
  { 
    arr[k] = R[j];
    brr[k]=r1[j]; 
    j++; 
    k++; 
  } 
} 
void mergeSort(int arr[],int brr[], int l, int r) 
{ 
  if (l < r) 
  { 
    int m = l+(r-l)/2; 
    mergeSort(arr,brr, l, m); 
    mergeSort(arr,brr, m+1, r); 
    merge(arr,brr, l, m, r); 
  } 
}
int32_t main(){
	int n,d,a;
	cin>>n>>d>>a;
	int ar[n],br[n],cm[n+1];
	for(int i=0;i<=n;++i)
		cm[i]=0;
	for(int i=0;i<n;++i)
		cin>>ar[i]>>br[i];
	mergeSort(ar,br,0,n-1);
	//for(int i=0;i<n;++i)
	//cout<<ar[i]<<" "<<br[i]<<endl;
	int ans=0;
	for(int i=0,j=0;i<n;++i){
		while(j<n && ar[j]<=ar[i]+2*d)
			j++;
		j--;
		int bomb=max((int)0,(br[i]-cm[i]*a+a-1)/a);
		//cout<<bomb<<endl;
		ans+=bomb;
		cm[i]+=bomb;
		cm[j+1]-=bomb;
		cm[i+1]+=cm[i];
	}
	cout<<ans;
	return 0;
}


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

int main(){
  char a,b,c;
  cin >> a >> b >> c;
  vector<char> vec(3);
  vec = {a , b , c};
  int count = 0, ans = 0;
  
  for (int i; i < 3; i++){
    if (vec.at(i) == 'R'){
      count++;
    }
    else{
      if(count > ans){
        ans = count;
        count = 0;
      }
      else{
        count = 0;
      }
    }
  }
  if(count > ans){
        ans = count;
        count = 0;
      }
      else{
        count = 0;
      }
  cout << ans << endl;
}

Measured memory_bytes: 3644
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

check :: [Int] -> [Int] -> [Int]
check [] as = as
check (s : ss) as = check ss as'
  where
    as'
      | s `elem` as = as
      | otherwise = s : as

main = do
  n <- getInt
  as <- getIntList
  let as' = map (\x -> x `div` 400) as
  let overNum = length (filter (\x -> x >= 8) as')
  let defaultNum = length (check (filter (\x -> x < 8) as') [])
  let minNum = maximum[1, defaultNum]
  let maxNum = defaultNum + overNum
  putStrLn $ show minNum ++ " " ++ show maxNum


Measured memory_bytes: 508
#include <stdio.h>
int main(int argc, const char * argv[]) {
    char s[2][100];
    int n;
    scanf("%d", &n);
    scanf("%s%s", s[0], s[1]);
    for (int i = 0; i < n; i++) {
        printf("%c%c", s[0][i], s[1][i]);
    }
    return 0;
}


Measured memory_bytes: 128
import sys
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    else:
        return gcd(y,x%y)

N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(N):
    A[i]//=2
    cnt=1
    while A[i]%2==0:
        A[i]//=2
        cnt+=1
    B.append(cnt)
B.sort()
if B[0]!=B[-1]:
    print(0)
    sys.exit()
num=A[0]
for i in range(1,N):
    num=num*A[i]//gcd(num,A[i])
num*=2**(B[0]-1)
ans=M//num
if ans%2==0:
    print(ans//2)
else:
    print(ans//2+1)

Measured memory_bytes: 64020
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
	bool key[10] = {false};
	int n[4];
	for (int i = 0; i < 4; ++i) {
		cin >> n[i];
		key[n[i]] = true;
	}

	if (key[1] && key[9] && key[7] && key[4]) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, x, N) for (long long i = x; i < (N); i++)
using namespace std;
int main()
{
	long long  N,K;
	cin>>N>>K;
	vector<long long>p(N);
	rep(i,0,N){
		cin>>p[i];
	}
	sort(p.begin(),p.end());
	long long count=0;
	rep(i,0,N-K){
		count+=p[i];
	}
	cout<<count<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;

template<class T>
ll part(const T& s, int l, int r) { return s[r] - s[l]; };

int main(){
  int N; cin >> N;
  vector<ll> A(N + 1);
  rep(i, 1, N + 1) cin >> A[i];
  rep(i, 0, N) A[i + 1] += A[i];
  sort(A.begin(),A.end());
  ll ans = 0;
  ll cnt = 0;
  rep(i, 0, N) {
    if(A[i + 1] == A[i]) cnt++;
    else cnt = 0;
    ans += cnt;
  }
  cout << ans << endl;
  return 0;
}


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

#define ll          long long
#define mp      make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
//----------------------------------------------------------------------------------------------------------------

void solve(){
    
    ll n, m1, k;
    cin >> n >> k;
    vi arr(n), dp(n);
    rep(i, 0, n)    cin >> arr[i];
    dp[0] = 0, dp[1] = abs(arr[0] - arr[1]);
    rep(i, 2, n) {
        m1 = INT_MAX;
        for(int j = 1; j <= k && (i - j) >= 0; j++) {
            m1 = min(m1, dp[i - j] + abs(arr[i] - arr[i - j]));
        }
        dp[i] = m1;
    }
    cout << dp[n - 1] << endl;

}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t ;
    
    t =1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
const int maxn = 200007;
int P[maxn],V[maxn],d[maxn],C[2][maxn];
struct cmp {
    bool operator() (const int &a,const int &b) {
        if(1LL * C[0][a] * C[1][b] != 1LL * C[0][b] * C[1][a])
            return 1LL * C[0][a] * C[1][b] > 1LL * C[0][b] * C[1][a];
        else return a > b;
    }
};
set<int,cmp>st;
int fi(int x) {
    return d[x] == x ? x : d[x] = fi(d[x]);
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 2 ; i <= n ; i++) {
        cin >> P[i];
    }
    f1 (n) {
        cin >> V[i];
    }
    f1 (n) {
        d[i] = i;
        C[V[i]][i] = 1;
    }
    ll ans = 0;
    for (int i = 2 ; i <= n ; i++) {
        st.insert(i);
    }
    for (int i = 1 ; i <= n - 1 ; i++) {
        int v = *st.begin();
        int p = fi(P[v]);
        st.erase(v);
        st.erase(p);
        ans += 1LL * C[0][v] * C[1][p];
        C[1][p] += C[1][v];
        C[0][p] += C[0][v];
        d[v] = p;
        if (p != 1) {
            st.insert(p);
        }
    }
    cout << ans << '\n';
}  

Measured memory_bytes: 13696
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define INF (ll) 1000000007

bool in_a(int n, int *a, int num){
    REP(i,num){
        if(a[i] == n) return true;
    }
    return false;
}

bool judge(int N, int *a, int num){

    while(N > 0){
        int digit = N%10;
        if(in_a(digit, a, num)) return false;
        N /= 10;
    }

    return true;
}

int main() {

    int N, K;
    cin >> N >> K;
    int D[K];
    REP(i,K) cin >> D[i];

    int ans=N;
    while(!judge(ans, D, K)){
        ans++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<long> Lucas(N+1);
  Lucas.at(0)=2;
  Lucas.at(1)=1;
  	for(int i=2;i<=N;i++){
      Lucas.at(i)=Lucas.at(i-1)+Lucas.at(i-2);
    }
  cout<<Lucas.at(N)<<endl;
}


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

//

int main(){
    int a,b; cin>>a>>b;
    if(a%3==0 or b%3==0 or (a+b)%3==0) cout<<"Possible"<<endl;
    else cout<<"Impossible"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;


string Zaki, O;
int n;

Int mod_pow(Int x, Int a, Int m = MOD){
    if(a == 0)return 1;
    Int res = mod_pow(x, a / 2, m);
    res = res * res % m;
    if(a % 2)res *= x;
    return res % m;
}

Int inv(Int x, Int m = MOD){
    return mod_pow(x, m-2, m);
}


Int countPalindrome(Int len){
    if(len == 0)return 1;
    if(len % 2 == 1)return countPalindrome(len - 1) * 26 % MOD;
    else return mod_pow(26, len/2);
}

int main(){
    cin >> Zaki;
    cin >> O;
    cin >> n;
    string invZaki(Zaki.rbegin(), Zaki.rend());
    string invO(O.rbegin(), O.rend());
    if(n <= O.size()){
        string Hoge(invO.begin(), invO.begin() + n);
        string invHoge(Hoge.rbegin(), Hoge.rend());
        string A = Hoge + Zaki + Hoge + O;
        string B = invO + invHoge + invZaki + invHoge;
        if(A == B)cout << 1 << endl;
        else cout << 0 << endl;
    }
    else if(Zaki.size() > O.size()){
        Int freeLength = n - O.size();
        Int ans = countPalindrome(freeLength);
        string rest(Zaki.begin() + O.size(), Zaki.end());
        string invRest(rest.rbegin(), rest.rend());
        bool ok = rest == invRest;
        for(int i = 0;i < O.size();i++){
            ok &= O[i] == Zaki[i];
        }
        if(ok)cout << ans << endl;
        else cout << 0 << endl;
    }
    else if(Zaki.size() <= O.size()){
        Int freeLength = n - O.size();
        Int ans = countPalindrome(freeLength);
        string rest(invO.begin(), invO.begin() + (O.size() - Zaki.size()));
        string invRest(rest.rbegin(), rest.rend());
        bool ok = rest == invRest;
        for(int i = 0;i < Zaki.size();i++){
            ok &= Zaki[i] == O[i];
        }
        if(ok)cout << ans << endl;
        else cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 4964
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main()
{
    string s;
	int it;
	getline(cin,s);
	for(auto it = s.begin(); it != s.end(); ++it)
	{
		auto &c = *it;
		if( islower(c) )
		{
			c = toupper(c);
		}
		else if ( isupper(c) )
		{
			c = tolower(c);
		}
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
#define vi vector<int>
#define vl vector<long long>
#define vvi vector< vector<int> >
#define vvl vector< vector<ll> >
#define vp vector<P>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPD(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORD(i, a, b) for (int i = (int)(a); i >= (int)(b); i--)
#define INF 1e18
#define INFTY 1e9
const int mod = 1000000007;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

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

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

//cout << fixed << setprecision(10) << y << endl;
struct edge {int to, cost;};
vector< vector<edge> > es;

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

ll lcm(ll a, ll b) {
    return a/gcd(a, b)*b;
}


int main() {
    int n;
    cin >> n;
    vi cnt(4);
    REP(i, 4) cnt[i] = 0;
    REP(i, n) {
        string s;
        cin >> s;
        if (s == "AC") cnt[0] += 1;
        else if (s == "WA") cnt[1] += 1;
        else if (s == "TLE") cnt[2] += 1;
        else cnt[3] += 1;
    }
    cout << "AC" << " " << "x" << " " << cnt[0] << endl;
    cout << "WA" << " " << "x" << " " << cnt[1] << endl;
    cout << "TLE" << " " << "x" << " " << cnt[2] << endl;
    cout << "RE" << " " << "x" << " " << cnt[3] << endl;
    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int max=0;
        int[] x=new int[3];
        int i;
        for(i=0;i<3;i++){
            x[i]=scan.nextInt();
            if(max<x[i]){
                max=x[i];
            }
        }
        int K=scan.nextInt();
        int sum=0;
        for(i=0;i<K;i++){
            for(int j=0;j<3;j++){
                if(x[j]==max){
                    x[j]*=2;
                    max=x[j];
                }
            }
        }
        for(i=0;i<3;i++){
            sum+=x[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21460
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF ( 1 << 30 )
#define fr first
#define sc second
typedef pair< int , int > Pt;
const int dx[] = { 0, 1, -1, 0}, dy[] = { 1, 0, 0, -1};
int w, h, cost[30][30];
bool mas[30][30][30][30];
int bfs(){
  fill_n(cost[0],900,0);
  queue<Pt> que;
  cost[0][0] = 1;
  que.push(Pt(0,0));
  while(!que.empty()){
    Pt p = que.front();
    que.pop();
    if(p.fr == h - 1 && p.sc == w - 1) break;
    for(int i = 0 ; i < 4 ; i++ ){
      int ny = p.fr + dy[i], nx = p.sc + dx[i];
      if(ny >= 0 && ny < h && nx >= 0 && nx < w && !cost[ny][nx] && !mas[p.fr][p.sc][ny][nx]  && !mas[ny][nx][p.fr][p.sc]){
        cost[ny][nx] = cost[p.fr][p.sc] + 1;
        que.push(Pt(ny,nx));
      }
    }
  }
  return cost[h-1][w-1];
}
int main(){
  while(cin >> w >> h , w){
    for(int i = 0 ; i < 2 * h - 1 ; i++ ){
      if(i % 2)
        for(int j = 0 ; j < w ; j++ ) cin >> mas[i/2][j][i/2+1][j];
      else
        for(int j = 0 ; j < w - 1 ; j++ ) cin >> mas[i/2][j][i/2][j+1];
    }
    cout << bfs() << endl;
  }
}

Measured memory_bytes: 2008
#include<bits/stdc++.h>
using namespace std;
int n,a;
bool flag=true;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%d",&a);
		if(a%2==0&&a%5!=0&&a%3!=0) flag=false;
	}
	if(flag) printf("APPROVED");
	else printf("DENIED");
	return 0;
}

Measured memory_bytes: 256
// ABC043D - アンバランス

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

int main() {
	string S;
	cin >> S;

	if (S[0] == S[1]) {
		cout << "1 2" << endl;
		return 0;
	}

	for (int i = 2; i < S.size(); i++) {
		if (S[i - 2] == S[i - 1]) {
			cout << i - 1 << " " << i << endl;
			return 0;
		}
		if (S[i - 2] == S[i]) {
			cout << i - 1 << " " << i + 1 << endl;
			return 0;
		}
	}

	cout << "-1 -1" << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
			// ??\???
			Scanner sc = new Scanner(System.in);
			int a, b, c;
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			
			// ???????????????
			if(a < b && b < c) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
	}

}

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

int n, A[20] = {};

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

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  int q, m;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> m;
    if (solve(0, m))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
}



Measured memory_bytes: 3120
using System;
using System.IO;

// arihon p335
// This solution is O(|T|log^2|T| + Q|P|log|T|) order.
namespace ALDS1_14_D
{
    class SuffixArray
    {
        internal int[] sa, rank, tmp;
        internal string S;
        internal int n, k;
 
        public SuffixArray(string SS)
        {
            S = SS;
            n = S.Length;
            sa = new int[n + 1];
            rank = new int[2 * n + 1];
            for (int i = n + 1; i <= n << 1; i++)
            {
                rank[i] = -1;
            }
            tmp = new int[n + 1];
            Construct_SA();
        }
 
        public int Compare_SA(int i, int j)
        {
            return (rank[i] != rank[j]) ? rank[i] - rank[j] : rank[i + k] - rank[j + k];
        }
 
        public void Construct_SA()
        {
            for (int i = 0; i < n; i++)
            {
                sa[i] = i;
                rank[i] = S[i];
            }
            sa[n] = n; rank[n] = -1;
 
            for (k = 1; k <= n; k <<= 1)
            {
                Array.Sort(sa, Compare_SA);
 
                int d;
                d = tmp[sa[0]] = 0;
 
                for (int i = 1; i <= n; i++)
                {
                    d = tmp[sa[i]] = d + ((Compare_SA(sa[i - 1], sa[i]) < 0) ? 1 : 0);
                }
 
                for (int i = 0; i <= n; i++)
                {
                    rank[i] = tmp[i];
                }
 
            }
        }
 
        public string Contains(string pattern)
        {
            int l = 1, r = n + 1;
            int pl = pattern.Length;
 
            while (l < r)
            {
                int m = (l + r) >> 1;
 
                string subStr = (sa[m] + pl > n) ? S.Substring(sa[m]) : S.Substring(sa[m], pl);
 
                int comp = subStr.CompareTo(pattern);
                if (comp == 0) return "1";
 
                if (comp < 0) l = m + 1;
                else r = m;
            }
            return "0";
        }
    }
 
 
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            var T = Console.ReadLine();
            var SA = new SuffixArray(T);
            var Q = int.Parse(Console.ReadLine());
            for (int i = 0; i < Q; i++)
            {
                var P = Console.ReadLine();
                Console.WriteLine(SA.Contains(P));
            }
            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 38872
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
const int INF = 1001001001;

int main()
{
    int k; cin >> k;
    string s; cin >> s;
    if(s.size() <= k) cout << s << endl;
    else cout << s.substr(0,k) << "..." << endl;

}

/*
Ctrl+@
g++ a.cpp
./a.out
*/

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

template<typename T, class F>
void prime_factors(T n, const F f){
    for(T k=2; k*k<=n; ++k){
        while(n % k == 0)f(k), n /= k;
    }
    if(1 < n)f(n);
}

int main(){
    int n;
    cin >> n;
    auto func = [](int x){cout << ' ' << x;};
    cout << n << ':';
    prime_factors(n, func);
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int count=0;
  for(int i=a;i<=b;i++){
    int c=i%10;
    int d=i/10000;
    int e=(i/10)%10;
    int f=(i/1000)%10;
    if(c==d&&e==f){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <string>
#include <functional>
#include <math.h>
#include <utility>
using namespace std;
int main()
{
	string s;cin>>s;
	for(int i=0;i<(int)s.length();i++){
		char c=s[i];
		cout<<char((c-'A'-3+26)%26+'A');
	}
	cout<<endl;
}

Measured memory_bytes: 1176
package main

import(
    "fmt"
    "strings"
)



func main() {
    var a,b,c string
    fmt.Scan(&a,&b,&c)
    fmt.Printf("%c%c%c",strings.ToUpper(a)[0],strings.ToUpper(b)[0],strings.ToUpper(c)[0])
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


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

#define ll long long
#define INF_LL 1LL << 60
#define INF 99999999
#define MOD (ll)1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, a, n) for(int i = a; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

void put_double(double obj){printf("%.12f\n",obj);};

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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


int main()
{
    int N,M;
    cin >> N >> M;

    vector<ll> a(N);
    vector<ll> b(N);
    rep(i,N) cin >> a[i] >> b[i];

    vector<ll> c(M);
    vector<ll> d(M);
    rep(i,M) cin >> c[i] >> d[i];

    rep(i,N)
    {
        int near_point = 1;
        ll dist = abs(a[i]-c[0])+ abs(b[i]-d[0]);
        REP(j, 1, M)
        {
            if( abs(a[i]-c[j])+abs(b[i]-d[j]) < dist )
            {
                dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
                near_point = j+1;
            }
        }
        cout << near_point << endl;
    }


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
//Int mod = 1e6+3;

int main() {
    string s;
    cin >> s;
    Int n = (Int)s.size();
    vector<Int> pw(n + 1);
    pw[0] = 1;
    for (Int i = 0; i < n; i++) {
        pw[i + 1] = pw[i] * 3LL;
        pw[i + 1] %= mod;
    }
    vector<Int> d(n + 1);
    d[0] = 1;
    for (Int i = 0; i < n; i++) d[i + 1] = (s[i] == '1') ? 2LL : 1LL;
    for (Int i = 0; i < n; i++) {
        d[i + 1] *= d[i];
        d[i + 1] %= mod;
    }
    pw[0] = 1; 
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        if (s[i] == '1') {
            res += d[i] * pw[n - 1 - i];
            res %= mod;
        }
    }
    dump((res + d[n]) % mod);
    return 0;
}

Measured memory_bytes: 2048
S = input()
S = [int(S[i:i+1]) for i in range(len(S))]
n = len(S)
bc = 0
wc = 0
for i in range(n):
  if i % 2 == 0:
    if S[i] == 1:
        bc += 1
    else:
        wc += 1
  else:
    if S[i] == 0:
      	bc += 1
    else:
        wc += 1
if bc > wc:
    print(wc)
else:
    print(bc)


Measured memory_bytes: 3956