akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class NQueens
    {
        readonly int n;

        List<KeyValuePair<int, int>> qPos;
        int[] row;
        bool[] col, dpos, dneg;

        public NQueens(int N)
        {
            n = N;

            qPos = new List<KeyValuePair<int, int>>();
            row = new int[n];
            col = new bool[n];
            dpos = new bool[2 * n - 1];
            dneg = new bool[2 * n - 1];
        }

        public void AddQueen(int i, int j)
        {
            qPos.Add(new KeyValuePair<int, int>(i, j));
        }

        public void Solve(int i)
        {
            if (i == n)
            {
                if (CheckQueenPos()) PrintBoard();
                return;
            }

            for (int j = 0; j < n; j++)
            {
                if (!IsValid(i, j)) continue;

                ChangeBoard(i, j, true);
                Solve(i + 1);
                ChangeBoard(i, j, false);
            }
        }

        private void ChangeBoard(int i, int j, bool isSet)
        {
            row[i] = isSet ? j : -1;
            col[j] = dpos[i + j] = dneg[i - j + n - 1] = isSet;
        }

        private bool IsValid(int i, int j)
        {
            if (col[j]) return false;
            if (dpos[i + j]) return false;
            if (dneg[i - j + n - 1]) return false;
            return true;
        }

        private bool CheckQueenPos()
        {
            int m = qPos.Count;

            for (int i = 0; i < m; i++)
            {
                int index = qPos[i].Key;
                if (row[index] != qPos[i].Value) return false;
            }
            return true;
        }

        private void PrintBoard()
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    sb.Append(row[i] == j ? "Q" : ".");
                }
                sb.AppendLine();
            }
            Console.Write(sb);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            NQueens Q = new NQueens(8);

            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int h = int.Parse(input[0]);
                int w = int.Parse(input[1]);

                Q.AddQueen(h, w);
            }

            Q.Solve(0);
        }
    }
}

