akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, k, a[N];
ll sum;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i];
   sort (a + 1, a + n + 1);
   for (int i = 1; i <= k; i ++) sum += a[i];
   cout << sum;
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3660
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  string s;
  cin>>s;

  map<char,int> mp;
  for(int i=0;i<s.size();i++)mp[s[i]]++;

  int ans=0;

  for(int i=0;i<26;i++){
    char x='a'+i;
    while(mp[x]>0){
      mp[x]--;
      int tmp=1;
      for(int j=i+1;j<26;j++){
        char y='a'+j;
        if(mp[y]>0){
          mp[y]--;
          tmp++;
        }else{
          break;
        }
      }
      ans+=min(tmp,3LL);
    }
  }

  for(int i=0;i<10;i++){
    char x='0'+i;
    while(mp[x]>0){
      mp[x]--;
      int tmp=1;
      for(int j=i+1;j<10;j++){
        char y='0'+j;
        if(mp[y]>0){
          mp[y]--;
          tmp++;
        }else{
          break;
        }
      }
      ans+=min(tmp,3LL);
    }
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 3184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC125A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, T,x,y;
            var word = Console.ReadLine().Split(' ');
            A = int.Parse(word[0]);
            B = int.Parse(word[1]);
            T = int.Parse(word[2]);
            x = T / A;
            y = x * B;
            Console.WriteLine(y);
            Console.WriteLine();
           
            
        }
    }
}

Measured memory_bytes: 13140
h, w = map(int, input().split())
c=[list(map(int, input().split())) for i in range(10)]
A=[list(map(int, input().split())) for i in range(h)]
for k in range(10):
    for i in range(10):
        for j in range(10):
            c[i][j]=min(c[i][j], c[i][k]+c[k][j])
cnt=[]      
for i in range(10):
    res=0
    for j in range(h):
        res+=A[j].count(i)
    cnt.append(res)    
