akhauriyash/Code-Regression huggingface dataset:
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
    return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
    return n = n | (1LL << pos);
}

ll dp[3003][3003][4];
ll val[3003][3003];
ll r, c;

ll solve(ll rr, ll cc, ll took)
{
    ll &ret = dp[rr][cc][took];

    if(ret != -1) return ret;

    if(rr > r || cc > c) return ret = 0;

    if(val[rr][cc] == -1)
    {
		return ret = max(solve(rr + 1, cc, 0), solve(rr, cc + 1, took));

    }

    ret = 0;

    if(took != 3)
    {
        ret = max(ret, solve(rr, cc + 1, took + 1) + val[rr][cc]);
    }

    ret = max(ret, solve(rr, cc + 1, took));


    ret = max(ret, solve(rr + 1, cc, 0) + (took == 3 ? 0 : val[rr][cc]));


//	cout << rr << " " << cc << " " << took << " = " << ret << endl;

    return ret;
}

int main()
{
    ll i, j, k, l, m, n, o, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    while(cin >> r >> c >> n)
    {
        memset(dp,-1,sizeof dp);
        memset(val,-1,sizeof val);

        for(ll i = 1; i <= n; i++)
        {
            ll x, y;

            cin >> x >> y >> val[x][y];
        }

        ans = solve(1,1,0);

        cout << ans << "\n";
    }


}





Measured memory_bytes: 356368
#include <stdio.h>

int main()
{
    int l, r;
    int i, j;
    int mod;
    int min = 2019;

    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%d %d", &l, &r);

    if((r -l)/673 >= 1){ //2019 = 673 / 3
        //printf("673, 3 must included.\n");
        min = 0;
    }else{
        for (i = l; i <= r-1; i++){
            for (j = i+1; j <= r; j++){
                mod = ((long)i * j) % 2019;
                if (min > mod){
                    //printf("i = %d j = %d : change %d -> %d\n", i, j ,min, mod);
                    min = mod;
                }
            }
        }
    }

    printf("%d", min);

}

Measured memory_bytes: 128
#include<bits/stdc++.h>
    #include<algorithm>
    #include<cmath>
    #include<climits>
    using namespace std;
    typedef long long int lli;
    typedef vector<int> vi;
    typedef vector<long long int> vlli;
    typedef pair<int,int> pii;
    typedef pair<long long int,long long int> plli;
    typedef vector< vi > vvi ;
    typedef vector< vlli > vvlli  ;
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define flli(i,a,b) for(long long int i=a;i<=b;i++)
    #define bi(i,a,b) for(int i=a;i>=b;i--)
    #define blli(i,a,b) for(long long int i=a;i>=b;i--)
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define all(x) x.begin(),x.end()
    #define sz(x) x.size()
    #define pi 2*acos(0.0)
    #define pb push_back
    #define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
    #define present(v,num) (v.find(num)!=v.end())
    #define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
    #define pq priority_queue
    #define mp make_pair
    const int inf=INT_MAX;
    const lli INF =LLONG_MAX;
    const lli mod = 1e9+7;
    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        fast;
        lli a;cin>>a;
        lli ans=a+a*a+a*a*a;
        cout<<ans;
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
        return 0;
    }

Measured memory_bytes: 3800
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 1005;
const int M     = 1000005;

int a[MAXN];

void run() {
    int64 n;
    cin >> n;
    string ans;
    while(n) {
        ans.pb( ((n-1)%26) + 'a');
        n = (n-1)/26;

    }
    reverse(all(ans));
    cout << ans << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n ,m , x;
	cin >> n >> m >> x ;
	int cntl = 0 , cntr = 0 ;
	rep(i,0,m){
		int a ;
		cin >> a;
		cntl+=(x>a);
		cntr+=(x<a);
	}
	cout << min(cntl,cntr) << endl;
}
signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3580
#include<iostream>

using namespace std;
#define int long long

signed main(){

    int N;
    cin>> N;
    int T[N], A[N];
    for(int i=0; i<N; i++) cin>> T[i]>> A[i];

    int ans=T[0]+A[0];
    for(int i=1; i<N; i++){
        int n=max(1+(T[i-1]-1)/T[i], 1+(A[i-1]-1)/A[i]);
        T[i]*=n;
        A[i]*=n;
    }

    cout<< T[N-1]+A[N-1]<< endl;


    return 0;
}


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