Measured memory_bytes: 9020
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> b[i];
  rep(i, 0, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());

  ll ans = 0;
  // Ai < Bj < Ck になる組 (i,j,k) の個数を求める場合
  // i を固定すれば求める個数は Ai < Bj なる i の個数と
  // Bj < Ck なる k の個数の積
  rep(i, 0, n) {
    ll mid = b[i];
    ll aa = lower_bound(a.begin(), a.end(), mid) - a.begin();
    ll cc = c.end() - upper_bound(c.begin(), c.end(), mid);
    ans += aa * cc;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4580
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    int ans = a-(2*b);
    if(ans<0)
    {
        cout<<0<<endl;
    }
    else
    {
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 1e5;
const int lgA = 60;
llong a[mxN+3];
char s[mxN+3];
int n;

struct LinearBasis
{
	llong a[mxN+3];
	void insert(llong x)
	{
		for(int i=lgA-1; i>=0; i--) if(x&(1ll<<i))
		{
			if(!a[i]) {a[i] = x; return;}
			else {x ^= a[i];}
		}
	}
	bool query(llong x)
	{
		for(int i=lgA-1; i>=0; i--) if(x&(1ll<<i))
		{
			if(a[i]) {x ^= a[i];}
			else {return false;}
		}
		return true;
	}
	void clear() {for(int i=0; i<lgA; i++) a[i] = 0ll;}
} lnbs;

int main()
{
	int T = read(); while(T--)
	{
		n = read();
		for(int i=1; i<=n; i++) scanf("%lld",&a[i]);
		scanf("%s",s+1);
		lnbs.clear(); bool ok = true;
		for(int i=n; i>=1; i--)
		{
			if(s[i]=='0') {lnbs.insert(a[i]);}
			else {ok &= lnbs.query(a[i]);}
		}
		if(ok) puts("0"); else puts("1");
	}
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define FAST() cin.tie(0), ios::sync_with_stdio(false)

#define NIL -1
#define LN() cout << '\n'
struct Node{
  int p,l,r;
  Node(): p(NIL), l(NIL), r(NIL){}
};

int N;
Node T[30];

void preorder(int u){
  if(u == NIL)return;
  cout << ' ' << u;
  preorder(T[u].l);
  preorder(T[u].r);
}
void inorder(int u){
  if(u == NIL)return;
  inorder(T[u].l);
  cout << ' ' << u;
  inorder(T[u].r);
}
void postorder(int u){
  if(u == NIL)return;
  postorder(T[u].l);
  postorder(T[u].r);
  cout << ' ' << u;
}

main()
{
  FAST();
  int v,l,r;
  int root;
  cin >> N;
  rep(i,N){
    cin >> v >> l >> r;
    T[v].l = l, T[v].r = r;
    T[l].p = T[r].p = v;
  }
  rep(i,N)
    if(T[i].p == NIL){
      root = i;
      break;
    }

  outl("Preorder");preorder(root);LN();
  outl("Inorder");inorder(root);LN();
  outl("Postorder");postorder(root);LN();
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll w, h;
    cin >> w >> h;
    ll p[w];
    rep(i,w)cin >> p[i];
    sort(p,p+w);
    ll q[h];
    rep(i,h)cin >> q[i];
    sort(q,q+h);
    ll ans = 0;
    ll i = 0;
    ll j = 0;
    while(true){
        if(i == w){
            if(j==h)break;
            ans += q[j];
            j++;
        }else if(j == h){
            ans += p[i];
            i++;
        }else{
            if(p[i] <= q[j]){
                ans += p[i] * (h + 1 - j);
                i++;
            }else{
                ans += q[j] * (w + 1 - i);
                j++;
            }
        }
    }

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


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val s = readLine()!!

    val len = s.length
    var diff1 = 0
    var diff2 = 0
    for (i in 0 until len) {
        var c1 = '0'
        var c2 = '0'
        if (i % 2 == 0) {
            c1 = '0'
            c2 = '1'
        } else {
            c1 = '1'
            c2 = '0'
        }

        if (s[i] != c1) {
            diff1++
        }
        if (s[i] != c2) {
            diff2++
        }
    }
    println(Math.min(diff1, diff2))
}

Measured memory_bytes: 34312
n = int(input())
ANS = []
even = [2, 10, 3, 9, 4, 8, 6, 12]
odd = [12, 2, 10, 3, 9, 4, 8, 6]
if n == 3:
    print(2, 5, 63)
else:
    p = n // 8
    r = n % 8
    if r % 2 == 0:
        tmp = even
    else:
        tmp = odd
    ANS += [12 * i + x for x in tmp for i in range(p)]
    ANS += [12 * p + x for x in tmp[:r]]
    print(*ANS)

Measured memory_bytes: 75564
#include <iostream>
#include <list>
#include <algorithm>
#include <iomanip>

using namespace std;

constexpr double sqrt3 = 1.73205080757;

struct Vec2
{
    double x, y;

    Vec2() : x(0.0), y(0.0) {}
    Vec2(double x_, double y_) : x(x_), y(y_) {}

    Vec2 operator-() const { return {x * -1, y * -1};}
    Vec2 operator+(const Vec2& rhs) const { return {x + rhs.x, y + rhs.y}; }
    Vec2 operator-(const Vec2& rhs) const { return {x - rhs.x, y - rhs.y}; }
    Vec2 operator*(double d) const { return {x * d, y * d}; }
    Vec2 operator/(double d) const { return {x / d, y / d}; }

    Vec2 operator+=(const Vec2& rhs) { x += rhs.x; y += rhs.y; return *this; }
    Vec2 operator-=(const Vec2& rhs) { x -= rhs.x; y -= rhs.y; return *this; }
    Vec2 operator*=(const Vec2& rhs) { x *= rhs.x; y *= rhs.y; return *this; }
    Vec2 operator/=(const Vec2& rhs) { x /= rhs.x; y /= rhs.y; return *this; }
};

Vec2 operator*(double d, const Vec2& rhs) { return {rhs*d}; }

void Koch(list<Vec2>& vertices, int n)
{
    if (n == 0)
        return;

    auto end = vertices.end();
    for (auto r = ++vertices.begin(); r != end; ++r)
    {
        auto l = r;
        --l;

        const Vec2 lr = *r - *l;
        
        list<Vec2> li = {
            {*l + lr / 3},
            {(*l + *r) / 2 + Vec2(-lr.y, lr.x) / 6 * sqrt3},
            {*r - lr / 3}        
        };

        vertices.insert(r, li.begin(), li.end());
    }

    Koch(vertices, --n);
}

int main()
{
    list<Vec2> vertices = {{0.0, 0.0}, {100.0, 0.0}};

    int n;
    cin >> n;

    Koch(vertices, n);

    cout << fixed << setprecision(8);
    
    for (const auto& v : vertices)
    {
        cout << v.x << ' ' << v.y << endl;
    }

    return 0;
}

Measured memory_bytes: 3420
#include <cstdio>

typedef long long ll;
const ll mod=1e9+7;

ll qmi(ll x,ll k)
{
    ll res=1;
    while(k)
    {
        if(k&1)res=res*x%mod;
        x=x*x%mod;
        k>>=1;
    }
    return res;
}

int main()
{
    int n;
    scanf("%d",&n);
    ll res=(qmi(10,n)+qmi(8,n)-2*qmi(9,n))%mod;
    printf("%lld\n",(res+mod)%mod);
    return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main(){
  ll n,m,X,Y,ii;
  vector<ll> x,y;
  ll maxX,minY;
  maxX = -200;
  minY = 200;
  cin >> n>>m>>X>>Y;

  x.resize(n);
  y.resize(m);

  for(ii=0;ii<n;ii++){
    cin >> x[ii];
    if(x[ii] > maxX){
      maxX = x[ii];
    }
  }
  
  for(ii=0;ii<m;ii++){
    cin >> y[ii];
    if(y[ii] < minY){
      minY = y[ii];
    }
  }
  ll z;
  z = maxX + 1;
  if(maxX < z && minY >= z &&  X < z && z <= Y){
    cout << "No War" << endl;
  }
  else{
    cout << "War" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int men[] = new int[6];
		for(int i = 0; i < 6; i++){
			men[i] = scan.nextInt();
		}
		String meirei = scan.next();

		
		Dice d = new Dice(men);
		d.turnDice(meirei);
		System.out.println(d.getDiceMen(1));
	}

}


class Dice{
	private int diceMen[] = new int[6];
	
	Dice(int men[]){
		for(int i = 0; i < 6; i++)
			this.diceMen[i] = men[i];
	}
	
	public int getDiceMen(int m){
		return this.diceMen[m - 1];
	}
	
	public void turnDice(String mei){
		int nullBox;
		char[] stWord = stlipWord(mei);
		for(char word: stWord){
			switch(word){
			case 'S':
				nullBox = this.diceMen[0];
				this.diceMen[0] = this.diceMen[4];
				this.diceMen[4] = this.diceMen[5];
				this.diceMen[5] = this.diceMen[1];
				this.diceMen[1] = nullBox;
				break;
			case 'E':
				nullBox = this.diceMen[0];
				this.diceMen[0] = this.diceMen[3];
				this.diceMen[3] = this.diceMen[5];
				this.diceMen[5] = this.diceMen[2];
				this.diceMen[2] = nullBox;
				break;
			case 'W':
				nullBox = this.diceMen[0];
				this.diceMen[0] = this.diceMen[2];
				this.diceMen[2] = this.diceMen[5];
				this.diceMen[5] = this.diceMen[3];
				this.diceMen[3] = nullBox;
				break;
			case 'N':
				nullBox = this.diceMen[0];
				this.diceMen[0] = this.diceMen[1];
				this.diceMen[1] = this.diceMen[5];
				this.diceMen[5] = this.diceMen[4];
				this.diceMen[4] = nullBox;
				break;
			}
		}
		
	}
	
	public char[] stlipWord(String mei){
		char[] stlipWord = new char[mei.length()];
		for(int i = 0; i < mei.length(); i++){
			stlipWord[i] = mei.charAt(i);
		}
		return stlipWord;
	}
	
}


Measured memory_bytes: 26196
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <vector>
#include <cstring>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <map>
#include <stack>
#include <cmath>
#define LL long long 
using namespace std; 
 
#define read(x) scanf("%d",&x)
#define Read(x,y) scanf("%d%d",&x,&y)
#define sRead(x,y,z)  scanf("%d%d%d",&x,&y,&z)
#define gc(x)  scanf(" %c",&x);
#define  INF (ll)1e14//无穷设置的大着点
#define mmt(x,y)  memset(x,y,sizeof x)
#define write(x) printf("%d\n",x)
const int N = 11000;
const int M=  2e5+5;
using namespace std;
typedef long long ll;
struct Edge
{
    int next;
    int to;
    ll dis;
}edge[M*2];
int head[M],tot;
ll d[M];bool vis[M];
inline void add(int from,int to,ll dis){
    edge[++tot].next = head[from];
    edge[tot].to = to;
    edge[tot].dis = dis;
    head[from] = tot;
}
struct node
{
    ll val;int id;
    node(){}
    node(int a,ll b):id(a),val(b){}
    bool operator <(node A)const{
        return val > A.val;
    }
};
void dij(int u)
{
    mmt(vis,0);
    d[u] = 0;
    priority_queue<node> Q;
    Q.push({u,0});
    node tmp;
    while(Q.size()){
        tmp = Q.top();
        Q.pop();
        int x = tmp.id;
        if(vis[x]) continue;
        for(int i =  head[x];~i;i = edge[i].next){
            int y = edge[i].to;
            ll dis = edge[i].dis;
            if(d[y] > d[x] +dis){
                d[y] = d[x] + dis;
                Q.push({y,d[y]});
            }
        }
    }
}
inline void init(int n)
{
    mmt(head,-1);
    tot = 0;
    for(int i = 1;i <= n;++i) d[i] = INF;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    init(n);
    int u,v;ll dis;
    for(int i = 1;i <= n;++i){//加反向边
        add(i,i - 1,0);
    }
    for(int i = 1;i <= m;++i){//只把端点 加进去
        cin>>u >> v>>dis;
        add(u,v,dis);
    }
    dij(1);
    if(d[n] == INF) cout<<-1<<endl;
    else cout<<d[n]<<endl;
}


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

int main()
{
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double rad_m = m / 60 * 360;
    double rad_h = (60 * h + m) / 720 * 360;
    double sa = abs(rad_m - rad_h);
    if (sa > 180)
        sa = 360 - sa;
    double ans = a * a + b * b - 2 * a * b * cos(sa / 180 * 3.14159265359);
    printf("%.11lf\n", pow(ans, 0.5));
    return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		if(Math.Min(p[0], p[1]) <= p[2] && p[2] <= Math.Max(p[0], p[1]))
		{
			Console.WriteLine("Yes");
			return;
		}
		Console.WriteLine("No");
		
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll M = 1e9 + 7;
int main() {
    ll N;
    cin >> N;
    vector<ll> T(N), A(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll maxl = max_element(T.begin(), T.end()) - T.begin();
    reverse(A.begin(), A.end());
    ll maxr = max_element(A.begin(), A.end()) - A.begin();
    maxr = N - 1 - maxr;
    reverse(A.begin(), A.end());

    bool flag = true;
    if (maxl > maxr) {
        flag = false;
    }
    int a = maxl, b = maxr;
    if (T[a] != A[b]) {
        flag = false;
    }

    ll sum = 1;
    for (int i = 1; i < maxl; i++) {
        if (T[i] == T[i - 1]) {
            sum *= T[i];
            sum %= M;
        }
    }
    for (int i = N - 2; i > maxr; i--) {
        if (A[i] == A[i + 1]) {
            sum *= A[i];
            sum %= M;
        }
    }

    ll gap = maxr - maxl - 1;
    while (gap > 0) {
        sum *= T[N - 1];
        sum %= M;
        gap--;
    }

    cout << (flag ? sum : 0) << endl;
}


Measured memory_bytes: 1792
N, Y = map(int, input().split())
flag = False
for x in range(0, N+1):
    for y in range(0, N+1-x):
        z = N-x-y
        if 10000*x + 5000*y + 1000*z == Y and x+y+z==N:
                print(x,y,z)
                flag = True
                break
    if flag:
        break
else:
    print('-1 -1 -1')

Measured memory_bytes: 3064
/*    Mohammed Sami Khan
                       মোহাম্মদ সামী খান
*/
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define endl "\n"
#define mp(a,b) make_pair(a,b)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef unsigned long long ull;

bool sortbysecc(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}

int main()
{
    fastio;
    //freopen("alchemy_input.txt", "r", stdin);
    //freopen("output2.txt", "w", stdout);
    ll tc, t, n, m, p, q, r, i, j, k, x, d, f=0;
    //cin>>tc;
    tc=1;
    while(tc--){
        cin>>n;
        if(n%1000==0) cout<<0;
        else cout<<1000 - n%1000;
    }
}


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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var nm = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            var result = 0L;

            var keisuu = 2;

            if(nm[0] != nm[1]) {
                if(Math.Abs(nm[0] - nm[1]) == 1) {
                    keisuu = 1;
                } else {
                    keisuu = 0;
                }
            }

            result = keisuu * (nPr(nm[0], nm[0]) * nPr(nm[1], nm[1]) % (1000000000 + 7));
            result %= (1000000000 + 7);

            Console.WriteLine(result);

            Console.Out.Flush();
        }


        /// <summary>
        /// nPrを求める
        /// </summary>
        public static long nPr(int n, int r)
        {
            // naive: return Factorial(n) / Factorial(n - r);
            return FactorialDivision(n, n - r);
        }

        private static long FactorialDivision(int topFactorial, int divisorFactorial)
        {
            long result = 1;
            for (int i = topFactorial; i > divisorFactorial; i--) {
                result *= i;
                result %= (1000000000 + 7);
            }
            return result;
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void)
{
    int ninzu,gokei[6]={0};
    double seito[40]={0};
    int i,j,k,l;

    scanf("%d",&ninzu);
    for(i=0;i<ninzu;i++)
    {
        scanf("%lf",&seito[i]);
        if(seito[i]<165)gokei[0]++;
        else if(seito[i]>=165 && seito[i] <170)gokei[1]++;
        else if(seito[i]>=170 && seito[i] <175)gokei[2]++;
        else if(seito[i]>=175 && seito[i] <180)gokei[3]++;
        else if(seito[i]>=180 && seito[i] <185)gokei[4]++;
        else if(seito[i]>=185)gokei[5]++;
    }
    for(j=0;j<6;j++){
        printf("%d:",j+1);
        for(k=0;k<gokei[j];k++){
            printf("*");
        }
        printf("\n");
    }
    return 0;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()
#define reset(a, v) memset((a), v, sizeof(a))
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

const int N = 300005;

int n, k;
int dat[N];
int segtree[N*4];

void update(int id, int L, int R, int pos, int v) {
	if (L == R) {
		segtree[id] = v;
		return;
	}
	int mid = (L+R)>>1;
	if (pos <= mid) update(id<<1, L, mid, pos, v);
	else update(id<<1|1, mid+1, R, pos, v);
	segtree[id] = max(segtree[id<<1], segtree[id<<1|1]);
}

int query(int id, int L, int R, int x, int y) {
	if (x <= L && R <= y) return segtree[id];
	int mid = (L+R)>>1;
	if (y <= mid) return query(id<<1, L, mid, x, y);
	if (x > mid) return query(id<<1|1, mid+1, R, x, y);
	return max(query(id<<1, L, mid, x, y), query(id<<1|1, mid+1, R, x, y));
}

int main() {
	scanf("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", &dat[i]);
	int ans = 0;
	for (int i = n; i >= 1; i--) {
		int x = max(0, dat[i]-k);
		int y = min(N-5, dat[i]+k);
		int res = 1 + query(1, 0, N-5, x, y);
		ans = max(ans, res);
		update(1, 0, N-5, dat[i], res);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 9100
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) ans += i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

#define rep(x,y) for(int x=0;x<(y);x++)

using namespace std;

int M,N;
char f[1024][1024];
char e[4][4];
char joi[]={'J','O','I'};

int same(int y, int x){
  if(y+1 >= M || x+1 >= N || y < 0 || x < 0) return 0;
  rep(i,2) rep(j,2) if(f[y+i][x+j] != e[i][j]) return 0;
  return 1;
}

int main(){
  scanf("%d%d", &M, &N);
  rep(i,M) scanf("%s", f[i]);
  rep(i,2) scanf("%s", e[i]);

  int sum = 0;
  rep(i,M-1) rep(j,N-1) if(same(i,j)) sum++;
  int res = sum;
  rep(i,M) rep(j,N) rep(al,3){
    if(f[i][j]==joi[al]) continue;
    int diff = 0;
    for(int k=max(0,i-1);k<=min(M-2,i);k++){
      for(int l=max(0,j-1);l<=min(N-2,j);l++){
	if(same(k,l)) diff--;
      }
    }
    char tmp = f[i][j];
    f[i][j] = joi[al];

    for(int k=max(0,i-1);k<=min(M-2,i);k++){
      for(int l=max(0,j-1);l<=min(N-2,j);l++){
	if(same(k,l)) diff++;
      }
    }
    f[i][j] = tmp;

    res= max(res, sum+diff);
  }

  printf("%d\n", res);
}

Measured memory_bytes: 2200
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
  if (ch == 'A') return 1;
  else if (ch == 'C') return 2;
  else if (ch == 'G') return 3;
  else if (ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0) return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for( i = 0; i < M; i++) H[i][0] = '\0';
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %s", com , str);

    if(com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}


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

int main() {
  int N;
  std::string S;

  std::cin >> N;
  std::cin >> S;

  long long r = 0, g = 0, b = 0;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'R')
      r++;
    else if (S[i] == 'G')
      g++;
    else
      b++;
  }

  long long cnt = r * g * b;

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (S[i] == S[j])
        continue;

      int k = 2 * j - i;
      // if (k > N - 1)
      //   break;
      // if (S[i] != S[j] && S[j] != S[k] && S[i] != S[k]) {
      //   cnt--;
      // }

      if (k >= N || S[i] == S[k] || S[j] == S[k])
        continue;
      cnt--;
    }
  }

  std::cout << cnt << '\n';

  return 0;
}

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

const int NUM = 1e6;

int main(){
    int n;
    ll sum=0, ans=0;
    
    cin>> n;

    map<ll, ll> a;
    for(int i=0; i<n; i++){
        ll input;
        cin>>input;
        a[input]++;
        sum+=input;
    }
   // cout<<sum<<endl;
    int q;
    cin>>q;
    for(int i=0; i<q; i++){
        ll b, c;
        cin>> b >>c;

        sum-=a[b]*b;
        sum+=a[b]*c;
        if(c!=b){
            a[c]+=a[b];        
            a[b]=0;
        }

        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 9484
#include <iostream>
#include <string>
#include <cmath>
#include <vector>

using namespace std;

int main()

{
    string s;
    cin>>s;
    if(s.size()==2){
        cout<<s<<endl;
    }else{
        cout<<s[2]<<s[1]<<s[0]<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n;
	cin>>n;
	vector <string> S(n);
	for(int i=0;i<n;i++)
	{
		cin>>S[i];
	}
	map <string,int> mp;
	int t=0;
	for(int i=0;i<n;i++)
	{
		mp[S[i]]++;
	}
	for(auto x:mp)
	{
		if(t<x.second)	
		{
			t=x.second;
		}
	}
	for(auto x:mp)
	{
		if(x.second==t)
		{
			cout<<x.first<<endl;
		}
	}
}

Measured memory_bytes: 26752
#include <iostream>

#include <vector>


using namespace std;

int N, K;
vector<int> d;
vector<vector<int>> A;

void input() {
	cin >> N >> K;
	d.resize(K);
	A.resize(K, vector<int>());
	for (int i = 0; i < K; i++) {
		cin >> d[i];
		A[i].resize(d[i]);
		for (int j = 0; j < d[i]; j++) {
			cin >> A[i][j];
		}
	}
}

void solve() {
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		bool have = false;
		for (auto v : A) {
			for (auto p : v) {
				if (p == i) have = true;
			}
		}
		if (!have) ans++;
	}
	cout << ans << endl;
}

int main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1e5+1;
const ll inf = 2e18;
const ll M = 105;
ll Dp[N][M];
ll DP[N];
ll A[N];
signed main(){
   ll n,k;
   cin>>n>>k;
   for(ll i=1;i<=n;i++)cin>>A[i];
   for(ll i=2;i<=n;i++){
     ll mini=inf;
     for(ll j=1;j<=k&&i-j>0;j++){
         Dp[i][j] = DP[i-j]+abs(A[i]-A[i-j]);
         mini = min(mini,Dp[i][j]);
     }
     DP[i] = mini;
   }
   cout << DP[n] << '\n';
return 0;
}


Measured memory_bytes: 83840
program mitsuitrust2019A
	integer(8)::M1,D1,M2,D2
	read(5,*)M1,D1
	read(5,*)M2,D2
	
	if(M1/=M2)then
		print'(i0)',1
	else
		print'(i0)',0
	end if
end program mitsuitrust2019A


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
 
signed main(){
    int N;cin>>N;
    vector<long long> A(N);
    REP(i, N) cin >> A[i];
    long long ans=LLONG_MAX;
    int sig[2]={1,-1};
    REP(j,2){ 
        long long sum=0;
        long long count=0;
        REP(i,N){
            sum+=A[i];
            if(sig[(i^j)&1]*sum>=0){
                count+=llabs(sum)+1;
                sum=-sig[(i^j)&1];
            }
        }
        ans=min(ans,count);
    }
    cout<<ans<<endl;
}

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

//宣言
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//数値
#define MOD 1000000007
#define INF (1<<20)
const double EPS = 1e-10;
const double PI = acos(-1.0);

//操作
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,n) FOR(i,0,n)
#define REPB(i,n) for(int i=n;i>=0;i--)
#define SORT(A) sort(A,A+sizeof(A)/sizeof(A[0]))
#define VSORT(A) sort(A.begin(),A.end())
#define EXIST(s,e) (s.find(e)!=s.end())
#define PB push_back
#define MP make_pair

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

int main() {

	char s[100],t[100];
	cin >> s>>t;
	int a[100] = { 0 }, b[100] = { 0 };
	for (int i = 0;i <(int)strlen(s);i++) a[i] = (int)(s[i] - 42);
 	for (int i = 0;i < (int)strlen(t);i++) b[i] = (int)(t[i] - 42);
	sort(a,a+strlen(s)); sort(b,b+strlen(t));
	if (a[0] < b[strlen(t) - 1]) cout << "Yes" << endl;
	else if (a[0] == b[strlen(t) - 1]) {
		if (a[strlen(s) - 1] == b[0]&&strlen(s)<strlen(t)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	else {
		cout << "No" << endl;
	}


}



Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

void main() {
    while(true) {
        string str = readln.chomp;
        if (str == "END OF INPUT") break;
        str.split(" ").map!(s => s.length.to!string).reduce!"a~b".writeln;
    }
}

Measured memory_bytes: 2456
#include<bits/stdc++.h>
using namespace std;
 
int frog(int n, int dp[], int a[]){
    dp[1]=abs(a[1]-a[0]);
    for(int i=2; i<n; i++){
        int o1, o2;
        o1=dp[i-1]+abs(a[i]-a[i-1]);
        o2 = dp[i-2]+abs(a[i]-a[i-2]);
        dp[i]=min(o1, o2);
    }return dp[n-1];
}
 
int main(){
    int n;
    cin>>n;
    int a[n];
    int dp[n]={0};
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    cout<<frog(n, dp,a );
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
  }
  
  sort(v.begin(), v.end());
  
  int C = v.at(N - 1) - v.at(0) + 1;
  vector<int> u(C);
  
  for(int j = 0; j < C; j++){
  for(int i = 0; i < N; i++){
  u.at(j) += (v.at(i) - (j + v.at(0))) * (v.at(i) - (j + v.at(0)));
  }
  }
  
  sort(u.begin(), u.end());
  
  cout << u.at(0) << endl;
    
}

Measured memory_bytes: 256
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>

#define int long long
#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define showp(n) cerr<<n.fs<<", "<<n.sc<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showsp(n) for(auto z:n){cerr<<z.fs<<" "<<z.sc<<", "}cerr<<endl

#define yes printf("Yes\n")
#define no printf("No\n")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using ull=unsigned long long;
using vi=vector<int>;
using pint=pair<int,int>;

const int INF=1LL<<55;

int n,a,b;

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

    cin>>n>>a>>b;
    if(a>b) {cout<<0<<endl;return 0;}
    if(n==1){
        if(a==b){cout<<1<<endl;return 0;}
        else{cout<<0<<endl;return 0;}
    }
    int lo=a*(n-1)+b;
    int hi=a+b*(n-1);
    cout<<hi-lo+1<<endl;

    return 0;
}

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

int main() {
int n,k;
cin >> n >> k;
int s = 1;
rep(i,n){
  if(s*2 < s+k) s *= 2;
  else s += k;
}
cout << s << endl;

 }


Measured memory_bytes: 3592
a, b, c, k = map(int, input().split())
sum = 0
if a >= k:
    sum = 1*k
else:
    if b >= (k - a):
        sum = (1*a) + (0*(k-a))
    else:
        if c >= (k - a - b):
            sum = (1*a) + (0*(k-a)) + (-1*(k-a-b))
print(sum)

Measured memory_bytes: 9132
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	long x, y, z;
	cin >> x >> y >> z;
	cout << (x - z) / (y + z);
	return 0;
}

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

using namespace std;

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

typedef long long ll;

constexpr ll INF = 0x3fffffffffffffff;
constexpr int inf = 0x1fffffff;
constexpr double inf_l = 1e18;
constexpr ll MOD = 1000000007LL;
constexpr int mod = 1000000007;

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

Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

import bisect
ans = 0
for i, b in enumerate(B):
    a = bisect.bisect_left(A, b)
    c = bisect.bisect_right(C, b)
    ans += a * (N-c)

print(ans)

Measured memory_bytes: 24096
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<lint> vlint;

#define inf 1e+9
#define endl "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

#define pb push_back
#define eb emplace_back
#define Size(c) (int)(c).size()

#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))

template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

template <class T, class S> inline bool chmax(T &a, S b) {
    if(a < b) {a = b;return 1;} return 0;
}
template <class T, class S> inline bool chmin(T &a, S b) {
    if(a > b) {a = b;return 1;} return 0;
}
template <class T>
void line(vector<T> &x){for (auto&& xi : x) cin >> xi;}

inline void IN(void){ return;}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){ cin >> first; IN(rest...); return;}

#define INT(...) int __VA_ARGS__; IN (__VA_ARGS__)
#define LINT(...) lint __VA_ARGS__; IN (__VA_ARGS__)
#define STR(...) string __VA_ARGS__; IN(__VA_ARGS__)

template <class T> void UNIQUE(vector<T> &x) {
    sort(all(x)); x.erase(unique(all(x)), x.end());
}
template <class T> void print_vec(T first, T end){
    for (auto i = first; i < end - 1; i++) cout << *i << " ";
    cout << *(end-1) << endl;
}
template <class T> void print(T a){ cout << a << endl;};
vector<string> Yes = {"No", "Yes"};
vector<string> YES = {"NO", "YES"};

lint mod = 1e9+7;
lint inv[500001], fac[500001], finv[500001];

void finv_table(int k){
    int mod = 1e9 + 7;
    inv[0] = 0; inv[1] = 1;
    fac[0] = 1; fac[1] = 1;
    finv[0] = 1; finv[1] = 1;
    for (int i = 2; i < k+1; ++i){
        inv[i] = inv[mod % i] * (mod - (mod / i)) % mod;
        fac[i] = fac[i-1] * i % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

template<typename T, typename U>
lint comb(T n, U r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;

    return fac[n] * finv[r] % mod * finv[n-r] % mod;
    
}

int main(){
    finv_table(300000);
    INT(n, k); vlint a(n); line(a);
    sort(all(a));
    lint ans = 0;
    rep(i, n){
        ans += a[i] * comb(i, k-1) % mod; ans %= mod;
        ans -= a[i] * comb(n-i-1, k-1) % mod; ans %= mod;
    }
    if (ans < 0) ans += mod;
    print(ans);
  	return 0;
}
    



Measured memory_bytes: 11184
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] x = new int[3];
		for(int i=0;i<3;i++) {
			x[i] = in.nextInt();
		}
		Arrays.sort(x);
		int ans = 0;
		if((x[2]-x[1])%2==0) {
			if((x[2]-x[0])%2==0) {
				ans += (x[2]-x[1])/2;
				ans += (x[2]-x[0])/2;
			}else {
				ans += (x[2]-x[1])/2;
				ans += (x[2]-x[0])/2;
				ans += 2;
			}
		}else {
			if((x[2]-x[0])%2==0) {
				ans += (x[2]-x[1])/2;
				ans += (x[2]-x[0])/2;
				ans += 2;
			}else {
				ans += (x[2]-x[1])/2;
				ans += (x[2]-x[0])/2;
				ans += 1;
			}
		}
		System.out.println(ans);
		in.close();
		

	}

}


Measured memory_bytes: 21844
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B, C, X;
int dp[150][401];

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

  dp[0][0] = 1;

  rep( i, 3 ) rep( j, 401 )
  {
    if( i == 0 )
    {
      rep( k, A+1 )
        dp[i+1][j+k*10] += dp[i][j];
    }
    else if( i == 1 )
    {
      rep( k, B+1 )
        dp[i+1][j+k*2] += dp[i][j];
    }
    else if( i == 2 )
    {
      rep( k, C+1 )
        dp[i+1][j+k] += dp[i][j];
    }
  }

  printf( "%d\n", dp[3][X/50] );
  
  return 0;
}

