akhauriyash/Code-Regression huggingface dataset:
N = input()

c_list = [str(i) * 3 for i in range(1,10)]
ans_list = [int(x)-int(N) for x in c_list]

upper = 999

ans_index = 0
for i,x in enumerate(ans_list):
  if 0 <= x <= upper:
    ans_index = i
    upper = x
    
print(c_list[ans_index])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

struct UnionFind{
    vector<int> par;

    UnionFind(int n) : par(n,-1) { }
    void init(int n) { par.assign(n,-1); }

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

    bool issame(int x,int y){
        return root(x)==root(y);
    }

    bool merge(int x,int y){
        x=root(x);
        y=root(y);
        if(x==y) return false;
        if(par[x]>par[y]) swap(x,y);
        par[x]+=par[y];
        par[y]=x;
        return true;
    }

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

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

    vector<ll> ans;
    UnionFind uf(n);
    for(int i=m-1;i>=0;i--){
        if(uf.issame(a[i],b[i])) ans.push_back(0);
        else{
            ll x=uf.size(a[i]);
            ll y=uf.size(b[i]);
            ll tmp=x*y;
            ans.push_back(tmp);
        }
        uf.merge(a[i],b[i]);
    }

    reverse(all(ans));
    for(int i=1;i<m;i++) ans[i]+=ans[i-1];

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


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    vector<lint> vec; map<lint, int> mp;
    rep(i, n){
        lint x; cin >> x;
        vec.push_back(x); mp[x]++;
    }
    sort(all(vec));

    lint res = 0;
    repr(i, n){
        if(mp[vec[i]] == 0) continue;
        lint s = 1;
        while(s <= vec[i]) s *= 2;
        s -= vec[i];

        if(s == vec[i] && mp[s] > 1){
            mp[s] -= 2; res++;
        }
        if(s != vec[i] && mp[s] > 0){
            mp[vec[i]]--; mp[s]--; res++;
        }
    }
    out(res);
}

