akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int main()
{
	int n;
	cin >> n;
	VI a(n),b(n-1);
	IN(n-1, b) ;

	a[0] = b[0];
	a[1] = b[0];
	FOR(1, n-1)
	{
		if (a[i] > b[i])
		{
			a[i] = b[i];
		}
		a[i + 1] = b[i];
	}

	int ans = 0;
	FOR(0, n)
	{
		ans += a[i];
	}

	cout << ans << endl;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;
    cout << (n ^ 1) << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

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

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 3608
fn read<T: std::str::FromStr>() -> T {
    let mut s  = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_ls<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main(){
    let _ : i64 = read();
    let l : Vec<i64> = read_ls();
    let lminop = l.iter().min();
    let lmaxop  = l.iter().max();
    let lsum : i64 = l.iter().sum();
    if let Some(lmin) = lminop {
        if let Some(lmax) = lmaxop {   
            println!("{} {} {}", lmin , lmax, lsum);
        }
    }
}




Measured memory_bytes: 5044
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define INF 1000000000
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N,K;
	cin>>N>>K;
	vector<int>A(N);
	vector<int>co(N);
	REP(i,N)co[i]=0;
	REP(i,N){
		cin>>A[i];
		co[A[i]-1]++;
	}
	//REP(i,N)cout<<co[i]<<endl;
	int ans=0,x=0;
	std::sort(co.begin(),co.end());
	REP(i,N){
		if(co[i]>0)x++;
	}
	x-=K;
	//cout<<x<<endl;
	int i=0;
	while(x>0){
		if(co[i]>0){
			ans+=co[i];
			x--;
		}	
		i++;
	}
	
	cout<<ans<<endl;
	
	return 0;
}
	

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main(void)
{
    int n;
    while (cin >> n)
    {
        int co = 0;
        for (int a = 0; a <= 9; a++)
        {
            for (int b = 0; b <= 9; b++)
            {
                for (int c = 0; c <= 9; c++)
                {
                    for (int d = 0; d <= 9; d++)
                    {
                        if (a + b + c + d == n)
                        {
                            co++;
                        }
                    }
                }
            }
        }
        cout << co << endl;
    }
}



Measured memory_bytes: 3084
#include<iostream>
#include<stack>
#include<queue>
using namespace std;

int main(){
	stack<int> st;
	queue<int> q;
	int input;

	cin >> input;
	st.push(input);
	while(cin >> input){
		if(input == 0){
			cout << st.top() << endl;
			st.pop();
		}
		else{
			st.push(input);
		}
	}
}

Measured memory_bytes: 1200
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	string s;
	cin >> s;
	if(s == "ABC")cout << "ARC" << endl;
	else cout << "ABC" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int h,w; char c[105][105]; cin>>h>>w;
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            cout<<c[i][j];
        }
        cout<<endl;
        rep(j,w){
            cout<<c[i][j];
        }
        cout<<endl;
    }

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n,ans=0;
    scanf("%lld",&n);
    // ll [n];
    ans+=n/500*1000;
    n%=500;
    ans+=n/5*5;
    // rep(i,0,n){
    //     scanf("%lld",&[i]);
    // }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
x=int(raw_input())
if x<=6:
    print(1)
else:
    x-=6
    if x%11>5:
        print(x/11*2+2+1)
    else:
        if x%11==0:
            print(x/11*2+1)
        else:
            print(x/11*2+1+1)

Measured memory_bytes: 2692
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>

int main()