int main(){
  ll X;
  cin >> X;
  int ans = 0;
  ll yokin = 100;
  while (yokin < X){
    yokin += yokin / 100;
    ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3528
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int modpow(ll a, ll n, ll p){
	if(n==0) return 1;
	if(n%2) return (a*modpow(a, n-1, p))%p;
	if(!(n%2)){
		ll t=modpow(a, n/2, p);
		return (t*t)%p;
	}
}


const int MAX = 1000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int n; cin >> n; pair<ll, ll>p[n]; pair<ll, ll>q[n];
  rep(i, n){
    ll x, y; cin >> x >> y; p[i] = {x+y, x-y}; q[i] = {x-y, x+y};
  }
  sort(p, p+n); sort(q, q+n);
  ll ans = p[n-1].first-p[0].first;
  ans = max(ans, q[n-1].first-q[0].first);
  cout << ans << endl;
}


Measured memory_bytes: 9800
/*package whatever //do not write package name here */

import java.io.*;
import java.util.Scanner;


class Main {
	public static void main (String[] args) {
	    Scanner in = new Scanner(System.in);
	    int n = in.nextInt();
        int x =  7 % n;
        int answer = 0;
        for (int i=1;i<=n;i++) {
            if(x == 0) {
                System.out.println(i);
                return;
            }
            x = (x*10 + 7 ) % n;
        }

        System.out.println(-1);
	}
}

Measured memory_bytes: 35652
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=5e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
   
   
   
int h,sum;   

void solve() {
    cin>>h;
    int ct=1;
    while(h!=0) {
		   sum+=ct;
		   ct*=2;
		   h>>=1;
		   //~ cout<<sum<<endl;
		}
		
		cout<<sum<<endl;
}

    
int32_t main() {
	cool;
	int t=1;	

	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int X;
  cin>>X;
  int happy=0;
  int t=X;
  while(t>=500){
    t-=500;
    happy+=1000;
  }
  while(t>=5){
    t-=5;
    happy+=5;

  }
  printf("%d",happy);

}

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

typedef long long ll;
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    int N, M, X;
    cin >> N >> M >> X;
    bool W[N] = {false};

    rep(i, M)
    {
        int temp;
        cin >> temp;
        W[temp] = true;
    }
    int ans1 = 0;
    int ans2 = 0;
    for (int i = X - 1; i > 0; i--)
    {
        if (W[i])
        {
            ++ans1;
        }
    }
    for (int i = X + 1; i < N; i++)
    {
        if (W[i])
        {
            ++ans2;
        }
    }

    cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
    cin >>x>>y;
    if (x> 0 && y > 0) 
	{
        cout << "Positive" << endl;
    } 
	else if (max(x,y) >= 0 && min(x,y) <= 0 || x == 0 || y == 0) 
	{
        cout << "Zero" << endl;
    }
	else 
	{
        if ((abs(min(x, y)) - abs(max(x, y))) % 2 == 0) {
            cout << "Negative" << endl;
        } 
		else {
            cout << "Positive" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
// #include<typeinfo>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#include<unordered_map>
#include<map>
#include<set>

#define loopi(x,y) for(int i = x;i<(y);i++)
#define rloopi(x,y) for(int i = x;i>=(y);i--)
#define loopj(x,y) for(int j = x;j<(y);j++)


#define nl cout<<"\n";
#define ll long long int
using namespace std;
#define mod  1000000007


int main() {

	ios :: sync_with_stdio(false);
	cin.tie(nullptr);
	// ios_base :: sync_with_stdio(false);
	// cin.tie(NULL)

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif

	int n, W;
	cin >> n >> W;
	vector<int> w(n + 1);
	vector<int> v(n + 1);

	loopi(1, n + 1)
	{
		cin >> w[i];
		cin >> v[i];
	}

	ll dp[n + 1][W + 1];

	for (int i = 0; i <= W; i++)
	{
		dp[0][i] = 0;
	}

	loopi(1, n + 1)
	{
		dp[i][0] = 0;
		loopj(1, W + 1)
		{
			if (j < w[i])
			{
				dp[i][j] = dp[i - 1][j];
			}
			else
			{
				dp[i][j] = max(dp[i - 1][j - w[i]] + v[i], dp[i - 1][j]);
			}
		}
	}
	cout << dp[n][W];
	return 0;
}


Measured memory_bytes: 79232
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32
    }
    for i in 0.. {
        if 7 * i > n {
            break;
        }
        if (n - 7 * i) % 4 == 0 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
n = int(input())
ans = 1
ma_div = 0
divs = [1, 2, 4, 8, 16, 32, 64,128]
for i in range(1, n + 1):
    for j, div in enumerate(divs):
        if i % div != 0:
            break
    if j > ma_div:
        ans = i
        ma_div = j
print(ans)


Measured memory_bytes: 38384
r, c = gets.split.map(&:to_i)
T = Array.new(r).map{Array.new(c+1,0)}
row = Array.new(c+1,0)
r.times do |i|
    x = gets.split.map(&:to_i)
    x.push x.inject(:+)
    x.length.times {|j| row[j] += x[j]}
    T[i] = x
end
T.push row
T.each do |t|
    puts t.join(' ')
end


Measured memory_bytes: 7104
import java.util.*;

public class Main {
    public static void main(String[] args) {
      Scanner scn = new Scanner(System.in);
      String s=scn.nextLine();
      if(s.equals("ABC")){
        System.out.println("ARC");
      }else{
        System.out.println("ABC");
      }
    }
}


Measured memory_bytes: 35532
#include <bits/stdc++.h>
int n,b[505*505];
struct note{
	int x,i;
}a[505];
bool cmp(note x,note y){
	return x.x<y.x;
}
void ex(){
	puts("No");
	exit(0);
}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i].x),a[i].i=i;
	int N=n*n;
	std::sort(a+1,a+n+1,cmp); 
	for (int i=1;i<=n;i++){
		int now=1;
		for (int j=1;j<a[i].x && now<a[i].i;j++)
			if (!b[j]) b[j]=a[i].i,now++;
		b[a[i].x]=a[i].i;
		if (now<a[i].i) ex();
	}
	for (int i=n;i>=1;i--){
		int now=n;
		for (int j=N;j>=a[i].x && now>a[i].i;j--)
			if (!b[j]) b[j]=a[i].i,now--;
		if (now>a[i].i) ex();
	}
	puts("Yes"); 
	for (int i=1;i<=N;i++) printf("%d ",b[i]);
} 

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