Measured memory_bytes: 128
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    A, B, M = MAP()
    a = LIST()
    b = LIST()
    
    ans = 10000000
    for i in range(M):
        x, y, c = MAP()
        ans = min(ans, a[x-1] + b[y-1] - c) 

    print(min(ans, min(a) + min(b)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 65716
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
using namespace std;

vector<pair<int, pair<int, int> > >p(20000); // taikaku h w

int main(){
  int c = 0;
  REP(i, 1, 200) REP(j, i+1, 200) p[c++] = make_pair(i*i+j*j, make_pair(i, j));

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

  //  rep(i, 25) printf("%d %d %d\n", p[i].first, p[i].second.first, p[i].second.second);
  int w, h;
  while(scanf("%d%d", &h, &w) && w+h){
    rep(i, p.size()){
      //      if(w * w + h * h < p[i].first && (h != p[i].second.first || w != p[i].second.second)){
      if(p[i].second.first == h && p[i].second.second == w){
	printf("%d %d\n", p[i+1].second.first, p[i+1].second.second);
	break;
      }
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++){
       cin>>a[i];
   }
   int k=0;
   vector<int> v(n,0);
   for(int i=1;i<n;i++){
       if(a[i]==a[i-1] && v[i-1]==0){
           v[i]=1;
           k++;
       }
   }
   cout<<k<<endl;
   return 0;
}

Measured memory_bytes: 256
using System;
public class Hello{
    public static void Main(){
       int A = int.Parse(Console.ReadLine());
       int B = int.Parse(Console.ReadLine());
       int C = int.Parse(Console.ReadLine());
       int X = int.Parse(Console.ReadLine());
       int count = 0;
       for(int x = 0;x <= A;x++){
           for(int y = 0;y <= B;y++){
               for(int z = 0;z <= C;z++){
                   if(x * 500 + y * 100 + z * 50 == X){
                       count++;
                   }
               }
           }
       }
       Console.WriteLine(count);
       
    }
}


Measured memory_bytes: 13140
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let ss = scan!(;;);
    println!(
        "{}{}{}",
        ss[0].to_uppercase().chars().next().unwrap(),
        ss[1].to_uppercase().chars().next().unwrap(),
        ss[2].to_uppercase().chars().next().unwrap(),
    )
}


Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
int n;
char str[205];
int main(){
	scanf("%d" , &n);
	scanf("%s" , str);
	int sum = 0;
	int pre = 0;
	for(int i = 0 ; i < n ; ++i){
		sum += (str[i] == ')') ? -1 : 1;
		pre = min(pre , sum);
	}
	for(int i = pre ; i < 0 ; ++i){
		printf("(");
	}
	printf("%s" , str);
	sum -= pre;
	for(int i = 0 ; i < sum ; ++i){
		printf(")");
	}
}

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

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

signed main()
{
    int a,b,c,d; cin >> a >> b >> c >> d;

    while(1){
        c -= b;
        if (c <= 0){
            puts("Yes"); break;
        }
        a -= d;
        if (a <= 0){
            puts("No"); break;
        }
    }

    return 0;
}


Measured memory_bytes: 3636
N,K = map(int, input().split())
A = list(map(int,input().split()))
t = 0
for i in range(N-1):
  for j in range(N-i-1):
    if A[i] > A[j+i+1]:
      t += 1
u = 0
for i in range(N):
  for j in range(N):
    if A[i]>A[j]:
      u += 1
T = t%(10**9+7)
U = u%(10**9+7)
Z=K*(K-1)//2%(10**9+7)
Y=T*K%(10**9+7)
X=U*Z%(10**9+7)
ans = (Y+X)%(10**9+7)
   
print(ans)

Measured memory_bytes: 3188
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<cmath>
#include<cstring>
#include<iostream>
#define IOS ios::sync_with_stdio(0);cin.tie(0)
#define MEM(X,Y) memset(X,Y,sizeof(Y))
#define FRE freopen("abc.in", "r", stdin)
long long int gcd(long long int a, long long int b) { return b ? gcd(b, a % b) : a; }
using namespace std;


int main(void)
{
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int n;
	scanf("%d", &n);
	printf("%d", a[n - 1]);

}

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++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    ll res=0;
    map<ll,ll> m;
    rep(i,n){
        ll a; cin>>a;
        if(m[a]==1){
            m[a]=0;
            res--;
        }else{
            m[a]=1;
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
    long long int A,B,C,D, K, N;
    long long int new_A, new_B, new_C, new_K;
    long long int a, b, c, d, e, f, g, h, i, j, k, l, m, n, s, w;
    vector<long long int> a_v;
    string str;
    cin >> str;
    // cout << str << endl;
    long long int board[str.length()];
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == 'W') {
            board[i] = 1;
        } else {
            board[i] = 0;
        }
    }
    long long int sum = 0, cny = 0;
    for (int i = 0; i < str.length(); i++) {
        if (board[i] == 1) {
            sum += i-cny;
            cny++;
        }
    }
    cout << sum << endl;
    // for (int i = 0; i < N; i++) {
    //     long long int a;
    //     cin >> a;
    //     a_v.push_back(a);
    // }

    // int now = 1;
    // bool flag = false;
    // for (i = 0; i < N; i++) { 
    //     now = a_v[now-1];
    //     // cout << now << endl;
    //     if (now == 2) {
    //         flag = true;
    //         break;
    //     }
    // }

    // if (flag) {
    //     cout << i+1 << endl;
    // }
    // else {
    //     cout << "-1" << endl;
    // }

    // cin >> A;
    // cin >> B;
    // cin >> C;
    // cin >> D;

    // while(1) {
    //     C = C-B;
    //     if (C <= 0) {break;} 
    //     A = A - D;    
    //     if (A <= 0) {break;} 
    // }
    // if (A <= 0) {
    //     cout << "No" << endl;
    // }
    // else {
    //     cout << "Yes" << endl;
    // }
    // long long int tmp, cnt = 0;
    // tmp = b;
    // for (;;) {
    //     tmp = tmp/10;
    //     cnt ++;
    //     if (tmp > 0) {
    //     }
    //     else {
    //         break;
    //     }
    // } 
    // long long int time = 1;
    // for (int i = 0; i < cnt; i++) {
    //     time *= 10;
    // }
    // b += a*time;
    // // cout << b<< endl;
    // bool flag = false;
    // for (long long int i = 0; i < sqrt(b)+1; i++) {
    //     if (i*i == b) {
    //         flag = true;
    //     }
    // }
    // if (flag) {
    //     cout << "Yes" << endl;
    // }
    // else {
    //     cout << "No" << endl;
    // }

    return 0;
}

Measured memory_bytes: 2180
# coding: utf-8
# Your code here!
a,b,c,d=map(int, input().split())
if a==b:
    if c==d:
        print("yes")
    else:
        print("no")
elif a==c:
    if b==d:
        print("yes")
    else:
        print("no")
elif a==d:
    if b==c:
        print("yes")
    else:
        print("no")
else:
    print("no")



Measured memory_bytes: 5600
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func ave(s []float64) float64 {
	var sum float64
	for _, v := range s {
		sum += v
	}
	return float64(sum) / float64(len(s))
}

func diff(a, b float64) float64 {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()
	a := make([]float64, n)
	for i := 0; i < n; i++ {
		a[i] = float64(ri())
	}
	// fmt.Println(a)

	ave := ave(a)

	minDiff := 999999.9
	ansIndex := -1
	for i, v := range a {
		diff := diff(v, ave)
		if diff < minDiff {
			minDiff = diff
			ansIndex = i
		}
	}
	fmt.Println(ansIndex)
}


Measured memory_bytes: 640