akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

//     1,0,0       0,1,0             0,0,1       1,-1
//     0,1,1       1,0,1             1,1,0      -1, 1
//     2,1,1       1,2,1             1,1,2       1,-1
//     2,3,3       3,2,3             3,3,2      -1, 1
//     6,5,5       5,6,5             5,5,6       1,-1

int main(){
  ll A,B,C,K; cin>>A>>B>>C>>K;
  if(K%2==0){ cout << A-B <<"\n"; }
  else{ cout << B-A  <<"\n"; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

int main(){
	vector<pair<int, int>> pos;
	for(int i = 0; i < 3; i++)
		for(int j = 0; j < 3; j++)
			pos.pb({i, j});
	int n, m, k;
	vector<long long> jaw(10, 0);
	cin >> n >> m >> k;
	vector<int> x(k), y(k);
	set<pair<int, int>> ada;
	for(int i = 0; i < k; i++){
		cin >> x[i] >> y[i];
		ada.insert({x[i], y[i]});
	}
	for(int i = 0; i < k; i++){
		for(int j = 0; j < 9; j++){
			int hit = 0;
			bool ya = true;
			for(int xx = 0; xx < 3; xx++){
				for(int yy = 0; yy < 3; yy++){
					int X = x[i] - pos[j].f + xx;
					int Y = y[i] - pos[j].s + yy;
					if(X < 1 || X > n || Y < 1 || Y > m)
						ya = false;
					if(ada.count({X, Y}))
						hit += 1;
				}
			}
			if(!ya)
				continue;
			jaw[hit] += 1;
		}
	}
	long long tot = 0;
	for(int i = 1; i <= 9; i++){
		assert(jaw[i] % i == 0);
		jaw[i] /= i;
		tot += jaw[i];
	}
	jaw[0] = 1LL * (n - 2) * (m - 2) - tot;
	for(auto i : jaw)
		cout << i << endl;
	// cout << endl;
}

Measured memory_bytes: 7552
#include <stdio.h>
int main (void){
    char stri[256],strj[256];
    scanf("%s%s",stri,strj);
    if(stri[0]==strj[2] && stri[1]==strj[1] && stri[2]==strj[0]){
        printf("YES");
    }
    else{
        printf("NO");
    }

    return 0;
}

Measured memory_bytes: 128
//by The_One_Solver
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
long long n,m,f=1,c=1,h=1,odd=1;
int main()
{

    cin>>n>>m;

cout << (n > 1 ? (n * (n - 1)) / 2 : 0) + (m > 1 ? (m * (m - 1)) / 2 : 0) << endl;


}


Measured memory_bytes: 256
inf = 10**10
N, M = map(int, input().split())
A = []
B = []
C = []
for i in range(M):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
    c = list(map(int, input().split()))
    res = 0
    for j in c:
        res+=(1<<(j-1))
    C.append(res)
dp = [[inf]*(2**N) for _ in range(M+1)]
dp[0][0] = 0
for i in range(1, M+1):
    for s in range(2**N):
        print
        dp[i][s] = min(dp[i-1][s], dp[i-1][(s|C[i-1])^C[i-1]]+A[i-1])
ans = dp[M][(1<<N)-1]
print(ans if ans<10**10 else -1)
        


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

int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(u==s) cout<<a-1<<" "<<b<<endl;
  else cout<<a<<" "<<b-1<<endl;
}

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int H, W;
    cin >> H >> W;
    int h, w;
    cin >> h >> w;
    int ans = 0;

    ans = W * H - (H * w + W * h - w * h);

    // 処理
    cout << ans << endl;

    // 出力

    return 0;
}


Measured memory_bytes: 256
import bisect

l = [1 for i in range(31)]


for i in range(1, 31):
    l[i] = l[i - 1] * 2

N, K = map(int, input().split())
P = 0.0
for i in range(1, N + 1):
    times = bisect.bisect_left(l, K/i)
    P += (1/N) * ((1/2)**times)

print(P)


Measured memory_bytes: 3060
#define ll long long
#define pb push_back
#define make_pair mp
#define first f
#define second s
#define upper_bound ub
#define lower_bound lb
#define MOD 1000000007
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;


#define ordered_set tree<pair<ll,ll> , null_type,less<pair<ll,ll> >, rb_tree_tag,tree_order_statistics_node_update>ll fn