#define N_MAX 18
int dp[(1 << N_MAX)][N_MAX];

// �J�[�hi �� j �Ԗڂɒu���Ƃ��̒l
int get_val(const int i, const int j, vector<int> &A, vector<int> &B){
    if ((j - i) % 2 == 0){
        return A[i];
    } else {
        return B[i];
    }
}
int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N)cin >> A[i];
    rep(i, N)cin >> B[i];
    
    rep(i, (1 << N))rep(j, N)dp[i][j] = INF;
    for (int k = 0; k < N; k++){
        dp[1<<k][k] = 0;
    }    
    for (int S = 1; S < (1 << N); S++){
        for (int k = 0; k < N; k++){
            if (S & (1 << k)){
                continue;
            }
            int cnt = 0, bnum = 0;
            for (int p = 0; p < N; p++){
                if (S & (1 << p)){
                    bnum++;
                    if (p > k){
                        cnt++;
                    }
                }
            }
            for (int j = 0; j < N; j++){
                if (S & (1 << j)){
                    //fprintf(stderr, "S = %d -> %d, k = %d, j = %d, %f\n", S, S | 1 << k, k, j, dist(j, k));
                    int prev = get_val(j, bnum - 1, A, B);
                    int next = get_val(k, bnum, A, B);
                    if (prev <= next){
                        dp[S | 1 << k][k] = min(dp[S | 1 << k][k], dp[S][j] + cnt);
                        //fprintf(stderr, "S = %d, j = %d, k = %d, bnum = %d, cnt = %d -> %d\n", S, j, k, bnum, cnt, 
                        //  min(dp[S | 1 << k][k], dp[S][j] + cnt));
                    //} else {
                    //    fprintf(stderr, "S = %d, j = %d, k = %d, bnum = %d, cnt = %d -> %d\n", S, j, k, bnum, cnt, INF);
                    }
                        
                }
            }
        }
    }
    int ans = INF;
    int S = (1 << N) - 1;
    
    for (int k = 0; k < N; k++){
        ans = min(ans, dp[S][k]);
    }
    
    if (ans == INF){
        cout << -1 << endl;
        
    } else {
        cout << ans << endl;
    }
        
    //int v[3] = { 1, 3, 2};
    //sort(v, v + 3, greater<int>());
    //cout << v[0] << v[1] << v[2];
    return 0;
}


Measured memory_bytes: 18688
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    string S,T;
    cin >> S >> T;

    int a=S.size();
    int b=T.size();
    int minsum=10000;
    for(int i=0; i<a-b+1; i++){
        int sum=0;
        for(int j=0; j<b; j++){
            if(S.at(i+j)!=T.at(j)) sum++;
        }
        if(sum<minsum) minsum=sum;
    }
    cout << minsum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100002;
ll n,d,x,ans;
vector<ll> a;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>d>>x;
	d--;
	FOR(i,0,n){
		ll k;
		cin>>k;
		ans+=1;
		ans+=d/k;
	}
	pri(ans+x);
	return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

