akhauriyash/Code-Regression huggingface dataset:
//#include "pch.h"
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>
#include <sstream>
#include <time.h>
#include <numeric>
using namespace std;
//#define int long long
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define l1 list[index]
#define l2 list[index - 1]
#define l3 list[index + 1]
#define iif(i,j) ((i<0 && j<0) || (i>0 && j>0)) ? true : false 
typedef long long ll;
typedef pair<int, int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint, int> P1;
typedef pair<int, pint> P2;
typedef pair<pint, pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = 3.14159265359;
int ca[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };

ll K;
vector<string>slist;
vector<ll>list;

int func(string s, int index ) {

	if (s.length() >= 12) {
		//slist.push_back(s);
		//cout << s << endl;
		return 0;
	}

	list.push_back(stoll(s));


	char ch = s[index];
	char ch2 = s[index];

	if (ch == '0') {
		func(s + ch, index + 1);
		//s.pop_back();

		ch += 1;
		s += ch;
		func( s , index + 1);
		s.pop_back();
	}
	else if (ch == '9') {
		func(s + ch, index + 1);
		//s.pop_back();

		ch -= 1;
		s += ch;
		func(s, index + 1);
		s.pop_back();
	}
	else  {
		func(s + ch, index + 1);
		//s.pop_back();

		ch += 1;
		s += ch;
		func(s, index + 1);
		s.pop_back();

		ch2 -= 1;
		s += ch2;
		func(s, index + 1);
		s.pop_back();
	}

	//func({ s[index]  ,(char)s[index] + 1 }, index + 1);
	//func(s[index] + s[index] - 1, index + 1);




	return 0;
}


signed main() {
	
	cin >> K;

	for (int i = 1; i < 10; i++) {
		//func({ '0' }, 0);
		char ch = '0' + i;
		func({ ch }, 0);
	}

	//sort(slist.begin(), slist.end());
	sort(list.begin(), list.end());

	//cout << slist[K - 1] << endl;
	cout << list[K - 1] << endl;

	return 0;
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

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

  vector<int> dp(N, INF);
  dp[0] = 0;
  for(int i = 1; i < N; ++i) {
    dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if(i >= 2) {
      dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
  }

  cout << dp[N - 1] << endl;


  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
char s[N] ;
int k, n;
int main() {
    cin >> n >> k;
    scanf("%s", s + 1);
    s[k] = s[k] - 'A' + 'a' ;
    printf("%s", s + 1);
    return 0;
}


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

namespace A_ABC130
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
            s = Array.ConvertAll(Console.ReadLine().Split().ToArray(), int.Parse);
            if(s[0]<s[1]){
                Console.WriteLine(0);
            }else{
                Console.WriteLine(10);
            }
        }
    }
}


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(int i=n; i<m; i++)
#define INF 1000000007
#define INFL (1LL << 60)
#define MOD 998244353
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int

ll POW(ll a, ll b){
	if(b == 0) return 1LL;
	if(b == 1) return a;
	if(b %2 == 1) return (a*POW(a, b-1))%INF;
	return POW(a*a%INF, b/2);
}

ll GCD(ll a, ll b){
	if(a<b) return GCD(b,a);
	if(b==0) return a;
	return GCD(b,a%b);
}

int main(){
	int n, k;
	cin >> n >> k;
	double ans = 0;
	FOR(i, 1, n+1){
		int x = i, c = 0;
		while(k > x){
			x *= 2;
			c++;
		}
		double cp = 1;
		REP(j, c) cp /= 2.0;
		ans += cp / (double)n;
	}
	cout << setprecision(16) << ans << endl;
	return 0;
} 


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

using namespace std;

