akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main()
{
 string s ;   int i;
 cin >> s;
 for (i=0 ; i<s.length() ; i++) {

    if (s[i]==',') {
        s[i] = ' ' ;

    }
    cout << s[i] ;
 }
    return 0;
}


Measured memory_bytes: 256
int main()
{
	/* ??\?????¨ */
	int sikaku_W;
	int sikaku_H;
	int maru_x;
	int maru_y;
	int maru_r;
		
	/* ??\????????? */
	scanf( "%d", &sikaku_W );
	scanf( "%d", &sikaku_H );
	scanf( "%d", &maru_x );
	scanf( "%d", &maru_y );
	scanf( "%d", &maru_r );
	
	/* ???????????? */
	/* x - r???0??\??? ?????????x + r???W??\?????? */
	if((( maru_x - maru_r ) >= 0 )
	&& (( maru_x + maru_r ) <= sikaku_W )){
		/* y - r???0??\??? ?????????y + r???H??\?????? */
		if((( maru_y - maru_r ) >= 0 )
		&& (( maru_y + maru_r ) <= sikaku_H )){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

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

#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
#define endl '\n'
// #define int long long

typedef pair<int,int> pii;
const int N = 2e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;

int n, a[N];
int b[N];
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=1; i<=n; i++){
		cin >> a[i];
	}
	vector<int> ans;
	for(int i=n; i>0; i--){
		int cnt = 0;
		for(int j=i; j<=n; j+=i){
			cnt ^= b[j];
		}
		if (a[i] != cnt) {
			b[i] = 1;
			ans.push_back(i);
		} 
	}
	cout << ans.size() << endl;
	for(auto x:ans) cout << x << ' ';

	return 0;
}


Measured memory_bytes: 2936
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
rsort($a);
$ans=$a[0];
$i=2;
$j=1;
while($i<$n){
  if($i%2==0){
    $ans+=$a[$i-$j];
  }else{
    $ans+=$a[$i-$j-1];
    ++$j;
  }
  ++$i;
}
echo $ans;

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

typedef long long ll;
typedef unsigned long long ull;

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

int main() {
  ll n;
  cin >> n;

  auto v = divisor(n);

  vector<ll> c;
  for (ll i = v.size()-2; i >= 0; --i) {
    bool ok = true;
    for (ll j = 0; j < c.size(); ++j) {
      if (c[j] % v[i] == 0) {
        ok = false;
        break;
      }
    }
    if (ok) {
      c.push_back(v[i]);
    }
  }

  cout << c.size() << " " << v.size() - 1 << endl;
    
  return 0;
}


Measured memory_bytes: 3168
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.next();
      
      // 判定
      int count = 0;
      int max = 0;
      for(int i = 0; i < 3; i++){
        if(strAt(S,i).equals("R")){
          count++;
        }else{
          if(max < count){
            max = count;
          }
          count = 0;
        }
      }

      if(max < count){
        max = count;
      }
      
      // 出力
      System.out.println(max);
    }
    
    // 文字列のx文字目を取得する関数
    public static String strAt(String str, int x){
      return String.valueOf(str.charAt(x));
    }

}

Measured memory_bytes: 35528
/*
 * 競技プログラミング用テンプレート
 * by yuma140902
 * 2020/06/07
 * ver 0.3.2
 */
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef tuple<int, int> ii;
typedef tuple<int, int, int> iii;
const int INF = 900000;
const ll INFL = 9000000;

#define vi vector<int>
#define vii vector<vector<int> >
#define vi_def(n) vector<int>((n))
#define vii_def(n,m) vector<vector<int> >((n), vector<int>((m)))
#define vi_def_dflt(n, def) vector<int>((n), (def))
#define vii_def_dflt(n, m, def) vector<vector<int> >((n), vector<int>((m), (def)))

#define rep(i, n) for(int i=0; i < (n); ++i)
#define per(i, n) for(int i=(n)-1; i >= 0; --i)
#define range(i, begin, end) for(int i=(begin); i < (end); ++i)

#define ALL(vec) vec.begin(), vec.end()

