akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
//const ll MOD=1000000007;
const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 0};

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

//https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,S; cin>>N>>S;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  
  //dp
  vector<vector<ll>> table(N,vector<ll>(S+1,-1));
  function<ll(ll,ll)> dp=[&](ll i,ll j){
    if(i<0) return (j==0?1LL:0LL);
    if(table[i][j]>-1LL) return table[i][j];
    
    ll ret=0LL;
    ret+=2*dp(i-1,j);
    if(j-A[i]>=0) ret+=dp(i-1,j-A[i]);
    
    return table[i][j]=ret%MOD;
  };
  
  ll ans=dp(N-1,S); //ans--; if(ans<0) ans=MOD-1;
  
  cout<<ans<<'\n';
  
  //rep(i,N) {rep(j,S+1) {if(j!=0) cout<<" "; cout<<dp(i,j);} cout<<'\n';}
  
  return 0;
}


Measured memory_bytes: 73916
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  ll d, g;
  cin >> d >> g;
  vector<ll> p(d);
  vector<ll> c(d);
  g /= 100;
  REP(i, d) {
    cin >> p[i] >> c[i];
  }
  REP(i, d) {
    c[i] /= 100;
  }
  ll ans = 1e9;
  REP(i, 1<<d) {
    ll cnt = 0;
    ll score = 0;
    REP(j, d) {
      if(i & 1 << j) {
        cnt += p[j];
        score += c[j] + p[j]  * (j+1);
      }
    }
    if(score >= g) {
      ans = min(ans, cnt);
      continue;
    }
    REP(j, d) {
      if(i & 1 << (d-1-j)) continue;
      ll m = ((g-score)  + (d-j-1)) / (d-j);
      if(p[d-j-1] <= m) {
        cnt += p[d-1-j];
        score += p[d-1-j] * (d-j);
      }
      else {
        cnt += m;
        score += m * (d-j);
        ans = min(ans, cnt);
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

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

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

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

struct grid
{
	ll to, cost;
};

vector<vector<grid>> G;
ll N, M;

int main(int argc, char **argv)
{
	cin >> N >> M;
	G.resize(N);
	REP(i, M)
	{
		ll a, b, c; cin >> a >> b >> c;
		--a, --b;
		G[a].push_back(grid{b, c});
		G[b].push_back(grid{a, -c});
	}

	vector<ll> dist(N, INF);
	vector<bool> mark(N, false);
	queue<ll> que;
	REP(i, N)
	{
		if (dist[i] != INF) continue;
		que.push(i);
		dist[i] = 0;
		while (!que.empty())
		{
			ll v = que.front(); que.pop();
			for (auto &p : G[v])
			{
				ll nv = p.to;
				ll c = p.cost;

				if (dist[nv] == INF)
				{
					dist[nv] = dist[v] + c;
					que.push(nv);
				}
				else if (dist[nv] != dist[v] + c)
				{
					std::cout << "No" << std::endl;
					return 0;
				}

				
			}
		}
	}

	std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 14080
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    double n,m,d;
    cin >> n >> m >> d;
    double ans;
    if ( d == 0 ) {
        ans = (m-1)/n;
    }
    else {
        ans = (2*n-2*d)/(n*n)*(m-1);
    }

    printf( "%.10f\n", ans );   

    return 0;
}

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

struct dish {
  int time;
  int taste;
};
bool operator < (const dish &l, const dish &r) { return l.time < r.time; }

int main() {
  int n, t;
  cin >> n >> t;
  dish menu[n+1];

  for ( int i = 1; i <= n; i++ ) {
    int time, taste;
    cin >> time >> taste;
    menu[i] = {time, taste};
  }
  sort(menu+1, menu + n+1);

  vector<vector<int>> dp(n+1, vector<int>(t, 0));
  for ( int i = 1; i <= n; i++ ) {
    for ( int j = 0; j < t; j++ ) {
      dp[i][j] = max(dp[i][j], dp[i-1][j]);
      if ( j + menu[i].time < t ) {
        dp[i][j + menu[i].time] = max(dp[i-1][j + menu[i].time], dp[i-1][j] + menu[i].taste);
      }
    }
  }

  int ans = 0;
  for ( int i = 1; i <= n; i++ ) {
    ans = max(ans, dp[i-1][t-1] + menu[i].taste);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

int main() {
    ll N, ans = 1e18;
    cin >> N;
    for (ll i = 1; i * i <= N; i++) {
        //cout << i << " ";
        if (N % i == 0) {
            ans = min(ans, i + N / i - 2);
        }
    }
    cout << ans <<  "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,A,B;
	int f,i,t;
	cin>>k;
	cin>>A>>B;
	for(i=1;i<=B;i++)
	{
		t=i*k;
		if(t>=A&&t<=B)
	    {
		f=1;
		break;
     	}
		else
		f=0;
	}
	if(f==1)
	cout<<"OK";
	else
	cout<<"NG";
	
}

Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()

	var monsters []int
	for i := 0; i < n; i++ {
		monsters = append(monsters, readInt())
	}

	fmt.Println(solve(n, monsters))
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readInt() int {
	i, e := strconv.Atoi(read())
	if e != nil {
		panic(e)
	}
	return i
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func solve(n int, monsters []int) int {
	m := make(map[int]int)
	slim := make([]int, 0)
	for _, element := range monsters {
		if _, ok := m[element]; !ok {
			m[element] = 0
			slim = append(slim, element)
		}
	}
	if len(slim) == 1 {
		return slim[0]
	}
	answer := gcd(slim[0], slim[1])
	for i, monster := range slim {
		if i <= 1 {
			continue
		}
		answer = gcd(answer, monster)
	}
	return answer

}

Measured memory_bytes: 11008
def solve():
    N, M = map(int, input().split())
    
    if N == 1 and M == 1:
        print(1)
        exit()
    
    if M < N:
        N, M = M, N
    if N == 1:
        print(M - 2)
        exit()
    
    print((N - 2) * (M - 2))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
long long rec(long long b, long long n) {
  if (n < b) return n;
  return rec(b, n / b) + n % b;
}
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, s;
  cin >> n >> s;
  if (s > n) {
    cout << -1 << endl;
    return 0;
  }
  if (s == n) {
    cout << n + 1 << endl;
    return 0;
  }
  for (long long b = 2; b * b <= n; b++) {
    if (s == rec(b, n)) {
      cout << b << endl;
      return 0;
    }
  }
  long long ans = 1LL << 60;
  for (long long p = 1; p * p <= n; p++) {
    long long b = (n - s) / p + 1;
    if (b == 1) continue;
    if (s == rec(b, n)) {
      ans = min(ans, b);
    }
  }
  cout << (ans == 1LL << 60 ? -1 : ans) << endl;
  return 0;	
}

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

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

	if(m%n==0){
		cout<<m/n;
		return 0;
	}
	int res = 1;
	for(int i = 2; m/i >= n; i++){
		if(m%i==0){
			res = max(res,i);
		}
	}

	cout<<res;
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = s.count('R') * s.count('G') * s.count('B')
for i in range(n - 2):
  for j in range(1, (n - i + 1) // 2):
    if s[i] != s[i+j] and s[i+j] != s[i+j*2] and s[i+j*2] != s[i]:
      ans -= 1
print(ans)

Measured memory_bytes: 9140
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        HashSet<Integer> ac = new HashSet<Integer>();
        HashMap<Integer,Integer> wa = new HashMap<Integer,Integer>();
        for(int i = 0; i < m; i++){
            int num = sc.nextInt();
            String s = sc.next();
            if(s.equals("AC")){
                ac.add(num);
            }else{
                if(ac.contains(num)){
                    continue;
                }else{
                    if(wa.containsKey(num)){
                        wa.put(num,wa.get(num)+1);
                    }else{
                        wa.put(num,1);
                    }
                }
            }
        }
        int was = 0;
        for(Map.Entry<Integer,Integer> entry : wa.entrySet()){
            if(ac.contains(entry.getKey())){
                was += entry.getValue();   
            }
		}
        System.out.print(ac.size() + " ");
        System.out.println(was);
    }
}

Measured memory_bytes: 68348
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	int n,m,t,sum=0;
	vector<int> a;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>t;
		sum+=t;
	}
	cout<<max(-1,n-sum)<<endl;
	return 0;
}

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

int main(void){
	int n,q,sum=0;
	vector<int> s;
	int a[20],m[200],mflag[200]={0};
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%d",&m[i]);
	}
	for(int i=0;i<(1<<n);i++){
		sum = 0;
		for(int j=0;j<n;j++){
			if(1 & i>>j){
				s.push_back(a[j]);
			}
		}
		for(int j=0;j<s.size();j++){
			sum += s[j];
		}
		for(int j=0;j<q;j++){
			if(sum == m[j])mflag[j]=1;
		}
		s.clear();
	}
	for(int i=0;i<q;i++){
		if(mflag[i]==1){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	return 0;
}


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

int main() {
    int s;
    cin >> s;
    int N = 1e9;
    int i;
    for (int i = 1; i < N; ++i) {
        if (s == 1 || s == 2 || s== 4) {
        cout << i+3 << endl;
        return 0;
        }else if ( s % 2 == 0)
            s = s/2;
        else
            s = 3 * s + 1;

    }
    }


Measured memory_bytes: 256
n,m = map(int,input().split())
a = []
for i in range(m):
    temp = int(input())
    a.append(temp)

mod = int(1e9+7)
dp = [0 for i in range(n+1)]
dp[0] = 1
ind = 0

for i in range(1,n+1):
    if ind < m and a[ind] == i:
        dp[i] = 0
        ind += 1
    else:
        if i != 1:
            dp[i] = dp[i-1] + dp[i-2]
        else:
            dp[i] = dp[i-1]
print(int(dp[-1]%mod))

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

const int MAX_N = 10000;
int N;
int dp[MAX_N+1];

int main()
{
  dp[0] = 1;
  erep(i, 1, MAX_N) dp[i] = dp[i-1] + i;


  while(~scanf(" %d", &N)){
    printf("%d\n", dp[N]);
  }

  return 0;
}

Measured memory_bytes: 1224
n,m,l=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for i in range(m)]
C=[[0]*l for i in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j]+=A[i][k]*B[k][j]
    print(*C[i])


Measured memory_bytes: 7032
#include <stdio.h>
#include <limits.h>

int abs(int n){return n>0?n:-n;}

int main()
{
    char s[15];
    scanf("%s",s);
    int min=INT_MAX;
    for(int i=0;;i++)
    {
        if(s[i+2]=='\0') break;
        int tmp=0;
        tmp+=(s[i]-'0')*100;
        tmp+=(s[i+1]-'0')*10;
        tmp+=(s[i+2]-'0');
        if(min>abs(tmp-753)) min=abs(tmp-753);
    }
    printf("%d\n",min);
}

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

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

    int ans = 0;
    for (int i = 1; i <= 100; i++){
        int cnt = 0;
        for (int j = 0; j < n; j++){
            if(i <= p[j]){
                cnt++;
            }
        }

        if(i <= cnt){
            ans = i;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3104
import numpy as np

n, W = map(int, input().split())
w = []
v = []
for i in range(n):
  w_, v_ = map(int, input().split())
  w.append(w_)
  v.append(v_)
  
dp = np.zeros(W+1, dtype=np.int64)
for i in range(n):
  dp[w[i]:] = np.maximum(dp[:-w[i]]+v[i], dp[w[i]:])
print(dp[W])

Measured memory_bytes: 29768
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main() {
    int x[3];
    cin >> x[0] >> x[1] >> x[2];
    sort(x, x + 3);
    int A = x[0];
    int B = x[1];
    int C = x[2];
    int m = B - A;
    int n = C - B;
    int ans = 0;
    if (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
        if (m == 0 && n == 0) {
            cout << -1 << endl;
            return 0;
        }
        while (m % 2 == 0 && n % 2 == 0) {
            m = m / 2;
            n = n / 2;
            ans++;
        }
    }
    cout << ans << endl;
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

bool palin(string S){//回文判定
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}



int main(){
  int N;
  cin >> N;
  vector<vector<int>> A(2, vector<int>(N));
  rep(i,2){
    rep(j,N){
      cin >> A[i][j];
    }
  }
  int ans = 0;
  int sumu = 0;
  int sums = 0;
  for(int j = 0;j<N;j++){
    sumu += A[0][j];
    for(int k = j;k<N;k++){
      sums += A[1][k];
    }
    ans = max(ans,sumu+sums);
    sums = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N;
  cin >> N;
  cout << N * 800 - N / 15 * 200 << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,x,y; cin>>a>>b>>c>>x>>y;
  ll ans=a*x+b*y;
  if(x<y){
    swap(x,y);
    swap(a,b);
  }
  chmin(ans,c*y*2+(x-y)*a);
  chmin(ans,c*x*2);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from functools import lru_cache


@lru_cache(maxsize=None)
def gcd(a, b):
    if a < b:
        a, b = b, a
    if a % b == 0:
        return b
    return gcd(b, a % b)


def main():
    ans = 0
    k = int(input())
    for i in range(1, k+1):
        for j in range(1, k+1):
            for l in range(1, k+1):
                ans += gcd(gcd(i, j), l)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int a[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i)
        cin >> a[i];

    return true;
}

void solve() {
    multiset<int> ms;

    for (int i = 0; i < n; ++i)
        ms.insert(a[i]);

    auto ans = 0;

    for (int k = 30; k > 0; --k)
        while (ms.size() >= 2 && *ms.rbegin() >= (1 << (k - 1))) {
            auto x = *ms.rbegin();
            ms.erase(--ms.end());

            if (ms.count((1 << k) - x)) {
                ms.erase(ms.find((1 << k) - x));
                ++ans;
            }
        }

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);  
  for(i=0;i<n;i++)cin>>a[i];
  ll sum=0;
  for(i=0;i<n;i++)sum+=a[i];
  for(i=0;i<n-1;i++){
    buf+=a[i];
    chmin(res2,abs(2*buf-sum));
  }
  cout<<res2<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

long long n, d;

int main () {
    cin >> n >> d;
    if ( n % ( 2 * d + 1 ) == 0 ) {
        cout << n / ( 2 * d + 1 );
    }
    else {
        cout << n / ( 2 * d + 1) + 1;
    }
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n)for(int i=0; i<n; i++)
using namespace std;

int main(){
    int n, xyz[3]{};
    cin >> n;
    for(int a=1; a<=n; a++){
        int ans=0;
        for(int i=1; i*i<=a; i++){
            for(int j=i; j*j<=a; j++){
                for(int k=j; k*k<=a; k++){
                    if(i*i + j*j + k*k + i*j + j*k+ k*i == a){
                        if(i==j && j==k) ans+=1;
                        if(i==j && j!=k) ans+=3;
                        if(i!=j && j==k) ans+=3;
                        if(i!=j && j!=k) ans+=6;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
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 FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, K;
vector<int> P, C;
ll ret;

void check(int st){
  vector<ll> v, w;
  int p = st;
  int k = 0;
  ll sum = 0;
  while(true){
    k++;
    sum += C[p];
    v.push_back(sum);
    w.push_back(C[p]);
    p = P[p];
    if(p == st) break;
  }

  //cout << st << ": ";
  //rep(i,w.size()) cout << w[i] << " "; cout << endl;
  //cout << "k = " << k << " sum = " << sum << endl;

  if(k >= K){
    rep(i,K){
      ret = max(ret, v[i]);
    }
    return;
  }

  if(sum > 0){
    ll n = K/k;
    ll tmp = sum * (n-1);
    REP(i,(n-1)*k,K){
      tmp += w[i%k];
      ret = max(ret, tmp);
    }
    return;
  }else{
    rep(i,v.size()){
      ret = max(ret, v[i]);
    }
    return;
  }
}


int main(){
  cin >> N >> K;
  rep(i,N){
    int a;
    cin >> a;
    a--;
    P.push_back(a);
  }
  rep(i,N){
    int a;
    cin >> a;
    C.push_back(a);
  }
  ret = C[0];

  rep(i,N){
    check(i);
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 3740
import sys


def input():
    return sys.stdin.readline().rstrip()


def bitall(s):
    for bit in range(1 << 3):
        f = s[0]

        for i in range(3):
            if bit & (1 << i):
                f += "+"
                f += s[i + 1]
            else:
                f += "-"
                f += s[i + 1]

        if eval(f) == 7:
            print(f + "=7")
            exit()


def main():
    s = input()

    bitall(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(pos,mp) for(ll pos=mp.begin();pos!=mp.end();pos -++)
#define ALL(a) (a).begin(),(a).end()

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

const ll MOD  = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;

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

    ll a[m], bit[m];
    rep(i, m){
        ll b;
        cin >> a[i] >> b;

        bit[i] = 0;
        rep(j, b){
            ll c;
            cin >> c;
            c--;
            bit[i] += 1LL << c;
        }
    }

    // dp[i][bit] : iつめまでの鍵を使い,bitの箱を開ける最小値
    ll dp[m+1][1LL<<n];
    rep(i, m+1)rep(j, 1LL<<n)dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, m)rep(j, 1LL<<n){
        // 使わない場合
        dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
        // 使う場合
        ll bor = bit[i] | j;
        dp[i+1][bor] = min(dp[i+1][bor], dp[i][bor]);
        dp[i+1][bor] = min(dp[i+1][bor], dp[i][j] + a[i]);
    }

    ll ans = dp[m][(1LL<<n)-1];
    if(ans >= INF)cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 35580
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  st a,b;
  	ci(a>>b);
  ll n=stoi(a+b);
  bool B=true;
  
  FOR(i,0,1000){
    if(n==i*i){
      co("Yes")
      B=false;
      break;
    }
  }
  if(B) co("No")
}

Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No");
}

Measured memory_bytes: 3616
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}


int main() {
  int A[20];
  int x[20][20];
  int y[20][20];
  int n;
  cin>>n;
  for(int i=1;i<=n;i++){
      cin>>A[i];
      for(int j=1;j<=A[i];j++){
          cin>>x[i][j]>>y[i][j];
      }
  }
  int ans=0;
  for(int bits=1;bits<(1<<n);bits++){
      bool ok=true;
      //配列０番目は全て０、使用しないため?
      for(int i=1;i<=n;i++){ 
          //??わからんマリアナ海溝
          if(bits&(1 << (i-1))){
              for(int j=1;j<=A[i];j++){
                  if(((bits >> (x[i][j]-1))&1)^y[i][j]) ok=false;
              }
          }
      }
      if(ok) ans=max(ans,counter(bits));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using ull=unsigned long long int;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
  while(1){
    int m;
    cin>>m;
    int cp=m;
    int n;
    cin>>n;
    string t(n,'0');
    int j=n-1;
    while(m){
      t[j--]=char(m%10+'0');
      m/=10;
    }
    if(n==0)return 0;
    map<string,int> mp;
    for(int i=0;i<=20;i++){
      if(mp[t]==0)mp[t]=i+1;
      else {
        cout<<int(mp[t])-1<<" "<<cp<<" "<<i-(int)mp[t]+1<<"\n";
        break; 
      }
      string a=t,b=t;
      sort(all(a),greater<ll>()),sort(all(b));
      int a1=0,b1=0;
      for(j=0;j<n;j++){
        a1*=10;
        a1+=(a[j]-'0');
      }
      for(j=0;j<n;j++){
        b1*=10;
        b1+=(b[j]-'0');
      }
      a1-=b1;
      cp=a1;
       string tmp(n,'0');
     j=n-1;
    while(a1){
      tmp[j--]=char(a1%10+'0');
      a1/=10;
    }
    t=tmp;
    }
  }
}


Measured memory_bytes: 3196
# C - Otoshidama

n,y = map(int,input().split())

import sys

tmp = y - 1000*n

a = y // 10000

for i in reversed(range(a+1)):
    for j in range((y - 10000*i) // 5000 + 1):
        if 9000*i + 4000*j == tmp:
            print(i,j,n-i-j)
            sys.exit()
print(-1,-1,-1)


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

const int Sz = 3e3 + 3;
using ii = pair<int,int>;

int n, m, k;
int x, y, z;
int val = 0;
int f[Sz][Sz][4];
int a[Sz][Sz];
int dp(int row, int col, int cnt){
    if(row > n || col > m) return 0;
    int &res = f[row][col][cnt];
    if(res != -1) return res;
    res = dp(row + 1, col, 0);
    if(cnt < 3) res += a[row][col];
    if(cnt < 3){
    if(a[row][col] != 0)
        res = max(res, dp(row, col + 1, cnt + 1) + a[row][col]);
        res = max(res, dp(row, col + 1, cnt));
    }
    //cout << row << " " << col << " " << res << '\n';
    return res;
}
void trace(int row, int col, int cnt){
    if(row > n || col > m) return ;
    if(f[row][col][cnt] == f[row + 1][col][0]) return trace(row + 1, col, 0);
    if(f[row][col][cnt] == f[row][col + 1][cnt]) return trace(row, col + 1, cnt);
    cout << row << " " << col << '\n';
    return trace(row, col + 1, cnt + 1);
}
int32_t main()
{
    //freopen("inp.txt" , "r", stdin);
    //freopen("out.txt", "w", stdout);
    memset(f, -1, sizeof f);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    while(k--){
        cin >> x >> y >> z;
        a[x][y] = z;
    }
    cout << dp(1, 1, 0);
    return 0;
}


Measured memory_bytes: 356272
#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
#include<math.h>
void recursion(ll number,ll digit,vector<ll> &ans,ll count)
{
	if(count>=10)
	{
		return ;
	}
	number=number*10+digit;
	ll lastdigit=number%10;
	ans.push_back(number);
	if(digit==9)
	{
		recursion(number,8,ans,count+1);
		recursion(number,9,ans,count+1);
	}
	else if(digit==0)
	{
		recursion(number,0,ans,count+1);
		recursion(number,1,ans,count+1);
	}
	else
	{
		recursion(number,digit-1,ans,count+1);
		recursion(number,digit,ans,count+1);
		recursion(number,digit+1,ans,count+1);
	}

}
int main()
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
   	//freopen("output.txt","w",stdout);
    //freopen("input.txt","r",stdin);
    ll K;
    cin>>K;
    vector<ll> ans;
    for(ll i=1;i<=9;i++)
    {
    	ll count=0;
    	recursion(0,i,ans,count);
    }
    sort(ans.begin(),ans.end());
    cout<<ans[K-1];
    // for(auto it:ans)
    // {
    // 	cout<<it<<" ";
    // }
    
}



Measured memory_bytes: 2420
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	int ac = 0, wa = 0, tle = 0, re = 0;
	rep(i, n){
		string s;
		cin >> s;
		if(s == "AC") ac++;
		if(s == "WA") wa++;
		if(s == "TLE") tle++;
		if(s == "RE") re++;
	}
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

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

    int x = (int)(n / 1.08);

    string answer = ":(";
    for (int x = 1; x <= n; x++)
    {
        if (((int)(x * 1.08)) == n)
        {
            answer = to_string(x);
            break;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <climits>
#include <map>
#include <cfloat>
using namespace std;

map<int, int> GetMin(const vector<int>& Nx, const vector<vector<int>>& Dv){
    map<int, int> minList;
    for(int c = 1; c<= Dv.size(); c++){
        auto d = 0;
        for(auto c1 : Nx){
            d += Dv[c1-1][c-1];
        }
        minList[c] = d;
    }
    return minList;
}

int GetMin(const vector<vector<int>>& Dv, const vector<vector<int>>& Cv){
    if(Cv.size()==1) return 0;
    vector<int> N0, N1,N2;
    for(size_t i=0; i<Cv.size(); i++){
        for(size_t j=0; j<Cv.size(); j++){
            if((i+j)%3 == 0) N0.push_back(Cv[i][j]);
            if((i+j)%3 == 1) N1.push_back(Cv[i][j]);
            if((i+j)%3 == 2) N2.push_back(Cv[i][j]);
        }
    }
    auto l0 = GetMin(N0, Dv);
    auto l1 = GetMin(N1, Dv);
    auto l2 = GetMin(N2, Dv);
    int dmin = INT_MAX;
    for(auto c0 : l0){
        for(auto c1 : l1){
            if(c0.first == c1.first) continue;
            for(auto c2 : l2){
                if(c0.first == c2.first) continue;
                if(c1.first == c2.first) continue;
                auto d = c0.second + c1.second + c2.second;
                if(d < dmin) dmin = d;
            }
        }
    }
    return dmin;
}

int main()
{
    size_t N, C;
    cin >> N >> C;
    size_t Dij, Cij;
    vector<vector<int>> Dv, Cv;
    for(size_t i=0; i<C; i++){
        Dv.push_back(vector<int>());
        for(size_t j=0; j<C; j++){
            cin >> Dij;
            Dv.back().push_back(Dij);
        }
    }
    for(size_t i=0; i<N; i++){
        Cv.push_back(vector<int>());
        for(size_t j=0; j<N; j++){
            cin >> Cij;
            Cv.back().push_back(Cij);
        }
    }
    auto s = GetMin(Dv, Cv);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
int n,m,f[210010],ans[210000];
int find(int k)
{
    if(f[k]==k)return k;
    return f[k]=find(f[k]);
}
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++) f[i]=i;
    for(int i=1;i<=m;i++)
    {
    	int x,y;
    	scanf("%d%d",&x,&y);
    	int fx=find(x),fy=find(y);
    	if(fx!=fy) f[fy]=fx;
	}
	for(int i=1;i<=n;i++)
	{
		ans[find(i)]++;
	}
	int shu=0;
	for(int i=1;i<=n;i++) shu=max(shu,ans[i]);
	cout<<shu;
    return 0;
}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  string s;
  cin >> s;
  ll n=s.size();
  ll ans1=0,ans2=0;
  for (ll i=0;i<n;i++) {
    if (i%2==0 && s.at(i)=='0') {
      ans1++;
    }
    if (i%2==1 && s.at(i)=='1') {
      ans1++;
    }
  }
  
  for (ll i=0;i<n;i++) {
    if (i%2==0 && s.at(i)=='1') {
      ans2++;
    }
    if (i%2==1 && s.at(i)=='0') {
      ans2++;
    }
  }
  
  
  cout << min(ans1,ans2) << endl;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int N;
string s;
int cnta, cntb;
int main() {
	cin>>N>>s;
	REP(i,0,N){
		if(s[i] == 'R') cnta++;
		else cntb++;
	}
	if(cnta > cntb){
		p("Yes");
	}else{
		p("No");
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#define MOD 1000000007
using namespace std;

int main(){
  int n,init=1;
  cin>>n;
  string s,t;
  cin>>s;
  cin>>t;

  long long ans=3;
  if(s[0]!=t[0]){
    ans=6ll;
    init=2;
  }
  for(int i=init;i<n;i++){
    if(s[i]!=t[i]){
      if(s[i-1]==t[i-1]){
        ans*=2ll;
        i++;
      }else{
        ans*=3ll;
        i++;
      }
    }else{
      if(s[i-1]==t[i-1]){
        ans*=2;
      }
    }
  }
  ans%=MOD;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class Main {

	static Scanner sc = new Scanner(System.in);
	static int tc;
	public static void main(String[] args) {
		tc = 0;
		while (read()) {
			solve();
			tc++;
		}
	}
	
	static int M;
	static int[] nc = new int[4], cv = {10, 50, 100, 500, 10000};
	static boolean read() {
		M = sc.nextInt();
		if (M == 0) return false;
		if (tc > 0) System.out.println();
		for (int i = 0; i < 4; i++) nc[i] = sc.nextInt();
		return true;
	}

	static void solve() {
		int min = 1 << 25;
		int[] ans = new int[4];
		int tmp = 0;
		for (int i = 0; i <= nc[0]; i++) {
			for (int j = 0; j <= nc[1]; j++) {
				for (int k = 0; k <= nc[2]; k++) {
					for (int l = 0; l <= nc[3]; l++) {
						tmp = i * cv[0] + j * cv[1] + k * cv[2] + l * cv[3];
						if (tmp >= M) {
							tmp -= M;
							int tmp2 = nc[0] + nc[1] + nc[2] + nc[3] - (i + j + k + l);
							int[] tmp3 = new int[4];
							for (int m = 3; m >= 0; m--) {
								tmp3[m] = tmp / cv[m];
								tmp2 += tmp3[m];
								tmp -= tmp3[m] * cv[m];
							}
							
							if (min > tmp2) {
								ans[0] = i;
								ans[1] = j;
								ans[2] = k;
								ans[3] = l;
//								System.out.println(ans[0] + " " + ans[1] + " " + ans[2] +" " + ans[3]);
								min = tmp2;
							}
						}
					}
				}
			}
			
		}
		
		for (int i = 0; i < 4; i++) 
			if (ans[i] > 0) 
				System.out.println(cv[i] + " " + ans[i]);
	}	
}

Measured memory_bytes: 13000
n=int(input())
List=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    List.append([s,p,i+1])
List.sort()
S=List[0][0]
k=[]
for i in List:
    if i[0]==S:
        k.append([i[1],i[2]])
    else:
        k.sort(reverse=True)
        for j in k:
            print(j[1])
        S=i[0]
        k=[]
        k.append([i[1],i[2]])
k.sort(reverse=True)
for j in k:
    print(j[1])


Measured memory_bytes: 38704
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
typedef long long int ll;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define MOD 1000000007
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);  
//*s.find_by_order(p)   returns the value of pth largest starting from 0 
//s.order_of_key(p)   returns no. of items that are strictly < p 
//string bin = bitset<64>(m).to_string();     convert decimal m to binary
int main()
{
	fast;ll t;t=1;
	while(t--)
	{
		ll n,s,d,a,b,ans=0,i;
		cin>>n>>d;
		for(i=1;i<=n;i++)
		{
			cin>>a>>b;
			if(a*a+b*b<=d*d){ans++;}
		}
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 3648
<?php
fscanf(STDIN, "%d", $N);
$zorome_count = 0;
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    if ($a == $b) {
        $zorome_count++;
    } else {
        $zorome_count = 0;
    }
    if ($zorome_count == 3) {
        echo "Yes\n";
        exit;
    }
}
echo "No\n";


Measured memory_bytes: 16136
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final long a = sc.nextLong();
			final long b = sc.nextLong();
			final long c = sc.nextLong();
			final long d = sc.nextLong();
			
			final long max = Math.max(Math.max(a * c, a * d), Math.max(b * c, b * d));
			
			System.out.println(max);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const db eps = 0.00000000001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 550555;
const int L = 21;
const int M = 2155;

void solve() {
    string s;
    cin >> s;
    
    if (s == "ABC") cout << "ARC";
    if (s == "ARC") cout << "ABC";

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
    int n,i,v,j;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)cin>>a[i];
    for(i=0;i<n;i++){
        if(i!=n-1)
            cout<<a[i]<<" ";
        else if(i==n-1)
            cout<<a[i]<<endl;
        }
    for(i=1;i<n;i++){
        v=a[i];
        j=i-1;
        
        while(j>=0&&a[j]>v){
           a[j+1]=a[j];
           j--;
        }a[j+1]=v;
        
        for(j=0;j<n;j++){
            if(j!=n-1)
                cout<<a[j]<<" ";
            else if(j==n-1)
                cout<<a[j]<<endl;
        }
    }
    return 0;
}


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

int main()
{
  int num;
  cin >> num; int cnt = 0;
  int div = num;
  while(num) {
    cnt += (num % 10);
    num /= 10;
  } if(div % cnt == 0) cout << "Yes\n";
  else cout << "No\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
ll MOD = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n;
    cin >> n;
    vector<ll> a_abs(n);
    int minus_num = 0;
    rep(i, n) {
        ll tmp_a; 
        cin >> tmp_a;
        if ( tmp_a < 0 ) ++minus_num;
        a_abs[i] = abs(tmp_a);
    }
    sort(a_abs.begin(), a_abs.end());
    ll ans = 0;
    rep(i, n) {
        if ( i == 0 ) {
            if ( minus_num & 1 ) ans -= a_abs[i];
            else                 ans += a_abs[i];
        }
        else {
            ans += a_abs[i];
        }
    } 
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
typedef pair<int,int> P;

bool check(int a,int b,int c)
{
  int v = b*b-4*a*c;
  if(v < 0)return false;
  int vs = (int)sqrt(v);
  if(vs*vs != v)return false;
  return true;
}

bool cmp(const P &a,const P &b)
{
  if(a.first != b.first)return a.first > b.first;
  return a.second > b.second;
}

int main()
{
  int a,b,c;
  while(cin >> a >> b >> c,a|b|c)
    {
      if(!check(a,b,c))
	{
	  cout << "Impossible" << endl;
	  continue;
	}
      int s1,s2,aa,ab;
      aa = ab = 2*a;
      s1 = -(-b+sqrt(b*b-4*a*c));
      s2 = -(-b-sqrt(b*b-4*a*c));
      //cout << s1 << " x " << s2 << endl;
      int gcd1 = __gcd(s1,aa);
      int gcd2 = __gcd(s2,ab);
      //cout << "gcd = " << gcd1 << " " << gcd2 << endl;
      if(gcd1 != 1)s1 /= gcd1,aa /= gcd1;
      if(gcd1 != 1)s2 /= gcd2,ab /= gcd2;
      //cout << s1/aa << " " << s2/ab << endl;
      //cout << "ss = " << s1 << " " << s2 << endl;
      //cout << "aa = " << aa << " " << ab << endl;
      vector<P> vec(2,P(0,0));
      vec[0].first = aa,vec[0].second = s1;
      vec[1].first = ab,vec[1].second = s2;
      if(vec[0].first < 0)vec[0].first*=-1,vec[0].second*=-1;
      if(vec[1].first < 0)vec[1].first*=-1,vec[1].second*=-1;

     
      sort(vec.begin(),vec.end(),cmp);
      cout << vec[0].first << " " << vec[0].second << " " << vec[1].first << " " << vec[1].second << endl;
    }
  return 0;
}

Measured memory_bytes: 1196