const int N = 100005;
vector<int> g[N];
int cnt[N];
// P es[N];
vector<P> es;
int col[N];
int deg[N];

void dfs(ll v,ll pre){
  cnt[v]=1;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    dfs(nv,v);
    cnt[v]+=cnt[nv];
  }
}

void ddfs(ll v,ll pre,ll c){
  col[v]=c;
  for(ll nv : g[v]){
    if(nv==pre)continue;
    ddfs(nv,v,c);
  }
}

bool solve(){
  int n,x,y;
  scanf("%d%d%d", &n, &x, &y);
  x--; y--;

  // memset(deg,0,sizeof(deg));

  rep(i,n-1){
    int a,b;
    scanf("%d%d", &a, &b);
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
    // es[i] = {a,b};
    es.push_back({a,b});
    deg[a]++;
    deg[b]++;
  }

  if(n==2) return true;
  if(n%2==1) return false;

  dfs(0,-1);
  memset(col,-1,sizeof(col));
  // rep(i,n-1){
    // ll a=es[i].fi, b=es[i].se;
  for(P p : es){
    ll a = p.first, b = p.second;
    if(cnt[a]<cnt[b]) swap(a,b);
    if(cnt[b]==n-cnt[b]){
      ddfs(a,b,0);
      ddfs(b,a,1);
      deg[a]--;
      deg[b]--;
      break;
    }
  }

  if(col[x]==col[y]) return false;

  int cnt1[2] = {0,0};
  rep(i,n){
    if(deg[i]>2) return false;
    if(deg[i]==1) cnt1[col[i]]++;
  }

  if(cnt1[0]!=2 || cnt1[1]!=2) return false;

  return (deg[x]==1 && deg[y]==1);
}

int main(){
  if(solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 15824
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

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

    for (int i = 0; i < n; i++) {
        cout << (k - (q - cnt[i]) > 0 ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);            
        
        for(int i = 0; i < 3000; i ++) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            
            if(printJudge(H,W)) {
                for(int height = 0; height < H ; height++) {
                    printRect(W);
                }                
            }else {
                break;
            }
            System.out.print("\n");
        }
    }    

    public static void printRect(int W) {        
	for(int i = 0; i < W; i++) {
		System.out.print("#");                
	}
        System.out.print("\n");    
    }
    
    public static boolean printJudge(int H, int W) {
        if((H == 0 && W == 0) || H < 0 || H > 300 || W < 0 || W > 300) {
            return false;
        }else {
            return true;
        }
    }
    
}

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

int kaijou(int i){
    if(i==0) return 1;
    int j=1;
    for(int k=1;k<=i;k++){
        j*=k;
    }
    return j;
}

double distance(vector<int>p,vector<int>q){
    int x,y;
    x=pow((p.at(0)-q.at(0)),2);
    y=pow((p.at(1)-q.at(1)),2);
    return sqrt(x+y);
}

int main(){
    cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<vector<int>> r(n,vector<int>(2));
    for(auto &p:r){
        for(auto &t:p){
            cin>>t;
        }
    }
    double sum=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            sum+=distance(r.at(i),r.at(j));
        }
    }
    double ave;
    ave=sum/(n*(n-1)/2);
    double ave2;
    ave2=ave*(n-1);
    cout<<ave2;
}


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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int a[ N ];

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n;
        cin >> n;
        for( int i = 1; i <= n; i++ ) cin >> a[i];
        sort( a + 1 , a + n + 1 );
        int ans = 0;
        for( int i = 1; i <= 1e5; i++ ) {
                int lo = 1 , hi = n , ret = 0 , key = i;
                while( lo <= hi ) {
                        int mid = ( lo + hi ) >> 1;
                        if( a[mid] >= key ) ret = mid , hi = mid - 1;
                        else if( a[mid] < key ) lo = mid + 1;
                }
                int big = n - ret + 1;
                int small = n - big;
                if( big == small ) ans++;
        }
        cout << ans << endl;
        return 0;
}










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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

int comb[51][51];

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

  vi v(n);
  rep(i, 0, n) cin >> v[i];

  comb[1][0] = comb[1][1] = 1;
  rep(i, 1, n) rep(j, 0, i+1){
    comb[i+1][j] += comb[i][j];
    comb[i+1][j+1] += comb[i][j];
//    cout << comb[i][j] << " \n"[j==i];
  }
  
  sort(v.rbegin(), v.rend());

  int sum = 0;
  rep(i, 0, a) sum += v[i];

  int ans = 0;
  if(v[0] == v[a-1]){
    int cnt = 0;
    rep(i, 0, n) if(v[i] == v[a-1]) cnt++;
    rep(i, a, b+1){
      ans += comb[cnt][i];
    }
  }else{
    int cnt = 0, cnt2 = 0;
    rep(i, 0, n){
      if(v[a-1] == v[i]){
        cnt++;
        if(i < a) cnt2++;
      }
    }
    ans += comb[cnt][cnt2];
  }

  printf("%.12f\n%lld\n", (double)sum/a, ans);

  return 0;
}



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

