akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String args[])
    {
        FastReader obj = new FastReader();
        int n = obj.nextInt(),u = obj.nextInt();
        double arr[] = new double[n];
         double o = obj.nextDouble();
         arr[0] = (o*(o+1)/2)/o;
        for(int i=1;i<n;i++)
        {
            double k = obj.nextDouble();
            arr[i] = (k*(k+1)/2)/k + arr[i-1];
        }
        double max = arr[0];
        for(int i=0;i<n-u;i++)
        {
             if((arr[i+u]-arr[i])>max)
                max = arr[i+u]-arr[i];
        }
        if(u==n)max = arr[n-1];
        System.out.printf("%.12f",max);
    }
}


Measured memory_bytes: 42428
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		String board = s.nextLine();
		int count = 0;
		char cur = board.charAt(0);
		for(int x=1;x<board.length();x++) {
			if(board.charAt(x)!=cur) {
				count++;
				cur = board.charAt(x);
			}
		}
		
		System.out.println(count);
	}
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

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

	ll ans = 0;

	for (int i = 0; i < N - 1; ++i) {
		for (int j = i + 1; j < N; ++j) {
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(ll i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

vector<pair<ll,ll>> v[2510];
vector<ll> dist(2510,longinf);
vector<int> used(2510,0);
 
void bfs(){
  queue<int> q;
  q.push(0);
  dist[0]=0;
  while(q.size()){
    int x=q.front(); q.pop();
    if(used[x]>3000){ continue; }
    for(auto e:v[x]){
      if(dist[e.F] > dist[x] + e.S){
        dist[e.F] = dist[x] + e.S;
        used[e.F]++;
        q.push(e.F);
      }
    }
  }
}
 
int main(){
  int n,m;
  cin >> n >> m;
  rep(i,m){
    ll a,b,c;
    cin >> a >> b >> c; a--; b--;
    v[a].push_back({b,-c});
  }
  
  bfs();
  
  if(used[n-1]>1010){ 
    cout << "inf" << endl; 
  } else {
    ll ans = -dist[n-1];
    cout << ans << endl; 
  }
  return 0;
}

Measured memory_bytes: 4592
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<iostream>
#include<bitset>
#include<functional>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<random>
#include<ctime>
#include<complex>
using namespace std;
typedef long long LL;
mt19937 gene(233);
typedef complex<double> Complex;
#define fi first
#define se second
#define ins insert
#define pb push_back
inline char GET_CHAR(){
	const int maxn = 131072;
	static char buf[maxn],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,maxn,stdin),p1==p2)?EOF:*p1++;
}
inline int getInt() {
	int res(0);
	char c = getchar();
	while(c < '0') c = getchar();
	while(c >= '0') {
		res = res * 10 + (c - '0');
		c = getchar();
	}
	return res;
}

inline LL fastpo(LL x, LL n, LL mod) {
	LL res(1);
	while(n) {
		if(n & 1) {
			res = res * (LL)x % mod;
		}
		x = x * (LL) x % mod;
		n /= 2;
	}
	return res;
}

inline string itoa(int x, int width = 0) {
  string res;
  if(x == 0) res.push_back('0');
  while(x) {
    res.push_back('0' + x % 10);
    x /= 10;
  }
  while((int)res.size() < width) res.push_back('0');
  reverse(res.begin(), res.end());
  return res;
}
const int _B = 131072;
char buf[_B];
int _bl = 0;
inline void flush() {
	fwrite(buf, 1, _bl, stdout);
	_bl = 0;
}
__inline void _putchar(char c) {
	if(_bl == _B) flush();
	buf[_bl++] = c;
}
inline void print(LL x, char c) {
	static char tmp[20];
	int l = 0;
	if(!x) tmp[l++] = '0';
	else {
		while(x) {
			tmp[l++] = x % 10 + '0';
			x /= 10;
		}
	}
	for(int i = l - 1; i >= 0; i--) _putchar(tmp[i]);
	_putchar(c);
}
const int N = 2000033;
const int LOG = 20;
const int mod = 1e9 + 7;
const int inf = 1e9 + 7;
int n, m;
int fac[N], invfac[N];
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
	int k;
	string s;
	cin >> k >> s;
	int n = s.size();
	fac[0] = invfac[0] = 1;
	for(int i = 1; i <= k + n; i++) {
		fac[i] = fac[i - 1] * (LL) i  %mod;
	}
	invfac[k + n] = fastpo(fac[k + n], mod - 2, mod);
	for(int i = k + n - 1; i >= 1; i--) {
		invfac[i] = invfac[i + 1] * (LL)(i + 1)  %mod;
	}
	int ans =0;
	for(int i = 0; i <= k; i++) {
		ans = (ans + fastpo(26, i, mod) * fastpo(25, k - i, mod) % mod * fac[k - i + n - 1] % mod  * invfac[n - 1] % mod * invfac[k - i] % mod) % mod; 
	}
//	cout << fastpo(25, k, mod) % mod * fac[k + n] % mod  * invfac[n] % mod * invfac[k] % mod << endl;
	cout << ans << endl;
}






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