int main()
{
	int n;
	int tri[31];
	
	tri[0] = 1;
	tri[1] = 1;
	tri[2] = 2;
	
	while (cin >> n && n){
		
		for (int i = 3; i <= n; i++){
		    tri[i] = tri[i - 1] + tri[i - 2] + tri[i - 3];
		}
		
		cout << (tri[n] + 3649)/3650 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int arr[100100];
int vis[100100];
vector<int>v,vec[100100];
map<int,int>mp;
void dfs(int src)
{
    vis[src]=1;
    mp[src]++;
    mp[arr[src]]++;
    v.push_back(src);
    for(int i=0; i<vec[src].size(); i++)
    {
        int child=vec[src][i];
        if(!vis[child])
            dfs(child);
    }
}
void init()
{
    for(auto x:v)
    {
        if(mp[x]==2)
            arr[x]=x;

    }
    mp.clear();
    v.clear();
}
int main()
{

    int n,m;
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>arr[i];
    while(m--)
    {
        int u,v;
        cin>>u>>v;
        vec[u].push_back(v);
        vec[v].push_back(u);
    }
    for(int i=1; i<=n; i++)
    {
        if(vec[i].size() && !vis[i])
        {
            dfs(i);
            init();
        }
    }
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(arr[i]==i)
            cnt++;
    }
    cout<<cnt<<endl;


    return 0;
}


Measured memory_bytes: 20732
#include <bits/stdc++.h>
    #define ll long long
    using namespace std;
    const int Mod = 1e9+7;
    ll AA(ll x)
	{
        ll ans = 1, i = 1;
        while(i <= x)
		{
            ans = (ans*i)%Mod;
            i++;
        }
        return ans%Mod;
    }
    int main()
	{
        ll n,m;
        //cout << AA(100000) << endl;
        cin >> n >> m;
        if(abs(n-m) > 1)
		{
            cout << 0 << endl;
            return 0;
        }
        if(abs(n-m) == 1)
		{
            cout << (AA(n)*AA(m))%Mod << endl;
        }
		else 
		{
            cout << ((AA(n)*2%Mod)*AA(m))%Mod << endl;
        }
        return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,x=0;
	scanf("%d",&n);
	x = n%10;
	if(x==2 || x==4 || x==5 || x==7 || x==9)
		printf("hon\n");
	else if(x==0 || x==1 || x==6 || x==8)
		printf("pon\n");
	else if(x==3) 
		printf("bon\n");
	return 0;
}



Measured memory_bytes: 1660
/*
 * Problem     : AOJ1165
 * Title       : Pablo Squarson's Headache (角角画伯，かく悩みき)
 * Author      : mizo0203
 * Copyright   : Your copyright free
 * Description : やるだけ
 */

#include <stdio.h>
#include <memory.h>
#include <algorithm>
using namespace std;

int N;
int nx[200], ny[200];
int minx, maxx, miny, maxy;

bool input() {
  int i, n, d;

  scanf("%d", &N);
  if (!N)
    return false;
  nx[0] = 0;
  ny[0] = 0;
  for (i = 1; i < N; i++) {
      scanf("%d %d", &n, &d);
      switch (d) {
      case 0:
        nx[i] = nx[n] - 1;
        ny[i] = ny[n];
        break;
      case 1:
        nx[i] = nx[n];
        ny[i] = ny[n] + 1;
        break;
      case 2:
        nx[i] = nx[n] + 1;
        ny[i] = ny[n];
        break;
      case 3:
        nx[i] = nx[n];
        ny[i] = ny[n] - 1;
        break;
      }
  }

  return true;
}

int main() {
  int i;

  while (input()) {
    minx = 0;
    miny = 0;
    maxx = 0;
    maxy = 0;
    for (i = 1; i < N; i++) {
      if (minx > nx[i]) minx = nx[i];
      else if (maxx < nx[i]) maxx = nx[i];
      if (miny > ny[i]) miny = ny[i];
      else if (maxy < ny[i]) maxy = ny[i];
    }
    printf("%d %d\n", maxx - minx + 1, maxy - miny + 1);
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(), v.end()
using namespace std;

ll n,m,h[100010],maxH[100010],a,b,ans;

int main()
{

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

    cin >> n >> m;
    for(ll i=1; i<=n; i++) cin >> h[i];
    for(ll i=0; i<m; i++){
        cin >> a >> b;
        maxH[ a ] = max( maxH[ a ] , h[ b ] );
        maxH[ b ] = max( maxH[ b ] , h[ a ] );
    }
    for(ll i=1; i<=n; i++) if( maxH[ i ] < h[ i ] ) ans++;
    cout << ans;

    return 0;
}


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

int run(int n, int a, int b, int c, int x, vector<int> &y, vector<int> &z) {
  int head = 0;
  rep (t, 10000+1) {
    if (y[head] == z[t]) head++;
    // if (t > 10000) return -1;
    if (head == n) return t;
  }
  return -1;
}

int main() {
  int n, a, b, c, x;
  while(cin >> n >> a >> b >> c >> x, n) {
    vector<int> y(n);
    vector<int> z(10000*n+1);
    z[0] = x;
    rep (i, n) cin >> y[i];

    for (int i=1; i<=10000*n; i++) z[i] = (a*z[i-1] + b) % c;

    // cout << "y: ";
    // rep (i, n) cout << y[i] << ' ';
    // cout << endl;
    // cout << "z: ";
    // rep (i, 300) cout << z[i] << ' ';
    // cout << endl;

    int ans = run(n, a, b, c, x, y, z);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 10340
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int main(){
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int n,k;
	cin >> n >> k;
	int a[1100];
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a,a+n);
	int ans = 0;
    for(int i=0; i<k; i++){ 
    	ans+=a[i];
    }
    cout << ans << "\n";
    return 0;
}	

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 105
using namespace std;
int n,a[M],b[M];
int main()
{
    while (~scanf("%d", &n)) {
        REP(i,1,n-1) scanf("%d", &b[i]);

        REP(i,1,n) a[i] = 2000000000;
        REP(i,1,n-1) {
            a[i] = min(a[i], b[i]);
            a[i+1] = min(a[i+1], b[i]);
        }
        printf("%d\n", accumulate(a+1, a+n+1, 0));

    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#define long long
using namespace std;

int main(){
	long a, b;
	cin >> a >> b;
	if (a * b <= 0) {
		cout << "Zero" << endl;
		return 0;
	}
	if (b < 0) {
		int minus = (b - a + 1) % 2;
		if (minus) {
			cout << "Negative" << endl;
			return 0;
		}
	}
	cout << "Positive" << endl;
	return 0;
 
	return 0;
}


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

int main() {
    int n; cin >> n;
    deque<int> res;
    int isleft = n % 2;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        if (isleft) res.push_front(a);
        else res.push_back(a);
        isleft = 1 - isleft;
    }
    for (int i = 0; i < n; ++i) {
        cout << res[i] << " ";
    }
    cout << endl;
}



Measured memory_bytes: 2944
ab1 = [int(i) for i in input().split()]
ab2 = [int(i) for i in input().split()]
ab3 = [int(i) for i in input().split()]

node = [0, 0, 0, 0]
for i in [ab1, ab2, ab3]:
    for j in i:
        node[j-1] += 1
if max(node) == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

short checkTable[1001][1001];

int tmp_max=0;


void calc(int index,char pattern[],char to_search[],int to_search_length){

	for(int i=to_search_length-1;i>=0;i--){
		if(to_search[i]==pattern[index]){
			checkTable[index][i]=1;
			if(pattern[index+1]!='\0' && i < to_search_length-1){
				checkTable[index][i] = checkTable[index+1][i+1] + checkTable[index][i];
			}
		}else{
			if(i != to_search_length-1){
				if(pattern[index+1] != '\0'){
					checkTable[index][i]=(checkTable[index+1][i]>checkTable[index][i+1])
							?checkTable[index+1][i]:checkTable[index][i+1];

				}else{
					checkTable[index][i]=(checkTable[index][i+1]>0)?checkTable[index][i+1]:0;
				}
			}else{
				if(pattern[index+1] != '\0'){
					checkTable[index][i]=(checkTable[index+1][i]>0)?checkTable[index+1][i]:0;
				}else{
					checkTable[index][i] = 0;
				}
			}
		}
		tmp_max = (tmp_max >= checkTable[index][i])?tmp_max:checkTable[index][i];
	}
}

int main(){
	for(int i=0;i<1000;i++){
		for(int k=0; k < 1000; k++)checkTable[i][k]= -1;
	}

	int q,left_length,right_length;
	char left[1001],right[1001];

	scanf("%d",&q);

	for(int i=0;i<q;i++){
		left_length=0;
		right_length=0;
		scanf("%s %s",left,right);
		for(int k=0;left[k]!='\0';k++)left_length++;
		for(int k=0;right[k]!='\0';k++)right_length++;

		if(right_length>=left_length){

			for(int k=left_length-1;k>=0;k--)calc(k,left,right,right_length);
		}else{

			for(int k=right_length-1;k>=0;k--)calc(k,right,left,left_length);
		}
		printf("%d\n",tmp_max);
		tmp_max=0;
	}

    return 0;
}

Measured memory_bytes: 5152
#include <iostream>
#include <set>
#include <vector>
#include <functional>

using i64 = long long;

const int N = 400000 + 7;

int n;
int f[N], v[N];
std::vector<int> g[N];

int vf[N], sv[N], sz[N];
int getvf(int x) {
	return vf[x] == x ? x : vf[x] = getvf(vf[x]);
}

struct str {
	int x;
	bool operator<(const str& k) const {
		int u = x, v = k.x;
		return 1ll * sv[u] * sz[v] != 1ll * sv[v] * sz[u] ?
			1ll * sv[u] * sz[v] < 1ll * sv[v] * sz[u] : u < v;
	}
};
std::multiset<str> q;

int l[N];
i64 p, k;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	scanf("%d", &n);
	for (int i = 2; i <= n; ++i)
		scanf("%d", f + i), g[f[i]].push_back(i);
	for (int i = 1; i <= n; ++i)
		scanf("%d", v + i), vf[i] = i, sv[i] = v[i], sz[i] = 1;
	for (int i = 2; i <= n; ++i)
		q.insert((str){i});
	for (int s, t, k = 0; q.size(); ) {
		s = getvf(q.begin()->x), q.erase(q.begin());
		t = getvf(f[s]), q.erase((str){t});
		l[s] = ++k;
		vf[s] = t, sv[t] += sv[s], sz[t] += sz[s];
		if (t != 1) q.insert((str){t});
	}

	for (int i = 1; i <= n; ++i) sv[i] = l[i], sz[i] = 1;
	q.insert((str){1});
	for (int s; q.size(); ) {
		v[s = q.begin()->x] ? ++k : (p += k), q.erase(q.begin());
		for (auto t : g[s]) q.insert((str){t});
	}
	printf("%lld", p);
	return 0;
}


Measured memory_bytes: 33536
/*
AizuOnline A0024
Title phisical experiment
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
#include <float.h>
#include <math.h>
//#include <limits.h>
//Global data section

//
main()
{
  double v,t,x;
  int N;

  while(EOF!=scanf("%lf",&v))
    {
      t = v / 9.8;
      x = t*t*4.9;
      N = (int)ceil(x/5.0)+1;
      printf("%d\n",N);
    }

return(0);
}

Measured memory_bytes: 632
n = int(input())

a, b, c = [0] * n, [0] * n, [0] * n
for i in range(n):
    a[i], b[i], c[i] = map(int, input().split())

dp = [[0] * n for _ in range(3)]
dp[0][-1], dp[1][-1], dp[2][-1] = a[-1], b[-1], c[-1]

for i in range(n - 2, -1, -1):
    dp[0][i] = a[i] + max(dp[1][i + 1], dp[2][i + 1])
    dp[1][i] = b[i] + max(dp[2][i + 1], dp[0][i + 1])
    dp[2][i] = c[i] + max(dp[0][i + 1], dp[1][i + 1])

print(max(dp[0][0], dp[1][0], dp[2][0]))


Measured memory_bytes: 53080
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L;
ll A[300005] = {};
ll B[101][100005] = {};
ll C[300005] = {};
bool f, ff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;


struct ST
{
	int kaisuu;
	int dan;
	int score;
	char situ[52][2][2];
	

	bool operator<(const ST& another) const
	{
		return dan < another.dan;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

string SS[3];


int main() {

	cin >>  SS[0]>>SS[1]>>SS[2];
	

	if (SS[0][SS[0].size() - 1] != SS[1][0] || SS[1][SS[1].size() - 1] != SS[2][0]) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}


	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


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

int N,K,Q,arr[100001],i,bil,sum;

int main(){
	cin>>N>>K>>Q;
	for (i = 1;i <= Q;i ++){
		cin>>bil;
		arr[bil] ++;
	}
	for (i = 1;i <= N;i ++){
		sum = sum + arr[i];
	}
	for (i = 1;i <= N;i ++){
		if ((sum - arr[i]) < K){
			cout<<"Yes"<<endl;
		}
		else {
			cout<<"No"<<endl;
		}
	}
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int[] sunuke = new int[n];
    for (int i = 0; i<k; i++) {
      int d = sc.nextInt();
      for (int j = 0; j<d; j++) {
        int idx = sc.nextInt();
        sunuke[idx-1]+=1;
      }
    }
    int ans = 0;
    for (int i : sunuke) {
      if (i==0) ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 37516
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
   int x[2];
   while(1){
      cin >> x[0] >> x[1];
      if (x[0] == 0 && x[1] == 0) break;
      sort(x,x+2);
      cout << x[0] << " " << x[1] <<endl;
   }
   return 0;
}

Measured memory_bytes: 3140
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
using namespace std;

int inf = 2147483647;
int64_t inf64 = 9223372036854775807;
int mod = 1e+7;

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

  int n;
  cin >> n;
  vector<int64_t> monsters(n+1);
  vector<int64_t> soldiers(n);
  rep(i,n+1) cin >> monsters[i];
  rep(i,n)   cin >> soldiers[i];

  //cout << endl;

  int64_t res = 0;
  rep(i,n) {
    if (monsters[i] < soldiers[i]) {
      res += monsters[i];
      soldiers[i] -= monsters[i];
      monsters[i] = 0;
      if (soldiers[i] > monsters[i+1]) {
        res += monsters[i+1];
        soldiers[i] -= monsters[i+1];
        monsters[i+1] = 0;
      }
      else {
        res += soldiers[i];
        monsters[i+1] -= soldiers[i];
        soldiers[i] = 0;
      }
    }
    else {
      res += soldiers[i];
      monsters[i] -= soldiers[i];
      soldiers[i] = 0;
    }
    //print_array(monsters);
    //print_array(soldiers);
    //cout << endl;
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




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

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ll d[100005];
vector<ll> M[100005];
vector<ll> anslist;


stack<int> to_1;






string S;


ll C[2 * 100005];
ll maxim[2 * 100005];
ll prof[2 * 100005];
int main() {
	ll N, T;

	cin >> N >> T;

	rep(i, N)
		cin >> C[i];


	rep(i, N) {

		maxim[N - i - 1] = max(maxim[N - i], C[N - i - 1]);

	}

	rep(i, N) {

		prof[i] = maxim[i + 1] - C[i];

	}


	ll maxprof = 0;
	rep(i, N)
		maxprof = max(maxprof, prof[i]);

	ll ans = 0;

	rep(i, N) {

		if (prof[i] == maxprof) {
			ans += 1;
		}

	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include<string>

using namespace std;

int n;
string s;
string ans;
string cand[] = {"SS", "SW", "WS", "WW"};

bool build() {
    // cout << s << endl;
    // cout << ans << endl;
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'o') {
            ans += ans[i - 1];
        } else {
            ans += ans[i - 1] == 'S' ? 'W' : 'S';
        }
        if (ans[i] == 'W') {
            ans[i + 1] = ans[i + 1] == 'S' ? 'W' : 'S';
        }
    }
    //cout << ans << endl;
    if (ans[0] != ans[n]) return false;
    ans = ans.substr(0, n);
    bool valid = ans[1] == ans[n - 1];
    if (s[0] == 'x') valid = !valid;
    if (ans[0] == 'W') valid = !valid;
    return valid;
}

int main(){
    cin >> n >> s;

    for (int i = 0; i < 4; ++i) {
        ans = cand[i];
        if (build()) {
            cout << ans << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

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

struct city{
  ll p,y,i;
};

bool s(city c1,city c2){
  return c1.y<c2.y;
}


int main(){
  ll n,m,p,y,k[100010],P[100010]={};
  city c[100010];
  cin>>n>>m;
  fr(i,m){cin>>p>>y;c[i]=(city){p,y,i};}
  sort(c,c+m,s);
  fr(i,m) k[c[i].i]=c[i].p*1e6+(++P[c[i].p]);
  fr(i,m) printf("%012lld\n", k[i]);
}

Measured memory_bytes: 5376
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	scan(N>>M);
	if(N==M){
		prin("Yes");
	}
	else{
		prin("No");
	}
	return 0;
}


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

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

  if (a+b > c+d) {
    cout << "Left" << endl;
  }
  else if (a+b == c+d) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right"<< endl;
  }
}

Measured memory_bytes: 256
main :: IO()
main = getContents >>= putStrLn.solve.formatIn

type Dice  = [String]
formatIn :: String -> [Dice]
formatIn = map words.tail.lines

solve :: [Dice] -> String
solve (x:xs) 
    | any (judge x) xs = "No"
    | otherwise        = "Yes"

judge :: Dice -> Dice -> Bool
judge [x1,x2,x3,x4,x5,x6] y
    | y == [x1,x2,x3,x4,x5,x6] = True
    | y == [x1,x3,x5,x2,x4,x6] = True
    | y == [x1,x5,x4,x3,x2,x6] = True
    | y == [x1,x4,x2,x5,x3,x6] = True
      
    | y == [x2,x6,x3,x4,x1,x5] = True
    | y == [x2,x3,x1,x6,x4,x5] = True
    | y == [x2,x1,x4,x3,x6,x5] = True
    | y == [x2,x4,x6,x1,x3,x5] = True
      
    | y == [x3,x1,x2,x5,x6,x4] = True
    | y == [x3,x2,x6,x1,x5,x4] = True
    | y == [x3,x6,x5,x2,x1,x4] = True
    | y == [x3,x5,x1,x6,x2,x4] = True
      
    | y == [x4,x1,x5,x2,x6,x3] = True
    | y == [x4,x2,x1,x6,x5,x3] = True
    | y == [x4,x6,x2,x5,x1,x3] = True
    | y == [x4,x5,x6,x1,x2,x3] = True
      
    | y == [x5,x1,x3,x4,x6,x2] = True
    | y == [x5,x3,x6,x1,x4,x2] = True
    | y == [x5,x6,x4,x3,x1,x2] = True
    | y == [x5,x4,x1,x6,x3,x2] = True
      
    | y == [x6,x2,x4,x3,x5,x1] = True
    | y == [x6,x3,x2,x5,x4,x1] = True
    | y == [x6,x5,x3,x4,x2,x1] = True
    | y == [x6,x4,x5,x2,x3,x1] = True
      
    | otherwise                = False

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n = 1) : n(n), f(n + 1) {
    f[0] = f[1] = -1;
    for (long long i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (long long j = i * i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }

  bool isPrime(int x) { return f[x] == x; }

  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }

  vector<pair<int, int>> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
};

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  Sieve s(1000001);

  ll all = gcd(a[0], a[1]);
  rep(i, n) all = gcd(all, a[i]);

  bool pc = true;
  map<int, int> mp;
  rep(i, n) {
    auto f = s.factor(a[i]);

    for (auto x : f) {
      if (x.first == 1) continue;
      mp[x.first]++;
      if (mp[x.first] > 1) {
        pc = false;
        break;
      }
    }
    if (!pc) break;
  }

  if (pc) {
    cout << "pairwise coprime" << endl;
  } else if (!pc && all == 1) {
    cout << "setwise coprime" << endl;
  } else {
    cout << "not coprime" << endl;
  }
  return 0;
}


Measured memory_bytes: 15636
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)

const lint mod=1e9+7;
const int N=100000;

lint fact[N];
lint invfact[N];
static long powerMod(long x, long exponent) {
  long prod = 1;
  for (int i = 63; i >= 0; --i) {
    prod = (prod * prod) % mod;
    if ((exponent & 1L << i) != 0) {
      prod = (prod * x) % mod;
    }
  }
  return prod;
}

static void initialize() {
  fact[0] = invfact[0] = 1;
  for (int i = 1; i < N; ++i)
    fact[i] = (i * fact[i - 1]) % mod;
  invfact[N-1]=powerMod(fact[N-1],mod-2);
  for(int i=N-2;i>=0;--i)
    invfact[i] = invfact[i+1]*(i+1)%mod;
}

void add(lint &x,lint y){
  x=(x+y)%mod;
}


int n,k;
int a[101];

lint dp[101][256];
lint dp2[101][256];


int main(){
  initialize();
  cin>>n>>k;
  rep(i,n)cin>>a[i];
  dp[0][0]=1;
  rep(i,n){
    memset(dp2,0,sizeof(dp2));
    rep(j,i+1){
      rep(b,256){
	add(dp2[j][b],dp[j][b]);
	add(dp2[j+1][b^a[i]],dp[j][b]);
      }
    }
    swap(dp,dp2);
  }
  lint ans=0;
  rep(i,n+1){
    add(ans,dp[i][k]*fact[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
using namespace std;

int main(void){
    int a, b, c, d, e, k;

    cin >> a >> b >> c >> d >> e >> k;


    if(abs(a - e) <= k){
        cout << "Yay!" << endl;
    } else{
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		for i := 0; i < n; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			math, _ := strconv.Atoi(buf[0])
			english, _ := strconv.Atoi(buf[1])
			japanese, _ := strconv.Atoi(buf[2])
			if math == 100 || english == 100 || japanese == 100 {
				fmt.Println("A")
			} else if math + english >= 180 {
				fmt.Println("A")
			} else if math + english + japanese >= 240 {
				fmt.Println("A")
			} else if math + english + japanese >= 210 {
				fmt.Println("B")
			} else if math + english + japanese >= 150 && (math >= 80 || english >= 80) {
				fmt.Println("B")
			} else {
				fmt.Println("C")
			}
		}
	}
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define FORD(i,b,a) for (int i = (int)(b) - 1; i >= a; --i)
#define REP(i,N) FOR(i,0,N)
#define st first
#define nd second
#define pb push_back

typedef pair<int, int> PII;
typedef long long LL;

int A[6000];
int B[6000][300];

LL increase[6000];
int increase_from[6000][300];
stack<int> increasing[300];

void set_increase_from(int i, int j, int to) {
  increase[i] += to - increase_from[i][j];
  increase_from[i][j] = to;
}

int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  FOR(i,1,N) scanf("%d", &A[i]);

  REP(i,N)REP(j,M) scanf("%d", &B[i][j]);

  LL result = 0;
  FORD(i,N,0) {
    REP(j,M) {
      while (!increasing[j].empty() && B[increasing[j].top()][j] <= B[i][j]) {
        set_increase_from(increasing[j].top(), j, 0);
        increasing[j].pop();
      }
      if (!increasing[j].empty()) set_increase_from(increasing[j].top(), j, B[increasing[j].top()][j] - B[i][j]);
      increasing[j].push(i);
    }

    LL sum = 0;
    REP(j,M) sum += B[i][j];
    result = max(result, sum);
    FOR(j,i+1,N) {
      sum += increase[j];
      sum -= A[j];
      result = max(result, sum);
    }
  }

  printf("%lld\n", result);
}


Measured memory_bytes: 12288
import copy

N = int(input())

x_list = []
for i in range(N):
    x = int(input())
    x_list.append(x)

max_value = max(x_list)

get_index = x_list.index(max(x_list))

tmp_list = copy.deepcopy(x_list)
tmp_list.pop(get_index)
without_max_value = max(tmp_list)

for i in range(len(x_list)):
    if i != get_index:
        print(max_value)
    else:
        print(without_max_value)

Measured memory_bytes: 97112
// AOJ 1201: Lattice Practices
// 2017.12.17 bal4u@uu

#include <stdio.h>
#include <string.h>

char a[10][6], b[10][6];
char *h[5], *v[5];
int diff[10];
int ans;

int check(int j)
{
	int i;
	for (i = 0; i < 5; i++) if (h[i][j] == v[j][i]) return 0;
	return 1;
}

void solve(int k, int s)
{
	int i, j, bit;

	if (k == 10) { ans++; return; }
	for (bit = 1, i = 0; i < 10; i++, bit <<= 1) {
		if (s & bit) continue;
		if (k < 5) {
			h[k] = a[i];
			solve(k+1, s | bit);
			if (diff[i]) {
				h[k] = b[i];
				solve(k+1, s | bit);
			}
		} else {
			j = k - 5;
			v[j] = a[i];
			if (check(j)) solve(k+1, s | bit);
			if (diff[i]) {
				v[j] = b[i];
				if (check(j)) solve(k+1, s | bit);
			}
		}
	}
}

int main()
{
	int i, j;

	while(scanf("%s", a[0]) && a[0][0] != 'E') {
		for (i = 1; i < 10; i++) scanf("%s", a[i]);
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 5; j++) b[i][j] = a[i][4-j];
			diff[i] = (memcmp(a[i], b[i], 5) != 0);
		}
		ans = 0;
		solve(0, 0);
		printf("%d\n", ans >> 3);
	}
	return 0;
}

Measured memory_bytes: 1772
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int gcd(int a,int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
   int n,h;
   cin>>n>>h;
   cout<<n*n-h<<endl;
    return 0;
}

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

int main()
{
    string a;
    cin>>a;
    set<char>s;
    for(int i=0; i<a.size(); i++)
    {
        s.insert(a[i]);
    }
    if(s.size()==2)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


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

using namespace std;
using ll = long long;

int main() {
  ll N, M, ans{};
  cin >> N >> M;
  vector<pair<ll, ll>> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(begin(v), end(v));

  for (int i = 0; i != N; i++) {
    if (v[i].second >= M) {
      ans += M * v[i].first;
      break;
    } else {
      ans += v[i].second * v[i].first;
      M -= v[i].second;
    }
  }
  cout << ans << endl;
}


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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;

int gcd(int a, int b) {
  return b ? gcd(b, a%b) : a;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x; cin >> n >> x;

  int ans; cin >> ans;
  ans = abs(ans - x);
  rep(i, n-1) {
    int y; cin >> y;
    ans = gcd(ans, abs(y-x));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
n = int(input())
ab = sorted([ list(map(int, input().split())) for _ in range(n) ], key=itemgetter(1), reverse=True)
cd = sorted([ list(map(int, input().split())) for _ in range(n) ])
ans = 0
sab = []
for i in range(n):
  for j in range(n):
    if cd[i][0] > ab[j][0] and cd[i][1] > ab[j][1]:
      if ab[j] not in sab:
        ans += 1
        sab.append(ab[j])
        break
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
ll cnt[1000010];

void pre(ll n){
    cnt[0]=0;
    for(ll i=1;i<=n;i++){
        ll add = 0;
        ll x = i;
        while(x%2==0)x/=2,add++;
        cnt[i] = cnt[i-1]+add;
    }
}

ll coff[3]={};
int  A(int x){
    if(x>=0)return x;
    else return -x;
}

int main(void){
    ll n;
    string s;
    cin>>n>>s;
    vector<int>a;
    bool flag = false;
    for(int i=0;i<n;i++){
        int x = s[i]-'0';
        x--;
        if(x==1)flag = true;
        a.push_back(x);
    }
    pre(n);
    for(ll i=0;i<a.size();i++){
        ll v = cnt[a.size()-1] - cnt[i] - cnt[a.size()-1-i];
        if(v==0)coff[a[i]]+=1;
    }
    if(coff[1]%2==1){
        cout<<1<<endl;
        return 0;
    }
    else{
        if(flag)cout<<0<<endl;
        else{
            if(coff[2]%2==1)cout<<2<<endl;
            else cout<<0<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 13688
# MInt(ModInt)
class Integer

  attr_accessor :mod
  @@mod = 10 ** 9 + 7
  @@h = Hash.new
  
  alias_method :primitive_plus, :+
  def +(other)
    primitive_plus(other) % @@mod
  end
  
  alias_method :primitive_minus, :-
  def -(other)
    primitive_minus(other) % @@mod
  end

  def +@
    super % @@mod
  end

  def -@
    super % @@mod
  end

  alias_method :primitive_times, :*
  def *(other)
    self.primitive_times(other) % @@mod
  end
  
  alias_method :primitive_div, :/
  def /(other)
    @@h[other] ||= other.pow(@@mod-2, @@mod)
    self * @@h[other]
  end

  alias_method :primitive_equal, :==
  def ==(other)
    ( self % @@mod ).primitive_equal( other % @@mod )
  end

  # def **(other)
  #   self.pow(other,@@mod)
  # end

  def abs
    self % @@mod
  end

  def <<(value)
    self * 2.pow(value, @@mod)
  end

  def >>(value)
    t = 2.pow(value, @@mod)
    @@h[t] ||= t.pow(@@mod-2, @@mod)
    self * @@h[t]
  end

  alias_method :primitive_inspect, :inspect
  def inspect
    self.primitive_inspect + " (mod #{@@mod.primitive_to_s})"
  end

  alias_method :primitive_to_s, :to_s
  def to_s
    (self % @@mod).primitive_to_s
  end
end

# ABC163
n, k = gets.to_s.split.map{|e|e.to_i}

ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum

puts ans

Measured memory_bytes: 15832
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,vector<int> > P;

void bfs(const vector<int>& tmp,int cost[8][8],int N,map<vector<int>,int>& visited){
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(P(0,tmp));

	visited[tmp] = 0;
	vector<int> now;
	vector<int> next;
	while(!que.empty()){
		now = que.top().second;
		int costNow = que.top().first;
		que.pop();
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				swap(now[i],now[j]);
				next = now;
				swap(now[i],now[j]);

				int c;
				if(visited[next] <= (c = (costNow + cost[i][j]))) continue;
				visited[next] = c;
				que.push(P(visited[next],next));
			}
		}
	}

}

int main(){
	int N;

	int cost[8][8];
	memset(cost,0x3,sizeof(cost));

	map<vector<int>,int> visited;

	while(~scanf("%d",&N)){
		for(int y=0;y<N;y++){
			for(int x=0;x<N;x++){
				int c;
				scanf("%d",&c);
				cost[y][x] = c;
			}
		}

		vector<int> tmp;
		for(int i=0;i<N;i++){
			tmp.push_back(i);
		}

		do{
			visited[tmp] = 5000000;
		}while(next_permutation(tmp.begin(),tmp.end()));

		bfs(tmp,cost,N,visited);

		int res=0;

		for(map<vector<int>,int>::iterator it = visited.begin(); it != visited.end(); it++){
			res = max(res,it->second);
		}

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

}

Measured memory_bytes: 7596
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int a, b;

int gcd(int a, int b){
	return (b == 0 ? a : gcd(b, a % b));
}

int main(){
    while(cin >> a >> b){
        cout << gcd(a, b) << " " << 1LL * a* b / gcd(a, b) << endl;
    }
}

Measured memory_bytes: 3000
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include <math.h>
int main(void){
	int a,b,d[101][6],i,j,k,n,x,y,s,t;
	char c;

	scanf("%d%*c",&x );
	for(j=0;j<x;j++){
		for(i=0;i<6;i++){
			scanf("%d%*c",&d[j][i] );
		}
	}
	for(s=0;s<x-1;s++){
		for(t=s+1;t<x;t++){

			for(i=0;i<4;i++){
				n=d[t][0];
				d[t][0]=d[t][2];
				d[t][2]=d[t][5];
				d[t][5]=d[t][3];
				d[t][3]=n;
				for(j=0;j<4;j++){
					n=d[t][0];
					d[t][0]=d[t][1];
					d[t][1]=d[t][5];
					d[t][5]=d[t][4];
					d[t][4]=n;
					for(k=0;k<4;k++){
						n=d[t][1];
						d[t][1]=d[t][3];
						d[t][3]=d[t][4];
						d[t][4]=d[t][2];
						d[t][2]=n;
						for(a=0,b=0;a<6;a++){
							if(d[t][a]==d[s][a])b++;
						}
						if(b==6){
							printf("No\n" );
							return 0;
						}
					}
				}
			}
		}
	}printf("Yes\n" );
	return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; cin >> n;
    vector<string> w(n);
    bool r = true;
    rep(i,n){
        cin >> w[i];
        rep(j,i) if(w[i] == w[j]) r = false;
    }
    rep(i,n-1){
        string w1 = w[i],w2 = w[i+1];
        if(w1[w1.size() - 1] != w2[0]) r = false;
    }
    if(r) Yes;
    else No;

    return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Math;

class Program
{
    static int n;
    static long xl1, xl2, xs1, xs2, yl1, yl2, ys1, ys2;
    static long xls, xrs, yls, yss;

    static void Main()
    {
        n = int.Parse(Console.ReadLine());
        xl1 = -((long)1e8);
        xl2 = -((long)1e8);
        yl1 = -((long)1e8);
        yl2 = -((long)1e8);
        xs2 = ((long)1e8);
        xs1 = ((long)1e8);
        ys2 = ((long)1e8);
        ys1 = ((long)1e8);
        xls = -(long)1e8;
        yls = -(long)1e8;
        xrs = (long)1e8;
        yss = (long)1e8;
        long x, y;
        char d;
        for (int i = 0; i < n; i++)
        {
            string[] input = Console.ReadLine().Split();
            x = long.Parse(input[0]);
            y = long.Parse(input[1]);
            d = input[2][0];
            if (d != 'R' && d != 'L')
                xl1 = Max(xl1, x);
            if (d != 'R' && d != 'L')
                xs1 = Min(xs1, x);
            if (d != 'U' && d != 'D')
                yl1 = Max(yl1, y);
            if (d != 'U' && d != 'D')
                ys1 = Min(ys1, y);
            if (d == 'R')
            {
                xl2 = Max(xl2, x);
                xrs = Min(xrs, x);
            }
            if (d == 'L')
            {
                xs2 = Min(xs2, x);
                xls = Max(xls, x);
            }
            if (d == 'U')
            {
                yl2 = Max(yl2, y);
                yss = Min(yss, y);
            }
            if (d == 'D')
            {
                ys2 = Min(ys2, y);
                yls = Max(yls, y);
            }
        }

        double low = 0.0, high = 1e8;
        while (high - low > 1e-9)
        {
            double width = high - low, ml = low + width / 3.0, mr = low + 2.0 * width / 3.0;
            if (Abs(f(ml) - f(mr)) < 1e-9)
            {
                Console.WriteLine(f(ml));
                return;
            }
            if (f(ml) <= f(mr))
            {
                high = mr;
            }
            else
            {
                low = ml;
            }
        }
        Console.WriteLine(f((high + low) / 2.0));
    }

    static double xmax(double t)
    {
        return Max(Max((double)xl1, t + xl2), -t + xls);
    }

    static double xmin(double t)
    {
        return Min(t + xrs, Min((double)xs1, -t + xs2));
    }

    static double ymax(double t)
    {
        return Max(-t + yls, Max((double)yl1, t + yl2));
    }

    static double ymin(double t)
    {
        return Min(t + yss, Min((double)ys1, -t + ys2));
    }

    static double f(double t)
    {
        return (xmax(t) - xmin(t)) * (ymax(t) - ymin(t));
    }
}


Measured memory_bytes: 17204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
 
    int a, b, c;
    cin >> a >> b >> c;
 
    int max_num = max(a, max(b, c));
    int diff = max_num * 3 - (a + b + c);
    if (diff % 2) {
        diff += 3;
    } 
    cout << diff / 2 << '\n';
 
 
    return 0;
}

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

int main(){
    char a;
    cin >> a;
    switch(a) {
        case 'A':
            cout << 'T';
            break;
        case 'C':
            cout << 'G';
            break;
        case 'G':
            cout << 'C';
            break;
        case 'T':
            cout << 'A';
            break;
    } 
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPL(i,f,n) for(int i=f, i##_len=(n); i<i##_len; ++i)
typedef long long ll;

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

	int N,A,B;
	cin >> N >> A >> B;
	cout << ((A-B)%2==0?"Alice":"Borys") << endl;
	return 0;
}


Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include <string>
#include <set>
#include<algorithm>
#include<map>
#include <vector>
#include <iterator>
#include<stack>
long long maxi( long long a, long long b){
    long long ans= a>b ? a:b;
    return ans;
}
int main(){
    int n,w;
    cin>>n>>w;
    int values[n+1],weight[n+1];
    for(int i=1;i<=n;i++){
        cin>>weight[i]>>values[i];
    }
    long long ans [n+1][w+1];
    for(int j=0;j<=w;j++)ans[0][j]=0;
    for(int u=1; u<=n ;u++){
        for(int y=0; y<=w; y++){
            long long z=ans[u-1][y];
            if(y-weight[u]>=0){
                z=maxi(z,values[u]+ans[u-1][y-weight[u]]);
            }
            ans[u][y]=z;
        }
    }
    cout<<ans[n][w];





}














Measured memory_bytes: 79104