{
    int a,b,c,d,na,nb;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(1)
    {
     c=c-b;
        if(c<=0)
        {
            printf("Yes\n");
            break;
        }
        a=a-d;
        if(a<=0)
        {
        printf("No\n");
        break;
    }

    }

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int k, s, sum = 0;
  cin >> k >> s;
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k; j++){
      int z = s - i - j;
      if(0 <= z && z <= k) sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
A1,B1,C1=list(map(int,input().split()))
ki=0
A=A1
B=B1
C=C1
while A%2==0 and B%2==0 and C%2==0:
    ki+=1
    ka=A
    kb=B
    A=(B+C)/2
    B=(ka+C)/2
    C=(ka+kb)/2
    if A==A1 and B==B1 and C==C1:
        ki=-1
        A=1
print(ki)

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

typedef long long int ll;
typedef vector<int> vi;			
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> 	pii;
typedef vector<bool> vb;
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#ifdef LOCAL
	#include "../../trace.h"
#else
    #define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}

void solve(){
	ll n, d; cin>>n>>d;
	int cntr = 0;
	for(int i = 0; i<n; i++){
		ll x, y; cin>>x>>y;
		cntr += (x*x+y*y)<=d*d;
	}
	cout<<cntr<<endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef LOCAL
		freopen(".inp.txt", "r", stdin);
    	freopen(".out.txt", "w", stdout);
    	freopen(".err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	while(t--)
		solve();
}

Measured memory_bytes: 3652
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
        	String s=sc.next();
            if(s.equals("-"))
                break;
        	int m=sc.nextInt();
        	for(int i=0;i<m;i++){
           		int h=sc.nextInt();
           		s=s.concat(s.substring(0,h));
                StringBuffer sb=new StringBuffer(s);
            	sb=sb.delete(0,h);
                s=sb.toString();
        	}
        	System.out.println(s);
        }
        
    }
}


Measured memory_bytes: 26336
#include <stdio.h>

int A[20],n;

int sum(int,int);

int main(){
  int q,m[200],i,cnt = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
  }
  for(i=0;i<q;i++){
    if(sum(0,m[i]))
      printf("yes\n");
    else
      printf("no\n");
  }

  return 0;
}

int sum(int i,int key){
  if(key == 0)
    return 1;
  else if(i >= n)
    return 0;
  if(sum(i+1,key)||sum(i+1,key-A[i]))
    return 1; 
}



Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a[5];
  int k;
  bool flag = true;
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  cin >> k;
  if((a[4] - a[0]) > k) flag = false;
  if(!flag) {
    cout << ":(" << endl;
  }
  else {
    cout << "Yay!" << endl;
  }
  return 0;
}


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

using namespace std;

#define forn for (ll i = 0; i < n; i++)
#define form for (ll j = 0; j < m; j++)
#define NO cout << "NO\n";
#define YES cout << "YES\n";
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

ll gcd(ll a, ll b){
    ll r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


ll *calc_z(string s){
    ll n = s.size();
    ll *z = new ll[n] {0};
    ll l = 0, r = 0;
    for (ll i = 1; i < n; i++){
        if (r >= i) z[i] = min(z[i-l], r-i+1);
        while (z[i]+i < n && s[z[i]] == s[z[i]+i]) z[i]++;
        if (i + z[i] - 1 > r){
            l = i;
            r = i+z[i]-1;
        }
    }
    return z;
}

ll find_lower(ll *a, ll n, ll v){
    ll l = -1, r = n;

    while (r>l+1){
        ll m = (l+r)/2;

        if (a[m] >= v) r = m;
        else l = m;
    }
    if (r == n) return n-1;
    if (a[r] == v) return r;
    return r == 0 ? 0 : r-1;
}

void solve(){
    ll a;
    cin >> a;
    cout << a + a*a + a*a*a << "\n";

}

int main(){
    //init();

    ios::sync_with_stdio(0);
    cin.tie(0);

    //ll t; cin >> t; while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, M;
        cin >> N >> M;

        vector<pll> ab(M);
        rep(i, 0, M) {
                ll a, b;
                cin >> a >> b;
                ab[i] = pll{a, b};
        }       

        sort(all(ab), [](auto a, auto b) { return a.second < b.second; });



        ll right = 0;
        ll ans = 0;

        rep(i, 0, M) {
                if (ab[i].first >= right) {
                        ++ans;
                        right = ab[i].second;
                }
        }
        cout << ans << endl;

}




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

int main(){
    ll n,k;
    cin>>n>>k;
    if(n<k) cout<<min(n,k-n);
    else{
        ll cnt=n/k;
        cout<<min(n-cnt*k,abs(n-k*(cnt+1)));
    }
    return 0;
}


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  string t;cin>>t;
  bool res=false;
  if(s==t)res=true;
  for(int i=0;i<s.size();i++){
    s=s[s.size()-1] + s.substr(0, s.size()-1);
    // cout<<s<<endl;
    if(s==t)res=true;
  }
  if(res)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
#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 {
#ifndef ONLINE_JUDGE
~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__) << "] "
const int nax = 1e5+100;
int main() {
	int n,W;
	cin>>n>>W;
	vector<long long> v(n),w(n);
	for(int i=0;i<n;i++) {
		cin>>w[i]>>v[i];
	}
	//dp[i][w] = max profit with i items and w weight
	vector<vector<long long>> dp(n+1,vector<long long> (W+1));
	for(int i=1;i<=n;i++) {
		for(int j=0;j<=W;j++) {
			if(w[i-1]>j) {
				dp[i][j] = dp[i-1][j]; //exclude if inclusion leads to overflow
			} else {
				dp[i][j] = max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
			}
		}
	}
	cout<<dp[n][W];
}




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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;