void solve(){
    ll n;cin>>n;
    ll a[n+1];
    vector<ll> primes;
    bool isprime[1006];
    memset(isprime,1,sizeof(isprime));
    //memset(freq,1,sizeof(freq));
    isprime[2]=1;
    for(ll i=2;i*i<=1000;i++){
        if(isprime[i]){
            for(ll j=2*i;j<=1000;j+=i){
                isprime[j]=0;
            }
        }
    }
    unordered_map<ll,ll> m;
    for(ll i=2;i<=1000;i++){
        if(isprime[i]){
            primes.pb(i);
            m[i]=0;
        }
    }
    
    ll gcd=0;
    bool f=1;
    for(ll i=1;i<=n;i++){
        cin>>a[i];
        if(gcd==0){
            gcd=a[i];
        }
        else{
            gcd = __gcd(gcd,a[i]);
        }
        for(ll j=0;j<primes.size()&&primes[j]<=a[i]&&f==1;j++){
            if(a[i]%primes[j]==0){
                m[primes[j]]++;
                if(m[primes[j]]>=2){
                    f=0;
                }
                while(a[i]%primes[j]==0){
                    a[i]/=primes[j];
                }
            }
        }
        if(a[i]>1){
            if(m.find(a[i])!=m.end()){
                m[a[i]]++;
                if(m[a[i]]>=2){
                    f=0;
                }
            }
            else{
                m[a[i]]=1;
            }
        }
    }
    if(f){
        cout<<"pairwise coprime";return;
    }
    if(gcd==1){
        cout<<"setwise coprime";return;
    }
    cout<<"not coprime";
    return;
}

int main ()
{
  ios_base::sync_with_stdio (false);
  cin.tie (NULL);
  ll t;
  //cin>>t;
  t = 1;
  while (t)
    {
      solve();t--;
      //cout<<"end of test case"<<endl;
    }
  return 0;
}


Measured memory_bytes: 50248
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N,M;
ll keyData[100010];
ll costs[100010];
ll dp[1<<13];
int main(){
    cin>>N>>M;
    for(ll i=0;i<M;i++){
        cin>>costs[i];
        ll b;
        cin>>b;
        for(ll j=0;j<b;j++){
            ll c;
            cin>>c;c--;
            keyData[i] += (1<<c);
        }
    }
    for(ll i=0;i<(1<<N);i++){
        dp[i]=INF;
    }
    dp[0]=0;
    
    for(ll i=0;i<(1<<N);i++){
        for(ll j=0;j<M;j++){
            ll nextState=i|keyData[j];
            dp[nextState]=min(dp[nextState],dp[i]+costs[j]);
        }
    }
    cout<<((dp[(1<<N)-1]!=INF)?dp[(1<<N)-1]:-1)<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    vector<int> f(123, 0);
    f[s[0]]++;
    f[s[1]]++;
    f[s[2]]++;
    cout << 700 + f['o']*100 << "\n";
    return 0; 
}

Measured memory_bytes: 15872
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int a, b,c,d;
	
	cin>>a>>b>>c>>d;
	
	cout<<yn(!((a*b)%2==1&&(c+d)%2==1))<<endl;
	
	return 0;
}


Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=1e5+5;
ll n,x;
int main(){
	n=read();
	ll ans=1,flag=0;
	for(int i=1;i<=n;i++){
		x=read();
		if(x==0){
			printf("0\n");
			return 0;
		}
		if(flag||x>1000000000000000000/ans){
			flag=1;
		}
		else ans*=x;
	}
	if(flag) printf("-1\n");
	else printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3760
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  ll ma = -1;
  int maxi = -1;
  REP(i, 0, n) {
    cin >> a[i];
    if (ma < abs(a[i])) {
      ma = abs(a[i]);
      maxi = i;
    }
  }
  if (ma == 0) {
    cout << 0 << endl;
    return 0;
  }
  vector<PI> ops;
  if (a[maxi] > 0) {
    ops.push_back(PI(maxi, 0));
    ops.push_back(PI(maxi, 0));
    REP(i, 0, n - 1) {
      ops.push_back(PI(i, i + 1));
      ops.push_back(PI(i, i + 1));
    }
  } else {
    ops.push_back(PI(maxi, n - 1));
    ops.push_back(PI(maxi, n - 1));
    for (int i = n - 1; i >= 1; --i) {
      ops.push_back(PI(i, i - 1));
      ops.push_back(PI(i, i - 1));
    }
  }
  cout << ops.size() << endl;
  REP(i, 0, ops.size()) {
    cout << ops[i].first + 1 << " " << ops[i].second + 1 << "\n";
  }
}


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

using namespace std;

int a, b;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> a >> b;
  cout << a * b << endl;

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


Measured memory_bytes: 3612
import pprint
from itertools import chain
import collections
n, x, y = (int(each) for each in input().split(' '))

# table1 = [[0] * n for i in range(n)]
# table2 = [[0] * n for i in range(n)]
table = [[0] * n for i in range(n)]
# cntr = {}

# # 点iから点jまでの距離をテーブルにする

# # 抜け道を通らないルートの場合
# for i in range(n):
#     for j in range(n):
#         if j-i > 0:
#             table1[i][j] = j-i

# # 抜け道を通るルートの場合
# for i in range(n):
#     for j in range(n):
#         if j-i > 0:
#             table2[i][j] = abs(j-y+1)+abs(i-x+1)+1

# どちらか近いほうのルートが最短距離
for i in range(n):
    for j in range(i, n):
        if j-i > 0:
            table[i][j] = min(j-i, abs(j-y+1)+abs(i-x+1)+1)

# テーブルをflattenして数をかぞえる
cntr = collections.Counter(list(chain.from_iterable(table)))

# cntr = dict(cntr)
for each in range(1,n):
    print(cntr.get(each, 0))

Measured memory_bytes: 115484
/// B-Great Ocean View.cpp : アプリケーションのエントリ ポイントを定義します。
//

