akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main(){
    vector<vector<int>> bingo(3, vector<int>(3));
    for (int i = 0; i < 3; i++){
        cin >> bingo.at(i).at(0) >> bingo.at(i).at(1) >> bingo.at(i).at(2);
    }

    int n;
    cin >> n;
    vector<int> num(n);
    for (int i = 0; i < n; i++){
        cin >> num.at(i);
    }

    vector<vector<int>> hantei(3, vector<int>(3));
    for(int i = 0; i < n; i++){
        for (int j = 0; j < 3; j++){
            for (int k = 0; k < 3; k++){
                if (num.at(i) == bingo.at(j).at(k)){
                    hantei.at(j).at(k) = 1;
                }
            }
        }
    }    
    
    bool result = false;

    for(int i = 0; i < 3; i++){
        if (hantei.at(i).at(0) == 1 && hantei.at(i).at(1) == 1 && hantei.at(i).at(2) == 1){
            result = true;
        }else if (hantei.at(0).at(i) == 1 && hantei.at(1).at(i) == 1 && hantei.at(2).at(i) == 1){
            result = true;
        }else if (hantei.at(0).at(0) == 1 && hantei.at(1).at(1) == 1 && hantei.at(2).at(2) == 1){
            result = true;
        }else if (hantei.at(0).at(2) == 1 && hantei.at(1).at(1) == 1 && hantei.at(2).at(0) == 1){
            result = true;
        }
    }
    
    if (result) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mkp make_pair
  #define pb push_back
  #define inf INT_MAX
  void pairsort(int a[], int b[], int n)
  {
      pair<int, int> pairt[n];
      for (int i = 0; i < n; i++) 
      {
          pairt[i].first = a[i];
          pairt[i].second = b[i];
      }
      sort(pairt, pairt + n);
      for (int i = 0; i < n; i++) 
      {
          a[i] = pairt[i].first;
          b[i] = pairt[i].second;
      }
  }
   int binomialCoeff(int n, int k) 
  { 
       int res = 1; 
    
      // Since C(n, k) = C(n, n-k) 
      if ( k > n - k ) 
          k = n - k; 
    
      // Calculate value of [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1] 
      for (int i = 0; i < k; ++i) 
      { 
          res *= (n - i); 
          res /= (i + 1); 
      } 
    
      return res; 
  } 
  void printVector(vector<ll> v) {
    for(int i=0;i<v.size();i++)
      {
        cout << v[i];
      }
 
    }
  int divisor(int num)
  { int div=0;
    for (int i = 1; i <= num; i++)
    {
      /* code */
      if(num%i==0)
        div++;
    }
      return div;
    
  }
  int sub(int a, int b)
  {
    if(a>=b)
      return a-b;
    else
      return b-a;
 
  }
  int32_t main()
  { 
    IOS
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    int arr[n][3];
    for(int i=0;i<n;i++)
    {
      cin>>arr[i][0]>>arr[i][1]>>arr[i][2] ;   }
    a[0] = arr[0][0];
   	b[0] = arr[0][1];
	  c[0] = arr[0][2];
    for(int i=1;i<n;i++)
    {
      a[i]=max(b[i-1],c[i-1]);
      a[i]+=arr[i][0];
      b[i]=max(a[i-1],c[i-1]);
      b[i]+=arr[i][1];
      c[i]=max(a[i-1],b[i-1]);
      c[i]+=arr[i][2];
      
      
    }
    int maxi=max(a[n-1],b[n-1]);
      int maxans=max(maxi,c[n-1]);
      cout<<maxans;
    return 0;
  }

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

int main(void) {
    string s;
    cin >> s;

    vector<char> ans;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == '0') ans.emplace_back('0');
        else if (s[i] == '1') ans.emplace_back('1');
        else if (!ans.empty()) ans.pop_back();
    }

    for (auto x : ans) cout << x;
    cout << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void){
    int a, b, x[10];
    cin >> a >> b;
    int ans = 0;
    for (int i = a; i <= b; i++) {
        int k = i;
        for (int j = 0; j < 5; j++) {
            x[j] = k % 10;
            k /= 10;
        }
        if (x[0] == x[4] && x[1] == x[3]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)if(i*(m-j)+j*(n-i)==k){cout<<"Yes"<<endl;return 0;}
    cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int n;
    int sum=0;
    cin>>n;
    int a[2][n];
   
    
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){cin>>a[i][j];}
    }
    sum+=a[0][0];
    for(int i=0;i<n;i++){sum+=a[1][i];}
   // cout<<sum<<endl;
    int ans=sum;
    for(int i=0;i<n-1;i++){
        
        int k=sum-a[1][i];
        ans=max(ans,(k+a[0][i+1]));
        sum-=a[1][i];
        sum+=a[0][i+1];
    }
    cout<<ans<<endl;
   
    
}