typedef long long ll;
typedef long double ld;
// use unique(x) - removec consecutive items, returns vec.begin() + number of items
// for vector: sort(all(vec)); vec.erase(unique(all(vec)), vec.end());
// use iota(all(vec), 0) for filling a vector with 0,1,2...
// use fill(all(vec), 1) for filling a vector with 1,1,1...
// use rotate(vec.begin(), vec.begin() + 1, vec.end()) to rotate a vector | middle arg becomes first
// use merge(all(vec1), all(vec2), vec3.begin()) to merge 2 vectors, use vec3.resize(vec1.size() + vec2.size()) first
// ll pos = partition_point(all(vec), pred) - vec.begin(); bool pred(ll a){return a<3};
// print number in binary -> cout << bitset<20>(n);

int main(){
	ll a,v,b,w,t;cin>>a>>v>>b>>w>>t;
	if(a>b)swap(a,b);
	if(a+t*v>=b+t*w)cout<<"YES\n";
	else cout<<"NO\n";
}


Measured memory_bytes: 3624
n,m,k = map(int,input().split())
t = n-k-1
mod = 998244353
rng = 200100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
dp = [0]*(t+1)
if t >= 1:
  dp[1] = m
for i in range(2,t+1):
  dp[i] = dp[i-1]*(m-1)%mod
ans = pow(m,n,mod)
for i in range(len(dp)):
  ans = (ans-dp[i]*cmb(n-1,n-i))%mod
print(ans%mod)

Measured memory_bytes: 87956
import sys
sys.setrecursionlimit(100000000)


def main():
    solve()


def solve():
    for data in get_dataset():
        print search(data)


def search(data):
    count = 0
    H = len(data)
    W = len(data[0])
    for i in xrange(H):
        for j in xrange(W):
            if data[i][j] == '.':
                continue
            _search(i, j, H, W, data[i][j], data)
            count += 1
    return count


def _search(i, j, H, W, cell, data):
    data[i][j] = '.'
    for a in xrange(i-1, i+2):
        if not -1 < a < H:
            continue
        for b in xrange(j-1, j+2):
            if not -1 < b < W:
                continue

            if a != i and b != j:
                continue

            if data[a][b] == '.':
                continue

            if cell == data[a][b]:
                _search(a, b, H, W, cell, data)
    return


def get_dataset():
    dataset = []
    while True:
        line = raw_input().rstrip().split()
        H = int(line[0])
        if H == 0:
            break

        data = []
        for i in xrange(H):
            data.append(list(raw_input().rstrip()))
        dataset.append(data)
    return dataset


if __name__ == '__main__':
    main()

Measured memory_bytes: 15732
n=int(input())
l=list(map(int, input().split()))
if n%2==0:
  for i in range(n-1, 0, -2):
    print(str(l[i]), end=' ')
  for i in range(0, n, 2):
    print(str(l[i]), end=' ')
else:
  for i in range(n-1, -1, -2):
    print(str(l[i]), end=' ')
  for i in range(1, n, 2):
    print(str(l[i]), end=' ')

Measured memory_bytes: 30808
use std::collections::*;
// use std::io::prelude;
use std::io;
use std::io::Read;
use std::cmp::*;

fn main(){
    let t_cases = 1;
    for _ in 0..t_cases{
        solve();
    }
}

