akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main() {
	int n; cin >> n;
	map<int, int> mp;
	int kind = 0,maxx=0;
	rep(i, 0, n) {
		int p; cin >> p;
		if (p >= 3200) {
			maxx++;
			continue;
		}
		else if (mp[p / 400] == 0) {
			mp[p / 400]++;
			kind++;
		}
	}
	printf("%d %d", max(1,kind), kind + maxx);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    string s,ans;
    cin >> s;
    rep(i,s.size()){
        if(s[i]=='0')ans.push_back('0');
        if(s[i]=='1')ans.push_back('1');
        if(s[i]=='B'&&ans!="")ans.erase(ans.size()-1,1);
    }
    cout << ans << endl;
}


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


using namespace std;

using vi=vector<int>;


int main(void)
{
	int n;

	while(scanf("%d", &n)==1)
	{
		vi h(n);

		for(int i=0;i<n;i++) scanf("%d", &h[i]);

		int ans=0;
		for(;;)
		{
			for(;h.size();)
			{
				if(h[0]>0) break;
				h.erase(h.begin());
			}
			if(h.size()<=0) break;
			for(int i=0;i<h.size();i++)
			{
				if(h[i]<=0) break;
				h[i]--;
			}
			ans++;
		}
		printf("%d\n", ans);
	}

	return 0;
}


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

int main(int argc, char const *argv[])
{
	int r; cin >> r;
	if (r < 1200) printf("ABC\n");
	else if (r < 2800) printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 2e5 + 5, LG = 19, MOD = 1e9 + 7;
const int SQ =225;
const long double EPS = 1e-7;
vector<int>p;
int get(int i){return i == p[i] ? i : p[i]=get(p[i]);}
int cnt =0;
void mrg(int u, int v){
  if(get(u)==get(v))return;
  cnt++;
  p[get(v)] = get(u);
}
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  int n, q;
  ll m;

  cin >> n >> m >> q;
  p.resize(n);
  iota(p.begin(),p.end(),0);
  vector<ii> nonBridges;

  f(i,0,q){
    int u, v, c;
    cin >> u >> v >> c;
    if(c)
      nonBridges.pb(ii(u,v));
    else
      mrg(u,v);
  }

  if(m == n - 1){
    if(nonBridges.size())
      cout << "No\n";
    else
      cout << "Yes\n";
    return 0;
  }

  for(auto x : nonBridges)
  if(get(x.F)==get(x.S)){
    cout << "No\n";
    return 0;
  }

  if(m <= cnt + 1ll*(n-cnt)*(n-cnt-1)/2)
    cout<<"Yes\n";
  else
    cout<<"No\n";


  return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
	int i,n,max_v=0,min_v=1000000001,pos,tmp,t1,t2;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		max_v=max(max_v,a[i]);
	}
	if(max_v%2==0)
	{
		t1=(max_v-1)/2;
		t2=t1+1;
		for(i=0;i<n;i++)
		{
			tmp=min(abs(a[i]-t1),abs(a[i]-t2));
			if(tmp<min_v)
			{
				min_v=tmp;
				pos=a[i];
			}
		}
	}
	else
	{
		tmp=(max_v-1)/2;
		for(i=0;i<n;i++)
		{
			if(abs(a[i]-tmp)<min_v)
			{
				min_v=abs(a[i]-tmp);
				pos=a[i];
			}
		}
	}
	printf("%d %d",max_v,pos);
	return 0;
}

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

#define FOR(i,a,b)    for (int i=(a)  ;i<(b) ;i++)
#define RFOR(i,a,b)   for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)      for (int i=0    ;i<(n) ;i++)
#define RREP(i,n)     for (int i=(n)-1;i>=0  ;i--)
#define EACH(i,a,b)   for (int i=(a)  ;i<=(b);i++)
#define REACH(i,a,b)  for (int i=(b)  ;i>=(a);i--)
#define ALL(a)        (a).begin(),  (a).end()
#define RALL(a)       (a).rbegin(), (a).rend()
#define YES()         printf("YES\n")
#define NO()          printf("NO\n")
#define Yes()         printf("Yes\n")
#define No()          printf("No\n")
#define in(a,x,b)     ((a) <= (x) && (x) < (b))

const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const double EPS = 1e-10;

using ll = long long;
using P = pair<int,int>;
template<class T = int> using V = vector<T>;

