akhauriyash/Code-Regression huggingface dataset:
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
using namespace std;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, k;
    cin >> n >> k;
    int a[n + 1];
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    int vis[n + 1] = {0};
    int start = 1;
    int cnt = 0, prev;
    while (k > 0 && !vis[start])
    {
        cnt++;
        vis[start] = cnt;
        prev = start;
        start = a[start];
        k--;
    }
    // cout << vis[start] << " " << vis[prev];
    // cout << cnt;

    if (k == 0)
        cout << start;
    else
    {
        cnt = abs(vis[start] - vis[prev]) + 1;
        // cout << cnt;
        k %= cnt;
        while (k > 0)
        {
            start = a[start];
            k--;
        }
        cout << start;
    }
}


Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int D;
    cin >> D;
    vector<int> c(26);
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < 26; ++i)
        cin >> c[i];
    for (int i = 0; i < D; ++i)
        for (int j = 0; j < 26; ++j)
            cin >> s[i][j];
    vector<int> t(D);
    vector<int> last(26), ans(D + 1);
    for (int i = 0; i < D; ++i) {
        int ma = 0;
        for (int k = 0; k < 26; ++k) {
            if (c[k] > 50)
                continue;
            int res = ans[i];
            res += s[i][k];
            for (int j = 0; j < 26; ++j)
                if (j != k)
                    res -= c[j] * (i + 1 - last[j]);
            if (ans[i + 1] < res) {
                ans[i + 1] = res;
                ma = k;
            }
        }
        t[i] = ma + 1;
        last[ma] = i + 1;
        cout << t[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 3680
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	string X;
	cin >> X;

	int result = 0;

	int check = 1;
	char prev = -1;
	for (int i = 0; i < X.size(); i++)
	{
		if (X[i] != prev)
		{
			result = max(result, check);
			check = 1;
			prev = X[i];
		}
		else
		{
			check++;
		}
	}

	result = max(result, check);

	if (result >= 3)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


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

using namespace std;

#define ll long long
#define fix cout << fixed; cout << setprecision(0)





void solve() {

	string s;
	cin >> s;
	int n = s.length();
	string a = s;
	reverse(a.begin(), a.end());
	if(s != a) {
		cout << "No";
		return;
	}
	s = s.substr(0, n / 2);
	a = s;
	reverse(a.begin(), a.end());
	if(s.substr(0, n / 2) != a) {
		cout << "No";
		return;
	}
	else {
		cout << "Yes\n";
	}

	




	
}

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	fix;
	solve();

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bs binary_search
#define pb push_back
#define pp pair<ll,ll>
#define F first 
#define S second 
#define lc "\n"
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;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
int main() 
{
    fastio
    map<string,ll>mp;
    ll n; cin>>n; string s;
    while(n--)
    {
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
    return 0;
}

Measured memory_bytes: 19244
#include<bits/stdc++.h>
using namespace std;
//14719021122270100109
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef unsigned long long ull;

#define f first
#define s second
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
#define forn(i, n) for(register int i=0; i<n; i++)
#define Forn(i, n) for(register int i=1; i<=n; i++)
#define foreach(it, a) for(__typeof((a).begin()) it=(a).begin(); it!=(a).end(); it++)
#define Foreach(it, a) for(__typeof((a).rbegin()) it=(a).rbegin(); it!=(a).rend(); it++)
#define mid (l+r>>1)
#define lid id<<1|1
#define rid (id<<1)+2
#define lson lid, l, mid
#define rson rid, mid, r

inline int in()
{
    char c=getchar();
    int neg=1, x=0;
    while(!isdigit(c)) (c=='-')?neg=-1, c=getchar():c=getchar();
    while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48), c=getchar();
    return neg*x;
}
inline int lcm(int a, int b){return a*b/__gcd(a, b);}

const int MAX=2e5+5;

int N, ptr, a[MAX];
pair<int,pair<int,int> > rr[MAX];
class State
{
    public:
    int t1, t2, p1, p2, l, r;
    State(int _t1, int _t2, int _p1, int _p2, int _l, int _r):
        t1(_t1), t2(_t2), p1(_p1), p2(_p2), l(_l), r(_r){}
    friend bool operator>(const State&A, const State&B) { return A.t1>B.t1; }
};
priority_queue<State, vector<State>, greater<State> > q; 

class Seg
{
    private:
    struct Dat
    {
        int v, p;
        Dat(int _v=0, int _p=0):v(_v), p(_p){}
        Dat operator+(const Dat&A)
        {
            Dat ret(v, p);
            if(v>A.v) ret=A;
            return ret;
        }
    }dat[20][MAX];
    public:
    inline void build(int t)
    {
        forn(i, N) if(i%2==t) dat[0][i]=Dat(a[i], i);
        else dat[0][i]=Dat(1e9, 1e9);
        forn(lg, 18) forn(i, N) if(i+(1<<lg)<N)
            dat[lg+1][i]=dat[lg][i]+dat[lg][i+(1<<lg)];
    }
    inline Dat mn(int l, int r)
    {
        int lg=31-__builtin_clz(r-l);
        return dat[lg][l]+dat[lg][r-(1<<lg)];
    }
    inline int query(int a, int b)
    {
        Dat tt=mn(a, b);
        return tt.p;
    }
}s0, s1;

inline void get(int l, int r)
{
    if(l>=r) return;
    int p1, p2;
    if(l%2==0)
    {
        p1=s0.query(l, r);
        p2=s1.query(p1, r);
    }
    else
    {
        p1=s1.query(l, r);
        p2=s0.query(p1, r);
    }
    q.push(State(a[p1], a[p2], p1, p2, l, r));
}

int main()
{
    N=in();
    forn(i, N) a[i]=in();
    s0.build(0);
    s1.build(1);
    get(0, N);
    while(!q.empty())
    {
        State t=q.top();
        q.pop();
        printf("%d %d ", t.t1, t.t2);
        get(t.l, t.p1);
        get(t.p1+1, t.p2);
        get(t.p2+1, t.r);
    }
    return 0;
}

Measured memory_bytes: 68212
#131
#文字入力
str = input() 

#文字列の長さ取得
str_leg = len(str)


#判定

check = 1; 

for i in range(0, str_leg - 1):
    for j in range(i+1, str_leg):
        if (str[i] == str[j] and j == i + 1) :
             check = 0; 

if(check == 1):
    print("Good")
else:
     print("Bad")

Measured memory_bytes: 3060
import collections

N = int(input())
S = []
A = []
m=0

for i in range(0,N):
  S.append(input())

c = collections.Counter(S)

for k, v in c.most_common(2*10**5):
#  print(k,v)
  if v>=m:
#      print(k)
    A.append(k)
    m=v
  else:
    break
A.sort()
for j in range(0,len(A)):
  print(A[j])

Measured memory_bytes: 45036
s = list(input())

ans = 0
for i in range(2 ** (len(s) - 1)):
    s_copy = s[:]
    for j in reversed(range(len(s))):
        if (i >> j) & 1:
            s_copy.insert(j + 1, '+')
    cut = ''.join(s_copy).split('+')

    for j in cut:
        ans += int(j)

print(ans)


Measured memory_bytes: 39792
s = input()
k = int(input())

kouho = []

tmp = 0

flag = False

for i in range(k):
    if flag == True:
        break
    for j in range(len(s)):
        if tmp >= k:
            flag = True
            break
        tmp += 1
        kouho.append(s[i:i+j+1])
        
kouho.sort()
tmp = 0

flag = False

for i in range(len(s)):
    for j in range(2*k):
        for l in range(k):
            if s[i:i+j+1] == kouho[l]:
                break
            elif s[i:i+j+1] < kouho[l]:
                kouho.insert(l,s[i:i+j+1])
                break
            else:
                continue
#print(s[0:1],s)
print(kouho[k-1])

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cstdio>

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    double ans;
    rep(i, n){
        int num = i + 1;
        double p = 1;
        while(num < k){
            num *= 2;
            p /= 2;
        }
        ans += p;
    }
    printf("%.10lf\n", ans / (double)n);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int N;
	cin >> N;
	vector<int> P(N);
	vector<int> Q(N);
	rep(i, N)
		cin >> P[i];
	rep(i, N)
		cin >> Q[i];
	ll ans1 = 0;
	ll ans2 = 0;
	vector<int> pq = P;
	while (1) {
		if (pq == Q)
			break;
		vector<int> pqold = pq;
		next_permutation(pq.begin(), pq.end());
		if (pqold[0] > pq[0]) {
			ans1 = Inf;
			break;
		}
		ans1++;
	}
	pq = Q;
	while (1) {
		if (P == pq)
			break;
		vector<int> pqold = pq;
		next_permutation(pq.begin(), pq.end());
		if (pqold[0] > pq[0]) {
			ans2 = Inf;
			break;
		}
		ans2++;
	}
	ll ans = min(ans1, ans2);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int M, D;
	int cnt = 0;
	cin >> M >> D;
	for (int i = 1; i <= M; i++) {
		for(int j = 22; j <= D; j++){
			if ((j % 10) * (j / 10) == i && (j % 10) >= 2) {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int q = Integer.parseInt(br.readLine());
		for (int i = 0; i < q; i++) {
			String[] sa = br.readLine().split(" ");
			int a = Integer.parseInt(sa[0]);
			int b = Integer.parseInt(sa[1]);
			long x = Math.min(a, b);
			long y = Math.max(a, b);
			long xy = x * y;

			if (y - x <= 1) {
				System.out.println((x - 1) * 2);
			} else {
				long ans = (x - 1) * 2;
				long start = (long) (Math.sqrt(xy)) + 10;
				start = start + start - x;
				for (long r = start; r > x; r--) {
					long d = r - x;
					if (d % 2 == 0) {
						long m = (x + r) / 2;
						if (m * m < xy) {
							ans += r - x;
							break;
						}
					} else {
						long m = (x + r) / 2;
						if (m * (m + 1) < xy) {
							ans += r - x;
							break;
						}
					}
				}
				System.out.println(ans);
			}
		}
		br.close();
	}
}


Measured memory_bytes: 23508
#include<cstdio>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

void pairsort(int n,int *a,int *b){
	pair<int,int> c[1000];
	rep(i,n) c[i]=make_pair(a[i],b[i]);
	sort(c,c+n);
	rep(i,n) a[i]=c[i].first, b[i]=c[i].second;
}

int n,m;
int x[1000],num[1000],esa[1000];

int sum[1001];
int count_cat(int l,int r){ // [l, r] にいるねこの数
	int i=lower_bound(x,x+n,l)-x;
	int j=upper_bound(x,x+n,r)-x;
	return sum[j]-sum[i];
}

bool check(int ub){
	// dp[i] := ( esa[i] にごはんを置いたときに右から来るねこの最小数 )
	int dp[1000];
	dp[m-1]=count_cat(esa[m-1]+1,20000);
	for(int i=m-2;i>=0;i--){
		dp[i]=INF;
		for(int j=i+1;j<m;j++){
			int a=count_cat(esa[i]+1,(esa[i]+esa[j])/2); // (esa[i], (esa[i]+esa[j])/2] にいるねこの数
			int b=count_cat((esa[i]+esa[j])/2+1,esa[j]); // ((esa[i]+esa[j])/2, esa[j]] にいるねこの数
			if(b+dp[j]<=ub){
				dp[i]=min(dp[i],a);
			}
		}
	}

	rep(i,m){
		if(dp[i]+count_cat(0,esa[i])<=ub) return true;
	}
	return false;
}

int main(){
	while(scanf("%d%d",&n,&m),m){
		rep(i,n) scanf("%d%*d%d",x+i,num+i), x[i]+=10000;
		rep(i,m) scanf("%d",esa+i), esa[i]+=10000; // あとで /2 するとき 0 方向へ丸められるのがイヤなので >=0 にしておく

		pairsort(n,x,num);
		sort(esa,esa+m);

		rep(i,n) sum[i+1]=sum[i]+num[i];

		int lo=0,hi=100000000;
		while(lo<hi){
			int mi=(lo+hi)/2;
			if(check(mi)) hi=mi; else lo=mi+1;
		}
		printf("%d\n",lo);
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct num { 
  ll i, a; 
  bool operator>(const num &x) const { return a>x.a||(a==x.a&&i>x.i); };
};

int main() {
  int N; cin >> N;
  num A[N]; rep(i,N) { ll t; cin >> t; A[i] = {i,t}; }
  sort(A,A+N,greater<num>());
  ll dp[N+1][N+1] = {};
  rep(i,N) {
    dp[i+1][0] = dp[i][0] + A[i].a*abs(A[i].i-(N-1-i));
    rep(j,i) {
      dp[i+1][j+1] = max(
        dp[i][j+1]+A[i].a*abs(A[i].i-(N-1-(i-(j+1)))),
        dp[i][j]+A[i].a*abs(A[i].i-j)
      );
    }
    dp[i+1][i+1] = dp[i][i] + A[i].a*abs(A[i].i-i);
  }
  // rep(i,N+1) debug(dp[i],dp[i]+(N+1));
  ll result = *max_element(dp[N],dp[N]+(N+1));
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 34956
#include <string.h>
#include <stdio.h>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
int a[1000005],b[1000005];
int f[1000005];
set<int>s[50];
int main()
{
    int  n,x,y,t,sum,i,j;
    n=1e5;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        f[i]=f[i/10]+i%10;
       // s[f[i]].insert(i);
    }
    int ans=100;
    for(i=1;i<n;i++)
    {
        ans=min(ans,f[i]+f[n-i]);
    }
    printf("%d\n",ans);
    return 0;
}


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

typedef long long ll;

int main() {
    int N, Q, l, r, ans;
    string S;
    cin >> N >> Q >> S;
    vector<int> s(N, 0);
    rep(i, N - 1) {
        s[i + 1] = s[i];
        if (S.substr(i, 2) == "AC") s[i + 1]++;
    }
    rep(i, Q) {
        cin >> l >> r;
        if (l == 1) {
            ans = s[r - 1];
        } else {
            ans = s[r - 1] - s[l - 2];
            if (S.substr(l - 2, 2) == "AC") ans--;
        }
        cout << ans << "\n";
    }
}

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

const ll mod = 1e9 + 7;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k, i, first=1;
    cin >> n >> k;
    vector<ll> a(n);
    for (i=0; i<n; ++i) {
        cin >> a[i];
        if (i < k)
            first *= a[i];
    }
    for (i=k; i<n; ++i) {
        if (a[i] > a[i-k]) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


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

int ctoi(char c){
  if(c=='0'){return 0;}
  if(c=='1'){return 1;}
  if(c=='2'){return 2;}
  if(c=='3'){return 3;}
  if(c=='4'){return 4;}
  if(c=='5'){return 5;}
  if(c=='6'){return 6;}
  if(c=='7'){return 7;}
  if(c=='8'){return 8;}
  if(c=='9'){return 9;}
  return -1;
}

int powpow(int x, int n){
  int res = 1;
  for(int i=0; i<n; i++){
    res*=x;
  }
  return res;
}

int pp(int x, int i){
  return (x/powpow(10,i))%10;
}

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int V;
  int ans=0;
  int judge = 0;
  int cha;
  for(int i=0; i<1000; i++){
    judge = 0;
    cha = 0;
    for(int j=0; j<3; j++){
      V = pp(i,j);
      for(int k=cha; k<N; k++){
        if(V==ctoi(S.at(N-k-1))){
          judge++;
          cha++;
          break;
        }
        cha++;
      }
    }
    if(judge==3){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    int N;
    cin >> N;
    vector <string> S(N);
    for (int i = 0; i < N; i++) {
        cin >> S.at(i);
    }
    sort(S.begin(), S.end());
    int count = N;
    for (int i = 1; i < N; i++) {
        if (S.at(i - 1) == S.at(i)) {
            count--;
        }
    }
    cout << count << endl;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	int nex=1;
	FOR(i,N) {
		cin>>A[i];
		if(A[i]==nex) nex++;
	}
	
	if(nex==1) cout<<-1<<endl;
	else cout<<(N+1-nex)<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
 
int minof(int min, int x) {
  min = (min < x) ? min:x;
  return min;
}
 
int slovei(int, int);
int slovei(int a, int b) {
  int i, j, k, l, o, p, min, temp, d[4] = {};
  min = 268435456;
  for(i = 1; i <= a; i += 1) {
    if(a % i == 0) {
      for(k = 1; k <= b; k += 1) {
        if(b % k == 0) {
          j = a / i;
          d[0] = i;
          d[1] = j;
          l = b / k;
          d[2] = k;
          d[3] = l;
          for(o = 0; o < 3; o += 1) {
            for(p = 3; p >= o; p -= 1) {
              if(d[p] < d[p - 1]) {
               temp = d[p];
               d[p] = d[p - 1];
               d[p - 1] = temp;
              }; 
            }; 
          }; 
          min = minof(min, (d[1] - d[0]) * (d[1] - d[0]) + (d[2] - d[1]) * (d[2] - d[1]) + (d[3] - d[2]) * (d[3] - d[2]));
        }; 
      }; 
    }; 
  }; 
  return min;
}
 
int main() {
  int a, b;
 
  while(1) {
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) {
      break;
    }; 
    printf("%d\n", slovei(a, b));
  };
 
  return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var weathers = new List<string>{ "Sunny", "Cloudy", "Rainy" };

        var input = Console.ReadLine();

        var output = weathers[(weathers.IndexOf(input) + 1) % weathers.Count];

        Console.WriteLine(output);
    }
}

Measured memory_bytes: 10976
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	s, t = rll()[0], rll()[0]
	m = len(t)
	ans = INF 

	def do(start):
		x = 0
		for i in range(m):
			if start + i >= len(s):
				return INF
			if t[i] != s[start + i]: 
				x += 1
		return x

	for i in range(len(s)):
		ans = min(ans, do(i))
	print(ans)

	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 74016
N, X = map(int, input().split())
gar = list(map(int, input().split()))
gar_cum = [0] * (N + 1)
for i in range(N):
    gar_cum[i + 1] = gar_cum[i] + gar[i]

def move_cost(i):
    #i回ゴミを捨てるときの移動コストの最小値
    v = [gar_cum[N - i * j] - gar_cum[max(0, N - i * (j + 1))] for j in range((N + i - 1) // i)]
    return sum([v[j] * max(5, j * 2 + 3) for j in range((N + i - 1) // i)])
def total_cost(i):
    return move_cost(i) + (i + N) * X

ans = float('inf')
for i in range(1, N+1):
    ans = min(ans, total_cost(i))

print(ans)

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

constexpr int mod = 1e9 + 7;

struct segment {
    int l, x;
    segment(int a, int b) : l(a), x(b) {}
};

int n, m;
vector<segment> seg[301];
int dp[301][301][301];

bool check(int r, int g, int b) {
    const int rp = max({r, g, b});
    for(auto const& s : seg[rp]) {
        const int cnt = (s.l <= r) + (s.l <= g) + (s.l <= b);
        if(cnt != s.x) return false;
    }
    return true;
}

int solve(int r, int g, int b) {
    if(g >= b) swap(g, b);
    if(r >= g) swap(r, g);
    if(g >= b) swap(g, b);

    int& res = dp[r][g][b];
    if(res != -1) return dp[r][g][b];
    if(!check(r, g, b)) return dp[r][g][b] = 0;
    if(b == n) return dp[r][g][b] = 1;
    res = 0;
    (res += solve(b + 1, g, b)) %= mod;
    (res += solve(r, b + 1, b)) %= mod;
    (res += solve(r, g, b + 1)) %= mod;
    return res;
}

int main() {
    memset(dp, -1, sizeof(dp));

    cin >> n >> m;
    for(int i = 0; i < m; ++i) {
        int l, r, x; cin >> l >> r >> x;
        seg[r].emplace_back(l, x);
    }

    cout << solve(0, 0, 0) << endl;
}


Measured memory_bytes: 106752
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  int n, k;
  cin >> n >> k;
  if(n % k == 0)
    cout << 0 << endl;
  else
    cout << 1 << endl;
  return 0;
}

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

int main() {
    int n;
    int t[110000], x[110000], y[110000];

    t[0] = x[0] = y[0] = 0;

    cin >> n;
    for(int i = 1; i < n + 1; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    bool can = true;
    // t[i]秒で(x[i],y[i])に移動できるか調べていく
    for(int i = 1; i < n + 1; i++) {
        int dt = t[i] - t[i - 1];
        int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        if(dt < dist)
            can = false;
        if(dist % 2 != dt % 2)
            can = false;
    }

    if(can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1408
//I read the news today, oh boy
//About a lucky man who made the grade
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=2e5+100;
const ll MOD = 1e9+7;

ll mul(ll a, ll b){
	return (a*b)%MOD;
}

ll sum(ll a, ll b){
	ll ans = a+b+MOD;
	while(ans>=MOD) ans-=MOD;
	return ans;
}

ll binpow(ll a, ll p){
	if(p==0) return 1;
	ll cur = binpow(a,p>>1);
	cur = mul(cur,cur);
	if(p&1) cur = mul(cur,a);
	return cur;
}

ll f[N], invf[N];

void prec(){
	f[0]=1;
	invf[0]=1;
	For(i,1,N){
		f[i] = mul(f[i-1],i);
		invf[i] = binpow(f[i],MOD-2);
	}
}

ll calc(int i, int j, int i2, int j2){
	int h = i2-i;
	int w = j2-j;
	return mul(f[h+w],mul(invf[h],invf[w]));
}

ll h, w, n;
vii V;

bool cmp(ii a, ii b){
	if(a.ff+a.ss != b.ff+b.ss) return a.ff+a.ss < b.ff+b.ss;
	return a.ss<b.ss;
}

ll dp[N];

int main(){
	fastio;
	cin>>h>>w>>n;	
	prec();
	For(i,0,n){
		int r, c; cin>>r>>c;
		r--,c--;
		V.pb(mp(r,c));
	}
	V.pb(mp(h-1,w-1));
	sort(all(V),cmp);
	For(i,0,n+1) dp[i] = calc(0,0,V[i].ff,V[i].ss);
	For(i,0,n){
		For(j,i+1,n+1) if(V[j].ff>=V[i].ff && V[j].ss>=V[i].ss){
			dp[j] = sum(dp[j],-mul(dp[i],calc(V[i].ff,V[i].ss,V[j].ff,V[j].ss)));
		}
	}
	cout << dp[n] << endl;
	return 0;
}



Measured memory_bytes: 6904
N, M = map(int, input().split())

mod = 998244353
def cmb(n, r, mod=mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

NN = 4*10**6 # 使うデータによって変える
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


A = []
tmp = 0
for i in range(2*M+N+2):
    tmp = (tmp + cmb(N-2+i, N-2)) % mod
    A.append(tmp)

ans = 0
for k in range(min(N, M)+1):
    if (M-k) % 2 != 0: continue
    l = (3*M-k)//2
    a = cmb(N-1+l, N-1) * cmb(N, k)
    b = N * (cmb(N-1, k-1)*A[l-M])
    if l >= M+1:
        b += N * cmb(N-1, k)*A[l-M-1]
    #print(k,a-b)
    ans = (ans + a - b) % mod 
print(ans)

# C = set()
# def calc(d, A):
#     if d == M:
#         t = ""
#         for a in A:
#             t += str(a)
#         C.add(t)
#         return
#     for i in range(N):
#         for j in range(N):
#             if i == j: continue
#             B = A[:]
#             B[i] += 2
#             B[j] += 1
#             calc(d+1, B)
#     return

#calc(0, [0]*N)
#print(len(C))
#print(C)


Measured memory_bytes: 331712
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	vector<int> a(7);
    rep(i, 7) {
        cin >> a[i];
    }
    if(a[0] == 0) {
        cout << a[1] + 2 * (a[3] / 2) + 2 * (a[4] / 2) << endl;
        return;
    }
    if(a[3] == 0 || a[4] == 0) {
        cout << a[1] + 2 * (a[0] / 2) << endl;
        return;
    }
    cout << a[1] + max(2 * (a[0] / 2) + 2 * (a[3] / 2) + 2 * (a[4] / 2), 3 + 2 * ((a[0] - 1) / 2)+ 2 * ((a[3] - 1) / 2) + 2 * ((a[4] - 1) / 2)) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
import numpy as np
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

_ = input()
T, A = [int(x) for x in input().split()]
H = [int(x) for x in input().split()]

anser = getNearestValue(H, (T-A)/0.006)
print(anser + 1)


Measured memory_bytes: 21432
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <numeric>
using namespace std;

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

// hi以下の素数を小さい順に返す
// O(hi^1.5)
vector<int> primes_under(int hi) {
    vector<int> primes;
    primes.push_back(2);
    for (int i = 3; i <= hi; i += 2) {
        bool ok = true;
        for (auto p : primes) {
            if (p*p > hi) { break; }
            if (i % p == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            primes.push_back(i);
        }
    }
    return primes;
}

// nを素因数分解する
// 事前条件: primes は sqrt(n) 以下の素数をすべて含んでいなければならない
// O(sqrt(n))
vector<pair<int, int>> prime_factorization(const vector<int>& primes, int n) {
    vector<pair<int, int>> factors;
    for (auto p : primes) {
        if (p*p > n) { break; }
        int cnt = 0;
        while (n % p == 0) {
            n /= p;
            ++cnt;
        }
        if (cnt > 0) {
            factors.push_back({p, cnt});
        }
    }
    if (n > 1) {
        factors.push_back({n, 1});
    }
    return factors;
}

bool is_pairwise_coprime(
    int N, const vector<int>& A, const vector<int>& primes
) {
    unordered_set<int> used_factors;
    REP(i, N) {
        auto factors = prime_factorization(primes, A[i]);
        for (auto f : factors) {
            if (used_factors.find(f.first) != used_factors.end()) {
                return false;
            }
            used_factors.insert(f.first);
        }
    }
    return true;
}

bool is_setwise_coprime(
    int N, const vector<int>& A
) {
    int g = gcd(A[0], A[1]);
    for (int i = 2; i < N; ++i) {
        g = gcd(g, A[i]);
    }
    return g == 1;
}

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    const auto primes = primes_under(1000);

    if (is_pairwise_coprime(N, A, primes)) {
        cout << "pairwise coprime\n";
    } else if (is_setwise_coprime(N, A)) {
        cout << "setwise coprime\n";
    } else {
        cout << "not coprime\n";
    }
}


Measured memory_bytes: 6708
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m=INTM()
    a=LIST()
    print(max(n-sum(a),-1))
if __name__ == '__main__':
    do()

Measured memory_bytes: 9888
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  string s;
  cin >>s;
  int cnt = 0;
  if(s[0] == '+') cnt++;
  if(s[1] == '+') cnt++;
  if(s[2] == '+') cnt++;
  if(s[3] == '+') cnt++;

  cout << -4 + cnt * 2 << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

class Program
{
    public void Proc()
    {
        Reader.IsDebug = false;
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int pointCount = inpt[0];
        int query = inpt[1];

        int[] cnt = new int[pointCount+1];
        for (int i = 0; i < query; i++)
        {
            inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).OrderBy(a => a).ToArray();

            if(inpt[0]==1) {
                cnt[inpt[1]]++;
            } else {
                cnt[inpt[0]]++;
                cnt[inpt[1]]++;
            }
        }
        string ans = "YES";
        if(cnt.Any(a=>a%2>0)) {
            ans = "NO";
        }
        Console.WriteLine(ans);
    
    }




    public class Reader
    {
        public static bool IsDebug = true;
        private static String PlainInput = @"

4 4
1 2
2 4
1 3
3 4

";
        private static System.IO.StringReader Sr = null;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (Sr == null)
                {
                    Sr = new System.IO.StringReader(PlainInput.Trim());
                }
                return Sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
    }
    static void Main()
    {
        Program prg = new Program();
        prg.Proc();
    }
}

Measured memory_bytes: 17828
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  int N;
  cin>>N;
  if(N%2==0){
    cout << (N*(N-2))/2 << endl;
    for(int i=1;i<N;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j==N+1) continue;
        cout << i << " " << j << endl;
      }
    }
  }
  if(N%2==1){
    cout << (N-1)*(N-1)/2 << endl;
     for(int i=1;i<N;i++){
      for(int j=i+1;j<=N;j++){
        if(i+j==N) continue;
        cout << i << " " << j << endl;
      }
    }
  }
}
  
        

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e9;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert


int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    ll T = 1;
    //cin>>T;
    while(T--){
        ll n,m;
        cin>>n>>m;
        ll ans  = n*m;
        ans = (ans+1)/2;
        if(m==1 || n==1)
            ans = 1;
        cout << ans;
    }   
    return 0;
}

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

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

using namespace std;

vector<int> v;

bool Check(int x,int n,int m)
{
	int i = 0,j = 0,l = 0;

	while(i < m && j < n)
	{
		if(l + v[i] <= x)
		{
			l += v[i];
			i++;
		}
		else
		{
			l = 0;
			j++;
		}
	}

	if(i == m && j < n) return true;
	else return false;
}

int main()
{
	int n,m;
	while(cin >> n >> m)
	{
		if(n == 0 && m == 0) break;
		
		v.clear();

		rep(i,m)
		{
			int temp;
			cin >> temp;
			v.push_back(temp);
		}

		int l = 0,r = 1500000;

		rep(i,1000)
		{
			int mid = (l + r) / 2;
			if(Check(mid,n,m)) 
			{
				r = mid;
			}
			else 
			{
				l = mid;
			}
		}	

		cout << r << endl;
	}
	return 0;
}

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

int main(){
	bool *map;
	string str;
	int n, cnt;

	while(1){
		cnt = 0;
		getline( cin, str );
		if( str.size()==0 )	break;
		sscanf(str.c_str(), "%d", &n);
		map = new bool[n+1];
		for( int i=2; i<=n; i++ ){
			map[i] = true;
		}

		for( int i=2; i<=n/2; i++ ){
			for( int j=2*i; j<=n; j+=i ){
				if( map[j] ){
					map[j] = false;
				}
			}
		}

		for( int i=2; i<=n; i++ ){
			if( map[i] ){
				cnt++;
			}
		}
		cout << cnt << endl;
		delete[] map;
		map = 0;
	}
	return 0;
}

Measured memory_bytes: 2056
import sys
for e in sys.stdin:
    H, W = map(int,e.split())
    if H == 0 and W == 0:
        break
    else:
        l = ["#"]*W
        l2 = ["#"] + ["."]*(W-2) + ["#"]
        for i in range(H):
            if i == 0 or i == H-1:
                print("".join(l))
            else:
                print("".join(l2))
            
        print()
            


Measured memory_bytes: 5624
s = list(input())
alph = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
c = 1
m = 0
for i in range(len(s)):
    if i == 0:
        if s[i] != "A":
            c = 0
    elif i == 1 or i == len(s) - 1:
        if not s[i] in alph:
            c = 0
    else:
        if m == 0 and not s[i] in alph:
            if s[i] == "C":
                m += 1
            else:
                c = 0
        elif m == 1 and not s[i] in alph:
            c = 0
if m == 0:
    c = 0
print("AC" if c == 1 else "WA")

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
long dp[3001][3001],a[3000];
int main(){
    int n;
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%ld",&a[i]);
    }
    for(int i=0;i<n;i++){
        if(n%2==1){
            dp[i][n-i-1]=a[i];
        }
        else{
            dp[i][n-i-1]=-a[i];
        }
    }
    for(int i=1;i<n;i++){
        for(int j=0;j+i<n;j++){
            if((n-i)%2==0){
                dp[j][n-j-i-1]=min(dp[j+1][n-j-i-1]-a[j],dp[j][n-j-i]-a[j+i]);
            }
            else{
                dp[j][n-j-i-1]=max(dp[j+1][n-j-i-1]+a[j],dp[j][n-j-i]+a[j+i]);
            }
        }
    }
    printf("%ld\n",dp[0][0]);
}

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

using namespace std;

int main() {
  int n; cin >> n;
  vector<int> r(n);
  for (int i = 0; i < n; i++) { cin >> r[i]; }

  int min_v = r[0];
  int ans = r[1]-r[0];

  for (int i = 1; i < n; i++) {
    ans = max(ans, r[i] - min_v);
    min_v = min(min_v, r[i]);
  }

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


Measured memory_bytes: 3624
#include<bits/stdc++.h>
typedef long long int lli;

#define em emplace_back
#define rep(i,j,n) for(lli i=j;i<n;i++)
#define repf(i,a,j,n) for(lli i=j,a=0;i<n;i++,a++)
#define repg(i,j,n) for(int i=j;i>n;--i)
using namespace std;

void dbg(vector<long long int > v){
  for(long long int i = 0 ; i<v.size(); ++i){
   cerr<<v[i]<<" ";
  }
  cerr<<endl;
}
void prt(vector<long long int > v){
  for(long long int i = 0 ; i<v.size() ; ++i){
   cout<<v[i]<<" "; 
  }
  cout<<endl;
}
 
void solve(){
    lli n;
    cin>>n;
    lli current = 0;
    lli flag = false;
    rep(i,0,n){
        lli a,b;
        cin>>a>>b;
        if(a==b){
            current++;
        }else{
            current = 0;
        }

        if(current==3){
            flag = true;
        }
    }
    if(flag){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
}
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    
 
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main() {
	int N, Q;
	string S;
	cin >> N >> S >> Q;
	vector<set<int>> Dict(26);
	for (int i = 0; i < N; i++) Dict[S[i] - 'a'].insert(i);
	vector<int> Ans;
	for (int q = 0; q < Q; q++) {
		int t;
		cin >> t;
		if (t == 1) {
			int i;
			char c;
			cin >> i >> c;
			i--;
			Dict[S[i] - 'a'].erase(i);
			Dict[c - 'a'].insert(i);
			S[i] = c;
		}
		else {
			int l, r;
			cin >> l >> r;
			l--, r--;
			int num = 0;
			for (int i = 0; i < 26; i++) {
				auto itr = Dict[i].lower_bound(l);
				if (itr != Dict[i].end() && *itr <= r) num++;
			}
			Ans.push_back(num);
		}
	}
	for (int a : Ans) cout << a << endl;
}

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

bool prime(int x){
	int i = 2;
	while (i*i<=x){
		if (x%i == 0){
			return false;
		}
		i++;
	}
	return true;
}

int main(void){
	int X;
	cin >> X;
	
	while (X){
		if (prime(X)) {
			cout << X << endl;
			return 0;
		}
		X++;
	}


	return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=1e5+10,mod=1e9+7;

int main ()
{
    FASTIO
    ll n , m;
    cin >> n >> m;
    vector<ll> h(n+1);
    for(int i=1;i<=n;i++){
        cin >> h[i];
    }
    vector<ll> G[N];
    for(int i=0;i<m;i++){
        ll u ,v;
        cin >> u >> v;
        G[u].pb(v);
        G[v].pb(u);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        bool ok=1;
        for(auto x:G[i]){
            if(h[x]>=h[i]){
                ok=0;
            }
        }
        ans += ok;
    }
    cout << ans << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 9780
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define int   long long
#define ll   long long
#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, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >   
#define vpl vector< pair<ll,ll> >   
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int32_t main()
{                
    IOS;
   /* #ifndef ONLINE_JUDGE
    freopen("int.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif*/
    int n;
    cin>>n;
    vi v(n);

    for(int i=0;i<n;i++)
        {cin>>v[i];v[i]-=(i+1);}
    if(n==1)
    {
        cout<<0;
        return 0;
    }
    sort(v.begin(),v.end());
    int b=v[n/2];
    int ans=0;
    for(int i=0;i<n;i++)
        ans+=abs(v[i]-b);
    if(n%2==0)
    {
        int lans=0;
        b=v[n/2+1];
        for(int i=0;i<n;i++)
            lans+=abs(v[i]-b);
        ans=min(ans,lans);

    }
    cout<<ans;


    

    return 0;
}

Measured memory_bytes: 1792
n = int(input())
A = list(map(int, input().split()))

alice = 0
bob = 0
for i in range(n):
    if (i+1)%2 == 1:
        alice += max(A)
    else:
        bob += max(A)
    A.remove(max(A))
    
print(alice - bob)

Measured memory_bytes: 3060
card=[list(input()) for _ in range(3)]
turn=0
while True:
    if len(card[turn])==0:
        if turn==0:
            print('A')
            break
        elif turn==1:
            print('B')
            break
        else:
            print('C')
            break
    else:
        if card[turn][0]=='a':
            card[turn].pop(0)
            turn=0
        elif card[turn][0]=='b':
            card[turn].pop(0)
            turn=1
        else:
            card[turn].pop(0)
            turn=2

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 21474836000000

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

  vector<vector<double>> dp(1<<n, vector<double>(n, INF));
  vector<vector<int>> prev(1<<n, vector<int>(n,-1));
  rep(i,n) dp[1<<i][i] = 0;
  repl(mask, 1, 1<<n){
    double tw = 70;
    rep(i,n) if(mask&(1<<i)) tw += v[i];
    double vv = 2000.0 / tw;
    rep(i,n) if(dp[mask][i]<INF){
      rep(j,n) if((mask&(1<<j))==0){
        double t = dp[mask][i] + abs(d[i]-d[j])/vv;
        int nmask = mask | (1<<j);
        if(dp[nmask][j] > t){
          dp[nmask][j] = t;
          prev[nmask][j] = i;
        }
      }
    }
  }

  double best=INF;
  int besti;
  int mask = (1<<n) -1;
  rep(i,n) if(best > dp[mask][i]) {best = dp[mask][i]; besti = i;}
  vector<int> res;
  while(besti!=-1){
    int i = besti;
    besti = prev[mask][i];
    mask = mask - (1<<i);
    res.pb(s[i]);
  }
  reverse(all(res));
  rep(i,n) printf("%d%c", res[i], " \n"[i==n-1]);

  return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    bool x = true;
    rep(i, s.size()){
    if((i + 1) % 2 == 1 && s.at(i) != 'L') {
    continue;
    }
    else if((i + 1) % 2 == 0 && s.at(i) != 'R') {
    continue;
    }
    else {
    x = false;
    }
    }
    
    if(x) {
    cout << "Yes";
    }
    else {
        cout << "No";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    int n, m;
    cin >> n >> m;
    dsu d(n);
    int ans = n - 1;
    while (m--) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if (!d.same(a, b)) {
            d.merge(a, b);
            ans--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3748
import numpy as np
n = int(input())
a=np.array(list(map(int,input().split())))
ans = 0
mod = 10**9 + 7
for bit in range(60):
   cnt=np.count_nonzero(a>>bit&1)
   ans += 2**bit * cnt * (n - cnt)
   ans %= mod
print(ans)

Measured memory_bytes: 48820
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);
            int C = int.Parse(str[2]);
            int D = B / A;
            Console.WriteLine("{0}", (D < C)? D: C);
        }
    }
}

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

int main() {
  int A, B;
  cin >> A >> B;
  vector<bool> xs = {
    A % 3 == 0,
    B % 3 == 0,
    (A + B) % 3 == 0
  };
  string s = "Impossible";
  for (const auto& x : xs) if (x) s = "Possible";
  cout << s << endl;
}


Measured memory_bytes: 256