using namespace std;
int main() {
    array<int, 5> a;
    int time = 0;
    int zero_count = 0;
    REP(i, 5) {
        cin >> a[i];
        if(a[i]%10 == 0) {
            time += a[i];
            zero_count++;
        }
    }
    if(zero_count == 5) {
        cout << time << "\n";
        return 0;
    }
    sort(a.begin(), a.end(), [](int x, int y) {return (x%10) > (y%10);});
    int cnt = 0;
    while(cnt != 5-zero_count) {
        time += a[cnt];
        time += (10 - ( (a[cnt++] % 10) ) );
    }
    time -= (10-((a[--cnt]%10)));
    cout << time << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int i,A[251],n;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
      scanf("%d",&A[i]);
  }
 
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1) printf("parent key = %d, ",A[i/2]);
    if(2*i<=n) printf("left key = %d, ",A[2*i]);
    if(2*i+1<=n) printf("right key = %d, ",A[2*i+1]);
    printf("\n");
  }
  
  return 0;
}

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

const long double EPS = 1e-15;
const long double pi = acos(-1);
int x[110], y[110];
double s[110];

int dcmp(long double a) {
	if (a > EPS) return 1;
	if (fabs(a) < EPS) return 0;
	return -1;	
}

int main() {

	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%d%d", &x[i], &y[i]);
	for (int i = 1; i <= n; ++i) {
		int res = 0;
		for (int j = 1; j <= n; ++j)
			if (j == i) continue;
			else s[++res] = atan2((double)(y[j] - y[i]), (double)(x[j] - x[i]));
		sort(s + 1, s + res + 1);
		s[0] = s[res] - 2 * pi;
		double r = 0; for (int j = 1; j <= res; ++j) r = max(r, s[j] - s[j - 1]);
		r -= pi;
		if (dcmp(r) <= 0) puts("0.00000000000000000000");
		else printf("%.20f\n", (double)(r / (pi * 2)));
	}

	return 0;
}


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

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define DEB 0

int dp[1<<10][331];