//#include "stdafx.h" //提出時にはコメント化必要
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

using namespace std;


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

	int N = S.length();
	vector<bool>colors;
	int l;

	for (int i = 0; i < N; i++) {
		bool color;//true:blak false:white
		if (S.substr(i, 1) == "0") {
			color = true;
		}
		else {
			color = false;
		}
		colors.push_back(color);
	}

	int result_whiteBlack = 0;
	int result_blackWhite = 0;

	for (int i = 0; i < N; i++) {
		//奇数番目
		if (i % 2 == 0) {
			if (colors[i] == true) {
				result_blackWhite++;
			}
			else {
				result_whiteBlack++;
			}
		}
		//偶数番目
		else {
			if (colors[i] == false) {
				result_blackWhite++;
			}
			else {
				result_whiteBlack++;
			}

		}
		
	}

	int a = max(result_blackWhite, result_whiteBlack);

	int score = N - a;

	cout << score;

	//cin>>N;

	return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

struct UnionFind{
    vector<int> par; // par[i]:iの親の番号
    vector<int> s; // s[i]:iの属する木のノード数
    int n_group; // 木の数
    
    UnionFind(int N) : par(N) {
        for(int i=0; i<N; i++) par[i] = i;
        s.assign(N, 1);
        n_group = N;
    }
    
    int root(int x){ // xが属する木の根
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }
    
    void unite(int x, int y){ // xとyの木を併合
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        s[ry] += s[rx];
        s[rx] = 0;
        n_group--;
    }
    
    bool same(int x, int y){ // xとyが同じ木に属するかどうか
        return root(x) == root(y);
    }

    int size(int x){ // xが属する木のノード数
        return s[root(x)];
    }
};

int main(void){
    ll N,M; cin >> N >> M;
    VI A(M), B(M);
    REP(i,M){
        int a,b; cin >> a >> b;
        a--; b--;
        A[i] = a; B[i] = b;
    }
    UnionFind uf(N);
    vector<ll> ans(M+1,0); ans[M] = N*(N-1)/2;
    RREP(i,M){
        if(uf.same(A[i], B[i])){
            ans[i] = ans[i+1];
        }
        else{
            ans[i] = ans[i+1] - uf.size(A[i])*uf.size(B[i]);
            uf.unite(A[i], B[i]);
        }
    }

    REP(i,M) cout << ans[i+1] << endl;
    return 0;
}

Measured memory_bytes: 3712
n, q = map(int, input().split())
S = input()
t = [0] * (n + 1)

for i in range(n):
    t[i + 1] = t[i] + (1 if S[i:i + 2] == 'AC' else 0)

for i in range(q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 7748
// 21:12
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <sstream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;

string ln;
int p;
vector< vector<int> > V;
vector<string> name;
vector<int> cntt;

int f(int dep = 0){
	//if( ln[p] != '~' && ln[p] == '<' && ln[p+1] != '/'){
		
		p++;
		string s;
		while(ln[p] != '>'){
			s += ln[p++];
		}
		p++;
		int c = 0;
		vector<int> w(4);
		stringstream ss;
		string t;
		while(ln[p] != '<'){
			t += ln[p++];
		}
		for(int i = 0 ; i < t.size() ; i++) if( t[i] == ',' ) t[i] = ' ';
		ss << t;
		assert((ss >> w[0] >> w[1] >> w[2] >> w[3]));
		int aaa=0;
		while( ln[p] == '<' && ln[p+1] != '/'){
			f(dep+1);
			aaa++;
		}
	//}
	V.push_back(w);
	name.push_back(s);
	cntt.push_back(aaa);	
	if( ln[p] == '~' ) return 0;
	p++;
	p++;
	string cnt;
	
	while(ln[p] != '>')cnt += ln[p++];
	p++;
	assert(cnt == s);
	return 0;
}
int main(){
	int n;
	while(cin >> n && n){
		cin >> ln;
		ln += "~";
		p = 0;
		V.clear();
		name.clear();
		f();
		cntt.clear();
		int fst = 0;
		assert(ln[p] == '~');
		for(int i = 0 ; i < n ; i++){
			int x,y;
			cin >> x >> y;
			int ok = 1e9 , idx = -1 , c = 0;
			for(int j = 0 ; j < V.size() ; j++){
				vector<int> &v = V[j];
				if( v[0] <= x && x <= v[2] && v[1] <= y && y <= v[3] ){
					ok = (v[2]-v[0])*(v[3]-v[1]);
					idx = j;
					break;
				}
			}
			if( idx == -1 ){ cout << "OUT OF MAIN PANEL 1" << endl; continue; }
			
			cout << name[idx] << " " << cntt[idx] << endl;
		}
		
	}
}

Measured memory_bytes: 1264
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"

using namespace std;
typedef long long ll;

int n, k;
int h[100100];
int dp[100100];
int ans;

int dist(int x)
{
  if (dp[x] >= 0)
  {
    return dp[x];
  }
  else
  if (x == n - 1)
  {
    ans = 0;
  }
  else
  {
    ans = dist(x + 1) + abs(h[x] - h[x + 1]);
    for (int i = 2; i <= k && x + i <= n - 1; i++)
    {
      ans = min(ans, dist(x + i) + abs(h[x] - h[x + i]));
    }
  }
  return dp[x] = ans;
}

int main()
{
  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  for (int i = 0; i < n; i++)
  {
    dp[i] = -1;
  }
  cout << dist(0) << endl;
}

Measured memory_bytes: 4096
#include <cstdio>
const int maxn = 2e5+5;
int n,a[maxn];
long long t[maxn];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),++t[a[i]];
	long long ans = 0;
	for(int i=1;i<=n;++i)ans += t[i]*(t[i]-1)/2;
	for(int i=1;i<=n;++i)printf("%lld\n",ans-(t[a[i]]-1));
	return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