Measured memory_bytes: 256
int main()
{
    int th, ts, ah, as;
    scanf("%d %d %d %d", &th, &ts, &ah, &as);
    
    int count = 1;
    while(th > 0 && ah > 0){
        if(count % 2 == 1)
            ah = ah - ts;
        else
            th = th - as;
        count ++;
    }
    if(th <= 0)
        printf("No\n");
        
    else
        printf("Yes\n");
}

Measured memory_bytes: 2112
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, now = 0, ans = 0;
    char c;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> c;
        now += (c - 'F') / 2;
        ans = max(ans, now);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define wi(x) cerr << #x << " is " << x << endl;

void solve(){
	int a,b; cin>>a>>b;
	cout << a*b;
}

int main(){
	fastio()
	
	int T=1;
	while(T--)solve();

	return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define ll long long


int main(void){
	int h,w;
	scanf("%d%d",&h,&w);
	char A[h][w+1];
	for(int i=0;i<h;i++)scanf("%s",&A[i]);
	
	int n=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
			if(A[i][j]=='#')n++;
	
	if(n==h+w-1)	printf("Possible");
	else printf("Impossible");
	return 0;
}

Measured memory_bytes: 128
s, t = map(int, input().split())
u = [list(map(int, input().split())) for _ in range(t)]
ln = ['a'] * s
x = 0
for i in range(t):
    if ln[u[i][0] - 1] == 'a':
        ln[u[i][0] - 1] = u[i][1]
    if ln[u[i][0] - 1] != 'a' and ln[u[i][0] - 1] != u[i][1]:
        x += 1
if s == 1 and ln[0] == 0:
    print(0)
elif s == 1 and t == 0:
    print(0)
elif x >= 1:
    print(-1)
elif ln[0] == 0:
    print(-1)
else:
    if ln[0] == 'a':
        ln[0] = 1
    ln = [str(a) for a in ln]
    ln = ''.join(ln)
    print(ln.replace('a', '0'))

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

void get_lcs(string s, string t)
{
    int N = s.length();
    int M = t.length();
    int dp[N+1][M+1];
    int ptr[N+1][M+1];
    for(int i=0; i<=N; i++){
	    dp[i][0] = 0;
    }
    for(int j = 0; j<=M; j++){
	    dp[0][j] = 0;
	    ptr[0][j] = -1;
    }
    for(int i=1; i<=N; i++){
	    for(int j=1; j<=M; j++){
		    if(s[i-1] == t[j-1]){
			    dp[i][j] = 1+dp[i-1][j-1];
	            }
		    else{
				    dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
	            }
	    }
    }

    string res="";
    int i=N, j=M;
    while(1){
	    if(i==0 or j==0)
		    break;
	    if(s[i-1] == t[j-1]){
		    res += s[i-1];
		    //cout << i << "; " << s[i-1] << endl;
		    i -= 1;
		    j -= 1;
	    }
	    else if(dp[i][j-1] > dp[i-1][j])
		    j -= 1;
	    else
		    i -= 1;
	    //cout << res << endl;

    }
    /*for(i=0; i<=N; i++){
	    for(j=0; j<=M; j++){
		    cout << dp[i][j] << " ";
            }
            cout << endl;
    }*/
   
    reverse(res.begin(), res.end());
    cout << res << endl;
}

int main()
{
    string s, t;
    cin >> s;
    cin >> t;

    get_lcs(s, t);
    return 0;
}


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

int main(){
	int a, b;
	int ans = 0;
	cin >> a >> b;
	if(a > b) ans = 2*a - 1;
	else if(a == b) ans = 2*a;
	else ans = 2*b - 1;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int a, b, x;
  cin >> a >> b >> x;
  if(x < a || a + b < x){
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

vector<long long> divisor(long long n) {
    vector<long long> res;
    for (long long i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    // if sort is required
    sort(res.begin(), res.end());
    return res;
}


void Main() {
	ll N; cin >> N;
	ll res = numeric_limits<ll>::max();
	auto d = divisor(N);
	for (ll num : d) {
		ll other = N / num;
		res = min(res, num + other - 2);
	}
	cout << res << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

using namespace std;

#define long long long
#define INF ((long) 1e18)
#define mOD 1000000007
#define mll map<long, long>
#define pll pair<long, long>
#define umap unordered_map
#define umll umap<long, long>
#define uset unordered_set
#define pb push_back
#define FOR(i, a, b) \
  for (long i = (a); i < (long) (b); i++)
#define PRINTV(v) \
  FOR (_i, 0, v.size()) \
    cout << v[_i] << " "; \
  cout << "\n";

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

  long a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  long total = 0;
  while (x > 0 and y > 0) {
    if (2*c < a + b) {
      total += 2*c;
    } else {
      total += a + b;
    }
    x--;
    y--;
  }
  while (x > 0) {
    if (2*c < a) {
      total += 2*c;
    } else {
      total += a;
    }
    x--;
  }
  while (y > 0) {
    if (2*c < b) {
      total += 2*c;
    } else {
      total += b;
    }
    y--;
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

int main(){
  int n;
  cin >> n;
  vector <long long> a;
  for(int i = 0; i < n; i++){
    long long num;
    cin >> num;
    a.push_back(num);
  }

  vector <long long> table(n);
  for(int i = 0; i < n; i++){
    table.at(i) = INF;
  }
  for(int i = 0; i < n; i++){
    if(i == 0){
      table.at(i) = 0;
    }else if(i == 1){
      table.at(i) = abs(a.at(i) - a.at(i-1));
    }else{
      if(table.at(i-2) + abs(a.at(i-2) - a.at(i)) > table.at(i-1) + abs(a.at(i-1)- a.at(i))){
        table.at(i) = table.at(i-1) + abs(a.at(i-1)- a.at(i));
      }else{
        table.at(i) = table.at(i-2) + abs(a.at(i-2)- a.at(i));
      }
    }
  }

  cout << table.at(n-1) << endl;
}


Measured memory_bytes: 5008
#include<stdio.h>
int main(void){
    long long n,res1,res2;
    scanf("%lld",&n);
    res1=1;
    res2=n;
    for(long long i=1;i<n;i++){
        if(n<i*i)break;
        if((n%i==0)&&((res1+res2)>(i+n/i))){
            res1=i;
            res2=n/i;
        }
    }
    printf("%lld\n",res1+res2-2);
    return 0;
}
    


Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#define INF 30000000000000

using namespace std;

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


int n,m;
vector<PP> e;
ll d[1050];

bool bellman_ford(int s)
{
	fill(d,d+n,INF);
	d[s]=0;
	for(int k=0;k<n;k++){
		//bool update=false;
		for(int i=0;i<m;i++){
			int from=e[i].first.first;
			int to=e[i].first.second;
			ll cost=e[i].second;
			if(d[from]!=INF&&d[to]>d[from]+cost){
				d[to]=d[from]+cost;
				//update=true;
				if(k==n-1&&to==n-1)return true;
			}
		}
	}
	return false;
}

/*
bool find_negative_loop()
{
	fill(d,d+n,0);
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int from=e[j].first.first;
			int to=e[j].first.second;
			ll cost=e[j].second;
		
			if(d[to]>d[from]+cost){
				d[to]=d[from]+cost;
				if(i==n-1)return true;
			}
		}
	}
	return false;
}
*/

int main()
{
	cin>>n>>m;
	int a,b;
	ll c;
	for(int i=0;i<m;i++){
		cin>>a>>b>>c;
		a--; b--; c*=-1;
		e.push_back(PP(P(a,b),c));
	}
	if(bellman_ford(0)){
		cout<<"inf"<<endl;
		return 0;
	}
	bellman_ford(0);
	cout<<d[n-1]*(-1)<<endl;

	return 0;	
}

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

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

		int[] ai = { 0, 4, 6, 8 };
		for (int i: ai)
			if (i < sb.length() && sb.charAt(i) != 'A' || i == sb.length())
				sb.insert(i, "A");
		System.out.println(sb.toString().equals("AKIHABARA") ? "YES" : "NO");
	}
}


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

int main(){
  int T,P,R,ttid,tpid,ttime,t;
  int solved[50];
  int wrong[50][10];
  int tpenum[50];
  int rk[50];
  char buf[10];
  while(1){
    for (int i=0;i<50;i++){
      solved[i]=0;
      tpenum[i]=0;
      rk[i]=i;
      for (int j=0;j<10;j++) wrong[i][j]=0;
    }
    
    cin >> T >> P >> R;

    if (T==0&&P==0&&R==0) break;

    for (int i=0;i<R;i++){
      cin >> ttid >> tpid >> ttime >> buf;
      ttid--;
      tpid--;
      if (buf[0]=='C'){
	solved[ttid]++;
	tpenum[ttid]+=wrong[ttid][tpid]*1200+ttime;
      }else{
	wrong[ttid][tpid]++;
      }
    }

    // for (int i=0;i<T;i++){
    //  for (int j=0;j<P;j++){
    //	tpenum[i]+=penum[i][j];
    //    }
    // }
    for (int i=0;i<T;i++){
      for (int j=T-1;j>i;j--){
	//	cout << j << rk[j]<< rk[j-1]<<solved[rk[j]]<<solved[rk[j-1]] <<endl;
	if (solved[rk[j]]>solved[rk[j-1]]){
	  // cout << "c" <<endl;
	  t=rk[j];
	  rk[j]=rk[j-1];
	  rk[j-1]=t;
	}else if (solved[rk[j]]==solved[rk[j-1]]){
	  if (tpenum[rk[j]]<tpenum[rk[j-1]]){
	    t=rk[j];
	    rk[j]=rk[j-1];
	    rk[j-1]=t;
	  }
	}
      }
    }

    for (int i=0;i<T;i++)cout << rk[i]+1 << " " << solved[rk[i]] << " " << tpenum[rk[i]] << endl;

  }
  return 0;
} 


	   

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

using namespace std;

const int N = 4e6 + 5;

typedef long long ll;

const ll mod = 1e9 + 7;

int n, k, g, a, mx;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a;
        g = __gcd(a, g);
        mx = max(mx, a);
    }
    if (k % g == 0 && k <= mx)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
}


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

using namespace std;
int main()
{
  int n;
  cin >> n ;
  int d[n];
  for(int i=0;i<n;i++) cin >> d[i] ;
  sort(d, d+n);
  
  int ind = n/2;
  int ans = d[ind]-d[ind-1];
   cout << ans << endl;
  
}


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

using namespace std;

long long knapsack_helper(int c, int idx, const vector<int>&w, const vector<int>& v, vector<vector<long long>>& cache)
{
	if (c < 0)
		return 0;
	if(c == 0 || idx < 0) {
		return 0;
	}
	if(cache[c][idx] != - 1)
		return cache[c][idx];
	if (c < w[idx]) {
		cache[c][idx] = knapsack_helper(c, idx - 1, w, v, cache);
		return cache[c][idx];
	}
	long long skip = knapsack_helper(c, idx - 1, w, v, cache);
	long long take = v[idx] + knapsack_helper(c - w[idx], idx - 1, w, v, cache);
	long long  res = max(skip,take);
	cache[c][idx] = res;
	return res;
}


long long knapsack_rec(int cap, const vector<int>& w, const vector<int>& v)
{
	vector<vector<long long>> cache(cap + 1, vector<long long>(w.size() + 1, -1));
	return knapsack_helper(cap, (int)w.size() - 1, w, v, cache);
}

int main()
{
	int N, cap;
	cin >> N >> cap;
	vector <int> weights(N);
	vector <int> values(N);
	for(int i = 0; i < N ; i++) {
		cin >> weights[i] >> values[i];
	}
	//cout << knapsack(cap, weigths, values) << endl;
	cout << knapsack_rec(cap, weights, values) << endl;
	return 0;
}


Measured memory_bytes: 82304
import numpy as np
n = int(input())
a_ls = list(map(int, input().split()))
diff_ls = [a - i for i, a in enumerate(a_ls,1)]
diff_ls.sort()
med = int(np.median(diff_ls))
ans = 0
for diff in diff_ls:
    ans += abs(diff - med)
print(ans)

Measured memory_bytes: 34224
import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		double N = sc.nextDouble(); int t = 0;
		for (double i=1; i<N; i++) {
	 		int C = (int) Math.floor((N-1)/i);
			if (C>0) t+=C;
		}
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 37420
import scala.util.control.Breaks
import Math._
object Main extends App {
  val b = new Breaks
  b.breakable {
    while (true) {
      val n = readLine.toInt

      if (n == 0) b.break()

      val s = readLine.split(' ').map(_.toDouble)

      val m = s.sum / s.length
      val a = s.map(t => (t-m)*(t-m)).sum / s.length
      println(sqrt(a))
    }
  }
}


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

int main() {
	int N;
	cin >> N;
	vector<int> h(N),dp(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> h.at(i);
	}
	dp.at(0) = 0;
	dp.at(1) = abs(h.at(1) - h.at(0));
	for (size_t i = 2; i < N; i++)
	{
		dp.at(i) = min(abs(h.at(i - 2) - h.at(i)) + dp.at(i - 2), abs(h.at(i - 1) - h.at(i)) + dp.at(i - 1));
	}
	cout << dp.at(N-1);
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
using namespace std;

typedef long long ll;
/*
typedef struct Name   Name;
struct Name {
    int a[3];
};
*/
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) for (int i = 0; i < (a); i++)
int main()
{
    int sum = 0;
    for(int i = 0; i < 5; i++)
    {
        int a;
        cin >> a;
        sum += a;
    }

    cout << 15-sum << "\n";
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
char a[100005],b[100005];
int n,m;
int main(){
	scanf("%s",a+1);
	scanf("%s",b+1);
	n=strlen(a+1);
	m=strlen(b+1);
	int i=1,j=1;
	while(i<=n||j<=m){
		if(i<=n){
			printf("%c",a[i]);
			i++;
		}
		if(j<=m){
			printf("%c",b[j]);
			j++;
		}
	}
	return 0;
}

Measured memory_bytes: 888
#pragma GCC optimize (3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, k;
int p[maxn];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) cin >> p[i];
	double s = 0, ans = 0;
	for(int i = 1; i <= n; ++i) {
		s += 0.5 * (double)(1 + p[i]);
		if(i < k) continue;
		ans = max(s, ans);
		s -= 0.5 * (double)(1 + p[i - k + 1]);
	}
	cout << setprecision(8) << fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
def factorization(n):
    if n == 1:
        return []

    arr = []
    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
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())

pes = factorization(N)

ans = 0
for p, e in pes:
    i = 1
    t = 1

    while t <= e:
        i += 1
        t += i

    ans += i - 1

print(ans)



Measured memory_bytes: 9484
#include<bits/stdc++.h>
using namespace std;
int a[20009],b[20009];

int main(){
  int n;
  int p[20009];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i];
  }

  for(int i=1;i<=n;i++){
    a[p[i]]+=i;
    b[p[i]]+=i;
  }
  for(int i=1;i<=n;i++){
    a[i]+=a[i-1];
  }
  for(int i=n;i>=1;i--){
    b[i]+=b[i+1];
  }

  for(int i=1;i<=n;i++){
    cout<<a[i]+i;
    if(i==n)cout<<endl;
    else cout<<' ';
  }
  for(int i=1;i<=n;i++){
    cout<<b[i]+n-i+1;
    if(i==n)cout<<endl;
    else cout<<' ';
  }

  return(0);
}


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