int main() {
    
    int x; cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var xys=Arr.shift().split(" ").map(Number);
   var x=xys[0];
   var y=xys[1];
   var s=xys[2];
   if(x==0 && y==0 && s==0)break;
   var max=0;
   for(var i=1;i<=s-1;i++){
      for(var j=1;j<=s-1;j++){
         var a=Math.floor(i*(100+x)/100)+Math.floor(j*(100+x)/100);
         if(a>s)break;
         if(a==s){
            var b=Math.floor(i*(100+y)/100)+Math.floor(j*(100+y)/100);
            max=Math.max(max,b);
            break;
         }
      }
   }
   console.log(max);
}

Measured memory_bytes: 10028
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
#define llx(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len) {char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
int n,m,i,j,num[500005],x,ans;
string st;
int main()
{
	cin>>n;
	while (n--)
	{
		cin>>x;
		while (x%2==0)
		{
			ans++;
			x/=2;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long k = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();
        if (k == 2 && a == 1) {
            long c = a;
            long change = (k - a + 1) / 2;
            if ((k - a + 1) % 2 == 0) {
                c += change * (b - a);
            } else {
                c += change * (b - a) + 1  ;
            }
            System.out.println(c);
            return;
        }


        if (b - a <= 2) {
            System.out.println(k + 1);
            return;
        }
        if (k - a < 1) {
            System.out.println(k + 1);
            return;
        }

        long c = a;
        long change = (k - a + 1) / 2;
        if ((k - a + 1) % 2 == 0) {
            c += change * (b - a);
        } else {
            c += change * (b - a) + 1  ;
        }

        System.out.println(c);
    }

}


Measured memory_bytes: 22740
#include <iostream>
#include <stdio.h>
using namespace std;
 
int main(){
    int A,B;
    scanf("%d %d",&A,&B);
    if((A+B)%3 ==0 || A%3==0 || B%3==0){
    cout << "Possible" << endl;

    }else{
        cout << "Impossible" << endl;
    }    


    return 0;
    
}

Measured memory_bytes: 256
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const s = input[0][0].split("").map(Number);

  return s.reduce((sum, cur) => sum + cur);
};

console.log(main(read()));


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

using namespace std;

const int MX = 100, MP = 100000;

int k, c[MX], p[MP], lastPos[MX];

bool check(int a, int b, int n) {
	for (int i = 0; i < k; i++)
		for (int j = 0; j < k; j++) {
			if (i == j) continue;
			
			int cntI = c[i];
			int cntJ = c[j];
			
			if (lastPos[i] >= b) {
				// need to cover last 'i'
				
				if (lastPos[j] >= a) {
					// last 'j' can be used to cover last 'i'
				}
				else {
					// last 'j' can not be used anymore
					cntI++;
				}
			}
			
			if (lastPos[j] > lastPos[i] && lastPos[j] >= a) {
				// can use last 'j' to cover the next 'i'
				cntI--;
			}
			
			if (cntI > 2 * cntJ) {
//				printf("\t%d %d %d -> %d %d | %d %d\n", a, b, n, i + 1, j + 1, cntI, cntJ);
				return false;
			}
		}
	
	return true;
}