#ifdef DBG_FLAG
#define pdbg(msg) cout << (msg)
#define pdbgl(msg) cout << (msg) << endl
#define dbg if(true)
#else
#define pdbg(msg) ;
#define pdbgl(msg) ;
#define dbg if(false)
#endif

int N;
vi a;

bool possible(int);

int main(){
  cin >> N;
  a = vi_def(N);
  rep(i, N) cin >> a[i];
  rep(i, N) a[i] -= 1;

  int src = 0;
  rep(count, N+1){
    if(src == 1){
      cout << count << endl;
      return 0;
    }
    src = a[src];
  }
  cout << "-1" << endl;
}


Measured memory_bytes: 640
def solve():
    n = int(input())
    ab = sorted(list(list(map(int, input().split())) for _ in range(n)), key=lambda x: x[1])
    total_time = 0
    for a, b in ab:
        total_time += a
        if b < total_time:
            return "No"
    return "Yes"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 55184
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
std::vector<int>s;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	ll n=gi()+1;int o=0;
	s.push_back(++o);
	int flg=-1;
	for(int i=39;~i;--i)
		if((n>>i)&1){
			if(flg==-1)flg=i;
			else{
				if(flg!=i+1)s.push_back(++o);
				s.insert(s.begin(),++o);
			}
		}else if(~flg&&flg!=i+1)s.push_back(++o);
	printf("%d\n",s.size()*2);
	for(int i:s)printf("%d ",i);
	for(int i=1;i<=o;++i)printf("%d ",i);
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
 char c[a][b];
  rep(i,a)rep(j,b)
    cin>>c[i][j];
  rep(i,2*a){
    rep(j,b){
    cout<<c[i/2][j];
    }
    cout<<' '<<endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
alpha = "abcdefghij"
ans = []
N = int(input())

def get_right(S):
    alpha_idx = 0
    for i in range(len(S)):
        flag = S.find(alpha[i])
        if flag > 0:
            alpha_idx = i
    return alpha_idx + 2


def dfs(S):
    if len(S) == N:

        ans.append(S)
    else:
        right = get_right(S)
        seq = alpha[:right]
        for c in seq:
            dfs(S+c)
    return

dfs("a")
ans = sorted(ans)
for a in ans:
    print(a)

Measured memory_bytes: 12684
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <complex>

int main(){
  long long int A, B;
  scanf("%lld%lld", &A, &B);

  long long int ans = 0;
  for(ans = 1; ans <= 20001; ans++){
    if((8*ans)/100 == A && (ans)/10 == B){
      break;
    }
  }

  std::cerr << "Answer: " << std::endl;
  if(ans < 20001){
    std::cout << ans << std::endl;
  }
  else{
    std::cout << -1 << std::endl;
  }

  return 0;
}


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

st = s+t
total_len = len(st)
dupl = 0
for n in range(N+1):
    if st[N-n:N] == st[N:N+n]:
        dupl = len(s[N-n:N])

total_len = total_len - dupl

print(total_len)


Measured memory_bytes: 38256
n=int(input())
t, a= list(map(int,input().split()))
h= list(map(int,input().split()))

dif=999999
res=0
index=0

for hh in h:
    temp=t-hh*(0.006)
    index+=1
    if 0 <= abs(temp-a) <= abs(dif):
        dif=temp-a
        res=index

print(res)






Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


vector<ll> enum_div(ll n){
    vector<ll> ret;
    for(ll i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}


int main(void) {
    
    ll x;
    cin>>x;
    vll v=enum_div(x);
    ll ans=LLINF;
    rep(i,v.size()){
        ans=min(ans,v[i]-1+x/v[i]-1);
    }
    fin(ans);
}

Measured memory_bytes: 384
#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
#define rep2(i, N, s) for(int (i) = (s); (i) < (N) + (s); (i) ++)
#define rrep(i, N) for(int (i) = (N) - 1; (i) >= (0); (i) --)
#define rrep2(i, N, s) for(int (i) = (s); (i) >= (s) - (N) + 1; (i) --)
#define INF 1e9

#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <cmath>
using namespace std;

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

int main() {
    int K;
    cin >> K;
    int x = (K + 1) / 2;
    int y = K / 2;
    cout << x * y << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [[] for _ in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    p[i].append(list(map(int,input().split())))
ans = 0
for i in range(2**n):
  a = [(i >> j) & 1 for j in range(n-1,-1,-1)]
  flag = 1
  for k in range(n):
    if a[k]*flag == 1:
      for l in p[k]:
        if a[l[0]-1] != l[1]:
          flag = 0
  ans = max(ans,flag*sum(a))
print(ans)

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = (n / (a + b)) * a + min(a, n % (a + b));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eb emplace_back
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<60;
template<class T> void chmin(T &a,T b){a=min(a,b);}
template<class T> void chmax(T &a,T b){a=max(a,b);}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n,a,b;cin>>n>>a>>b;
	cout<<a*(n/(a+b))+min(n%(a+b),a)<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    decimal a = decimal.Parse(aho[0]);
    decimal b = decimal.Parse(aho[1]);
    long k = (long)(a*b);
    Console.WriteLine(k);
  }
}

Measured memory_bytes: 18044
#include<stdio.h>
#include<cstring>
#include<stdlib.h>

int main() {
    char s[1000], t[1000];
    scanf("%s", s);
    scanf("%s", t);
    int cnt = strlen(t);
    int min = strlen(t);
    for (int i = 0; i < strlen(s) - strlen(t) + 1; i++) {
        int cnt = strlen(t);
        for (int j = 0; j <= strlen(t) - 1; j++) {
            if (s[i + j] == t[j]) {
                cnt--;
            }
        }
        min = (min < cnt) ? min : cnt;
    }
    printf("%d\n", min);
}



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

using namespace std;

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


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

    int N;
    cin >> N;
    vector<int> h(N);

    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    int cnt = 0;
    for (int i = 0; i < 100; i++) {
        bool isbef = false;
        for (int j = 0; j < N; j++) {
            if (h[j] > 0) {
                h[j]--;
                if (!isbef)
                    cnt++;
                isbef = true;
            } else
                isbef = false;
        }
    }

    cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
l, r = map(int, input().split())
if r - l >= 2019:
    print(0)
    exit()
ans = 2019

for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
        ans = min(ans, (i * j) % 2019)
print(ans)

Measured memory_bytes: 9120
n=int(input())
w=list(map(int,input().split()))
ans=10**5
for i in range(n-1):
    s1=0
    s2=0
    for a in range(i+1):
        s1+=w[a]
    for b in range(i+1,n):
        s2+=w[b]
    if abs(s1-s2)<ans:
        ans=abs(s1-s2)
print(ans)

Measured memory_bytes: 9052
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d%d", &a, &b);
	if(a < b){
		printf("%s\n", "a < b");
	} else if(a > b){
		printf("%s\n", "a > b");
	} else{	
		printf("%s\n", "a == b");
	}
	
	return(0);
}



Measured memory_bytes: 1724
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        while(true) {
            int n = sc.nextInt();
            if(n == 0) {
                break;
            }
            int count = 0;
            while(n > 0) {
                count += n / 5;
                n =  n/ 5;
            }
            System.out.println(count);
        }
    }
}