fn solve(){
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let a = buf
                .trim()
                .split_whitespace()
                .map(|x| x.parse::<i32>().unwrap())
                .collect::<Vec<i32>>();
    let (n,m) = (a[0],a[1]);
    buf.clear();
    io::stdin().read_to_string(&mut buf).unwrap();
    let mut t=vec![];
    let mut mx = 0i32;
    for line in buf.trim().lines(){
        let a = line
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse::<i32>().unwrap())
                    .collect::<Vec<i32>>();
        mx+=a[1];
        t.push(a);
    }

    let mut dp = vec![10i64.pow(15)+7;mx as usize +1];
    dp[0] = 0;
    for item in &t{
        for i in (1..(mx+1)).rev(){
            if i >= item[1]{
                dp[i as usize] = min(dp[i as usize], dp[(i-item[1]) as usize]+item[0] as i64);
            }
        }
    }
    for i in (0..(mx as usize+1)).rev(){
        if dp[i] <= (m as i64){
            println!("{}",i);
            return;
        }
    }
}

Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
using namespace std;
#define ll long long
const ll INF=1e15+10;
#define MAX 100005
typedef pair<ll,ll> p;
struct Edge{
    ll to;
    ll cost;
    Edge(ll to,ll cost):to(to),cost(cost){}
};
vector<Edge> edge[MAX*100];
ll dis[MAX];
ll u,v,w;
ll n,q,x;
void Dijkstra(int s)
{
    priority_queue<p,vector<p>,greater<p> > que;
    fill(dis+1,dis+n+1,INF);
    dis[s]=0;
    que.push(p(0,s));
    while(!que.empty())
    {
        p P=que.top();
        que.pop();
        v=P.second;
        if(dis[v]<P.first)
            continue;
        for(ll i=0;i<edge[v].size();i++)
        {
            Edge e=edge[v][i];
        if(dis[e.to]>dis[v]+e.cost)
        {
            dis[e.to]=dis[v]+e.cost;
            que.push(p(dis[e.to],e.to));
        }
        }
    }
}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n-1;i++)
    {
        scanf("%lld%lld%lld",&u,&v,&w);
        edge[u].push_back(Edge(v,w));
        edge[v].push_back(Edge(u,w));
    }
    scanf("%lld%lld",&q,&x);
    Dijkstra(x);
    for(int i=0;i<q;i++)
    {
        scanf("%lld%lld",&u,&v);
        printf("%lld\n",dis[u]+dis[v]);
    }
    return 0;
}

Measured memory_bytes: 243184
N=int(input())
S=list(input())
LE= [0] * (N+1)
RW= [0] * (N+1)
for i in range(1,N+1):
  if S[i-1] == 'E':
    LE[i] = LE[i-1] + 1
  else:
    LE[i] = LE[i-1]
for i in range(N-1,-1,-1):
  if S[i] == 'W':
    RW[i] = RW[i+1] + 1
  else:
    RW[i] = RW[i+1]

#print(LE)
#print(RW)
ANS = N + 1
for i in range(0,N):
  W = abs((N-1) - i - RW[i+1])
  if i == 0:
    E = 0
  elif i == N - 1:
    W = 0
  else:
  	E = abs(i - LE[i])
  #print("i:{}, W:{}, E:{}, RW[i+1]={}, LE[i]={}".format(i, W, E, RW[i+1], LE[i]))
  ANS = min(ANS, W + E)
print(ANS)
  

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) {
        freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);
        //freopen("d:\\code\\cpp\\contests\\stdout", "w", stdout);
    }

    int N, M;
    cin >> N >> M;

    int n = 1<<N;
    const ll INF = 1ll<<60;
    vector<ll> dp(n+1, INF);

    vector<int> a(M), c(M);
    FOR(i, M){
        cin >> a[i];
        int bi;
        cin >> bi;
        FOR(j, bi){
            int cii;
            cin >> cii;
            c[i] |= 1<<(cii-1);
        }
    }

    dp[0] = 0;
    FOR(i, M){
        vector<ll> dp2 = dp;
        FOR(j, n)
            dp2[j | c[i]] = min(dp2[j | c[i]], dp[j] + a[i]);
        dp = dp2;
    }
    if (dp[n-1] == INF)
        cout << -1 << endl;
    else
        cout << dp[n-1] << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789)        cerr << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

#define f first
#define s second
#define p pair<int,int>
#define P pair<ll,ll>
#define pb push_back
#define ll long long
#define db double
#define zero(a) memset(a,0,sizeof(a))
#define inff(a,n) fill(a,a+n+1,inf)
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define read(x) scanf("%lld",&x)
#define read2(x,y) scanf("%lld%lld",&x,&y)
#define write(x) printf("%lld\n",x)
#define lson k*2,l,mid
#define rson k*2+1,mid+1,r

const int maxn=1e5+5;
const ll inf=1e16;

ll n,m,k,q,a[maxn],b[maxn],ok,flag,sum,ans1,ans2,ans,l,r;
string s,t,s1,s2;