print(sum(cnt[i]*c[i][1] for i in range(10)))    

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main() {
    int N;
    int K;
    cin >> N >> K;
    int prices[N];
    rep(i,N){
        cin >> prices[i];
    }


    sort(prices, prices+N);     

    int sum = 0;
    rep(i, K){
        sum += prices[i];
    }
    
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3628
m,k=map(int,input().split())
if m==1:
  if k!=0:
    print(-1)
  else:
    print(0,0,1,1)
  exit()
elif 2**m<=k:
  print(-1)
  exit()
b=[]
for i in range(2**m):
  if i!=k:
    b.append(i)
c=b[::-1]
d=b+[k]+c+[k]
print(*d)

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

const int inf = 1e9;

signed main () {
	int n, k;
	cin >> n >> k;
	vector < int > a(n + 1, 0), pref(n + 1, 0), p(n + 1, 0);
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		pref[i] = (pref[i - 1] + a[i]) % k;
		p[i] = (pref[i] - i + ((inf / k) * k)) % k;
	}
	map < int, int > cnt;
	int64_t ans = 0;
	for (int i = 0; i <= n; ++i) {
		if (i >= k)
			--cnt[p[i - k]];
		ans += cnt[p[i]];
		++cnt[p[i]];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
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; }
int main(){
    ios::sync_with_stdio(false);
    string s,t;
    cin >> s >> t;
    vector<string> cand_list;
    rep(i,s.size()-t.size()+1) {
        bool ok = true;
        string cand_str = s.substr(i, t.size());
        rep(j, t.size()) {
            if(cand_str[j] == t[j]) continue;
            else if(cand_str[j] == '?')  cand_str[j] = t[j];
            else ok = false;
        }
        if(ok) {
            string new_str = s;
            new_str.replace(i,t.size(),cand_str);
            rep(j,s.size()) if(new_str[j] == '?') new_str[j] = 'a';
            cand_list.push_back(new_str);
        }
    }
    if(cand_list.size() == 0) cout << "UNRESTORABLE" << endl;
    else {sort(cand_list.begin(), cand_list.end());
    cout << cand_list[0] << endl;
    }
}

Measured memory_bytes: 256
N = int(input())

if N % 2 == 0:
    S = 1 + N
else:
    S = N
ans = []
for i in range(1, N+1):
    for j in range(i+1, N+1):
        if i+j == S:
            continue
        ans.append([i, j])
print(len(ans))
for p in ans:
    print(p[0], p[1])


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll X; cin >> X;
  ll now = 100, result = 0;
  while (now<X) { now *= 1.01; result++; }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    ll n;cin>>n;
    string s;cin>>s;
    ll r=0,b=0;
    rep(i,0,s.size()-1){
        if(s[i]=='R')r++;
        else b++;
    }
    if(r>b){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
    
    return 0;
}






Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    string s;
    cin>>s;
    int ans = 0;
    int curr = 0;
    owo(i, 0, s.size()) {
        if(s[i]=='R')curr++;
        else curr = 0;
        ans = max(ans, curr);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#define rep(i,start,n) for(int i=0 ; i < n ; i++)                  //???????????????

using namespace std;

int main(){

int count[26]={0};                              //A~Z?????§????????????????????°?????????
int x=0;
string sentence;                                 //sentence??¨?????????????????¨????????°?????????

while(getline(cin,sentence)){                           //sentence?????????????????????????????\??????????´?
x = sentence.length();                          //x?????\??????????????????????????????????´?


  rep(i , 0 , sentence.size()){               //?????????
    char c = tolower(sentence[i]);            //??\??????????????????????°????????????????
    count[c-'a']++;                      //????????????????????????????????????????????????
  }
}

rep( i , 0 , 26 ){

  cout << char(i+'a') << " : " << count[i] << endl;    //??¨???

}

return 0;

}

Measured memory_bytes: 1176
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    int H, W;
    cin >> H >> W;

    int N; // color num
    cin >> N;

    vector<int> V;
    FOR(i, 0, N){
        int a;
        cin >> a;
        FOR(j, 0, a){
            V.push_back(i+1);
        }
    }

    vector<int> subV(W);
    FOR(i, 0, H){
        copy(V.begin() + i*W, V.begin() + (i+1)*W, subV.begin());
        if(i%2==1){
            reverse(ALL(subV));
        }
        vprint(subV);
    }
    
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String[] s = scan.next().split("");
        scan.close();

        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length; i++) {
            if (s[i].equals("0")) {
                sb.append("0");
            } else if (s[i].equals("1")) {
                sb.append("1");
            } else {
                if (sb.length() > 0) {
                    sb.deleteCharAt(sb.length() - 1);
                }
            }
        }

        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 35644
s=input()
flg=0
for i in range(len(s)):
  if i%2==0:
    if s[i]!='R' and s[i]!='U' and s[i]!='D':
      flg=1
      break
  else:
    if s[i]!='L' and s[i]!='U' and s[i]!='D':
      flg=1
      break
if flg==0:
  print("Yes")
else:
  print("No")
      

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF ((int)(1e9))

using namespace std;

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

const int MAX_N = (int)1e5 + 5;

int dp[MAX_N][3];

int main()
{
	rep (i, MAX_N) rep (j, 3) dp[i][j] = 0;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N; cin >> N;
	vector<int> a(N, 0), b(N, 0), c(N, 0);
	rep (i, N){
		cin >> a[i] >> b[i] >> c[i];
	} // end rep
	
	rep (i, N){
		rep (j, 3){
			if (j == 0){
				dp[i+1][1] = max(dp[i+1][1], dp[i][j] + a[i]);
				dp[i+1][2] = max(dp[i+1][2], dp[i][j] + a[i]);
			}else
			if (j == 1){
				dp[i+1][0] = max(dp[i+1][0], dp[i][j] + b[i]);
				dp[i+1][2] = max(dp[i+1][2], dp[i][j] + b[i]);
			}else
			if (j == 2){
				dp[i+1][0] = max(dp[i+1][0], dp[i][j] + c[i]);
				dp[i+1][1] = max(dp[i+1][1], dp[i][j] + c[i]);
			} // end if
		} // end rep
	} // end rep

	int res = 0;
	rep (j, 3){
		res = max(res, dp[N][j]);
	} // end rep

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 2560
/*
 题意：给定n个数，每次可以替换一个数，求n个数的最大公因数。

思路：求一遍前缀后缀gcd再枚举
*/

#include<iostream>
using namespace std;

int gcd(int x,int y){
	return y==0 ? x : gcd(y,x%y);
}

int main(){
	int n,a[100005],per[100005],las[100005],ans=0;
	cin>>n;
	for(int i=1;i<=n;++i)	cin>>a[i];
	per[1]=a[1];
	las[n]=a[n];
	for(int i=2;i<=n;++i)	per[i]=gcd(per[i-1],a[i]);
	for(int i=n-1;i>=1;--i)	las[i]=gcd(las[i+1],a[i]);
	for(int i=1;i<=n;++i)
		if(ans<gcd(per[i-1],las[i+1]))
			ans=gcd(per[i-1],las[i+1]);
	cout<<ans;
}

Measured memory_bytes: 1408
def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d[i] = cnt
    
    if temp!=1:
        d[temp] = 1
    
    if len(d) == 0:
        d[n] = 1
    
    return list(d.values())


def calc(n):
    res = 1
    n -= 1
    while n >= res+1:
        res += 1
        n -= res
    return res

N = int(input())
if N == 1:
    print(0)
    quit()

e = factorization(N)
ans = 0
for ei in e:
    ans += calc(ei)

print(ans)

Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; i++)
#define REPR(i,n) for(int i = n; i >= 0; i--)
#define FOR(i,m, n) for(int i = m-1; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
//vector<vector<要素の型>> 変数名(要素数1, vector<要素の型>(要素数2, 初期値))
//vector<intなど> 変数名(要素数,初期値)
using namespace std;
typedef long long ll;
const int MAX = 510000;
const int INF =2000000000;
const int MOD = 1000000007;
//gcd,lcmセット
ll gcd(ll a, ll b){
   if (a%b == 0) return b;
   else return gcd(b, a%b);
}
ll lcm(ll a, ll b){	
   return a*b/gcd(a, b);
}
int pow_kai(int a, int n){//aのn乗を計算します。
  int x = 1;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
// a^n mod を計算する
long long modPow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
// a^{-1} mod を計算する
ll modInv(ll a, ll mod) {
    return modPow(a, mod - 2, mod);
}

long long fac[MAX], finv[MAX], inv[MAX];

// combinationのテーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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;
    }
}
 