Measured memory_bytes: 25976
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	if n%2 == 0 {
		fmt.Println(-1)
		return
	}
	if n%5 == 0 {
		fmt.Println(-1)
		return
	}
	n = 9 * n
	if n%7 == 0 {
		n = n / 7
	}
	c := 1
	tmp := 1
	for {
		tmp = (tmp * 10) % n
		if tmp == 1 {
			fmt.Println(c)
			return
		}
		c++
	}

}


Measured memory_bytes: 1852
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;



int main() {
	complex<long double>cmpmp;
	const long long int mod = 1000000007;
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m, k, d[200050], t[200050], left = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> t[i];
	}
	sort(t, t + m);
	for (int i = 0; i < m; i++) {
		if (n <= left) { cout << "NO" << endl; return 0; }
		for (int j = left; j < n; j++) {
			if (t[i] == d[j]) {
				left = j + 1;
				break;
			}
			if (j == n - 1) { cout << "NO" << endl; return 0; }
		}
	}
	cout << "YES" << endl;
} 


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

int main(){
  int n, ans=1;
  long long k;
  cin >> n >> k;
  vector<int> a(n+1);
  for(int i = 1; i <= n; i++){
  	cin >> a[i];
  }
  map<int, int> mp;
  int pos = 1;
  int move = 0;
  while(mp[pos]==0){
  	mp[pos]++;
  	pos = a[pos];
  	move++;
  }
  //cout << move << endl;
  
  int pos2=1, move2=0;
  for(int i = 0; i < move; i++) pos2 = a[pos2];
  //cout << pos2 << endl;
  
  int pos3 = 1;
  while(pos3!=pos2){
  	pos3 = a[pos3];
  	move2++;
  }
  //cout << move2 << endl;
  
  move -= move2;
  if(k<=move2){
  for(int i = 0; i < k; i++) ans = a[ans];
  cout << ans << endl;
  }
  else{
  
  k = k-move2;
  //cout << k << endl;
  k = k%move;
  //cout << k << endl;
  
  for(int i = 0; i < k+move2; i++) ans = a[ans];
  cout << ans << endl;
  }
  //cout << k << endl;
}