int main()
{
    read(n);
    for(int i=0;i<n;i++)
    {
        read2(l,r);
        for(int j=l;j<=r;j++)a[j]=1;
    }
    for(int i=0;i<=100000;i++)if(a[i])ans++;
    write(ans);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

int Dist[16];
int N, M;
int crt;
Int calc(int cup){
    //N個のコップを0 -> 2 または 2 -> 0と動かすのに必要な手数をF(N)とする。
    //F(N) = 3*F(N-1)+2
    //F(N)+1 = 3*F(N-1)+3
    //F(N)+1 = 3*(F(N-1)+1)
    //F(N)+1 = 3^(N-1)*(2+1)
    //F(N) = 3^N-1
    
    Int ret = 0;

    int move_dist = abs(Dist[cup] - crt);
    if (move_dist == 1){
        ret = 1;
        for (int i = 0; i < (N-cup); i++){
            ret *= 3LL;
        }
        crt = 2 - crt;    
    }else if(move_dist == 2){
        ret = 1;
        for (int i = 0; i < (N-cup); i++){
            ret *= 3LL;
        }
        ret--;
        ret *= 2;
        ret += 2;
    }
    return ret;
}

int solve(){
    cin >> N >> M;
    if (!N && !M) return 0;
    for (int i = 0; i < 3; i++){
        int n; cin >> n;
        for (int j = 0; j < n; j++){
            int cup; cin >> cup;
            Dist[cup] = i;
        }
    }

    crt = 0;
    Int ans[2] = {0}; 
    for (int i = 1; i <= N; i++){
        ans[0] += calc(i);
    }
    crt = 2;
    for (int i = 1; i <= N; i++){
        ans[1] += calc(i);
    }
    if (min(ans[0], ans[1]) > M) ans[0] = -1;
    cout << min(ans[0], ans[1]) << endl;
    return 1;
}


int main(){
    cin.tie(0);
    while (solve());
}




Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
 
int main(void){
    int n, a[110], sum=0, min=1000000;
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
        sum += a[i];
        if(a[i]%10!=0){
            if(min > a[i]) min = a[i];
        }
    }
    sort(a, a+n);
    if(sum%10!=0){
        cout << sum << endl;
        return 0;
    }
    if(min!=1000000){
        sum -= min;
        cout << sum << endl;
    }else{
        cout << "0" << endl;
    }
}

Measured memory_bytes: 256
def main():
    n,a,b=map(int,input().split())
    if a==0:
        ans=0
    else:
        t=n//(a+b)
        if t==0:
            ans=min(a,n)
        else:
            ans=a*t+min(n%(t*(a+b)),a)
    print(ans)

if __name__=='__main__':
    main()

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

#define int int64_t
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,n) for(int i=1; i<=(n); ++i)
#define pii pair<int,int>
#define gsort(x,n) sort((x),(x)+(n),greater<int>())
#define all(x) (x).begin(), (x).end()
#define ll long long
#define re(s) reverse((s).begin(),(s).end())
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int mod = 1000000007;
const int INF = 0x3f3f3f3f;
const int LINF = 0x3f3f3f3f3f3fLL;

using namespace std;

