akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main(){
    vector<long long> d(3);
    cin >> d[0];
    cin >> d[1];
    cin >> d[2];

    if(d[0]%2 && d[1]%2 && d[2]%2){
        sort(d.begin(),d.end());
        cout << d[0] * d[1];
    }else{
        cout << 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}

int main () {
	SpeedForce;
	int x;
	cin >> x;
	x -= 400;
	x /= 200;
	cout << 8-x;	


	return Accepted;
}

// B...a

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
using namespace std;
using Graph = vector<vector<int> >;
Graph G;
void dfs(int v, vector<bool> &seen, int &res) {
    bool end = true;
    for (int i = 0; i < seen.size(); ++i) if (!seen[i] && i != v) end = false;
    if (end) {
        ++res;
        return;
    }
    seen[v] = true;
    for (auto nv : G[v]) {
        if (seen[nv]) continue;
        dfs(nv, seen, res);
    }
    seen[v] = false;
}
int main() {
    int N, M; cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<bool> seen(N, false);
    int res = 0;
    dfs(0, seen, res);
    cout << res << endl;
}

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

using namespace std;

#define ll long long

void solve() {
	string s;
	cin >> s;
	cout << (s[0] == '9' || s[1] == '9' ? "Yes\n" : "No\n");
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
char buf[114514];
string S[3];

int main() {
  scanf("%d", &N);
  rep(i, 3) {
    scanf("%s", buf);
    S[i] = buf;
  }

  int ans = 0;
  rep(i, N) {
    map<char, int> cnt;
    int m = 0;
    rep(j, 3) {
      cnt[S[j][i]]++;
      MX(m, cnt[S[j][i]]);
    }
    ans += 3 - m;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc144/tasks/abc144_d
import math

a, b, x = list(map(int, input().split()))
if a * a * b * (1/2) <= x:
    tmp = 2 * (a*a*b-x) / (a*a*a)
    print(math.degrees(math.atan(tmp)))
else:
    tmp = a*b*b / (2*x)
    print(math.degrees(math.atan(tmp)))


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

using namespace std;


int main(){
     #ifndef ONLINE_JUDGE 
    freopen("inp.txt", "r", stdin); 
    freopen("oup.txt", "w", stdout); 
    #endif
    string s;
    cin>>s;
    if(s[1]=='B'){
        s[1]='R';
    }
    else{
        s[1]='B';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int main(){
	int n;
    cin >> n;
    vector<string> s;
    REP(i, n){
        string tmp;
        cin >> tmp;
        s.pb(tmp + tmp);
    }
    int ans = 0;
    REP(k, n){
        bool flag = false;
        FOR(i, 1, n){
            if(flag) break;
            REP(j, i){
                if(flag) break;
                if(s[i][j + k] != s[j][i + k]){
                    flag = true;
                }
            }
        }
        if(!flag){
            ans += n;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<(int)(n);i++)
#define N 200000

long long gcd(long long x, long long y) {
	if (x < 0)x = -x;
	if (y < 0)y = -y;
	if (x > y)swap(x, y);
	if (x == 0)return y;
	if (y%x == 0)return x;
	return gcd(y%x, x);
}

int main() {
	int n;
	long long a, b, c, d, g, x;
	scanf("%d", &n);
	f(i, n) {
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		if (a < b) {
			printf("No\n");
			continue;
		}
		if (d < b) {
			printf("No\n");
			continue;
		}
		g = gcd(b, d);
		x = a % g;
		x = (c - x + g) / g;
		x = x * g;
		x += (a%g);
		if(x<b)printf("No\n");
		else printf("Yes\n");
	}


	return 0;
}

Measured memory_bytes: 128
//
//AtCoder Beginner Contest 143
//D - Triangles
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> l(n);
    REP(i, n) cin >> l[i];

    sort(ALL(l));

    int ans = 0;
    REP(b, n){
        REP(a, b){
            int ab = l[a]+l[b];
            int lt = b + 1;
            int rt = lower_bound(l.begin(), l.end(), ab) - l.begin();
            ans += rt - lt;
        }
    }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main(){
  ll n;
  ll k;
  ll q;
  ll x;
  ll A[n] = {0};
  cin >> n >> k >> q;
  rep(i,q){
    cin >> x;
    A[x-1]++;
  }
  rep(i,n){
    if(k-(q-A[i]) > 0) printf("Yes\n");
    else printf("No\n");
  }

  return 0;

}


Measured memory_bytes: 33408
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int max_k = 0, max_k_offset = 0;
    for (int i = 0; i < k; i++) max_k += p[i];
    int total = max_k;

    /* 隣接するK個のサイコロの組み合わせ最大値を求める */
    for (int i = 1; i <= n - k; i++){
        total -= p[i - 1];
        total += p[i + (k - 1)];
        if (total > max_k){
            max_k = total;
            max_k_offset = i;
        }
    }
    /* 期待値を計算する */
    double ans = 0;
    for (int i = max_k_offset; i < max_k_offset + k; i++){
        double p_seq = (p[i] * (p[i] + 1)) / 2;
        double e_value = p_seq / p[i];
        ans += e_value;
    }
    printf("%f\n", ans);
    return 0;
}

Measured memory_bytes: 1792
N, MA, MB = gets.split.map(&:to_i)
abcs = readlines.map { |l| l.split.map(&:to_i) }

NMAX = 40
ABMAX = 10

dp = Array.new(N+1) { Array.new(NMAX*ABMAX+1) { Array.new(NMAX*ABMAX+1, Float::INFINITY) }}
dp[0][0][0] = 0

(0..(N-1)).each do |i|
  (0..(NMAX*ABMAX)).each do |ca|
    (0..(NMAX*ABMAX)).each do |cb|
      next if dp[i][ca][cb] == Float::INFINITY
      dp[i+1][ca][cb] = [ dp[i+1][ca][cb] , dp[i][ca][cb] ].min
      dp[i+1][ca+abcs[i][0]][cb+abcs[i][1]] = [ dp[i+1][ca+abcs[i][0]][cb+abcs[i][1]] , dp[i][ca][cb] + abcs[i][2] ].min
    end
  end
end

ans = Float::INFINITY
(1..(NMAX*ABMAX)).each do |ca|
  (1..(NMAX*ABMAX)).each do |cb|
    ans = [ ans , dp[N][ca][cb] ].min if ca * MB == cb * MA
  end
end

ans = -1 if ans == Float::INFINITY
puts(ans)

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

int main()
{
    int n,m;

    cin >> n >> m;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    vector<pair<int ,int> > path(m);
    for (int i = 0; i <m; i++)
    {
        cin >> path[i].first;
        cin >> path[i].second;
        path[i].first --;
        path[i].second --;
    }
    bool judge[n];
    for (int i = 0; i < n; i++)
    {
        judge[i] = true;
    }
    for (int i = 0; i < m; i++)
    {
        if(h[path[i].first] < h[path[i].second])
        {
            judge[path[i].first] = false;
        }
        else if(h[path[i].first] > h[path[i].second])
        {
            judge[path[i].second] = false;
        }
        else if (h[path[i].first] == h[path[i].second])
        {
             judge[path[i].first] = false;
             judge[path[i].second] = false;
        }
    }
    int count = 0;
    for (int i = 0; i < n; i++)
    {

        if(judge[i] == true)
        {
            count++;
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 4580
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		TreeMap<Long, Long> map = new TreeMap<>();
		// 件数
		long N = scan.nextInt();
		// 本数
		long M = scan.nextInt();

		Long tempKey;
		Long tempVal;
		for (int i = 0; i < N; i++) {
			tempKey = scan.nextLong();
			tempVal = scan.nextLong();
			if (map.containsKey(tempKey)) {
				map.put(tempKey, map.get(tempKey) + tempVal);
			} else {
				map.put(tempKey, tempVal);
			}
		}

		long ans = 0;
		Entry<Long, Long> tempMap;
		while (map.size() != 0) {
			tempMap = map.pollFirstEntry();
			tempKey = tempMap.getKey();
			tempVal = tempMap.getValue();
			if (M > tempVal) {
				M = M - tempVal;
				ans = ans + (tempVal * tempKey);
			} else {
				ans = ans + (M * tempKey);
				break;
			}
		}
		System.out.println(ans);
		scan.close();
	}
}

Measured memory_bytes: 99596
#include <bits/stdc++.h>
#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define ull              unsigned long long
#define f                first
#define s                second
#define sqr(x)           (x)*(x)
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define SZ(a)            (int)a.size()
#define sfi(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sffi(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfffi(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define intlim           2147483648
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))
#define mk(x1,y1) make_pair(x1, y1)
#define maxl 300010
#define psz 20
using namespace std;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdin);
//ios_base::sync_with_stdio(false);
 //cin.tie(NULL);
//Code starts from here......
int main(){

   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout); n,k;

    int n,k;
    cin>>n>>k;

    if(k == 1) cout<<0<<endl;
    else cout<<n-k<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main() {
  ll K;
  cin >> K;
  int N = 50;
  vll a(N,N-1);
  repeat(i,N){
    a[i] += K/N;
  }
  repeat(i,K%N){
    a[i] += N+1;
  }
  repeat(i,N){
    a[i] -= K%N;
  }
  cout << N << endl;
  repeat(i,N){
    cout << a[i];
    cout <<(i<N-1? " ":"\n");
  }
  return 0;
}


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

int main() {
    string s;cin>>s;

    int a=0,z=0;

    rep(i,0,s.size()){
        if(s[i]=='A'){
            a=i;
            break;
        }
    }

    for (int i=s.size()-1;i>=0;i--) {
        if(s[i]=='Z'){
            z=i;
            break;
        }
    }

    cout<<z-a+1<<endl;
}


Measured memory_bytes: 640
count = 0

def merge(a, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    l = a[left:left+n1]
    r = a[mid:mid+n2]
    l.append(float('inf'))
    r.append(float('inf'))
    i = 0
    j = 0
    global count
    count += right - left
    for k in range(left, right):
        if l[i] <= r[j]:
            a[k] = l[i]
            i += 1
        else:
            a[k] = r[j]
            j += 1


def mergeSort(a, left, right):
    if left+1 < right:
        mid = (left+right) // 2
        mergeSort(a, left, mid)
        mergeSort(a, mid, right)
        merge(a, left, mid, right)


n = int(input())
a = [int(i) for i in input().split()]

mergeSort(a, 0, n)

print(' '.join([str(v) for v in a]))
print(count)


Measured memory_bytes: 66848
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    // vector<int> a(n);
    if (n == 1) {
        int a1;
        cin >> a1;
        for (int i = 0; i < m; i++) {
            a1 /= 2;
        }
        cout << a1 << endl;
        return 0;
    }

    priority_queue<int> a;
    for (int i = 0; i < n; i++) {
        int l;
        cin >> l;
        a.push(l);
    }
    for (int i = 0; i < m; i++) {
        int max = a.top();
        a.pop();
        a.push(max / 2);
    }

    long int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a.top();
        a.pop();
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  int A[N];
  REP(i,N)cin>>A[i];
  vector<int> ps;
  FOR(i,2,1001){
    bool f=true;
    FOR(j,2,i)if(i%j==0)f=false;
    if(f)ps.push_back(i);
  }
  // for(auto e:ps)cerr<<e<<endl;
  map<int,int> m;
  REP(i,N){
    int B=A[i];
    for(auto e:ps){
      if(B%e==0)m[e]++;
      while(B%e==0)B/=e;
    }
    if(B>1)m[B]++;
  }
  int k=0;
  for(auto e:m){
    // cerr<<e.first<<":"<<e.second<<endl;
    k=max(k,e.second);
  }
  if(k==N)cout<<"not coprime"<<endl;
  else if(k<=1)cout<<"pairwise coprime"<<endl;
  else cout<<"setwise coprime"<<endl;
  return 0;
}


Measured memory_bytes: 11056
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<998244353>;
int main(){
	string s;
	cin>>s;
	int N = s.size();
	V<mint> dp(N+N+1);
	V<mint> ndp = dp;
	dp[0] = 1;
	int num0 = 0, num1 = 0;
	rep(i,N+N){
		if(i<N){
			if(s[i]=='0') num0 += 2;
			if(s[i]=='1') num0++,num1++;
			if(s[i]=='2') num1 += 2;
		}
		rep(i,N+N+1) ndp[i] = 0;
		rep(use0,N+N+1) if(dp[use0]){
			V<int> left = {num0 - use0, num1 - (i-use0)};
			rep(t,2) if(left[t]){
				ndp[use0 + (t==0)] += dp[use0];
			}
		}
		dp = ndp;
	}
	cout << dp[num0] << endl;
}

Measured memory_bytes: 256
#define pb push_back
#define ff first
#define ss second
#define ll long long unsigned
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 100005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

map<string, int> mp;
vector<string> v;
int mx;

int main() {
    int n;
    cin >> n;
    string s;
    for(int i=1;i<=n;i++){
        cin >> s;
        mp[s] ++;
    }
    for(auto x: mp){
        mx = max(mx, x.ss);
    }
    for(auto x: mp){
        if(x.ss == mx)v.pb(x.ff);
    }
    sort(v.begin(), v.end());
    for(auto x: v){
        cout << x << endl;
    }


    return 0;
}

/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/


Measured memory_bytes: 26868
import math
def com(n, a, b):
    #n ,a,b = map(int, input().split())
    if (abs(a-b) % 2) == 1:
        oneToA = a-1
        oneToB = b-1
        endToA = n-a
        endToB = n-b
        print(min((oneToA+oneToB+1)//2, (endToA+endToB+1)//2))
    else:
        print((abs(a-b)//2))

def main():
    n ,a,b = map(int, input().split())
    #n = 6
    #for i in range(n):
    #    com(6, 1, i+1)
    com(n, a, b)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
 
ll n;
cin>>n;
ll a[n],i;
for(i=0;i<n;i++)cin>>a[i];
ll c=0;
for(i=0;i<n;i+=2)
{
  
  if(a[i]%2!=0)c++;
}
  cout<<c;
}


Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10


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

	cout << max(0, a - 2 * b) << endl;






	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author GYSHGX868
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    TaskB solver = new TaskB();
    solver.solve(1, in, out);
    out.close();
  }

  static class TaskB {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      String s = in.nextString();
      int start = s.length();
      for (int i = 0; i < s.length(); i++) {
        if (s.charAt(i) == 'A') {
          start = i;
          break;
        }
      }
      int end = 0;
      for (int i = s.length() - 1; i >= 0; i--) {
        if (s.charAt(i) == 'Z') {
          end = i;
          break;
        }
      }
      out.printLine(Math.max(0, end - start + 1));
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public String nextString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        if (Character.isValidCodePoint(c)) {
          res.appendCodePoint(c);
        }
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public interface SpaceCharFilter {
      boolean isSpaceChar(int ch);

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void printLine(int i) {
      writer.println(i);
    }

  }
}



Measured memory_bytes: 23892
#include <stdio.h>
int main(void){
    int N,D,X;
    int i,y,z,T=0;
    scanf("%d\n%d %d\n",&N,&D,&X);
    for(i=0;i<N;i++){
        scanf("%d\n",&y);
        for(z=1;z<=D;z+=y){
            T++;
        }
    }
    T+=X;
    printf("%d\n",T);
}

Measured memory_bytes: 384
H , W = map(int , input().split())
gazo = [input().split() for i in range(H)]

answer = ""
for i in range(W+2):
    answer += "#"
answer += "\n"
for pic in gazo:
    answer += "#"
    answer += "".join(pic)
    answer += "#"
    answer += "\n"
for i in range(W+2):
    answer += "#"

print(answer)

Measured memory_bytes: 3064
n, m, x, y = map(int,input().split())
cx = list(map(int,input().split()))
cy = list(map(int,input().split()))
a = max(cx)+1
b = min(cy)
if a>b:
    print('War')
    exit()
for z in range(a, b+1):
    if x<z<=y:
        print('No War')
        exit()
print('War')

Measured memory_bytes: 3064
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	while (tc--)
	{
		ll i, j, n;
		double l;
		cin >> l;
		printf ("%.9lf\n", (l/3)*(l/3)*(l/3));
	}

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)



int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	vector<int>B(N);
	vector<int>C(N);
	rep(i, N) {
		cin >> A[i] >> B[i] >> C[i];
	}
	vector<vector<int>>dp(N + 1, vector<int>(3));
	dp[0][0] = 0;
	dp[0][1] = 0;
	dp[0][2] = 0;
	for (int i = 1; i <= N; i++) {
		dp[i][0] = max(dp[i - 1][1] + A[i - 1], dp[i - 1][2] + A[i - 1]);
		dp[i][1] = max(dp[i - 1][0] + B[i - 1], dp[i - 1][2] + B[i - 1]);
		dp[i][2] = max(dp[i - 1][0] + C[i - 1], dp[i - 1][1] + C[i - 1]);
	}
	int ans = 0;
	rep(i, 3) {
		ans = max(ans, dp[N][i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    int a, b, c; cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    printf("%d %d %d\n",a,b,c);
}


Measured memory_bytes: 256
#import<cstdio>
int main(){int i,j;for(int n;scanf("%d",&n),n;){int p[10]={};for(i=n;i;--i)scanf("%d",&j),++p[j];for(i=0;i<10;++i,puts("")){for(j=0;j<p[i];++j)printf("*");if(!p[i])printf("-");}}}

Measured memory_bytes: 0
from typing import List
import sys


def solution(inp: List) -> int:
    S = inp[0]
    T = inp[1]
    ans = len(T)

    for i in range(len(S) - len(T) + 1):
        a = 0
        for j in range(len(T)):
            if T[j] != S[i + j]:
                a += 1
        ans = min(ans, a)
    return ans


inp: List = []
for j in sys.stdin:
    inp += j.split()
print(solution(inp))


Measured memory_bytes: 10040
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL l;
    cin>>l;
    LD ld=1.;
    cout << setprecision(20)<<l*l*l*ld/27<<endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second

using namespace std;

typedef long long ll;
#define mp make_pair 

pair<long long, long long> normalize(long long a, long long b) {
  if (a == 0) return mp(0, 1);
  else if (b == 0) return mp(1, 0);
  else {
    ll g = __gcd(abs(a), abs(b));
    if ((a ^ b) >> 63) return mp(-abs(a) / g, abs(b) / g);
    else return mp(abs(a) / g, abs(b) / g);
  }
}
template<unsigned mod=1000000007>struct fp {
   unsigned v;
   static unsigned get_mod(){return mod;}
   unsigned inv() const{
      int tmp,a=v,b=mod,x=1,y=0;
      while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
      if(x<0){x+=mod;} return x;
   }
   fp():v(0){}
   fp(ll x):v(x>=0?x%mod:mod+(x%mod)){}
   fp operator-()const{return fp(-v);}
   fp pow(ll t){fp res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;} return res;}
   fp& operator+=(const fp& x){if((v+=x.v)>=mod)v-=mod; return *this;}
   fp& operator-=(const fp& x){if((v+=mod-x.v)>=mod)v-=mod; return *this;}
   fp& operator*=(const fp& x){v=ll(v)*x.v%mod; return *this;}
   fp& operator/=(const fp& x){v=ll(v)*x.inv()%mod; return *this;}
   fp operator+(const fp& x)const{return fp(*this)+=x;}
   fp operator-(const fp& x)const{return fp(*this)-=x;}
   fp operator*(const fp& x)const{return fp(*this)*=x;}
   fp operator/(const fp& x)const{return fp(*this)/=x;}
   bool operator==(const fp& x)const{return v==x.v;}
   bool operator!=(const fp& x)const{return v!=x.v;}
}; using Fp=fp<>;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<pair<ll, ll>, int> cnt;
  int cnt0 = 0;
  for (int i = 0; i < n; i++) {
    ll a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      cnt0++;
      continue;
    }
    //cerr << normalize(a, b).first << ", " << normalize(a, b).second << endl;
    cnt[normalize(a, b)]++;
  }
  set<pair<ll, ll>> used;
  Fp ans = 1;
  for (auto e : cnt) {
    if (used.count(e.first)) continue;
    auto c = make_pair(abs(e.first.second), abs(e.first.first));
    if (e.first.first > 0) c.first *= -1;
    auto cur = Fp(2).pow(e.second) + Fp(2).pow(cnt[c]) - 1;
    //cerr << "compliment: " << "(" << c.first << ", " << c.second << "), " << cnt[c] << endl;
    used.insert(c);
    used.insert(e.first);
    //cerr << "(" << e.first.first << ", " << e.first.second << "), " << cur << endl;
    ans = ans * cur;
  }
  ans -= 1;
  ans += cnt0;
  cout << ans.v << endl;
  return 0;
}


Measured memory_bytes: 53628
#include<stdio.h>
int main(){
	int ans,n,k,a[1001],b[1001],i,j,x=0;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<k;i++)scanf("%d",&b[i]);
	for(i=0;i<k;i++){
		for(j=0;j<n;j++){
			if(b[i]>=a[j]){
				b[i]=j;
				break;
			}
		}
	}
	for(i=0;i<n;i++)a[i]=0;
	for(i=0;i<k;i++)++a[b[i]];
	for(i=0;i<n;i++){
		if(x<a[i]){
			x=a[i];
			ans=i;
		}
	}
	printf("%d\n",ans+1);
	return 0;
}


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

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

    string S;
    cin >> S;

    int idx = 0;
    int left = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[idx] == '(')
        {
            left++;
        }
        else
        {
            left--;
        }
        if (left < 0)
        {
            S.insert(0, "(");
            idx++;
            left++;
        }
        idx++;
    }
    while (left > 0)
    {
        S.insert(S.size(), ")");
        left--;
    }
    cout << S << endl;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if a>=b&&a>=c{b+c}else if b>=a&&b>=c{a+c}else{a+b})
}