int main() {
  int n, l;
  cin >> n >> l;

  int ori = 0;
  for (int k = 0; k < n; k++) {
    ori += (k + l);
  }

  int min = ori - l;
  for (int k = 0; k < n; k++) {
    int diff = ori - (k + l);
    if (abs(ori - diff) < abs(ori - min)) { min = diff; }
  }
  cout << min << endl;
}

Measured memory_bytes: 256
num=int(input())
if len(str(num)) %2 != 0:
  if len(str(num))==7:
    print(num-999999+90000+900+9)
  elif len(str(num))==5:
    print(num-9999+900+9)
  elif len(str(num))==3:
    print(num-99+9)
  elif len(str(num))==1:
    print(num)
else:
  if len(str(num))==8:
    print(9000000+90000+900+9)
  elif len(str(num))==6:
    print(90000+900+9)
  elif len(str(num))==4:
    print(900+9)
  elif len(str(num))==2:
    print(9)


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

#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 2e5 + 123;
int n, rem[N], cnt[3000], pw[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	string s;
	cin >> s;
	n = s.size();
	
	pw[0] = 1;
	for (int i = 1; i <= n; i++) {
		pw[i] = pw[i - 1] * 10 % 2019;
	}
	ll ans = 0;
	cnt[0]++;
	for (int i = n; i >= 1; i--) {
		rem[i] = (rem[i + 1] + (s[i - 1] - '0') * pw[n - i]) % 2019;
		ans += cnt[rem[i]];
		cnt[rem[i]]++;
	}
	cout << ans;
}


