akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1234567890

int main(){
    ll i,j;
    ll n;
    cin>>n;
    double a=0;
    double b;
    for(i=0;i<n;i++){
        cin>>b;
        a+=1/b;
    }
    printf("%.10lf\n",1/a);
    
    return 0;
}

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

using namespace std;
typedef long long ll;
const int maxN = 1e5 + 100;
int n;
ll h[maxN];
ll a, b;
bool check(ll x) {
    ll need = 0;
    for (int i = 1; i <= n; i++) {
        if (b * x >= h[i]) continue;
        need += (h[i] - b * x + a - b - 1) / (a - b);
    }
    return need <= x;
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    cin >> a >> b;
    for (int i = 1; i <= n; i++) cin >> h[i];
    ll l = 0;
    ll r = 1e9 + 100;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        if (check(mid)) r = mid;
        else l = mid;
    }
    cout << r;
    return 0;
}


Measured memory_bytes: 1024
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let l: i32 = vec[0].parse().unwrap();

    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let d: i32 = vec[0].parse().unwrap();
    let mut ans: i32 = vec[1].parse().unwrap();

    for _ in 0..l{
        let scan = std::io::stdin();
        let mut line = String::new();
        let _ = scan.read_line(&mut line);
        let vec: Vec<&str> = line.split_whitespace().collect();
        let a: i32 = vec[0].parse().unwrap();
        let mut cnt = 1;
        'l1:loop{
            if cnt > d{
                break 'l1;
            }
            ans = ans + 1;
            cnt = cnt + a;
        }
    }

    println!("{}",ans);

}


Measured memory_bytes: 4352
#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>;

int main() {
  int n;
  cin >> n;
  vector<int> r(n);
  rep(i, n) cin >> r[i];
  
  int ans = -1000000005;
  int minv = r[0];
  for (int i=1; i<n; i++) {
    ans = max(ans, r[i] - minv);
    minv = min(minv, r[i]);
  }

  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3632
a = int(input())
ar = list(map(int,input().split(" ")))
ar.sort()
count = a
total = ar[0]
b = 1
for i in range(1,a):
    if total * 2 < ar[i]:
        count -= b
        b = 0
    b += 1
    total += ar[i]
print(count)
    

Measured memory_bytes: 14404
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,k;
    cin>>n>>k;
    if(k<=(n/2)+(n%2!=0)) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int A, B, T;
    std::cin >> A >> B >> T;  
    int ans = T / A * B;

/*
    int ans = 0;
    for (int i = 0; i <= T; i++) {
        if (i % A == 0) ans += B;
    }
*/
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){

long double A, B, H, M, hk, mk, k, ans;
cin >> A >> B >> H >> M;
//なんにも考えずに全部doubleで定義して入力
//hkは分針の角度,mkは時針の角度,kはその差で,ansが答え出力用

mk = M * 6;
hk = H * 60;
hk = hk + M;
hk = hk / 2;
k = fabs(hk - mk);
//ここまでで時計の針の角度を算出
//fabs関数で絶対値を算出できるらしい？
if(k > 180){
  k = 360 - k;
}

//角度が180度以上の場合の処理

k = k*(M_PI/180);
//角度をラジアンに変換
ans = 2 * A * B * cos(k);
ans = ans * -1;
A = A * A;
B = B * B;
ans = A + B + ans;
//ここまで余弦定理(c^2=a^2+b^2-2ab cos(a))
ans = sqrt(ans);
//平方根が答え

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

}

Measured memory_bytes: 4152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n, m;
    cin >> n >> m;
    long long x[1050], y[1050], z[1050];
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> y[i] >> z[i];
    }
    vector <pair<long long, int> > score[8];
    long long ans = -INF;
    for(int i = 0; i < 8; i++){
        for(int j = 1; j <= n; j++){
            pair<long long, int> in;
            in.first = 0;
            in.first += x[j] * ((i % 2) * 2 - 1);
            in.first += y[j] * (((i / 2) % 2 ) * 2 - 1);
            in.first += z[j] * (((i / 4) % 2) * 2 - 1);
            in.second = j;
            score[i].push_back(in);
        }
        sort(score[i].begin(), score[i].end(), greater<pair<long long, int> >());
        for(int k = 0; k < n; k++){
            //cout << score[i][k].first << endl;
        }
        long long checker[3] = {0, 0, 0};
        for(int k = 0; k < m; k++){
            checker[0] += x[score[i][k].second];
            checker[1] += y[score[i][k].second];
            checker[2] += z[score[i][k].second];
        }
        ans = max(ans, abs(checker[0]) + abs(checker[1]) + abs(checker[2]));
    }
    cout << ans << endl;
        
    return 0;
}

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

