akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll k, q; cin >> k >> q;
	vector<ll>d(k);
	for (ll i = 0; i < k; i++) {
		cin >> d[i];
	}
	while (q--) {
		ll n, x, m; cin >> n >> x >> m;
		auto dd = d;
		for (auto& xx : dd) {
			xx = (xx % m == 0 ? m : xx % m);
		}
		ll sumd = 0;
		for (ll xx : dd) {
			sumd += xx;
		}
		ll last = x % m + sumd * ((n - 1) / k);
		for (ll i = 0; i < (n - 1) % k; i++) {
			last += (dd[i]);
		}
		ll ans = (n - 1) - (last / m);
		cout << ans << '\n';
	}

	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 384
import java.io.IOException;
import java.util.NoSuchElementException;

import java.io.InputStream;

import java.util.Arrays;
import java.util.Comparator;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner fs = new FastScanner();

        final int N = fs.nextInt();

        Integer[] X = new Integer[N];
        Integer[] Y = new Integer[N];

        for (int i = 0; i < N; i++) {
            X[i] = fs.nextInt();
            Y[i] = X[i];
        }

        Arrays.sort(Y, Comparator.reverseOrder());

        Integer left = Y[N / 2 - 1];
        Integer right = Y[N / 2];

        for (int i = 0; i < N; i++)
            System.out.println(left.compareTo(X[i]) <= 0 ? right : left);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
        if (hasNextByte()) return buffer[ptr++];
        else return -1;
    }
    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
        while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
        return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if(b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 59544
#include<stdio.h>

int main(){
  int group[14]={1,3,5,7,8,10,12,0,4,6,9,11,0,2};
  int x,y;
  int i;
  scanf("%d %d",&x,&y);
  for(i=0;i<14;i++){
    if(group[i]==x){
      break;
    }
  }
  if(i<7){
    for(int j=0;j<7;j++){
      if(group[j]==y){
	printf("Yes");
	return 0;
      }
    }
    printf("No");
    return 0;
  }
  if(i>7 && i<12){
    for(int j=8;j<12;j++){
      if(group[j]==y){
	printf("Yes");
	return 0;
      }
    }
    printf("No");
    return 0;
  }
  if(i>12 && y==2){
    printf("Yes");
    return 0;
  }else{
    printf("No");
    return 0;
  }
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort()
f.sort(reverse=True)


ng = -1
ok = 10**12
while ok-ng > 1:
    mid = (ok+ng)//2
    cnt = 0

    for i,e in enumerate(a):    
        cnt += max(0,e-mid//f[i])
    if cnt <= k:
        ok = mid
    else:
        ng = mid

print(ok)

Measured memory_bytes: 119500
#include<bits/stdc++.h>
using namespace std;
int calc(int x, int y, int z)
{
  return (x * x + y * y + z * z + x * y + y * z + z * x);
}
int main()
{
  vector<int> vc(10001);
  int x = 0;
  for(int i = 1; i <= 100; i++) 
  {
    x = calc(i, i, i);
	if(x <= 10000) vc[x] += 1;
    for(int j = 1; j <= 100; j++)
    {
      if(j != i) {x = calc(i, i, j);
      if(x <= 10000) vc[x] += 3;
      else break;}
    }
  }
  for(int i = 1; i <= 100; i++)
  {
    for(int j = i + 1; j <= 100; j++)
    {
      for(int k = j + 1; k <= 100; k++)
      {
        x = calc(i, j, k);
        if(x <= 10000) vc[x] += 6;
        else break;
      }
    }
  }
  int n;
  cin>>n;
  for(int i = 1; i <= n; i++) cout<<vc[i]<<"\n";
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int A,B,C;

int main(){
	
	ll n,a,b;cin >> n >> a >> b;
	vector<ll> v(n);
	REP(i,n){
		int tmp;cin >> tmp;
		if(tmp <= a)A++;
		else if(tmp <= b)B++;
		else C++;
	}
	
	cout << min(A,min(B,C)) << endl;
	
	return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

int gcd(int a, int b) {
	return b != 0 ? gcd(b, a%b) : a;
}

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

#define N_MAX 310
#define MOD 1000000007

void solv()
{
	int K, X; scanf("%d%d", &K, &X);
	if (500 * K >= X) {
		printf("Yes");
	}
	else {
		printf("No");
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}


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

int main()
{
 int i,n;
 cin>>n;
 double x[n];
 string u[n];
 double count=0;
 
 for (i=0;i<n;i++)
 {
  cin>>x[i];
  cin>>u[i];
  if(u[i][0]=='J')
   count=count+x[i];
  else
   count=count+(380000*x[i]);
 }
 cout<<count;
 return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
  h, w = map(int, input().split())
  red = [[int(x) for x in input().split()] for _ in range(h)]
  blue = [[int(x) for x in input().split()] for _ in range(h)]
  
  max_dp = 13000
  dp_first = 2**max_dp
  dp = [[0]*(w+1) for _ in range(h+1)]
  
  for i in range(h):
    for j in range(w):
      sub = dp[i][j+1]|dp[i+1][j]
      sub = sub|dp_first if i == j == 0 else sub
      shift = abs(red[i][j]-blue[i][j])
      dp[i+1][j+1] = (sub << shift)|(sub >> shift)
  
  judge = dp[h][w]
  for i in range(max_dp):
    if (judge >> max_dp+i)&1 or (judge >> max_dp-i)&1:
      print(i)
      sys.exit()
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 26628
moto=input()
count=0
countlist=[0]
for i in range(len(moto)):
  if moto[i]=="A" or moto[i]=="T" or moto[i]=="G" or moto[i]=="C":
    count=count+1
  else:
    countlist.append(count)
    count=0
countlist.append(count)
kotae=max(countlist)
print(kotae)

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

using namespace std;

#define all(x) (x).begin(), (x).end()
typedef long double ld;
typedef long long ll;


int main() {
#ifdef LOCAL
  assert(freopen("a.in", "r", stdin));
#endif

  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<int> a(n + 2);
  a[0] = -1;
  a[n + 1] = -2;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }

  int ans = 0;
  bool bad = true;
  while (bad) {
    bad = false;
    for (int i = 1; i <= n; ++i)
      if (a[i] == a[i - 1] && a[i] == a[i + 1]) {
        bad = true;
        a[i] = -i - 1000;
        ++ans;
        break;
      }

    if (!bad) {
      for (int i = 1; i <= n; ++i)
        if (a[i] == a[i - 1]) {
          bad = true;
          a[i] = -i - 1000;
          ++ans;
          break;
        }
    }
  }

  cout << ans << "\n";

}



Measured memory_bytes: 256
///not today

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

typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef pair<long long, long long> pll;

#define SZ(x) (int)(x).size()
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define int long long
#define accept_sho ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#define lc (v << 1)
#define rc ((v << 1)| 1)
#define MID ((R + L) >> 1)

const int mod = 998244353, maxn = 1e6 + 3;
int fc[maxn];

int pw(int a, int b){
      int ans = 1;
      for(int i = 30; i >= 0; i --){
            ans *= ans;                                                    ans %= mod;
            if(b & (1 << i)){
                  ans *= a;                                                ans %= mod;
            }
      }
      return ans;
}

int c(int k, int n){
      if(k == 0){
            return 1;
      }
      if(k > n){
            return 0;
      }
      int ans = fc[n];
      ans *= pw(fc[k], mod - 2);                                           ans %= mod;
      ans *= pw(fc[n - k], mod - 2);                                       ans %= mod;
      return ans;
}

int32_t main(){
      accept_sho
      int n, m;
      cin >>n >>m;
      fc[0] = 1;
      for(int i = 1; i < maxn - 1; i ++){
            fc[i] = fc[i - 1] * i;                                         fc[i] %= mod;
      }
      int ans = max(n, m);
      for(int i = 1; i <= min(n, m); i ++){
            int x = ( c(n - i, n + m - (2 * i)) * c(i, 2 * i) )% mod;
            x *= pw(c(n, n + m) ,mod - 2);                                 x %= mod;
            x *= pw(2, mod - 2);                                           x %= mod;
            ans = (ans + x)% mod;
      }
      cout <<ans <<endl;
      return false;
}


Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=3005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<pair<double,string>> S(N);
        
        for(int i=0;i<N;i++){
            cin>>S[i].second;
            vector<int> A(9);
            for(int j=0;j<9;j++) cin>>A[j];
            double price=A[6]*A[7]*A[8]-A[0],time=0;
            for(int j=1;j<=5;j++) time+=A[j];
            time+=(A[8]-1)*(A[4]+A[5]);
            //time*=A[8];
            
            S[i].first=-(price/time);
        }
        
        sort(all(S));
        
        for(int i=0;i<N;i++){
            cout<<S[i].second<<endl;
        }
        cout<<"#\n";
    }
    
}



Measured memory_bytes: 3188
k, n = map(int, input().split())
home_positions = list(map(int, input().split()))


def max_distance_homes(homes):
    max_distance = 0
    for i in range(len(homes) - 1):
        distance = homes[i + 1] - homes[i]
        if max_distance < distance:
            max_distance = distance
    distance = k + homes[0] - homes[-1]
    if max_distance < distance:
        max_distance = distance
    return max_distance


print(k - max_distance_homes(home_positions))

Measured memory_bytes: 26444
#include<cstdio>
#define MAX_SIZE 100

int main() {
  int size, numbers[MAX_SIZE];

  scanf("%d", &size);

  for(int i = 0; i < size; i++) {
    scanf("%d", &numbers[i]);
  }

  for(int i = size -1; i >= 0; i--) {
    printf("%d", numbers[i]);

    if(i != 0) {
      printf(" ");
    }
  }

  printf("\n");
}



Measured memory_bytes: 2700
n = int(input())
if n <= 99:
  print(0)
  exit()
if 100 <= n <= 105:
  print(1)
  exit()
dp = [True] + [False] * n
for i in range(100, n + 1):
  if dp[i - 100] or dp[i - 101] or dp[i - 102] or dp[i - 103] or dp[i - 104] or dp[i - 105]:
    dp[i] = True
print([0, 1][dp[n]])

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S,T;
  cin >> S >> T;
  int count = 0;
  for (int i = 0; i < 3; i++){
    if (S.at(i) == T.at(i)) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
// بِسمِ اللہِ  الرَّحم?نِ  الرَّ حِیم
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define INF 1e18
#define N 1000100
typedef pair<ll,ll> pll;
ll power(ll a,ll b)
{
    if(b==1)return a;
    if(b==0)return 1;
    ll temp=power(a,b/2);
    ll ans=temp*temp;
    if(b&1)
        ans*=a;
    return ans;
}
ll power(ll a,ll b,ll p)
{
    a=a%p;
    if(b==1)return a;
    if(b==0)return 1;

    ll temp=power(a,b/2,p);
    ll ans=(temp*temp)%p;
    if(b&1)
        ans=(a*ans)%p;
    return ans;
}
ll inv(ll a)
{
    return power(a,MOD-2,MOD);
}
//code begins
ll b[N];
signed main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    cin.sync_with_stdio(false);
    ll t;
    t=1;
//    cin>>t;
    while(t--)
    {
        ll a,b,c;cin>>a>>b>>c;
        if(c-a-b<=0)
        {
            cout<<"No\n";
            continue;
        }
        ll left=4*a*b;
        ll right=c*c+a*a+b*b-2*a*c+2*a*b-2*b*c;
        if(left<right)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	cin >> n;
	int P[2*100001];
	for (int i = 0; i < n; ++i)
	{
		cin >> P[i];
	}
	int mi = (1<<30)-1;
	int ans = 0;
	for (int i = 0; i < n; ++i)
	{
		ans += (P[i] <= mi);
		mi = min(mi, P[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

template< typename T >
struct WeightedUnionFind {
    vector< int > data;
    vector< T > ws;

    WeightedUnionFind() {}

    WeightedUnionFind(int sz) : data(sz, -1), ws(sz) {}

    int find(int k) {
        if(data[k] < 0) return k;
        auto par = find(data[k]);
        ws[k] += ws[data[k]];
        return data[k] = par;
    }

    T weight(int t) {
        find(t);
        return ws[t];
    }

    bool unite(int x, int y, T w) {
        w += weight(x);
        w -= weight(y);
        x = find(x), y = find(y);
        if(x == y) return false;
        if(data[x] > data[y]) {
            swap(x, y);
            w *= -1;
        }
        data[x] += data[y];
        data[y] = x;
        ws[y] = w;
        return true;
    }

    T diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(void) {
    int N, M;
    cin >> N >> M;
    WeightedUnionFind<int> uf(N);
    while(M--) {
        int L, R, D;
        cin >> L >>R >> D;
        --L; --R;
        if(uf.find(L) != uf.find(R)) {
            uf.unite(L, R, D);
        } else if(uf.diff(L, R) != D) {
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 1152
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    int a,b,c,d; cin >> a >> b >> c >> d;
    if((a+b) > (c+d)) {
        cout << "Left" << endl;
    } else if((a+b) == (c+d)) {
        cout << "Balanced" << endl; 
    } else {
        cout << "Right" << endl; 
    }
    return 0;
}
    



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdlib.h>
using namespace std;
struct kinomi{
    double a;
    char b[10];
};
int main(){
    int a;
    double sum;
    cin>>a;
    struct kinomi hin[a];
    for(int i=0;i<a;i++) cin>>hin[i].a>>hin[i].b;
    for(int i=0;i<a;i++){
        if(hin[i].b[0]=='B') sum=sum+380000*hin[i].a;
        else if(hin[i].b[0]=='J') sum+=hin[i].a;
    }
    cout<<sum;
}


Measured memory_bytes: 256
#import numpy as np
#import math
#from fractions import gcd

def main():

    ##get int
    first_input = list(map(lambda x:int(x), input().split(" ")))
    #second_input = list(map(lambda x:int(x), input().split(" ")))

    ##get float
    #first_input = list(map(lambda x:float(x), input().split(" ")))
    #second_input = list(map(lambda x:float(x), input().split(" ")))

    ##get string
    #first_input = input().split(" ")
    #second_input = input().split(" ")

    print(first_input.index(0)+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61644
#include <bits/stdc++.h>
#define INF 1000000007
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define print(x) cout << x << "\n"
#define print2(x, y) cout << x << " " << y << "\n"
#define printv(vec) rep(lp, vec.size()) cout << vec[lp] << " "; print(""); 
#define ALL(v) v.begin(), v.end()
#define SUM(v) accumulate(ALL(v), 0)
#define MAX(v) *max_element(ALL(v))
#define MIN(v) *min_element(ALL(v))
#define SORT(v) sort(ALL(v))
#define REV(v) reverse(ALL(v))
typedef long long ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;

const int mod = 1000000007;
class mint {
public:
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

ll modpow(ll a, ll n){
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

ll dp[1010][4100];

void Main(){

	ll N, M;
	cin >> N >> M;
	vl a(M), b(M);
	vector<vector<bool>> v(M, vector<bool>(12));
	rep(i, M){
		cin >> a[i] >> b[i];
		rep(j, b[i]){
			ll in;
			cin >> in;
			v[i][in - 1] = true;
		}
	}

	rep(i, 1010) rep(j, 4100) dp[i][j] = INF;
	dp[0][0] = 0;

	rep(i, M){
		rep(j, 4096){
			ll cur = j;
			rep(k, 12){
				if(!(cur & (1LL << k)) && v[i][k]) cur += (1LL << k);
			}
			chmin(dp[i + 1][cur], dp[i][j] + a[i]);
			chmin(dp[i + 1][j], dp[i][j]);
		}
	}
	
	ll ans = dp[M][modpow(2, N) - 1];
	if(ans == INF) print(-1);
	else print(ans);				

}

int main(){
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	Main();
	return 0;
	
}





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

int main() {
	vector<int> a(10);
	for(int i=1;i<=9;i++){
		cin >>a[i];
	}
	int N;
	cin >>N;
	vector<int> b(N+1);
	for(int i=1;i<=N;i++){
		cin >>b[i];
		for(int k=1;k<=9;k++){
			if(b[i]==a[k]){
				a[k]=0;
			}
		}

	}
	if(a[1]+a[2]+a[3]==0||a[4]+a[5]+a[6]==0||a[7]+a[8]+a[9]==0||a[1]+a[4]+a[7]==0||a[2]+a[5]+a[8]==0||a[3]+a[6]+a[9]==0||a[1]+a[5]+a[9]==0||a[3]+a[5]+a[7]==0){
		cout <<"Yes";
	}
	else{
		cout <<"No";
	}





}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define erep(i, a, b) for (int i = a; i <= (int)(b); i++)
#define per(i, a, b) for (int i = (b)-1; i > (a); i--)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const int INF = (1 << 30) - 1;
const int MOD = 1000000007;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

ll n, cnt[5];
ll ans;
char cc[] = {'M', 'A', 'R', 'C', 'H'};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, 0, n) {
    string s;
    cin >> s;
    rep(j, 0, 5) {
      if (s[0] == cc[j])
        cnt[j]++;
    }
  }
  rep(i, 0, 5) {
    rep(j, i + 1, 5) {
      rep(k, j + 1, 5) { ans += cnt[i] * cnt[j] * cnt[k]; }
    }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
// Aizu Vol-5 0565: Lunch
// 2017.8.31 bal4u@uu

#include <stdio.h>

int main()
{
	int p[5], i, min, ans;

	for (i = 0; i < 5; i++) scanf("%d", p+i);
	for (min = i = 0; i < 3; i++)
		if (min == 0 || min > p[i]) min = p[i];
	ans = min;
	for (min = 0, i = 3; i < 5; i++)
		if (min == 0 || min > p[i]) min = p[i];
	ans += min - 50;
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;
int a[200010],b[200010];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++) {scanf("%d",a+i);b[i]=a[i];}
    sort(b,b+n);
    for(int i=0;i<n;i++) if(a[i]==b[n-1]) cout<<b[n-2]<<endl; else cout<<b[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 3200
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;

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

  string s;
  cin >> s;

  int ans = 0;
  for(int i = 0;i <= 9;i++){
    for(int j = 0;j <= 9;j++){
      for(int k = 0;k <= 9;k++){
        char num[3] = {(char)(i+'0'),(char)(j+'0'),(char)(k+'0')};
	bool flag[3] = {};
	int s_index = 0;
	int n_index = 0;
	while(s_index < s.size() && n_index < 3){
	  if(s[s_index] == num[n_index]){
	    flag[n_index] = true;
	    n_index++;
	  }
	  s_index++;
	}
	if(flag[0] == flag[1] && flag[1] == flag[2] && flag[2] == true){
	  ans++;
	}
      }
    }
  }    
  cout << ans << endl;
} 


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int main(){
	int n,m;
	while(cin>>n){
		if(n==0)break;
		map<char,char> t;
		vector<char> s;
		for(int i=0;i<n;++i){
			char c1,c2;
			cin>>c1>>c2;
			t.insert(map<char,char>::value_type(c1,c2));
		}
		cin>>m;
		for(int i=0;i<m;++i){
			char c;
			cin>>c;
			s.push_back(c);
		}
		for(vector<char>::iterator it=s.begin();it<s.end();++it){
			if(t.find(*it)!=t.end())*it=t.find(*it)->second;
			cout<<*it;
		}
		cout<<"\n";
	}
	return 0;
}

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

int main() {
  int total = 0;
  int max_diff = 0;

  for (int i = 0; i < 5; i++) {
    int t;
    cin >> t;

    int ceil_t = ((t + 9) / 10) * 10;
    total += ceil_t;
    max_diff = max(max_diff, ceil_t - t);
  }

  cout << total - max_diff << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N, M, C;
	int ans = 0;
	cin >> N >> M >> C;
	vector<int> data(M);
	for (int i = 0; i < M; i++)
	{
		cin >> data[i];
	}

	for (int i = 0; i < N; i++)
	{
		lint check = C;
		for (int j = 0; j < M; j++)
		{
			int tmp;
			cin >> tmp;
			check += tmp * data[j];
		}
		if (0 < check)
			ans++;
	}

	cout << ans << endl;
	return;
}

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

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(in);
        int N=sc.nextInt();
        if(N==1)out.println("Hello World");
        else out.println(sc.nextInt()+sc.nextInt());
    }
}

Measured memory_bytes: 21844
l = [int(x) for x in input().split()]
if l[0] == l[1] and l[0] != l[2]:
    print("Yes")
    exit()
if l[0] == l[2] and l[0] != l[1]:
    print("Yes")
    exit()
if l[1] == l[2] and l[0] != l[1]:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))

ls_result = []
idou_cnt = 0
bef = h[0]

for i in h[1:]:
  now = i
  
  if bef >= now:
    idou_cnt += 1
    
  else:
    ls_result.append(idou_cnt)
    idou_cnt = 0
    
  bef = now

ls_result.append(idou_cnt)

print(max(ls_result))

Measured memory_bytes: 14224
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int main() {
    int N, M;
    scanf("%d %d", &N, &M);
    vector<int> V1;
    for (int i = 0; i < M; i++) {
        int tmp;
        scanf("%d", &tmp);
        V1.push_back(tmp);
    }
    sort(V1.begin(), V1.end());
    V1.erase(unique(V1.begin(), V1.end()), V1.end());
    int tg = (int)V1.size();
    if (N >= tg) puts("0");
    else {
       vector<int> V2;
       for (int i = 1; i < tg; i++) {
           V2.push_back(V1[i] - V1[i - 1]);
       }
       sort(V2.rbegin(), V2.rend());
       int ans = V1.back() - V1.front();
       for (int i = 0; i < N - 1; i++) {
           ans -= V2[i];
       }
       printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using psi = pair<string,int>;

int main(){
    string str;
    cin >> str;
    vector<psi> pair_si(str.length()+1);
    int cnt_x = 0,pos=0;

    rep(i,str.length()){
        if(str[i] == 'x'){
            cnt_x++;
        }else{
            pair_si[pos] = make_pair(str[i],cnt_x);
            cnt_x = 0;
            pos++;
        }
    }
    
    pair_si[pos] = make_pair(' ',cnt_x);

int ans = 0;

    if(pos % 2 ==0){
        rep(i,pos/2){
                if(i != pos/2) ans += abs(pair_si[i].second - pair_si[pos - i].second);
                if(pair_si[i].first != pair_si[pos-1-i].first){
                    cout << -1 << endl;
                    return 0;
                }
        }
    }else{
        rep(i,pos/2){  
                ans += abs(pair_si[i].second - pair_si[pos  - i].second);
                if(pair_si[i].first != pair_si[pos-1-i].first){
                    cout << -1 << endl;
                    return 0;
                }
        }
        ans += abs(pair_si[pos/2].second - pair_si[pos/2+1].second);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6656
#[allow(unused_imports)]
use proconio::{fastout, input, marker::*};

#[fastout]
fn main() {
   input! {
      mut n: usize,
   }
   let mut k = 1;
   let mut m = 26;
   while n > m {
      m = (m + 1) * 26;
      k += 1;
   }
   n -= m / 26;

   let mut ans = vec![];
   for _ in 0..k {
      ans.push(b'a' + (n % 26) as u8);
      n /= 26;
   }
   ans.reverse();

   for c in ans {
      print!("{}", c as char);
   }
}


Measured memory_bytes: 2188
"""
すべて等しかったら0
それ以外は A > B を満たすものの内最小の黒以外取れる
"""

N = int(input())

ans = 0
l = []

for i in range(N):

    A,B = map(int,input().split())

    ans += A

    if A > B:
        l.append(B)


if len(l) == 0:
    print (0)
else:
    l.sort()
    print (ans - l[0])
    


Measured memory_bytes: 52200
#include<bits/stdc++.h>
using namespace std;
int n,m;
int s[6],c[6];
bool v[6];
int t[10];
int main() {
	memset(v,0,sizeof(v));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) {
		scanf("%d%d",&s[i],&c[i]);
		if(v[s[i]] && t[s[i]]!=c[i]) {
			cout<<-1;
			exit(0);
		}
		v[s[i]]=1;
		t[s[i]]=c[i];
	}
	if(n==1 && t[1]==0) {
		printf("0\n");
		exit(0);
	}
	if(v[1]==0) {
		t[1]=1;
	}
	bool first=1;
	for(int i=1;i<=n;i++) {
		if(first && t[first]==0) {
			cout<<-1;
			exit(0);
		}
		first=0;
		printf("%d",t[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(500000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def calc(p, P):
    ans = 0
    for i in range(1, len(p)):
        x1, y1 = P[p[i - 1]]
        x2, y2 = P[p[i]]
        ans += sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)

    return ans


def solve():
    N = int(input())
    P = []
    for _ in range(N):
        X, Y = map(int, input().split())
        P.append((X, Y))

    ans = 0
    num = 0
    for p in permutations(range(N)):
        ans += calc(p, P)
        num += 1
    print(ans / num)


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9952
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
/* do your best */

int solve(int startNode, vector<vector<int>> &g) {
  // startNode から幅優先探索をして，どれだけ進めるかを返す．
  // ダメなら -1 をかえす

  int n = g.size();

  bool ok = true;
  int ret = 0;

  queue<tuple<int, int, int>> que; // cur, par, cost
  vector<int> used(n, -1);
  que.push({startNode, -1, 1});

  while (!que.empty()) {
    int cur, par, cost;
    tie(cur, par, cost) = que.front();
    que.pop();
    if (used[cur] != -1) {
      continue;
    }
    used[cur] = cost;
    ret = max(ret, cost);
    for (auto nxt : g[cur]) {
      if (used[nxt] != -1 and cost - 1 != used[nxt]) {
        ok = false;
        break;
      }

      if (!ok) break;

      if (used[nxt] == -1) que.push({nxt, cur, cost + 1});
    }
  }



  if (!ok) return -1;
  else return ret;
}

int main() {
  
  // 幅優先探索をするが，途中で探索済みに遷移しようとしたら out
  // これをすべての頂点に対してやる
    
  int n; cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c; cin >> c;
      if (c == '1') {
        g[i].push_back(j);
      }
    }
  }

  int ans = -1;

  for (int i = 0; i < n; i++) {
    ans = max(ans, solve(i, g));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    char a,b;
    int t,x;
    scanf("%c %c",&a,&b);
    if(a=='H')
        t=1;
    else
        t=2;
    if(t==1)
    {
        if(b=='H')
            x=1;
        else
            x=2;
    }
    else
    {
        if(b=='H')
            x=2;
        else
            x=1;
    }
    if(x==1)
        printf("H");
        else
        printf("D");
    return 0;
}



Measured memory_bytes: 128
import sys
input = sys.stdin.readline


N,M,X,Y=list(map(int,input().split()))
x =list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)

if min(y) - max(x) >0:
    print('No War')
else:
    print('War')



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

int main() {
  int N, M;
  cin >>N >>M;
  
  //cout <<N <<" " <<M <<endl;
  
  vector<int> k(M);
  vector<vector<int>> s(M);
  
  for (int i=0; i<M; i++){
    cin >>k.at(i);
    //cout <<k.at(i);
    for (int j=0; j<k.at(i); j++){
      int tmp;
      cin >> tmp;
      s.at(i).push_back(tmp-1);
      //cout  <<" " << tmp;
    }
    //cout <<endl;
  }
  
  vector<int> p(M);
  for (int i=0; i<M; i++){
    cin >>p.at(i);
    //cout << p.at(i) <<" ";
  }
  
  int ans=0;
  int flag=0;
  for (int i=0; i<(1<<N); i++){ // bit loop
    bitset<10> bit(i);
    flag=0;
    for (int j=0; j<M; j++){
      int sum=0;
      for (int k=0; k<s.at(j).size(); k++){
        int tmp;
        tmp=s.at(j).at(k);
        if(bit.test(tmp)) sum++;
      }
      if(sum%2 == p.at(j)) flag++;
    }
    if (flag == M) ans ++;
  }
  
  cout <<ans <<endl;

}


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

int main(){
    vector<long> nums(3);
    vector<int> att(3);
    att = {1, 0, -1};
    long numk, sum=0;
    for(auto i=0;i<nums.size();i++){
        cin >> nums.at(i);
    }
    cin >> numk;
    for(auto i=0;i<nums.size();i++){
        sum += (numk >= nums.at(i)) ? nums.at(i)*att.at(i) : numk*att.at(i);
        numk = (numk >= nums.at(i)) ? numk-nums.at(i) : 0;
        if(numk == 0)break;
    }
    cout << sum << endl;
}


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

#ifdef LOCAL
#include <debug.hpp>
#else
#define debug(...) void()
#endif

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char init[] = {'M', 'A', 'R', 'C', 'H'};
  int n;
  cin >> n;
  vector<long long> cnt(5, 0);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 5; j++) {
      if (s[0] == init[j]) cnt[j]++;
    }
  }
  int cc = 0;
  for (int i = 0; i < 5; i++) {
    if (cnt[i] > 0) cc++;
  }
  if (cc <= 2) {
    cout << 0 << '\n';
    return 0;
  }
  long long ans = 0;
  for (int bit = 0; bit < (1 << 5); bit++) {
    int on_cnt = 0;
    for (int i = 0; i < 5; i++) {
      if (bit & (1 << i)) on_cnt++;
    }
    if (on_cnt != 3) continue;
    long long ans1 = 1;
    for (int i = 0; i < 5; i++) {
      if (bit & (1 << i)) ans1 *= cnt[i];
    }
    ans += ans1;
  }
  cout << ans << '\n';
  return 0;
}

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

def string_three_numbers_spliter():
    a, b, c = [int(i) for i in input().split()]
    return a, b, c


def main():
    a, b, c = string_three_numbers_spliter()
    lst = [a, b, c]
    lst.sort()
    print(' '.join(str(i) for i in lst))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7756
# Graph II - Single Source Shortest Path I
def dijkstra(length, adj_m):
    INFTY = float('inf')
    d = [INFTY for _ in range(length)]
    d[0] = 0
    Q = [i for i in range(length)]
    while Q:
        idx = INFTY
        minv = INFTY
        for q in Q:
            if d[q] < minv:
                idx, minv = q, d[q]
        u = Q.pop(Q.index(idx))
        for i, v in enumerate(adj_m[u]):
            if not v == -1:
                if d[i] > d[u] + v:
                    d[i] = d[u] + v
    return d

n = int(input())
adj_m = [[-1 for _ in range(n)] for _ in range(n)]
for _ in range(n):
    ss = list(map(int, input().split()))
    u, k = ss[0], ss[1]
    for i in range(k):
        vi,ci = ss[2*i+2], ss[2*i+3]
        adj_m[u][vi] = ci
d = dijkstra(n, adj_m)
for i,v in enumerate(d): print(i,v)


Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  string b = "No" ;
    for(int i = 1;i < 10;i++){
      if(a%i==0 && a/i < 10)b = "Yes";}
  cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
using ll = long long;
using namespace std;
int a[110];
int main(void)
{
    int sum = 0;
    int N;
    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        cin >> a[i];
        sum += a[i];
    }
    int ans = (sum % 10 != 0) ? sum : 0;
    for (int i = 0; i < N; ++i)
    {
        if ((sum - a[i]) % 10 != 0)
        {
            ans = max(ans, sum - a[i]);
        }
    }
    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 D;
    cin >> D;
    int c[30];
    rep (i, 26) cin >> c[i];
    int s[D+5][30];
    rep (i, D) rep (j, 26) cin >> s[i][j];

    rep (i, D){
        int maxi = -1;
        int ans = 0;
        rep (j, 26){
            if (maxi < s[i][j]){
                ans = j+1;
                maxi = s[i][j];
            }
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    x = int(input())

    if x >= 1:
        return 0
    return 1


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


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define LINF 3e18+7
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const double PI = acos(-1.0);
const double EPS = 1e-10;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>> A(N);
    priority_queue<int> q;
    REP(i,N){
        cin>>A[i].first>>A[i].second;
    }
    VSORT(A);

    ll ans = 0;
    ll sum = 0;
    int idx = 0;
    for(int i=M-1;i>=0;i--){
        while(idx<N){
            if(i+A[idx].first <= M){
                q.push(A[idx].second);
                idx++;
            }
            else break;
        }
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
void check(bool p)
{
  if(!p)
  {
    puts("-1");
    exit(0);
  }
}
const int B = 35;
int N;
long long X[1010];
long long Y[1010];
long long XpY[1010];
long long XmY[1010];
int main()
{
  scanf("%d", &N);
  for(int i=0; i<N; ++i)
  {
    scanf("%lld%lld", X+i, Y+i);
    XpY[i] = X[i]+Y[i];
    XmY[i] = X[i]-Y[i];
  }
  vector<long long> W;
  if(XpY[0]%2 == 0)
  {
    W.push_back(1LL);
    for(int i=0; i<N; ++i)
    {
      XpY[i]++; XmY[i]++;
    }
  }
  for(int i=0; i<N; ++i) 
      check(XpY[i]%2 != 0);
  for(int i=0; i<B; ++i) W.push_back(1LL<<i);
  for(int i=0; i<N; ++i)
  {
    XpY[i] += (1LL<<B)-1;
    XmY[i] += (1LL<<B)-1;
    XpY[i] /= 2;
    XmY[i] /= 2;
  }
  printf("%d\n", (int)W.size());
  for(auto x: W) printf("%lld ", x);
  puts("");
  for(int i=0; i<N; ++i)
  {
    if(W.size() == B+1) putchar('L');
    for(int j=0; j<B; ++j)
    {
      bool p = (XpY[i]&(1LL<<j)) != 0;
      bool m = (XmY[i]&(1LL<<j)) != 0;
      if(!p && !m) putchar('L');
      if( p &&  m) putchar('R');
      if(!p &&  m) putchar('D');
      if( p && !m) putchar('U');
    }
    puts("");
  }
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;

    
    rep1(i,N) {
        int cnt = 0;
        string S1 = S.substr(0, i);
        string S2 = S.substr(i,N-i);
        vei check1(26,0);
        vei check2(26,0);
        rep(j,S1.length()) check1[S1[j] - 'a']++;
        rep(j,S2.length()) check2[S2[j] - 'a']++;
        rep(j,26) if(check1[j] != 0 and check2[j] != 0) cnt++;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void exec1()
{
	int a, b;
	cin >> a >> b;
	string answer;
	if (a % 2 == 0 || b % 2 == 0) {
		answer = "Even";
	}
	else {
		answer = "Odd";
	}

	cout << answer << endl;
}
int main()
{
	exec1();
	return 0;
}


Measured memory_bytes: 3024
import sys
readline = sys.stdin.readline

# dp[i][j] = i番目の子供まででj個の飴を配る場合の数
# dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] + ... + dp[i - 1][j - A[i]]
# 累積和を使える

N,K = map(int,readline().split())
A = list(map(int,readline().split()))
DIV = 10 ** 9 + 7

dp = [[0] * (K + 1) for i in range(N + 1)]
dp[0][0] = 1
sdp = [[0] * (K + 1) for i in range(N + 1)]
for i in range(len(sdp[0])):
  sdp[0][i] = 1

for i in range(1, N + 1):
  for j in range(K + 1):
    # dp[i][j] = dp[i - 1][j] + dp[i - 1][j - 1] + ... + dp[i - 1][j - A[i]]
    # 左端をj - A[i], 右端をjとする累積和
    dp[i][j] = sdp[i - 1][j]
    if j - A[i - 1] - 1 >= 0:
      dp[i][j] -= sdp[i - 1][j - A[i - 1] - 1]
    dp[i][j] %= DIV
  sdp[i][0] = dp[i][0]
  for j in range(1, K + 1):
    sdp[i][j] = sdp[i][j - 1] + dp[i][j]
    sdp[i][j] %= DIV

print(dp[N][K])


Measured memory_bytes: 222664
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// Still trying to be normal
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int cost[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(cost,0,sizeof cost);
    int n;
    cin>>n;
    int vet[maxn];
    rep(i,0,n){
        cin>>vet[i];
    }
    cost[1]=abs(vet[0]-vet[1]);
    rep(i,2,n){
        cost[i]=min(cost[i-1]+abs(vet[i]-vet[i-1]),cost[i-2]+abs(vet[i]-vet[i-2]));
    }
    cout<<cost[n-1]<<'\n';
    return 0;   
}

Measured memory_bytes: 1024
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            switch (s.charAt(i)) {
                case '0':
                    builder.append("0");
                    break;
                case '1':
                    builder.append("1");
                    break;
                case 'B':
                    if (builder.length() > 0) {
                        builder.deleteCharAt(builder.length() - 1);
                    }
                    break;
            }
        }
        System.out.println(builder.toString());
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	char b;
	cin >> b;
	if (b == 'A') cout << "T\n";
	if (b == 'T') cout << "A\n";
	if (b == 'C') cout << "G\n";
	if (b == 'G') cout << "C\n";


	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a>>b >> c;
    if(c>=a && c<=b){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256