pair<int, int> append(int a, int b, int n, int x) {
	p[n] = x;
	c[x]--;
	a = max(lastPos[x] + 1, a);
	lastPos[x] = n;
	n++;
	
	if (n - a == k) {
		a++;
		b = n;
	}
	
	return {a, b};
}

bool tryAppend(int a, int b, int n, int x) {
	int xPos = lastPos[x];
	
	if (xPos >= b) return false;
	
	int aa, bb;
	tie(aa, bb) = append(a, b, n, x);
	
	bool res = check(aa, bb, n + 1);
	
	lastPos[x] = xPos;
	c[x]++;
	
	return res;
}

int main() {
	ignore = scanf("%d", &k);
	for (int i = 0; i < k; i++) ignore = scanf("%d", c + i);
	
	fill(lastPos, lastPos + k, -1);
	
	if (check(0, 0, 0) == false) {
		printf("%d\n", -1);
		
		return 0;
	}
	
	int a = 0, b = 0, n = 0;
	while (*max_element(c, c + k) > 0) {
		int x = 0;
		while (x < k && tryAppend(a, b, n, x) == false) x++;
		
		if (x == k) {
			printf("Fail\n");
			return 0;
		}
		
		tie(a, b) = append(a, b, n, x);
		n++;
		
		printf("%d ", x + 1);
	}
	
	printf("\n");
	
	return 0;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long X;cin>>X;
  if(X%11==0){
    cout<<X/11*2<<endl;
  }
  else if(X%11>6){
    cout<<X/11*2+2<<endl;
  }
  else{
    cout<<X/11*2+1<<endl;
  }
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    string n; cin >> n;
    ll sum = 0;
    each(i, n)sum += i - '0';
    print(sum % 9 == 0 ? "Yes" : "No");

    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 1000000009
string s;
int main(){
	ios::sync_with_stdio(false);
	cin>>s;
	if (s.size()==2) cout<<s;
	else{
		swap(s[0],s[2]);cout<<s;
	}
	return 0;
}

Measured memory_bytes: 256
from math import sqrt
n,d=input().split()
n=int(n)
d=int(d)
ans=0
for i in range(n):
    x,y=input().split()
    x=int(x)
    y=int(y)
    if(sqrt(x*x+y*y)<=d):ans+=1
print(ans)
        


Measured memory_bytes: 9080
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N;
	static int[] P;
	static ArrayList<ArrayList<Integer>> g = new ArrayList<>();

	public static void main(String[] arg) {
		N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			g.add(new ArrayList<>());
		}
		for (int i = 0; i < N - 1; ++i) {
			int U = Integer.parseInt(sc.next()) - 1;
			int V = Integer.parseInt(sc.next()) - 1;
			g.get(U).add(V);
			g.get(V).add(U);
		}
		P = new int[N];
		P[0] = -1;
		int[] order = new int[N];
		int pos = 1;
		for (int i = 0; i < N; ++i) {
			for (int c : g.get(order[i])) {
				if (c == P[order[i]]) continue;
				P[c] = order[i];
				order[pos++] = c;
			}
		}
		int[] dp = new int[N];
		int[] dp2 = new int[N];
		for (int i = N - 1; i >= 0; --i) {
			int node = order[i];
			for (int c : g.get(node)) {
				if (c == P[node]) continue;
				if (dp[c] + 1 > dp[node]) {
					dp2[node] = dp[node];
					dp[node] = dp[c] + 1;
				} else if (dp[c] + 1 > dp2[node]) {
					dp2[node] = dp[c] + 1;
				}
			}
		}
		for (int i = 1; i < N; ++i) {
			int p = P[order[i]];
			int pv = (dp[p] == dp[order[i]] + 1 ? dp2[p] : dp[p]) + 1;
			if (pv > dp[order[i]]) {
				dp2[order[i]] = dp[order[i]];
				dp[order[i]] = pv;
			} else if (pv > dp2[order[i]]) {
				dp2[order[i]] = pv;
			}
		}
		int[] ans = new int[N];
		for (int i = 0; i < N; ++i) {
			ans[order[i]] = (N - 1) * 2 - dp[order[i]];
		}
		for (int i = 0; i < N; ++i) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 92268
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-10;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a[3][3];
    rep(i,0,3)rep(j,0,3)cin>>a[i][j];
    bool used[3][3];
    memset(used,false,sizeof used);
    int n;cin>>n;
    rep(i,0,n){
        int b;cin>>b;
        rep(j,0,3){
            rep(k,0,3){
                if(a[j][k]==b)used[j][k]=true;
            }
        }
    }
    rep(i,0,3){
        int cnt=0;
        rep(j,0,3)cnt+=used[i][j];
        if(cnt==3){
            cout<<"Yes"<<endl;
            return 0;
        }
        cnt=0;
        rep(j,0,3)cnt+=used[j][i];
        if(cnt==3){
            cout<<"Yes"<<endl;
            return 0;
        }
        
    }
    int cnt=0;
    rep(i,0,3){
        cnt+=used[i][i];
    }
    if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
    }
    cnt=0;
    rep(i,0,3){
        cnt+=used[2-i][i];
    }
    if(cnt==3){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}







Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    def ans(self):
        print(len(set(self.par))-1)