vector<P> lar[200010]={};

ll dat[800010],del[800010],n;

void init(ll n_){
  n=1;
  while(n<n_) n*=2;
  fr(i,2*n-1) dat[i]=0;
}

void ud(ll be,ll en,ll c,ll k=0,ll l=0,ll r=n){
  if(r<=be||en<=l) return;
  if(be<=l&&r<=en){del[k]+=c;return;}
  ud(be,en,c,k*2+1,l,(l+r)/2);
  ud(be,en,c,k*2+2,(l+r)/2,r);
  dat[k]=max(dat[k*2+1]+del[k*2+1],dat[k*2+2]+del[k*2+2]);
}

ll mx(ll be,ll en,ll k=0,ll l=0,ll r=n){
  if(be==en) return 0;
  if(r<=be||en<=l) return 0;
  if(be<=l&&r<=en) return del[k]+dat[k];
  del[k*2+1]+=del[k];del[k*2+2]+=del[k];dat[k]+=del[k];del[k]=0;
  return max(mx(be,en,k*2+1,l,(l+r)/2),mx(be,en,k*2+2,(l+r)/2,r))+del[k];
}

int main(){
  ll N,m,l,r,a;
  cin>>N>>m;
  init(N+1);
  fr(i,m){cin>>l>>r>>a;lar[r].pb(mp(l,a));}
  Fr(i,N){
    ud(i,i+1,mx(0,i));
    for(auto it=lar[i].begin();it!=lar[i].end();it++){
      ud((*it).first,i+1,(*it).second);
    }
  }
   cout<<mx(0,N+1)<<endl;
}

Measured memory_bytes: 21120
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	string S;	cin>>S;
	int ans;
	if(S=="SUN"){
		ans=7;
	}
	else if(S=="MON"){
		ans=6;
	}
	else if(S=="TUE"){
		ans=5;
	}
	else if(S=="WED"){
		ans=4;
	}
	else if(S=="THU"){
		ans=3;
	}
	else if(S=="FRI"){
		ans=2;
	}
	else if(S=="SAT"){
		ans=1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3644
l, r = map(int, input().split())
if r-l >= 2019:
    print(0)
else:
    ret_val =2019
    for left_val in range(l, r):
        for right_val in range(left_val+1, r+1):
            ret_val = min(ret_val, (left_val * right_val) % 2019)
    print(ret_val)

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;



//DONT WASTE YOUR TIME......i said don't waste -_- 
//prove yourself remember....fuck ps&&as hard....show them your are better then them
//Be confident.....dont lose hope.......You can do it.....
//dimaag  khoob h tere meh ....bas concentration ki kami h
//CONCENTRATE
//A,B,C dimaag nhi ...observation h .....zyaada mat sochna unme.....bas observe karna dhyaan se aur implement kar daal jitni jaldi ho sake

//capture it

// fortunately or unfortunately tu sabse badaah chodu h ....ek number ka chutiyaa -_-

const ll N= 1e6+55,mod = 1e9+7;
ll ct[N];
vpii red,blue;
pii p;
set<ll>s[500];
set<ll>::iterator it;
int main() {
 	//freopen("task.in","r",stdin);freopen("task.out","w",stdout);
	ll n,i,j,k,a,b,c,x,y,z;
	sc(n);
	for(i=0;i<n;i++){
		sc(a);sc(b);
		red.pb(mp(a,b));
	}
	for(i=0;i<n;i++){
		sc(a);sc(b);
		blue.pb(mp(a,b));
	}
	c=0;
	for(i=0;i<n;i++){
		a=red[i].ff;b=red[i].ss;
		for(j=0;j<n;j++){
			if(a<blue[j].ff && b<blue[j].ss){
				s[i].insert(j);
				ct[j]++;
			}
		}
	}
	k=0;
	while(1){
		if(k>=n)break;
		y=mod;x=-1;
		for(i=0;i<n;i++){
			if(s[i].size()){
				j=s[i].size();
				if(j<y){
					y=j;
					x=i;
				}
			}
		}
		if(x==-1)break;
		z=mod;b=-1;
		for(it=s[x].begin();it!=s[x].end();it++){
			if(ct[*it]>0){
				if(ct[*it]<z){
					z=ct[*it];
					b=*it;
				}
			}
		}
		if(b!=-1)c++;
		for(it=s[x].begin();it!=s[x].end();it++){
			ct[*it]--;
		}
		ct[b]=0;
		for(i=0;i<n;i++){
			if(s[i].find(b)!=s[i].end()){
				s[i].erase(s[i].find(b));
			}
		}
		s[x].clear();
	}
	pr(c);
}

Measured memory_bytes: 384
#include <algorithm>  //min, max, sort, unique, fill
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>  //pair, swap,
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using VI = vector<ll>;
using VB = vector<bool>;
using VP = vector<P>;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) for (ll i = 0; i < (n); i++)

