akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <math.h>
using namespace std;

class Point {
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}

    Point operator + (Point p) { return Point(x+p.x, y+p.y); }
    Point operator - (Point p) { return Point(x-p.x, y-p.y); }
    Point operator * (double a) { return Point(a*x, a*y); }
    Point operator / (double a) { return Point(x/a, y/a); }

    double abs() {return sqrt(norm()); }
    double norm() {return x*x + y*y; }
};

typedef Point Vector;


double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x*b.y - a.y*b.x;
}

int main(){
    //cinの入力元をテキストファイルに(テスト用)
    #if 0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    #endif

    Point p0, p1;
    int q;
    string message[6] = {"ERROR", "COUNTER_CLOCKWISE", "CLOCKWISE", "ONLINE_BACK", "ONLINE_FRONT", "ON_SEGMENT"};

    //標準入力
    cin >> p0.x;
    cin >> p0.y;
    cin >> p1.x;
    cin >> p1.y;
    cin >> q;

    Vector v01 = p1 - p0;

    for(int i=0; i<q; i++){
        int num = 0;
        Point p2;
        cin >> p2.x;
        cin >> p2.y;

        Vector v02= p2 - p0;

        double Dot = dot(v01, v02);
        double Cross = cross(v01, v02);

        if(Cross > 0){num = 1;}
        else if (Cross < 0){num = 2;}
        else
        {
            if(Dot < 0){num = 3;}
            else{
                if(v01.norm() < v02.norm()){num = 4;}
                else{num = 5;}
            }
        }
        cout << message[num] << "\n";
    }
    return 0;
}



Measured memory_bytes: 3276
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; 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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
ll N, K;
int x[100], y[100];

bool check(int top, int bottom, int right, int left) {
  int cnt = 0;
  rep(k, 0, N) {
    int cx = x[k];
    int cy = y[k];
    if (left <= cx && cx <= right && bottom <= cy && cy <= top) {
      ++cnt;
    }
  }

  return cnt >= K;
}

int dummy[1000000];