Measured memory_bytes: 13088
N, A, B = [int(x) for x in input().split()]
S = list(input())
go = 0
go_abroad = 0
for i in range(N):
  if(go)<(A+B):
    if(S[i]=='a'):
      print('Yes')
      go += 1
    elif(S[i]=='b') and (go_abroad<B):
      print('Yes')
      go += 1
      go_abroad += 1
    else:
      print('No')
  else:
    print('No')

Measured memory_bytes: 9836
import java.io.*;
   
class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    
    String[] strAry = str.split(" ");
   
    int a = Integer.parseInt(strAry[0]);
    int b = Integer.parseInt(strAry[1]);
    
    int d = a / b;
    int r = a % b;
    String f = String.format("%.5f", 1.0 * a / b);
    System.out.println(d + " " + r + " " + f);
  }
}

Measured memory_bytes: 24740
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int ans=1;
  string A="dreamer",B="eraser",C="dream",D="erase";
  if(S[0]=='a') ans=0;
  S.insert(0,"dreamer");
  while(S.size()>0){
    int L=S.size(),X=1,Y=1,Z=1,W=1;
    for(int i=0;i<7;i++) X*=int(S[L-7+i]==A[i]);
    for(int i=0;i<6;i++) Y*=int(S[L-6+i]==B[i]);
    for(int i=0;i<5;i++) Z*=int(S[L-5+i]==C[i]);
    for(int i=0;i<5;i++) W*=int(S[L-5+i]==D[i]);
    if(X) S.erase(L-7);
    else if(Y) S.erase(L-6);
    else if(Z) S.erase(L-5);
    else if(W) S.erase(L-5);
    else{
      ans=0;
      break;
    }
  }
  cout<<(ans?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
    int n;
    int m;
    string l;
 
   cin >> n >> m >> l;
  
 for(int i = 0;i<n;i++){
     
   if(i==m-1){
     
    char c;
    c = l[i] + 0x20;
     
      l[i]=c;
        
     cout <<  l[i];
   }else if(i==n-1){
     
     cout <<  l[i] << endl;
   }else{
     cout <<  l[i];
   }
     
}
   
  
  return 0;
}

Measured memory_bytes: 256
page_count = gets.to_i
text_list = page_count.times.map { gets }


text_list = text_list.group_by(&:itself)
max_count = text_list.max { |x,y| x[1].count <=> y[1].count}[1].count

most_duplicated_text_list = text_list.each_with_object([]) do |hash, result|
  result << hash[0] if hash[1].count == max_count
end

puts most_duplicated_text_list.sort


#def duplicate_text_hash(text, count)
#  {
#    text: text,
#    count: count
#  }
#end

#duplicate_text_list = page_count.times.inject([]) do |list, _|
#  text = gets
#  same_text_hash = list.find { |hash| hash[:text] == text }
#  if same_text_hash.nil?
#    list.append(duplicate_text_hash(text, 1))
#  else
#    list.delete(same_text_hash)
#    same_text_hash[:count] = same_text_hash[:count] + 1
#    list.append(same_text_hash)
#  end
#end
#
#duplicate_text_list.max { |x,y| x[: }