n,m=map(int,input().split())
uf=UnionFind(n)

for i in range(m):
    a,b,c=map(int,input().split())
    uf.union(a,b)

for i in range(1,n+1):
    uf.find(i)
uf.ans()


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

int main(){
    int N;
    cin >> N;
    int a[N], count=1;
    for(int i=0; i<N; i++) cin >> a[i];
    sort(a, a+N);
    for(int i=0; i<N-1; i++){
        if(a[i]!=a[i+1]) count++;
    }
    cout << count << endl;
    return 0;
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;



int main(void) {
	int a, b, c;
	int p, q, r;
	int maxi;
	int count, point;

	cin >> a >> b >> c;

	maxi = max(a, max(b, c));
	p = maxi - a;
	q = maxi - b;
	r = maxi - c;

	if ((p + q + r) % 2 == 0) {
		cout << (p + q + r) / 2 << endl;
	}
	else {
		cout << (p + q + r + 3) / 2 << endl;
	}



	return 0;
}



Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		HashMap<String,Integer> map=new HashMap<String,Integer>();
		int z=0;
		long ans=0;
		while(z<N){
			String a=stdIn.next();
			String b="";
			int d[]=new int[26];
			for(int i=0;i<10;i++){
				char c=a.charAt(i);
				d[c-'a']++;
			}
			for(int i=0;i<26;i++){
				b+=String.valueOf(d[i]);
			}
			for(int i=0;i<10;i++){
				d[i]=0;
			}
			if(map.containsKey(b)){
				ans+=map.get(b);
				map.put(b,map.get(b)+1);
			}
			else
				map.put(b,1);
			z++;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 168416
<?php
list($L, $R, $d) = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

$ans = 0;
for ($i = $L; $i <= $R; $i++) {
    if ($i % $d === 0) {
        $ans += 1;
    }
}

echo $ans;

Measured memory_bytes: 16124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<string> words;
    set<string> se;
    rep(i,n){
        string s; cin >> s;
        se.insert(s);
        words.push_back(s);
    }
    if(se.size() != n){
        cout << "No" << endl;
        return 0;
    }
    char c = words[0].back();
    bool isOK = true;
    for(int i = 1; i < n; ++i){
        if(c != words[i][0]) {
            isOK = false;
            break;
        }
        c = words[i].back();
    }
    if(isOK) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<iomanip>
using namespace std;

int main(void)
{
    long long W, H, x, y;
    cin >> W >> H >> x >> y;

    double s = H * W / 2.0;
    printf("%.30f ", s);

    long long xx = W - x;
    long long yy = H - y;
    if (xx == x && yy == y)
        puts("1");
    else
        puts("0");
    //if (xx == x && yy == y) {
    //    double s = W * H / 2.0;
    //    cout << fixed << setprecision(30) << s << " " << 1 << endl;
    //}
    //else if (xx == x) {
    //    double s = x * H;
    //    cout << fixed << setprecision(30) << s << " " << 0 << endl;
    //}
    //else if (yy = y) {
    //    double s = W * y;
    //    cout << fixed << setprecision(30) << s << " " << 0 << endl;
    //}
    //else {
    //    double s = W * H / 2.0;
    //    cout << fixed << setprecision(30) << s << " " << 0 << endl;
    //}

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s;
    cin>>t;
    if(s[0]==t[2] && s[1]==t[1] && s[2]==t[0])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
dp = [None for _ in range(50)]

def fib(n):
    if n == 0 or n == 1:
        dp[n] = 1
        return dp[n]
    if dp[n] != None:
        return dp[n]
    dp[n] = fib(n-1) + fib(n-2)
    return dp[n]

n = int(input())
print(fib(n))


Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll h,w,d;
    cin>>h>>w>>d;
    vector<pair<ll,ll>>a(h*w+1);
    rep(0,i,h){
        rep(0,j,w){
            ll a0;
            cin>>a0;
            a[a0]={i,j};
        }
    }
    ll d0[h*w+1];
    rep(0,i,d)d0[i]=0;
    rep(d,i,h*w+1){
        d0[i]=d0[i-d]+abs(a[i].first-a[i-d].first)+abs(a[i].second-a[i-d].second);
    }
    ll q;
    cin>>q;
    rep(0,i,q){
        ll l,r;
        cin>>l>>r;
        cout<<d0[r]-d0[l]<<endl;
    }
}


Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
struct dice {
	vector<P> x;
	dice() : x(3) {}
	dice(int x_[6]) : x(3) {
		x[0] = P(x_[0], x_[5]);
		x[1] = P(x_[1], x_[4]);
		x[2] = P(x_[2], x_[3]);
	}
	dice(const dice& d) : x(d.x) {}
	dice& operator=(dice d) {
		x = d.x;
		return *this;
	}
	int X(int n) {
		return n < 3 ? x[n].first : x[5 - n].second;
	}
	void N() {
		swap(x[0], x[1]);
		swap(x[1].first, x[1].second);
	}
	void E() {
		swap(x[0], x[2]);
		swap(x[0].first, x[0].second);
	}
	void W() {
		swap(x[0], x[2]);
		swap(x[2].first, x[2].second);
	}
	void S() {
		swap(x[0], x[1]);
		swap(x[0].first, x[0].second);
	}
	void C() {
		swap(x[1], x[2]);
		swap(x[2].first, x[2].second);
	}
	void RC() {
		swap(x[1], x[2]);
		swap(x[1].first, x[1].second);
	}
	void top(int val) {
		if (x[0].first == val) {
			return;
		}
		if (x[1].first == val) {
			N();
		}
		else if (x[2].first == val) {
			W();
		}
		else if (x[2].second == val) {
			E();
		}
		else if (x[1].second == val) {
			S();
		}
		else {
			N(); N();
		}
	}
	void front(int val) {
		if (x[1].first == val) {
			return;
		}
		if (x[2].first == val) {
			C();
		}
		else if (x[2].second == val) {
			RC();
		}
		else {
			swap(x[1].first, x[1].second);
			swap(x[2].first, x[2].second);
		}
	}
	set<dice> all() {
		set<dice> res;
		dice d(*this);
		dice tmp(d);
		for (int i = 0; i < 4; i++) {
			tmp = d;
			for (int j = 0; j < 4; j++) {
				res.insert(tmp);
				tmp.C();
			}
			d.N();
		}
		d.W();
		tmp = d;
		for (int i = 0; i < 4; i++) {
			res.insert(tmp);
			tmp.C();
		}
		d.E(); d.E();
		tmp = d;
		for (int i = 0; i < 4; i++) {
			res.insert(tmp);
			tmp.C();
		}
		return res;
	}
};

bool operator==(const dice& l, const dice& r) {
	return l.x == r.x;
}

bool operator<(const dice& l, const dice& r) {
	return l.x < r.x;
}

int main()
{
	int n;
	cin >> n;
	vector<dice> dices(n);
	for (int i = 0; i < n; i++) {
		int x[6];
		for (int j = 0; j < 6; j++) {
			cin >> x[j];
		}
		dices[i] = dice(x);
	}
	bool res = true;
	for (int i = 0; i < n; i++) {
		auto a = dices[i].all();
		for (int j = i + 1; j < n; j++) {
			if (a.count(dices[j])) {
				res = false;
				break;
			}
		}
		if (!res) {
			break;
		}
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3100
n, k = gets.split.map(&:to_i)
count = 0
(k..(n + 1)).each do |i|
  min = (i - 1) * i / 2

  max = (n * (n + 1) / 2) - (n - i) * ((n - i) + 1) / 2
  count += max - min + 1
end

puts count % 1000000007


Measured memory_bytes: 14376
N, A, B = map(int, input().split())
ans = 0

for i in range(1, N + 1):
    I = str(i)
    sum_i = 0
    for j in range(len(I)):
        sum_i += int(I[j])

    if A <= sum_i <= B:
        ans += i

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#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 FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    ll k, x;
    cin >> k >> x;

    if (500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#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>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

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

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

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

  int n;

  cin >> n;

  printf("%.8f", ((n+1)/2)/(double)n);
}


Measured memory_bytes: 888
//https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_b
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll N; cin>>N;
    vector<ll> an;
    for(ll i=1;i<=N;++i){
        ll a; cin>>a;
        an.push_back(a);
    }

    ll s=0;
    vector<ll> sumt;
    REP(i,an.size()){
        s+=an.at(i);
        sumt.push_back(s);
    }

    ll ans=INT64_MAX;
    FOR(i,0,an.size()){
        ll l = sumt.at(i);
        ll r = s - sumt.at(i);
        ans = min(abs(l-r),ans);
    }

    cout<<ans<<endl;

    return 0;
}

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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

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

int main() {
	int x, y; cin >> x >> y;

	if (gcd(x, y) == y) {
		puts("-1");	
	} else {
		cout << x << endl;
	}
}

Measured memory_bytes: 3592
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	int h,m,s;
	while(1){
		int sr=0,ssr,ssr3,ur[3]={};
		cin>>h>>m>>s;
		if(h==-1&&m==-1&&s==-1) break;
		sr=h*3600+m*60+s;
		ssr=120*60-sr;
		ssr3=ssr*3;
		ur[0]=ssr/3600;
		ur[1]=(ssr%3600)/60;
		ur[2]=(ssr%3600)%60;
		fu(0,3){
			if(ur[i]<10&&i!=2) cout<<"0"<<ur[i]<<":";
			else if(ur[i]>=10&&i!=2) cout<<ur[i]<<":";
			else if(ur[i]<10) cout<<"0"<<ur[i]<<endl;
			else cout<<ur[i]<<endl;
		}
			ur[0]=ssr3/3600;
			ur[1]=(ssr3%3600)/60;
			ur[2]=(ssr3%3600)%60;
			fu(0,3){
				if(ur[i]<10&&i!=2) cout<<"0"<<ur[i]<<":";
				else if(ur[i]>=10&&i!=2) cout<<ur[i]<<":";
				else if(ur[i]<10) cout<<"0"<<ur[i]<<endl;
				else cout<<ur[i]<<endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define N 20
#define N2 65634
using namespace std;

int V, E;
int i, u, v, w;
int G[N][N];
int f[N2][N];
int in[N2], out[N][N2], ans;

void up(int &x, const int y) {x < y ? x = y : 0;}

int main(){
    scanf("%d%d", &V, &E);
    for(i = 0; i < E; ++i){
        scanf("%d%d%d", &u, &v, &w); --u; --v;
        G[u][v] = G[v][u] = w; ans += w;
    }
    for(i = 0; i < 1 << V; ++i)
        for(u = 0; u < V; ++u) if(i >> u & 1)
            for(v = u + 1; v < V; ++v) if(i >> v & 1)
                in[i] += G[u][v];
    for(i = 0; i < 1 << V; ++i)
        for(u = 0; u < V; ++u) if(!(i >> u & 1))
            for(v = 0; v < V; ++v) if(i >> v & 1)
                out[u][i] += G[u][v];
    memset(f, 128, sizeof f);
    f[1][0] = 0;
    for(i = 1; i < 1 << V; ++i)
        for(u = 0; u < V; ++u) if((i >> u & 1) && f[i][u] >= 0){
            for(v = 0; v < V; ++v) if(!(i >> v & 1) && G[u][v])
                up(f[i | 1 << v][v], f[i][u] + G[u][v]);
            v = ~(-1 << V | i);
            for(; v; v = v - 1 & ~i)
                up(f[i | v][u], f[i][u] + out[u][v] + in[v]);
        }
    printf("%d\n", ans -= f[(1 << V) - 1][V - 1]);
    return 0;
}

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

int main() {
  int L, R;
  int L_all, R_all;
  
  int N, M;
  cin >> N >> M;
  
  for (int i = 0; i < M; i++){
    cin >> L >> R;
    if (i == 0){
      L_all = L;
      R_all = R;
    }else{
      if(L_all < L){
        L_all = L;
      }
      if(R < R_all){
        R_all = R;
      }
    }
  }
  
  cout << max (0, R_all - L_all +1) << endl;
}

Measured memory_bytes: 256
<?php

list($n, $m) = explode(" ", trim(fgets(STDIN)));

for($i = 0; $i < $m; $i++){
    $map[$i] = 0;
}
for($i = 0; $i < $n; $i++){
    $array = explode(" ", trim(fgets(STDIN)));
    array_shift($array);
    foreach($array as $fid){
        @$map[$fid]++;
    }
}

$count = 0;
foreach($map as $val){
    $count += $val == $n;
}
echo $count;

Measured memory_bytes: 5112
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[23],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>a[i];
	for(int i=0;i<n;i++)
	{
		bool ok=1;
		for(int j=0;j<i;j++)
		{
			if(a[j]>a[i])
			ok=0;
		}
		if(ok)
		ans++;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef int LL;

LL gcd(LL a, LL b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

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

int main() {
	LL a, b;
	while (~scanf("%Id%Id", &a, &b)) {
		printf("%Id %Id\n", gcd(a, b), lcm(a, b));
	}

	return 0;
}

Measured memory_bytes: 1064
#include<iostream>
#include<queue>
#include<map>
#include<cassert>

using namespace std;

typedef long long ll;

int N;
ll A[100000 + 10];

const ll MOD = 1000000007;

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

	ll ans = 1;
	int cnt[3] = {};
	for (int i = 0; i < N; i++) {
		bool mode = false;
		ll times = 0;
		for (int j = 0; j < 3; j++) {
			if (!mode && A[i] == cnt[j]) {
				mode = true, cnt[j]++, times++;
			}
			else if (mode && A[i] == cnt[j]) {
				times++;
			}
		}
		(ans *= times) %= MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<set>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    multiset<int> s;
    int q;
    cin>>q;
    while(q--)
    {
        int c,t;
        cin>>c>>t;
        if(c==0) 
        {
            s.insert(t);
            cout<<s.size()<<endl;
        }
        else if(c==1) 
        {
            cout<<s.count(t)<<endl;
        }
        else if(c==2)
        {
            s.erase(t);
        }
        else
        {
            int R;
            cin>>R;
            auto its=s.lower_bound(t);
            auto ite=s.upper_bound(R);
            for(auto it=its;it!=ite;it++)
            {
                cout<<*it<<endl;
            }
        }
    }
}




Measured memory_bytes: 12260