static const ll kIntMax = numeric_limits<ll>::infinity();
static const double kFloatMax = numeric_limits<double>::infinity();

vector<ll> vi;

int main() {
  string s;
  cin >> s;
  int n = 100000;
  FOR(i, 0, s.size() - 3) { n = min(n, abs(stoi(s.substr(i, 3)) - 753 )); }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    def swap(a, i, j):
        # list aのi番目の要素とj番目の要素を交換する関数
        k = a[j]
        a[j] = a[i]
        a[i] = k

    def partition(A, p, r):
        x = A[r]
        i = p-1
        for j in range(p, r):
            if A[j] <= x:
                i += 1
                swap(A, i, j)
        swap(A, i+1, r)
        return i+1


    n = int(input())

    A = list(map(int, input().split()))

    q = partition(A, 0, n-1)

    for i in range(n):
        if i:
            print(" ", end="")
        if i==q:
            print("[", end="")
        print(A[i], end="")
        if i==q:
            print("]", end="")
    print()



Measured memory_bytes: 15600
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[]
 for l in L[::-1]:
  while R and R[-1]>l:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:]))if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 61868
// 標準入力から一行を読み取り、指定の型に変換する
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_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn advance(c: char, n: i32) -> char {
    let alphabet_index: u8 = c as u8 - 65;
    let converted_index: i32 = (alphabet_index as i32 + n) % 26;
    return (converted_index + 65) as u8 as char;
}

fn main() {
    let n: i32 = read();
    let mut s: String = read();
    let mut result: String = "".to_string();

    for c in s.chars()
    {
        result.push(advance(c, n));
        
    }

    println!("{}", result);
}


Measured memory_bytes: 4352
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
s = reversed(input())
t = reversed(input())

feasible_bound = [1, w, 1, h]

for si, ti in zip(s, t):
    if ti == "L":
        feasible_bound[1] = min(w, feasible_bound[1] + 1)
    elif ti == "R":
        feasible_bound[0] = max(1, feasible_bound[0] - 1)
    elif ti == "U":
        feasible_bound[3] = min(h, feasible_bound[3] + 1)
    elif ti == "D":
        feasible_bound[2] = max(1, feasible_bound[2] - 1)

    if si == "L":
        feasible_bound[0] += 1
    elif si == "R":
        feasible_bound[1] -= 1
    elif si == "U":
        feasible_bound[2] += 1
    elif si == "D":
        feasible_bound[3] -= 1

    # print(si, ti, feasible_bound)

    if feasible_bound[0] > feasible_bound[1] or feasible_bound[2] > feasible_bound[3]:
        print("NO")
        break
else:
    if (
        feasible_bound[0] <= sc <= feasible_bound[1]
        and feasible_bound[2] <= sr <= feasible_bound[3]
    ):
        print("YES")
    else:
        print("NO")


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

int main(){
	int d, ans, n;
	while(cin >> d){
		ans = pow(d, 3);
		n = 600 / d - 1;
		ans *= n*(n+1)*(2*n+1) / 6;
		cout << ans << endl;
	}
	return 0; 
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    ll n,m,a=0;
    cin>>n;
    rep(i,n){
        cin>>m;
        a=a^m;
    }
    if(a==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

map<ll, ll> mp;
ll N, K, a, b, r;

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> a >> b;
        mp[a] += b;
    }
    for (auto x : mp)
    {
        r += x.second;
        if (r >= K)
        {
            cout << x.first << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n, x, y;
  cin >> n >> x >> y;
  map<int, int> data;
  FOR(i, 1, n + 1) {
    FOR(j, i + 1, n + 1) {
      //経路が関係ない場合
      if (j <= x || y <= i) {
        data[j - i] += 1;
      } else {  // 関係ある場合
        // DEBUG(i);
        // DEBUG(j);
        int dist = min(j - i, abs(i - x) + 1 + abs(y - j));
        // DEBUG(dist);
        data[dist] += 1;
      }
    }
  }

  FOR(i, 1, n) { cout << data[i] << endl; }
}

Measured memory_bytes: 384
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
typedef pair<int,int> P;

int main(){
    int n;cin>>n;
    P arr[20];
    rep(i,n){
        int a,v;cin>>a>>v;
        arr[i]=make_pair(a,v);
    }
    partial_sort(arr,arr+1,arr+n,
                 [](const P& a, const P& b){
                     if(a.second!=b.second) return a.second>b.second;
                     return a.first<b.first;
                 });
    cout<<arr[0].first<<" "<<arr[0].second<<endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	int N, Q;
	string S;
	cin >> N >> Q >> S;

	vector<int> l(Q), r(Q);

	for (int i = 0; i < Q; i++) {
		cin >> l.at(i) >> r.at(i);
	}

	vector<int> sum(N + 1);

	for (int i = 1; i < N; i++) {
		sum.at(i) = sum.at(i-1);
		if ((S.at(i-1) == 'A') && (S.at(i) == 'C')) {
			sum.at(i)++;
		}
	}

	///////////////////////////////////////////
	/*for (auto&i:sum) {
		cout << i << " ";
	}*/

	for (int i = 0; i < Q; i++) {
		cout << (sum.at(r.at(i)-1) - sum.at(l.at(i)-1)) << "\n";
	}
	return 0;
}

Measured memory_bytes: 2256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    int n,s=0;
    scanf("%d",&n);
    int a[n];
    scanf("%d",&a[0]);
    s+=abs(a[0]);
    for(int i=1;i<n;i++)
        {
            scanf("%d",&a[i]);
            s+=abs(a[i]-a[i-1]);
        }
        s+=abs(a[n-1]);
        printf("%d\n",s-abs(a[0])-abs(a[0]-a[1])+abs(a[1]));;
        for(int i=1;i<n-1;i++)
        {
            printf("%d\n",s-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i+1]-a[i-1]));
        }
        printf("%d\n",s-abs(a[n-1])-abs(a[n-1]-a[n-2])+abs(a[n-2]));
    return 0;
}