Measured memory_bytes: 65244
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let l: f64 = read();

    let e: f64 = l/3.0;

    println!("{:.012}", e * e * e );
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>

using namespace std;

int C[5];

int main(void) {

	string S;
	cin >> S;

	int N = S.size();

	for (int i = 0; i < N; i++) {
		if (S[i] == 'N') { C[1]++; }
		else if (S[i] == 'S') { C[2]++; }
		else if (S[i] == 'W') { C[3]++; }
		else { C[4]++; }
	}

	bool ans = true;
	if (C[1] == 0 && C[2] != 0) { ans = false; }
	if (C[1] != 0 && C[2] == 0) { ans = false; }
	if (C[3] == 0 && C[4] != 0) { ans = false; }
	if (C[3] != 0 && C[4] == 0) { ans = false; }

	if (ans) { cout << "Yes" << endl; }
	else { cout << "No" << endl;  }

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}


int main(){
	int a,b,c; cin >> a >> b >> c;
	if(a <= c && c <= a+b) cout << "YES\n";
	else cout << "NO\n";
}

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

using namespace std;

const int SIZE = 210;
const double eps = 1e-10;

typedef complex<double> P;

typedef double P_type;
typedef complex<P_type> P;
const P_type P_eps = 1e-8; //整数の時はゼロ

namespace std{
  template<class T> bool operator<(const complex<T> &a, const complex<T> &b){
    return a.real() == b.real() ? a.imag() < b.imag() : a.real() < b.real();
  }
};

P rotate(P p, double theta){
  return p * P(cos(theta), sin(theta));
}

//内積
double dot(P a, P b) {
  return (a * conj(b)).real();
}

//外積
double cross(P a, P b) {
  return (conj(a) * b).imag();
}

//反時計回り
int ccw(P a, P b, P c){
  if(cross(b-a,c-a) > P_eps) return 1; //COUNTER_CLOCKWISE
  if(cross(b-a,c-a) < -P_eps) return -1; //CLOCKWISE
  if(dot(b-a,c-a) < -P_eps) return -2; //ONLINE_BACK
  if(dot(a-b,c-b) < -P_eps) return 2; //ONLINE_FRONT
  return 0; //ON_SEGMENT
}

int main(){
  int x0, y0, x1, y1;
  P p0, p1;

  scanf("%d%d%d%d",&x0,&y0,&x1,&y1);
  p0 = P(x0, y0);
  p1 = P(x1, y1);

  int n;
  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    int x2, y2;
    scanf("%d%d",&x2, &y2);

    switch(ccw(p0,p1,P(x2,y2))){
    case 1:
      puts("COUNTER_CLOCKWISE");
      break;
    case -1:
      puts("CLOCKWISE");
      break;
    case 2:
      puts("ONLINE_FRONT");
      break;
    case -2:
      puts("ONLINE_BACK");
      break;
    case 0:
      puts("ON_SEGMENT");
      break;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3136
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
      	List ss = new ArrayList<Character>();
 		
      	for(int i = 0;i < s.length(); i++){
          if(s.charAt(i) != 'B') ss.add(s.charAt(i));
          else{
          	if(ss.size() != 0) ss.remove(ss.size()-1);
          }
        }
      
     	for(int i = 0;i < ss.size();i++) System.out.print(ss.get(i));
      	System.out.println();
        
	}
}