int main() {
  int c[3][3] = {};
  for(int i = 0;i < 3;i++){
    for(int j = 0;j < 3;j++){
      cin >> c[i][j];
    }
  }

  bool flag = false;
  int b1 = 0, b2 = 0, b3 = 0;
  for(int a1 = 0; a1 <= 100; a1++){
    for(int a2 = 0; a2 <= 100; a2++){
      for(int a3 = 0; a3 <= 100; a3++){
        b1 = c[0][0] - a1;
        b2 = c[0][1] - a1;
        b3 = c[0][2] - a1;
        if(a2+b1 == c[1][0] && a2+b2 == c[1][1] && a2+b3 == c[1][2]){
          if(a3+b1 == c[2][0] && a3+b2 == c[2][1] && a3+b3 == c[2][2]){
            flag = true;
          }
        }
      }
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


}


Measured memory_bytes: 384
n, m = map(int, input().split())

divisors = []
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        divisors.append(i)
        if i != m // i:
            divisors.append(m // i)
divisors.sort()

print([i for i in divisors if i <= m/n][-1])


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k; cin >> n >> k;

    ll mx = 0;

    vector<ll> a(n);
    for (ll i = 0; i < n; ++i) {
        cin >> a[i];
        mx = max(mx, a[i]);
    }

    if (mx < k) {
        puts("IMPOSSIBLE");
        return 0;
    }

    ll g = 0;
    for (ll i = 0; i < n; ++i) {
        g = __gcd(g, a[i]);
    }

    if (k % g == 0) {
        puts("POSSIBLE");
    } else {
        puts("IMPOSSIBLE");
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	map<int, int> mp;
	for(int i = 0; i < n; ++i) {
		int d;
		//cin >> d;
		scanf("%d", &d);
		mp[d]++;
	}
	
	int m;
	cin >> m;
	
	vector<int> t(m);
	for(int i = 0; i < m; ++i) {
		//cin >> t[i];
		scanf("%d", &t[i]);
	}
	
	bool yes = true;
	for(int i = 0; i < m; ++i) {
		if( mp[t[i]] == 0 ) {
			yes = false;
			break;
		}
		
		mp[t[i]]--;
	}
	
	if( yes ) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string.h>
using namespace std;

int main(void)
{
	string n;
	int sum;

	cin >> n;
	while (n[0] != '0')
	{
		sum = 0;
		for (int i = 0; i < n.size(); i++)
		{
			sum += n[i] - '0';
		}
		cout << sum << endl;
		cin >> n;
	}
	return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int x, t;
  cin >> x >> t;

  cout << max(0, x - t) << endl;

  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> status(n);
    vector<int> WA_count(n);
    int ans = 0;
    int penalties = 0;
    for(int i = 0; i < m; ++i){
        int id;
        string s;
        cin >> id >> s;
        if(s == "AC"){
            if(!status[id]){
                penalties += WA_count[id];
                status[id] = true;
                ans++;
            }
        }
        else{
            WA_count[id]++;
        }
    }
    cout << ans << " " << penalties << endl;
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
typedef vector<vp> vvp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>(b);--i)
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
  string s,t;cin>>s>>t;
  bool ok=true;
  rep(i,0,s.size()){
    if(s[i]!=t[i]){ok=false;}
  }
  if(ok){
    cout<<"Yes"<<endl;
  }
  else{cout<<"No"<<endl;}
}



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;

/*vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
*/
// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
//vll a;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll cou = 0;
	cin >> n >> x >> y;
	while(n>0) {
		cou+=y;
		n-=x;
	}
	cout<<cou;
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3580
#define DEBUG
#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;
 
#define F first
#define S second 
#define pb push_back
#define endl "\n"

#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }

#ifdef DEBUG
    #define dbg(s) {s;}
#endif

#ifndef DEBUG
    #define dbg(s)
#endif

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int grand(int x) { // from [0, x-1]
    return uniform_int_distribution<int>(0, x - 1)(rng);
}

#define int ll
#define i32 int32_t

#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 

#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;

int getInt () {
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}


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

const ll mod = 1e9 + 7;

ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % mod;
        ex >>= 1ll;
        x = (x * x) % mod;
    }
    return ans;
}

const int maxn = 1e6 + 7;

const ll inf = 1e9 + 7;

int arr[maxn];

vector<int> prec;
vector<int> coun;
int n;

int findAns(int k)
{
    int m = prec.size();

    int l = 0;
    int r = n/k;
    int mid;
    int req;
    int idx;
    int tot, rem;
    while(l!=r)
    {
        mid = l+r+1;
        mid/=2;
        
        req = mid*k;
        idx = upper_bound(coun.begin(),coun.end(),mid)-coun.begin();
        idx--;
        rem = m-1-idx;

        tot = rem*mid + prec[rem];

        if(tot>=req)
            l=mid;
        else
            r= mid-1;
    }
    
    return l;
}

i32 main() {
    //freopen("<file>.in", "r", stdin);
    //freopen("<file>.out", "w", stdout);

    IOS;
    cin>>n;
    
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        arr[x]++;
    }

    for(int i=1;i<=n;i++)
    {
        coun.pb(arr[i]);
    }
    
    sort(all(coun));
    reverse(all(coun));

    int m = coun.size();

    for(int i=0;i<m;i++)
        prec.pb(coun[i]);

    for(int i=m-2;i>=0;i--)
        prec[i] += prec[i+1];
    
    reverse(all(coun));
    int ans;
    for(int i=1;i<=n;i++)
    {
        cout<<findAns(i)<<endl;
    }

    
}