// 二項係数計算
 
bool isPrime(ll x){
    int i;
    if(x < 2)return false;
    else if(x == 2) return true;
    if(x%2 == 0) return false;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return false;
    return true;
}
//dfsではvector<vector<int>> g(n);で◎
int main() {
  	int a[2020][2020];
	REP(i,2020) REP(j,2020) a[i][j]=INF;
    //COMinit();
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++) {
      for(int j=i+1;j<=n;j++){
        if(j==i+1) a[i][j]=1;
        else if(j>=y&&i<=x) a[i][j]=j-y+x-i+1;
        else if(j<y&&i>x) a[i][j]=min(j-i,y-x-(j-i)+1);
        else a[i][j]=min(abs(j-y)+1+abs(i-x),j-i);
    	//cout<<"i:"<<i<<"j:"<<j<<"|"<<a[i][j]<<endl;
    }}
    int k[n];
    REP(i,n) k[i]=0;
    for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++) k[a[i][j]]++;
    for(int i=1;i<n;i++) cout<<k[i]<<endl;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; ++i)
#define repe(i, n) for(int i=0; i <= n; ++i)
#define repr(i, n) for(int i=n-1; i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
using namespace std;
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;}
template <class T> using V=vector<T>;
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1000000007;
const ll MAX = 510000;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; 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(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int n;
    cin >> n;
    int c = 0;
    int res =0;
    if (n==1) {
        cout << 1 << "\n";
    } else {
        for(int i=1; i<=n; ++i) {
            int j = i;
            int _c = 0;
            while(j%2 ==0) {
                _c++;
                j /= 2;
            }
            if (_c > c) {
                c = _c;
                res = i;
            }
        }
        cout << res << "\n";
    }
}


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

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

    int non=0;
    for(int j=0; j<num; j++){
        if(A[j]%2==0){
            if(A[j]%5==0 || A[j]%3==0){
            }else{
                non++;
            }
        }
    }

    if(non==0){
        cout << "APPROVED\n";
    }else{
        cout << "DENIED\n";
    }

    return 0;
  
}

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