Measured memory_bytes: 1664
n, a, b, c, d = gets.split.map(&:to_i)
s = gets.chomp.split("")

rocks = 0
areas = Array.new(n+1, 0)
for i in 0..(n-1)
  if s[i] == "."
    areas[i+1] = areas[i] + 1
    rocks = 0
  elsif s[i] == "#"
    areas[i+1] = 0
    if i >= a - 1 && i <= ([c, d].max - 1)
      rocks += 1
    end
  end
  if rocks >= 2
    break
  end
end
if rocks >= 2
  puts "No"
else
  if c < d
    puts "Yes"
  else
    ifover = 0
    for i in (b+1)..(d+1)
      if areas[i] >= 3
        ifover = 1
        break
      end
    end
    if ifover > 0
      puts "Yes"
    else
      puts "No"
    end
  end
end

Measured memory_bytes: 18172
import sys

n = int(sys.stdin.readline())
a = [[int(i) for i in sys.stdin.readline().strip().split()] for _ in range(2)]

if n == 1:
    print(a[0][0] + a[1][0])
else:
    import itertools
    top_accum = list(itertools.accumulate(a[0]))
    bottom_accum_reverse = list(reversed(list(itertools.accumulate(reversed(a[1])))))

    count_max = 0
    for i in range(n):
        count_max = max(count_max, top_accum[i] + bottom_accum_reverse[i])
    print(count_max)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int A,B,C,X,ANS=0;
	int i=0,j=0,k=0;
	cin >> A >> B >> C >> X;
	while(i<=A && j<=B && k<=C){
		//cout << i << ":" << j << ":" << k << endl;
		//cout << i*500+j*100+k*50 << endl;
		if(X==i*500+j*100+k*50)ANS++;
		if(k<C){
			k++;
		}
		else if(k==C&&j<B){
			j++;
			k=0;
		}
		else if(k==C&&j==B){
			i++;
			j=0;
			k=0;
		}
	}
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))



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

	int pena = 0;
	set<int> ac;
	map<int,int> ma;
	FOR(i,0,M){
		int p;
		string S;
		cin >> p >> S;
		if(ac.count(p))continue;
		if(S=="WA"){
			ma[p]++;
		}else{
			pena += ma[p];
			ac.insert(p);
		}
	}

	cout << ac.size() << " " << pena << endl;

}



Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

map<ll, ll> mp;

ll memo_rec(ll x){
    if(mp.find(x) != mp.end())  return mp[x];
    if(x == 1)  return mp[x] = 1;
    ll res = memo_rec(x / 2) * 2 + 1;
    return mp[x] = res;
}

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

    ll h;
    cin >> h;
    cout << memo_rec(h) << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

const int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    string s; cin >> s;
    bool f = true; rep(i, 3) if (s[i] == s[i+1]) f = false;
    if (f) cout << "Good" << endl;
    else cout << "Bad" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  
  int A;
  int B;
  int X;
  
  scanf("%d %d %d",&A,&B,&X);
  
  if(A > X || A + B < X){
    puts("NO");
  }
  else{
    puts("YES");
  }
  
  
  return 0;
}
  


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

size_t length(const string& str) {
    return str.length();
}

int main(){
  int K;
  cin>>K;
  string S;
  cin>>S;
  int s=length(S);
  
  if(s<=K){ cout<<S<<endl;}
  else{
    string A=S.substr(0,K);
    A.append("...");
    cout<<A<<endl;}
  
 
}

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

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

    int a[210]; // 適当な数を用意する
    for(int i=0; i<n; i++)
        cin >> a[i];

    int count = 0;
    bool isSuccess;
    //　判定
    while(1) {
        isSuccess = true;
        for(int i=0; i<n; i++){
            if(a[i] % 2 == 0) {
                a[i] = a[i] /2;
            } else {
                isSuccess = false;
                break;
            }
        }
        if(!isSuccess){
          break;
        }
        count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,cnt;
double m,x,y;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	while(n--){
		cin>>x>>y;
		double dis=sqrt(x*x+y*y);
		if(dis<=m)cnt++;
	}
	cout<<cnt<<endl;
}