Measured memory_bytes: 15980
/*
** author:mahmoud magdy
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"

inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m;
    cin>>m;
    return m;
}
void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
const int N=1e2+5;
int a[N];
int main()
{
    int n=D();
    for(int i=0;i<n;++i){
        a[i]=D();
    }
    ll ans=1e9;
    for(int i=-100;i<=100;++i){
        ll sum=0;
        for(int j=0;j<n;++j){
            sum+=(a[j]-i)*(a[j]-i);
        }
        ans=min(sum,ans);
    }
    cout<<ans<<endl;
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int A,B;
	
	cin >> A >>B;
	if((A+B)%2==0){
		std::cout << (A+B)/2 << "\n";
	}
	else {
		print("IMPOSSIBLE");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>

using namespace std;

int main()
{
    int n, r;
    cin >> n >> r;
    
    if(n >= 10) {
        cout << r << endl;
    }else {
        cout << r+100*(10-n) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
data = []
for i in range(n):
    data.append(tuple(map(int,input().split())))

data.sort(key = itemgetter(1))

m = 0

for i, j in data:
    if m+i <= j:
        m += i
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 81624
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::min;
fn main() {
    input!{
        a: u64,
        b: u64,
    }
    println!("{}", ((a + b + 1) / 2));
}


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

using namespace std;

bool solve(int A, int B, const string& S) {
    for (int i = 0; i < A; ++i) {
        if (S[i] == '-') {
            return false;
        }
    }
    if (S[A] != '-') {
        return false;
    }
    for (int i = 0; i < B; ++i) {
        if (S[A + i + 1] == '-') {
            return false;
        }
    }
    return true;
}

void Main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;

    cout << (solve(A, B, S) ? "Yes" : "No") << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
    int n, m;
    char ch;
    cin >> n;
    vector< vector<int> > v(4, vector<int>(13));
    
    for (int i = 0; i < n; i++) {
        cin >> ch >> m;
        if (ch == 'S') {
            v.at(0).at(m-1) = 1;
        } else if (ch == 'H') {
            v.at(1).at(m-1) = 1;
        } else if (ch == 'C') {
            v.at(2).at(m-1) = 1;
        } else if (ch == 'D') {
            v.at(3).at(m-1) = 1;
        }
    }
    
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (!(v.at(i).at(j))) {
                if (i == 0) cout << 'S';
                if (i == 1) cout << 'H';
                if (i == 2) cout << 'C';
                if (i == 3) cout << 'D';
                cout << ' ' << j + 1 << endl;
            }
        }
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <string>
#include <stdio.h>
#include <sstream>


using namespace std;
void swap(int &a, int &b);

int main()
{
	// 探索する文字列
	string sstr;// = {};
	string Output[10];
	
	int tempcount = 0;
	while (true)
	{
		cin >> sstr;
		if (sstr == "-")
			break;
		int numOfShuffle;
		cin >> numOfShuffle;

		int tempnum;

		for (int i = 0; i < numOfShuffle; ++i)
		{
			cin >> tempnum;
			string stemp = sstr.substr(0, tempnum);
			sstr.erase(0, tempnum);
			sstr += stemp;

		}

		Output[tempcount] = sstr;
		tempcount++;

	}

	for (int i = 0; i < tempcount; ++i)
		cout << Output[i].c_str() << endl;

	return 0;
}




Measured memory_bytes: 3192
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 200000;

int main() {
	int N;
	int A[MAX], B[MAX];
	int ans = 0;

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

	for (int i = 0; i < 29; i++) {
		int T = pow(2, i);
		vector<int>a, b;

		for (int i = 0; i < N; i++) {
			a.push_back(A[i] % (2 * T));
			b.push_back(B[i] % (2 * T));
		}

		sort(b.begin(), b.end());

		int sum = 0;

		for (int i = 0; i < N; i++) {
			int t1 = lower_bound(b.begin(), b.end(), 1 * T - a[i]) - b.begin();
			int t2 = lower_bound(b.begin(), b.end(), 2 * T - a[i]) - b.begin();
			int t3 = lower_bound(b.begin(), b.end(), 3 * T - a[i]) - b.begin();
			sum += (t2 - t1) + (N - t3);
		}

		if (sum % 2)ans |= T;
	}
	

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define R(a) a=sqrt(a)
#define POW(a,b) a=pow(a,b)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    FAST;
    string n;
    cin>>n;
    char c;
    char z='0';
    ll q=0;
    ll ans;
    rep(i,n.length()){
        c=n[i];
        q+= ll(c-z);
    }
    if(q%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    

    
}



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

string s;
ll dp[1100100][2];

int main() {
    cin >> s;
    dp[0][1] = 1;
    for (int i = 0; i < (int) s.length(); i++) {
        int num = (int)(s[i] - '0');
        dp[i+1][0] = min(dp[i][0] + num, dp[i][1] + (10 - num));
        dp[i+1][1] = min(dp[i][0] + num + 1, dp[i][1] + (10 - num - 1));
    }
    cout << dp[(int)s.length()][0] << endl;
    return 0;
}

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

int main() {
    while(1){
        string s;
        cin >> s;
        if(s=="-")break;
        int m, sum=0, h;
        cin >> m;
        REP(i,m){
            cin >> h;
            sum += h;
        }
        sum %= int(s.size());
        cout << s.substr(sum, s.size()-sum);
        cout << s.substr(0,sum) << endl;
    }
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

ll dp[110000];

int main() {
  ll n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  vector<vector<char>> vec(k,vector<char>());
  rep(i,n) {
    int a = i;
    a %= k;
    char c;
    cin >> c;
    vec[a].push_back(c);
  }
  ll ans = 0;
  rep(i,k) {
    if(vec[i][0] == 'r') ans += p;
    if(vec[i][0] == 's') ans += r;
    if(vec[i][0] == 'p') ans += s;
    bool a = true;
    rep(j,vec[i].size()-1) {
      if(vec[i][j] == vec[i][j+1]) {
        a = !a;
        if(a) {
          if(vec[i][j+1] == 'r') ans += p;
          if(vec[i][j+1] == 's') ans += r;
          if(vec[i][j+1] == 'p') ans += s;
        }
      }
      else {
        if(vec[i][j+1] == 'r') ans += p;
        if(vec[i][j+1] == 's') ans += r;
        if(vec[i][j+1] == 'p') ans += s;
        a = true;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5120
H,W = [int(i) for i in input().split()]
li = [list(input()) for _ in range(H)]

flag = 0
for i in range(H):
    tmp = []
    for j,k in enumerate(li[i]):
        if k == '#':
            tmp.append(j)
    if i != 0 and p != tmp[0]:
        flag = 1
        break
    p = tmp[-1]

print(['Possible', 'Impossible'][flag])


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

int main() {

int N;
int a,b,c;

cin >> N ;

a = N/100;
b = N/10 %10;
c = N % 10;

// cout << a << endl;
// cout << b << endl;
// cout << c << endl;

if(a == 7 || b == 7 || c == 7){
    cout << "Yes" << endl;
}
else{
    cout << "No"  << endl;
}

}

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

int main(){
    ll x, y; cin >> x >> y;
    ll base = x;
    ll res = 1;
    while(base * 2 <= y){
        base*=2;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def lcm(a, b):
    while a % b != 0:
        a, b = b, a % b
    return b


N, X = map(int,input().split())
xs = list(map(int,input().split()))

xs.append(X)
xs.sort()

D = [xs[i + 1] - xs[i] for i in range(N)]

res = min(D)
for d in D:
    if res == 1:
        break
    
    if d % res == 0:
        continue

    res = lcm(d, res)
    
print(res)

Measured memory_bytes: 14252
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
            continue;
        }
        
        while (x!=0) {
            
            if (x % 10 == 3) {
                cout << " " << i;
                break;
            }
            x /= 10;
        }
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 3096
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,t;
  cin>>n>>t;

  //vector<ll> a(n);
  //vector<ll> b(n);

  using pa=pair<ll,ll>;

  vector< pa > pab(n);

  ll ans=0;

  rep(i,n) cin>>pab[i].first>>pab[i].second;

  //sort(begin(pab),end(pab),greater<pa>());
  sort(begin(pab),end(pab));

  vector<ll> a(n);
  vector<ll> b(n);

  rep(i,n){
    a[i]=pab[i].first;
    b[i]=pab[i].second;
  }

  vector<ll> dp( 6001,0 );
  vector<ll> dp_new( 6001,0 );
  dp[0]=0;
  rep(i,n){
    rep(j,6001){
      if( j-a[i]>=0 && j-a[i] < t && dp[j] < dp[j- a[i] ] + b[i] ){
        dp_new[j]=dp[j- a[i] ] + b[i];
      }
    }
    rep(j,6001){
      //if(j==0) dp[j]=0;
      //else dp[j]=max(dp_new[j],dp[j-1]);
      dp[j]=dp_new[j];
    }
    dp_new.resize(6001,0);
  }
  
  ///*
  rep(i,6001){
    //cerr << dp[i] << " " ;
    chmax(ans,dp[i]);
  }
  //cerr << endl;
  //*/
  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		while (true){
			//文字列のリスト
			ArrayList<Character> list = new ArrayList<Character>();
		
			//データ入力
			String input = sc.next();
			
			//終了条件の判定
			if (input.equals("-") == true){
				break;
			}
		
			//データをリストに格納
			for (int i = 0; i < input.length(); i++){
				list.add(input.charAt(i));
			}
			
			//データのシャッフル
			int m = sc.nextInt();//シャッフルの回数
			for (int i = 0; i < m; i++){
				//次のシャッフル位置
				int h = sc.nextInt();
				
				//シャッフル
				ArrayList<Character> subList = new ArrayList<Character>();
				for (int j = 0; j < h; j++){
					char temp = list.get(0);
					list.add(temp);
					list.remove(0);
				}
			}
			
			//結果を出力
			for (char c : list){
				System.out.print(c);
			}
			System.out.print("\n");
			
		}
		
	}
}


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