int main(){
  int n,s;
  while(~scanf("%d%d",&n,&s)){
    rep(i,1<<10)rep(j,331)dp[i][j]=0;
    if( s>330 ){
      puts("0");
      continue;
    }

    rep(i,n){
      if( i==0 ){
	rep(k,10){
	  dp[1<<k][k] = 1;
	}
      }else{
	int comb = (1<<i)-1;
	while( comb < 1<<10 ){
	  rep(j,s+1)if( dp[comb][j] ){
	    rep(k,10)if( !(comb&(1<<k)) ){
	      if( j+(i+1)*k<=s ){
		dp[comb|(1<<k)][j+(i+1)*k] += dp[comb][j];
	      }
#if DEB
	      printf("__comb:%d|(1<<%d)][%d]\n",comb,k,j+(i+1)*k);
#endif
	    }
	  }
	  int x = comb & -comb;
	  int y = comb + x;
	  comb = ((comb&~y)/x>>1)|y;
#if DEB
	  printf("comb:%d i:%d\n",comb,i+1);
#endif
	}
      }
    }
    int ans = 0;
    int comb = (1<<n)-1;
    while( comb < 1<<10 ){
      ans += dp[comb][s];
      int x = comb & -comb;
      int y = comb + x;
      comb = ((comb & ~y)/x>>1)|y;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
import scala.io.StdIn
object Main extends App {
  val Seq(n, t) : Seq[Int] = StdIn.readLine.split(" ").map(_.toInt)
  val cts = Range(0, n)
    .map(_ => (StdIn.readLine.split(" ").map(_.toInt)))
    .map(s => (s(0), s(1)))
  println(cts.sorted.find(_._2 <= t).map(_._1.toString).getOrElse("TLE"))
}


Measured memory_bytes: 25420
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

double dp[21][200001];
int v[20];
int main(){
	int n;
	cin >> n;
	for(int i = 0 ; i < n ; i++) cin >> v[i];
	for(int i = 0 ; i < 21 ; i++)
		for(int j = 0 ; j <= 200000 ; j++)
			dp[i][j] = 1e10;
	
	dp[0][1] = 0;
	for(int i = 0 ; i < n ; i++){
		for(int j = 1 ; j <= 200000 ; j++){
			if(dp[i][j] != 1e10){
				for(int k = j ; k <= 200000 ; k+=j){
					dp[i+1][k] = min(dp[i+1][k],max(dp[i][j],fabs(v[i]-k)/v[i]));
				}
			}
		}
	}
	printf("%.10f\n",*min_element(dp[n],dp[n]+200001));
	
}

Measured memory_bytes: 32000
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

#ifndef ONLINE_JUDGE
	#define ONLINE_JUDGE
#endif

#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define pb push_back
#define mp make_pair
#define rep(i,n) for(i=0;i<n;i++)
#define repr(i,j,n) for(i=j;i<=n;i++)
#define endl '\n'
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<int> > graph;
const ll maxn = (ll) 1e5+9;
const ll mod = (ll) 1e9+7;
//ll a[maxn];
//ll dp[1024][1024];
string s,t;
int main()
{
	std::ios::sync_with_stdio(0);
	ll i,j,k,q,m,l,r,n;
	cin>>n;
	cin>>s;
	cin>>t;
	ll ans=2*n;
	rep(i,n) {
		k=2*n;
		rep(j,n) {
			if(i+j>=n)break;
			if(s[i+j]!=t[j])break;
			else k--;
		}
		ans=MIN(ans,k);
	}
	cout<<ans<<endl;
}

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

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

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


def main():
    s = S()
    def f(t):
        l = len(t)
        for i in range(l//2):
            if t[i] != t[-1 - i]:
                return False
        return True
    l = len(s)
    if f(s) and f(s[:l//2]) and f(s[l//2+1:]):
        return "Yes"

    return "No"


print(main())





Measured memory_bytes: 5524
#include<iostream>                                                                 
#include<cctype>
#include<string>
using namespace std;
int main(){
        int a,b;
        string str;
        cin>>a>>b>>str;
        for(int i=0;i<a+b+1;i++)
		{
                if(i>str.size())
				{
                        cout<<"No\n";
                        return 0;
                }   
                if(i<a){
                        if(!isdigit(str[i]))
						{
                                cout<<"No\n";
                                return 0;
                        }   
                }   
                if(i==a)
				{
                        if(str[i]!='-')
						{
                                cout<<"No\n";
                                return 0;
                        }   
                }   
                else{
                        if(!isdigit(str[i]))
						{
                                cout<<"No\n";
                                return 0;
                        }   
                }   
        }   
        cout<<"Yes\n";
        return 0;
}

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

struct bian{
	int x,to,next;
}edge[400001];
int cnt,head[100001],dis[100001];
bool vis[100001],f;

inline void add(int u,int v,int x){
	edge[++cnt].x=x,edge[cnt].to=v,edge[cnt].next=head[u],head[u]=cnt;
}

inline void dfs(int x,int fa){
	vis[x]=1;
	for(int i=head[x];i;i=edge[i].next)
		if(fa!=edge[i].to){
			if(dis[edge[i].to]!=0x7f7f7f7f){
				if(edge[i].x!=dis[edge[i].to]-dis[x]){
					puts("No");exit(0);
				}
			}else{
				dis[edge[i].to]=dis[x]+edge[i].x;
				dfs(edge[i].to,x);
			}
		}
}

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		add(l,r,d),add(r,l,-d);
	}
	memset(dis,0x7f,sizeof dis);
	for(int i=1;i<=n;i++)
		if(!vis[i]) dfs(i,i);
	cout<<"Yes";
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,C,D;
cin>>A>>B>>C>>D;
if(A+B==C+D){
cout<<"Balanced";
}
else if(A+B>C+D){
cout<<"Left";
}
else if(A+B<C+D){
cout<<"Right";
}
}




Measured memory_bytes: 3644
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll K,S;
	while(cin>>K>>S) {
		ll ans=0;
		REP(x, K+1) REP(y, K+1) {
			ll z=S-x-y;
			if(0<=z&&z<=K) ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
seed_seq seq{
        (uint64_t) chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count(),
        (uint64_t) __builtin_ia32_rdtsc(),
        (uint64_t) (uintptr_t) make_unique<char>().get()
};
mt19937 rng(seq);
int rnd(int l, int r) {return l + rng() % (r - l + 1);}
#define int long long
#define For(a, b, c) for(int a = b; a <= c; ++a)
#define Ford(a, b, c) for(int a = b; a >= c; --a)
#define Fv(a, b) for(auto &a : b)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define vt vector<int>
#define vpi vector<pair<int, int>>
#define all(a) a.begin(), a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define vt vector<int>
#define vpi vector<pair<int, int>>
#define bit(x, i) (x >> (i - 1) & 1ll)
#define onbit(x, i) (x | (1ll << (i - 1)))
#define offbit(x, i) (x & ~(1ll << (i - 1)))
#define fixa(a) for(auto &i : a) cerr << i << ' '; cerr << '\n';
#define fixn(a, l, r) For(i, l, r) cerr << a[i]; cerr << '\n';
#define debug(x) cerr << #x << ' ' << x << '\n'
#define inp(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define fasty ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define fix(i) cerr << i << '\n';
#define task "npairs"
main(){
    int n;
    cin>>n;
    For(i,1,9){
        if(n%i==0){
            if(n/i<=9) return cout<<"Yes",0;
        }
    }
    cout<<"No";
}


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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    ll N,K;
    cin>>N>>K;
    vector<ll> mm(K,0);
    for (int i=1;i<=N;i++) {
        mm[i%K]++;
    }
    ll ans = 0;
    ans += mm[0] * mm[0] * mm[0];
    if (K%2==0) ans += mm[K/2] * mm[K/2] * mm[K/2]; 
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	char a,b;
	cin>>a>>b;
	if(a=='H'){
		cout<<b<<endl;
	}
	else{
		if(b == 'H') cout<<'D'<<endl;
		else cout<<'H'<<endl;
	}
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

int main(){
	int n,ans=0;
	cin>>n;
	while(n--){
		int a;
		cin>>a;
		mp[a]++;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++){
		if((it->second)<(it->first)) ans+=it->second;
		else ans+=(it->second)-(it->first);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() 
{
	int n;
	cin>>n;
	int dp[n][3];
	for(int i=0;i<n;i++)
	{
	    for(int j=0;j<3;j++)
	    {
	        cin>>dp[i][j];
	    }
	}
	
	for(int i=1;i<n;i++)
	{
	    dp[i][0]=max(dp[i-1][1]+dp[i][0],dp[i-1][2]+dp[i][0]);
	     dp[i][1]=max(dp[i-1][0]+dp[i][1],dp[i-1][2]+dp[i][1]);
	      dp[i][2]=max(dp[i-1][0]+dp[i][2],dp[i-1][1]+dp[i][2]);
	}
	
	
	

	cout<<max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]) );
	return 0;
}


Measured memory_bytes: 1408
open Batteries
open BatPrintf

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_listn n cnv =
  (0 --^ n) |> Enum.map (fun _ -> (cnv % read_line) ())

let bsearch_ge arr a =
  let l = Array.length arr in
  match Array.bsearch Int.ord arr a with
  | `All_lower -> l
  | `All_bigger -> 0
  | `Just_after n -> l - n -1
  | `At n -> l - n
  | `Empty -> 0

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let square x = x * x

let dbg n = Printf.printf "%s\n" @@ dump n; n

module Comb = struct
  let prime = 1_000_000_000+7

  let ( * ) a b = a * b mod prime
  let (-) a b = (a+prime - b) mod prime

  let rec pow n m =
    if m = 0 then 1
    else if m mod 2 = 0 then pow (n*n mod prime) (m/2)
    else n * pow (n*n mod prime) (m/2) mod prime

  let fact n =
    let rec aux m ret =
      if m = 0 then ret
      else aux (m-1) @@ (m*ret) mod prime in
    aux n 1

  let comb n k =
    let x = Enum.fold ( * ) 1 (n-k+1 -- n) in
    x * (pow (fact k) (prime - 2))
end

let (n, a, b) = scan "%d %d %d" Tuple.Tuple3.make


let () =
  let open Comb in
  pow 2 n
  |> (fun x -> (-) x 1)
  |> (fun x -> (-) x @@ comb n a)
  |> (fun x -> (-) x @@ comb n b)
  |> printf "%d\n"


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

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; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  ll k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      puts("OK");
      return 0;
    }
  }
  puts("NG");

  return 0;
}


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

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

	if (n % 4 == 0 || n % 7 == 0) {
		cout << "Yes" << endl;
		return 0;
	}

	for (int i = 0; i <= n / 4; i++) {
		for (int j = 0; j <= n / 7; j++) {
			if (4 * i + 7 * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    boolean chmax ( llong &a, llong b ) { return a<b ? a=b, true : false; }
    boolean chmin ( llong &a, llong b ) { return b<a ? a=b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    boolean exists[10001000];

    signed call_of_Cthulhu( signed datum ) {

        int s;
        read s;
        exists[s] = true;
        int prev = s;
        for ( int i = 1; true; i++ ) {
            if ( prev & 1 ) {
                prev = prev * 3 + 1;
            }
            else {
                prev /= 2;
            }
            if ( exists[prev] ) {
                echo i+1 fin;
                return 0;
            }
            exists[prev] = true;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


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();
		
		long sum = 0;
		
		for(int i = 0; i < N; i++) {
			sum += sc.nextLong();
		}
		
		System.out.println(sum - N);
	}
}


Measured memory_bytes: 25712
#include<iostream>
#include<vector>
#include <numeric>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> v;
    for (int i = 0; i < N; i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    cout << accumulate(v.begin(), v.end(), 0) - N << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PUTS(x) cout << (x) << endl;
constexpr auto L = 50; // 2進法表示で最大50桁とっておく
int main() {
    Int n, k;
    cin >> n >> k;
    Int counts[L] = {0}; // 各桁の1の個数をカウント（左ほど小さい桁）
    rep(i, n) {
        Int a;
        cin >> a;
        int j = 0;
        // 2進法での各桁の1の数をカウントして言うk
        while (a > 0) {
            if (a % 2 == 1) counts[j]++;
            a /= 2;
            j++;
        }
    }
    // 最大化するための理想の数を求める（右ほど小さい桁）
    int ideal[L] = {0};
    for (int i = 0; i < L; i++) {
        int a = counts[i]; // 1の個数
        int b = n - a; // 0の個数
        // 1の方が少なければ1，0の方が少なければ0，同数なら0を理想とする（同数で0を理想とするのは理想をできるだけ下げるため）
        ideal[L - 1 - i] = (a < b) ? 1 : 0;
    }
    // 定義域の最大値kを2進法表示する（右ほど小さい桁）
    int maxdigits[L] = {0};
    int j = L - 1;
    while (k > 0) {
        if (k % 2 == 1) maxdigits[j] = 1;
        k /= 2;
        j--;
    }
    // f(x)の最大値を与えるxの値の2進法表示(50桁)を求める（左ほど小さい桁）
    int results[L] = {0};
    bool flag = false; // 既に最大値を下回ることが確定し自由に選べる桁に突入したことを示すフラグ
    for (int i = 0; i < L; i++) { // 上の桁から順に見てゆく
        int q = L - 1 - i;
        int a = ideal[i]; // 理想値のi桁目
        int m = maxdigits[i]; // 最大値kのi桁目
        if (flag) { // 自由に選べる桁なら
            results[q] = a; // 理想値をそのまま入れる
        } else { // まだ最大値を下回ることが未定の場合
            if (m == 0) { // 最大値の桁が0なら問答無用で0にするしかない
                results[q] = 0;
            } else if (a == 1) { // 最大値が1，理想値も1なら1にする（まだ確定しない）
                results[q] = 1;
            } else { // 最大値が1，理想値が0なら0にする（この後の桁は自由に選べることが確定）
                results[q] = 0;
                flag = true;
            }
        }
    }
    Int ans = 0;
    for (int i = 0; i < L; i++) {
        int d = results[i]; // 求めるxのi桁目
        int one = counts[i]; // その桁の1の個数
        int zero = n - one; // その桁の0の個数
        ans += (1LL << i) * ((d == 1) ? zero : one);
    }
    PUTS(ans);
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
from functools import reduce
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#agc018 getting difference
n,k=mii()
arr=limii()
#print(arr)
def gcd1(numbers):
    return reduce(gcd,numbers)

p=gcd1(arr)

if k%p==0 and k<=max(arr):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int ar[n],a[n];
    for(int i=0;i<n;i++){
        cin >> ar[i];
        a[i]=ar[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(ar[i]==a[n-1]){
            cout << a[n-2] << "\n";
        }
        else{
            cout << a[n-1] << "\n";
        }
    }


    return 0;
}


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

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Library

//
int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    for(int i = 0; i < m; ++i){
        cin >> b[i];
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        vector<int> a(m);
        for(int i = 0; i < m; ++i){
            cin >> a[i];
        }
        ll tmp = c;
        for(int i = 0; i < m; ++i){
            tmp += a[i] * b[i];
        }
        if(tmp > 0){
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}
const int MAXN=15;
const int CHARSET=26;
int n,m,num[MAXN][CHARSET];
char s[MAXN][MAXN];
bool visit[MAXN];
int tmp[MAXN];
bool same_l(int a,int b)
{
	for (int i=1;i<=n;i++)
		if (s[tmp[i]][a]!=s[tmp[n+1-i]][b])
			return false;
	return true;
}
bool check()
{
	bool used[MAXN];
	memset(used,0,sizeof(used));
	if (m&1)
	{
		int cnt=0;
		for (int i=1;i<=m;i++)
		{
			if (used[i]) continue;
			int j;
			for (j=1;j<=m;j++)
			{
				if (used[j] || i==j) continue;
				if (same_l(i,j))
					break;
			}	
			if (j==m+1)
			{
				cnt++;
				used[i]=1;
				if (!same_l(i,i))
					return false;
			}
			else
				used[i]=used[j]=1;
		}
		if (cnt>1) return false;
		return true;
	}
	else
	{
		for (int i=1;i<=m;i++)
		{
			if (used[i]) continue;
			int j;
			for (j=1;j<=m;j++)
			{
				if (used[j] || i==j) continue;
				if (same_l(i,j))
					break;
			}
			if (j==m+1) return false;
			else used[i]=used[j]=1;
		}
		return true;
	}
}
bool same_h(int a,int b)
{
	for (int i=0;i<CHARSET;i++)
		if (num[a][i]!=num[b][i])
			return false;
	return true;
}
void dfs(int sz)
{
	if (sz==(n+1)/2+1)
	{
		if (check())
		{
			cout<<"YES";
			exit(0);
		}
		return ;
	}
	if (n&1 && sz==(n+1)/2)
	{
		for (int i=1;i<=n;i++)
		{
			if (visit[i]) continue;
			int cnt=0;
			tmp[sz]=i;
			dfs(sz+1);
			return ;
		}
	}
	for (int i=1;i<=n;i++)
	{
		if (visit[i]) continue;
		for (int j=1;j<=n;j++)
		{
			if (visit[j] || j==i) continue;
			if (same_h(i,j))
			{
				tmp[sz]=i,tmp[n+1-sz]=j;
				visit[i]=visit[j]=1;
				dfs(sz+1);
				visit[i]=visit[j]=0;
			}
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		for (int j=1;j<=m;j++)
			num[i][s[i][j]-'a']++;
	}
	dfs(1);
	cout<<"NO";
	return 0;
}

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

int main(void)
{
	vector<int> w, k;
	vector<int> max_w, max_k;
	
	w.resize(10);
	k.resize(10);
	max_w.resize(3);
	max_k.resize(3);
	
	for (int i = 0; i < 10; i++){
		cin >> w[i];
	}
	for (int i = 0; i < 10; i++){
		cin >> k[i];
	}
	
	for (int i = 0; i < 3; i++){
		max_w[i] = *max_element(w.begin(), w.end());
		w.erase(find(w.begin(), w.end(), max_w[i]));
	}
	
	for (int i = 0; i < 3; i++){
		max_k[i] = *max_element(k.begin(), k.end());
		k.erase(find(k.begin(), k.end(), max_k[i]));
	}
	
	cout << max_w[0] + max_w[1] + max_w[2] << " " << max_k[0] + max_k[1] + max_k[2] << endl;
}

Measured memory_bytes: 1216
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N, M;

		N = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String S = sc.next();
			if (map.containsKey(S)) {
				map.put(S, map.get(S) + 1);
			} else {
				map.put(S, 1);
			}
		}

		M = sc.nextInt();
		for (int i = 0; i < M; i++) {
			String S = sc.next();
			if (map.containsKey(S)) {
				map.put(S, map.get(S) - 1);
			} else {
				map.put(S, -1);
			}
		}

		int max = 0;
		for(String string : map.keySet()) {
			max = Math.max(max, map.get(string));
		}

		System.out.println(max);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

int main() {
	int n;
	long long ans = 0;
	std::vector<int> v, p;
	std::map<int, int> pos; // value, pos

	std::cin >> n;
	v.resize(n, 0);
	
	for (int i = 0; i < n; i++) {
		std::cin >> v[i];
	}

	p = v;
	std::sort(p.begin(), p.end());

	for (int i = 0; i < p.size(); i++) {
		pos[p[i]] = i % 2;
	}

	for (int i = 0; i < v.size(); i++) {
		if (i % 2 == pos[v[i]]) {
			pos.erase(pos.find(v[i]));
		}
	}

	std::cout << pos.size() / 2 << std::endl;

	return 0;
}

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

#define N 42
char s[N][N];

long long dp[N][N][N][N], ep[N][N][N][N];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n;
	cin>>n;
	n *= 2;
	for (int i = 0; i < n; i ++) {
		cin>>s[i];
		for (int j = 0; j < n; j ++) s[i][j] -= '0';
	}
	for (int i = 1; i <= n; i ++) for (int j = 1; j <= n; j ++) dp[i][i-1][j][j-1] = ep[i][i-1][j][j-1] = 1;
	for (int d = 1; d < n; d ++) {
		for (int c = d; c >= 1; c --) {
			for (int b = 1; b < c; b ++) {
				for (int a = b; a >= 1; a --) {
					for (int p = a; p <= b; p ++) {
						for (int q = d; q >= c; q --) {
							if (s[p][q]) dp[a][b][c][d] += ep[a][p-1][p+1][b] * ep[c][q-1][q+1][d];
							ep[a][b][c][d] += dp[a][p][q][d] * ep[p+1][b][c][q-1];
						}
					}
				}
			}
		}
	}
	long long ans = 0;
	for (int a = 1; a < n; a ++) if (s[0][a]) {
		ans += ep[1][a-1][a+1][n-1];
	}
	cout<<ans;
}


Measured memory_bytes: 17028
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main()
{
	char s[200010];
	int n = 0, i;
	scanf("%s", s);
	for (i = 0; i < strlen(s); i++)
	{
		n = n + (s[i] - '0');
	}
	if (n %9== 0)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
	return 0;
}

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

using namespace std; 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>; 

#define INF 10000000000
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

//#define DEBUG

int main_(){
  int A,B;
  cin>>A>>B;
  map<int,int>m;
  for(int i=2;i<=13;i++)m[i]=i-2;
  m[1]=12;
  if(m[A]>m[B])cout<<"Alice"<<endl;
  else if(m[A]<m[B])cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
  return 0;
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef DEBUG
  vector<string>test;
  /*
   * input for debug
   */
  for(int i=0;i<test.size();++i){
    stringbuf buf;
    streambuf*out=cout.rdbuf(&buf);
    cout<<test[i]<<flush;
    cout.rdbuf(out);
    streambuf*in=cin.rdbuf(&buf);
    main_();
    cin.rdbuf(in);
    cout<<endl;
  }
#else
  main_();
#endif

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln = '\n';

const int mx=200010;
const ll mod=1e9+7;

int main(){
  char n;
  cin >> n;
  if('A'<=n && n<='Z'){
    cout << "A" << ln;
  } else {
    cout << "a" << ln;
  }


  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n >> m;
    VP p(n);
    REP(i,0,n) cin >> p[i].first >> p[i].second;
    sort(all(p));
    LL sum = 0;
    REP(i,0,n) {
        if (m <= 0) break;
        int buy = min(m, p[i].second);
        m -= buy;
        sum += 1LL * p[i].first * buy;
    }
    cout << sum << endl;
}

int main() {
    solve();
    
    return 0;
}

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

priority_queue<int> pq;

int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int k;
	scanf("%d",&k);
	pq.push(a);
	pq.push(b);
	pq.push(c);
	while(k--){
		int atas= pq.top();
		pq.pop();
		pq.push(2*atas);
	}
	int has=0;
	while(!pq.empty()){
		has+=pq.top();
		pq.pop();
	}
	printf("%d\n",has);
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A,B,C;

int hoge(int a,int b) {
	if(a>b) return a-b;
	return (b-a+1)/2;
}

void solve() {
	int i,j,k,l,r,x,y,z; string s;
	
	cin>>A>>B>>C;
	int mi=1010;
	FOR(x,100) FOR(y,100) FOR(z,100) {
		int AA=A+x+y;
		int BB=B+y+z;
		int CC=C+z+x;
		if(abs(AA-BB)%2) continue;
		if(abs(BB-CC)%2) continue;
		if(abs(CC-AA)%2) continue;
		int DD=max({AA,BB,CC});
		mi=min(mi,x+y+z+(DD-AA)/2+(DD-BB)/2+(DD-CC)/2);
		
		
	}
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	var sc = bufio.NewScanner(os.Stdin)
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	var (
		a int
		b int
	)
	fmt.Sscanf(s, "%d %d", &a, &b)
	ans, surplus := (a + b) / 2, (a + b) % 2
	if surplus == 0 {
		fmt.Println(ans)
		return
	}
	fmt.Println("IMPOSSIBLE")
}


Measured memory_bytes: 640
import math

def is_prime(x):
  if x <= 1:
    return False
  max_judge = math.sqrt(x)
  count = 2
  while(count < max_judge):
    if x % count == 0:
      return False
    count+=1
  return True
 
x = int(input())
 
judge_prime = False

while(True):
  if is_prime(x):
    break
  x+=1

print(x)

Measured memory_bytes: 3060
import java.math.*;
import java.util.*;
public class Main 
{
	public static void main(String arg[])
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			BigInteger b = in.nextBigInteger();
			if(b.intValue()==-1)
				return;
			System.out.println(b.toString(4));
		}
	}

}

Measured memory_bytes: 12000
#include <cstdio>
using namespace std;

int toint(int y, int m, int d){
	return y * 400 + m * 32 + d;
}

int main(){
	int y, m, d;
	int mj = toint(1868, 9, 8);
	int ts = toint(1912, 7, 30);
	int sw = toint(1926, 12, 25);
	int hs = toint(1989, 1, 8);

	while(scanf("%d%d%d", &y, &m, &d) == 3){
		const char *fmt = "pre-meiji\n";
		int u = toint(y, m, d);

		if(u >= hs){
			fmt = "heisei %d %d %d\n";
			y -= 1988;
		}
		else if(u >= sw){
			fmt = "showa %d %d %d\n";
			y -= 1925;
		}
		else if(u >= ts){
			fmt = "taisho %d %d %d\n";
			y -= 1911;
		}
		else if(u >= mj){
			fmt = "meiji %d %d %d\n";
			y -= 1867;
		}
		printf(fmt, y, m, d);
	}
}

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll N;
    string S;
    scanf("%lld", &N);
    cin >> S;

    if ( N % 2 != 0 ){
        printf("No\n");
        return 0;
    }
    else{
        for ( int i = 0; i < N / 2; i++){
            if ( S.at(i) != S.at(i+N/2) ){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 256
//Code is like humor. When you have to explain it, it’s bad.
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define pii pair<int,int>
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first
int32_t main()
{
    fastio;
    int T,n,m,i,j,k,a,b,c,d;
    cin>>a>>b>>c>>d;

    i=0;
    while(a>0 and c>0)
    {
        if(i&1)
            a-=d;
        else
            c-=b;
        i++;
    }
    if( a>0 )
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
using P=pair<int,int>;
typedef unsigned long long ull;
typedef long long ll;
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; }
const ll INF=1e18;
const ll MOD=1e9+7;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  int n;
  cin >> n;
  int two=0,four=0,odd=0;
  rep(i,n){
    ll a;
    cin >> a;
    if(a&1)odd++;
    else{
      if(a%4==0)four++;
      else two++;
    }
  }
  bool ok=false;
  if(four>=odd)ok=true;
  else if(four+1==odd){
    if(four+odd==n && n>1)ok=true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
while True:
    H,W = map(int,input().split())
    if H == 0: break
    d0 = H*H + W*W
    ans = (10**9,H,W)
    for w in range(2,151):
        for h in range(1,w):
            d = h*h + w*w
            if (d,h,w) < (d0,H,W) or (h,w) == (H,W): continue
            ans = min(ans, (d,h,w))
            break
    print('{0} {1}'.format(ans[1], ans[2]))

Measured memory_bytes: 5596
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int[] sums = new int[n];
		for (int i = 1; i < n; i++) {
		    if (arr[i - 1] == 'A' && arr[i] == 'C') {
		        sums[i]++;
		    }
	        sums[i] += sums[i - 1];
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int left = sc.nextInt();
		    int right = sc.nextInt();
		    int count = sums[right - 1] - sums[left - 1];
		    sb.append(count).append("\n");
		}
		System.out.print(sb);
	}
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

#define MOD 1000000007

long binary_square(int x, int n);

int main(){
    int x;
    cin >> x;
    vector<long> V;
    rep(i, 10000){
        //cout << i << " : " << binary_square(i, 5) << endl;
        V.push_back(binary_square(i, 5));
    }

    rep(i, 10000){
        rep2(j, i, 10000){
            if(V[j]-V[i]==x){
                cout << j << " " << i << endl;
                return 0;
            }
            if(V[i]+V[j]==x){
                cout << j << " " << -i << endl;
                return 0;
            }
        }
    }
    return 0;
}

long binary_square(int x, int n){
    // int m = MOD;
    long ans = 1;
    while(n){
        if(n%2==1){
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

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

int main() {
	int x,y;
	cin>>x>>y;
	for (int i = 0; i <= x; ++i) {
		for (int j = 0; j <= x; ++j) {
			if (i+j ==x && 2*i+4*j == y) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

}

Measured memory_bytes: 3632