Measured memory_bytes: 3860
#include <algorithm>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

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

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

int main() {
  ll N, M;
  while (cin >> N >> M) {
    string S, T;
    cin >> S >> T;
    ll L = lcm(N, M);
    map<ll, char> mp;
    for (int i = 0; i < N; i++) {
      ll j = (L / N) * i;
      mp[j] = S[i];
    }
    bool ok = true;
    for (int i = 0; i < M; i++) {
      ll j = (L / M) * i;
      if (mp.count(j) && mp[j] != T[i]) {
        ok = false;
        break;
      }
    }
    cout << (ok ? L : -1) << endl;
  }
  return 0;
}


Measured memory_bytes: 6144
{
  const main = (input: string): void | string | number => {
    const r = reader(input)
    const N = r.n()
    const a = r.ns()

    let minu = 0
    let hasZero = false

    let min = Infinity

    a.forEach(v => {
      if (v === 0) {
        hasZero = true
      }
      if (v < 0) {
        minu++
      }
      min = Math.min(min, Math.abs(v))
    })
    if (hasZero || minu % 2 == 0) {
      return a.map(Math.abs).reduce((a, b) => a + b, 0)
    } else {
      return a.map(Math.abs).reduce((a, b) => a + b, 0) - min * 2
    }
  }

  const reader = (str: string) => {
    const lines = str.trim().split('\n')
    const s = () => lines.shift() || ''
    const n = () => Number(s())

    const ss = () => s().split(' ')
    const ns = () => ss().map(Number)
    const nls = () => lines.map(Number)

    return { lines, s, n, ss, ns, nls }
  }

  const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
  const res = main(getInput())

  if (typeof res === 'number' || typeof res == 'string') console.log(res)
}


Measured memory_bytes: 29756
#include <iostream>

//#include <algorithm>
//#include <vector>
//#include <cmath>
//#include <cstring>
//include <queue>
//#include <map>
//cout<<*itr<<endl;
//#define ll long long //data types used often, but you don't want to type them time by time
//#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
//#define FOREACH(itr,cont) for (auto itr=cont.begin(); itr!=cont.end(); itr++) // traverse an STL data structure
#define F(i,R) for (int i = 0; i < R; i++) //next four are for "for loops"

using namespace std;
int main()
{
    ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
    int a,b;
        cin>>a>>b;


    
        if(a<b)
            cout<<"0"<<endl;
        else
            cout<<"10"<<endl;
}

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

using namespace std;
typedef long long LL;

const int N=1e5+10;
const LL Inf=1e10+10;

LL s[N],cube[N];
int n,prime[N],cntprime;
bool notprime[N];
map<LL,int>app;
map<LL,LL>r;

void Init()
{
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%lld",&s[i]);
}

void Euler()
{
	int n=2200;
	notprime[1]=1; cntprime=0;
	for (int i=2;i<=n;++i)
	{
		if (!notprime[i]) prime[++cntprime]=i,cube[cntprime]=1ll*i*i*i;
		for (int j=1;j<=cntprime && 1ll*i*prime[j]<=n;++j)
		{
			notprime[i*prime[j]]=1;
			if (!(i%prime[j])) break;	
		}
	}
}

void Solve()
{
	Euler();
	for (int i=1;i<=n;++i)
	{
		LL rev=1,d=s[i];
		for (int j=1;j<=cntprime && prime[j]<=s[i];++j)
		{
			while (!(s[i]%cube[j])) s[i]/=cube[j],d/=cube[j];
			if (!(s[i]%prime[j]))
			{
				s[i]/=prime[j];
				if (!(s[i]%prime[j])) s[i]/=prime[j],rev*=prime[j],rev=min(rev,Inf);
				else rev*=prime[j],rev=min(rev,Inf),rev*=prime[j],rev=min(rev,Inf);
			}
		}
		LL v=sqrt(s[i]);
		if (1ll*v*v==s[i]) rev=rev*v,rev=min(rev,Inf);
		else rev=rev*s[i],rev=min(rev,Inf),rev=rev*s[i],rev=min(rev,Inf);
		app[d]++; r[d]=rev;
		if (d>rev) swap(d,rev);
		if (d*d!=rev && rev!=Inf)
		{
			fprintf(stderr,"Error:%d %lld %lld\n",i,d,rev);
		}
	}
	int ans=0;
	for (auto a:app)
	{
		LL v=a.first; int ap=a.second;
		if (v==1) { ans++; continue; }
		if (v<=100000) 
		{
			LL rev=r[v];
			ans+=max(app[rev],ap);
			app[rev]=0; app[v]=0;
		}else ans+=ap;
	}
	printf("%d\n",ans);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 16512
h, w = map(int, input().split())
d = []
for i in range(10):
    d.append(list(map(int, input().split())))
a = []
for i in range(h):
    a.append(list(map(int, input().split())))
for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

#for k in range(0, 10):
#    print(c[k])
#for k in range(0, 10):
#    print(d[k])
#print(d[8][1])

ans = 0
for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += d[a[i][j]][1]
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 29)
using namespace std;

