akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int maxw, n;
	int[] w;
	Pair[] elements;
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(int cnt=1;;cnt++) {
			maxw = sc.nextInt();
			if ( maxw == 0 ) break;
			w = new int[maxw+1];
			n = sc.nextInt();
			elements = new Pair[n];
			
			fill(w, -1);
			w[0] = 0;
			
			for(int i=0;i<n;i++) {
				String s = sc.next();
				String[] str = s.split(",");
				elements[i] = new Pair(Integer.parseInt(str[0]), Integer.parseInt(str[1]));
			}
			sort(elements);
			System.out.println("Case " + cnt + ":");
			dp();
		}
	}
	
	void dp() {
		for(int i=0;i<n;i++) for(int j=maxw;j>=elements[i].s;j--) {
			if( w[j-elements[i].s] >= 0 ) 
				w[j] = max(w[j], w[j-elements[i].s] + elements[i].f);
		}
		int cw = 0,cv = 0;
		for (int i=0;i<=maxw;i++) {
			if(cv < w[i]) {cv = w[i]; cw = i;}  
		}
		System.out.println(cv);
		System.out.println(cw);
		
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	class Pair implements Comparable<Pair> {
		int f, s;
		Pair(int f, int s) {
			this.f = f;
			this.s = s;
		}
		@Override
		public int compareTo(Pair o) {
			// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
			return s - o.s;
		}
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf

int d;

int main() { 
  cin >> d;

  string ans = "Christmas";
  for (int i = 24; i >= 22; i--) {
    if (i >= d) {
      ans += " Eve";
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    int N;
    string S,T;
    cin >> N >> S >> T;
    rep(i,N){
        cout << S[i] << T[i];
    }   
    return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e2+5;

const int mod = 1e9+7;

//A 1
//C 2
//G 3
//T 4

int n;
int mem[N][5][5][5];

int go(int idx , int lst1 , int lst2 , int lst3){
    if(idx == n)
        return 1;
    if(~mem[idx][lst1][lst2][lst3])
        return mem[idx][lst1][lst2][lst3];
    int cnt = 0;
    for(int i = 1; i <= 4; i++){
        if(i == 3 && lst1 == 2 && lst2 == 1) continue;
        if(i == 3 && lst1 == 1 && lst2 == 2) continue;
        if(i == 3 && lst2 == 2 && lst3 == 1) continue;
        if(i == 3 && lst1 == 2 && lst3 == 1) continue;
        if(i == 2 && lst1 == 3 && lst2 == 1) continue;

        cnt += go(idx + 1 , i , lst1 , lst2);
        cnt %= mod;
    }
    return mem[idx][lst1][lst2][lst3] = cnt;
}

int main(){
    scanf("%d" , &n);
    memset(mem , -1 , sizeof mem);
    printf("%d\n" , go(0 , 0 , 0 , 0));
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<memory.h>
long long dp[110][100010]={} ;

using namespace std ;
int main()
	{
	int n ,w ;
	scanf("%d%d" ,&n ,&w) ;
	vector <pair <long long ,long long> > v ;
	long long tmp_v ,tmp_w ;
	for(int k=0 ;k<n ;k++)
		{
		scanf("%lld%lld", &tmp_w ,&tmp_v) ;
		v.push_back(make_pair(tmp_v ,tmp_w)) ;
		}
	for(int j=1 ;j<=w ;j++)
		for(int i=0 ;i<=n ;i++)
			{
			if(i==0)
				dp[i][j]=0 ;
			else
				dp[i][j]=dp[i-1][j] ;
			if(v[i].second<=j)
				{
				if(i>0)
					dp[i][j]=max(dp[i][j] ,dp[i-1][j-v[i].second]+v[i].first) ;
				else
					dp[i][j]=v[i].first ;
				}
			//cout<<"i"<<i<<"j"<<j<<"	"<<dp[i][j]<<endl ;
			}
	printf("%lld" ,dp[n-1][w]) ;
	}

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

int main(){
  int a;
  cin >> a;
  int b = a%100;
  int c = (a-b)/100;
  if(b > 0 && b < 13){
    if(c < 13 && c > 0){
      cout << "AMBIGUOUS" << endl;
    }else{
      cout << "YYMM" << endl;
    }
  }else{
    if(c < 13 && c > 0){
      cout << "MMYY" << endl;
    }else{
      cout << "NA" << endl;
    }
  }
}


Measured memory_bytes: 256
#pragma region

#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin); i < (end); i++)
#define _irep3(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  ll N, W;
  cin >> N >> W;
  vector<ll> w(N), v(N);
  rep(i, N) cin >> w[i] >> v[i];

  vector<vector<ll>> dp(N + 1, vector<ll>(1000 * N + 1, INF));
  rep(i, N) dp[i][0] = 0;
  rep(i, N) {
    rep(j, 1000 * N + 1) {
      dp[i + 1][j] = dp[i][j];
    }
    rep(j, 1000 * N) {
      if (dp[i][j] == INF || j + v[i] > 1000 * N) continue;
      dp[i + 1][j + v[i]] = min(dp[i][j] + w[i], dp[i + 1][j + v[i]]);
    }
  }

  irep(i, 1000 * N + 1) {
    if (dp[N][i] != INF && dp[N][i] <= W) {
      out(i);
      return 0;
    }
  }
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;

int main()
{
    int A, B;
    cin >> A >> B;

    int ans = max(A + B, A - B);
    ans = max(ans, A * B);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  zjsdut
 *    created: 2020/03/23 20:13:42
 **/
#include <bits/stdc++.h>

using namespace std;

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

template <typename A, typename B> bool chkmin(A &a, const B &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

template <typename A, typename B> bool chkmax(A &a, const B &b) {
  if (b > a) {
    a = b;
    return true;
  }
  return false;
}

template <typename T> istream &operator>>(istream &stream, vector<T> &vec) {
  for (auto &x : vec)
    stream >> x;
  return stream;
}

void scan() {}

template <class T, class... Args> void scan(T &a, Args &... rest) {
  cin >> a;
  scan(rest...);
}

using ll = long long;
using vl = vector<ll>;
using vb = vector<bool>;
using vi = vector<int>;
using pii = pair<int, int>;
template <typename T> using vv = vector<vector<T>>;
#define rng(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define up(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define down(i, b, a) for (int i = int(b); i >= int(a); i--)
#define TOKENPASTE(x, y) x##y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
#define rep(n)                                                                 \
  for (int TOKENPASTE2(_iter_, __LINE__) = 0,                                  \
                               TOKENPASTE2(_num_, __LINE__) = (int)(n);        \
       TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__);           \
       ++TOKENPASTE2(_iter_, __LINE__))
#define FOR(x, cont) for (const auto &x : cont)
#define For(x, cont) for (auto &x : cont)
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ep emplace
#define SZ(x) (int)(x).size()
#define UNIQ(vec) (vec).erase(unique(all(vec)), end(vec))
#define LB(cont, x) int(lower_bound(all(cont), x) - begin(cont))
#define UB(cont, x) int(upper_bound(all(cont), x) - begin(cont))

template <typename T>
ostream &operator<<(ostream &stream, const vector<T> &vec) {
  if (!vec.empty()) {
    stream << vec[0];
    for (size_t i = 1; i != vec.size(); ++i)
      stream << ' ' << vec[i];
  }
  return stream;
}

template <typename T> void print(const vector<T> &t) { cout << t << '\n'; }

template <typename T> void print(const vector<vector<T>> &t) {
  for (const auto &row : t) {
    print(row);
  }
}

template <typename T> void print(const T &t) { cout << t << ' '; }

template <typename T, typename... Args>
void print(const T &t, const Args &... rest) {
  print(t);
  print(rest...);
}

template <typename T> void println(const T &t) { cout << t << '\n'; }

template <typename T, typename... Args>
void println(const T &t, const Args &... rest) {
  print(t);
  println(rest...);
}

int main() {
#if defined LOCAL && !defined DUIPAI
  ifstream in("in.txt");
  cin.rdbuf(in.rdbuf());
#endif
  int n;
  scan(n);
  vi a(2 * n);
  scan(a);
  sort(all(a));
  int ans = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    ans += a[i];
  }
  println(ans);
  return 0;
}

Measured memory_bytes: 256
while True:
    
    a,b = map(int,input().split())
    if a == 0 and b == 0:
        break
    for tate in range(a):
        for yoko in range(b):
            if tate == 0 or tate == a - 1:
                print("#" ,end="")
            else:
                if yoko == 0 or yoko == b - 1:
                    print("#",end="")
                else:
                    print("." ,end="")
        print()
    print()

    


Measured memory_bytes: 7004
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
//const int MOD = 1000000007;
const int MOD = 998244353;
const int INF = 1001001001;

int main(){
    int n;
    cin >> n;
    cout << (n-2)*180 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define el '\n'
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define repd(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define large 1000000007
#define pb() push_back()
#define MAX 10e+7
int dp[100000];
int hp(int arr[],int n,int k,int i)
{
    int min=INT_MAX;
int z=i-k;
if(z<0)   z=0;
rep(j,z,i)
{
   if(dp[j]+abs(arr[j]-arr[i])<min)
   min=dp[j]+abs(arr[j]-arr[i]);
}
    return min;
}
void solve()
{
int n,k;
cin>>n>>k;
int arr[n];
rep(i,0,n)
{
    cin>>arr[i];
}
dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
rep(i,2,n)
{
dp[i]=hp(arr,n,k,i);
}
//cout<<dp[1]<<el;
cout<<dp[n-1]<<el;
}
int main()
{
    
 long long int t;
 
  solve();
  
 
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  int a, b;
  while (true) {
    cin >> a >> b;
    if (a == 0 && b == 0)
      break;

    b -= a;
    int noguchi = b / 1000;
    b %= 1000;
    int iwakura = b / 500;
    b %= 500;
    int itagaki = b / 100;
    cout << itagaki << ' ' << iwakura << ' ' << noguchi << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ull            unsigned long long int
#define ll             long long int
#define pb(x)          push_back(x)
#define mp(a,b)        make_pair(a,b)
#define li(ini)        for(ull i=ini;;i++)
#define lf(i,ini,n)    for(ull i=ini;i<n;i++)
#define lfd(i,n)       for(ull i=n;i>=1;i--)
#define lit(it,v)      for(auto it=v.begin();it!=v.end();it++)
#define sorta(v)       sort(v.begin(),v.end())
#define sortd(v)       sort(vec.begin(), vec.end(), greater<>())
#define vf(i)          v[i].first
#define vs(i)          v[i].second
#define fast_io        ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

vector<ll>v;
vector<ll>::iterator it;



int main()
{
    fast_io

    ll n=0,k=0,x=0,res=0;
    cin>>n>>k;

    lf(i,0,n)
    {
        cin>>x;
        v.pb(x);
    }

    vector<ll> memo(n,INT_MAX);

    memo[0]=0;
    memo[1]=abs(v[0]-v[1]);///base case definition

    lf(i,2,n)
    {
        ll j,jump;
        for(j=i-1,jump=0 ; j>=0 && jump<k ; j--,jump++)
        {
            memo[i]=min(memo[i],memo[j]+abs(v[j]-v[i]));

        }
    }

    cout<<memo[n-1]<<"\n";

    return 0;
}







Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    int sum = accumulate(all(A),0);
    int ans = 0;
    rep(i,N){
        int a = A[i];
        if(a*M*4>=sum) ++ans;
    }
    cout << ((ans>=M)?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
vector<vi> to;
vi ans;
void dfs(int now, int parent = -1){
  for(int next : to[now]){
    if(next == parent) continue;
    ans[next] += ans[now];
    dfs(next,now);
  }
}
int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,q; cin >> n >> q;
  to = vector<vi>(n);
  rep(i,n-1){
    int a,b; cin >> a >> b;  a--;  b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = vi(n);
  rep(i,q){
    int p,x; cin >> p >> x;  p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 24180
A,B,C,K = map(int, input().split())
ans = 0

if K < A:
  ans += K
  print(ans) 
elif K <= A+B:
  ans += A
  print(ans)
elif K < (A + B + C):
  ans += A
  ans -= K-(A+B)
  print(ans)
elif K >= (A + B + C):
  ans += A
  ans -= C
  print(ans)


Measured memory_bytes: 9044
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

vector<int> G[100001];
int N;
int root;
int MAX_LOG_V = 17;
int POW[18];

int** parent;
int* depth;

void dfs(int node_id,int parent_id,int d){
	parent[0][node_id] = parent_id;
	depth[node_id] = d;
	for(int i = 0; i < G[node_id].size(); i++){
		if(G[node_id][i] != parent_id)dfs(G[node_id][i],node_id,d+1);
	}
}

void init(){

	dfs(root,-1,0);

	for(int k = 0; k + 1 < MAX_LOG_V; k++){
		for(int node_id = 0; node_id < N; node_id++){
			if(parent[k][node_id] < 0)parent[k+1][node_id] = -1;
			else{
				parent[k+1][node_id] = parent[k][parent[k][node_id]];
			}
		}
	}
}


int lca(int left,int right){

	if(depth[left] > depth[right])swap(left,right);

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(depth[right]-depth[left] >= POW[k]){
			right = parent[k][right];
		}
	}

	if(left == right)return left;

	for(int k = MAX_LOG_V-1; k >= 0; k--){
		if(parent[k][left] != parent[k][right]){
			left = parent[k][left];
			right = parent[k][right];
		}
	}
	return parent[0][left];
}



int main(){

	for(int i = 0; i <= 17; i++)POW[i] = pow(2,i);

	scanf("%d",&N);

	int num,child;

	for(int i = 0; i < N; i++){
		scanf("%d",&num);
		for(int k = 0; k < num; k++){
			scanf("%d",&child);
			G[i].push_back(child);
		}
	}

	parent = new int*[MAX_LOG_V];
	for(int i = 0; i < MAX_LOG_V;i++)parent[i] = new int[N];
	depth = new int[N];
	root = 0;
	init();

	int Q;
	scanf("%d",&Q);

	int left,right;

	for(int i = 0; i < Q; i++){
		scanf("%d %d",&left,&right);
		printf("%d\n",lca(left,right));
	}

	return 0;
}

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

int main() {
	int a, b, c, d, p, x, y;
	cin >> a >> b >> c >> d >> p;
	x = a*p;
	if (p <= c) {
		y = b;
	}
	else {
		y = b + (p - c)*d;
	}
	if (x > y) {
		cout << y << endl;
	}
	else {
		cout << x << endl;
	}
}

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {

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

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

    System.out.println(Math.max(C - (A - B), 0));
  }
}

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

#define ll long long

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

    int a, b;
    cin >> a >> b;

    if (b % a == 0) cout << a + b << endl;
    else cout << b - a << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MIN -1000000
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll comb[2005][2005];
int N,K;
void combinit()
{
  for(int i=0;i<=2000;i++)
  {
    for(int j=0;j<=i;j++)
    {
      if(j==0 || j==i) comb[i][j]=1;
      else
      {
        comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%MOD;
      }

    }
  }
}

class Work
{
public:
  ll time,deadline;
  Work(ll _t,ll _d):time(_t),deadline(_d){}
  bool operator < (const Work &a) const{
    return (deadline<a.deadline);
  }
};
int main(void)
{
  memset(comb,0,sizeof(comb));
  combinit();
  cin >> N >> K;
  int space=N-K+1;
  int ans=0;
  for(int i=1;i<=K;i++)
  {
    ans=(comb[space][i]*comb[K-1][i-1])%MOD;
    cout << ans << endl;
  }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    ll MA = 1000001;
    vector<ll> B(MA, 0);
    vector<ll> C(MA, 0);
    REP(i, N) B[A[i]]++;
    sort(A.begin(), A.end());    

    ll res = 0;
    REP(i, N){
        if(B[A[i]]<=1 and C[A[i]]==0) res++;
        if(C[A[i]]==0){
            for(int j=A[i];j<MA;j+=A[i]){
                C[j] = 1;
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 20344
using System.Collections.Generic;
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = long.Parse(line[1]);
        var d = new Dictionary<int , long>();
        for (int i = 0; i < n; i++)
        {
            line = Console.ReadLine().Trim().Split(' ');
            var a = int.Parse(line[0]);
            var b = long.Parse(line[1]);
            if (d.ContainsKey(a)) d[a] += b;
            else d[a] = b;
        }
        var total = 0L;
        foreach (var x in d.OrderBy(y => y.Key))
        {
            total += x.Value;
            if (total >= k) { Console.WriteLine(x.Key); break; }
        }
    }
}

Measured memory_bytes: 20548
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

int f[1002][100003];

signed main()
{
	speed
	for(int i=0;i<1002;++i)
	{
		for(int j=0;j<100003;++j)
		{
			f[i][j]=INT_MAX;
		}
	}
	int h,n;cin>>h>>n;
	vector<int> a(n+1),b(n+1);
	for (int i = 1; i <= n; ++i)
	{
		cin>>a[i]>>b[i];
	}
	f[0][0]=0;
	for(int i=1;i<=n;++i)
	{
		for(int rem=0;rem<=100000;++rem)
		{
			f[i][rem]=f[i-1][rem];
			if(rem>=a[i]){f[i][rem]=min(f[i][rem],f[i][rem-a[i]]+b[i]);}
		}
	}
	int ans=INT_MAX;
	for(int rem=100000;rem>=h;--rem)
	{
		//if(f[n][rem]==0){cout<<n<<" "<<rem<<"\n";}
		ans=min(ans,f[n][rem]);
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 783232
#!/usr/bin/env python3

from typing import Iterable


def main() -> None:
    N, K = rmi()
    D, A = [], []
    for k in range(K):
        d = ri()
        D.append(d)
        A.append(rmi())
    target = [False] * N
    for k in range(K):
        for a in A[k]:
            target[a - 1] = True
    w(target.count(False))


def r() -> str:
    return input().strip()


def ri() -> int:
    return int(r())


def rmi(delim: str = ' ') -> int:
    return tuple(map(int, input().split(delim)))


def w(data) -> None:
    print(data)


def wm(data: Iterable) -> None:
    print(' '.join(data))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10208
using System;
using System.Collections.Generic;
using System.Linq;

class B
{
    static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
    static void Main()
    {
        var a = int.Parse(Console.ReadLine());
        var cnt = 0;
        var ans = "";
        for (int i = 0; i < a; i++)
        {
            var b = Read();
            if (b[0] == b[1]) cnt++;
            else cnt = 0;
            if (cnt > 2) ans = "Yes";
        }
        Console.WriteLine(ans == "Yes" ? "Yes" : "No");
    }
}

Measured memory_bytes: 28288
#include<bits/stdc++.h>
#define ll long long
#define repeat(i,a,n) for(int i=a;i<=n;i++)
using namespace std;

int main(){
  ll N;
  cin >>N;
  
  const ll mod = 1e9+7;
  ll ans = 1;
  
  repeat(i,1,N){
    ans = (ans*i)%mod;
  }
  
  cout <<ans<< endl;
}

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

void print(int *a, int N) {
    //出力
    for(int i = 0; i < N - 1; i++) cout<<a[i]<<' ';
    cout<<a[N - 1]<<endl;
}

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

    int N, key, j;
    cin>>N; // データの数の入力

    int array[N];
    for(int i = 0; i < N; i++) cin>>array[i]; //データの入力

    // insertionSort
    for(int i = 1; i <= N - 1; i++) {
        
        print(array, N); //出力
        key = array[i];
        j = i - 1;
        while(j >= 0 && array[j] > key) {
            array[j + 1] = array[j];
            j--;
        }
        array[j + 1] = key;
    }

    print(array, N);  //出力
    return 0;
}



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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    int a, b;
    rep(i, M) {
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    rep(i, N) sort(G[i].begin(), G[i].end());
    vector<int> perm(N-1);
    rep(i, N-1) perm[i] = i+1;
    int ans = 0;
    do {
        int tmp = 0;
        bool flag = true;
        for (int i = 0; i < N-1; i++) {
            if (!binary_search(G[tmp].begin(), G[tmp].end(), perm[i])) {
                flag = false;
                break;
            }
            tmp = perm[i];
        }
        if (flag) ans++;
    }
    while(next_permutation(perm.begin(), perm.end()));
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemA
{
    class Program
    {
        static void Main(string[] args)
        {
            var read = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var H = read[0];
            var W = read[1];
            var countWhite = 0;
            var As = new char[H, W];
            var AIndexs = new int[H, W];
            var que = new Queue<Tuple<int, int, int>>();
            for (int i = 0; i < H; i++)
            {
                var readChar = Console.ReadLine().ToString().ToArray();
                for (int j = 0; j < W; j++)
                {
                    //if (readChar[j] == '.') countWhite++;
                    if (readChar[j] == '#') que.Enqueue(Tuple.Create(i, j, 0));
                    As[i, j] = readChar[j];
                    //AIndexs[i, j] = readChar[j] == '.' ? -1 : 0;
                }
            }

            var ret = 0;
            while (que.Count() > 0)
            {
                var q = que.Dequeue();
                var i = q.Item1;
                var j = q.Item2;
                var c = q.Item3;

                if(i!=0&&As[i - 1,j] == '.')
                {
                    As[i - 1, j] = '#';
                    que.Enqueue(Tuple.Create(i - 1, j, c + 1));
                }
                if (i != H-1 && As[i + 1, j] == '.')
                {
                    As[i + 1, j] = '#';
                    que.Enqueue(Tuple.Create(i + 1, j, c + 1));
                }

                if (j != 0 && As[i , j-1] == '.')
                {
                    As[i , j-1] = '#';
                    que.Enqueue(Tuple.Create(i , j-1, c + 1));
                }

                if (j != W-1 && As[i , j+1] == '.')
                {
                    As[i , j+1] = '#';
                    que.Enqueue(Tuple.Create(i , j+1, c + 1));
                }
                if (que.Count() == 0) ret = c;
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 56832
l=[]
while gets
  n,m=$_.split.map(&:to_i)
  if n==0 and m==0
    tf=true
    (1..(l.max)).each do |x|
      if x.between?(1,2) then tf=l.count(x).odd?
      else tf=l.count(x).even? end
      break unless tf
    end
    puts tf ? "OK" : "NG"
    l=[]
  else
    l<<n<<m
  end
end

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


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] s = sc.next().toCharArray();

		if (s.length >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<int, ii>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e5 + 5;

int n, m, a, b, ans;
bool vis[N];
vt<int> v[N];

void dfs(int u) {
    if(vis[u]) return;
    vis[u] = true;
    for(int x : v[u]) {
        dfs(x);
    }
}

void solve() {
    int T = 1;
    // cin >> T;
    for(int tc = 1; tc <= T; tc++) {
        cin >> n >> m;
        while(m--) {
            cin >> a >> b;
            v[a].pb(b);
            v[b].pb(a);
        }
        for(int i = 1; i <= n; i++) {
            if(!vis[i]) {
                dfs(i);
                ans++;
            }
        }
        cout << ans - 1 << "\n";
    }
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
    
}

Measured memory_bytes: 9508
import java.util.Scanner;
import java.util.TreeMap;
import java.util.Map;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        Map<Integer,Long> map = new TreeMap<>();
        for(int i = 0;i < n;i++){
            int a = sc.nextInt();
            long b = sc.nextLong();
            if(map.containsKey(a)){
                map.put(a,map.get(a)+b);
                continue;
            }
            map.put(a,b);
        }
        //System.out.println(k);
        //System.out.println(list);
        long m = 0;
        for(Integer key : map.keySet()){
            m += map.get(key);
            if(m >= k){
                System.out.println(key);
                return;
            }
        }
    }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, a, b;
int x[100000];

int main() {
    scanf("%d%d%d", &n, &a, &b);
    forn(i, n) {
        scanf("%d", x + i);
    }
    LL ans = 0;
    for (int i = 1; i < n; ++i) {
        int dist = x[i] - x[i - 1];
        LL cost = (LL)dist * a;
        cost = min(cost, (LL)b);
        ans += cost;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;


#define SIZE 26
#define INF 1000000000
#define LLINF 1000000000000000000LL

int calc(int m,int w){
  int ans = 0;
  int bm[12],bw[12];
  int dp[13][1<<12] = {0};
  
  for(int i=0;i<m;i++){
    scanf("%d",bm+i);
  }
  
  for(int i=0;i<w;i++){
    scanf("%d",bw+i);
  }

  for(int i=0;i<=w;i++){
    for(int j=0;j<(1<<m);j++){
      dp[i][j] = -INF;
    }
  }

  dp[0][0] = 0;
  
  for(int i=0;i<w;i++){
    for(int j=0;j<(1<<m);j++){
      for(int k=0;k<m;k++){
	dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
	if(j&(1<<k)) continue;
	int d = abs(bw[i]-bm[k]);
	int add = d * (d-30) * (d-30);
	dp[i+1][j+(1<<k)] = max(dp[i+1][j+(1<<k)],dp[i][j] + add);
	ans = max(ans,dp[i+1][j+(1<<k)]);
      }
    }
  }

  return ans;
}

int main(){
  int m,w;
    
  while(1){
    scanf("%d%d",&m,&w);
    if(m==0) break;
    
    printf("%d\n",calc(m,w));
  }
  
  return 0;
}

Measured memory_bytes: 1388
#include <stdio.h>
int main(void) {
    int n,k,h,i,j,tmp;
    scanf("%d%d",&n,&k);
    int seq[n];
    for(i=0;i<n;i++) {
        j=0;
        tmp = i+1;
        while(1){
            tmp = i+1;
           for(h=0;h<j;h++){
              tmp = tmp*2;
           }
           if(tmp>=k)
               break;
           j++;
        }
        seq[i] = j;
    }
    double ans,tmp2;
    double n2 = (double)1/n;
    double front_pro = (double)1/2;
    for(i=0;i<n;i++) {
        tmp2 = n2;
        for(j=0;j<seq[i];j++) {
            tmp2 = tmp2*front_pro;
        }
        ans = ans + tmp2;
    }
    printf("%13.12f\n",ans);
}

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

int main() {
    string s;
    cin >> s;
    bool T = false;
    for (int i = 0; i < s.length()-1; i++) {
        if (s[i]=='A' && s[i+1]=='C') {
            T = true;
            break;
        }
        if (T) break;
    }
    if (T) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int top = s[0] - '0', cnt1 = 0;
    for (int i = 1; i < n; i++) {
        int t = s[i] - '0';
        if (top != t) {
            top = t;
            cnt1++;
        }
    }
    top = s[n - 1] - '0';
    int cnt2 = 0;
    for (int i = n - 1; i >= 0; i--) {
        int t = s[i] - '0';
        if (top != t) {
            top = t;
            cnt2++;
        }
    }
    cout << min(cnt1, cnt2) << endl;
}

Measured memory_bytes: 512
N,T = map(int,input().split())
foods = []
for _ in range(N):
  a,b = map(int,input().split())
  foods.append([a,b])

foods.sort(key=lambda x: x[0])

# dp[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値
dp = [ [0]*(T+1) for _ in range(N+1) ]

for i in range(N):
  a,b = foods[i]
  for j in range(T+1):
    if j >= a:
      dp[i+1][j] = max(dp[i][j], dp[i][j-a]+b)
    else:
      dp[i+1][j] = dp[i][j]

# for d in dp:
#   print(d)

ans = 0
for i in range(1, N+1):
  b = foods[i-1][1]
  ans = max(ans, dp[i][-1], dp[i-1][-2]+b)

print(max(ans, dp[-1][-1]))

Measured memory_bytes: 145868
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 2e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = asin (1) * 2;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	string s;
	cin >> s;
	if (s == "ABC") cout << "ARC";
	else cout << "ABC";







}

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

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

const int N = 1e5 + 5;

int n, a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int k = 0;
	while(true) {
		int z = 0, f = 0, g = 0;
		for (int i = 0; i < n; i++) {
			if(a[i] & 1)
				f++;
			else
				z++;
		}
		if(f == n) {
			cout << (k? "First" : "Second") << "\n";
			return 0;
		}
		if(z & 1) {
			cout << (!k? "First" : "Second") << "\n";		
    		return 0;
		}
		if((z % 2) == 0 && f > 1) {
			cout << (k? "First" : "Second") << "\n";
			return 0;
		}
		for (int i = 0; i < n; i++) {
			if(a[i] & 1) {
				if(a[i] == 1) {
					cout << (k? "First" : "Second") << "\n";		
    				return 0;
				}
				else {
					a[i]--;
				}
				break;
			}
		}
		for (int i = 0; i < n; i++)
			g = __gcd(a[i], g);
		for (int i = 0; i < n; i++)
			a[i] /= g;
		k ^= 1;
	}
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for(int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    System.out.println(a[N - 1] - a[0]);
  }
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <algorithm>
#include <functional>
using namespace std;
int a[101010];

main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	sort(a,a+n,greater<int>());
	
	for(int i=1;i<=n;i++){
		if(a[i-1]>=i && (i==n || a[i]<i+1)){
			int arm=a[i-1]-i;
			int leg=0;
			for(int j=i;j<=n;j++){if(j==n||a[j]<i){leg=j-i;break;}}
			//fprintf(stderr,"%d %d %d\n",i,arm,leg);
			if(arm%2==1||leg%2==1)puts("First"); else puts("Second");
			return 0;
		}
	}
}

Measured memory_bytes: 512
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

string S;

int main() {
    cin >> S;
    if (S=="Sunny") {
        print("Cloudy");
    } else if (S=="Cloudy") {
        print("Rainy");
    } else {
        print("Sunny");
    }
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
cnt = 0
q = ['3', '5', '7']
while q:
    qq = q.pop()
    v = list(qq)
    if '3' in v and '5' in v and '7' in v:
        cnt += 1
    if int(qq + '3') <= n:
        q.append(qq + '3')
        if int(qq + '5') <= n:
            q.append(qq + '5')
            if int(qq + '7') <= n:
                q.append(qq + '7')
print(cnt)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repa(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define COUT(x) cout << (x) << endl
#define VIEW(x) do{cout << "--" << #x << "--" << endl; view(x);}while(0)
template<typename T> void view(T e){COUT(e);}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
#define _GLIBCXX_DEBUG

int main(){
  
  int x, t;
  cin >> x >> t;
  cout << max(x - t, 0) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=1e5+5;
//ll a[N],sum[N];
struct node{
    ll a,b,c;
}p[N];
int n,m,i,j,k;
bool cmp(node x,node y){
    return x.a*i+x.b*j+x.c*k>y.a*i+y.b*j+y.c*k;
}
int main(void){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n>>m;
    ll ans=0;
    for(int i=1;i<=n;i++)   cin >>p[i].a>>p[i].b >>p[i].c;
    for( i=-1;i<=1;i+=2){// i,j,k分别代表绝对值里的符号趋向
        for( j=-1;j<=1;j+=2){
            for( k=-1;k<=1;k+=2){
                sort(p+1,p+1+n,cmp);
                ll t[4]={0};
                for(int te=1;te<=m;te++)    t[1]+=p[te].a,t[2]+=p[te].b,t[3]+=p[te].c;
                ans=max(ans,t[1]*i+t[2]*j+t[3]*k);
            }
        }
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 256
import math
a, b = map(int, input().split())
a_min = math.ceil(a/0.08)
b_min = math.ceil(b/0.1)
a_able = set(i for i in range(a_min, a_min+12))
b_able = set(i for i in range(b_min, b_min+10))
if a_able&b_able:
    print(min(a_able&b_able))
else:
    print(-1)

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

int main(){
    int n;
    cin >> n;
    int d[n];
    int sum=0;
    for(int i=0; i<n; i++){
        cin >> d[i];
    }
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            sum+=d[i]*d[j];
        }
    }

    cout << sum << endl;
    
}

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

int main()
{
    string a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;

    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());
    reverse(c.begin(), c.end());

    auto n = a.back();
    a.pop_back();
    while (true)
    {
        // cout << n << endl;
        // cout << a << endl;
        // cout << b << endl;
        // cout << c << endl;
        // cout << "---------" << endl;
        if (n == 'a')
        {
            if (a.size() == 0)
            {
                break;
            }
            n = a.back();
            a.pop_back();
        }
        else if (n == 'b')
        {
            if (b.size() == 0)
            {
                break;
            }
            n = b.back();
            b.pop_back();
        }
        else if (n == 'c')
        {
            if (c.size() == 0)
            {
                break;
            }
            n = c.back();
            c.pop_back();
        }
    }

    if (n == 'a')
    {
        cout << 'A' << endl;
    }
    else if (n == 'b')
    {
        cout << 'B' << endl;
    }
    else if (n == 'c')
    {
        cout << 'C' << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define pb push_back
#define pf push_front
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
 
ll gcd(ll x, ll y) {
	if(y==0) return x;
	return gcd(y,x%y);	
}

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

int main()
{
	ll a,b,c;
	cin >> a >> b >> c;
	cout << (b/a>c?c:b/a) << endl;
	return 0;
}


Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <stack>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

int power(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}

int n,m,k,comp,ex[111],ey[111],c[211][211],pwk[111];
bool con[55][55];

stack<pii> stk;
vector<pii> bcc[55];

int pre[55],timer,bcc_cnt;
int dfs(int u,int fa)
{
	int lowu=pre[u]=++timer;
	for(int v=1;v<=n;v++)if(con[u][v])
	{
		pii e=mp(u,v);
		if(!pre[v])
		{
			stk.push(e);
			int lowv=dfs(v,u);lowu=min(lowu,lowv);
			if(lowv>=pre[u])
			{
				bcc_cnt++;
				while(!stk.empty())
				{
					bcc[bcc_cnt].pb(stk.top());
					stk.pop();
					if(*bcc[bcc_cnt].rbegin()==e)break;
				}
			}
		}
		else if(pre[v]<pre[u]&&v!=fa)
		{
			stk.push(e);
			lowu=min(lowu,pre[v]);
		}
	}
	return lowu;
}

int main()
{
	for(int i=0;i<211;i++)
	{
		c[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			c[i][j]=c[i-1][j]+c[i-1][j-1];
			if(c[i][j]>=mod)c[i][j]-=mod;
		}
	}
	
	get3(n,m,k);
	pwk[0]=1;for(int i=1;i<111;i++)pwk[i]=1ll*pwk[i-1]*k%mod;
	for(int i=1;i<=m;i++)
	{
		get2(ex[i],ey[i]);
		con[ex[i]][ey[i]]=con[ey[i]][ex[i]]=1;
	}
	
	for(int i=1;i<=n;i++)if(!pre[i])dfs(i,0);
	
	int ans=1;
	for(int i=1;i<=bcc_cnt;i++)
	{
		int sz=(int)bcc[i].size();
		set<int> tmp;
		for(int j=0;j<sz;j++)
		{
			tmp.insert(bcc[i][j].ff);
			tmp.insert(bcc[i][j].ss);
		}
		if(sz==1)ans=1ll*ans*k%mod;
		else
		{
			if((int)tmp.size()==sz)
			{
				int sum=0;
				for(int j=1;j<=sz;j++)
				{
					sum+=pwk[__gcd(sz,j)];
					if(sum>=mod)sum-=mod;
				}
				ans=1ll*sum*ans%mod*power(sz,mod-2)%mod;
			}
			else ans=1ll*ans*c[sz+k-1][k-1]%mod;
		}
	}
	
	printendl(ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
ll inf=100000000000000000,mod=1000000007,m;

int main(){
    ll n,sum=0,prev=1,curr;
    cin>>n;curr=n;n=1;
    while(curr)
    {
       sum+=prev;
       curr/=2;
       prev*=2;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n){
        cin >> s[i];
        sort(all(s[i]));
    }
    sort(all(s));
    LL ans = 0, tmp = 1;
    rep(i, n-1){
        if(s[i] == s[i+1]) tmp++;
        else{
            ans += tmp*(tmp-1)/2;
            tmp = 1;
        }
    }
    ans += tmp*(tmp-1)/2;
    cout << ans << endl;

}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define forn_s(i,start,lim) for(ll_s i=start;i<lim;i++)
#define forn_d_s(i,start,lim) for(ll_s i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define debug1(a) cout<<a<<endl
#define debug2(a,b) cout<<a<<" "<<b<<endl
#define debug3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

pair <ll,ll> p[5005];
ll dp[5005][5005];

bool mycompare(pair <ll,ll> a,pair <ll,ll> b){
  return a.f+a.s < b.f+b.s;
}

int main()
{
  //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,1,n+1) cin>>p[i].f>>p[i].s;
  sort(p+1,p+1+n,mycompare);
  //forn(i,1,n+1) cout<<p[i].f<<" "<<p[i].s<<endl;
  forn(i,1,5005){
    forn(j,1,5005) dp[i][j]=1e18;
  }
  dp[1][1]=p[1].s;
  forn(i,2,n+1){
    forn(j,1,n+1){
      if(j>i) break;
      if(j==i){
        if(p[i].f >= dp[i-1][j-1]) dp[i][j]=dp[i-1][j-1]+p[i].s;
        break;
      }
      if(p[i].f >= dp[i-1][j-1])
        dp[i][j]=min(dp[i-1][j-1]+p[i].s,dp[i-1][j]);
      else
        dp[i][j]=dp[i-1][j];
    }
  }
  /*forn(i,1,n+1){
    forn(j,1,n+1) if(dp[i][j]==1e18) cout<<"inf  ";else cout<<dp[i][j]<<"  ";
    cout<<endl;
  }*/
  forn_d(i,n,1){
    if(dp[n][i]!=1e18){
      cout<<i<<endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 195968