Measured memory_bytes: 5320
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

string s;
int a[26];
bool haji = false;
int cho = 0;

int main() {
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		a[s[i] - 'a']++;
	}
	haji = s[0] == s[s.size() - 1];
	for (int i = 0; i < 26; i++) {
		cho += a[i] / 2;
	}

	if (haji) {
		if (s.size() % 2 == 0)
			cout << "First" << endl;
		else
			cout << "Second" << endl;
	}
	else {
		if (s.size() % 2 == 1)
			cout << "First" << endl;
		else
			cout << "Second" << endl;
	}
//	cin >> s;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int n;
vector<vector<pii>> edges;
vector<int> colors;

void dfs(int u, int p, int lc){
    int color = 1;
    for(auto it : edges[u]){
        if (it.first != p){
            if (color == lc)
                color++;
            colors[it.second] = color;
            dfs(it.first, u, color);
            color++;
        }
    }
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    cin >> n;
    edges.resize(n+1);
    colors.resize(n+1);
    FOR1(i, n-1){
        int u, v;
        cin >> u >> v;
        edges[u].push_back(make_pair(v, i));
        edges[v].push_back(make_pair(u, i));
    }


    dfs(1, -1, -1);
    int k = 0;
    FOR1(i, n-1)
        k = max(k, colors[i]);
    cout << k << endl;
    FOR1(i, n-1)
        cout << colors[i] << endl;

    //if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

Measured memory_bytes: 8320
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
#define endl '\n'
#define MAX 100002
#define pii pair<int, int>
#define pll pair<long long, long long>
 
typedef vector<int> vec;
typedef long long int ll;
typedef unsigned long long ull;

int main(){
    fast_cin();
    ll n, k;cin>>n>>k;
    ll ans=0;
    for(ll i=k;i<=n+1;i++){
        ll mi=(i*(i-1))/2;
        ll ma=i*n-(i*(i-1))/2;
        ans+=(ma-mi+1);
    }
    cout<<ans%MOD<<endl;
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"

#define ll long long

using namespace std;

ll n, m, res = 0;
int main(){
    cin >> n >> m;
    if(n > 2 && m > 2){
        cout << n * m - 2 * (m - 2) - 2 * (n - 2) - 4;
    }
    else if(n == 1 && m == 1){
        cout << 1;
    }
    else if(n == 1 || m == 1){
        cout << max(max(n, m) - 2, 0LL);
    }
    else if(n == 2 || m == 2){
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    S = input()
    idx = [0, 4, 6, 8]
    A = "AKIHABARA"
    patterns = set()
    patterns.add(A)
    for i in range(2**4):
        pattern =  list(A)
        for j, bit in enumerate(format(i, "04b")):
            if bit == "1":
                pattern[idx[j]] = ""
                patterns.add("".join(pattern))

    if S in patterns:
        print("YES")
    else:
        print("NO")


main()

Measured memory_bytes: 3064
# まず取り出しきっちゃってから捨てる
# 左右からいくつずつ取り出すか

N,K = map(int,input().split())
V = [int(x) for x in input().split()]

max_value = 0 # 何もとらない

for L in range(N+1):
  for R in range(N+1):
    if L+R > K:
      break
    if L+R > N:
      break
    #get = V[:L] + V[-R:]
    get = V[:L]
    if R > 0:
      get += V[-R:]
    get.sort()
    rest = K - (L+R)
    minus = sum((1 if x < 0 else 0 for x in get))
    if minus > rest:
      value = sum(get[rest:])
    else:
      value = sum((x for x in get if x > 0))
    if value > max_value:
      max_value = value
    #print(L,R,rest,get,value)
      
      
   
print(max_value)
    


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int H = sc.nextInt();
		int W = sc.nextInt();
		int A = 0, B = 0;
		int count = 0;
		for (int i = 0; i < N; i++) {

			A = sc.nextInt();
			B = sc.nextInt();

			if (H <= A) {
				if (W <= B) {
					++count;
				}
			}
		}

		System.out.println(count);

	}

}


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

const int MAXN = 3000; //dummy
const ll MOD = 1e9 + 7;

int n;
double dp[MAXN][MAXN];
double ans = 0;
vector<double> p(MAXN);

double rec(int id, int head){
	//cout << id << " " << head << '\n';
	if(id == n){
		if( head > n - head){
			return 1.0;
		} else {
			return 0.0;
		}
	}

	double &res = dp[id][head];
	if( res != -1)
		return res;
	
	res = rec(id + 1, head + 1)*p[id] + rec(id + 1, head)*(1 - p[id]); 
	//cout << res << '\n';
	return res;
}

void solve(){
	for(int i = 0; i < MAXN; ++i){
		for(int j = 0;j <MAXN; ++j){
			dp[i][j] = -1;      
		}
	}
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> p[i];
	}	
	double ans = rec(0, 0);
	cout << fixed << setprecision(10) << ans << '\n';
}


int main(){
	ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}


Measured memory_bytes: 70784
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin>>a;
    cin>>b;
    cin>>c;
    if(a-b==0)
        cout<<c<<endl;
    else if(a-c==0)
        cout<<b<<endl;
           else  cout<<a<<endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	int A, B;	cin >> A >> B;
	if(A >= 13)
	 	SCOUT(B) << endl;
	else if(A >= 6)
	 	SCOUT(B / 2) << endl;
	else
	 	SCOUT(0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <map>
#include <algorithm>
#include <random>
#include <complex>
#include <unordered_map>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <bitset>

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

const int MN = 501*1000*1000;

ll gcd(ll a, ll b) {
    if (!a) return b;
    return gcd(b%a, a);
}
ll ext_gcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if (b) {
        d = ext_gcd(b, a%b, y, x);
        y -= a / b*x;
    } else {
        x = 1;
        y = 0;
    }
    return d;
}

int w, d, n, m, t, u, h;
int x;
void init() {
    m = t-m%t;
    u = gcd(t, w+d), h = gcd(t, m);
    ll xx, y;
    ext_gcd(m, t, xx, y);
    x = ((xx % t) + t) % t;
}
int solve() {
    init();

    int res = 0;
    int l = 0;

    int s = 0;
    int th = t/h;
    for (int i = 0; i < t; i += h) {
        if (s<n) {
            res += max(0, (i-l - w + u) / u);
            l = (i/u+1)*u;
        }
        s += x; s %= th;
    }
    res += max(0, (t-l-w+u)/u);
    return res;
}

int main() {
    cin >> w >> d >> n >> m >> t; w++; d--;
    printf("%.20f\n", 1.0 * solve() / (t / u));
    return 0;
}

Measured memory_bytes: 1172
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

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

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

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

	vvi v(n, vi(n, -1));
	int m = 2 * n * n - 2 * n;
	vi a(m), b(m);
	vvi cnt(n * n);
	REP(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		cnt[a[i]].push_back(b[i]);
		cnt[b[i]].push_back(a[i]);
	}
	vi used(m, 0);
	REP(i, n)REP(j, n) {
		int c = 2;
		if (i % (n - 1) != 0)c++;
		if (j % (n - 1) != 0)c++;
		REP(k, n * n) {
			if (cnt[k].size() != c || used[k] == 1)continue;
			bool ok = true;
			if (i > 0)if (find(ALL(cnt[k]), v[i - 1][j]) == cnt[k].end())ok = false;
			if (j > 0)if (find(ALL(cnt[k]), v[i][j - 1]) == cnt[k].end())ok = false;
			if (ok) {
				used[k] = 1;
				v[i][j] = k;
				break;
			}
		}
	}
	REP(i, n)REP(j, n) {
		cout << v[i][j] + 1 << " \n"[j == n - 1];
	}
}