int main() {
  cin >> N >> K;
  rep(i, 0, N) { cin >> x[i] >> y[i]; }

  for (ll i = 0; i <= N * N * N * N * N; ++i) {
    dummy[i % 1000000] = i;
  }

  ll ans = numeric_limits<ll>::max();
  rep(i, 0, N) {
    rep(j, i, N) {
      rep(k, j, N) {
        rep(l, k, N) {
          ll top = max(y[i], max(y[j], max(y[k], y[l])));
          ll bottom = min(y[i], min(y[j], min(y[k], y[l])));
          ll left = min(x[i], min(x[j], min(x[k], x[l])));
          ll right = max(x[i], max(x[j], max(x[k], x[l])));

          if (check(top, bottom, right, left)) {
            chmin(ans, (top - bottom) * (right - left));
          }
        }
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 7492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    cout << S.substr(0,K) << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;

using namespace std;

int main() 
{
    string sp, t;
    cin >> sp >> t;
    v_string ans;

    irep(i, sp.size()) {
        if(sp.size() - i < t.size()) {
            continue;
        }
        //cout << sp.substr(i, t.size()) << endl;
        string u = sp.substr(i, t.size());
        string s = sp.substr(0, i) + t;
        bool check = true;
        irep(j, u.size()){
            if(u[j] != t[j] && u[j] != '?') {
                //cout << u << endl;
                check = false;
            }
        }
        if(check) {
            s += sp.substr(i+u.size(), sp.size()-s.size());
            irep(k, sp.size()){
                if(s[k] == '?') { 
                    s[k] = 'a'; 
                }
            }
            //cout << s << endl;
            ans.push_back(s);
        }
    }

    if(ans.size()) {
        sort(ans.begin(), ans.end());
        cout << ans[0] << endl;
    } else {
        cout << "UNRESTORABLE" << endl;
    }

    return 0;
}
    



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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    
    vector<int> M(N);
    M[0] = H[0];
    for (int i = 1; i < N; ++i) {
        if (H[i] < M[i-1]) M[i] = M[i-1];
        else M[i] = H[i];
    }
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        if (M[i] == H[i]) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
def resolve():
    import math
    from fractions import Fraction
    mod = 10**9 + 7
    n = int(input())
    enpty = 0
    dic1 = {}
    for i in range(n):
        a, b = map(int, input().split())
        if a == 0 and b == 0:
            enpty += 1
        else:
            c = math.gcd(a,b)
            a = a//c
            b = b//c
            if b < 0 or (b==0 and a<0):
                a = -a
                b = -b
            if (a, b) in dic1:
                dic1[(a, b)] += 1
            else:
                dic1[(a,b)] = 1

    ans = 1

    for (a, b), num in dic1.items():
        if (-b, a) in dic1:
            ans = (ans*(pow(2, num, mod)+pow(2, dic1[(-b, a)], mod)-1))%mod
        elif not (b, -a) in dic1:
            ans = (ans*pow(2, num, mod))%mod

    print((ans-1+enpty)%mod)


resolve()

Measured memory_bytes: 122092
#include <iostream>
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <tuple>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int a[3][3];
    for (int i = 0; i < 9; i++) cin >> a[i / 3][i % 3];
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        for (int j = 0; j < 9; j++) {
            if (a[j/3][j%3] == b) a[j/3][j%3] = 0;
        }
    }

    for (int i = 0; i < 3; i++) {
        bool ok = 1;
        for (int j = 0; j < 3; j++) {
            if (a[i][j] != 0) ok = 0;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    for (int i = 0; i < 3; i++) {
        bool ok = 1;
        for (int j = 0; j < 3; j++) {
            if (a[j][i] != 0) ok = 0;
        }
        if (ok) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0) {
        cout << "Yes" << endl;
    }
    else if (a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>

#define REP(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define RREP(i,x,y) for(int i=(int)(x);i>(int)(y);i--)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

const int MAX_N = 3 * 100000;
string S;
int N;
int number[MAX_N]; // the number of people turning to the leader from the point of i th position.

void solve() {
    int count = 0;
    REP(i,1,S.length()) {
        if (S[i] == 'W') count++;
    }
    number[0] = count;
//    printf("%d\n", number[0]);
    REP(i,1,S.length()) {
        int diff = 0;
        diff += (S[i-1] == 'E' ? 1 : 0) + (S[i] == 'W' ? -1 : 0);
        number[i] = number[i-1] + diff;
//        printf("%d\n", number[i]);
    }
    int max = *max_element(number, number + N);
    printf("%d\n", N - 1 - max);
    return;
}

int main() {
    // to shorten execution time for iostream
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> S;
    solve();
    return 0;
}


Measured memory_bytes: 1812
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define loop(i,n) for(int i=0;i<(n);i++)
#define pool(i,n) for(int i=(n)-1;i>=0;i--)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define tnoc(i,n) for(int i=(n);i>=1;i--)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define cric(i,a,b) for(int i=(b);i>=(a);i--)
#define sub(i,a) for(int i=a;i;i=((i-1)&(a)))
#define subs(i,a) for(int i=a;i>=0;i=(!i?-1:((i-1)&(a))))
#define subt(i,a) for(int i=((a-1)&a);i;i=((i-1)&(a)))
#define subst(i,a) for(int i=((a-1)&a);i>=0;i=(!i?-1:((i-1)&(a))))
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define parse(i,s) for(int i=0;s[i];i++)

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mak make_pair

#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define ws WSrAkIoi2333wSraKIoIWSraKiOi
#define left left_jTjTJtJtIoiiOiioIAuaU66666jtIOIau
#define hash whYusEthiSnamE_caNyoUusEothERnaMesliKeHSH

#define Mask(a) (1ll<<(a))
#define Maskx(a,x) ((a)<<(x))
#define Full(a) ((1ll<<(a))-1)
#define Bit(a,x) (((a)>>(x))&1)
#define all(a) (a).begin(),(a).end()
#define SZ(a) ((int)((a).size()))

typedef long long ll;
typedef long double lf;

const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const lf inF=11451419198101145141919810.1145141919810;
const lf pi=acosl(-1);
/* Source code starts here */

int n,a,b;
const int jt=1000000007;
int dp[5005][5005][2],qzh1[5005],qzh2[5005][5005];
void inline add(int &a,int b){a+=b;if(a>=jt)a-=jt;if(a<0)a+=jt;}

int main(){
	scanf("%d%d%d",&n,&a,&b);
	if(a<b)swap(a,b);
	dp[0][0][1]=1;
	loop(i,n+1){
		if(i)add(qzh1[i],qzh1[i-1]);
		add(dp[i][0][0],qzh1[i]);
		loop(j,i+1){
			if(i)add(qzh2[i-j][i],qzh2[i-j][i-1]);
			add(dp[i][j][0],qzh2[i-j][i]);
			if(j==a){
				add(dp[i][j][1],dp[i][j][0]);dp[i][j][0]=0;
				add(dp[i+1][j][1],dp[i][j][1]);
				add(dp[i+1][j][1],dp[i][j][1]);
				break;
			}
			add(dp[i+1][j+1][1],dp[i][j][0]);
			add(dp[i+1][j+1][1],dp[i][j][1]);
			add(qzh1[i+1],dp[i][j][1]);
			if(i+b<=n){
				add(qzh1[i+b],-dp[i][j][1]);
				if(j+b<=a)add(qzh2[i-j][i+b],dp[i][j][1]);
				else add(dp[i+b][a][1],dp[i][j][1]);
			}
		}
	}
	add(dp[n][a][1],dp[n][a][0]);
	printf("%d\n",dp[n][a][1]);
	return 0;
}

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

using namespace std;
using ll = long long;

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

const int mod = 1000000007;

ll modpow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n % 2 == 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

ll modinv(ll x) { return modpow(x, mod - 2); }

// nCk
ll modfact(ll n, int k) {
  ll ret = 1, m = n % mod;
  rep(i, k) {
    ret *= m % mod;
    ret %= mod;
    --m;
  }
  return ret;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  ll ans = modpow(2, n) - 1;

  ll fa = modfact(a, a);
  ll ifa = modpow(fa, mod - 2);

  ll fb = modfact(b, b);
  ll ifb = modpow(fb, mod - 2);

  ans -= modfact(n, a) * ifa % mod;
  ans = (ans + mod) % mod;
  ans -= modfact(n, b) * ifb % mod;
  ans = (ans + mod) % mod;

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = '-1'


def is_anag(a, b):
    return Counter(a) == Counter(b)


N = int(input())
S = ["".join(sorted(input())) for _ in range(N)]
counter = Counter(S)

ans = 0
for value in counter.values():
    if value >= 2:
        ans += value * (value - 1) // 2

print(ans)

# for i, s in enumerate(S, start=1):
#     if s == NIL:
#         continue
#     counter = 1
#     for j in range(i, len(S)):
#         if S[j] == NIL:
#             continue
#         if is_anag(s, S[j]):
#             counter += 1
#             S[j] = NIL
#     if counter != 1:
#         ans.append(counter * (counter - 1) // 2)

# res = []
#
# for a in ans:
#     res.append(a * (a - 1) // 2)
# print(sum(ans))


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

using namespace std;

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

    int n;
    cin >> n;
    string s;
    cin >> 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
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1e6+5;

ld dist(pair<ld,ld> x,pair<ld,ld> y)
{
    ld d = (x.ff-y.ff)*(x.ff-y.ff);
    d += (x.ss-y.ss)*(x.ss-y.ss);
    return sqrt(d);
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        pair<ld,ld> p[n];
        int per[n];
        for(int i=0;i<n;i++)cin>>p[i].ff>>p[i].ss,per[i]=i;
        ld sum = 0;
        ld cnt = 0;
        do{
            for(int i=1;i<n;i++)sum+=dist(p[per[i]],p[per[i-1]]);
            cnt++;
        }while(next_permutation(per,per+n));
        sum/=cnt;
        cout<<sp(9)<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int p[200005], tot;
bool np[2205];
map<ll, ll> app, to;
int main()
{
	// freopen("AGC003-D.in", "r", stdin);
	for (int i = 2; i < 2205; i++)
	{
		if (!np[i])
			p[tot++] = i;
		for (int j = 0; j < tot && i * p[j] < 2205; i++)
		{
			np[i * p[j]] = true;
			if (!(i % p[j]))
				break;
		}
	}
	bool f = false;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		ll x, y = 1, z = 1;
		scanf("%lld", &x);
		for (int j = 0; j < tot; j++)
		{
			int cnt = 0;
			while (!(x % p[j]))
			{
				x /= p[j];
				cnt = (cnt + 1) % 3;
			}
			int t = (3 - cnt) % 3;
			while (cnt--)
				y *= p[j];
			while (t--)
				z *= p[j];
		}
		if (x != 1)
		{
			ll k = sqrt(x);
			if (k * k == x)
			{
				y *= k * k;
				z *= k;
			}
			else
			{
				y *= x;
				z *= x * x;
			}
		}
		// cout << y << " " << z << endl;
		if (y == 1)
		{
			f = true;
			continue;
		}
		app[y]++;
		to[y] = z;
	}
	// cout << endl;
	ll ans = 0;
	for (map<ll, ll>::iterator it = to.begin(); it != to.end(); it++)
	{
		if (it->second >= it->first || !to.count(it->second))
		{
			// cout << it->first << " " << it->second << " " << app[it->first] << " " << app[it->second] << endl;
			ans += max(app[it->first], app[it->second]);
		}
	}
	printf("%lld\n", ans + f);
	return 0;
}


Measured memory_bytes: 18944
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> InputList = new List<int>();
            List<List<int>> ResultList = new List<List<int>>();

            string oputputstring = string.Empty;
            string outputpoint = string.Empty;

            while (true)
            {
                var Input = Console.ReadLine().Split(' ');
                int H = int.Parse(Input[0]);
                int W = int.Parse(Input[1]);

                if (H == 0 && W == 0) break;

                InputList = new List<int>();

                InputList.Add(H);
                InputList.Add(W);
                ResultList.Add(InputList);
            }


            foreach (var InThelist in ResultList)
            {
                //?????§????????????????????????("."?????????)
                for (int x = 0; x < InThelist[1]; x++)
                {
                    if (x % 2 == 0) oputputstring += "#";
                    else oputputstring += ".";
                }

                //?????§????????????????????????("#"?????????)
                for(int z = 0; z < InThelist[1]; z++)
                {
                    if (z % 2 == 0) outputpoint += ".";
                    else outputpoint += "#";
                }

                //?????????Consle.WriteLine???????????????
                for (int y = 0; y < InThelist[0]; y++)
                {
                    //??¶??°?????´???"."???????????????????????§?????????????????¨???
                    if (y%2 == 0) Console.WriteLine(oputputstring); 

                    //?\???°?????´???"#"???????????????????????§?????????????????¨???
                    else Console.WriteLine(outputpoint);
                }

                oputputstring = string.Empty;
                outputpoint = string.Empty;
                Console.WriteLine();   
            }

        }

    }

}

Measured memory_bytes: 8980
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

type bufReader struct {
	r   *bufio.Reader
	buf []byte
	i   int
}

var reader = &bufReader{
	bufio.NewReader(os.Stdin),
	make([]byte, 0),
	0,
}

func (r *bufReader) readLine() {
	if r.i < len(r.buf) {
		return
	}
	r.buf = make([]byte, 0)
	r.i = 0
	for {
		line, isPrefix, err := r.r.ReadLine()
		if err != nil {
			panic(err)
		}
		r.buf = append(r.buf, line...)
		if !isPrefix {
			break
		}
	}
}

func (r *bufReader) next() string {
	r.readLine()
	from := r.i
	for ; r.i < len(r.buf); r.i++ {
		if r.buf[r.i] == ' ' {
			break
		}
	}
	s := string(r.buf[from:r.i])
	r.i++
	return s
}

func (r *bufReader) nextLine() string {
	r.readLine()
	s := string(r.buf[r.i:])
	r.i = len(r.buf)
	return s
}

var writer = bufio.NewWriter(os.Stdout)

func next() string {
	return reader.next()
}

func nextInt64() int64 {
	i, err := strconv.ParseInt(reader.next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func nextInt() int {
	return int(nextInt64())
}

func nextLine() string {
	return reader.nextLine()
}

func out(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func max64(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func max(x, y int) int {
	return int(max64(int64(x), int64(y)))
}

func min64(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

func min(x, y int) int {
	return int(min64(int64(x), int64(y)))
}

func abs64(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func abs(x int) int {
	return int(abs64(int64(x)))
}

func joinInt64s(a []int64, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.FormatInt(v, 10)
	}
	return strings.Join(b, sep)
}

func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

func divUp64(x, y int64) int64 {
	return (x + y - 1) / y
}

func divUp(x, y int) int {
	return int(divUp64(int64(x), int64(y)))
}

func gcd64(x, y int64) int64 {
	if x < y {
		x, y = y, x
	}
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func gcd(x, y int) int {
	return int(gcd64(int64(x), int64(y)))
}

func lcm64(x, y int64) int64 {
	return x * y / gcd64(x, y)
}

func lcm(x, y int) int {
	return int(lcm64(int64(x), int64(y)))
}

func pow64(x, y int64) int64 {
	return int64(math.Pow(float64(x), float64(y)))
}

func pow(x, y int) int {
	return int(pow64(int64(x), int64(y)))
}

func main() {
	solve()
	writer.Flush()
}

func solve() {
	W, H, N := nextInt(), nextInt(), nextInt()
	x, y, a := make([]int, N), make([]int, N), make([]int, N)
	for i := 0; i < N; i++ {
		x[i], y[i], a[i] = nextInt(), nextInt(), nextInt()
	}
	minX, minY, maxX, maxY := 0, 0, W, H
	for i := 0; i < N; i++ {
		switch a[i] {
		case 1:
			minX = max(minX, x[i])
		case 2:
			maxX = min(maxX, x[i])
		case 3:
			minY = max(minY, y[i])
		case 4:
			maxY = min(maxY, y[i])
		}
	}
	out(max(0, maxX-minX) * max(0, maxY-minY))
}


Measured memory_bytes: 640
MODE = "stdio"
require 'matrix'

tmp = Array.new

class Integer
  def divisor_list2
    return [1] if self == 1
    (1..Math.sqrt(self).to_i).select do |i|
      self%i == 0
    end.map {|e| [e, self/e]}.flatten.uniq.sort
  end
end

if(defined? MODE)
  tmp = STDIN.read.split("\n")
else
  iotmp = "\
  2 4
  ".split("\n")
  iotmp.each{|s|
    tmp << s.strip
  }
end


class MaxMin
  def initialize(a,b)
    @a = a
    @b = b
  end

  def display
    if @a < @b
      print "a"," < ", "b","\n"
    elsif @a > @b
      print "a"," > ", "b","\n"
    else
      print "a"," == ", "b","\n"
    end
  end
end


a,b = tmp[0].split(" ").map(&:to_i)

maxmin = MaxMin.new(a,b)

maxmin.display

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

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int N;
    cin >> N;

    vector<int> A(N);
    rep(i,0,N-1) {
        int tmp; cin >> tmp;
        A[tmp - 1]++;
    }

    rep(i,0,N) cout << A[i] << endl;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b && b==c) {
        cout <<  "Yes" << endl;
    }else if( c > a && c < b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.List
import Data.List.Split
import Data.Char

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
cond t f c = if c then t else f
-- end of templete

f :: (Floating f, RealFrac f) => (f, f, Int) -> [[Int]] -> [Int]
f (x, y, _) [] = map truncate [x, y]
f (x, y, t) ([d, a]:s) = f (x + d' * cos theta, y + d' * sin theta, mod (t - a) 360) s
  where
    d' = fromIntegral d
    theta = (fromIntegral t) * pi / 180

main = do
  takeWhile (any (/=0)) . map (map readInt . wordsBy (==',')) . lines <$> getContents >>= mapM print . f (0, 0, 90)

Measured memory_bytes: 4104
from bisect import bisect_left
def main():
    A, B, q = map(int, input().split())
    INF = 10**18
    s = [-INF] + [int(input()) for _ in range(A)] + [INF]
    t = [-INF] + [int(input()) for _ in range(B)] + [INF]
    for _ in range(q):
        x = int(input())
        sind = bisect_left(s, x)
        tind = bisect_left(t, x)
        
        res = INF
        for S in [s[sind-1], s[sind]]:
            for T in [t[tind-1], t[tind]]:
                d1 = abs(x-S) + abs(S-T)
                d2 = abs(x-T) + abs(T-S)
                res = min([res, d1, d2])
        print(res)
main()

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

int main()
{
	int n;
	cin >> n;
	vector<pair<double,double>> vp(n);
	for(int i = 0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		vp[i] = make_pair(x,y);
	}

	double cnt = 0,ans = 0;
	sort(vp.begin(),vp.end());
	do
	{
		for(int i = 0;i<n-1;i++)
		{
			ans += sqrt(pow(vp[i].first-vp[i+1].first,2.0)+pow(vp[i].second-vp[i+1].second,2.0));
		}
		cnt+=1.0;
	} while (next_permutation(vp.begin(),vp.end()));
	printf("%.10lf\n",ans/cnt);
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

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

	auto ans = 0ll;
	if (N % 2 == 0)
	{
		for (auto i = 0; i < N; ++i)
		{
			if (i < N / 2 - 1)
			{
				ans -= 2 * A[i];
			}
			else if (i == N / 2 - 1)
			{
				ans -= A[i];
			}
			else if (i == N / 2)
			{
				ans += A[i];
			}
			else
			{
				ans += 2 * A[i];
			}
		}
	}
	else
	{
		auto sum = 0ll;
		for (auto i = 0; i < N; ++i)
		{
			if (i < N / 2)
			{
				sum -= 2 * A[i];
			}
			else if (i < N / 2 + 2)
			{
				sum += A[i];
			}
			else
			{
				sum += 2 * A[i];
			}
		}
		ans = sum;
		sum = 0ll;
		for (auto i = 0; i < N; ++i)
		{
			if (i < N / 2 - 1)
			{
				sum -= 2 * A[i];
			}
			else if (i < N / 2 + 1)
			{
				sum -= A[i];
			}
			else
			{
				sum += 2 * A[i];
			}
		}
		ans = max(ans, sum);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import sys

for i in sys.stdin:
    h,w = map(int,i.strip().split())

    if h==0 and w==0:
        break

    for i in range(h):
        for j in range(w):
            if (i+j) % 2 == 0:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()

Measured memory_bytes: 8984
n,k=map(int,input().split())
p=list(map(int,input().split()))

pi={}
pi[0]=0
pi[1]=1
for i in range(2,1002):
    pi[i]=pi[i-1]+i
    pi[i-1]=pi[i-1]/(i-1)

temp=0
for i in range(k):
    temp+=pi[p[i]]
    #print("start",temp)



#print(temp)
result=temp

for i in range(k,n):
    temp=temp-pi[p[i-k]]+pi[p[i]]
    #print(temp)
    result=max(result,temp)
print(result)


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << 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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;


int main(){

  ll l;cin>>l;

  out(setprecision(10)<<pow(l/3.0,3));

  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int searchA(int s[],int key,int head,int tail){
    if(head>tail)return -1;
    
    int mid=(head+tail)/2;
    
    if(s[mid]==key){
        if(mid-1<0||s[mid-1]!=key)return mid;
        else tail=mid-1;
    }
    else if(s[mid]>key)tail=mid-1;
    else if(s[mid]<key)head=mid+1;
    
    return searchA(s,key,head,tail);
}
int searchB(int s[],int key,int head,int tail){
    if(head>tail)return -1;
    
    int mid=(head+tail)/2;
    
    if(s[mid]==key){
        if(mid+1>tail||s[mid+1]!=key)return mid;
        else head=mid+1;
    }
    else if(s[mid]>key)tail=mid-1;
    else if(s[mid]<key)head=mid+1;
    
    return searchB(s,key,head,tail);
}
int getLB(int s[],int key,int head,int tail){
    if(s[0]>key||tail<0)return 0;
    if(s[tail]<key||head>tail)return tail+1;
    
    int mid=(head+tail)/2;
    
    if(s[mid]<key)head=mid+1;
    else if(s[mid]>=key){
        if(s[mid-1]<key)return mid;
        else tail=mid-1;
    }
        
    return getLB(s,key,head,tail);
}
int insert(int s[],int key,int cnt){
    int d;
    if(cnt==0)d=0;
    else d=getLB(s,key,0,cnt-1);
    
    int i;
    for(i=cnt;i>d;i--)s[i]=s[i-1];
    s[i]=key;
    return 1;
}
int delete(int s[],int key,int cnt){
    int h,t;
    h=searchA(s,key,0,cnt-1);
    if(h<0)return 0;
    t=searchB(s,key,h,cnt-1);
    
    int i,j;
    for(i=h,j=1;i<cnt;i++,j++)s[i]=s[t+j];
    return t-h+1;
}
void dump(int s[],int l,int r,int cnt){
    int i;
    i=getLB(s,l,0,cnt-1);

    while(s[i]<=r&&i<cnt)printf("%d\n",s[i++]);
    return;
}
void print(int s[],int cnt){
    printf("cnt=%d,s:",cnt);
    for(int i=0;i<cnt;i++)printf("%d ",s[i]);
    printf("\n");
    return;
}
int main(void){
    int q;
    scanf("%d\n",&q);
    
    int s[q];
    int cnt=0;
    
    int com,x,y;
    int h,t;
    while(q--){
        scanf("%d ",&com);
        switch(com){
            case 0:
                //insert
                scanf("%d\n",&x);
//    printf("insert:%d\n",x);
                if(insert(s,x,cnt)==1)cnt++;
                printf("%d\n",cnt);
                break;
            case 1:
                //find
                scanf("%d\n",&x);
//    printf("find:%d\n",x);
                h=searchA(s,x,0,cnt-1);
                if(h==-1){
                    printf("0\n");
                    break;
                }
                t=searchB(s,x,h,cnt-1);
//    printf("h=%d,t=%d\n",h,t);
                printf("%d\n",t-h+1);
                break;
            case 2:
                //delete
                scanf("%d\n",&x);
//    printf("delete:%d\n",x);
                cnt-=delete(s,x,cnt);
                break;
            case 3:
                //dump
                scanf("%d %d\n",&x,&y);
//    printf("dump:%d %d\n",x,y);
                dump(s,x,y,cnt);
                break;
        }
//        print(s,cnt);
    }
    
    return 0;
}



Measured memory_bytes: 2476
import java.util.Scanner;
class Main {
 public static void main(String[] args){
  Scanner in = new Scanner(System.in);
  int a = in.nextInt();
  int b = in.nextInt();
  int c = in.nextInt();
  if(a < b && b < c) System.out.println("Yes");
  else System.out.println("No");
 }
}

Measured memory_bytes: 17156
#include<bits/stdc++.h>
using namespace std;
int main(){

  string s;
  cin>>s;

  int cnt=0;

  for(int i=0;i<4;i++){
    if(s[i]=='+'){
      cnt++;
    }
    else if(s[i]=='-'){
      cnt--;
    }
  }

  cout<<cnt<<endl;

  return 0;

}


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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int):
    s = set([A, B, C])
    if len(s) == 2:
        print("Yes")
    else:
        print("No")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
typedef long long ll;

int n;
ll c, k;
ll t[100005];

int main(int argc, char const *argv[]) {
	cin >> n >> c >> k;
	FOR(i, n) cin >> t[i];
	sort(t, t+n);
	int ans = 0, cur = 0;
	ll last;
	FOR(i, n) {
		if (cur == 0 || t[i] > last) {
			ans++;
			cur = 1;
			last = t[i] + k;
		}
		else {
			cur++;
		}
		if (cur == c) cur = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
n=int(input())
s=[input() for i in range(n)]
c=[[0]*26 for i in range(n)]
a=[0]*26

for i,ss in enumerate(s):
    for sss in ss:
        c[i][ord(sss)-97]+=1

for i in range(26):
    tmp=10**9
    for j in range(n):
        tmp=min(tmp,c[j][i])
    a[i]=tmp

ans=[]
for i,aa in enumerate(a):
    t_str=chr(i+97)
    ans+=[t_str]*aa
ans.sort()
print(''.join(ans))


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

using namespace std;

int tab[100010];

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

    int a, b, wy=numeric_limits<int>::max();
    cin >> a >> b;
    if( a <= b ) {
        wy = min( wy, b-a );
    }
    if( -a <= b ) {
        wy = min( wy, b+a+1 );
    }
    if( a <= -b ) {
        wy = min( wy, -b-a+1 );
    }
    if( -a <= -b ) {
        wy = min( wy, -b+a+2 );
    }
    cout << wy;

    return 0;
}


Measured memory_bytes: 256
def merge(a, left, mid, right)
    n1 = mid - left
    n2 = right - mid
     
    l = Array.new(n1+1)
    r = Array.new(n2+1)
     
    for i in 0..n1-1 do
        l[i] = a[left + i]
    end
    for i in 0..n2-1 do
        r[i] = a[mid + i]
    end
     
    l[n1] = 10 ** 9
    r[n2] = 10 ** 9
     
    i = 0
    j = 0
    for k in left..right-1 do
        if l[i] <= r[j]
            a[k] = l[i]
            i = i + 1
        else
            a[k] = r[j]
            j = j + 1
        end
        $cnt += 1
    end
end
 
def merge_sort(a, left, right)
    if left + 1 < right
        mid = (left + right) / 2
        merge_sort(a, left, mid)
        merge_sort(a, mid, right)
        merge(a, left, mid, right)
    end
end
 
n = gets.chomp.to_i
s = gets.chomp.split(" ").map(&:to_i)
 
$cnt = 0
merge_sort(s, 0, n)
 
puts s.join(" "),$cnt

Measured memory_bytes: 65448
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, d) = in.readLine.split(" ").map(_.toInt)
  val x = Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  var cnt = 0
  for(i <- 0 until n) {
    for(j <- i+1 until n) {
      val dist = (0 until d).map {z =>
        val v = x(i)(z) - x(j)(z)
        v * v
      }.sum


      if(math.sqrt(dist) % 1 == 0) cnt+=1
    }
  }

  println(cnt)
}

Measured memory_bytes: 25548
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll r;
  cin >> r;
  str ans;
  if(r<1200){
    ans = "ABC";
  }else if(r<2800){
    ans = "ARC";
  }else{
    ans = "AGC";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           ((ll)x.size())
#define hell            (1000000007)
#define inf             ((ll)5e18 + 5)
#define PI              ((double)3.14159265358979323844)
#define DECIMAL(n)      cout << fixed << setprecision(n);
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define bitcount(a)     (ll)__builtin_popcount(a)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741


ll expo(ll base, ll exponent) {                     //return base^exponent modulo hell
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%hell;
        }
        base = base*base;
        base %= hell;
        exponent>>= 1;
    }
    return ans%hell;
}
ll add(ll a,ll b) {
    return ((a%hell)+(b%hell))%hell;
}
ll sub(ll a,ll b) {
    return ((a%hell)-(b%hell)+hell)%hell;
}
ll mul(ll a,ll b) {
    return ((a%hell)*(b%hell))%hell;
}
void solve() {
    ll n;
    cin>>n;
    ll arr[n];
    ll sum=0, meow=0;
    rep(i, 0, n) {
        cin>>arr[i];
        sum=add(sum, arr[i]);
        meow=add(meow, mul(arr[i], arr[i]));
    }
    sum=mul(sum, sum);
    ll temp=sub(sum, meow);
    cout<<mul(temp,expo(2, hell-2))<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 5220
#abc119 a
s=input()
year=s[:4]
month=s[5:7]
day=s[8:]
flag=False
if year<"2019":
    flag=True
elif year=="2019":
    if month<="04":
        if day<="30":
            flag=True
if flag:
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int64,int64>;

const int MOD = 1000000007;
int main() {
    int64 n;
    cin >> n;
    vector<int64> a(n);
    for (int64 i=0; i<n; i++) cin >> a[i];

    sort(a.rbegin(), a.rend());
    vector<P> len(1, P(a[0], 0));
    for (const auto& ai : a) {
        if (len.back().first == ai) len.back().second++;
        else len.emplace_back(ai, 1);
    }

    if (n % 2 == 1 && len.back().first == 0 &&  len.back().second == 1) len.pop_back();
    bool f = all_of(len.begin(), len.end(), [](P p){return p.second == 2;});

    int ans = 1;
    if (f) {
        for (int i=0; i<n/2; i++) {
            ans *= 2;
            ans %= MOD;
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2296
//  .:::.   .:::.
// :::::::.:::::::
// :::::::::::::::
// ':::::::::::::'
//   ':::::::::'
//     ':::::'
//       ':'
#include <bits/stdc++.h>
#define rep(i,a,b) for (i=a;i<b;i++)
#define rep2(i,a,b) for (i=a;i>=b;i--)
#define mod 1000000007
#define mod2 998244353
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define INF  1e9+5
#define f first
#define s second
#define endl '\n'
#define ll long long
#define ii pair <int,int>
#define pll pair <ll,ll>
#define vi vector <int>
#define vl vector <ll>
#define vvi vector < vi >
#define vii vector < ii >
#define vpl vector < pll >
#define vvii vector < vii >
#define vll vector < ll >
#define vb  vector <bool>
#define pb push_back
#define mk make_pair
#define pg priority_queue<ll, vector<ll>, greater<ll>>
#define pq priority_queue<ll>
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define cset(a) __builtin_popcountll(a)
#define FILL(a, b, T) fill_n((T *)a, sizeof(a) / sizeof(T), b)
using namespace std;
const ll k_lim = 1e4; 
ll k;
string ss;
ll dp[10001][101][2];
ll call(ll pos, ll digsum, ll matches)
{
    ll i;
    ll lim = 9;
    ll dig = ss[pos] - '0';
    if( matches)
        lim = dig;
    ll &ans = dp[pos][digsum][matches];
    if( pos < 0)
    {
        return (digsum == 0);
    }
    if( ans != -1)
        return ans;
    ans = 0;
    rep(i,0,lim + 1)
    {
        ans+=call(pos - 1, (i + digsum)%k, ( matches and (lim == i) ) );
        ans%=mod;
    }
    return ans;
}
ll count()
{
    reverse(all(ss));
    FILL(dp,-1,ll);
    return call(sz(ss) - 1, 0, 1);
}
int main()
{
    FIO;
    ll t, q, maxx, n, i, j, k1, k2, k3, x, flag, ans, sum, cnt, prev;
    string ss1, ss2;
    cin>>ss>>k;
    // cout<<ss<<endl;
    ans = count() - 1;
    ans+=mod;
    ans%=mod;
    cout<<ans<<endl;
    return 0;    
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> p(n+1);
  for(int i = 1;i<=n;i++) cin >> p[i];
  
  int k = 0;
  for(int i = 1;i<=n;i++){
    if(p[i]!=i) k++;
  }

  if(k>2){
    cout << "NO" << endl;
    return 0;
  }
  else{
    cout << "YES" << endl;
    return 0;
  }
  
  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
int n,a,x;
bitset<15>BIT;
int main()
{
	scanf("%d %d",&n,&a);
	for(int i=0;i<15;i++)BIT[i]=false;
	for(int i=1;i<=a;i++)scanf("%d",&x),BIT[x]=true;
	while(1)
	{
		int k=n;
		bool p=true;
		while(k>0)
		{
			if(BIT[k%10])p=false;
			k/=10;
		}
		if(p)
		{
			printf("%d",n);
			break;
		}
		n++;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    vector<ll> m(n,0);
    rep(i,n){
        if(i%2 == 0) m[0] += v[i];
        else m[0] -= v[i];
    }
    for(int  i = 1; i < n; i++){
        m[i] = 2*v[i-1] - m[i-1];
    }
    rep(i,n) cout << m[i] << endl;
    return 0;
}

Measured memory_bytes: 4752
# input = sys.stdin.readline
from bisect import *
from collections import *
from heapq import *

N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]
data=[[] for i in range(N+1)]
for a,b in AB:
    data[a].append(b)
    data[b].append(a)

count=0
stack=[[1,"1"]]
while stack:
    point,visited=stack.pop()
    for p in data[point]:

        if not str(p) in visited:
            vis=visited+str(p)
            if len(vis)==N:
                count+=1
            else:
                stack.append([p,visited+str(p)])
print(count)


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

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(int argc, const char * argv[]) {
    ll N; cin>> N;
    
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    ll ans=0;
    
    map<ll,ll> L;
    map<ll,ll> R;
    rep(i,N){
//        L[i+A[i]]++;
        R[i-A[i]]++;
    }
    rep(i,N){
        ans += R[i+A[i]];
    }
    
    cout << ans << endl;
    
    
    
    

    
    return 0;
}


Measured memory_bytes: 27272
import java.lang.*;
import java.io.*;
import java.util.*;

class Main{
	public static void main(String args[]) throws FileNotFoundException{
		FScanner fs=new FScanner();
		//Scanner sc=new Scanner(System.in);
		
		int[] num=fs.readIntL();
		
		System.out.println((num[0]-1)*(num[1]-1));
		
	}
	
	static void solver(){
		
	}

	static void disp(int[] data){
		for(int i=0; i<data.length; i++){
				System.out.printf("%d ",data[i]);
		}
			System.out.println();
	}
	
	static class FScanner{
		Scanner sc;
		FScanner() throws FileNotFoundException{
			sc=new Scanner(System.in);
		}
		boolean hasNextLine(){
			boolean has=true;
			if(!sc.hasNextLine()){
				has=false;
			}
			return has;
		}
		int readInt(){
			int i=Integer.parseInt(sc.nextLine());
			return i;
		}
		int[] readIntL(){
			String[] buf=sc.nextLine().split(" ");
			int[] num=new int[buf.length];
			for(int i=0; i<buf.length; i++){
				num[i]=Integer.parseInt(buf[i]);
			}
			return num;
		}
		String[] readStringL(){
			String[] s=sc.nextLine().split("");
			return s;
		}
	}
}


Measured memory_bytes: 21332
/*
make a=.

(a+b)%k=0
(a+c)%k=0
(b+c)%k=0

*/
#include <cstdio>
typedef long long int64;
using namespace std;
const int SQRT=450;
int64 c[SQRT+50];
int n, m, i, j, k, step;
int64 ans;
int main(){
    scanf("%d %d", &n, &m);
    if(m>=SQRT){
        if(m&1) step=m;
        else step=m>>1;
        for(i=step; i<=n; i+=step){
            for(j=step; j<=n; j+=step){
                for(k=step; k<=n; k+=step){
                    if((i+j)%m==0 and (j+k)%m==0 and (i+k)%m==0){
                        ans++;
                    }
                }
            }
        }
    }
    else{
        for(i=1; i<=n; i++) c[i%m]++;
        for(i=0; i<m; i++)
            for(j=0; j<m; j++)
                for(k=0; k<m; k++)
                    if((i+j)%m==0 and (j+k)%m==0 and (i+k)%m==0){
                        ans+=(int64)c[i]*c[j]*c[k];
                    }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
# ABC151 D String Formation
from collections import deque

s = deque(input())
q = int(input())

b_flag = False
for i in range(q):
    _list = [x for x in input().split()]
    if _list[0] == "1":
        if b_flag:
            b_flag = False
        else:
            b_flag = True
    else:
        if _list[1] == "1":
            if b_flag:
                s.append(_list[2])
            else:
                s.appendleft(_list[2])
        else:
            if b_flag:
                s.appendleft(_list[2])
            else:
                s.append(_list[2])

if b_flag:
    s.reverse()

print(*s,sep="")


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

int main()
{
  int a,b,c,d;
  d = 0;
  cin >>a>>b>>c;
  for(int i=a;i <b+1;i++){
    if(c%i == 0){d++;}
  }

  cout<<d<<endl;

  return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
 
## Library
 
import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy
 
## input
 
# N=int(input())
# A,B,C,D=map(int, input().split())
# S = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]
#    S = []
#    for _ in range(N):
#        S.append(list(input()))
 
X=int(input())

tmp = 0

for i in range(1,X+1):
    tmp = tmp+i
    if X <= tmp:
        print(i)
        sys.exit()

Measured memory_bytes: 77428