akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;

int main() {
  string s;
  int k;
  cin >> s >> k;
  for (int i = 0; i < s.size(); ++i) if (s[i] != 'a' && k > 'z' - s[i]) {
    k -= 1 + ('z' - s[i]);
    s[i] = 'a';
  }
  if (k) {
    int r = s[s.size() - 1] - 'a';
    r = (r + k) % 26;
    s[s.size() - 1] = 'a' + r;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
  int i,sum=0;
string s;
  cin>>s;
  for(i=0;i<s.length();i++)
  {
    sum+=s[i]-'0';
  }
  if(sum%9==0)
  {cout<<"Yes";}
  else{cout<<"No";}
  return 0;
}

Measured memory_bytes: 3368
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
N = int(input())
A = list(map(int,input().split()))
ans = 0

lcm = lcm_list(A)

for i in range(N):
  ans += lcm//A[i]

print(ans%1000000007)

Measured memory_bytes: 10324
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int A[5];
    REP(i, 5) cin >> A[i];
    int min_d = 10, sum = 0;
    REP(i, 5) {
        if (A[i] % 10  > 0) {
            min_d = min(min_d, A[i] % 10);
        }
        sum += (A[i] + 9) / 10 * 10;
    }
    cout << sum + min_d - 10 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef long double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int MOD = (int) (1e9 + 7);
inline void Add(int& x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int& x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

const int N = 25010, K = 410;
int n, k, m, arr[N], dp[N][K], ans, rec[K], val[2][N];
int cal[N][K], jc[N];
int specialmain() {
  dp[0][0] = 1;
  rep (i, 1, n) {
    rep (j, 0, k-1) {
      Add(dp[i][1], dp[i-1][j]);
      Sub(dp[i][j+1], dp[i-1][j]);
      Add(cal[i][1], cal[i-1][j]);
      Sub(cal[i][j+1], cal[i-1][j]);
      // rep (a, 1, j) Add(dp[t][i][a], dp[t][i-1][j]);
    }
    rep (j, 1, k) Add(dp[i][j], dp[i][j-1]), Add(cal[i][j], cal[i][j-1]);
    rep (j, 0, k-1) {
      Add(dp[i][j+1], 1ll * dp[i-1][j] * (k-j) % MOD);
      Add(cal[i][j+1],  1ll * cal[i-1][j] * (k-j) % MOD);
    }
    rep (j, 0, k-1) if (j >= m)
      Add(cal[i][j], dp[i][j]);
  }
  int num = 0;
  rep (j, 0, k-1) Add(num, cal[n][j]);
  jc[0] = 1;
  rep (i, 1, k) jc[i] = 1ll * jc[i-1] * i % MOD;
  num = 1ll * num * power(jc[k], MOD - 2) % MOD * jc[k-m] % MOD;
  Sub(ans, num);
  cout << ans << endl;
  return 0;
}
void doit(int t) {
  int key = 0, v = 0;
  memset(rec, 0, sizeof rec);
  for (int i = 1; i <= m; ++ i) {
    if (!rec[arr[i]]) ++ v;
    else {
      v = i - rec[arr[i]];
      rep (j, 1, k) if (rec[j] <= i - v)
	rec[j] = 0;
    }
    rec[arr[i]] = i;
    if (v == k) key = 1;
  }
  memset(dp, 0, sizeof dp);
  if (!key) dp[0][v] = 1;
  rep (i, 1, n) {
    rep (j, 0, k-1) {
      Add(dp[i][1], dp[i-1][j]);
      Sub(dp[i][j+1], dp[i-1][j]);
      // rep (a, 1, j) Add(dp[t][i][a], dp[t][i-1][j]);
    }
    rep (j, 1, k) Add(dp[i][j], dp[i][j-1]);
    rep (j, 0, k-1)
      Add(dp[i][j+1], 1ll * dp[i-1][j] * (k-j) % MOD);
  }
  rep (i, 0, n) rep (j, 0, k-1)
    Add(val[t][i], dp[i][j]);
}
int main() {
  read(n), read(k), read(m);
  rep (i, 1, m) read(arr[i]);
  rep (i, m, n)
    Add(ans, power(k, n - m));
  int key = 1;
  rep (i, 1, m) {
    if (rec[arr[i]]) key = 0;
    rec[arr[i]] = 1;
  }
  if (key) return specialmain();
  doit(0);
  reverse(arr + 1, arr + m + 1);
  doit(1);
  rep (i, m, n)
    Sub(ans, 1ll * val[0][n-i] * val[1][i-m] % MOD);
  cout << ans << endl;
  return 0;
}


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

int m[53][53];
int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

bool judge(int a,int b)
{
	for(int i=0;i<4;++i)
	{
		if(m[a+dir[i][0]][b+dir[i][1]]==1)
		{
			return false;
		}	
	}	
	return true;
}
int main()
{
	int h,w;
	int flag=0;
	cin>>h>>w;
	for(int i=1;i<=h;++i)
	{
		for(int j=1;j<=w;++j)
		{
			char a;
			cin>>a;
			if(a=='#')
				m[i][j]=1;
		}
	}
	for(int i=1;i<=h;++i)
	{
		for(int j=1;j<=w;++j)
		{
			if(m[i][j]==1&&judge(i,j))
			{
				flag=1;
				break;
			}
		}
	}
	if(flag==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
void swap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
ll compare_asc(const void *a,const void *b){return *(ll*)a-*(ll*)b;}
ll compare_desc(const void *a,const void *b){return *(ll*)b-*(ll*)a;}
/*void qsort(配列のアドレス,サイズ,) */
int main(){
    static ll n,a[200000],ans=0,max=-1;
    int i,j,k;

    scanf("%lld",&n);
    for(i=0;i<n;i++)scanf("%lld",&a[i]);

    qsort(a,n,sizeof(ll),compare_asc);//O(NlogN)
    /*for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
            if(a[i]>a[j])swap(&a[i],&a[j]);
        }
    }
    O(N^2)*/
    int cnt;
    ll tmp=a[0];
    cnt=1;

    for(i=1;i<n;i++){
        if(a[i]!=tmp){
            tmp=a[i];
            if(cnt%2)ans++;
            cnt=1;
        }else{
            cnt++;
        }
    }
    if(cnt%2)ans++;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1788
package main

import (
	"fmt"
	"sort"
)

func main()  {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	num := []int{a, b, c}
	sort.Sort(sort.IntSlice(num))
	fmt.Println(num[0], num[1], num[2])
}


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

using namespace std;

namespace shamal{
	template<typename F, typename IndexType, typename TargetType>
	IndexType lower_bound(F const& func, IndexType left, IndexType right, TargetType const& t){
		while(true){
			auto const mid = left + (right - left) / 2;
			auto const val = func(mid);
			if(val > t){
				right = mid - 1;
			}else if(val < t){
				left = mid + 1;
			}else{
				right = mid;
			}
			if(left == right)
				break;
		}
		return left;
	}
};

int search(vector<int> const& w, int n, int k, int const p){
	int offset = 0;
	int i;
	for(i = 1; i <= n; i++){
		if(w[i] - offset > p && k > 0){
			offset = w[i-1];
			--k;
			--i;
		}
	}

	return (k >= 1) && ((i-1) == n);
}

int main(void)
{
	int n, k;
	cin >> n >> k;
	vector<int> w(n+1, 0);
	for(int i = 1; i <= n; i++){
		int temp;
		cin >> temp;
		w[i] = w[i-1] + temp;
	}
	int l = 1, r = w[n];
	cout
		<< shamal::lower_bound([&](int p){return search(w, n, k, p);}, 1, w[n], 1)
		<< endl;
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void solve(){
    vector<map<int,vector<int>>> v(12);
    int n;
    cin>>n;
    {
        int x,y;
        char u;
        fr(i,n){
            cin>>x>>y>>u;
            switch (u){
                case 'U':
                    v[0][x+y].push_back(y);
                    v[1][x].push_back(y);
                    v[2][x-y].push_back(y);
                    break;
                case 'R':
                    v[3][x-y].push_back(y);
                    v[4][y].push_back(x);
                    v[5][x+y].push_back(y);
                    break;
                case 'D':
                    v[6][x+y].push_back(y);
                    v[7][x].push_back(y);
                    v[8][x-y].push_back(y);
                    break;
                default:
                    v[9][x-y].push_back(y);
                    v[10][y].push_back(x);
                    v[11][x+y].push_back(y);
            }
        }
    }
    int ans=INT_MAX;
    struct K{
        int i,j,k;
    };
    vector<K> vk(6);
    vk[0]=K{0,5,10};
    vk[1]=K{1,7,5};
    vk[2]=K{2,9,10};
    vk[3]=K{3,8,10};
    vk[4]=K{4,10,5};
    vk[5]=K{11,6,10};
    for(auto[i,j,k]:vk){
        for(auto&[z,e]:v[i]){
            if(v[j].find(z)==v[j].end()) continue;
            auto&E=v[j][z];
            sort(E.begin(),E.end());
            for(auto y:e){
                auto it=lower_bound(E.begin(),E.end(),y);
                if(it==E.end()) continue;
                chmin(ans,(*it-y)*k);
            }
        }
    }
    if(ans==INT_MAX) cout<<"SAFE"<<'\n';
    else cout<<ans<<'\n';
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
}

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

int clip(int i){
    return max(0, min(255, i));
}

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

    while(1){
        int n, m;
        cin >> n >> m;

        if(n == 0) break;

        vector<int> c(m);
        rep(i, m) cin >> c[i];

        vector<int> x(n);
        rep(i, n) cin >> x[i];

        const int INF = 1001001001;
        vector<vector<int>> dp(n, vector<int>(256, INF));
        rep(i, m) dp[0][clip(128 + c[i])] = pow(clip(128+c[i])-x[0], 2);

        rep(i, n-1){
            rep(j, 256){
                if(dp[i][j] == INF) continue;
                rep(k, m){
                    dp[i+1][clip(j+c[k])] = min(dp[i+1][clip(j+c[k])], dp[i][j] + (int)pow(clip(j+c[k])-x[i+1], 2));
                }
            }
        }

        int res = INF;
        rep(i, 256) res = min(res, dp[n-1][i]);

        cout << res << "\n";

    }

    return 0;
}


Measured memory_bytes: 23748
#include <iostream>
using namespace std;
int main(void){
    long long int i,n,min,max,sum,input;
    cin >> n;
    cin >> input;
    min = input;
    max = input;
    sum = input;
    
    for (i=2; i<=n; i++)
    {
        cin >> input;
        sum = sum + input;
        
        if (input>max) {max = input;}
        if (input<min) {min = input;}
    }
    
    cout << min << " " << max << " " << sum << endl;
    return 0;
    
}



Measured memory_bytes: 3096
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int ans  = 0;
    String s = sc.nextLine();
    
    for (int i = 0; i < s.length(); i++) {
      if (s.charAt(i) == '+') {
        ans++;
      } else if (s.charAt(i) == '-') {
        ans--;
      }
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 22228
import java.lang.Math;
import java.util.ArrayList;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        while (sn.hasNext()) {
            int a = sn.nextInt();
            int b = sn.nextInt();
            if (a == 0 && b == 0) {
                break;
            }
            System.out.println(String.format("%d %d", Math.min(a, b), Math.max(a, b)));
        }
    }
}

Measured memory_bytes: 33308
import collections

n = int(input())
case = list(input() for _ in range(n))

cn = collections.Counter(case)

print("AC x " + str(cn["AC"]))
print("WA x " + str(cn["WA"]))
print("TLE x " + str(cn["TLE"]))
print("RE x " + str(cn["RE"]))


Measured memory_bytes: 16352
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        if (Math.abs(x - y) <= 1) {
            System.out.println("Brown");
            return;
        }
        System.out.println("Alice");
    }
}


Measured memory_bytes: 23252
#include <iostream>
#include <cmath>
using namespace std;
 
const int MAX=1000;
char Laby[MAX+4][MAX+4];
long long int DP[MAX+4][MAX+4];
 
int NbLig,NbCol;
void LitGraphe()
{
   cin >> NbLig >> NbCol;
   for(int iLig=0;iLig<NbLig;iLig++)
      for(int iCol=0;iCol<NbCol;iCol++)
      {
         DP[iLig][iCol]=0;
         cin >>Laby[iLig][iCol];
      }
}
    long long int modulo=pow(10,9)+7;
int main()
{
   LitGraphe();
   DP[0][0]=1;
   for(int iLig=0;iLig<NbLig;iLig++)
      for(int iCol=0;iCol<NbCol;iCol++)
      {
        if(Laby[iLig][iCol]=='.')
        {
           if(iLig-1>=0&&Laby[iLig-1][iCol]=='.')
              DP[iLig][iCol]+=DP[iLig-1][iCol]%modulo;
           if(iCol-1>=0&&Laby[iLig][iCol-1]=='.')
              DP[iLig][iCol]+=DP[iLig][iCol-1]%modulo;
        }
      }
     
            
 
   cout<< DP[NbLig-1][NbCol-1]%modulo;
}

Measured memory_bytes: 9088
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<iomanip>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#define N 110
#define M 110
double dp[M][N];
double g[M][M];
int n,m;

double shishagonyu2(double x){
  ll a=x*1000;
  a=a/10+(a%10>=5?1:0);
  x=(double)a/100.0;
  return x;
}

int main(){
  //cout<<shishagonyu2(5.5555)<<endl;
  while(cin>>n>>m&&n+m){
    lol(i,n)lol(j,n)cin>>g[i][j];
    lol(i,n)dp[0][i]=1.0;
    lol(i,m)lol(j,n)dp[i+1][j]=0.0;
    lol(i,m){
      lol(j,n){
	lol(k,n){
	  dp[i+1][k]=max(dp[i+1][k],dp[i][j]*g[j][k]);
	}
      }
    }
    double ans=0;
    lol(i,n)ans=max(ans,dp[m-1][i]);
    ans=shishagonyu2(ans);
    cout<<fixed<<setprecision(2)<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3340
'use strict';
const fs = require('fs');
const mod = BigInt(1e9+7);


class ABC041 {
  static A(input) {
    var s, i
    input = input.trim().split('\n');
    [s, i] = input;
    i = parseInt(i, 10);
    console.log(s[i-1]);
  }
  static B(input) {
    var a, b, c;
    input = input.trim().split(' ').map(BigInt);
    [a, b, c] = input;
    var ans = a * b % mod * c % mod;
    ans = Number(ans);
    console.log(ans);
  }
  static C(input) {
    var [n, height] = input.trim().split('\n');
    height = height.split(' ').map(n => parseInt(n, 10));
    n = parseInt(n, 10);
    var height = Object.keys(height).map(key => [parseInt(key, 10)+1, height[key]]);
    height.sort(function(first, second) {
      return (second[1] - first[1]);
    });
    for (var [i, _] of height) {console.log(i);}
  }
  static D(input) {
    var lines = input.trim().split('\n');
    var [n, m] = lines[0].split(' ').map(x => +x);
    var edges = new Array(n).fill(0);
    for (var i = 0; i < m; i++) {
      var [x, y] = lines[1+i].split(' ').map(x => +x);
      edges[x-1] |= 1<<(y-1);
    }
    var comb = new Array(1<<n).fill(null); comb[0] = 1;
    function count(edges, bit) {
      if (comb[bit] != null) {return comb[bit];}
      comb[bit] = 0;
      for (var i = 0; i < n; i++) {
        if (bit>>i&1 && !edges[i]) {
          var nxt_bit = bit & ~(1<<i);
          var nxt_edges = edges.slice();
          for (var j = 0; j < n; j++) {
            nxt_edges[j] &= ~(1<<i);
          }
          comb[bit] += count(nxt_edges, nxt_bit);
        }
      }
      return comb[bit];
    }
    console.log(count(edges, (1<<n)-1));
  }
}

class ABC173 {
  static A(input) {
    var n = +input.trim();
    console.log(Math.floor((n+999)/1000)*1000 - n);
  }
  static B(input) {
    var lines = input.trim().split('\n');
    var n = +lines[0];
    var cnt = {
      'AC': 0,
      'WA': 0,
      'TLE': 0,
      'RE': 0
    }
    for (var i = 0; i < n; i++) {
      cnt[lines[1+i]]++;
    }
    for (var [verd, c] of Object.entries(cnt)) {
      console.log(`${verd} x ${c}`);
    }
  }
  static C(input) {
    var lines = input.trim().split('\n');
    var [h, w, k] = lines[0].split(' ').map(x => +x);
    var c = lines.slice(1);
    var tot = 0;
    for (var i = 0; i < (1<<h); i++) {
      for (var j = 0; j < (1<<w); j++) {
        var cnt = 0;
        for (var y = 0; y < h; y++) {
          if (i>>y&1) continue;
          for (var x = 0; x < w; x++) {
            cnt += c[y][x]=='#' && !(j>>x&1);
          }
        }
        tot += cnt == k;
      }
    }
    console.log(tot);
  }
  static D(input) {
  }
  static E(input) {
  }
  static F(input) {
  }
}


var input = fs.readFileSync('/dev/stdin', 'utf8');
ABC173.C(input);

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

ll N, K;

int main(void) {
  cin >> N >> K;

  ll p = 1;
  REP(i, 0, N - 1) p = (p * (K + 1)) % MOD;
  ll all = (p * ((K * (K + 1) / 2) % MOD)) % MOD * N % MOD;

  vector< vector<ll> > dp(N + 1, vector<ll>(3500, 0));
  dp[0][0] = 1;
  REP(i, 0, N) {
    REP(j, 0, K + 1) {
      REP(k, 0, 3500) {
        if(dp[i][k] == 0) continue;
        if(j <= N - i) {
          if(k + (k + j) / (N - i) < 3500) {
            dp[i + 1][k + (k + j) / (N - i)] += dp[i][k];
            dp[i + 1][k + (k + j) / (N - i)] %= MOD;
          }
        } else {
          dp[i + 1][k] += dp[i][k];
          dp[i + 1][k] %= MOD;
        }
      }
    }
  }

  ll ans = 0;
  REP(i, 0, 3500) {
    ans += (dp[N][i] * i) % MOD;
    ans %= MOD;
  }
  cout << (all - ans + MOD) % MOD << endl;
}


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

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

  double ans = 0;
  for (int i = 1; i <= N; i++){
      int score = i;
      double prob = 1.0/N;
      while (score < K){
          score *= 2;
          prob /= 2;
      }
      ans += prob;
  }
  cout << std::setprecision(10) << ans << endl;
}


Measured memory_bytes: 256
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 10
w0 = INF
for w, v in wv:
  w0 = min(w0, w)

for i in range(N):
  wv[i][0] -= w0
#print("wv:", wv)

U = [[] for _ in range(4)]
for w, v in wv:
  U[w].append(v)
  
for i in range(4):
  U[i].sort(reverse = True)
#print("U:", U)

S = [[0] for _ in range(4)]
for i in range(4):
  for u in U[i]:
    S[i].append(S[i][-1] + u)
#print("S", S)

answer = []
for i0 in range(len(S[0])):
  for i1 in range(len(S[1])):
    for i2 in range(len(S[2])):
      for i3 in range(len(S[3])):
        if i1 + i2 * 2 + i3 * 3 + (i0 + i1 + i2 + i3) * w0 <= W:
          answer.append(S[0][i0] + S[1][i1] + S[2][i2] + S[3][i3])
print(max(answer))

Measured memory_bytes: 48564
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;
int A[100010];
int list[100010];
int ans;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		list[A[i]] = i;
	}
	for (int i = 1; i <= N; i++) {
		cout << list[i] << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll n,x,ans=0,p=0;
  ll a[100010];
  cin>>n>>x;
  rep(i,100010) a[i]=0;
  rep(i,n) cin>>a[i];
  ans+=max(p,a[0]-x);
  a[0]=min(a[0],x);
  rep(i,n){
    if(a[i]+a[i+1]>x){
      if(a[i+1]!=0){
	if(a[i+1]>=a[i]+a[i+1]-x){ans+=(a[i]+a[i+1])-x;a[i+1]-=(a[i]+a[i+1])-x;}
	else{
	  ans+=(a[i]+a[i+1])-x;
	  a[i]-=a[i]-x;
	  a[i+1]=0;
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 1024
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
def ddprint(x):
  if DBG:
    print(x)

n,a,b,c,d = inm()
a -= 1
b -= 1
c -= 1
d -= 1
s = input()
if c<d:
    for i in range(a,d-1):
        if s[i:i+2] == '##':
            print('No')
            exit()
    print('Yes')
else:
    for i in range(a,c-1):
        if s[i:i+2] == '##':
            print('No')
            exit()
    for i in range(b-1,d):
        if s[i:i+3] == '...':
            print('Yes')
            exit()
    print('No')


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

#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;i<n;i++)
#define EPS (1e-7)
#define INF 1e18

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

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

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

const ll mod=1e9+7;
const int MAX_N=300;

int main(){
	int k,n;
	cin>>n>>k;
	int a[n];
	REP(i,n)cin>>a[i];
	int sum[n];
	REP(i,n)sum[i]=0;
	REP(i,n){
		sum[a[i]-1]++;
	}
	int ans=0;
	sort(sum,sum+n);
	for(int i=0;i<n;i++){
		if(i>n-1-k)break;
		ans+=sum[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int num = sc.nextInt();
		int day = sc.nextInt();
		int remain = sc.nextInt();
		int[] arr = new int[num];
		for (int i = 0; i < num; i++) {
			arr[i] = sc.nextInt();
		}
		sc.close();

		int result = remain + num;
		for (int i = 0; i < arr.length; i++) {

			if (arr[i] <= day) {

				if ((day % arr[i]) == 0) {
					result--;
				}
				result += (day / arr[i]);
			}
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 23380
#include <iostream>

using namespace std;

int main()
{
	const int MAXN = 100;
	int N, A[MAXN];
	cin >> N;

	for(int i = 0; i < N; i++) cin >> A[i];

	for(int i = 1; i <= N; i++) {
		for(int k = 0; k < N; k++) {
			cout << A[k];
			if(k != N-1) cout << " ";
			else cout << endl;
		}
		if(i == N) break;
		
		int tmp = A[i], j = i - 1;

		while(j >= 0 && A[j] > tmp) {
			A[j + 1] = A[j];
			j--;
		}
		A[j + 1] = tmp;
	}

	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n)cin >> a[i];
    vector<ll> plus, minus, zero;
    rep(i,n){
        if(a[i] > 0)plus.push_back(a[i]);
        if(a[i] < 0)minus.push_back(a[i]);
        if(a[i] == 0)zero.push_back(a[i]);
    }
    n = plus.size();
    int m = minus.size();
    int w = zero.size();
    sort(plus.begin(), plus.end(), greater<ll>());
    sort(minus.begin(), minus.end());

    ll ans = 1;
    ll MOD = 1e9+7;

    if(n + m < k){
        cout << 0 << endl;
        return 0;
    }

    else if(n == 0){
        if(k % 2 == 0){
            rep(i,k){
                ans *= abs(minus[i]);
                ans %= MOD;
            }
        }else if(w > 0){
            ans = 0;
        }else{
            rep(i,k){
                ans *= abs(minus[m-1-i]);
                ans %= MOD;
            }
            ans = MOD - ans;
        }
    }

    else if(n + m == k && w == 0){
        rep(i,n){
            ans *= plus[i];
            ans %= MOD;
        }
        rep(i,m){
            ans *= MOD + minus[i];
            ans %= MOD;
        }
    }

    else{ // 最初にn,m,kをすべて偶数にしてしまう.
        if(k % 2 == 0){
            if(n % 2 == 1){
                plus.erase(plus.begin() + n - 1);
                n--;
            }
            if(m % 2 == 1){
                minus.erase(minus.begin() + m - 1);
                m--;
            }
        }else{
            ans *= plus[0];
            plus.erase(plus.begin());
            n--;
            k--;
            if(n % 2 == 1){
                plus.erase(plus.begin() + n - 1);
                n--;
            }
            if(m % 2 == 1){
                minus.erase(minus.begin() + m - 1);
                m--;
            }
        }
        vector<ll> v;
        rep(i,n/2){
            v.push_back(plus[i*2] * plus[i*2+1]);
        }
        rep(i,m/2){
            v.push_back(minus[i*2] * minus[i*2+1]);
        }
        sort(v.begin(), v.end(), greater<ll>());
        rep(i,k/2){
            ans *= v[i] % MOD;
            ans %= MOD;
        }
    }


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




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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

#define deg2rad(deg) (((deg)/360)*2*M_PI)
#define rad2deg(rad) (((rad)/2/M_PI)*360)

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

/*素数判定*/
bool is_prime(ll n){
    if(n==1) return false;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0) return false;
    }
    return true;
}

/*約数列挙*/
vll enum_divisors(ll n){
    vll l;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            l.push_back(i);
            if(n/i != i) l.push_back(n/i);
        }
    }
   sort(all(l));
   return l;
}

/*素因数分解*/
vector<P> prime_factorize(ll n){
    vector<P> l;
    for(ll i=2;i*i<=n;i++){
        if(n%i!=0) continue;
        ll e = 0;
        while(n%i==0){
            e++;
            n /= i;
        }
        l.push_back({i, e});
    }
    if(n!=1) l.push_back({n, 1});
    return l;
}

/*最小公倍数*/
ll lcm(ll a, ll b){
    return a*b/__gcd(a,b);
}

/*最大公約数*/
ll gcd(ll a, ll b){
    return __gcd(a,b);
}

int main(){

    ll n; cin >> n;
    vll a(n), acp(n);
    rep(i, n){
        cin >> a[i];
        acp[i] = a[i];
    }

    sort(all(acp));

    ll max_1 = acp[n-1];
    ll max_2 = acp[n-2];

    rep(i,n){
        if(a[i] == max_1){
            cout << max_2 << endl;
        }
        else{
            cout << max_1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6440
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (in i = 0; i < (in)(n); i++)
#define REP(i,a,b) for(in i=(in)(a);i<(in)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const in inf=1e9+7;
using P=pair<in,in>;
vector<in> dx={0,1,-1,0};
vector<in> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    in n;
    cin>>n;
    vector<in> a(n);
        rep(i,n) cin>>a.at(i);
    
    vector<vector<P>> dp(n,vector<P>(2));
    dp[0][0]=P(1000,0);
    dp[0][1]=P(1000%a[0],1000/a[0]);
    REP(i,1,n){
        in k1,k2,m1,m2;
        tie(m1,k1)=dp[i-1][0];
        tie(m2,k2)=dp[i-1][1];
        m2 +=k2*a[i];
        k2=0;
        dp[i][0]=P(max(m1,m2),0);
        tie(m1,k1)=dp[i-1][0];
        tie(m2,k2)=dp[i-1][1];
        k1 +=m1/a[i];
        m1 %=a[i];
        k2 +=m2/a[i];
        m2 %=a[i];
        if(k1<k2){
            dp[i][1]=P(m2,k2);
        }
        else if(k1!=k2){
            dp[i][1]=P(m1,k1);
        }
        else if(m1>m2){
            dp[i][1]=P(m1,k1);
        }
        else{
            dp[i][1]=P(m2,k2);
        }
    }
    cout<<dp[n-1][0].first<<endl;
}/*
./problem.exe
*/

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

int main(){
  int N; string s, t;
  cin >> N >> s >> t;
  int ans=2*N;
  for(int i=0; i<N; i++){
    int flag=0;
    for(int j=0; j<N-i; j++){
      if(s.at(i+j)==t.at(j)) flag++;
    }
    if(flag==N-i){
      ans=N+i;
      break;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
import math

def comb(n, r):
	if n <= r:
		return 1
	else:
		return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def perm(n, r):
	if n <= r:
		return math.factorial(n)
	else:
		return math.factorial(n) // (math.factorial(n - r))
	
N = int(input())
K = int(input())
N_str = str(N)
N_keta = len(N_str)
N_f = int(N_str[0])

def K1(a):
	a_str = str(a)
	a_keta = len(a_str)
	a_f = int(a_str[0])
	return a_f + (a_keta-1)*9

def K2(a):
	a_str = str(a)
	a_keta = len(a_str)
	a_f = int(a_str[0])
	if a_keta < 2:
		return 0
	else:
		a_under1 = int(a_str[1:])
		a_list = [9*9*i for i in range(1, a_keta-1)]
		return (a_f-1)*9*(a_keta-1) + K1(a_under1) + sum(a_list)

if K == 1:	
	print(K1(N))

elif K == 2:
	print(K2(N))

elif K == 3:
	if N_keta < 3:
		print(0)
	else:
		N_under1 = int(N_str[1:])
		N_list = [9*9*9*comb(i, 2) for i in range(2, N_keta-1)]
		print(K2(N_under1) + (N_f-1)*9*9*comb(N_keta-1, 2) + sum(N_list))



Measured memory_bytes: 3064
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

a = A % 10
b = B % 10
c = C % 10
d = D % 10
e = E % 10

list_1 = [A, B, C, D, E]
list_2 = [a, b, c, d, e]
list_2_2 = []
for x in list_2:
    if x != 0:
        list_2_2.append(x)
if list_2_2 != []:
	smallest = min(list_2_2)
else:
  	smallest = 10

list_3 = []

count = 0
for i in range(5):
    if list_2[i] == smallest and count % 10 == 0:
        list_3.append(list_1[i])
    elif list_2[i] != 0:
        list_3.append(list_1[i] - list_2[i] + 10)
    else:
        list_3.append(list_1[i])
    count += list_3[i]

sum = 0
for x in list_3:
    sum += x
    
print(sum)




Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)

#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)

#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)

using namespace std;

int main()
{
	static char stationID[]	= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int n;
	int	key[128];
	int	ids[128];
	string enc;
	while(cin >> n, n)
	{
		rep(i, n)	{	::scanf("%d", key + i);	}
		
		cin >> enc;
		rep(i, enc.size())
		{
			ids[i] = ('a' <= enc[i] && enc[i] <= 'z') ? (enc[i] - 'a') : (enc[i] - 'A' + 26);
		}
		rep(i, enc.size())	{	enc[i] = stationID[(52 + ids[i] - key[i % n]) % 52];	}
		cout << enc << endl;
	}
	return(0);
}

Measured memory_bytes: 1244
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define rep(i,n) for(int i=1; i<=n; i++)
#define forp(i,a,b) for(int i=a;i<b;i++)
#define forn(i,a,b) for(int i=a;i>=b;i--)
#define All(x,v) for(auto x:v)
#define arrin(a,n) ll a[n]; rep(i,n) cin>>a[i]
#define vi vector<int>
#define nl "\n"
#define print(arr) All(x,arr) cout<<x<<" "; cout<<nl
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define vdsort(v) sort(v.begin(),v.end(),greater<int>())
#define F first
#define S second
#define mod 1000000007
const int MAXN=100001;
int spf[MAXN];
int gcd(int x, int y){ return y?gcd(y,x%y):x; }

void precal(){  
    spf[1] = 1; 
    for (int i=2; i<MAXN; i++)  spf[i] = i; 
    for (int i=4; i<MAXN; i+=2) spf[i] = 2; 
    for (int i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) 
            for (int j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j)  spf[j] = i; 
    } 
} 
vector<int> getFactorization(int x){
    vector<int> ret; 
    while (x != 1) { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
}

ll exp(ll n, ll m){
    ll a = 1;
    while (m){
        if (m & 1) a = (a * n % mod) % mod;
        m /= 2;
        n = (n*n) % mod;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    int n,t=1;
    // cin>>t;
    while(t--){
        cin>>n;
        map<int,int> m;
        rep(i,100) rep(j,100) rep(k,100){
            m[i*i+j*j+k*k+i*j+i*k+j*k]++;
        }
        rep(i,n) cout<<m[i]<<nl;
    }
    return 0;
}

Measured memory_bytes: 4904
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n,a = readline() |> split |> parseMap
	x = readline() |> split |> parseMap
	s = sum(x)
	dp = zeros(Int,n+1,s+1)
	dp[1,1] = 1
	for i in 1:n
		for j in 0:n-1
			for k in 0:s
				if k+x[i]<s+1
					dp[n+1-j,k+x[i]+1]+=dp[n-j,k+1]
				end
			end
		end
	end
	t = 0
	for i in 1:n
		for j in 1:s
			if i*a==j
				t+=dp[i+1,j+1]
			end
		end
	end
	println(t)
end

main()

Measured memory_bytes: 112896
#include <boost/algorithm/string/join.hpp>
#include <iostream>

using namespace std;
using namespace boost;

typedef int64_t INT;

void Resolve(istream &is, ostream &os) {
    INT A,B,C;
    is>>A>>B>>C;
    os<<((A==B)&&(A==C)?"Yes":"No");
}

#if !TEST
int main() { cin.tie(0); ios::sync_with_stdio(false); Resolve(cin, cout); cout.flush(); return 0;}
#endif


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

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

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, M, S, T, ans=0;
	vector<pii> edge[100005][3];

	cin >> N >> M;
	rep(i,M){
		int u, v;
		cin >> u >> v;
		u--; v--;
		rep(k,3) edge[u][k].emplace_back(v,(k+1)%3);
	}
	cin >> S >> T;
	S--; T--;

	vector<vector<ll>> D(N, vector<ll>(3,INF));

	typedef pair<int,pii> ppi;
	priority_queue<ppi, vector<ppi>, greater<ppi>> que;
	que.emplace(0, pii(S,0));
	D[S][0] = 0;
	while(que.size()){
		int d = que.top().X;
		pii i = que.top().Y;
		que.pop();
		if( D[i.X][i.Y] < d ) continue;
		for(auto t: edge[i.X][i.Y]) if(D[t.X][t.Y] > d+1){
			D[t.X][t.Y] = d+1;
			que.emplace(d+1, t);
		}
	}

	ans = (D[T][0] == INF ? -1 : D[T][0] / 3);

	cout << ans << endl;

	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

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

//const ll INF=(ll)1e18;
const int INF=(1<<30);

int h,w;

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


int solve(int x, int y, vector<vector<char>> &mz){
  if(mz[x][y]=='#')return 0;

  vector<vector<int>> dist(h+2, vector<int>(w+2, INF));

  dist[x][y]=0;

  queue<P> q;

  q.push(P(x,y));

  while(q.size()){
    P p = q.front(); q.pop();

    REP(i,4){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];

      if(mz[nx][ny] != '#' && dist[nx][ny] == INF){
        q.push(P(nx,ny));
        dist[nx][ny] = dist[p.first][p.second] + 1;
      }
    }
  }

  int ret=-1;
  REP(i,h+2)REP(j,w+2){
    if(dist[i][j]==INF)continue;
    ret=max(ret,dist[i][j]);
  }
  return ret;
}


int main(){
  cin >> h >> w;

  vector<vector<char>> mz(h+2, vector<char>(w+2, '#'));

  REP(i,h)REP(j,w){
    cin >> mz[i+1][j+1];
  }

  int ans=-1;
  FOR(i,1,h+1)FOR(j,1,w+1){
    ans=max(ans,solve(i,j,mz));
  }
  cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//

int main(){
        int n,m;
        cin>>n>>m;
        if(n==m) {
                cout<<"Draw"<<endl;
                return 0;
        }
        if(n==1 && m!=1) {
                cout<<"Alice"<<endl;
                return 0;
        }else if(m==1 && n!=1) {
                cout<<"Bob"<<endl;
                return 0;
        }
        if(n>m) {
                cout<<"Alice"<<endl;

        }else{
                cout<<"Bob"<<endl;
        }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = sc.nextInt();
        }
        boolean bool = true;
        for (int i = 0; i < a.length; i++) {
            if (a[i] % 2 == 0) {
                if (a[i] % 3 != 0 && a[i] % 5 != 0) {
                    bool = false;
                    break;
                }
            }
        }
        if (bool == true) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
        sc.close();
    }
}

Measured memory_bytes: 25300
n = int(input())

c = list(input())

n_r = c.count('R')
n_w = c[:n_r]
# print(n_w)
if 'R' in n_w:
    n_x = n_w.count('R')
else:
    n_x = 0

print(n_r - n_x)


# print(c.count('R'))


Measured memory_bytes: 11696
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 100003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*//*
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}*/
ll n,m,k,l,r;
bool ok = false;
ll dp[N][6];
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>n;
    c=  0;
    for(i=1 ; i<=n ; i++)
    {
        for(j=1 ; j<=n ; j++)
        {
            for(k=1 ; k<=n ; k++)
            {
                c+=gcd(i,gcd(j,k));   
            }
        }
    }
    cout<<c;
}

Measured memory_bytes: 3640
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e5+5;
const int mod=1e9+7;

ll n,q,f[N];
signed main(){
    FastIO;
    cin>>n;
    ll sum=0;
    rep(i,1,n){
        int x;
        cin>>x;
        sum+=x;
        f[x]++;
    }
    cin>>q;
    while(q--){
        int a,b;
        cin>>a>>b;
        sum-=a*f[a];
        sum-=b*f[b];
        f[b]+=f[a];
        f[a]=0;
        sum+=b*f[b];
        cout<<sum<<'\n';
    }
//    ll n;
//    cin>>n;
//    string s;
//    while(n){
//        int m=(n%26?n%26:26);
//        m--;
//        s+=char(m+'a');
//        n/=26;
//    }
//    reverse(all(s));
//    cout<<s;
    return 0;
}


Measured memory_bytes: 4396
// #define _GLIBCXX_DEBUG
// #pragma GCC optimize("Ofast")
#pragma GCC diagnostic ignored "-Wsign-compare"
#include <bits/stdc++.h>
// #include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define reps(i, s, n) for (int i = s; i < (int)(n); ++i)
#define rreps(i, s, n) for (int i = n - 1; (int)(s) <= i; --i)
// reps(s,n)[::-1]
using namespace std;
using ll = long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
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;
}
constexpr int INF = 1e9 + 7;
constexpr ll LINF = 1LL << 60;
class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* _sep, const char* _term) : sep(_sep), term(_term) {}
        template <class... Args> void operator()(const Args&... args) const { print(args...); }
        template <typename T> void pvec(const T& vec, size_t sz) const {
            for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T> void pmat(const T& mat, size_t h, size_t w) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++) std::cout << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail> void print(const T& head, const Tail&... tail) const {
            std::cout << head, print_rest(tail...);
        }
        template <class T, class... Tail> void print_rest(const T& head, const Tail&... tail) const {
            std::cout << sep << head, print_rest(tail...);
        }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints print;

void solve() {
    ll a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    // x >= y とする
    if (x < y) {
        swap(a, b);
        swap(x, y);
    }
    ll ans = a * x + b * y;
    ans = min(c * 2 * x, ans);
    ans = min(c * 2 * y + (x - y) * a, ans);
    print()(ans);
}
int main() {
    cin.tie(nullptr);
    // ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define sz(a)           (int)(a).size()
#define all(x)          (x).begin(), (x).end()
#define fore(i,a,b)     for(int i=a; i<b; i+=1)
#define forr(i,a)       for(int i=a; i>=0; i--)
#define F first
#define S second
 
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef pair<string, int> si;
typedef pair<int, string> is;
typedef vector<string> vs;
const int MAX=1e5+10;

 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll k,n; cin>>k>>n;
    vector<ll> dis;
    ll i0; cin>>i0;
    ll aux=i0;
    fore(i,0,n-1){
        ll h; cin>>h;
        dis.pb(h-i0);
        i0=h;
    }
    dis.pb((k-i0)+(aux));
    ll res=1e9;
    fore(i,0,sz(dis)) res=min(res,abs(k-dis[i]));
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 2420