Measured memory_bytes: 35664
//101B
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    long n, p;
    int sum=0;
    cin >> n;
    p = n;
    while(true){
        sum += p%10;
        //cout << sum;
        p = p/10;
        if (p==0) break;  
    }
    if(n%sum==0){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
int main() {
	int n;cin >> n;ll sum = 0;
	vector<int> a(n),c(n + 1,0);
	rep(i, n) {
		cin >> a[i];
		sum += c[a[i]];
		c[a[i]]++;
	}
	rep(i,n) cout << sum - c[a[i]] + 1 << endl;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  double a,b,c,d,e,f;
  while(cin>>a>>b>>c>>d>>e>>f){
    double y=(a*f-c*d)/(a*e-b*d);
    double x=(c-b*y)/a;
    printf("%.3f %.3f\n",x,y);
  }
  

}

Measured memory_bytes: 1236
def read():
    return raw_input()


def write(message):
    import sys
    print message
    sys.stdout.flush()


if __name__ == '__main__':
    n = int(read())
    v = map(int, read().split())
    from collections import Counter
    counts_odd = Counter(v[::2])
    counts_even = Counter(v[1::2])
    co = counts_odd.most_common(2) + [(0, 0)]
    ce = counts_even.most_common(2) + [(0, 0)]

    ok = None
    if co[0][0] == ce[0][0]:
        ok = max(co[0][1] + ce[1][1], co[1][1] + ce[0][1])
    else:
        ok = co[0][1] + ce[0][1]
    write(n - ok)





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

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

    string S;   // len = 10^5
    cin >> S;
    int N = (int)S.size();

    vector<int> count(N,0);

    int r_st, r_end, l_st, l_end;
    int idx = 0;

    while(idx < N){
        // find start & end of "R+", "L+"
        r_st = idx;
        while(S[idx] == 'R') idx++;
        r_end = max(idx-1, r_st);
        l_st = idx;
        while(S[idx] == 'L') idx++;
        l_end = max(idx-1, l_st);

        count[r_end] = 1 + (r_end - r_st) / 2 + (l_end - r_end) / 2; 
        count[l_st] = 1 + (l_st - r_st) / 2 + (l_end - l_st) / 2; 
    }

    for(int i=0; i<N; i++){
        if(i != 0)
            cout << " ";
        cout << count[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1104
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using namespace std;

void Main()
{
   char b;
   cin >> b;
   switch (b)
   {
   case 'A':
      cout << 'T' << endl;
      break;
   case 'T':
      cout << 'A' << endl;
      break;
   case 'C':
      cout << 'G' << endl;
      break;
   case 'G':
      cout << 'C' << endl;
      break;
   }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second

ll gcd(ll x, ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}

ll lcm(ll x, ll y){
	return x*y/gcd(x,y); 
}

ll  num_of_multiples(ll a, ll b, ll x){
	ll num_a = (a-1)/x;
	ll num_b = b/x;
	return num_b-num_a;
}

int main(void) {
	ll a,b,c,d; cin >> a >> b >> c >> d;
	ll l = lcm(c,d);
	ll num_c = num_of_multiples(a,b,c);
	ll num_d = num_of_multiples(a,b,d);
	ll num_l = num_of_multiples(a,b,l);
	ll ans = b-a+1-(num_c+num_d-num_l);
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
int M = 1e9+7;

int minCost(int n, vector<int> &heights, vector<int> &dp) {
    if(n <= 0) return 0;
    if(n == 1) return abs(heights[n] - heights[n - 1]);
    if(dp[n] != -1) return dp[n]; 
    dp[n] = min(minCost(n - 1, heights, dp) + abs(heights[n] - heights[n - 1]),
        minCost(n - 2, heights, dp) + abs(heights[n] - heights[n - 2]));
    return dp[n];
}


int main() {
   
    //Fast IO crap
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    vector<int> heights(n);
    for(int i = 0; i < n; i++) cin >> heights[i];
    
    vector<int> dp(n, -1);
    cout << minCost(n - 1, heights, dp);
    
        
    return 0;
}


Measured memory_bytes: 4992
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double; using vi = vector<int>;
using ll = int_fast64_t; using ull = uint_fast64_t;
using vl = vector<ll>; using vul = vector<ull>;

// -----------------------------------------------------------------------------



void solve() {
    int n, m;
    cin >> n >> m;
    int re = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << re << '\n';
}

// -----------------------------------------------------------------------------

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    // preprocess();
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
n = int (input())
def factorization(n):
    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
ans = 0
if n == 1:
    print(0)
else:
    for i in range(len(factorization(n))):
        s = factorization(n)[i][1]
        ans +=  int((-1+(1+8*s)**(1/2))/2)




    print(ans)


Measured memory_bytes: 9484
def someSums():
	n, a, b = map(int, input().split())
	count = 0
	for i in range(1, n + 1):
		sum = 0
		n = i
		while True:
			sum += n % 10
			if n >= 10:
				n = n // 10
			else:
				break
		if a <= sum and sum <= b:
			count += i
	print(count)

someSums()

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

int main(){
  string a,b;
  cin>>a>>b;
  reverse(b.begin(),b.end());
  if(a==b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      ss: [usize; n],
    }
    const M: usize = 10001;
    let mut dp = vec![vec![0; n+1]; M];
    dp[0][0] = 1;
    for i in 0..n {
        let s = ss[i];
        for j in 0..M {
            dp[j][i+1] |= dp[j][i];
            if s + j <= M-1 {
                dp[s+j][i+1] |= dp[j][i];
            }
        }
    }
    for i in (0..M).rev() {
        if i % 10 != 0 && dp[i][n] > 0 {
            return println!("{}", i);
        }
    }
    println!("{}", 0);
}


Measured memory_bytes: 8444
#include <iostream>
using namespace std;
int main(){
 int n, m, a[100][100], b[100], x[100];
 int y = 0;
 cin >> n >> m;
 for(int h=0; h<n; h++){
  for(int i=0; i<m; i++){
   cin >> a[h][i];
  }
 }
 for(int j=0; j<m; j++){
  cin >> b[j];
 }
 for(int k=0; k<n; k++){
  for(int l=0; l<m; l++){
   if(l == 0)
    x[k] = a[k][l]*b[l];
   else
    x[k] += a[k][l]*b[l];
  }
 cout << x[k] << endl;
 }
 return 0;
}

Measured memory_bytes: 3136
from collections import defaultdict

d = defaultdict(lambda: 0)
N = int(input())
for _ in range(N):
    a, b = map(int, input().split())
    d[b] += a
d_keys = list(d.keys())
d_keys.sort()
tmp_time = 0
flag = True
for i in range(len(d_keys)):
    tmp_time += d[d_keys[i]]
    if tmp_time > d_keys[i]:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 31688
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7;

long calc(long k, int[] a) {
    long ans = 0;

    // a 内での転倒数
    long p = 0;
    for (int i = 0; i < a.length; i++) {
        for (int j = i + 1; j < a.length; j++) {
            if (a[i] > a[j]) p++;
        }
    }
    ans += (p * k) % MOD;

    // 二つの a に対する転倒数
    long q = 0;
    for (int i = 0; i < a.length; i++) {
        for (int j = 0; j < a.length; j++) {
            if (a[i] > a[j]) q++;
        }
    }
    ans += q * (((k * (k - 1)) / 2) % MOD); // q * kC2
    ans %= MOD;
    return ans;
}

void main() {
    int n, k; scan(n, k);
    auto a = readints;
    writeln(calc(k, a));
}


Measured memory_bytes: 2300
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;

int main(){
    int H,W;cin>>H>>W;
    mat A(100,vec(100)),B(100,vec(100));
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>A[i][j];
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            cin>>B[i][j];
        }
    }
    vector<vector<vector<bool>>> dp(90,vector<vector<bool>>(90,vector<bool>(13000,false)));
    dp[1][1][abs(A[1][1]-B[1][1])]=true;
    for(int h=1;h<=H;h++){
        for(int w=1;w<=W;w++){
            for(int k=0;k<13000;k++){
                if(dp[h-1][w][k]){
                    dp[h][w][abs(k+A[h][w]-B[h][w])]=true;
                    dp[h][w][abs(k-A[h][w]+B[h][w])]=true;
                }
                if(dp[h][w-1][k]){
                    dp[h][w][abs(k+A[h][w]-B[h][w])]=true;
                    dp[h][w][abs(k-A[h][w]+B[h][w])]=true;                    
                }
            }
        }
    }
    for(int k=0;k<13000;k++){
        if(dp[H][W][k]){
            cout<<k<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 13952
W,C;char m[484];R(char*i){*i>45?*i=0,C++,R(i-1),R(i+1),R(i-W),R(i+W):0;}main(){for(;scanf("%d%*d",&W)*W;C=!printf("%d\n",C))memset(m,W++,484),scanf("%[^0-9]",m+W),R(strchr(m,64));}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int,ll> pii;
const int max_N=1e5+10;
int n,W;
const int inf=1e9+5;
vector <pii> G[max_N],rg[max_N];
vector<int>p(105,0);
ll w[105];
ll v[105];
int main()
{
  cin >> n>> W;
  for(int i=1;i<=n;i++)
    {
      cin >> w[i] >> v[i];
    }
  vector<vector<ll> >dp(105,vector<ll>(W+5,0));
  dp[0][0]=0;
  ll ans=0;
  for(int i=1;i<=n;i++)
    {
      for(int j=0;j<=W;j++)
	{
	  if(w[i]+j<=W)
	    {
	      dp[i][j+w[i]]=max(dp[i][j+w[i]],dp[i-1][j]+v[i]);
	      dp[i][j]=max(dp[i][j],dp[i-1][j]);
	    }
	  else
	    {
	      dp[i][j]=max(dp[i][j],dp[i-1][j]);
	    }
	}
    }
  for(int i=0;i<=W;i++)
    {
      ans=max(ans,dp[n][i]);
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 88064
import java.util.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {	

	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] A = na(N);
		long[] cnt = new long[N + 1];
		long[] combi = new long[N + 1];
		long combisum = 0;

		for(int i = 0; i < N; i++) cnt[A[i]]++;
		for(int i = 1; i <= N; i++) {
			combi[i] = cnt[i] * (cnt[i] - 1) / 2;
			combisum += combi[i];
		}
		for(int i = 0; i < N; i++) {
			long result = combisum - combi[A[i]] + (cnt[A[i]] - 1) * (cnt[A[i]] - 2) / 2;
			System.out.println(result);
		}
	}
	
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		boolean hasNext = true;
		while(hasNext){
			solve();	
			try{
				br.mark(1);
				if(br.read() > 0){
					br.reset();			
					System.out.println("---");
				} else {
					hasNext = false;
				}
			}catch(Exception e){
				throw new RuntimeException(e);
			} 
		}
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 69328
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N, M, X, oo=4e18; cin >> N >> M >> X;
  vector<vector<ll>> C(N, vector<ll>(M+1, 0));
  rep(i, N) rep(j, M+1)
    cin >> C[i][j];
  ll ans = oo;
  ll end = 1LL<<N;
  for(ll i=1; i<end; i++){
    vector<ll> A(M+1, 0);
    for(ll j=0; j<N; j++){
      if ((i & (1<<j))){
        for(ll k=0; k<=M; k++)
          A[k] += C[j][k];
      }
    }
    //check
    for (ll m=1; m<=M; m++){
      if (A[m] < X)
        break;
      if (m == M)
        chmin(ans, A[0]);
    }
  }
  if (ans == oo)
    ans = -1;
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#define ll long long

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> L(2*N,0);
    for(int i=0;i<2*N;i++){
        cin >> L[i];
    }
    sort(L.begin(),L.end());
    int ans=0;
    for(int i=0;i<2*N;i+=2){
        ans+=L[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void){
 	int n;
  	int cnt = 0;
  	cin >> n;
  	vector<int> p(n); 	
  
  	for(int i = 0; i < n; i++){
     	cin >> p[i]; 
    }
 
  	for(int i = 1; i < n-1; i++){
      	if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])){
        	cnt++;
        }
    }
  
    cout << cnt << endl;
	return 0;
}

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

signed main() {
  int N;
  cin >> N;
  vector<int>vec(N*3);
  for(int i=0; i<N*3; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int ans = 0;
  for(int i=1; i<=N; i++){
    ans += vec[i*2-1];
  }
  cout << ans << endl;
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
using pp=pair<int,pair<int,int>>;
#define MAX 1000000
#define MOD 1777777777

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

  if(N>=30){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[55],ans;
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=n-1;i>=n-k;i--)
    ans+=a[i];
	cout<<ans<<endl;
	return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		long N = readLong(); if(N <= 9) {println(N); exit();}
		String s = "9"; int total = 9;
		for(int i = 1; i<=70; i++) {
			if(Long.parseLong(s + "9") > N) break;
			s += "9";
			total += 9;
		}
		for(int i = 1; i<=9; i++) {
			if(Long.parseLong(i + s) > N) break;
			total++;
		}
		println(total);
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBool() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readChar() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 21204