template<class T> bool inline chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool inline chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T = int> T inline input() { T x; cin >> x; return (x); }
template<class T> void inline print(T& x) { cout << x << '\n'; }
#define debug(x) cerr << #x << ": " << x << endl;

const int dxs[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dys[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

  int N,P;
  cin >> N >> P;
  int counts[2] = {0,0};
  REP(i,N) {
    int a = input();
    counts[a%2]++;;
  }

  ll ans = 1;
  REP(i, counts[0]) ans *= 2;
  ll coef;
  if (P == 1) {
    coef = counts[1];
  } else {
    coef = 1;
  }

  ll coef_sum = coef;
  for(int i =  2 + P; i <= counts[1]; i += 2) {
    coef = coef * (counts[1] - i + 2) * (counts[1] - i + 1) / (i * (i - 1));
    coef_sum += coef;
  }

  cout << ans * coef_sum << endl;
}


Measured memory_bytes: 3656
#include<complex>
#include<cstdio>
#include<iostream>
#include<queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)
template<class T> T at(vector<T> v, int i) {return v[i % v.size()];}


#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};
typedef vector<P> Pol;

const D EPS = 1e-8;
const D PI = acos(-1);

// 比較関数
int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}

// 平方根
D sr(D a) {return sqrt(max(a, (D)0));}

// 内積
D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
// 外積
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

// 線分のベクトル
P vec(L a) {return a.b - a.a;}

// 有向角度
D arg(P base, P a, P b) {return arg((b - base) / (a - base));}

// 射影
P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.a + proj(vec(l), p - l.a);}

// 距離
D dLP(L l, P p) {return abs(det(vec(l), p - l.a) / vec(l));}
D dSP(L s, P p) {
  if (dot(vec(s), p - s.a) < 0) return abs(p - s.a);
  if (dot(vec(s), p - s.b) > 0) return abs(p - s.b);
  return dLP(s, p);
}

// 円
struct C{P c; D r;};

// 交差判定
bool iCS(C c, L s) {return sig(c.r, dSP(s, c.c)) >= 0;}

// 交点
pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(x - c.c));
  return make_pair(x - y, x + y);
}

// 円と多角形の共通部分面積
D aCTnc(D r, P p1, P p2) {return sig(abs((p1 + p2) / (D)2), r) <= 0 ? det(p1, p2) / 2 : r * r * arg(0, p1, p2) / 2;}
D aCT(D r, P p1, P p2) {
  if (!sig(r) || near(0, p1) || near(0, p2) || near(p1, p2)) return 0;
  if (!iCS((C){0, r}, (L){p1, p2})) return r * r * arg(0, p1, p2) / 2;
  pair<P, P> pp = pCL((C){0, r}, (L){p1, p2});
  return aCTnc(r, p1, pp.first) + aCTnc(r, pp.first, pp.second) + aCTnc(r, pp.second, p2);
}
D aCPol(C c, Pol pol) {D res = 0; rep (i, pol.size()) res += aCT(c.r, pol[i] - c.c, at(pol, i + 1) - c.c); return res;}

int main() {
  int n, r;
  cin >> n >> r;
  Pol pol(n);
  rep (i, n) cin >> pol[i].X >> pol[i].Y;
  D res = 0;
  for (int i = 1; i < r; i += 2) res += (2 * i + 1) * PI - (aCPol((C){0, (D)i + 1}, pol) - aCPol((C){0, (D)i}, pol));
  for (int i = 0; i < r; i += 2) res += aCPol((C){0, (D)i + 1}, pol) - aCPol((C){0, (D)i}, pol);
  printf("%.12Lf\n", res);
  return 0;
}

Measured memory_bytes: 1288
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            String a = scan.next();
            int a_number = Integer.parseInt(a);
            String op = scan.next();
            String b = scan.next();
            int b_number = Integer.parseInt(b);
            if (op.equals("+")) {
                System.out.println(a_number + b_number);
            } else if (op.equals("-")) {
                System.out.println(a_number - b_number);
            } else if (op.equals("*")) {
                System.out.println(a_number * b_number);
            } else if (op.equals("/")) {
                System.out.println(a_number / b_number);
            } else if (op.equals("?")) {
                break;
            }
        }
        
        scan.close();
    }
    
}