int main() {
  int N;
  cin>>N;
  string S="";
  if(N==0){
    S="0";
  }
  while(N!=0){
    if(N%2!=0){
      N--;
      S.push_back('1');
    }
    else{
      S.push_back('0');
    }
    N/=-2;
  }
  reverse(S.begin(),S.end());
  cout<<S<<endl;
}



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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

ll big = (ll)(1e9+100);

struct STNode {
  ll lazy;
  ll vmin;
  STNode() {
    lazy = vmin = big;
  }
};

class SegTree {
private:
  ll tSize;
  vector<STNode> nodes;

  void _update(ll xL, ll xR, ll val, ll node, ll left, ll right) {
    ll& tVmin = nodes.at(node).vmin;
    ll& tLazy = nodes.at(node).lazy;
    if (tLazy <= val) return;
    if (xR <= left || right <= xL)  return;
    tVmin = min(tVmin, val);
    if (xL <= left && right <= xR) {
      tLazy = val;
    }else {
      ll mid = (left + right) / 2;
      _update(xL, xR, val, 2*node+1, left, mid);
      _update(xL, xR, val, 2*node+2, mid, right);
    }
  }

  ll _query(ll xL, ll xR, ll node, ll left, ll right) {
    ll& tVmin = nodes.at(node).vmin;
    ll& tLazy = nodes.at(node).lazy;
    if (xR <= left || right <= xL)  {
      return big;
    }else if (xL <= left && right <= xR) {
      return tVmin;
    }else {
      if (tVmin == tLazy)  return tVmin;
      ll mid = (left + right) / 2;
      ll v1 = _query(xL, xR, 2*node+1, left, mid);
      ll v2 = _query(xL, xR, 2*node+2, mid, right);
      return min(tLazy, min(v1, v2));
    }
  }

public:
  SegTree(ll n) : tSize(n), nodes(4*n) {}