Measured memory_bytes: 4352
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int A, B, H; cin >> A >> B >> H;
    cout << (A + B) * H / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,d;
  cin>>n>>d;
  int a[10][20];
  int b[200];
  rep(i,200){
    b[i]=i*i;
  }
  rep(i,n){
    rep(j,d){
      cin>>a[i][j];
    }
  }
  int sum;
  int ans=0;
  rep(i,n){
    repi(j,i+1,n){
      sum=0;
      rep(k,d){
	sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      rep(k,200){
	if(sum==b[k]) ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] s = sc.nextLine().split(" ");
    int N = Integer.parseInt(s[0]);
    int x = Integer.parseInt(s[1]);
    int[] candy = new int[N];
    for(int i = 0; i < N; i++){
      candy[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(candy);
    
    int count = 0;
    for(int i = 0; i < N; i++){
      x-= candy[i];
      if(x >= 0){
        count++;
      }else{
        break;
      }
    }
    if(x > 0){
      count--;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int k;
  cin >> s >> k;
  int n = s.length();
  int i,j;
  set<string>str;
  for(i=0;i<n;i++){
    for(j=1;i+j<=n && j <= k;j++){
      str.insert(s.substr(i,j));
    }
  }
  i = 1;
  for(auto kk:str){
    if(i==k){
      cout << kk << endl;
      break;
    }
    i++;
  }
}


Measured memory_bytes: 1664
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
#include<map>
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll t;
    while (cin >> t)
    {
        unsigned long long ans=0;
        for(ll i=1;i<=t;i++)
        {
        if(i%3!=0&&i%5!=0)ans+=i;   
        }
        cout<<ans<<'\n';
    }
}



Measured memory_bytes: 3608
a=[]
dp=[float("inf") for i in range(1+10**4)]
h,n=map(int,input().split())
for i in range(n):
    A,B=map(int,input().split())
    a.append((A,B))
dp[0]=0
for i in range(1+10**4):
    for A,B in a:
        dp[i]=min(dp[i],dp[max(0,i-A)]+B)
print(dp[h])

Measured memory_bytes: 73804
#include<iostream>
#include<vector>
#include<algorithm>
#define MAX_V 100
#define INF 1e9
using namespace std;
int cost[MAX_V][MAX_V];
int d[MAX_V];
bool used[MAX_V];
int V;
void dijkstra(int s) {
	for (int i = 0; i < V; i++) {
		d[i] = INF;
		used[i] = false;
	}
	d[s] = 0;
	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && ((v == -1) || d[u] < d[v])) {
				v = u;
			}
		}
		//全ての頂点が到達済み
		if (v == -1) {
			break;
		}
		//集合に新たに頂点を追加
		used[v] = true;
		for (int u = 0; u < V; u++) {
			d[u] = min(d[u], d[v] + cost[v][u]);
		}
	}
}

int main() {
	for (int i = 0; i < V+100; i++) {
		for (int j = 0; j < V+100; j++) {
			cost[i][j] = INF;//iからjへの辺の重さ
		}
	}
	cin >> V;
	for (int i = 0; i < V; i++) {
		int u;
		cin >> u;
		int k;
		cin >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			int c;
			cin >> c;
			cost[u][v] = c;
		}
	}
	dijkstra(0);

	for (int i = 0; i < V; i++) {
		cout << i << " " << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3132
#include<stdio.h>
int main(void)
{
  unsigned long long int n,a,b;
  scanf("%llu",&n);
  if(n>6){
    if(n%11==0||n%11==6){
      printf("%llu\n",2*n/11);
    }
    else{
      n=2*n/11;
      printf("%llu\n",n+1);
    }
  }
  else {
    printf("1\n");
  }
  return 0;
}
/*
1-6  1
7-11 2
12-17 3
18-22 4
28 
33
39
an=1+(n-1)*d;
*/

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

int main() {
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    cout<<fixed;
    cout<<setprecision(10);
    if(w==2*x&&h==2*y){
        cout<<w*h/2<<" "<<1<<endl;
    }else {
        cout<<w*h/2<<" "<<0<<endl;
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b, k;
	cin >> a >> b >> k;
	rep3(i,a,b) {
		if(abs(i-a) < k || abs(i-b) < k) cout << i << endl;
	}
	return;
}

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


Measured memory_bytes: 256
N,W = map(int,input().split())

dp = [0]*(W+1)
L = []
for i in range(N):
    ta,tb = map(int,input().split())
    L.append([tb,ta])

for i in range(N):
    for w in range(W,-1,-1):
        if w-L[i][1]>=0 :dp[w] = max(dp[w],dp[w-L[i][1]]+L[i][0])
print(dp[-1])

Measured memory_bytes: 43100
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, q; cin >> n >> q;
  dsu uf(n);
  rep(i, q) {
    int t, u, v;
    cin >> t >> u >> v;
    if(t) cout << uf.same(u, v) << endk;
    else uf.merge(u, v);
  }
  return 0;
}


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

const int W = 100, H = 50, D = 30;
vector<int> x, h;

void pour(int pos, int l, int r, double& amt, vector<double>& ans) {
    if (r - l > 1) {
        int sep = max_element(h.begin() + l + 1, h.begin() + r) - h.begin();
        if (pos < sep) {
            pour(pos, l, sep, amt, ans); pour(pos, sep, r, amt, ans);
        } else {
            pour(pos, sep, r, amt, ans); pour(pos, l, sep, amt, ans);
        }
    }
    double side = min(h[l], h[r]);
    double add = min(amt, (side - ans[l]) * (x[r] - x[l]));
    amt -= add;
    for (int i = l; i < r; i++) ans[i] += add / (x[r] - x[l]);
}

#include <iomanip>
int main() {
    cout << fixed << setprecision(6);
    int DD; cin >> DD;
    while (DD--) {
        int N; cin >> N;
        x.assign(N + 2, 0), h.assign(N + 2, H);     // boards
        for (int i = 1; i <= N; i++) cin >> x[i] >> h[i];
        x[0] = 0, x[N + 1] = W;
        h[0] = h[N + 1] = H;

        int M; cin >> M;
        vector<double> flow(N + 1, 0);
        while (M--) {                               // faucets
            int pos, amount; cin >> pos >> amount;
            int i = lower_bound(x.begin(), x.end(), pos) - begin(x) - 1;
            flow[i] += 1.0 * amount / D;
        }

        int L; cin >> L;
        while (L--) {                               // queries
            int pos, time; cin >> pos >> time;
            vector<double> ans(N + 1, 0);
            for (int i = 0; i <= N; i++) {
                double amt = flow[i] * time;
                pour(i, 0, N + 1, amt, ans);
            }
            int i = lower_bound(x.begin(), x.end(), pos) - begin(x) - 1;
            cout << ans[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;


int main() {
    int cnt = 0;
    string s;
    cin >> s;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]) cnt++;
    }
    cout << cnt << endl;
}


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

const int MAX_N = 2 * 1e5 + 2;
const int MAX_Q = 2 * 1e5 + 2;

char T[MAX_Q], D[MAX_Q];

int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  for (int i = 0; i < Q; i++) {
    cin >> T[i] >> D[i];
  }
  int left_left = 0, left_right = N + 1;
  while (left_right - left_left > 1) {
    int mid = (left_left + left_right) / 2;
    int cur_pos = mid;
    for (int i = 0; i < Q; i++) {
      if (cur_pos == 0 || cur_pos == N + 1) break;
      if (S[cur_pos - 1] == T[i]) {
        if (D[i] == 'R')
          cur_pos++;
        else
          cur_pos--;
      }
    }
    if (cur_pos == 0)
      left_left = mid;
    else
      left_right = mid;
  }
  int right_left = 0, right_right = N + 1;
  while (right_right - right_left > 1) {
    int mid = (right_left + right_right) / 2;
    int cur_pos = mid;
    for (int i = 0; i < Q; i++) {
      if (cur_pos == 0 || cur_pos == N + 1) break;
      if (S[cur_pos - 1] == T[i]) {
        if (D[i] == 'R')
          cur_pos++;
        else
          cur_pos--;
      }
    }
    if (cur_pos == N + 1)
      right_right = mid;
    else
      right_left = mid;
  }
  cout << right_right - left_left - 1 << endl;
  return 0;
}


Measured memory_bytes: 900