Measured memory_bytes: 3668
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
typedef long long LL;
using namespace std;
const int Maxn = 1e6;
int main()
{
	int a , b;
	while( cin >> a >> b ){
		if( a + b > 16 || a > 8 || b > 8 )
			cout << ":(" << endl;
		else	cout << "Yay!" << endl;
	}
}

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

int main() {
  int N, L;
  cin >> N >> L;
  int sum = 0;
  for(int i = 0; i < N; i++) sum += L + i;
  if(L >= 0) cout << sum -L << endl;
  else if(L + N > 0) cout << sum << endl;
  else cout << sum - (L + N - 1) << endl;
}

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

#define int long long

const int N = 10;
int n, k, mark[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	memset(mark, 1, sizeof mark);
	
	cin >> n >> k;
	for (int i = 0, x; i < k; i++)
		cin >> x, mark[x] = 0;
	
	int tmp = n;
	vector <int> vec;
	while (tmp) {
		vec.push_back(tmp % 10);
		tmp /= 10;
	}
	reverse(vec.begin(), vec.end());
	
	bool check = 0;
	int ans = 0;
	for (int i : vec) {
		if (check) {
			for (int j = 0; j < 10; j++)
				if (mark[j]) {
					ans = 10 * ans + j;
					break;
				}
			continue;
		}
		
		if (mark[i]) {
			ans = 10 * ans + i;
			continue;
		}
		
		bool ok = 0;
		for (int j = i; j < 10; j++)
			if (mark[j]) {
				ans = 10 * ans + j;
				check = 1;
				ok = 1;
				break;
			}
		if (ok)
			continue;
		
		for (int i = 1; i < 10; i++)
			if (mark[i]) {
				ans = i;
				break;
			}
		for (int j = 0; j < vec.size(); j++)
			for (int x = 0; x < 10; x++)
				if (mark[x]) {
					ans = 10 * ans + x;
					break;
				}
		break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main(void)
{
	int n,i,j,k;
	int a[1000],b[1000],c[1000];
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			for(k=0;k<n;k++) {
				if(a[i]>b[i])swap(a[i],b[i]);
				if(b[i]>c[i])swap(b[i],c[i]);
				if(a[i]>c[i])swap(a[i],c[i]);
			}
		}
	}
	string ss[1000];
	for(i=0;i<n;i++) {
		ss[i]=a[i]+'0';
		ss[i]+=b[i]+'0';
		ss[i]+=c[i]+'0';
	}
	int cnt=0,flg[1000]={0};
	for(i=0;i<n-1;i++) {
		if(flg[i]==0) {
			for(j=i+1;j<n;j++) {
				if(ss[i]==ss[j]&&flg[j]==0) cnt++,flg[j]=1;
			}
		}
	}
	cout<<cnt<<endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y =  sc.nextInt();
        int sum;
        int A = 15;

        if((X + Y) == A ){
            System.out.println("+");
        } else if((X * Y) == A ){
            System.out.println("*");
        } else{
            System.out.println("x");
        }
    }
}


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