  void update(ll xL, ll xR, ll val) {
    DLOG("update: %lld, %lld, %lld", xL, xR, val);
    return _update(xL, xR, val, 0, 0, tSize);
  }
  
  ll query(ll xL, ll xR) {
    return _query(xL, xR, 0, 0, tSize);
  }

};

ll N, Q;
vector<ll> S, T, X, D;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  cin >> N >> Q;
  S.resize(N);
  T.resize(N);
  X.resize(N);
  for (ll i = 0; i < N; i++) {
    ll s, t, x;
    cin >> s >> t >> x;
    S.at(i) = s;
    T.at(i) = t;
    X.at(i) = x;
  }
  D.resize(Q);
  for (ll i = 0; i < Q; i++) {
    cin >> D.at(i);
  }
  SegTree seg(Q);
  for (ll i = 0; i < N; i++) {
    auto l = lower_bound(D.begin(), D.end(), S.at(i) - X.at(i));
    auto u = upper_bound(D.begin(), D.end(), T.at(i) - X.at(i) - 1);
    seg.update(l - D.begin(), u - D.begin(), X.at(i));
  }
  for (ll i = 0; i < Q; i++) {
    ll v = seg.query(i, i+1);
    cout << (v == big ? -1 : v)  << "\n";
  }

  return 0;
}



