akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct unionFind{
    vector<int> par;
    int siz;

    void init(int N){
        par.resize(N);
        fill(par.begin(), par.end(), -1);
        siz = N;
        return;
    }

    int root(int X){
        if(par[X] < 0){
            return X;
        }
        return par[X] = root(par[X]);
    }

    bool unite(int X, int Y){
        X = root(X);
        Y = root(Y);

        if(X == Y){
            return false;
        }

        if(par[X] < par[Y]){
            swap(X, Y);
        }

        par[Y] += par[X];
        par[X] = Y;
        --siz;

        return true;
    }

    bool same(int X, int Y){
        return root(X) == root(Y);
    }

    int size(int X){
        return -par[root(X)];
    }
};

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

    int n, m;
    cin >> n >> m;

    vector<int> a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        --a[i];
        --b[i];
    }

    vector<lint> ans(m);
    lint now = n * (n - 1LL) / 2LL;
    unionFind uf;
    uf.init(n);
    repr(i, m){
        ans[i] = now;
        lint sa = uf.size(a[i]);
        lint sb = uf.size(b[i]);
        if(uf.unite(a[i], b[i])){
            now -= sa * sb;
        }
    }

    rep(i, m){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 2e5+5;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/

void solve()
{
  string s,t;
  cin>>s>>t;
  ll a,b;
  cin>>a>>b;
  string u;
  cin>>u;
  if(s==u)
    cout<<a-1<<" "<<b;
  else
    cout<<a<<" "<<b-1;  
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

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

using namespace std;

const int N = 1e5+7;

char s[N];

int main(){
    int n,k;
    scanf("%d%d",&n,&k);
    scanf("%s",s+1);

    s[0]='$';s[n+1]='$';
    vector<int>v;
    if(s[1]=='1');
    else v.push_back(0);
    for(int i=1,l=1,sum=0;i<=n+1;i++){
        if(i>1 && s[i]!=s[i-1]){
            v.push_back(sum);
            sum=0;
        }
        sum++;
    }
    if(s[n]=='0') v.push_back(0);
    //for(auto x: v)printf("%d ",x);puts("");
    int ans = 0;
    for(int i=0;i<v.size();++i){
        if(i>0)v[i]+=v[i-1];
        if(i%2==0){
            if(i<=2*k) ans=max(ans,v[i]);
            else ans=max(ans,v[i]-v[i-2*k-1]);
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1020
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
#define Mohamed_Gad fast()
#define ll long long
#define ull unsigned long long
#define all(v) v.begin(),v.end()
#define endl "\n"
#define sz(x) size(x)
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void Open()
{
#ifndef ONLINE_JUDGE
    freopen("Input.txt", "r", stdin);
    //freopen("Output.txt", "w", stdout);
#endif

}
//long long frq[100009],prf[100009];

int main() {
    fast();
    string x,y="";
    cin>>x;
    for(int i=0;i<x.size();i++){
        if(x[i]=='B'&&y.size()>0)y.pop_back();
        else if(x[i]!='B')y+=x[i];
    }
    cout<<y<<endl;


}


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

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i = 0; i < 5; i++) {
		int n;
		cin >> n;
		if (!n) {
			cout << i + 1 << '\n';
			break;
		}
	}
}



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

#define ll long long 

using namespace std;
vector<int> lang;

int find(int a) {
	if(a == lang[a]) {
		return a;
	}
	int ans = find(lang[a]);
	lang[a] = ans;
	return ans;
}

bool union_(int a, int b) {
	int pa = find(a);
	int pb = find(b);

	if(pa == pb) {
		return true;
	} 

	lang[pa] = pb;
	return false;
}

int main() {
	

	int n,m;
	vector<bool> person_l;

	cin >> n >> m;

	for (int i = 0;i < m; i++) {
		lang.push_back(i);
		person_l.push_back(false);
	}


	for (int i = 0;i < n; i++) {
		int k;
		cin >> k;
		int l_fst;
		cin >> l_fst;
		l_fst --;
		person_l[l_fst] = true;

		for (int j = 1; j < k; j++) {
			int l;
			cin >> l;
			l--;
			person_l[l] = true;

			union_(l_fst,l);
		}
	}
	int l_fst = -1;
	for (int i = 0; i < m; i++) {

		if (person_l[i] == false) {
			continue;
		}

		//cout << i << " find:" << find(i) << endl; 

		if (l_fst == -1) {
			l_fst = find(i);
			continue;
		}

		if (l_fst == find(i)) {
			continue;
		}
		cout << "NO" << endl;
		return 0;
	}

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

Measured memory_bytes: 1404
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main(){
    int n,x;
    while(cin >> n >> x && !(n==0 && x==0)){
        int cnt=0;
        F(i,1,n+1){
            F(j,i+1,n+1){
                F(k,j+1,n+1){
                    int sum=i+j+k;
                    if(sum==x) ++cnt;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
var
 n,i,j,l,r,ans:longint;
 a:array[0..100005] of boolean;
 b:array[0..100005] of longint;
begin
 readln(n);
 a[1]:=true;
 for i:=2 to trunc(sqrt(100000)) do
  if not a[i] then
   for j:=2 to 100000 div i do
    a[i*j]:=true;
 b[1]:=0;
 b[2]:=0;
 for i:=1 to 100000 do
  if odd(i) and not a[i] and not a[(i+1) div 2] then b[i]:=b[i-1]+1 else b[i]:=b[i-1];
 for i:=1 to n do
  begin
   readln(l,r);
   writeln(b[r]-b[l-1]);
  end;
end.

Measured memory_bytes: 1024
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    let w = std::io::BufWriter::new(out.lock());
    f(w);
}

fn main() {
    let k: i64 = input();
    let n: i64 = input();
    const MOD: i64 = 998244353;

    let comb = Combination::new(n + k, MOD);
    let mut p2 = vec![0; k as usize + 1];
    p2[0] = 1;
    for i in 0..k as usize {
        p2[i + 1] = 2 * p2[i] % MOD;
    }

    let mut ans = vec![0; 2 * k as usize + 1];
    for i in 2..2 * k + 1 {
        let mut p = 0;
        for j in 1..k {
            if 0 < i - j && i - j <= k && j < i - j {
                p += 1;
            }
        }
        let mut r = k - 2 * p;
        if i % 2 == 0 {
            r = k - 2 * p - 1;
        }

        let mut temp = 0;
        for q in 0..p + 1 {
            if i % 2 == 0 {
                temp += p2[q as usize] * comb.combination(p, q) % MOD
                    * comb.combination(n - q + q + r - 1, n - q)
                    % MOD;
                temp += p2[q as usize] * comb.combination(p, q) % MOD
                    * comb.combination(n - 1 - q + q + r - 1, n - 1 - q)
                    % MOD;
            } else {
                temp += p2[q as usize] * comb.combination(p, q) % MOD
                    * comb.combination(n - q + q + r - 1, n - q)
                    % MOD;
            }
            temp %= MOD;
        }
        ans[i as usize] = temp;
    }

    with_stdout_lock(|mut w| {
        for i in 2..2 * k as usize + 1 {
            writeln!(w, "{}", ans[i]).unwrap();
        }
    });
}

struct Combination {
    fact: Vec<i64>,
    ifact: Vec<i64>,
    modulus: i64,
}
impl Combination {
    fn new(n: i64, m: i64) -> Combination {
        let n = n as usize;
        let mut fact = vec![0; n + 1];
        let mut ifact = vec![0; n + 1];
        fact[0] = 1;
        for i in 1..n + 1 {
            fact[i] = fact[i - 1] * i as i64 % m;
        }
        ifact[n] = Combination::pow(fact[n], m - 2, m);
        for i in (1..n + 1).rev() {
            ifact[i - 1] = ifact[i] * i as i64 % m;
        }
        Combination {
            fact: fact,
            ifact: ifact,
            modulus: m,
        }
    }
    fn pow(x: i64, p: i64, m: i64) -> i64 {
        if p == 0 {
            1
        } else if p % 2 == 0 {
            let t = Combination::pow(x, p / 2, m);
            t * t % m
        } else {
            let t = Combination::pow(x, p / 2, m);
            t * t % m * x % m
        }
    }
    fn combination(&self, n: i64, k: i64) -> i64 {
        if n < 0 || k < 0 || n < k {
            0
        } else {
            let (n, k) = (n as usize, k as usize);
            self.fact[n] * self.ifact[k] % self.modulus * self.ifact[n - k] % self.modulus
        }
    }
}


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

int main() {
  int a,b,n,ans = 0;
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    int tmp = i;
    int sum = 0;
    while (tmp > 0) {
      sum += tmp % 10;
      tmp /= 10;
    }
    if (sum >= a && sum <= b) ans+=i;
  }
  cout << ans << endl;
}

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

int main() {

	for(int i = 0; i < 3; i++){
		int hour,min,sec;
		cin >> hour >> min >> sec;
		int byoin = hour * 60 * 60 + min*60 + sec;
		cin >> hour >> min >> sec;
		int byoout = hour * 60*60 + min*60 + sec;
		int zaisya = byoout - byoin;
		cout << zaisya / (60*60) << " " << zaisya % (60*60) / 60 << " " << zaisya % 60 << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define Mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define gcd(m,n)        __gcd(m,n)
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz               size()
#define inc(i,x,y)      for(int i=x;i<=y;i++)
#define dec(i,x,y)      for(int i=x;i>=y;i--)



#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define deb(...)
#endif

void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}

//////////////////////////////code//////////////////////////////

vi adj[1000];
int n,m,q;
int ans;
vector<pair<pii,pii > >a;
void cal(vi &v)
{  int curr=0;
   //show(v,0,n-1);
    inc(i,0,q-1)
    {
        if(v[a[i].ff.ss-1]-v[a[i].ff.ff-1]==a[i].ss.ff)
            curr+=a[i].ss.ss;
    }
   ans=max(ans,curr);
   //deb(curr);
}
void seq(int st,vi &s)
{
  if(s.size()==n)
  {
    cal(s);return;
  }

    inc(i,st,m)
    {  s.pb(i);
      seq(i,s);
      s.pop_back();
    }
}

int32_t main()
{

  cin>>n>>m>>q;
  ans = 0;
  inc(i,0,q-1)
  {
      int k,b,c,d;
      cin>>k>>b>>c>>d;
      a.pb({{k,b},{c,d}});
  }
  vi s;
  seq(1,s);

  cout<<ans<< "\n";

}


Measured memory_bytes: 3644
#include<stdio.h>
int main()
{
    char s[4];
    int a,b,c,d;
    scanf("%s",s);

    a=s[0]-48;
    b=s[1]-48;
    c=s[2]-48;
    d=s[3]-48;

    if((a*10+b)<=12 && (c*10+d)<=12 && (a*10+b)*(c*10+d)>0)
    {
        printf("AMBIGUOUS");
    }
    else if((a*10+b)<=12 && (a*10+b)>0)
    {
        printf("MMYY");
    }
    else if((c*10+d)<=12 && (c*10+d)>0)
    {
        printf("YYMM");
    }
    else
        printf("NA");




}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    // 整数の入力
    int N, L;
    cin >> N >> L;
  
    int origin = 0;
    int min = abs(L);
    int min_N = 0;
    for (int i=0; i<N; i++) {
        if (min > (abs(L + i))) {
          min = abs(L + i);
          min_N = i;
        }
      	origin += L + i;
    }
    int dummy = origin - (L+min_N);
    //cout << origin << " " << L << " " << min << endl;
	cout << dummy << endl;
  
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
//void spf(ll num)
//{
//    fore(i,0,num+1)arr[i]=i;
//    for(ll i=2;i<=num;i+=2)
//    {
//        arr[i]=2;
//    }
//    for(ll i=3;i<=num;i+=2)
//    {
//        if(arr[i]==i)
//        for(ll j=i;j<=num;j+=i)
//        {
//           if(arr[j]==j) arr[j]=i;
//        }
//    }
//}
 
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    ll n;cin>>n;
    ll count=0;ll a=1;
    for(ll i=0;i<n;i++)
    {
        ll x;cin>>x;
        if(x==a)
        {
            a++;
        }
        else count++;
    }
    if(count>=n)cout<<"-1"<<endl;
    else cout<<count<<endl;
    return 0;
    }


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

string s="RYGB";

signed main(){
    int H,W,d;
    cin>>H>>W>>d;

    rep(i,H){
        rep(j,W){
            int y=i+j;
            int x=i-j;

            int c=(y+114514*d)%(2*d)/d*2+(x+114514*d)%(2*d)/d;
            cout<<s[c];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    char a;
    cin >> a;
    cout << ('a' <= a && 'z' >= a ? 'a' : 'A') << '\n';
    return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<signed(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans=0;
	ll N,K,A[500010];


int main(){
	ios_base::sync_with_stdio(false);
	cin>>N;
	REP(i,N){cin>>A[i];A[i]-=i+1;}
	sort(A,A+N);
	ll B=0;
	if(N%2==0){
			ll x=0,y=0;
			REP(i,N){
				x+=abs(A[i]-A[(N-1)/2-1]);
				y+=abs(A[i]-A[(N-1)/2]);
			}
			if(x<y)B=A[(N-1)/2-1];
			else B=A[(N-1)/2];
	}else{
		B=A[(N-1)/2];
	}
	//if(B<0)B=0;
	REP(i,N)ans+=abs(A[i]-B);
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	while((s = readln.chomp).length != 0)
	{
		double d = s.to!double;
		if(91.00 < d) "heavy".writeln;
		if(81.00 < d && d <= 91.00) "light heavy".writeln;
		if(75.00 < d && d <= 81.00) "middle".writeln;
		if(69.00 < d && d <= 75.00) "light middle".writeln;
		if(64.00 < d && d <= 69.00) "welter".writeln;
		if(60.00 < d && d <= 64.00) "light welter".writeln;
		if(57.00 < d && d <= 60.00) "light".writeln;
		if(54.00 < d && d <= 57.00) "feather".writeln;
		if(51.00 < d && d <= 54.00) "bantam".writeln;
		if(48.00 < d && d <= 51.00) "fly".writeln;
		if(d <= 48.00) "light fly".writeln;
	}
	return 0;
}

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

int main() {
	int L, R, d, answer;
	cin >> L;
	cin >> R;
	cin >> d;
	answer = 0;
		for (cin >> L; L <= R; L++) {
		if (L % d == 0){
		answer++;
}
}
cout << answer <<endl;
}


Measured memory_bytes: 3628
import math

n = int(input())
l_list = list(map(int, input().split()))

# l_list = set(l_list)

# def combinations_count(n, r):
#     return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

# print(combinations_count(len(l_list), 3))

l_list = sorted(l_list)

# print(l_list)

ans = 0

for a in range(len(l_list)):
    
    for b in range(a + 1, len(l_list)):

        for c in range(b + 1,len(l_list)):

           if l_list[a] != l_list[b] and l_list[b] != l_list[c] and l_list[c] != l_list[a] and abs(l_list[b] - l_list[c]) < l_list[a] < l_list[b] + l_list[c] :
               ans += 1

print(ans)


Measured memory_bytes: 9096
line = input().split()
w = int(line[0])
h = int(line[1])
x = int(line[2])
y = int(line[3])

s = w * h /2

if w/2 == x and h/2 == y:
    another = 1
else:
    another = 0
    
print(str(s) + ' ' + str(another))

Measured memory_bytes: 3064
#include <cstdlib>
#include <iostream>
using namespace std;

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

	int l, a, b, c, d;
	cin >> l >> a >> b >> c >> d;
	cout << l - max((a + c - 1) / c, (b + d - 1) / d) << endl;

	return EXIT_SUCCESS;
}

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


// dp[k] : if there are k stones remaining then any person making any move wins that is dp[k - ni] is False.
// Then the person making a move on that stone wins.
int main() {
	// your code goes here
	int N=0,K=0;
	cin>>N>>K;
	vector<int> vals;
	for(int i=0;i<N;i++){
		int val = 0;
		cin>>val;
		vals.push_back(val);
	}
	vector<bool> dp(K+1, false);
	for(int i=1;i<=K;i++){
		for(int j=0;j<N && vals[j] <= i;j++){
			if(!dp[i - vals[j]]){
				dp[i] = true;
				break;
			}
		}
	}
	if(dp[K])cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    set<int> se;
    rep(_, K) {
        int d;
        cin >> d;
        rep(__, d) {
            int A;
            cin >> A;
            se.insert(A);
        }
    }

    cout << N - se.size() << endl;
}


Measured memory_bytes: 3600
N = int(input())
max_4 = int(N/4)+1
max_7 = int(N/7)+1
Flag = 0
for i in range(max_4):
    for j in range(max_7):
        if N == i*4 + j*7:
            Flag = 1
            break
    if Flag == 1:
        break
if Flag == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int count=0,flag=1,t=b,i;
    do
    {
        t=t/10;
        count++;
    }while(t);
    for(i=0;i<count;i++)
        a=a*10;
    a=a+b;
    for(i=1;i*i<=a;i++)
    {
        if(i*(a/i)==a)
        {
            if(i==a/i)
            {
                printf("Yes\n");
                flag=0;
                break;
            }

        }
    }
    if(flag)
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		while (scan.hasNextLine()) {
			String s = scan.nextLine();
			String p = scan.nextLine();

			s = s.concat(s);

			if (s.contains(p))
				System.out.println("Yes");
			else
				System.out.println("No");
		}
		System.exit(0);
	}

}

Measured memory_bytes: 26348
// In The Name Of God
#include <bits/stdc++.h>

#define sqr(A) ((A) * (A))
#define X first
#define Y second
#define MP make_pair
#define bsz  __builtin_popcount
#define all(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
const int MOD2 = 1e9 + 9;
const int PR = 727;
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;

string s, t;
unordered_map<ll, char> p;
ll L, n, m;

ll lcm(ll x, ll y) {
	return (1LL * x * y) / __gcd(x, y);
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m >> s >> t;
	L = lcm(n, m);
	for (ll i = 0; i < n; i++)
		p[i * (L / n) + 1] = s[i];
	for (ll i = 0; i < m; i++)
		if (p.count(i * (L / m) + 1) != 0 && p[i * (L / m) + 1] != t[i])
			return cout << -1 << endl, 0;
	cout << L << endl;
}



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

int main(){
    int n;
    cin >> n;
    int low_lim[8] = {1, 400, 800, 1200, 1600, 2000, 2400, 2800};
    int high_lim[8] = {399, 799, 1199, 1599, 1999, 2399, 2799, 3199};
    int cnt = 0;
    set<int> st;
    rep(i, n) {
        int a;
        cin >> a;
        bool flg = true;
        rep(i, 8) {
            if ( a >= low_lim[i] && a <= high_lim[i] ) {
                st.insert(i);
                flg = false;
            }
        }
        if ( flg ) {
            ++cnt;
        }
    }
//    for ( auto tmp_num : st ) {
//        cout << tmp_num << endl;
//    }
    int min_num = ( st.empty() ) ? 1 : st.size();
    cout << min_num << " " << st.size() + cnt << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


bool hoge(ll a, ll b)
{
	while(a>=b)
	{
		if(a%b) a%=b; else a/=b;
	}
	return a==1;
}


vll xx(ll v)
{
	vll ret;
	for(ll i=2;i*i<=v;i++)
	{
		for(;v%i==0;)
		{
			ret.push_back(i);
			v/=i;
		}
	}
	if(v>1) ret.push_back(v);
	return ret;
}


vector<pair<ll,int>> yy(ll v)
{
	vector<pair<ll,int>> ret;

	for(ll i=2;i*i<=v;i++)
	{
		if(v%i==0)
		{
			int c=1;
			for(v/=i;v%i==0;v/=i,c++)
				;
			ret.push_back(make_pair(i, c));
		}
	}
	if(v>1) ret.push_back(make_pair(v, 1));
	return ret;
}


void elm_i(vector<ll>&result, vector<pair<ll,int>>&m, int a, ll b)
{
	if(a>=m.size())
	{
		result.push_back(b);
		return;
	}
	for(int i=0;i<=m[a].second;i++)
	{
		elm_i(result, m, a+1, b);
		b*=m[a].first;
	}
}


vector<ll> elm(ll v)
{
	auto p=yy(v);
	vector<ll> ret;

	elm_i(ret, p, 0, 1LL);

	return ret;
}


int main(void)
{
	ll n;

	while(scanf("%lld", &n)==1)
	{
		int ans=0;

		auto p=elm(n);
		auto q=elm(n-1);

		for(ll mp:p)
		{
			if(mp==1) continue;
			if(hoge(n, mp))
			{
				ans++;
			}
		}
		ans+=q.size()-1;

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


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

int main(){
    int n;
    string s;
    cin>>n>>s;
    vector<int>l(n),r(n);
    for(int i=1; i<n; ++i){
        if(s[i-1]=='W')l[i]=l[i-1]+1;
        else l[i]=l[i-1];
    }
    for(int i=n-1; i>0; --i){
        if(s[i]=='E')r[i-1]=r[i]+1;
        else r[i-1]=r[i];
    }
    int ans=1e9;
    rep(i,n){
        ans=min(ans,l[i]+r[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6164
#include <stdio.h>

int main(void){
  int ball[3]={1,0,0};
  char c1,c2;
  int ind1,ind2;
  int tmp;
  while(scanf("%c,%c\n",&c1,&c2)!=EOF){
    ind1=(int)(c1-'A');
    ind2=(int)(c2-'A');
    tmp=ball[ind1];
    ball[ind1]=ball[ind2];
    ball[ind2]=tmp;
  }


  for(int i=0;i<3;i++){
    if(ball[i]==1){
      printf("%c\n",i+'A');
    }
  }
  return 0;
}



Measured memory_bytes: 2048
#include<cstdio>

int main(void){
  
  int x,y,n,a,b;
  
  while(1){
    scanf("%d%d",&x,&y);
    if(x==0 && y==0) break;
    int dp[y][x];
    
    for(int i=0;i<y;i++)
      for(int j=0;j<x;j++)
	dp[i][j]=-1;
  
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      scanf("%d%d",&a,&b);
      dp[b-1][a-1]=0;
    }
    
    for(int i=0;dp[i][0]!=0 && i<y;i++)
      dp[i][0]=1;
    for(int i=0;i<y;i++)
      if(dp[i][0]==-1) dp[i][0]=0;
    for(int i=0;dp[0][i]!=0 && i<x;i++)
      dp[0][i]=1;
    for(int i=0;i<x;i++)
      if(dp[0][i]==-1) dp[0][i]=0;

 
    for(int i=1;i<y;i++)
      for(int j=1;j<x;j++)
	if(dp[i][j]==-1) dp[i][j]=dp[i-1][j]+dp[i][j-1];
  
    printf("%d\n",dp[y-1][x-1]);
  }
   return 0;
}

Measured memory_bytes: 1028
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int s,w;
    cin>>s>>w;

    if(w>=s)
        cout<<"un";
    cout<<"safe";
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 3608
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;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 llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


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

	vector<ll> cnt(n + 10, 0);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		cnt[a[i]]++;
	}

	ll sum = 0LL;

	for (int i = 1; i <= n; i++)
	{
		sum += cnt[i] * (cnt[i] - 1) / 2;
	}


	for (int i = 0; i < n; i++)
	{
		ll before = (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2;
		ll diff = cnt[a[i]] * (cnt[a[i]] - 1) / 2 - before;
		cout << sum - diff << endl;
	}


	return 0;
}



Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int main(){
	int t,n;
	int aka[5]={0};
	int i;
	for(i=0;i<4;i++){
		cin>>t>>n;
		if(t==1){
			aka[i]=6000*n;
		}
		else if(t==2){
			aka[i]=4000*n;
		}
		else if(t==3){
			aka[i]=3000*n;
		}
		else{
			aka[i]=2000*n;
		}
	}
	for(i=0;i<4;i++){
		cout<<aka[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3080
N = int(input())
h = list(map(int, input().split()))
tmp = 0
ans = 0
pre = h[0]
for i in range(1, N):
    if pre >= h[i]:
        tmp += 1
    else:
        ans = max(ans, tmp)
        tmp = 0
    pre = h[i]

ans = max(ans, tmp)
print(ans)


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

int n, K;
vector<int> a, memo;

bool solve(int res){
	if(memo[res] != -1) return memo[res];
	for(int i = 0; i < n; i++){
		if(res - a[i] >= 0){
			if(!solve(res - a[i])) return memo[res] = true;; 
		}
	}
	return memo[res] = false;
}


signed main(){
	scanf("%d %d", &n, &K);
	a.resize(n);
	memo.resize(K + 1, -1);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	if(solve(K)) cout << "First" << endl;
	else cout << "Second" << endl;
}

Measured memory_bytes: 8372
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>

using namespace std;

void solve()
{
	string line;
	cin >> line;

	vector<string> strs;
	for(unsigned int i = 1; i < line.length(); i++){
		string l = line.substr(0,i);
		string r = line.substr(i);
		string lr(l.rbegin(),l.rend());
		string rr(r.rbegin(),r.rend());

		strs.push_back(l+r);
		strs.push_back(l+rr);
		strs.push_back(lr+r);
		strs.push_back(lr+rr);
		strs.push_back(r+l);
		strs.push_back(r+lr);
		strs.push_back(rr+l);
		strs.push_back(rr+lr);
	}

	sort(strs.begin(),strs.end());
	vector<string>::iterator end_it = unique(strs.begin(),strs.end());
	int c = 0;
	for(vector<string>::iterator it = strs.begin(); it != end_it; ++it)
		c++;

	cout << c << endl;
}

int main()
{
	int m;
	cin >> m;
	for(int i = 0; i < m; i++){
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    import sys
    readline = sys.stdin.buffer.readline

    import math

    a, b, x = map(int, readline().split())

    c = a*a*b
    if x <= a*a*b/2:
        ans = math.atan2(a*b*b, 2*x)
    else:
        ans = math.atan2(2*(a*a*b-x), a**3)
    print(math.degrees(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9444
#include <iostream>
#include <cmath>

using namespace std;
int popcount(int num){
    if(num == 0) return 0;
    if(num % 2 == 1) return 1 + popcount(num/2);
    if(num % 2 == 0) return popcount(num/2);
}

int digit10(int num){
    if(num == 0) return 0;
    return 1 + digit10(num/10);
}

int main(){
    int n;
    cin>>n;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(digit10(i+1) % 2 == 1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  if(n%2 == 0) cout << 0.5 << endl;
  else {
    double m = n;
    cout << fixed << setprecision(10);
    cout << (m+1)/2/m << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int
main()
{
    int n;
    scanf("%d", &n);
 
    int i;
    int result;
    int a_score = 0;
    int b_score = 0;
    char a_card[100];
    char b_card[100];
    for (i = 0; i < n; i++)
    {
        scanf("%s %s", a_card, b_card);
        result = strcmp(a_card, b_card);
        if (result == 0)
        {
            a_score += 1;
            b_score += 1;
        }
        if (result > 0)
        {
            a_score += 3;
        }
        if (result < 0)
        {
            b_score += 3;
        }
    }
    printf("%d %d\n", a_score, b_score);
 
    return 0;
}
 

Measured memory_bytes: 604
import copy

from collections import deque
 
H, W = [int(x) for x in input().split()]

Ch,Cw = map(int,input().split())

Ch,Cw = Ch-1,Cw-1

Dh,Dw = map(int,input().split())

Dh,Dw = Dh-1,Dw-1

cell = [list(input()) for i in range(H)]

dp = [[-1]*W for _ in range(H)]

copy_stack = []
copy_stack.append([Ch,Cw])

nstack = []

dp[Ch][Cw] = 0

def search(stack):
    while len(stack) > 0:
        h,w = stack.pop()
        for dy, dx in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
            nh = h + dy
            nw = w + dx
            if 0 <= nh < H and 0 <= nw < W and (dp[nh][nw] == -1 or dp[nh][nw] > dp[h][w]):
                if cell[nh][nw] == '.':
                    dp[nh][nw] = dp[h][w]
                    stack.append([nh,nw])
                    copy_stack.append([nh,nw])
                   
while True:
    if len(copy_stack):
        nstack = copy.copy(copy_stack)
    else:
        copy_stack = copy.copy(nstack)
    search(nstack)
    #print(dp)
    if dp[Dh][Dw] == -1:
        while len(copy_stack)>0:
            h,w = copy_stack.pop()
            for ddy in range(-2,3):
                for ddx in range(-2,3):
                    if ddy==ddx==0:
                        continue
                    nnh = h + ddy
                    nnw = w + ddx
                    if 0 <= nnh < H and 0 <= nnw < W:
                        if cell[nnh][nnw] == '.' and dp[nnh][nnw] == -1:
                            dp[nnh][nnw] = dp[h][w] + 1
                            nstack.append([nnh,nnw])
        if len(nstack) == 0:
            break
    else:
        break
                        
if dp[Dh][Dw] != -1:
    print(dp[Dh][Dw])
else:
    print(-1)

Measured memory_bytes: 137480
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m; cin >> n >> m;
	vector<int> votes(n); fore(e, votes) cin >> e;
	int tot = accumulate(votes.begin(), votes.end(), 0);
	double amt = (double)tot/(4*m);
	int cnt = 0;
	fore(e, votes) {
		if(e >= amt) {
			cnt++;
		}
	}
	if(cnt >= m) println("Yes");
	else println("No");
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 17:27:39 2020

@author: shinba
"""

x = int(input())

if x%11 == 0:
    print(2*(x//11))
elif x%11 <=6:
    print(2*(x//11)+1)
else:
    print(2*(x//11)+2)


Measured memory_bytes: 2940
import math
def c(x):
    global yaku
    now=x
    for i in range(2,int(math.sqrt(now))+1):
        while now%i==0:
            if i in sosu.keys():
                v=sosu[i]
                sosu[i]=v+1
            else:
                sosu[i]=1
            now=now//i
            yaku+=1
    if(now!=1):
        sosu[now]=1
        yaku+=1
def d(x):
    global ans
    q=x
    cur=1
    while(q>0):
        q=q-cur
        if q>=0:
            ans+=1
        cur+=1
    
n=int(input())
sosu={}
yaku=0
c(n)
if n==1:
    print(0)
else:
    if(yaku==1):
        print(1)
    else:
        ans=0
        #print(sosu)
        for i in sosu.keys():
            d(sosu[i])
        print(ans)

Measured memory_bytes: 63244
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(ll i=a;i<b;i++)
#define bFor(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll lpow(ll a,ll b){
  ll res=1;
  rep(i,b){
    res*=a;
  }
  cout<<res;
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

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

ll modncr(ll n,ll r){
  ll plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll f=1;
  string ss;cin>>ss;
  rep(i,(ll)ss.size()){
    if(i%2==0&&ss[i]=='L')f=0;
    if(i%2==1&&ss[i]=='R')f=0;
  }
  if(f){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<string>> vvs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef pair<int,int> P;
#define vrep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する
#define rep(i, l, n) for (int i = l; i < (int)(n); i++)
#define repn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 

const int mod = 1000000007;
const int inf = 1e9;

int main(){
    int a,b;
    cin >> a >> b;
    int ans = -1;
    repn(i,0,1250){
        if(floor(i*0.08)==a && floor(i*0.1)==b) ans = i;
        if(ans != -1)break;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vi               vector<int>
#define pb(x)            push_back(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define sortrev(x)       sort(all(x), greater<int>())
#define debug(x)         cout << '>' << #x << ':' << x << endl;
#define int              long long
#define ld               long double
#define endl 			 "\n";
#define mp 				 make_pair
#define pii 			 <int, int>
#define lb 				 lower_bound
#define ub				 upper_bound
#define len(a)           int((a).size())
#define prec(n)          fixed<<setprecision(n)
#define cnt(n)           __builtin_popcountll(n)
#define pi               pair<int, int>
const int mod = 1000000007;
using namespace std;
const int N = 1e9; 
// int n;
// int a[N];



int32_t 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;
t = 1;
// cin >>t;
while(t--){
int n;
cin >>n;
// cout << pow(N,0.2);
for(int i = -200; i<=200; i++){
	for(int j = -200 ; j<=200; j++){
		// debug(i);
		if(pow(i,5) - pow(j,5) == n){
			// cout << "d";
			cout << i << " " <<j ;
			return 0;
		}
	}
}
// cout <<"D";




}
return 0;
}

Measured memory_bytes: 4012
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];

    ll ans = 0;
    rep(i, N - 1) rep(j, i + 1, N) {
        ans += d[i] * d[j];
    }

    write(ans);
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# from collections import defaultdict
def main():
    N = int( input())
    A = list( map( int, input().split()))
    Q = int( input())
    BC = [ tuple( map( int, input().split())) for _ in range(Q)]
    L = [0]*(10**5+1)
    ans = sum(A)
    for a in A:
        L[a] += 1
    ANS = []
    for b, c in BC:
        ans = ans + L[b]*c - L[b]*b
        L[c] += L[b]
        L[b] = 0
        ANS.append(ans)

    print("\n".join( map( str, ANS)))
if __name__ == '__main__':
    main()


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

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

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

  ll ans = 0;
  int mask = 0;
  for(int i = 30; i >= 0; i--){
    if(1<<i & k){
      ll tmp = 0;
      rep(j, n){
        if(!(a[j]&(mask|1<<i))) tmp += b[j];
      }
//      cout << i << " , " << tmp << endl;
      ans = max(ans, tmp);
    }else{
      mask |= 1<<i;
    }
  }

  ll tmp = 0;
  rep(i, n){
    if(!(a[i]&mask)) tmp += b[i];
  }
  ans = max(ans, tmp);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int


def solve(N: int, M: int, a: "List[int]"):
    a = set(a)
    dp = [0] * (N+2)
    dp[0] = 1
    for i in range(N):
        if i in a:
            dp[i] = 0
        dp[i+1] = (dp[i+1] + dp[i]) % MOD
        dp[i+2] = (dp[i+2] + dp[i]) % MOD
    return dp[N]


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(M)]  # type: "List[int]"
    print(solve(N, M, a))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 13208