const int Nmax = 100010;
int N, H;
int a[Nmax], b[Nmax];

int main() {
	cin >> N >> H;
	for (int i = 0; i < N; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + N);
	sort(b, b + N);
	int Amax = a[N - 1];
	int ans = 0;
	int i = N - 1;
	while (H > 0) {
		if (b[i] > Amax) {
			H -= b[i];
			i--;
			ans++;
		}
		else {
			if (H%Amax == 0) ans += H / Amax;
			else ans += H / Amax + 1;
			break;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
#define PI 3.14159265359
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-------------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	int flg=1;
	for(i=1;i<=n;i++){
		if(ar[i]%2==0){
			if(ar[i]%3!=0&&ar[i]%5!=0){
				flg=0;
				break;
			}
		}
	}
	if(flg) cout<<"APPROVED";
	else cout<<"DENIED";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
  
int main()
{
        int H, W, i, j;
        while (1) {
                scanf("%d %d", &H, &W);
                if (H==0 && W==0) break;
                for (i=0; i<H; i++) {
                        for (j=0; j<W; j++) {
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}


Measured memory_bytes: 1964
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> jb[n];
  while(1){
    int s,t,e;
    cin>>s>>t>>e;
    if(s==0 && t==0 && e==0) break;
    jb[s-1].push_back(make_pair(t-1,e));
  }
  int l;
  cin>>l;
  int b[m];
  rep(i,l){
    rep(j,m){
      cin>>b[j];
    }
    int money[n]={0};
    rep(j,n){
      rep(k,jb[j].size() ){
	money[j]+=jb[j][k].scd*b[jb[j][k].fst];
      }
      cout<<money[j];
      if(j!=n-1) cout<<" ";
    }
    cout<<endl;
  }
    
  

  return 0;
}



Measured memory_bytes: 4644
a = int(input()) #500円玉の枚数
b = int(input()) #100円玉の枚数
c = int(input()) #50円玉の枚数
x = int(input()) #目標金額
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500 + j*100 + k*50 == x:
                count+=1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#define REP(i,n) for(int i = 0;i<(n);i++)

using namespace std;
const int N = 300000;
int p[N+1];
void e() {
  fill(p,p+N,1);
  p[0]=p[1]=0;
  for(int i=2;i*i<=N;i++)
    if(p[i])for(int j=i*i;j<=N;j+=i)p[j]=0;
}
int main() {
  int n;
  e();
  REP(i,N)p[i+1] += p[i];
  while (cin >> n, n) {
    cout << p[2*n] - p[n] << endl;
  }
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

ll gcd(ll a, ll b) { //gcdを返す
	if(a == 0){
		return b;
	} else if (b == 0){
		return a;
	} else {
	  if(a < b) return gcd(b, a);
	  ll r;
	  while ((r=a%b)) {
	    a = b;
	    b = r;
	  }
	  return b;
	}
}
ll ketasum(ll n) { //桁の数字全ての和を返す 例: 112 -> 4
	ll sum=0;
	if (n<0) return 0;
	while (n>0) {
		sum += n%10;
		n /= 10;
	}
	return sum;
}

typedef pair<ll, ll> pair_t;

bool comp(const pair_t &a, const pair_t &b) {
        return a.first < b.first;
}

void sort2vectors(vector<ll> &av, vector<ll> &bv)
{ // ふたつの配列をまとめてそーと A[2,1] B[3,4] -> 1,4 2,3
        ll n = av.size();
        vector<pair_t> p(n);
        vector<ll> av2(n), bv2(n);
        for (ll i = 0; i < n; i++)
                p[i] = make_pair(av[i], bv[i]);
        sort(p.begin(), p.end(), comp);
        for (ll i = 0; i < n; i++) {
                av2[i] = p[i].first;
                bv2[i] = p[i].second;
        }
        av = av2;
        bv = bv2;
}

int main(){
	ll N, A, B;
	cin >> N >> A >> B;
	 if((B - A) % 2 == 0){
	 	cout << "Alice" << endl;
	 } else {
	 	cout << "Borys" << endl;
	 }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MOD(a) ((a)<0?((-1)*(a)):(a))

int main()
{
    long long x,k,d;
    scanf("%lld %lld %lld",&x,&k,&d);
    x=MOD(x);
    long long dif=k-x/d;
    long long dif1=x-k*d;
    double check=(((1.0)*x)/k)-((1.0)*d);
    if(check>=0)
        printf("%lld\n",dif1);
    else if(dif%2==0)
        printf("%lld\n",x%d);
    else if(dif%2==1)
        printf("%lld\n",d-(x%d));
}

Measured memory_bytes: 1728
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) = IO().exec {
    val n = long()
    val q = int()
    for (i in 0 until q) {
        var v = long()-1
        var w = long()-1
        if (n == 1L) {
            v = Math.min(v, w)
        } else while (v != w) {
            if (v > w) v = w.apply { w = v }
            w = (w - 1) / n
        }
        println(v + 1)
    }
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 38016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

struct edge{int to;ll cost;};
const int VMAX = 1e5+10;
const int MMAX = 1e5+10;
const ll INF = 1e15;
vector<vector<edge> > G(VMAX);
vector<ll> d(VMAX,INF);
int V,M;

void dijkstra(int s){
  priority_queue<PLI, vector<PLI>, greater<PLI> > pque;
  d[s] = 0;
  pque.push(PLI(0,s));
  while(!pque.empty()){
    PLI p = pque.top();pque.pop();
    int v = p.second;
    if(d[v] < p.first)continue;
    for(const edge& e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        pque.push(PLI(d[e.to],e.to));
      }
    }
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> M;
  rep(i,M){
    int f,t;
    ll c;cin >> f >> t >> c;
    G[f].push_back({t,c});
  }
  rep(i,V-1){
    G[i+1].push_back({i,0});
  }
  dijkstra(1);
  if(d[V] == INF)cout << -1 << endl;
  else cout << d[V] << endl;
  return 0;
}


Measured memory_bytes: 9464
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,D,X;
  cin >> N >> D >> X;
  int A[N];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans += (D + A[i] - 1) / A[i];
  }
  cout << ans + X << endl;
  return 0;
}

Measured memory_bytes: 256