int n,m;
int a[10010],b[10010];
int dp[1<<20];
int c[1010][1010];

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

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

        rep(j,b[i]){
            cin>>c[i][j];
           --c[i][j];
        }
    }

    rep(i,(1<<n)) dp[i] = LINF;
    dp[0] = 0;

    rep(i,m){
        rep(j,(1<<n)){
            if(dp[j] != LINF){
                int cnt = 0;
                rep(k,b[i]) cnt |= (1<<c[i][k]);
                dp[j|cnt] = min(dp[j|cnt],dp[j]+a[i]);
            }
        }
    }

    if(dp[(1<<n)-1] == LINF) cout<<-1<<'\n';
    else cout<<dp[(1<<n)-1]<<'\n';
}

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

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

	vector<long long> a(n+1);
	for(int i=1;i<n+1;i++){
		cin >> a[i];
		//累積和をとる
		a[i]+=a[i-1];
	}

	long long ans=0;
	map<long long,int> m;

	//各値の数を数えながらnC2を求めていく
	for(int i=0;i<n+1;i++){
		ans+=m[a[i]];
		m[a[i]]++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define ALLA(a) a,a+a.size();
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;


int main (){
  int n;
  while (cin >> n){
    vector<int> A;
    REP(i,n){
      int ii;
      cin >> ii;
      A.push_back(ii);
    }
    sort(ALL(A));
    ostringstream ostr;
    ostr << A[0];
    string s1 = ostr.str();
    A.erase(A.begin());
    vector<int> vi;
    for(int is = 0; is < 5 && is < A.size(); is++){
      int ai = A[is];
      ostringstream ostr1;
      ostr1 << ai;
      string a = ostr1.str();
      string na = a + s1;
      int ivi;
      sscanf(na.c_str(),"%d",&ivi);
      vi.push_back(ivi);
      na = s1 + a;
      sscanf(na.c_str(), "%d", &ivi);
      vi.push_back(ivi);
    }

    sort(ALL(vi));
    cout << vi[2] << endl;   
  }
  return 0;
}



Measured memory_bytes: 3316
using System;
using System.Linq;

class AtCoderCS {
    static void Main(string[] args) {
        int[] ABCD= Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        int A = ABCD[0], B = ABCD[1], C = ABCD[2], D = ABCD[3];

        int tak = (int)Math.Ceiling((double)C / B);
        int aok = (int)Math.Ceiling((double)A / D);

        Console.WriteLine(tak <= aok ? "Yes" : "No");
    }
}

Measured memory_bytes: 28300
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
   /* #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        

fast();
//ll t;cin>>t;while(t--)
{
    string s,ss;
    cin>>s;
    ss=s;
    ll n=s.length(),ans=INT_MAX;
    //cout<<n<<endl;
    string t="";
    for(int i=0;i<26;i++)
{
      char c='a'+i;
      map<char,ll>m;
       s=ss;
      ll count=0;
      for(int k=0;k<s.length();k++)
      {
        m[(s[k])]++;
      }
      if(m.size()==1)
        {
           //cerr<<" first if"<<endl;
           ans=min(ans,count);
           break;
        }
        else
        {
          m.clear();
        }
    
    

      
      while(m.size()!=1)
    {
      //cout<<" S = "<<s<<" "<<c<<endl;
       for(int j=0;j<s.length()-1;j++)
      {
        if(s[j]==c||s[j+1]==c)
        {
          t=t+c;
          m[(c)]++;
        }
        else
        {
          t=t+s[j];
          m[(s[j])]++;
        }
        

      }
     //cout<<" S = "<<s<<" "<<s.length()<<" "<<c<<endl;
      //cerr<<"T = "<<t<<" "<<t.length()<<endl;
        
           count++;
        if(m.size()==1)
        {
          //cout<<"IF Second "<<count<<endl;
          ans=min(ans,count);
          m.clear();
        s=t;
        t="";
           break;
        }
        m.clear();
        s=t;
        t="";
    }
      
   
}
    cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <random>

int main(void){
    int L, R, D;
    std::cin >> L >> R >> D;
    int res = 0;
    for(int i = L; i <= R; ++i) if(i % D == 0) ++res;
    std::cout << res << '\n';
}

Measured memory_bytes: 3628
# Problem
# Python 2nd Try


def solver(marble):
    result = 0
    n = marble
    while 0 < n:
        scaleNo = n % 10
        result = result + scaleNo
        n = n // 10
    return result


if __name__ == "__main__":
    answer = 0
    answer = solver(int(input()))
    print(answer)


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;
vector<int> h;
int A,B,N;

bool canKill(int);
int binary_search(int,int,int);

int main() {
    cin>>N>>A>>B;
    int h_max=0;
    REP(i,N){
        int tmp;
        cin>>tmp;
        h.push_back(tmp);
        h_max=max(h_max,tmp);
    }
    sort(ALL(h));

    int binary_left=0;
    int binary_right=(h_max-1)/B+1;
    int center;
    canKill(3);
    while(true) {
        center=(binary_left+binary_right)/2;
        if (canKill(center)) {
            binary_right = center;
        } else {
            binary_left = center;
        }
        if((binary_left+binary_right)/2==center){
            break;
        }

    }
    cout<<binary_right<<endl;



    return 0;
}

bool canKill(int num){
    //h[k]<=B*num
    int k = binary_search(B*num,0,N);
    int ex = A-B;
    long long int cnt =0;
    for(int i=k;i<N;i++){
        cnt+=(h[i]-B*num-1)/ex+1;
    }
    if(cnt<=num){
        return true;
    }else{
        return false;
    }


}

int binary_search(int H,int left,int right){
    int center =(left+right)/2;
    if(h[center]>H){
        right = center;
    }else{
        left = center;
    }

    if((left+right)/2==center){
        return right;
    }else{
        return binary_search(H,left,right);
    }


}

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

ll gcd(ll x, ll y) {
    if (x < y)
        swap(x, y);
    while (y > 0) {
        ll r = x % y;
        x = y;
        y = r;
    }
    return x;
}

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

int main(void) {
    ll n;
    cin >> n;
    ll ans = 1LL;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        ans = lcm(ans, x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
typedef pair<int, int>P;

int main() {
	char s;
	cin >> s;
	if (s == 'A') {
		cout << 'T' << endl;
	}
	else if (s == 'C') {
		cout << 'G' << endl;
	}
	else if (s == 'G') {
		cout << 'C' << endl;
	}
	else if (s == 'T') {
		cout << 'A' << endl;
	}
	return 0;
}

Measured memory_bytes: 768