Measured memory_bytes: 20608
from collections import Counter
N=int(input())
A=list(map(int,input().split()))

A_freq = Counter(A)
#print(A_freq)


A.sort()
maxi = A[-1]
note = [True for i in range(maxi+1)]
B=list(set(A))

for i in B:
  for j in range(2,maxi//i+1):
    note[j*i] = False

#print(note)
#print(B)

ans = 0
for i in B:
  if note[i] == True and A_freq[i]<=1:
    ans += 1
print(ans)




Measured memory_bytes: 51224
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
string a[100];
int main() {
	int H, W;
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> a[i];
	cout << string(W + 2, '#') << endl;
	for (int i = 0; i < H; i++) {
		cout << "#" << a[i] << "#" << endl;
	}
	cout << string(W + 2, '#') << endl;
}

Measured memory_bytes: 256
N, Q = [int(i) for i in input().split()]
S = input()
LRs = [[int(i) for i in input().split()] for _ in range(Q)]


accs = [0] * N
begins = [False] * N
for c in range(N):
    if c != 0:
        accs[c] = accs[c-1]
    if c == N-1:
        break
    if S[c] == 'A' and S[c+1] == 'C':
        accs[c] += 1
        begins[c] = True

for lr in LRs:
    l, r = lr
    count = accs[r - 1] - accs[l - 1]
    if begins[l - 1]:
        count += 1
    if begins[r - 1]:
        count -= 1

    print(count)


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

int main(){
    int a,b,x=0;
    cin>>a>>b;
    vector <int> n;
    for(int i=0;i<a;i++){
        int daf;
        cin>>daf;
        n.push_back(daf);
    }
    sort(n.begin(),n.end());
    for(int i=0;i<b;i++){
        x =x+n[i];
    }
    cout<<x<<endl;
}

Measured memory_bytes: 3556
#include<stdio.h>
 
int main(){
	int a, b[100], i, c, count = 0, j;
	while(scanf("%d", &a) != 0){
		if(a == 0) break;
		for(i = 0; i < a; i++) scanf("%d", &b[i]);
		for(j = a - 1; j >= 1; j--){
			for(i = 0; i < j; i++){
				if(b[i + 1] < b[i]){
						c = b[i];
						b[i] = b[i + 1];
						b[i + 1] = c;
						count++;
				}
			}
		}
		printf("%d\n", count);
		count = 0;
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include<bits/stdc++.h>
#define ll long long int
#define lld long double
#define F first
#define S second
#define f(i,a,b) for(int i=a;i<=b;i++)
#define g(i,a,b) for(int i=a;i>=b;i--)
#define pb push_back
#define mh make_heap
#define ph push_heap
#define pq priority_queue
#define bits(x) __builtin_popcountll(x)
#define op(x) cout<<"Case #"<<x<<": "
#define op1(x) cout<<"Scenario #"<<x<<": "
#define endl "\n"
using namespace std;
const ll mod = 1000000007;
const ll INF = LLONG_MAX;
const ll NEGINF = LLONG_MIN;
const int N = 18;
const ll MAXN = 1000001;
#define MAX 5


void solve(int t)
{
	int x;
	cin >> x;
	cout << (x ^ 1) << endl;




}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


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


	int t = 1;
	//cin >> t;



	for (int i = 1; i <= t; i++)
	{
		solve(i);

	}
}

Measured memory_bytes: 3648
#include<iostream>
#include<stdlib.h>
using namespace std;

int main(){
  int n,k;
  long long h[400000];
  long long dp[400000];
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> h[i] ;
  }
  for (int i = 0; i < 400000; ++i) dp[i] = 100000000000000;
  
  dp[0] = 0;
  
  for(int i=0;i<n;i++){
    for(int j=1;j<=k;j++){
      dp[i+j] = min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  
  cout << dp[n-1] << endl;
  
  return 0;
}


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

#define rep(i,n) for(int i=0;i<int(n);++i)

int d[22][22];
int V;
int inf=10000000;

void warshall_floyd(){
	for(int k=0; k<V; k++){
		for(int i=0;i<V;i++){
			for(int j=0;j<V;j++){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
}
	

int main(){
	int n,m;
	int a,b,c,e;
	char tmp;
	
	cin>>n>>m;
	V=n;
	rep(i,n+1){
		rep(j,n+1){
			d[i][j]=inf;
		}
	}
	rep(i,n+1) d[i][i]=0;
	rep(i,m){
		cin>>a>>tmp>>b>>tmp>>c>>tmp>>e;
		//cout<<a<<endl;
		d[a-1][b-1]=c;
		d[b-1][a-1]=e;
	}
	//cout<<"hoge";
	warshall_floyd();
	cin>>a>>tmp>>b>>tmp>>c>>tmp>>e;
	cout<<c-e-d[b-1][a-1]-d[a-1][b-1]<<endl;
	return 0;
}

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

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, K;
  cin >> N >> K;
  vec a;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    a.pb(tmp);
  }

  static bool dp[101010];
  m0(dp);

  for (int i = a[0]; i <= K; i++) {
    dp[i] = false;
    for (int j = 0; j < N; j++) {
      dp[i] |= i >= a[j] && !dp[i - a[j]];
    }
  }

  if (dp[K]) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}


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

const int MAX_N = 10002;
const int NUM_P = 1300;

bool isP[MAX_N];
vector<int> P; // size:1299;

void make() {
  P.clear();
  fill(isP, isP+MAX_N, true);
  isP[0] = isP[1] = false;
  for(int i = 2; i < MAX_N; ++i) {
    if(isP[i]) {
      P.push_back(i);
      for(int j = i*2; j < MAX_N; j += i) isP[j] = false;
    }
  }
}

int T[NUM_P][MAX_N];

int rec(int p, int n) {
  int &res = T[p][n];
  if(res == -1) {
    res = 0;
    //if(n-P[p] >= 0) res += rec(p, n-P[p]);
    if(p < P.size() && n-P[p] >= 0) res += rec(p+1, n-P[p]);
  }
  return res;
}

int main() {
  make();
  fill(T[0], T[NUM_P], -1);
  for(int i = 0; i < NUM_P; ++i) T[i][0] = 1;

  int n;
  while((cin >> n) && n) {
    int ans = 0;
    for(int i = 0; i < P.size() && P[i] <= n; ++i) {
      ans += rec(i, n);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
vector<int> X;
vector<int> Y;

int main(){
  cin >> N >> M;
  X.resize(M);
  for(int i=0;i<M;i++){
    cin >> X[i];
  }
  sort(X.begin(),X.end());
  for(int i=M-1;i>0;i--){
    Y.push_back(X[i]-X[i-1]);
  }
  sort(Y.begin(),Y.end());
  if(N >= M){
    cout << "0" << endl;
  }
  else{
    long long sum = 0;
    for(int i = 0; i < (M-N) ; i++){
      sum += Y[i];
    }
    cout << sum << endl;
  }
}

Measured memory_bytes: 1276
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c;
	cin >> a >> b >> c;
	for (int i = 0; i < 10000; i++) {
		if (a % 2 || b % 2 || c % 2) {
			cout << i << endl;
			return 0;
		}
		int na = b / 2 + c / 2;
		int nb = a / 2 + c / 2;
		int nc = a / 2 + b / 2;
		a = na;
		b = nb;
		c = nc;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n; cin >> n;

    bool ok = false;
    rep(i, 1, 10){
        rep(j, 1, 10){
            ok |= (i * j == n);
        }
    }

    cout << (ok ? "Yes":"No") << endl;

    return 0;
}


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

#define sd(a) scanf("%d",&a)
#define ss(a) scanf("%s",a)
#define sl(a) scanf("%lld",&a)
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define N 200010

set<pair<int,int> > sett;

int main()
{
	int n,m,i;
	sd(n);sd(m);
	for(i=0;i<m;i++)
	{
		int x,y;
		sd(x);sd(y);
		sett.insert(MP(x,y));
	}
	for(i=2;i<n;i++)
		if(sett.find(MP(1,i))!=sett.end() && sett.find(MP(i,n))!=sett.end())
			break;
	if(i<n)
		printf("POSSIBLE\n");
	else
		printf("IMPOSSIBLE\n");
}

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

using namespace std;

#define endl '\n'

typedef long long int64;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
const int maxn = 100000 + 10;

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

    int n; cin >> n;

    map<int,int> best;

    int ans = 0;

    for (int i = 0; i < n; ++i){
        int v; cin >> v;
        best[v] = best[v - 1] + 1;
        ans = max(ans, best[v]);
    }

    cout << n - ans << endl;

    return 0;
}

Measured memory_bytes: 9600
import java.util.*;
 
public class Main {
  public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		Integer a = sc.nextInt();
    Integer b = sc.nextInt();
    Integer dist = b-a;
    Integer num = 0;
    for (int i = 1; i < b-a; i++) {
      num += i;
    }
    System.out.println(num-a);
  }
}  

Measured memory_bytes: 35408
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# 圧倒的爆速だった
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

heap = []  # ヒープといっても順序を工夫したただのリスト

from heapq import heapify, heappop, heappush, heappushpop
heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))

ans = []
for k_th in range(1, K+1):
    heap_max, i, j, k = heappop(heap)
    # print(heap_max)
    ans.append(-heap_max)
    for di, dj, dk in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
        i_new, j_new, k_new = i+di, j+dj, k+dk
        if i_new >= X or j_new >= Y or k_new >= Z:
            continue
        tmp = (-(A[i_new]+B[j_new]+C[k_new]), i_new, j_new, k_new)
        if tmp not in heap:
            heappush(heap, tmp)


print(*ans, sep='\n')


Measured memory_bytes: 4084
n,m=map(int,input().split())
import collections
d=collections.defaultdict(list)
for i in range(m):
    x,a=input().split()
    x=int(x)
    d[x].append(a)

ac=0
wa=0
for i in d:
    cnt=0
    for j in d[i]:
        if j=="WA":
            cnt+=1
        else:
            ac+=1
            wa+=cnt
            break
print(ac,wa)

Measured memory_bytes: 29804