int main(){
    int n;
    vector< pair<long long, long long> > v;
    cin >> n;
    rep(i,n){
        long long a, b;
        cin >> a >> b;
        v.emplace_back(make_pair(a,b));
    }
    range(i,1,n){
        long long f = v[i].first;
        long long s = v[i].second;
        long long kf, ks;
        if(v[i].first < v[i - 1].first || v[i].second < v[i - 1].second){
            kf = abs(v[i - 1].first - v[i].first) / f;
            ks = abs(v[i - 1].second - v[i].second) / s;
            long long k = max(kf, ks);
            v[i].first = v[i].first + f * k;
            v[i].second = v[i].second + s * k;
            if(v[i].first < v[i - 1].first){
                v[i].first+=f;
                v[i].second+=s;
            }
            if(v[i].second < v[i - 1].second){
                v[i].first+=f;
                v[i].second+=s;
            }
        }
    }
    cout << v[n - 1].first + v[n - 1].second << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    int d[N];
    int ans =0;
    for(int i=0;i<N;i++) cin >> d[i];
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
N, L = map(int, input().split())

if L + N - 1 < 0:
    eaten = N + L - 1
elif L <= 0 <= L + N - 1:
    eaten = 0
else:
    eaten = L

ans = (L + (L + N - 1)) * N // 2 - eaten
print(ans)


Measured memory_bytes: 2940
// S と現在の区間の位置関係が重要。S を区間が含んでいなければ終了。含んでいれば、戻るとき同じ方向で通るものをまとめてカウント。
#include <cstdio>
#include <cstdlib>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

using ll = long long;

constexpr int MAX_N = 100010;

ll N, S;
ll X[MAX_N], P[MAX_N];

int main()
{
    scanf( "%lld%lld", &N, &S );
    rep( i, N )
        scanf( "%lld%lld", X+i, P+i );

    ll s = 0, t = N-1;
    ll ans = 0;

    while( s <= t )
    {
        if( S <= X[s] )
        {
            ans += X[t]-S;
            break;
        }
        if( X[t] <= S )
        {
            ans += S-X[s];
            break;
        }

        if( P[s] >= P[t] )
        {
            ans += X[t]-X[s];
            
            while( t-s > 0 && P[s] >= P[t] )
            {
                P[s] += P[t];
                --t;
            }
        }
        else
        {
            ans += X[t]-X[s];
            
            while( t-s > 0 && P[s] < P[t] )
            {
                P[t] += P[s];
                ++s;
            }
        }
    }

    printf( "%lld\n", ans );

    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>
int main(){
  int i=0, j=2, n, runner=0, out=0, point=0;
  char s[10];
  scanf ( "%d" ,&n );

  while ( i < n ){
    while ( out <= j ){ 
      scanf ( "%s" ,s );

      if ( strcmp ( s,"HIT" ) == 0 ){
	runner++;

	if ( runner == 4 ){
	  point++;
	  runner--;
	}
      }

      if ( strcmp ( s,"HOMERUN" ) == 0 ){
	point++;
	point = point + runner;
	runner = 0;
      }

      if ( strcmp ( s,"OUT" ) == 0 ){
	out++;
      }

    }
    printf ( "%d\n" ,point );
    point = 0;
    runner = 0;
    out = 0;
    i++;
  }

  return 0;
}

Measured memory_bytes: 596
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int n, pre[2009], nxt[2009], val[2009]; string a, b;
int main() {
	cin >> a >> b; n = a.size();
	if (b.find('1') == string::npos) cout << (a == b ? 0 : -1) << endl;
	else {
		int ret = 1 << 30;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n; j++) {
				if (b[j] == '1') {
					a = a.substr(j) + a.substr(0, j);
					b = b.substr(j) + b.substr(0, j);
					break;
				}
			}
			for (int j = 0; j < n; j++) pre[j] = (b[j] == '1' ? 0 : pre[j - 1] + 1), val[j] = 0;
			for (int j = n - 1; j >= 0; j--) nxt[j] = (b[j] == '1' ? 0 : nxt[j + 1] + 1);
			for (int j = 0; j < n; j++) {
				if (a[j] == '0') pre[j] = nxt[j] = 0;
				val[pre[j]] = max(val[pre[j]], nxt[j]);
			}
			for (int j = n - 1; j >= 0; j--) val[j] = max(val[j], val[j + 1]);
			for (int j = 0; j < n; j++) {
				int cnt = 0;
				for (int k = 0; k < n; k++) {
					if (a[k] != b[(j + k) % n]) cnt++;
				}
				for (int k = 0; k < n; k++) {
					ret = min(ret, cnt + j + max(val[k + 1] - j, 0) * 2 + k * 2);
				}
			}
			reverse(a.begin(), a.end());
			reverse(b.begin(), b.end());
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 256