Measured memory_bytes: 26864
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        int a = int.Parse(input[2]);
//        int b = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
        if(n%m==0){
            WriteLine("0");
        }else{
            WriteLine("1");
        }
    }
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> p(n);
    rep(i, n) cin >> p[i].first >> p[i].second;

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

    ll ans = 0;
    rep(i, n) {
        if (p[i].second < m) {
            ans += p[i].first * p[i].second;
            m -= p[i].second;
        } else {
            ans += p[i].first * m;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
X, Y = map(int, input().split())
ret = 0
if X == 1:
    ret += 300000
elif X == 2:
    ret += 200000
elif X == 3:
    ret += 100000

if Y == 1:
    ret += 300000
elif Y == 2:
    ret += 200000
elif Y == 3:
    ret += 100000
if X == 1 and Y == 1:
    ret += 400000
print(ret)

Measured memory_bytes: 3064
N, K, C = map(int,input().split())
S = list(input())

A = list()
B = list()

i = 0
num = 0
while num < K:
  if S[i] == "o":
    A.append(i)
    num += 1
    i += C
  i += 1
i = len(S)-1
num = 0
while num < K:
  if S[i] == "o":
    B.append(i)
    num+=1
    i -= C
  i -= 1
B.sort()

for i,j in zip(A,B):
  if i == j:
    print(i+1)

Measured memory_bytes: 21996
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
using namespace std;
int main() {
	int n, v[50];
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> v[i];
	sort(v, v + n);
	double sum = (v[0] + v[1]) / 2.0;
	for (int i = 1; i < n - 1; ++i) {
		sum = (sum + v[i + 1]) / 2.0;
	}
	printf("%.6f\n", sum);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007

    using namespace std;
    void solve()
    {
         int i,j,r=200,n,m,p,q,y=0,k,ans=0,d;
       cin>>n>>k; if(k==1) {cout<<0; return;}
       rep(i,1,k)
        {
            n--;
        }
    cout<<n-1;





    }



    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

bool hoge(string a){
	return true;
}
int main(){
	string s;
	cin>>s;
	ll end1=(s.size()-3)/2;
	REP(i,end1+1){
		if(s[i]!=s[s.size()-1-i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	ll end2=(end1+1)/2;
	REP(i,end2+1){
		if(s[i]!=s[end1-i]){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, input().split())
if a < c:
        if b < c:
                print(0)
        if c <= b <= d:
                print(abs(b-c))
        if d < b:
                print(abs(d-c))
if c <= a:
        if d < a:
                print(0)
        if a <= d <= b:
                print(abs(d-a))
        if b < d:
                print(abs(b-a))

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

using namespace std;
typedef long long int ll;
int main() {
    
    ll i, dap=0;
    string s, t;
    cin>>s;
    cin>>t;
    for(i=0;i<s.length();i++)
    dap+=(s[i]!=t[i]);
    
    cout<<dap;
    
    return 0;
}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;


signed main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(m), sc(n + 1, 0);
    rep(i, 0, m) cin >> a[i];
    rep(i, 0, m){
        vector<int> d(n + 1);
        rep(j, 1, n + 1) cin >> d[j];
        int cnt = 0;
        rep(j, 1, n + 1){
            if(d[j] == a[i]){
                cnt++;
                sc[j]++;
            }
        }
        sc[a[i]] += n - cnt;
    }
    rep(i, 1, n + 1){
        cout << sc[i] << endl;
    }
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
#include <cstdio>
#include <cmath>
using namespace std;
int n;
double x[1005], y[1005], X, Y, d, e;
double dist(double a, double b) {
    return a*a + b*b;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lf%lf", &x[i], &y[i]);
        X += x[i]; Y += y[i];
    }
    X /= n; Y /= n;
    double P = 0.1;
    for (int i = 0; i < 30000; i++) {
        int f = 0;
        d = dist(X - x[0], Y - y[0]);
        for (int j = 1; j < n; j++) {
            e = dist(X - x[j], Y - y[j]);
            if (d < e) { d = e; f = j; }
        }
        X += (x[f] - X)*P;
        Y += (y[f] - Y)*P;
        P *= 0.999;
    }
    cout << fixed << setprecision(10) << sqrt(d) << endl;
}

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

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

  int ans = 0;
  for (int i = 0; i <= N - 3; i++) {
    if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
// abc177-A
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>

using namespace std;
typedef double dou;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	dou a,b,c;
	cin>>a>>b>>c;
	if (b>=a/c)
	cout<<"Yes"<<endl;
	else 
	cout<<"No"<<endl;
	return 0;	
}

Measured memory_bytes: 3720
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    int d, e, f;
    d = a;
    e = b;
    f = c;
    a = f;
    b = d;
    c = e;
    cout << a << " " << b << " " << c <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a>b) swap(a, b);
	if (b>c) swap(b, c);
	if (a>c) swap(a, c);
	if (a>b) swap(a, b);
	cout << a << " " << b << " " << c << endl;
	return 0;
}


Measured memory_bytes: 3120
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    ll n, p; cin >> n >> p;
    vector<pll> div = prime_factorize(p);
    ll res = 1;
    for(auto d: div){
        int num = d.second;
        while(num >= n){
            res *= d.first;
            num -= n;
        }
    }
    if(n==1) res = p;
    cout << res << ln;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define allsort(v) sort(v.begin(),v.end())
const ll mod = 1e9 + 7;
const int inf = 1e9;

int main() {
	cin.sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int>a(N);
	int mina = 100, maxa = -100;
	for (auto &x : a) {
		cin >> x;
		mina = min(mina, x);
		maxa = max(maxa, x);
	}
	int ans = inf;
	int sum = 0;
	reps(i, mina, maxa + 1) {
		for (auto x : a)sum += (i - x)*(i - x);
		ans = min(ans, sum);
		sum = 0;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,i,k;
	
	scanf("%d",&n);
	
	for(i=1;i<=n;i++){
		if(i%3==0){
			printf(" %d",i);
			continue;
		}
		else{
			int j=i;
			for(k=10000;k>=1;k/=10){
				if(j/k==3){
					printf(" %d",i);
					break;
				}
				j%=k;
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1028
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int k = readint;
    int even = k / 2;
    writeln(even * (k - even));
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  
  ll man = 0;
  
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      man += d[i]*d[j];
    }
  }
  
  cout << man << endl;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int r, D, x; cin >> r >> D >> x;
	vector<ll> xi(11, x);
	rep(i, 10) {
		xi[i+1] = r * xi[i] - D;
		cout << xi[i+1] << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

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

  int ans = 0;

  int c = 0;
  for(int i = N - 1; i > 0; i--) {
    if(H[i-1] < H[i]) {
      c = 0;
    } else {
      c++;
      ans = max(ans, c);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
    int A,B;
    scanf("%d %d",&A,&B);

    char S[A+B+1];

    scanf("%s",&S);

    int flag=0;

    for(int i=0; i<A; i++){
        if(S[i]<48 || S[i]>57){
            flag=1;
            goto x;
        }
    }


    if(S[A]=='-'){flag=0;}
    else{flag=1;goto x;}

    for(int i=A+1; i<A+B+1; i++){
            if(S[i]<48 || S[i]>57){
                    flag=1;
                    goto x;
                }
    }


    x:
    if(flag==1){
        printf("No");
    }
    else{
        printf("Yes");
    }
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int s[3],i,j,tmp;
  for(i=0;i<3;i++){
    scanf("%d",&s[i]);
  }
  for(i=2;i>=0;i--){
    for(j=0;j<i;j++){
      if(s[j]>s[j+1]){
        tmp=s[j+1];
        s[j+1]=s[j];
        s[j]=tmp;
         }
      }
    }
    printf("%d",s[2]*10+s[1]+s[0]);
    return 0;
  }

Measured memory_bytes: 128
import collections

N = int(input())
D = map(int, input().split())
M = int(input())
T = map(int, input().split())

DC = collections.Counter(D)

for t in T:
    if t in DC:
        if DC[t] > 0:
            DC[t] -= 1
            continue

    print('NO')
    break

else:
    print('YES')


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

int main() {
	int N;
	cin >> N;
	vector<int>a(N);
	rep(i, N) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	int Alice = 0, Bob = 0;
	rep(i, N) {
		if (i % 2 == 0) {
			Alice += a.at(i);
		}
		else {
			Bob += a.at(i);
		}
	}
	cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
from collections import deque

H,W = map(int, input().split())
board = [["#"]*(W+2)]
for i in range(H):
    board.append(["#"]+list(input())+["#"])
board.append(["#"]*(W+2))
board[H][W] = "g" 

# #を数えておく
cntsharp = 0
for i in range(1,H+1):
    for j in range(1,W+1):
        if board[i][j] == "#":
            cntsharp += 1

# BFS
seen = [[-1] * (W+2) for i in range(H+2)]
seen[1][1] = 0 # 始めどこから行くか
q = deque([[1,1,1]]) #h,w,p
mvs = [(1,0),(-1,0),(0,1),(0,-1)]

while len(q) > 0:
    h,w,p = q.popleft()
    for dh,dw in mvs: 
        next_h = h + dh
        next_w = w + dw
        next_p = p + 1
        if seen[next_h][next_w] == -1 and board[next_h][next_w] != "#":
            seen[next_h][next_w] = next_p
            q.append([next_h,next_w,next_p])
            
if seen[H][W] == -1:
    print(-1)
else:
    print(H*W-cntsharp-seen[H][W])

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;

int main()
{
	string s;
	cin >> s;
	int g_cnt = 0;
	int point = 0;
	rep(i, s.size())
	{
		char opp_hand = s[i];
		if (g_cnt>0)
		{
			if (opp_hand=='g')
			{
				point++;
				g_cnt--;
			}
			else
			{
				g_cnt--;
			}
		}
		else
		{
			if (opp_hand == 'g')
			{
				g_cnt++;
			}
			else
			{
				point--;
				g_cnt++;
			}
		}
	}
	co(point);
	return 0;
}


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

int main()
{
	int w;
	while(cin >> w, w>=0)
	{
		int a = 4280-1150;
		
		if(w>30)
		{
			a -= (w-30)*160;
			w  = 30;
		}
		if(w>20)
		{
			a -= (w-20)*140;
			w  = 20;
		}
		if(w>10)
		{
			a -= (w-10)*125;
		}

		cout << a << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
  int m; //???????????????????????°
  cin >> m;
  do {
    string w; //?????????????????????
    cin >> w;
    
    int s;
    s = w.size(); //???????????°???s??¨??????
    set<string> a; //??????????????\??£??????????????????????´?????????????
    
    for (int i = 0; i < s; i++) { //i+1???????????????????????????(1~i??¨i+1~s, ??????????????¨??????)
      string w1 = w.substr(0, i); //??????????????????w1??????????????????
      string w2 = w.substr(i, s - i); //??????????????????w2??????????????????
      
      for (int j = 0; j < 2; j++) {
	//?????????????????¨????????????????????\???????????????
	if (j == 0) {
	  for (int k = 0; k < 4; k++) {
	    //???r???????????´???????????????????????\?????????4??????
	    string w3 = w1, w4 = w2; //w1,w2???????£?
	    if (k == 0) {
	      string w_ans = w3 + w4;
	      a.insert(w_ans);
	    }
	    else if (k == 1) {
	      reverse(w3.begin(), w3.end());
	      string w_ans = w3 + w4;
	      a.insert(w_ans);
	    }
	    else if (k == 2) {
	      reverse(w4.begin(), w4.end());
	      string w_ans = w3 + w4;
	      a.insert(w_ans);
	    }
	    else if (k == 3) {
	      reverse(w3.begin(), w3.end());
	      reverse(w4.begin(), w4.end());
	      string w_ans = w3 + w4;
	      a.insert(w_ans);
	    }
	  }
	}
	//?????????????????¨????????????????????\????????????
	else {
	  for (int k = 0; k < 4; k++) {
	    //?????????????????´???????????????????????\?????????4???
	    string w3 = w1, w4 = w2; //w1,w2???????£?
	    if (k == 0){
	      string w_ans = w4 + w3;
	      a.insert(w_ans);
	    }
	    else if (k == 1) {
	      reverse(w3.begin(), w3.end());
	      string w_ans = w4 + w3;
	      a.insert(w_ans);
	    }
	    else if (k == 2){
	      reverse(w4.begin(), w4.end());
	      string w_ans = w4 + w3;
	      a.insert(w_ans);
	    }
	    else if (k == 3) {
	      reverse(w3.begin(), w3.end());
	      reverse(w4.begin(), w4.end());
	      string w_ans = w4 + w3;
	      a.insert(w_ans);
	    }
	  }
	}
      }
    }
    cout << a.size() << endl; //??¨?¨?????????????
  } while (--m > 0);
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 1000000007;

void solve(long long N, long long K){
  ll ans=0;
  vector<ll> X(N+1);
  iota(X.begin(),X.end(),0LL);
  vector<ll> sum(N+1);
  partial_sum(X.begin(),X.end(),sum.begin());
  FOR(i,K,N+2){
    if(i==N+1){
      ++ans;
      continue;
    }
    ll mini,maxi;
    mini=sum[i-1];
    maxi=sum[N]-sum[N-i];
    ans+=maxi-mini+1;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    solve(N, K);
    return 0;
}


Measured memory_bytes: 6332
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define ll long long
#define lowbit(x) (x&-x) 
using namespace std;
const int maxn = 10;
int n;
int p[maxn] , q[maxn] , tree[maxn];
ll f[maxn];
void init() {
	f[0] = 1;
	for(register int i = 1; i <= n; ++i)
		f[i] = i * f[i - 1];
}
inline void update(int x) {
	for(register int i = x; i <= n; i += lowbit(i)) 
		tree[i] += 1;
}
inline ll query(int x) {
	ll ret = 0;
	for(register int i = x; i; i -= lowbit(i)) 
		ret += tree[i];
	return ret;
}
ll cantor(int *a) {
	memset(tree , 0 , sizeof(tree));
	ll ret = 0;
	for(register int i = 1; i <= n; ++i) {
		ll cnt = query(a[i]); //Çó³öÒÑ¾­ÓÐ¶àÉÙ¸öÐ¡ÓÚa[i]µÄÊýÒÑ¾­³öÏÖÁË 
		update(a[i]);
		ret += (a[i] - cnt - 1) * f[n - i];
	}
	return ret + 1; //ÓÉÓÚ×ÖµäÐò´Ó1¿ªÊ¼£¬ËùÒÔ¼Ó1 
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n;
	for(register int i = 1; i <= n; ++i) cin >> p[i];
	for(register int i = 1; i <= n; ++i) cin >> q[i];
	init();
	ll a = cantor(p) , b = cantor(q);
	cout << abs(a - b) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<long long> A(3*N);
  for(int i=0; i<3*N;i++){
    cin>> A.at(i);
  }
  sort(A.begin(),A.end());
  long long sum =0;
  for(int i= 0; i<N;i++){
    sum += A.at(2*i+N);    
  }
  cout<< sum <<endl;
}

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

int main() {
  int k,s;cin>>k>>s;
  int ans = 0;
  rep(x,k+1) rep(y,k+1) {
    int wk = s-x-y;
    if(wk>=0&&wk<=k) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

queue<ll> q;

struct Node{
    bool visited;
    vector<ll> par;
    ll muki;
    ll from;
};
Node node[200000];

void bfs(ll index){
    q.pop();
    node[index].visited=true;
    rep(i, node[index].par.size()){
        if(!node[node[index].par[i]].visited){
            node[node[index].par[i]].visited=true;
            q.push(node[index].par[i]);
            node[node[index].par[i]].from=index;
        }
    }
    //cout<<index<<q.size()<<endl;
    if(!(q.size()==0)) bfs(q.front());
}

int main(void){
    ll N, M;
    cin>>N>>M;
    rep(i, N) node[i].visited=false;
    ll A, B;
    rep(i, M){
        cin>>A>>B;
        node[A-1].par.push_back(B-1);
        node[B-1].par.push_back(A-1);
    }
    node[0].from=-1;
    q.push(0);
    bfs(0);
    cout<<"Yes"<<endl;
    rep(i, N-1){
        cout<<node[i+1].from+1<<endl;
    }
    return 0;
}


Measured memory_bytes: 19264
a1,b1=input().split()
a2,b2=input().split()
a3,b3=input().split()
lista=[a1,a2,a3,b1,b2,b3]
yn=0
for i in range(1,5):
    if lista.count(str(i))==0 or lista.count(str(i))>2:
        yn=1
        break
if yn==1:
    print("NO")
else:
    print("YES")


Measured memory_bytes: 3060
while gets do
  n = $_.chomp.to_i
  next if n == 0
  sums = Hash.new(0)
  n.times do
    i, p , q = gets.split
    sums[i] += p.to_i * q.to_i
  end
  sums.delete_if{|k, v| v < 1_000_000}
  if sums.size == 0
    puts "NA"
  else
    puts sums.keys
  end
end

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

using ll = long long;
using ld = long double;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll a, b, h, m; cin >> a >> b >> h >> m;
	ll d = 60 * h + m;

	ld diff = 5.5 * d;

	std::cout << fixed << setprecision(10)  << sqrt(a*a + b*b - 2*a*b*cos(diff*(M_PI)/180)) << std::endl;
}

Measured memory_bytes: 4164
#include<bits/stdc++.h>
#define fastio     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl       '\n'
#define MAX        1000000
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    ll a ; double b;
    cin>>a>>b;
    ll d=round(b*100);
    ll ans=a*d;
    ans/=100;
    cout<<ans;

}





int main(){
    fastio
    int test=1;
    while(test--)
        solve();
    return 0;
}


Measured memory_bytes: 3744
n=gets.to_i
x=Array.new(n){Array.new()};y=Array.new(n){Array.new()}
a=[]
n.times{|i|
  a[i]=gets.to_i;a[i].times{|j| x[i][j],y[i][j] = gets.split.map &:to_i}
}
ans=0
[0,1].repeated_permutation(n).to_a.each{|k|
  dame=0
  n.times{|z|
    next if k[z]==0
    a[z].times{|q|dame=1 if (y[z][q])!=k[x[z][q]-1]}
  }
  ans=[ans,k.sum].max if dame==0
}
puts ans


Measured memory_bytes: 21448
import java.util.Scanner;

public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int N = in.nextInt();
		int M = in.nextInt();
		int[] ALL = new int[N+M];
		for(int i=0;i<N;i++) {
			ALL[i] = 2;
		}
		for(int i=N;i<N+M;i++) {
			ALL[i] = 1;
		}

		int answer = 0;
		for(int i=0;i<N+M-1;i++) {
			for(int j=i+1;j<N+M;j++) {
				if ((ALL[i] + ALL[j]) % 2 == 0) answer++;
			}
		}


		System.out.println(answer);
	}


	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

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

int r, c, countR[100], countC[100], temp;
char a[100][100];

int main(){
	cin >> r >> c;

	for(int row=0; row<r; row++){
		temp = 0;
		for(int col=0; col<c; col++){
			cin >> a[row][col];
			if(a[row][col] == '.'){
				countC[col]++;
				temp++;
			}
		}
		if(temp==c){
			countR[row]++;
		}
	}

	for(int row=0; row<r; row++){
		if(countR[row]){
			continue;
		}
		for(int col=0; col<c; col++){
			if(countC[col] == r){
				continue;
			}
			cout << a[row][col];
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define p 1000000007
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x = 0; char zf = 1; char ch = getchar();
    while (ch != '-' && !isdigit(ch)) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int i,j,k,m,n,x,y,z,cnt,sum,ans;
int jc[200010],njc[200010],inv[200010],e2[200010];
int f1[200010],f2[200010];
int C(int x,int y){
	return 1ll*jc[x]*njc[y]%p*njc[x-y]%p;
}
int main(){
	n=r;m=r;swap(n,m);
	for(rt i=0;i<2;i++)jc[i]=njc[i]=inv[i]=1;
	for(rt i=2;i<=n+m;i++){
		jc[i]=1ll*jc[i-1]*i%p;
		inv[i]=1ll*inv[p%i]*(p-p/i)%p;
		njc[i]=1ll*njc[i-1]*inv[i]%p;
	}
	e2[0]=1;e2[1]=inv[2];
	for(rt i=2;i<=n+m;i++)e2[i]=1ll*e2[i-1]*inv[2]%p;
	for(rt i=n;i<=n+m;i++)f1[i]=(f1[i-1]+1ll*e2[i]*C(i-1,n-1)%p)%p;
	for(rt i=m;i<=n+m;i++)f2[i]=(f2[i-1]+1ll*e2[i]*C(i-1,m-1)%p)%p;
	for(rt i=0;i<n+m;i++)writeln(((f1[i]+(1ll-f1[i]-f2[i])*inv[2]%p)%p+p)%p);
    return 0;
}








Measured memory_bytes: 6144
import java.io.*;
import java.math.*;
import java.util.*;
import java.lang.*;

// import java.text.DecimalFormat; 
// import java.text.DecimalFormatSymbols; 
/*
caba
abc
  
 */

public class Main {

	
	
    public static void main(String args[] ) throws Exception {
        PrintWriter pw=new PrintWriter(System.out);
        FastScanner sc = new FastScanner();
        
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int n = s.length;
        int m = t.length;
        int max = 0;
        for(int i=0;i<n-m+1;i++) {
        	int c=0;
        	int in=0;
        	for(int j=i;j<i+m;j++) {
        		if(s[j]==t[in]) {
        			c++;
        		}
        		in++;
        	}
        	max = Math.max(max, c);
        }
        
        
        
        pw.print(t.length-max);
        pw.close();
    }
    
    
    
    
    
    
   
   static <T> void deb(T x){
       System.out.println(x);
   }
   
   
   static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		public String next(int k) {
			try {
				return br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "Not able to read";
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		double nextDouble() {
			return Double.parseDouble(next());
		}
		
	    
	}
   
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n, i);
  out(n - i + 1);
}


Measured memory_bytes: 3624
from collections import Counter

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

c=Counter(a)

def eratosthenes(lim):
  is_p=[1]*lim
  is_p[0]=1
  is_p[1]=1

  for i in set(a):
    if is_p[i]:
      for j in range(i*2,lim,i):
        is_p[j]=0

  return is_p

lim=10**6+5
is_p=eratosthenes(lim)

cnt=0
for i in a:
  if is_p[i]==1 and c[i]==1:
    cnt+=1

print(cnt)

Measured memory_bytes: 162320
#include<iostream>
using namespace std;
int main() {
	int r, g,b,x;
	cin >> r >> g >> b;
	//x = r * 100 + g * 10 + b;
	if ((10*g+b)%4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>

#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long int

using namespace std;

int main(void) {
    int s=0 , t=0;
    REP(i,4){
        int a;
        cin >> a;
        s+=a;
    }
    REP(i,4){
        int a;
        cin >> a;
        t+=a;
    }
    cout << max(s,t) << endl;
    
    return 0;
}

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  ll d, n , ans =1 ;
  cin >> d >> n ;

  if(n==100)n++ ;
  for(int i = 0 ; i<d ;i++) ans*=100 ;
  ans*=n ;
  cout << ans << endl ;
	
  return 0 ;
}

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

int len2;
long long suma;
char s2[30];
void tomo(int pos){
    if(pos==len2){
        long long sum=0;
        for(int i=1; i<=len2+1; i+=2){
            if(s2[i]=='+' || i==len2){
                long long pot=1, num=0;
                for(int j=i-1; j>=0; j--){
                    if(s2[j]=='+')
                        break;
                    if(s2[j]>='1' && s2[j]<='9'){
                        num+=(s2[j]-'0')*pot;
                        pot*=10;
                    }
                }
                sum+=num;
            }
        }
        suma+=sum;
        return;
    }
    if(s2[pos]>='1' && s2[pos]<='9')
        tomo(pos+1);
    else{
        s2[pos]='+';
        tomo(pos+1);
        s2[pos]=' ';
        tomo(pos+1);
    }
}

int main(){
    string s;
    cin>>s;
    int len=s.length(), pos=0;
    len2=len*2-1;
    for(int i=0; i<len2; i++){
        if(i%2==0){
            s2[i]=s[pos];
            pos++;
        }
        else
            s2[i]=' ';
    }
    tomo(1);
    printf("%lld", suma);
return 0;
}


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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int count=0;
  for(int i=0;i<N-2;++i){
    if(S[i]=='A'){
      if(S[i+1]=='B'){
        if(S[i+2]=='C'){
          ++count;
        }
      }
    }
  }
  cout<<count<<endl;

}

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

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

int main() {

    int a, b;
    char op;

    while(1) {
        scanf("%d %c %d", &a, &op, &b);
        if(op == '+') {
            printf("%d\n", a + b);
        } else if(op == '-') {
            printf("%d\n", a - b);
        } else if(op == '*') {
            printf("%d\n", a * b);
        } else if(op == '/') {
            printf("%d\n", a / b);
        } else {
            break;
        }
    }

    return 0;
}



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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << 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; }

int main()
{   
    int k;
    cin >> k;
    int x = 7%k;
    set<int> s;
    int i = 1;
    while(s.count(x) == 0) {
        s.insert(x);
        if(x == 0) {
            cout << i << endl;
            return 0;
        }
        x = (x*10+7)%k;
        i++;
    }
    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 50460
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/arc077/tasks/arc077_c>
 問題文============================================================
 E - guruguru
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class T>
struct cum_sum_linear{
    int n;
    vector<T> x,a,b;
    cum_sum_linear(int n_ = 0) : n(n_), x(n), a(n+1), b(n+1){}

    // 区間[l,r)に対して、
    // x_l += c , x_l+1 += c + d , x_l+2 = c + 2*d, x_l+r = c + (r-l)*d
    // を加算する
    void add(int l,int r, T c, T d){
        a[l] += c; a[r] -= c;
        a[l] -= d*l; a[r] += d*l;
        b[l] += d; b[r] -= d;
    }
    void fix(){
        for(int i = 0; i < n;i++){
            x[i] = a[i] + b[i]*i;
            a[i+1] += a[i];
            b[i+1] += b[i];
        }
    }
    T operator[](int i) const { return x[i]; }
};
template<class Type>
Type solve(Type res = Type()){
    int n,m; cin >> n >> m;
    vector<ll> a(n); for(auto& in:a) cin >> in;

    ll sum = 0;
    cum_sum_linear<ll> x(2*m+1);
    for(int i = 1; i < n;i++){
        ll l = a[i-1], r = a[i];
        if(r < l) r += m;

        sum += r-l;

        x.add(l+1,r+1,0,1);
    }
    x.fix();

    res = LINF;
    for(int i = 1; i <= m;i++){
        res = min(res,sum - x[i] - x[i+m]);
    }

    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<ll>() << endl;
    return 0;
}

Measured memory_bytes: 8648
#include <bits/stdc++.h>
 
//BIAR MANTAB LAH YA
#define Willy using
#define Indrayana namespace
#define Komara std
 
Willy Indrayana Komara;

bool besarDulu(const int &a, const int &b)
{
    return a > b;
}

bool tupleSort(tuple<int, int, int> &a, tuple<int, int, int> &b)
{
    return get<2>(a) > get<2>(b);
}

using ll = long long int;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int i;
    cin >> i;
    cout << a[i-1] << endl;
    return 0;
}


Measured memory_bytes: 256
using System;


namespace AtCoderBeginnerContest177
{
    class Program
    {
        static void Main(string[] args)
        {

            // 課題C：Sum of product of pairs(2020/8/29)

            int num = int.Parse(Console.ReadLine());
            string[] numSet = Console.ReadLine().Split(' ');

            long ans = 0;
            long sum = 0;
            int modValue = 1000000007;
            int cnt = num - 1;

            for (int i = cnt; i > 0; i--)
            {
                sum = (sum + int.Parse(numSet[i])) % modValue;
                ans = ans + int.Parse(numSet[i-1]) * sum % modValue;
            }

            Console.Write(ans % modValue);
        }

    }
}


Measured memory_bytes: 45512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int main(void){
char w[105];
int al[36];
for(int i=0;i<=35;i++){
    al[i]=0;
}
scanf("%s",w);
for(int i=0;w[i]!='\0';i++){
    al[w[i]-'a']++;
}
for(int i=0;i<=35;i++){
    if(al[i]%2==1){printf("No");return 0;}
}
printf("Yes");return 0;
}

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

using namespace std;

#define rep(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define drep(i, a, n) for (int i = a, _n = n; i >= n; --i)
#define debug(x) cout << #x <<" = "<< x << endl

int n, k;

int main () {
	scanf ("%d%d", &n, &k);
	if (k > (n - 2) * (n - 1) / 2) {
		puts("-1");
		return 0;
	}

	int t = (n - 2) * (n - 1) / 2, m = n - 1;

	while (t > k) --t, ++m;

	printf ("%d\n", m);

	rep(i, 2, n) printf ("%d %d\n", 1, i);

	m -= n - 1;	

	rep(i, 2, n) rep(j, i + 1, n) {
		if (m == 0) return 0;
		--m;
		printf ("%d %d\n", i, j);
	}

	return 0;
}


Measured memory_bytes: 256
//123 A
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <vector>
using namespace std;

int main(){
  int a[5];
  for(int i=0;i<5;i++) cin>>a[i];
  int k; cin>>k;
  string ans;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(a[j]-a[i]>k){
        ans=":(";
        break;
      }
    }
  }
  if(ans==":(") cout<<ans<<endl;
  else cout<<"Yay!"<<endl;
  return 0;
}  

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N;
	string S;

	cin >> N >> S;

	vector<vector<Int>> dp(N+1, vector<Int>(N+1));//dp[i][j]: i文字目以降およびj文字目以降の共通部分文字列長さ（この段階では被りOK）
	for (Int i = N - 1; i >= 0; i--) {
		for (Int j = N - 1; j >= 0; j--) {
			if (S[i]!=S[j]) {
				dp[i][j] = 0;
			}
			else {
				dp[i][j] = dp[i + 1][j + 1] + 1;
			}
		}
	}

	Int ans = 0;
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			if (i >= j) {
				continue;
			}
			else {
				ans = max(ans, min(dp[i][j], j - i));
			}
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 195840
/*
11111111
00000110
00001100
00011000
00110000
01100000
*/
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<queue>
#include<vector>
#define ll long long
#define F first
#define S second
#define debug(x); printf("debug%d\n",x);
#define rep(f,t) for(int i=f;i<=t;i++)
const int inf=0x3f3f3f3f;
using namespace std;
const int N=1e5+5;
int A,B,M;
int a[N],b[N];
int x,y,z;
int main()
{
    scanf("%d%d%d",&A,&B,&M);
    int maxx=inf;
    int minn=inf;
    int minn2=inf;
    for(int i=1;i<=A;i++)
    {
        scanf("%d",&a[i]);
        minn=min(minn,a[i]);
    }
    for(int i=1;i<=B;i++)
    {
        scanf("%d",&b[i]);
        minn2=min(minn2,b[i]);
    }
    for(int i=1;i<=M;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        maxx=min(maxx,a[x]+b[y]-z);
    }
    printf("%d\n",min(maxx,minn+minn2));
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>

int n;
int a[1024 * 1024];

int count;

int swap(int x, int y) {
	int h = a[x];
	a[x] = a[y];
	a[y] = h;
	count++;	
	//for(int i = 1; i <= n; i++) {
	//	printf("%d ", a[i]);
	//}
	//printf("\n");
}

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	
	if(a[1] == 1) {
		swap(1, 2);
		for(int i = 2; i <= n; i++) {
			if(a[i] == i && a[i + 1] != i + 1) {
				swap(i, i - 1);
			} else {
				if(a[i] == i && a[i + 1] == i + 1) swap(i, i + 1);
			}
		}
	} else {
		for(int i = 2; i <= n; i++) {
			if(a[i] == i && a[i + 1] != i + 1) {
				swap(i, i - 1);
			} else {
				if(a[i] == i && a[i + 1] == i + 1) swap(i, i + 1);
			}
		}
	}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 512
x_1, y_1, x_2, y_2 = map(int, input().split())
X = x_2 - x_1
Y = y_2 - y_1
x_3 = x_2 - Y
y_3 = y_2 + X
x_4 = x_3 - X
y_4 = y_3 - Y
print(x_3, y_3, x_4, y_4)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x, t;
  cin >> x >> t;
  cout << max(0LL, x - t) << endl;
}

Measured memory_bytes: 3592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int main(){
	int N,a[2][2]={{0,0},{0,0}},i,k,now=0,min;
	char ss[100001];
	scanf("%s",&ss);
	N=strlen(ss);

	for(i=0;i<N;i++){
		k=ss[i]-'0';
		a[now][k]++;
		now=(now+1)%2;
	}

	min=a[0][1]+a[1][0];
	if(min>a[1][1]+a[0][0])min=a[1][1]+a[0][0];
	printf("%d",min);
	return 0;
}

Measured memory_bytes: 256