using namespace std;

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

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n,k;
int a[252521];
int s[252521];

int main(){
    scanf("%d%d",&n,&k);
    REP(i,n)scanf("%d",a+i);
    unordered_map<int,int> cnt;
    REP(i,n)s[i+1] = (s[i] + a[i]) % k;
    ll ans = 0;
    REP(i,n+1){
        int v = (s[i] - i%k + k) % k;
        if(i >= k){
            int j = i-k;
            int w = (s[j] - j%k + k) % k;
            cnt[w]--;
        }
        ans += cnt[v];
        cnt[v]++;
    }
    printf("%lld\n",ans);
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int r; cin >> r;
  cout << r * r << endl;
}


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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

ll gcd(ll a, ll b)
{
    return (a < b) ? gcd(b, a) : ((a % b) ? gcd(b, a % b) : b);
}

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

int main()
{
    ll N;
    cin >> N;
    rep(a, 3500)
        rep(b, 3500)
    {
        ll A = a + 1;
        ll B = b + 1;
        ll x = N * A * B;
        ll y = 4 * A * B - N * A - N * B;
        if (y != 0 && x % y == 0)
        {
            ll C = x / y;
            bool isans = (0 < C) && (C <= 3500) && (4 * A * B * C == (A * B + B * C + C * A) * N);
            if (isans)
            {
                cout << A << " " << B << " " << C << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif


long long floorSum(long long n, long long m, long long a, long long b) {
    //sum from 0 to n-1 of floor(ai+b / m)
    long long ans = (n - 1) * n * (a / m) / 2 + n * (b / m);
    a %= m;
    b %= m;

    long long y_max = (a * n + b) / m, x_max = (y_max * m - b);
    if (y_max == 0) return ans;
    ans += (n - (x_max + a - 1) / a) * y_max;
    ans += floorSum(y_max, a, m, (a - x_max % a) % a);
    return ans;
}

long long floorRangeSum(long long l, long long r, long long m, long long a, long long b) {
    // from la+b to ra+b
    return floorSum(r + 1, m, a, b) - floorSum(l, m, a, b);
}



int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif


    int tests;
    cin >> tests;
    for (int casenum = 1; casenum <= tests; casenum++) {
        int n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floorSum(n, m, a, b) << endl;
    }

}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n;
	static ll a[200010];
	scanf("%d",&n);
	rep1(i,n)scanf("%lld",&a[i]);
	
	vector<P> vec;
	rep1(i,n){
		vec.pb(P(a[i],i));
	}
	sor(vec);
	
	set<int> S;
	S.insert(0);
	S.insert(n+1);
	ll ret = 0;
	
	rep(i,vec.size()){
		P p = vec[i];
		set<int>::iterator itr = S.lower_bound(p.sc);
		int r = *itr;
		itr--;
		int l = *itr;
		ret += p.fr*(r-p.sc)*(p.sc-l);
		S.insert((int)p.sc);
	}
	
	cout << ret << endl;
}


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

using namespace std;

#define INF INT_MAX
#define F first
#define S second

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

int main(){
  string s;
  int len,ans=0;
  cin>>s;
  len=s.size();
  for(int i=0;i<len/2;i++){
    if(s[i]!=s[len-i-1]) ans++;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
using namespace std;
int main()
{
    long long a,b,c,p,q;
    cin>>a>>b>>c;
    a=abs(a);
    if (abs(a/c)>b)cout<<abs(a-(b*c));
    else 
    {
        if (a<0)a=-a;
        p=(a%c);
        q=abs(p-c);//cout<<p<<" "<<q;
        if (p<q)
        {
            if ((b-(a/c))%2==0)cout<<p;
            else cout<<q;
        }
        else
        {
            if ((b-(a/c))%2==0)cout<<p;
            else cout<<q;
        }
    }
}
            

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
int main(){
  int h1,m1,h2,m2,k,len=0;
  cin>>h1>>m1>>h2>>m2>>k;
  len = (h2-h1)*60+m2-m1;
  if((len/k)>=1){
    cout << len-k<< endl;
  }
  else cout << 0<< endl;
}







Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(int i = b; i < e; i++)
#define forg(i, b, e, m)	for(int i = b; i < e; i+=m)

using namespace std;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
const int tam = 10000010;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	int n, m;
	cin>>n>>m;
	int ar[m], b, id[m];
	vector<pair<int,int>> ord[n];
	fore(i, 0, m)
	{
		cin>>ar[i]>>b;
		ord[ar[i]-1].pb(mp(b, i));
	}
	fore(i, 0, n)
	{
		sort(ord[i].begin(), ord[i].end());
		fore(j, 0, ord[i].size())
		{
			id[ord[i][j].s] = j+1;
		}
	}
	//cout<<log10(1)<<' '<<log10(2)<<'\n';
	fore(i, 0, m)
	{
		int cer = 5 - (int)(floor(log10((double)ar[i]) + EPS) + EPS);
		//cout<<cer<<' '<<floor(log10((double)ar[i]) + EPS) + EPS<<'\n';
		fore(i, 0, cer) cout<<0;
		cout<<ar[i];
		cer = 5 - (int)(floor(log10((double)id[i]) + EPS) + EPS);
		fore(i, 0, cer) cout<<0;
		cout<<id[i]<<'\n';
	}
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS2

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

int main() {
    int n, k;
    cin >> n >> k;
    ll ans = pow(n/k,3);
    if (k&1) cout << ans << endl;
    else {
        ans += pow(n/(k/2)-n/k,3);
        cout << ans << endl;
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(long long N, vector<long long> a) {
  ll ans = 0;

  sort(ALL(a));

  ll buf = a[0];
  ll count = 1;
  for (int i = 1; i < N; ++i) {
    if (a[i] == buf) {
      count++;
    } else {
      ans += (count >= buf) ? count - buf : count;
      count = 1;
      buf = a[i];
    }
  }

  ans += (count >= buf) ? count - buf : count;

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> a(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> a[i];
  }
  solve(N, a);
  return 0;
}


Measured memory_bytes: 1792
#sys.stdin.readline()
import sys
input = sys.stdin.readline

N,Y = map(int,input().split())
p = Y//1000
x,y,z = 0,0,0
judge = 0 #0:不可,1:可

#連立方程式
#10000x + 5000y + 1000z = 1000p(Y = 1000p)
#x + y + z = N 
#整数解 x = -4k+p-N , y = 9k-2p+2N, z = N-x-y(k = 0,...2000)

if((p-N) >= 0):
 for k in range((p-N)//4 + 1):
  x = -4*k+p-N
  y = 9*k-2*p+2*N
  z = N-x-y
  if((x>=0)and(y>=0)and(z>=0)):
    judge = 1
    break

if(judge == 1):
  print(x,y,z)
else:
  print(-1,-1,-1)

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

using namespace std;

int main()
{
    int a,b,k1=0,k2=0;
    cin>>a>>b;
    for(int i=1; ;i++){
        k1=(i*(i+1))/2;
        k2=((i+1)*(i+1+1))/2;
        if(k1>=a && k2>=b && (k1-a)==(k2-b)) break;
    }
    cout<<k1-a;
    return 0;
}


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

int main(){
	int n;
	scanf("%d", &n);
	
	vector <int> cnt(n, 0), cntb(n, 0), a(n), b(n);
	
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		a[i]--;
		
		cnt[a[i]]++;
	}
	
	for(int i = 0; i < n; i++){
		scanf("%d", &b[i]);
		b[i]--;
		
		cnt[b[i]]++;
		cntb[b[i]]++;
	}
	
	set < pair <int, int> > s;
	for(int i = 0; i < n; i++){
		if(cnt[i] > n){
			printf("No\n");
			return 0;
		}
		if(cntb[i] > 0)s.insert(make_pair(cnt[i], i));
	}
	
	auto dec = [&](int x, int db){
	                cntb[x] -= db;
                    if(cntb[x] == 0){
                        if(db > 0)s.erase(make_pair(cnt[x], x));
                    }else{
                        auto d = s.extract(make_pair(cnt[x], x));
                        d.value().first--;
                        cnt[x]--;
                        s.insert(move(d));
                    }
	            };
	
	printf("Yes\n");
	for(int i = 0; i < n; i++){
		if(i > 0)printf(" ");
		
		if(s.size() == 1){
			printf("%d", s.begin()->second + 1);
			continue;
		}
		
		int x = prev(s.end())->second, y = prev(prev(s.end()))->second;
		
		if(x != a[i]){
			printf("%d", x + 1);
			
			dec(a[i], 0);
			dec(x, 1);
		}else{
			printf("%d", y + 1);
			
		    dec(a[i], 0);
		    dec(y, 1);
		}
	}
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 15512
#include <cstdlib>
#include <climits>
#include <iostream>
#include <sstream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

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

    std::vector<int64_t> a;
    for (int64_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        a.push_back(t);
    }

    std::stringstream ss;
    if (N % 2 == 0) {
        // 偶数
        for (int64_t i = N - 1; i > 0; i -= 2) {
            ss << a[i] << " ";
        }
        for (int64_t i = 0; i < N; i += 2) {
            ss << a[i] << " ";
        }
    }
    else {
        // 奇数
        for (int64_t i = N - 1; i >= 0; i -= 2) {
            ss << a[i] << " ";
        }
        for (int64_t i =1; i < N; i += 2) {
            ss << a[i] << " ";
        }
    }

    std::string s = ss.str();
//    boost::algorithm::trim(s);
    std::cout << s << std::endl;

    return 0;
}


Measured memory_bytes: 7668
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,k,s = LI()
    if s == 10**9:
        return JA([s]*k + [1]*(n-k), " ")

    return JA([s]*k + [s+1]*(n-k), " ")

print(main())





Measured memory_bytes: 15300
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
int main(){
	int a=gi(),b=gi();
	if((b&1)^(a&1))puts("IMPOSSIBLE");
	else printf("%d\n",(a+b)/2);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int a[4],b[4];
  int i,j,h,v;

  while(scanf("%d",&a[0])!=EOF){
    for(i=1;i<4;i++)
      scanf("%d",&a[i]);
    for(i=0;i<4;i++)
      scanf("%d",&b[i]);
    h=0; v=0;
    for(i=0;i<4;i++){
      if(a[i]==b[i])
	h++;
    }
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(a[i]==b[j])
	  v++;
      }
    }
    v=v-h;
    printf("%d %d\n",h,v);
  }
  return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cctype>
#include<cassert>
#define REP(i,a,b) for(register int i=(a); i<(b); i++)
#define REPE(i,a,b) for(register int i=(a); i<=(b); i++)
using namespace std;
typedef long long ll;
#define MAXN 1000007
#define MO 1000000007
ll fz[MAXN*2],fm[MAXN*2];
ll g(int r, int c) {
	ll ans=0;
	REPE(i,0,r) {
		ans=(ans+fz[i+1+c]*fm[i+1]%MO*fm[c]%MO)%MO;
	}
	return ans;
}
int qpow(ll a, int b) {
	ll ans=1;
	for(;b;b>>=1) {
		if(b&1) ans=ans*a%MO;
		a=a*a%MO;
	}
	return ans;
}
int main() {
	int r1,c1,r2,c2; scanf("%d%d%d%d", &r1, &c1, &r2, &c2);
	fz[0]=fz[1]=1;
	fm[0]=fm[1]=1;
	REP(i,2,MAXN*2) fz[i]=fz[i-1]*i%MO;
	REP(i,2,MAXN*2) fm[i]=qpow(fz[i],MO-2);
	printf("%lld\n", (g(r2,c2)-g(r2,c1-1)-g(r1-1,c2)+g(r1-1,c1-1)+MO*2)%MO);
}



Measured memory_bytes: 31360
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

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

    int n;cin>>n;
    vector<vector<int>> g(n);
    rep(i,n-1){
        int u,v;cin>>u>>v;u--,v--;
        g[u].push_back(v);g[v].push_back(u);
    }    
    function<int(int,int)> dfs=[&](int pre,int now){
        int ret=0;
        for(auto &to:g[now])if(to!=pre)ret^=dfs(now,to)+1;
        return ret;
    };
    cout<<(dfs(-1,0)==0?"Bob\n":"Alice\n");
    return 0;
}


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

const int mod = 1e9 + 7;

int n, ans = 1;
int cnt[26];
string s;

signed main() {
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		cnt[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		ans *= cnt[i] + 1;
		ans %= mod;
	}
	cout << ans - 1 << '\n';
	return 0;
}

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

int main() {
  int D;
  cin>>D;
  if(D==25){
    cout<<"Christmas"<<endl;
  }
  else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  else if(D==23){
    cout <<"Christmas Eve Eve"<<endl;
  }
  else if(D==22){
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if(A==1 && B==2)
        printf("3\n");
    else if(A==1 && B==3)
        printf("2\n");
    else if(A==2 && B==3)
        printf("1\n");
    else if(A==3 && B==1)
        printf("2\n");
    else if(A==3 && B==2)
        printf("1\n");
    else if(A==2 && B==1)
        printf("3\n");
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

vector<int> adj[100000];
int ans = 1e9;
int kenken_dist[100000][3];

int N, M, S, T;

int main(){
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 3; j++){
            kenken_dist[i][j] = 1e9;
        }
    }
    for(int i = 0; i < M; i++){
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        adj[u].push_back(v);
    }
    cin >> S >> T;
    S--;
    T--;

    queue<pair<int, int>> q;
    q.push(make_pair(S, 0));
    kenken_dist[S][0] = 0;
    while(!q.empty()){
        pair<int, int> args = q.front(); q.pop();
        int now = args.first;
        int dist = args.second;
        kenken_dist[now][dist % 3] = dist;
        if(now == T && dist % 3 == 0){
            cout << dist / 3 << endl;
            return 0;
        }
        for(int i = 0; i < adj[now].size(); i++){
            if(kenken_dist[adj[now][i]][(dist + 1) % 3] > dist + 1){
                kenken_dist[adj[now][i]][(dist + 1) % 3] = dist + 1;
                q.push(make_pair(adj[now][i], dist + 1));
            }
        }
    }
    cout << -1 << endl;
    
}


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

using namespace std;

#define foorp(i , a , n) for (int (i) = (a); (i) < (n); (i)++)
#define foorm(i , a , n) for (int (i) = (a); (i) > (n); (i)--)
#define ll long long int

string s;
bool  n , w , sb , e;

int main()
{
    cin >> s;
    for (int i = 0; i < (int)s.size(); i++)
    {
        if (s[i] == 'N')
            n = true;
        if (s[i] == 'W')
            w = true;
        if (s[i] == 'S')
            sb = true;
        if (s[i] == 'E')
            e = true;
    }
    if (!(n == sb) || !(w == e))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}


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

char c[55][55]; 
int w,h,cnt;

int main(){
	cin>>h>>w;
	for(int i=1; i<=h;i++){
		for (int j=1; j<=w;j++) 
			cin>>c[i][j];
	}
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(c[i][j]=='#'&&c[i][j - 1]!='#'&&c[i - 1][j]!='#'&&c[i][j + 1]!='#'&&c[i + 1][j]!='#') 
				cnt++;
		}
	}
	if(cnt==0) 
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int>cnt(N+1, 0);
    for (int i = 0; i < N; ++i) {
        int A;
        cin >> A;
        cnt[A]++;
    }
    sort(cnt.begin(), cnt.end());
    int sum = 0;
    vector<int>ans(N+1);
    ans[0] = N+1;
    // 取ることのできる回数でループ
    // Kに対して単調減少
    for (int i = 1; i <= N; ++i) {
        auto iter = lower_bound(cnt.begin(), cnt.end(), i);
        sum += cnt.end() - iter;
        ans[i] = sum / i; // ans[i] >= K ならi個取れる
    }
    for (int i = 1; i <= N; ++i) {
        auto iter = upper_bound(ans.begin(), ans.end(), i, greater<int>());
        cout << iter - ans.begin() - 1 << "\n";
    }
    return 0;
}

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

int const N=1e2+5, M=1e5+7, OO = 0x3f3f3f3f;

int n,W;
int w[N],v[N];

long long mem[N][M];
long long solve(int i, int rem)
{
    if(i==n)
        return 0;
    if(mem[i][rem]!=-1)
        return mem[i][rem];
    long long op1=solve(i+1,rem);
    long long op2= (rem>=w[i]) ? solve(i+1,rem-w[i])+v[i] : 0;
    return mem[i][rem]=max(op1,op2);
}


int main()
{
//    freopen("input.txt","rt",stdin);
//    freopen("output.txt","wt",stdout);
    scanf("%d %d",&n,&W);
    for(int i=0; i<n; i++)
        scanf("%d %d",w+i,v+i);
    memset(mem, -1, sizeof mem);
    printf("%lld\n",solve(0,W));



    return 0;
}


Measured memory_bytes: 82304
import java.util.Scanner;

public class Main {


public static void main(String args[]) {
	
		Scanner s = new Scanner(System.in);
	
		for(int i = 1;;i++) {
			int x = s.nextInt();
	
	if(x!=0) {
		System.out.println("Case "+i+":"+" "+x);
	}
	else break;
		}
		s.close();
}
}



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

int main () {
  int a = 0;
  string S;
  cin >> S;
  
  for (int i = 0; i < 4; i++) {
    if (S.at(i) == '+') {
      a ++;
    }
    if (S.at(i) == '-') {
      a --;
    }
  }
  cout << a << endl;
}

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

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    a.sort();
    a.reverse();

    let mut ans: usize = 0;
    for i in 0..n {
        if i == 0 {
            continue;
        }
        ans += a[i / 2];
    }
    ans.to_string()
}


Measured memory_bytes: 6324
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

N, K = MAP()
A = [a-1 for a in LIST()]
C = LIST()
MAX = 32

N = len(A)
# nxt[k][i] := iから2^k回移動した後のマス
nxt = list2d(MAX, N, -1)
# score[k][i] := iから2^k回移動した時のスコア
score = list2d(MAX, N, -1)
# mx[k][i] := iから2^k回以下移動した時のスコアの最大値
mx = list2d(MAX, N, -1)
for i, a in enumerate(A):
    nxt[0][i] = a
    score[0][i] = C[a]
    mx[0][i] = C[a]

for k in range(1, MAX):
    for i in range(N):
        nxt[k][i] = nxt[k-1][nxt[k-1][i]]
        score[k][i] = score[k-1][i] + score[k-1][nxt[k-1][i]]
        mx[k][i] = max(mx[k-1][i], score[k-1][i] + mx[k-1][nxt[k-1][i]])

ans = -INF
for i in range(N):
    cur = i
    sm = 0
    for k in range(MAX-1, -1, -1):
        if K >> k & 1:
            ans = max(ans, sm + mx[k][cur])
            sm += score[k][cur]
            cur = nxt[k][cur]
    ans = max(ans, sm)
print(ans)


Measured memory_bytes: 79184
import java.util.Scanner;

public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);


while(true){
int i,j,k;
double sum=0,ave,s=0,sg=0; 


j = sc.nextInt();
int[] intarray = new int[j];

if (j == 0 ){
    break;
}

for(i=0;i<j;i++){

 intarray[i] = sc.nextInt();

sum = sum + intarray[i];
}
ave = sum/j;

for(k=0;k<j;k++){

    s =  s + (intarray[k]-ave)*(intarray[k]-ave);
}



sg = Math.sqrt(s/j);

System.out.println(sg);

}
}
}


Measured memory_bytes: 31260