Measured memory_bytes: 26080
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = 100; i > 0; i--) {
        if (a % i == 0 && b % i == 0) {
            k--;
        }
        if (k == 0) {
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


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

int main()
{
	string s; cin >> s;
	string ans = "Yes";

	for (int i = 0; i < s.size(); i++) {
	
		// odd
		if (i % 2 == 0) {
			if (s.at(i) == 'R' || s.at(i) == 'U' || s.at(i) == 'D') {}
			else {
				ans = "No";
				break;
			}
		}
		// even
		else {
			if (s.at(i) == 'L' || s.at(i) == 'U' || s.at(i) == 'D') {}
			else {
				ans = "No";
				break;
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#%%
n = list(input())
n = n[::-1]
if n.count('1') == len(n):
    n = list('0' * len(n) + '1')
else:
    for i in range(len(n)):
        if n[i] == '0':
            n[i] = '1'
            point = i
            break
    for i in range(point):
        n[i] = '0'

n = n[::-1]

count = 0
ans = 0
mod = 10 ** 9 + 7

for i in range(len(n)):
    a = pow(2, count, mod)
    b = pow(3, len(n)-i-1, mod) 
    tmp = (a * b) % mod
    if n[i] == '1':
        count += 1
        ans += tmp
        ans %= mod

print(ans)

Measured memory_bytes: 4776
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int cntN = 0;
            int cnt2 = 0;
            int cnt4 = 0;

            for (int i = 0; i < n; i++) {
                int a = in.nextInt();
                if (a % 4 == 0) cnt4++;
                else if (a % 2 == 0) cnt2++;
                else cntN++;
            }

            if (cntN > cnt4 + 1) {
                out.println("No");
                return;
            }

            if (cntN == cnt4 + 1) {
                out.println(cnt2 == 0 ? "Yes" : "No");
                return;
            }

            out.println("Yes");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 38132
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, -1, 0, 1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

const int MAXN = 8;
const int MAXP = 1000;
const int MAXM = 33;
const double INF = 1e18;
int T[MAXN];
int dist[MAXM][MAXM];

double dp[MAXM][1<<MAXN];

int main() {
    int n, m, p, a, b;
    while (cin >> n >> m >> p >> a >> b) {
        if (m == 0) break;
        a--; b--;
        memset(dist, -1, sizeof(dist));
        for (int i = 0; i < n; i++)
            cin >> T[i];
        for (int i = 0; i < p; i++) {
            int x, y, z;
            cin >> x >> y >> z;
            x--; y--;
            dist[x][y] = dist[y][x] = z;
        }
        for (int i = 0; i < m; i++) for (int j = 0; j < 1<<n; j++) {
            dp[i][j] = INF;
        }
        dp[a][0] = 0;
        priority_queue<pair<double, pii> > que;
        que.push(make_pair(0, pii(a, 0)));
        while (!que.empty()) {
            auto queTop = que.top(); que.pop();
            pii p = queTop.second;
            int v = p.first, s = p.second;
            double d = -queTop.first;
            if (d > dp[v][s]) continue;
            for (int i = 0; i < m; i++) if (dist[v][i] != -1) {
                for (int j = 0; j < n; j++) {
                    if (((s>>j)&1)==0) {
                        double plus = 1.*dist[v][i]/T[j];
                        double nd = d+plus;
                        int ns = s|(1<<j);
                        if (dp[i][ns] > nd) {
                            dp[i][ns] = nd;
                            que.push(make_pair(-nd, pii(i, ns)));
                        }
                    }
                }
            }
        }
        double ans = INF;
        for (int s = 0; s < 1<<n; s++) {
            ans = min(ans, dp[b][s]);
        }
        if (ans == INF) printf("Impossible\n");
        else printf("%.10lf\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4412
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define ceil(a,b) ((a+b-1)/b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A, B;
    cin >> A >> B;
    if (B >= A)
        cout << A;
    else
        cout << A - 1;
}

Measured memory_bytes: 888
n, m = map(int, input().split())
info = list()
for i in range(0, n + 1):
    info.append(0)
for i in range(0, m):
    a, b = map(int, input().split())
    info[a] = info[a] + 1
    info[b] = info[b] + 1
for i, value in enumerate(info):
    if i is not 0:
        print(value)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define mxn 1003
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;

ld A, B, M, H, D;
ld x_1, y_1, x_2, y_2;
const ld PI = acos(0)*ld(2);

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    cin >> A >> B >> H >> M;
    H = ld(90) - (H*ld(30) + M/ld(2));
    M = ld(90) - M*ld(6);
    H = (H*PI) / ld(180);
    M = (M*PI) / ld(180);

    x_1 = cos(H) * A, y_1 = sin(H) * A;
    x_2 = cos(M) * B, y_2 = sin(M) * B;
    x_1 = x_1-x_2, y_1 = y_1-y_2;
    D = (x_1*x_1) + (y_1*y_1);
    D = sqrt(D);
    cout << fixed << setprecision(9) << D << "\n";

    return 0;
}

Measured memory_bytes: 4172
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var d = Console.ReadLine().Split(' ');
            var n = int.Parse(d[0]);
            var m = int.Parse(d[1]);
            var x = Console.ReadLine().Split(' ');

            var list = new List<int>();
            for (int i = 0; i < m; i++)
            {
                list.Add(int.Parse(x[i]));
            }

            var sortList = Sort(list);

            //for (int i = 0; i < sortList.Count; i++)
            //{
            //    Console.WriteLine(i + " = " + sortList[i]);
            //}

            var k = 0;

            List<int> sub = new List<int>();
            for(int i = 0; i < m - 1; i++)
            {
                sub.Add(Math.Abs(sortList[i + 1] - (sortList[i])));
            }
            Sort(sub);

            for(; n - 1 < sub.Count;)
            {
                k += sub[0];
                sub.RemoveAt(0);
            }
            //for (int i = 0; i < sub.Count; i++)
            //{
            //    Console.WriteLine(i + " = " + sub[i]);
            //}

            //while (sub.Count > n - 1)
            //{
            //    int min = 0;
            //    for(int i = 0; i < sub.Count; i++)
            //    {
            //        if (sub[min] > sub[i])
            //        {
            //            min = i;
            //        }
            //    }

            //    k += sub[min];
            //    //Console.WriteLine("sub" + sub[min] + " " + min);
            //    sub.RemoveAt(min);
            //}

            Console.WriteLine(k);

        }

        static List<int> Sort(List<int> list)
        {
            list.Sort();

            return list;
        }
    }
}


Measured memory_bytes: 20448
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int[] num = new int[51];
	for (int i = 0; i < 10; i++) {
	    for (int j = 0; j < 10; j++) {
		for (int k = 0; k < 10; k++) {
		    for (int l = 0; l < 10; l++) {
			num[i+j+k+l]++;
		    }
		}
	    }
	}
	int n;
	while (scan.hasNext()) {
	    n = Integer.parseInt(scan.nextLine());
	    System.out.println(num[n]);
	}
    }
}

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

#define watch(x) cerr << (#x) << ": " << (x) << endl

long long n, a, b, ans;

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> a >> b;
    if(a > b) swap(a, b);
    long long diff = b-a;
    if(diff%2) {
        ans += min(a, n-b+1);
    }
    ans += diff/2;

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


Measured memory_bytes: 764
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n = int(input())
if n == 1:
    print(0)
else:
    answer = 0
    for factor in factorization(n):
        x = factor[1]
        kouho = int((2*x)**0.5)-1
        if (kouho)*(kouho+1)/2 <=x and x < (kouho+1)*(kouho+2)/2:
            kaisu = kouho
        else:
            kaisu = kouho+1
        answer += kaisu

    print(answer)


Measured memory_bytes: 9500
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
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;}
const ll INF = 1LL << 56;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    string s;
    cin >> s;
    ll n=s.size(),x=2019;
    ll a[n+1];
    fill(a,a+n+1,0);
    ll tmp=0;
    ll mod=1;
    for (ll i=0;i<n;i++){
        tmp+=(ll(s[n-1-i]-'0'))*mod;
        a[i+1]+=tmp%x;
        mod*=10;
        mod%=x;
    }
    ll ans=0,c[2019];
    fill(c,c+2019,0);
    for (ll i=0;i<n+1;i++){
        c[a[i]]++;
    }
    for (ll i=0;i<2019;i++){
        ans+=((c[i]*(c[i]-1))/2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5280
using System;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            string[] array = Console.ReadLine().Split(' ');
            Array.Reverse(array);
            for (int i = 0; i < count; i++)
            {
                if (i + 1 == count)
                {
                    Console.Write(array[i]);
                }
                else
                {
                    Console.Write(array[i] + " ");
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define all(v) v.bigin(),v.end()
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define R(a) a=sqrt(a)
#define POW(a,b) a=pow(a,b)
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    FAST;
    ll n,all,all2;
    cin>>n;
    ll a[n];
    all=0;
    rep(i,n){
        cin>>a[i];
        all+=a[i];
    }

    ll ans;
    ans=0;
    rep(i,n){
        all-=a[i];
        all2=all%1000000007;
        ans+=(a[i]*all2)%1000000007;
        ans%=1000000007;
    }
    cout<<ans;
    return 0;
}



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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string a, b, c; cin >> a >> b >> c;
    if(a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) cout << "YES";
    else cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{  
  std::string a, b;
  std::cin >> a >> b;
  
  for(int i = 0; a[i] != NULL; i++)
  {
    if(b[i] != NULL)
    {
      std::cout << a[i] << b[i];
    }
    else
    {
      std::cout << a[i];
    }
  }

  return 0;
}

Measured memory_bytes: 3068
n = int(input())
a = list(map(int,input().split()))
import collections
p = []
q = []
d = collections.defaultdict(int)
e = collections.defaultdict(int)
for i in range(n):
    p.append(a[i]+i+1)
for i in range(n):
    q.append(-a[i]+i+1)
ans = 0
for i in range(n):
    d[p[i]] += 1
    e[q[i]] += 1
for i in d.keys():
    ans += d[i]*e[i]
print(ans)

Measured memory_bytes: 168860
#include <iostream>

using namespace std;

char table[21][21];
bool reachable;
int cnt;
int w, h;

void dfs(int x, int y) {
    if (table[y][x] == '@')
        reachable = true;
    table[y][x] = '#';
    for (int dy = -1; dy <= 1; dy++) {
        for (int dx = -1; dx <= 1; dx++) {
            if (dx*dy != 0 || x+dx < 0 || x+dx >= w || y+dy < 0 || y+dy >= h)
                continue;
            if (table[y+dy][x+dx] != '#') {
                cnt++;
                dfs(x+dx, y+dy);
            }
        }
    }
}

int main()
{
    start:
    while (cin >> w >> h, w|h) {
        // input
        for (int i = 0; i < h; i++) {
            cin >> table[i];
        }
        // dfs
        for (int j = 0; j < h; j++) {
            for (int i = 0; i < w; i++) {
                if (table[j][i] != '#') {
                    reachable = false;
                    cnt = 1;
                    dfs(i, j);
                    if (reachable) {
                        cout << cnt << endl;
                        goto start;
                    }
                }
            }
        }
    }

    return 0;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int n;
    string s;
    cin >> n >> s;

    if (s.front() == 'W' || s.back() == 'W') {
        cout << 0 << '\n';
        return;
    }
    int L = 0, R = 0;
    ll res = 1;
    for (int i=0; i<2*n; ++i) {
        if (i == 0 || s.at(i) != s.at(i-1)) {
            ++L;
        } else {
            res *= L - R;
            res %= MOD;
            ++R;
            s.at(i) = s.at(i) == 'W' ? 'B' : 'W';
        }
    }
    if (L != R) {
        cout << 0 << '\n';
    } else {
        for (int i=1; i<=n; ++i) {
            res *= i;
            res %= MOD;
        }
        cout << res << '\n';
    }
}

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

    solve();

    return 0;
}


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

typedef pair<int, int> P;

int main(){
  
  int H, W, i, j, d = 0;
  vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
  cin >> H >> W;
  vector<vector<char>> s(H, vector<char>(W));
  vector<vector<int>> checked(H, vector<int>(W, 0));
  
  for (i = 0; i < H; i++){
    for (j = 0; j < W; j++){
      cin >> s.at(i).at(j);
      if(s.at(i).at(j) == '#') d++;
    }
  }
  
  P pos = P(0, 0);
  queue<P> quepos;
  quepos.push(pos);
  
  while(quepos.size()){
    
    pos = quepos.front(); quepos.pop();
    for(i = 0; i < 4; i++){
      
      int x = pos.first + dx.at(i), y = pos.second + dy.at(i);
      if(x >= 0 && x < W && y >= 0 && y < H && s.at(y).at(x) == '.' && checked.at(y).at(x) == 0){

        checked.at(y).at(x) = checked.at(pos.second).at(pos.first) + 1;
        quepos.push(P(x, y));
        if(y == H - 1 && x == W - 1){
          cout << H * W - d - checked.at(y).at(x) - 1 << endl;
          return 0;
        }
      }
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) int((a).size()) 
#define pb push_back 
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define present(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#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 N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
int main(){
	int n,x; cin>>n; int ct=0;
	rep(i,0,n){
		cin>>x; if(x&1) ++ct;
	}
	if(ct&1) cout<<"NO";
	else cout<<"YES";
}

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

using namespace std;
using Graph = vector<vector<int>>;
string explanation1 = "これは幅優先探索の問題！";
string explanation2 = "参考URL:https://qiita.com/drken/items/996d80bcae64649a6580";

const int INF = 1001001001;
const int B = 100005;
int main() {
  int n, m;
  cin >> n >> m;

  //グラフ入力受け取り
  Graph G(B);
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--; //distで０と１のズレを直しておくため
    G[a].push_back(b); //有向グラフ
    G[b].push_back(a); //無向グラフなのでこれも追加
  }

  //BFSのためのデータ構造
  vector<int> dist(n, INF); //全頂点を「未訪問」に初期化
  queue<int> que; //キュー
  vector<int> pre(n, -1);

  //初期条件（頂点1をノードとする）
  dist[0] = 0;
  que.push(0); //1を橙色頂点にする

  //BFS開始（キューが空になるまで探索を行う）
  while(!que.empty()) {
    int v = que.front(); //キューから先頭頂点を取り出す
    que.pop(); //先頭要素を削除

    // v から辿れる頂点をすべて調べる
    for(int u : G[v]) { //拡張for文 変数uにG[v]の値を入れてる
      if(dist[u] != INF) continue; //すでに発見済みの頂点は探索しない

      //新たな白色頂点uについて距離情報を更新してキューに追加する
      dist[u] = dist[v] + 1;
      pre[u] = v;
      que.push(u);
    }
  }

  for(int i = 1; i < n; i++) {
    if(pre[i] == -1) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i = 0; i < n; i++) {
    if(i == 0) continue;
    int ans = pre[i];
    ans++; //18,19行目で１減らしてたのを元に戻す
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 10572
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=1e5+5;
int n,a[N],b[N],pa[N],pb[N],to[N],oria[N],orib[N];
bool v[N];

void OK(){
	puts("Yes");
	exit(0);
}

void GG(){
	puts("No");
	exit(0);
}

signed main(){
	read(n);
	for(int i=1;i<=n;i++) oria[i]=read(a[i]),pa[i]=i;
	for(int i=1;i<=n;i++) orib[i]=read(b[i]),pb[i]=i;
	sort(a+1,a+1+n);sort(b+1,b+1+n);
	for(int i=1;i<=n;i++) if(a[i]>b[i]) GG();
	for(int i=1;i<=n;i++) if(a[i]<=b[i-1]) OK();
	sort(pa+1,pa+1+n,[](int x,int y){return oria[x]<oria[y];});
	sort(pb+1,pb+1+n,[](int x,int y){return orib[x]<orib[y];});
	for(int i=1;i<=n;i++) to[pa[i]]=pb[i];
	for(int i=1;!v[i];i=to[i]) v[i]=1;
	for(int i=1;i<=n;i++) if(!v[i]) OK();
	GG();
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;


bool vecfind(int A[],int n,int x){
  int L=0;
  int R=n;
  while(L<R){
    int mid=(L+R)/2;
    if(A[mid]==x){
      return true;
    } 
    else if(x<A[mid]){
      R=mid;
    }
    else{
      L=mid+1;
    }
  }
  return false;
}

int main (){
  int n,ans=0;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  int b,m;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>b;
    if(vecfind(A,n,b)) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
typedef pair<int,pair<int, int>> P1;

using Graph = vector<vector<int>>;

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

  int N;
  cin >> N;
  int ans = 0;
  rep(i,N+1) ans += i;
  cout << ans << endl;
}


Measured memory_bytes: 256
import random

def is_prime(q,k=50):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1
    
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        while t != q-1 and y != 1 and y != q-1: 
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

n = int(input())

i = n
while(not is_prime(i)):i += 1
print(i)


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

int main(){
  map<string, int> list;
  long n;
  string s;
  cin >> n;
  for(long i = 0; i < n; i++){
    cin >> s;
    list[s] = 1;
  }
  cout << list.size() << endl;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int n, k;
	cin >> n >> k;
	int ans = n - k;
	if (k == 1) {
		ans = 0;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding:utf-8 -*-

from __future__ import division, print_function, absolute_import, unicode_literals

S = input()
k = int(input())

ans = ''
for s in S:
    if s == 'a':
        ans += s
        continue
    # print(ord('z') - ord(s) + 1)
    tmp = ord('z') - ord(s) + 1
    if k >= tmp:
        ans += 'a'
        k -= tmp
    else:
        ans += s
if k > 0:
    k = k % 26
    ans = ans[:-1] + chr(ord(ans[-1]) + k)
print(ans)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int N; cin>>N;
    vector<ll> a(N),cnt(N+10,0);
    for (int i = 0; i < N; ++i) {
        cin>>a[i]; cnt[a[i]]++;
    }

    ll total=0ll;
    for (int j = 1; j <= N; ++j) {
        total+=cnt[j]*(cnt[j]-1ll)/2ll;
    }

    for (int i = 0; i < N; ++i) {
        ll ans=total-cnt[a[i]]*(cnt[a[i]]-1)/2+(cnt[a[i]]-1)*(cnt[a[i]]-2)/2;
        cout<<ans<<endl;
    }

    return 0;
}


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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e9+7; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll h,n,a,b;
	cin>>h>>n;
	ll dp[h+1];
	forn(i,h+1) dp[i]=inf;
	dp[0]=0;
	forn(i,n){
		cin>>a>>b;
		forn(j,h){
			dp[min(j+a,h)]=min(dp[min(j+a,h)],dp[j]+b);
		}
	}
	cout<<dp[h]<<'\n';
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""
 


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

using namespace std;

constexpr int N = 3000000;
constexpr long long MOD = 1000000007;

long long f[N + 1];

/* O(Log(min(a, b))) - Extended Euclidean Algorithm.
   Returns a solution to a * x + b * y = gcd(a, b).
   Returns |x| <= |a / gcd(a, b)|, |y| <= |b / gcd(a, b)| and gcd(a, b). */
tuple<long long, long long, long long> extended_gcd(long long a, long long b) {
	long long x, y, gcd;

	if (a == 0) {
		return make_tuple(b, 0, 1);
	}

	tie(gcd, x, y) = extended_gcd(b % a, a);

	return make_tuple(gcd, y - (b / a) * x, x); 
}

/* O(Log(M)) - Returns the modular multiplicative inverse of a mod m, if it exists.
Returns x that satisfies a * x = 1 (mod m) if a and m are coprime. Returns 0 otherwise. */
long long modular_inverse(long long a, long long m) {
	long long gcd, x, y;

	tie(gcd, x, y) = extended_gcd((a % m + m) % m, m);

	if (gcd != 1) {
		return 0;
	}

	return (x % m + m) % m;
}

/* O(Log(M)) - This only works if k! * (n - k)! is coprime with m. */
long long nck(long long n, long long k, long long m) {
	long long num, den;

	// Trivial case.
	if (k < 0 or k > n) {
		return 0;
	}

	num = f[n];
	den = (f[k] * f[n - k]) % m;

	return (num * modular_inverse(den, m)) % m;
}

/* O(N). */
void nck_init(long long m) {
	f[0] = 1;

	for (long long i = 1; i <= N; i++) {
		f[i] = (f[i - 1] * i) % m;
	}
}

long long solve(int x, int y) {
	long long ans = 0;

	for (int i = 0; i <= x; i++) {
		ans = (ans + nck(i + y + 1, i + 1, MOD)) % MOD;
	}

	return ans;
}

int main() {
	int x1, y1, x2, y2;
	long long ans;

	nck_init(MOD);

	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);

	ans = solve(x2, y2) - solve(x2, y1 - 1) - solve(x1 - 1, y2) + solve(x1 - 1, y1 - 1);

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

	return 0;
}

Measured memory_bytes: 23680
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>

using namespace std;

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

const double EPS = 1e-10;

typedef vector<int> vi;

int main()
{
	double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
	while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &xa1, &ya1, &xa2, &ya2, &xb1, &yb1, &xb2, &yb2) != EOF){
		bool x = min(xa1, xa2) <= max(xb1, xb2) && max(xa1, xa2) >= min(xb1, xb2);
		bool y = min(ya1, ya2) <= max(yb1, yb2) && max(ya1, ya2) >= min(yb1, yb2);
		puts(x&&y ? "YES" : "NO");
	}

	return 0;
}

Measured memory_bytes: 0
from sys import stdin
import math

n, d = map(int, input().split())
data = [stdin.readline().rstrip().split() for _ in range(n)]


count = 0
fig = 0

for i in range(n):

        for j in range(n):

                if i == j:
                        pass
                elif i > j:
                        pass
                else:
                        fig = 0
                        res = 0

                        for h in range(d):
                                fig += abs(int(data[i][h]) - int(data[j][h])) **2
                        res = math.sqrt(fig)
                        #print(res)
                        if res%1 == 0:
                                count +=1



print(count)
#print(data)

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

int c[8];

class DICE{
public:
   void setdice(char a);
};

void DICE::setdice(char a){
   if(a == 'S'){
       c[7] = c[1];
       c[1] = c[5];
       c[5] = c[6];
       c[6] = c[2];
       c[2] = c[7];
   }
   else if(a == 'W'){
       c[7] = c[1];
       c[1] = c[3];
       c[3] = c[6];
       c[6] = c[4];
       c[4] = c[7];
   }
   else if(a == 'N'){
       c[7] = c[1];
       c[1] = c[2];
       c[2] = c[6];
       c[6] = c[5];
       c[5] = c[7];
   }
   else{
       c[7] = c[1];
       c[1] = c[4];
       c[4] = c[6];
       c[6] = c[3];
       c[3] = c[7];
   }
}

int main(void){
   DICE dice;
   int n, i, j, cc[101][8],  count = 0;
   cin >> n;
   for(i = 1; i <= n; i++){
       cin >> cc[i][1] >> cc[i][2] >> cc[i][3] >> cc[i][4] >> cc[i][5] >> cc[i][6];
   }
   
   for(i = 1; i <= n; i++){
       for(j = i+1; j <= n; j++){
       if(cc[i][1] == cc[j][3] || cc[i][1] == cc[j][4]){
           for(int k = 0; k < 5; k++){
               c[1] = cc[j][1];c[2] = cc[j][2];c[3] = cc[j][3];c[4] = cc[j][4];c[5] = cc[j][5];c[6] = cc[j][6];
               dice.setdice('E');
               cc[j][1] = c[1];cc[j][2] = c[2];cc[j][3] = c[3];cc[j][4] = c[4];cc[j][5] = c[5];cc[j][6] = c[6];
               if(cc[j][1] == cc[i][1] && cc[j][6] == cc[i][6])    break;
           }
       }
           for(int k = 0; k < 5; k++){
               if(cc[j][1] == cc[i][1] && cc[j][6] == cc[i][6])    break;
               c[1] = cc[j][1];c[2] = cc[j][2];c[3] = cc[j][3];c[4] = cc[j][4];c[5] = cc[j][5];c[6] = cc[j][6];
               dice.setdice('S');
               cc[j][1] = c[1];cc[j][2] = c[2];cc[j][3] = c[3];cc[j][4] = c[4];cc[j][5] = c[5];cc[j][6] = c[6];
           }
           c[1] = cc[j][1];c[2] = cc[j][2];c[3] = cc[j][3];c[4] = cc[j][4];c[5] = cc[j][5];c[6] = cc[j][6];
       dice.setdice('N');
       cc[j][1] = c[1];cc[j][2] = c[2];cc[j][3] = c[3];cc[j][4] = c[4];cc[j][5] = c[5];cc[j][6] = c[6];
       for(int t = 0; t < 5; t++){
           c[1] = cc[j][1];c[2] = cc[j][2];c[3] = cc[j][3];c[4] = cc[j][4];c[5] = cc[j][5];c[6] = cc[j][6];
           dice.setdice('W');
           cc[j][1] = c[1];cc[j][2] = c[2];cc[j][3] = c[3];cc[j][4] = c[4];cc[j][5] = c[5];cc[j][6] = c[6];
           if(cc[j][1] == cc[i][2] && cc[j][3] == cc[i][3] && cc[j][4] == cc[i][4] && cc[j][6] == cc[i][5])    count++;
       }
   }
   }
   if(count > 0)  cout << "No" << endl;
   else    cout << "Yes" <<endl;
   
   
   
   return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  int h, w, n; cin >> h >> w >> n;
  if(h > w) swap(h, w);
  for(int i = 1; i <= h; i++) {
    n -= w;
    if(n <= 0) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long
const int inf = 1 << 30;
#define INF 1e+9
#define MAX_V 100008


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


int main(){
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for(int i=0; i<s.size(); i++){
    if(s[i] != t[i])ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3916
using System;
 
class Program
{
    static void Main(string [] args)
    {
        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
        var h = int.Parse(Console.ReadLine());
        var result = (a + b) * h / 2;
        Console.WriteLine(result);
    }
}

Measured memory_bytes: 11092