akhauriyash/Code-Regression huggingface dataset:
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/30/2019 11:03:37 PM
*************************************************************************/
//#pragma GCC optimize(2)
//#pragma GCC diagnostic error "-std=c++11"
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define endl '\n'
#define ALL(x) x.begin(),x.end()
#define MP(x,y) make_pair(x,y)
#define ll long long
#define ull unsigned long long
#ifdef WindCry1
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#endif
#define lowbit(x) x&(-x)
#define ls u<<1
#define rs u<<1|1
using namespace std;
template<typename T> inline T MIN(const T &a,const T &b) {return a<b?a:b;}
template<typename T> inline T MAX(const T &a,const T &b) {return a>b?a:b;}
template<typename T,typename ...Args> inline T MIN(const T &a,const T &b,Args ...args) {return MIN(MIN(a,b),args...);}
template<typename T,typename ...Args> inline T MAX(const T &a,const T &b,Args ...args) {return MAX(MAX(a,b),args...);}
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
const double eps = 1e-8;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const ll mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};

int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifdef WindCry1
	freopen("C:/Users/LENOVO/Desktop/in.txt","r",stdin);
#endif
	int n;ll k;cin>>n>>k;
	vector<ll> a(n);for(auto &i:a) cin>>i;
	sort(ALL(a));
	ll L=-INF,R=INF;
	while(L+1!=R){
		ll MID=(L+R)>>1;
		ll res=0;
		for(int i=0;i<n;i++){
			if(a[i]<0){
				int l=i,r=n;
				while(l+1!=r){
					int mid=(l+r)>>1;
					if(a[i]*a[mid]<=MID) r=mid;
					else l=mid;
				}
				res+=n-r;
			}
			else{
				int l=i,r=n;
				while(l+1!=r){
					int mid=(l+r)>>1;
					if(a[i]*a[mid]<=MID) l=mid;
					else r=mid;
				}
				res+=l-i;
			}
		}
		if(res<k) L=MID;
		else R=MID;
	}
	cout<<R<<endl;
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define INF INT_MAX
#define MAX 100000

using namespace std;
using LL=long long;

int D[105][105];

int main(){
    int M,N,c=0;
    string s;
    cin>>M>>N;
    for(int i=0;i<M;i++){
        cin>>s;
        for(int j=0;j<N;j++){
            switch(s[j]){
                case 'o':
                    D[i][j]=-1;
                    break;
                case 'x':
                    D[max(0,i-1)][j]=D[i][j]=D[min(i+1,M-1)][j]=-1;
            }
        }
    }
    for(int i=1;i<M;i++){
        for(int j=0;j<N;j++){
            if(D[i][max(0,j-1)]!=-1&&D[i][j]!=-1&&D[i][min(j+1,N-1)]!=-1) c++;
        }
    }
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <queue>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;


ll mod = 1000000000 + 7;

int main(){
    ll N;
    cin >> N;
    
    ll sum = 0;
    for(ll i =1; i<N; i++){
        sum += i;
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
N = int(input())
x_list = [i for i in list(map(int, input().split()))]
tmp = x_list.copy()
x_list.sort()
big = x_list[len(x_list)//2]
small = x_list[len(x_list)//2-1]

for x in tmp:
    if x >= big:
        print(small)
    else:
        print(big)


Measured memory_bytes: 25620
import math
import fractions
#import sys
#input = sys.stdin.readline

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

def ZipArray(a):
    aa = [[a[i],i]for i in range(n)]

    aa.sort(key = lambda x : x[0])
    for i in range(n):
        aa[i][0]=i+1
    aa.sort(key = lambda x : x[1])
    b=[aa[i][0] for i in range(len(a))]
    return b

def ValueToArray10(x, digit):
    ans = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        ans[digit-i-1] = now%10
        now = now //10
    return ans

def Zeros(a,b):
    if(b<=-1):
        return [0 for i in range(a)]
    else:
        return [[0 for i in range(b)] for i in range(a)]

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
            
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 2
N = 10 ** 6 + 2
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

'''

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

#################################################
#################################################
#################################################
#################################################


n = int(input())
c = list(map(int, input().split()))
a = []
for i in range(n):
    temp = list(map(int, input().split()))
    a.append(temp)

ans = [(i%26) for i in range(n)]

def cost(a,c,ans):
    val = 0
    last = [0 for i in range(26)]
    for i in range(n):
        for j in range(26):
            last += 1
        here = ans[i]
        val += a[i][here]
        last[here] = 0
        for j in range(26):
            val -= last[j]*c[j]
    return val
#

for i in range(n):
    maxim = -10**9
    idx = -1
    for j in range(26):
        if(maxim < a[i][j]):
            idx = j
            maxim = a[i][j]
    ans[i] = idx
#print(ans)

#d = [[i,c[i]]]

for i in ans:
    print(i+1)











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

int main() {
	//读入数据
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	int x1, y1, x2, y2;
	scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
	//迷宫描述
	char maze[h][w];
	//距离描述
	int dis[h][w];
	for (int i=0; i<h; i++) {
		for (int j=0; j<w; j++) {
			scanf(" %c", &maze[i][j]);
			dis[i][j] = INT_MAX;
		}
	}

	//数据处理
	//由于我们是从0开始
	x1--;
	y1--;
	x2--;
	y2--;

	const int dir[4][2] = {{-1,0}, {0,-1}, {1,0}, {0,1}};//方向定义次序无所谓
	queue<pair<int, int> > q;
	//插入起点
	dis[x1][y1] = 0;
	q.push({x1, y1});
	while (!q.empty()) {
		//获取队首数据
		int x = q.front().first;
		int y = q.front().second;
		q.pop();

		//按照规定方向移动
		for (int i=0; i<4; i++) {
			//新坐标和距离 
			int nx = x;
			int ny = y;
			int nd = dis[x][y]+1;
			//1 ~ k步
			for (int j=1; j<=k; j++) {
				//计算新的坐标
				nx += dir[i][0];
				ny += dir[i][1];

				//合法性判断
				if (nx<0 || nx>=h || ny<0 || ny>=w || '@'==maze[nx][ny] || dis[nx][ny]<nd) {
					break;
				}
				if (dis[nx][ny]>nd) {
					dis[nx][ny] = nd;
					q.push({nx, ny});
				}
			}
		}
	}

	int ans = dis[x2][y2];
	printf("%d\n", (INT_MAX==ans ? -1 : ans));

	//system("pause");

	return 0;
}

Measured memory_bytes: 9152
#include<stdio.h>
main(){
    int n;
    scanf("%d",&n);
    while(n!=0){
    int i,j;
    char before[n],after[n];
    for(i=0;i<n;i++){
        scanf(" %c %c",&before[i],&after[i]);
    }
    int m;
    scanf("%d",&m);
    char str[m];
    for(i=0;i<m;i++){
        scanf(" %c",&str[i]);
        for(j=0;j<n;j++){
            if(str[i]==before[j]){
                str[i]=after[j];
                break;
            }
        }
    }
    for(i=0;i<m;i++){
        printf("%c",str[i]);
    }
    printf("\n");
    scanf("%d",&n);
    }
    return 0;
}
    

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

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

  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (auto &i : a) cin >> i;

  lint ans = 0;
  lint cur = 1;
  vector<lint> lim(n + 1);

  for (int i = 0; i <= n; i++) {
    if (a[i] > cur) {
      cout << -1 << "\n";
      return 0;
    }
    cur -= a[i];
    lim[i] = cur;
    if (i < n) {
      cur *= 2;
      cur = min(cur, (lint) 1e18);
    }
  }

  // cur = 1;
  // for (int i = 0; i <= n; i++) {
  //   lim[i] = cur;
  //   cur *= 2;
  //   cur = min(cur, (lint) 1e18);
  // }

  cur = 0;
  for (int i = n; i >= 0; i--) {
    // cout << lim[i] << " \n"[i == 0];
    // cur += a[i];
    cur = min(cur, lim[i]);
    cur += a[i];
    ans += cur;
    // cout << cur << " ";
  }

  cout << ans << "\n";
  return 0;

  // function<pair<int, int>(int)> dfs = [&](int d) {
  //   if (d > n) return pair<int, int>{0, 0};
  //   if (a[d] > 0) {
  //     a[d]--;
  //     return pair<int, int>{1, 1};
  //   }
  //   auto res1 = dfs(d + 1);
  //   auto res2 = dfs(d + 1);
  //   if (max(res1.first, res2.first) == 0) {
  //     return pair<int, int>{0, 0};
  //   }
  //   int res = 1;
  //   if (res1.first == 1) res += res1.second;
  //   if (res2.first == 1) res += res2.second;
  //   return pair<int, int>{1, res};
  // };

  // int ans = dfs(0).second;
  // for (int i = 0; i <= n; i++) {
  //   if (a[i] != 0) {
  //     cout << -1 << "\n";
  //     return 0;
  //   }
  // }

  // cout << ans << "\n";
  // return 0;
}


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

typedef long long ll;

ll LCM(ll a, ll b) {
  ll tmp;
  ll m = a;
  ll n = b;
  while (m % n != 0) {
    tmp = n;
    n = m % n;
    m = tmp;
  }
  return a / n * b;
}

int main() {
  int N;
  cin >> N;
  vector<ll>T(N);
  ll ans = 1;
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
    ans = LCM(ans, T.at(i));
  }
  cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
int n,m,x;
cin>>n>>m>>x;
vector<int> a(m,0);
for(int i=1; i<=m; i++) cin>>a[i];

int front=0;
int back=0;
for(int i=1; i<=m; i++)
{
    if(x<a[i])  ++back;
    else ++front;
}
int ans=min(front,back);
cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())

sys.setrecursionlimit(10 ** 9)


def main():
    N = INT()

    num = [i for i in range(1, 10)]

    for i in num:
        if N % i == 0 and N//i in num:
            print("Yes")
            sys.exit()

    print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <stdlib.h>

using namespace std;
// vector push_back push front top empty pop make_pair long long insert begin end  
typedef long long ll;
typedef vector<int> vi;
typedef vector<pair <int,int> > vpi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define B begin()
#define RB rbegin()
#define E end()
#define RE rend()
#define Z size()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define L length()
#define show(a) cerr << " *** " << a << endl;
#define show1(a) cerr << " /// " << a << endl;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int n, m;
    cin >> n >> m;
    vi all(n);
    REP(i,0,n)
        cin >> all[i];
    priority_queue <int, vector <int>, less<int> > kyou;
    REP(i,0,n)
        kyou.push(all[i]);
    while (m > 0)
    {
        int x = kyou.top();
        if (x == 0)
            break;
        kyou.pop();
        m--;
        x /= 2;
        kyou.push(x);
    }
    ll out = 0;
    while (kyou.empty() == 0)
    {
        out += kyou.top();
        kyou.pop();
    }
    cout << out;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 10000;
int n,m,src;
struct ed{
    int u,v,cost;
};
vector<ed> e;
long long  dis[MAXN];

void ballmanf(){
    memset(dis,63,sizeof dis);
    long long inf = dis[0];
    dis[src] = 0;
    bool nc = false;
    for(int i=0; i<n; i++){
        nc=false;
        for(int j=0; j<m; j++){
            if( dis[e[j].u] < inf){
                if(dis[e[j].v] > dis[e[j].u] + e[j].cost){
                nc=true;
                dis[e[j].v] = min(dis[e[j].v],dis[e[j].u]+e[j].cost);

                }
            }
        }
    }

    if(nc){
        cout<<"NEGATIVE CYCLE"<<"\n";
    }
    else{
        for(int i=0; i<n; i++){
            if(dis[i]==inf){
                cout<<"INF"<<"\n";
            }
            else{
                cout<<dis[i]<<"\n";
            }
        }
    }
}

int main() {
    // freopen("./input.txt","r",stdin);
    // freopen("./output.txt","w",stdout);

    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin>>n>>m>>src;
    for(int i=0;i<m;i++){
        int a,b,c; cin>>a>>b>>c;
        e.push_back({a,b,c});
    }
    ballmanf();
}


Measured memory_bytes: 3300
#include<stdio.h>

int S[100001],n;
int BinarySearch(int);

int main(){
  
  int q,i,count=0;
  int T[50000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);
  
  for(i=0;i<q;i++) count += BinarySearch(T[i]);
  
  printf("%d\n",count);

  return 0;

}

int BinarySearch(int key){

  int left=0,right,mid;
  right=n;
  while(left < right){
    mid=(left + right)/2;
    if(S[mid] == key) return 1;
    else if(S[mid] < key) left = mid + 1;
    else if(S[mid] > key) right = mid;
  }
  return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
#include<stdlib.h>

int main()
{
  int n,i,j,k,l,v,**a,u;
  scanf("%d",&n);
  a = malloc(sizeof(int*)*n);
  for(i=0;i<n;i++)
    {
      a[i] = malloc(sizeof(int)*n);
    }
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&u,&k);
      for(l=0;l<n;l++)
	{
	  a[u-1][l]=0;
	}
      for(j=0;j<k;j++)
	{
	  scanf("%d",&v);
	  a[u-1][v-1]=1;
	}
    }
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	{
	  printf("%d",a[i][j]);
	  if(j!=n-1)printf(" ");
	}
      printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2112
import numpy as np
N = int(input())
X = []
Y = []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
X = np.array(X)
Y = np.array(Y)
theta = np.arctan2(X, Y)
index = theta.argsort()
X = X[index]
Y = Y[index]
X = np.tile(X, 2)
Y = np.tile(Y, 2)
Xcum = X.cumsum()
Ycum = Y.cumsum()
ans = (Ycum-Ycum[:, None])**2+(Xcum-Xcum[:, None])**2
m = 0
for i in range(N*2):
    m = max(m, ans[i, i:i+N+1].max())
print(m**0.5)

Measured memory_bytes: 13344
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  long long N,M;
  cin >> N >> M;

  vector<int> A(N);
  vector<pair<int,int>> BC(M);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
  }

  long long bsum = 0;
  for(int i = 0;i < M;i++) {
    int b,c;
    cin >> b >> c;
    bsum += b;
    pair<int,int> p = make_pair(c,b);
    BC.at(i) = p;
  }

  
  sort(BC.begin(),BC.end());
  reverse(BC.begin(),BC.end());

  int j = min(N,bsum),k = 0;
  while(j > 0) {
    while(BC.at(k).second > 0) {
      A.push_back(BC.at(k).first);
      BC.at(k).second--;
      j--;
    }
    k++;
  }
  
  long long sum = 0;
  sort(A.begin(),A.end(),greater<int>());
  
  for(int i = 0;i < N;i++) {
    sum += A.at(i);
  }

  cout << sum << endl;

  
}




Measured memory_bytes: 2552
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] x=new int[n];
        int[] y=new int[n];
        for(int i=0;i<n;i++){
            x[i]=sc.nextInt();
        }
        for(int i=0;i<n;i++){
            y[i]=sc.nextInt();
        }
        double D1=0,D2=0,D3=0,D=0;
        for(int i=0;i<n;i++){
            int d=Math.abs(x[i]-y[i]);
            D1+=d;
            D2+=d*d;
            D3+=d*d*d;
            if(D<d){
                D=d;
            }
        }
        System.out.printf("%.6f\n", D1);
        System.out.printf("%.6f\n", Math.sqrt(D2));
        System.out.printf("%.6f\n", Math.cbrt(D3));
        System.out.printf("%.6f\n", D);
    }
}


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

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

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define ZERO(a) memset(a,0,sizeof(a))

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll dp[(1<<21)+1];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  ll a[n][n];
  REP(i,n)REP(j,n)cin>>a[i][j];

  REP(i,(1<<n)+1)dp[i]=0;

  dp[0]=1;
  REP(i,(1<<n)){
    ll cnt=0;
    REP(j,n){
      if((i>>j)&1)
        cnt++;
    }

    REP(j,n){
      if(a[cnt][j]==1 && ~(i>>j)&1)
        dp[i^(1<<j)] = (dp[i^(1<<j)]+dp[i])%MOD;

//      if(a[cnt][j]==1 && (i>>j)&1)
//        dp[i] = (dp[i]+dp[i^(1<<j)])%MOD;
    }
  }

//  REP(i,(1<<n))
//    cout<<dp[i]<<endl;
  cout<<dp[(1<<n)-1]<<endl;
}



Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 1e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 0;i * i <= n;i++){
    ret.push_back(i);
    if(i*i != n) ret.push_back(i);
  }
  sort(ALL(ret));
  return ret;
}

signed main()
{
  ios();
  int r,D;
  cin >> r >> D ;
  int x[2011];
  cin >> x[2000];
  for(int i = 2000; i < 2010; i++) {
    x[i+1] = r * x[i] - D;
  }
  for(int i = 2001; i < 2011; i++) {
    cout << x[i] << endl;
  }
}


Measured memory_bytes: 256
import itertools

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

x = sorted(itertools.permutations(list(range(1, n + 1))))
a = None
b = None
for i in range(len(x)):
    if p == x[i]:
        a = i
    if q == x[i]:
        b = i
    if a is not None and b is not None:
        break
print(abs(a - b))


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int dp[2][1<<20];
int bit[501],bit2[27][501],cnt[501];
int main(){
    int n,m;
    string s;
    while(cin>>n>>m,n){
        if(m<=19){
            memset(bit,0,sizeof(bit));
            rep(i,n){
                cin>>s;
                rep(j,m)if(s[j]=='1') bit[i]|=1<<j;
            }
            memset(dp,-1,sizeof(dp));
            dp[0][0]=0;
            rep(i,n){
                rep(j,1<<m) dp[1][j]=dp[0][j];
                rep(j,1<<m)if(dp[0][j]!=-1){
                    dp[1][j^bit[i]]=max(dp[1][j^bit[i]],dp[0][j]+1);
                }
                swap(dp[0],dp[1]);
            }
            cout<<dp[0][0]<<endl;
        }
        else{
            memset(bit2,0,sizeof(bit2));
            rep(i,n){
                cin>>s;
                rep(j,m)if(s[j]=='1') bit2[i][j]=1;
            }
            int mx=0;
            rep(i,1<<n){
                int c=__builtin_popcount(i);
                if(mx>=c) continue;
                memset(cnt,0,sizeof(cnt));
                rep(j,n)if((i>>j)&1)rep(k,m) cnt[k]^=bit2[j][k];
                int sum=0;
                rep(j,m) sum+=cnt[j];
                if(sum==0) mx=max(mx,c);
            }
            cout<<mx<<endl;
        }
    }
    return 0;
}


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

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

const int MAX_N = 110000;

int dp[MAX_N];

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

    for (int i = 0; i < MAX_N; ++i) dp[i] = N;
    dp[0] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
    q.push(make_pair(0, 0));

    while (!q.empty()) {
        int cur = q.top().first;
        int v = q.top().second;
        q.pop();

        if (cur > dp[v]) continue;

        for (int pow6 = 1; v + pow6 <= N; pow6 *= 6) {
            int nv = v + pow6;
            if (chmin(dp[nv], dp[v] + 1)) q.push(make_pair(dp[nv], nv));
        }
        for (int pow9 = 1; v + pow9 <= N; pow9 *= 9) {
            int nv = v + pow9;
            if (chmin(dp[nv], dp[v] + 1)) q.push(make_pair(dp[nv], nv));
        }
    }
    cout << dp[N] << endl;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=2019LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
ll modpow(ll a, ll n, ll mod) {
  
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  string s;cin>>s;
  ll n=s.size();
  reverse(s.begin(),s.end());
  vl sum(n);
  sum[0]=s[0]-'0';
  for(ll i=1;i<n;i++){
    sum[i]=sum[i-1]+(s[i]-'0')*modpow(10,i,MOD);
    sum[i]%=MOD;
  }
  //rep(i,n)cout<<sum[i]<<" ";
  map<ll,ll>M;
  rep(i,n)M[sum[i]]++;
  ll ans=M[0];
  rep(i,2019)ans+=M[i]*(M[i]-1)/2;
  cout<<ans<<endl;

}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
const int INF = 1e9;
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound // returns iterator to either the searched elements index or smallest number higher than searched's index (Keep 2 cases in mind) 1. ptr.end() 2. when ptr points to the searched element
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)
#define print(a)       for(auto x : a) cout << x << " "; cout << "\n"
#define print1(a)      for(auto x : a) cout << x.ff << " " << x.ss << "\n"
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << "\n"


ll fast_exp(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
int val(char c){if (c >= '0' && c <= '9')return (int)c - '0';else return (int)c - 'A' + 10;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]
string bitstring(int n, int size){string s;while(n){s+=(n%2)+'0';n/=2;}while(s.size()<size){s+='0';}reverse(all(s));return s;}
// dsu start

vi root(200001,0);
vi size(200001,1);
int find(int x){while(x!=root[x])x = root[x];return x;}
bool same(int a,int b){return find(a)==find(b);}
void unite(int a, int b){a = find(a);b = find(b);if(size[a]<size[b])swap(a,b);size[a] += size[b];root[b] = a;}

// dsu end
vi vis(200001,0);
vi adj[200001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //string bitstring = std::bitset< 3 >( 7 ).to_string(); <bits> (num)
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    string s,d;
    cin>>s>>d;
    for(int i=0; i<s.size(); ++i)
    {
    	cout<<s[i];
    	if(i<d.size())
    		cout<<d[i];
    } 
}

Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void fill(int y, int x, char c, vector<vector<char> > &f){
	if(f[y][x] != c) return;
	f[y][x] = '.';
	for(int i=0; i<4; i++){
		fill(y+dy[i], x+dx[i], c, f);
	}
}

int main(){
	while(1){
		int h,w;
		cin >> h >> w;
		if(h==0) break;
		
		vector<vector<char> > field(h+2, vector<char>(w+2, '.'));
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				cin >> field[i][j];
			}
		}
		
		int ans = 0;
		for(int i=1; i<=h; i++){
			for(int j=1; j<=w; j++){
				if(field[i][j] != '.'){
					ans++;
					fill(i, j, field[i][j], field);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}



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

#define int long long
#define fi first
#define se second
#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 rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int a,b;

signed main() {
    cin >> a >> b;
    cout << max(a+b, max(a-b, a*b)) << endl;
}


Measured memory_bytes: 256
class Convex
  def initialize
    results = []

    while input = $stdin.gets do
      @xa,@ya,@xb,@yb,@xc,@yc,@xd,@yd = input.chomp.split(',').map(&:to_f)
      if check && check2
        results << "YES"
      else
        results << "NO"
      end
    end

    results.each do |str|
      puts str
    end
  end

  def calc_slope
    if @xd > @xb
      (@yd-@yb)/(@xd-@xb)
    else
      (@yb-@yd)/(@xb-@xd)
    end
  end

  def calc_slope2
    if @xa > @xc
      (@ya-@yc)/(@xa-@xc)
    else
      (@yc-@ya)/(@xc-@xa)
    end
  end

  def check
    flag1 = false
    flag2 = false

    if (@xd-@xb) != 0
      a = calc_slope
      b = @yb - a*@xb
    else
      a = 0
      b = @xb
    end

    if a == 0 && (@xd-@xb) == 0
      if b < @xa
        flag1 = true
      end
      if b < @xc
        flag2 = true
      end
    else
      if a*@xa + b < @ya
        flag1 = true
      end
      if a*@xc + b < @yc
        flag2 = true
      end
    end

    flag1^flag2
  end

  def check2
    flag1 = false
    flag2 = false

    if (@xc-@xa) != 0
      a = calc_slope2
      b = @ya - a*@xa
    else
      a = 0
      b = @xa
    end

    if a == 0 && (@xc-@xa) == 0
      if b < @xb
        flag1 = true
      end
      if b < @xd
        flag2 = true
      end
    else
      if a*@xb + b < @yb
        flag1 = true
      end
      if a*@xd + b < @yd
        flag2 = true
      end
    end

    flag1^flag2
  end
end

c = Convex.new

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

int main() {
    int n; cin >> n;
    vector<int> l(n);
    for (auto &e : l) cin >> e;

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            for (int k = j + 1; k < n; ++k) {
                if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
                int s = l[i] + l[j] + l[k];
                int m = max(max(l[i], l[j]), l[k]);
                if (m < s - m) {
                    ++ans;
                }
            }
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 3624
#include<stdio.h>
int main()
{
	int a,b,c;
	int s1,s2,s3;
	scanf("%d%d%d",&a,&b,&c);
	s1=a+b;
	s2=a+c;
	s3=b+c;
	if(s1==c||s2==b||s3==a)
	  printf("Yes\n");
	else
	  printf("No\n");
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c; cin>>a>>b>>c;
    if (a==b) cout<<c<<endl;
    if (b==c) cout<<a<<endl;
    if (a==c) cout<<b<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  if (n%2) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  for (ll i = 5; i <= n; i*=5)
    ans += n/i/2;
  cout << ans << endl;
  return 0;
}

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

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

    ll ng = 0, r = 0, g = 0, b = 0;
    rep(i, n) {
        s[i] == 'R' ? r++ : s[i] == 'G' ? g++ : b++;
        rep(d, n) {
            int j = i + d, k = j + d;
            if (k >= n) break;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ng++;
        }
    }

    cout << r * g * b - ng << endl;
    return 0;
}


Measured memory_bytes: 3628
(defun q-emptyp (queue)
  (and (null (car queue))
       (null (cdr queue))))

(defun q-singlep (queue)
  (and
   (not (q-emptyp queue))
   (eq (car queue) (cdr queue))))

(defun enqueue (queue obj)
  (if (q-emptyp queue)
      (progn
        (setf (car queue) (list obj))
        (setf (cdr queue) (car queue)))
      (progn
        (setf (cddr queue) (cons obj nil))
        (setf (cdr queue) (cddr queue)))))

(defun dequeue (queue)
  (let ((tmp nil))
    (cond 
      ((q-emptyp queue) nil)
      ((q-singlep queue)
        (setf tmp (caar queue))
        (setf (car queue) nil)
        (setf (cdr queue) nil))
      (t
        (setf tmp (caar queue))
        (setf (car queue) (cdar queue))))
    tmp))

(defun add-lunlun (queue n)
  (if (not (= (mod n 10) 0)) 
      (enqueue queue (+ (* 10 n) (- (mod n 10) 1))))
  (enqueue queue (+ (* 10 n) (mod n 10)))
  (if (not (= (mod n 10) 9))
      (enqueue queue (+ (* 10 n) (mod n 10) 1))))
  
(let ((n (read))
      (queue '(nil))
      (next 0))
  (loop :as i 
        :below 9
        :do (enqueue queue (+ i 1)))
  (loop :repeat n
        :do (setf next (dequeue queue))
            (add-lunlun queue next))
  (princ next))

Measured memory_bytes: 17764
#include<bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define SFOR(i,a,b) for(int i=a;i<b;i++)
#define elif(a) else if(a)
#define INF INT_MAX
#define F first
#define S second
#define endl '\n'
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int h,w,hsum[2001][2001],wsum[2001][2001];
int mp[2001][2001];
char a[2001][2001];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w;
  int xfl,yfl[2001];
  memset(yfl,-1,sizeof(yfl));
  FOR(y,h){
    xfl=-1;
    FOR(x,w){
      cin>>a[y][x];
      if(a[y][x]=='.'){
        if(y==0) wsum[y][x]++;
        else wsum[y][x]=wsum[y-1][x]+1;
        if(xfl==-1) xfl=x;
        if(x==0) hsum[y][x]++;
        else hsum[y][x]=hsum[y][x-1]+1;
        if(yfl[x]==-1) yfl[x]=y;
      }else{
        hsum[y][x]=0;
        wsum[y][x]=0;
        if(xfl!=-1){
          SFOR(i,xfl,x){
            hsum[y][i]=hsum[y][x-1];
          }
        }
        if(yfl[x]!=-1){
          SFOR(i,yfl[x],y){
            wsum[i][x]=wsum[y-1][x];
          }
        }
        xfl=-1;
        yfl[x]=-1;
      }
      if(y==h-1 && yfl[x]!=-1){
        SFOR(i,yfl[x],y){
          wsum[i][x]=wsum[y][x];
        }
      }
      if(x==w-1 && xfl!=-1){
        SFOR(i,xfl,x){
          hsum[y][i]=hsum[y][x];
        }
      }
    }
  }
  int ans=0;
  FOR(y,h){
    FOR(x,w){
      ans=max(ans,hsum[y][x]+wsum[y][x]-1);
    }
  }
  cout<<ans<<endl;
  return 0;
}



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

int K, S;

int main()
{
	scanf("%d%d", &K, &S);
	int ans = 0;

	for (int x = 0; x <= K; ++x) {
		for (int y = 0; y <= K; ++y) {
			int z = S - x - y;
			if (0 <= z && z <= K) ++ans;
		}
	}
	printf("%d", ans);
}
		


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL A, B, Q;
vector<LL> s, t;
LL INF = 1LL<<55;

void init() {

}

void input() {
  cin >> A >> B >> Q;
  REP(i, A) {
    LL l;
    cin >> l;
    s.PB(l);
  }
  s.PB(INF);
  s.PB(-INF);
  REP(i, B) {
    LL l;
    cin >> l;
    t.PB(l);
  }
  t.PB(INF);
  t.PB(-INF);
  sort(ALL(s));
  sort(ALL(t));
}

void solve() {
  REP(_, Q) {
    LL x;
    cin >> x;
    int prs = lower_bound(ALL(s), x) - s.begin();
    int pls = prs - 1;
    int prt = lower_bound(ALL(t), x) - t.begin();
    int plt = prt - 1;
    LL rs = s[prs] - x;
    LL ls = x - s[pls];
    LL rt = t[prt] - x;
    LL lt = x - t[plt];

    LL res = INF;
    chmin(res, rs + rt - min(rs, rt));
    chmin(res, ls + lt - min(ls, lt));
    chmin(res, rs + lt + min(rs, lt));
    chmin(res, ls + rt + min(ls, rt));
    cout << res << endl;
  }
}

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


Measured memory_bytes: 3060
#include<stdio.h>
int S(int x,int A, int B)
{
	int sum = 0;
	while (x != 0)
	{
		sum += x % 10;
		x /= 10;
	}
	if (sum >= A&&sum <= B)
		return 1;
	else
		return 0;
}
int main()
{
	int N, A, B,sum=0;
	scanf("%d %d %d", &N, &A, &B);
	for (int n = 1;n <= N;n++)
		if (S(n, A, B))
			sum += n;
	printf("%d", sum);
}

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

template <long long MOD_ = (long long)1e9 + 7>
class ModMath {
public:
    ModMath(int N = 0)
        : N_(N)
    {
    }

    template <class... Ts>
    constexpr long long mul(long long head, Ts&&... tail)
    {
        auto res = head;
        using swallow = std::initializer_list<int>;
        (void)swallow { (void(res = (res * tail) % MOD_), 0)... };
        return res;
    }

    template <class... Ts>
    constexpr long long add(long long head, Ts&&... tail)
    {
        auto res = head;
        using swallow = std::initializer_list<int>;
        (void)swallow { (void(res = (res + tail) % MOD_), 0)... };
        return res;
    }

    constexpr long long del(long long x, long long y)
    {
        auto res = x - y;
        if (res < 0) {
            res += MOD_;
        }
        return res;
    }

    constexpr long long pow(long long x, long long y)
    {
        ll ans = 1;
        while (y > 0) {
            if (y & 0x1) {
                ans = mul(ans, x);
            }
            x = mul(x, x);
            y >>= 1;
        }
        return ans;
    }

    long long combination(long long n, long long k)
    {
        if (k < 0 || k > n) {
            return 0;
        }
        if (fact_.empty()) {
            build_fact();
        }
        return mul(fact_[n], fact_inv_[k], fact_inv_[n - k]);
    }

private:
    void build_fact()
    {
        if (!fact_.empty()) {
            return;
        }
        fact_.resize(N_ + 1);
        fact_[0] = 1;
        for (ll i = 1; i <= N_; i++) {
            fact_[i] = mul(fact_[i - 1], i);
        }
        fact_inv_.resize(N_ + 1);
        fact_inv_[N_] = pow(fact_[N_], MOD_ - 2);
        for (ll i = N_ - 1; i >= 0; i--) {
            fact_inv_[i] = mul(fact_inv_[i + 1], (i + 1));
        }
    }

    int N_;
    vector<long long> fact_;
    vector<long long> fact_inv_;
};

void solve(string S)
{
    ModMath<2019> m;

    ll num = 0;
    ll mult = 1;
    vector<ll> cnt(2019);
    cnt[0] = 1;

    ll ans = 0;
    for (auto it = rbegin(S); it != rend(S); it++) {
        num = m.add(num, m.mul(*it - '0', mult));
        ans += cnt[num];
        cnt[num]++;
        mult = m.mul(mult, 10);
    }
    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    string S;
    cin>>S;
    solve(move(S));
    return 0;
}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC50(void);
void ABC51(void);
void ABC52(void);
void ABC53(void);
void ABC54(void);
void ABC55(void);
void ABC56(void);
void ABC57(void);
void ABC58(void);
void ABC59(void);

int main(void){
    ABC52();
}

void ABC52(){
    int min=-1,max=-1,i,n;
    string s;
    cin>>s;
    n=s.length();
    for(i=0;i<n;i++){
        if(s[i]=='A'&&min==-1)min=i;
        if(s[n-1-i]=='Z'&&max==-1)max=n-1-i;
        if(min!=-1&&max!=-1)break;
    }
    cerr<<min<<" "<<max<<endl;
    cout<<max-min+1<<endl;
}


Measured memory_bytes: 640
#include <cstdio>

#define int long long
#define dotimes(i, n) for (int i : range(n))

using namespace std;

class range {
  class iterator {
    int i, s;
  public:
    iterator(int i, int s): i(i), s(s) {}
    int& operator*() {
      return i;
    }
    void operator++() {
      i += s;
    }
    bool operator!=(iterator const& that) {
      return i < that.i;
    }
  };
  iterator b, e;
public:
  range(int e): b({0, 1}), e({e, 1}) {}
  range(int b, int e): b({b, 1}), e({e, 1}) {}
  range(int b, int e, int s): b({b, s}), e({e, s}) {}
  iterator begin() {
    return b;
  }
  iterator end() {
    return e;
  }
};

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

template<typename T>
inline int size(T container) {
  return static_cast<int>(container.size());
}

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

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

signed main() {
  int H = rint();
  int W = rint();
  int K = rint();
  int board0[H][W];
  dotimes(j, H) {
    char s[W+1];
    scanf("%s\n", s);
    dotimes(i, W)
      board0[H-j-1][i] = s[i] - '0';
  }
  int r = 0;
  dotimes(y, H) dotimes(x, W) {
    int board[H][W+1] = {};
    dotimes(j, H) dotimes(i, W)
      board[j][i] = board0[j][i];
    for (int j : range(y+1, H))
      board[j-1][x] = board[j][x];
    board[H-1][x] = 0;
    int g = 0;
    for (int t = 1; ; t <<= 1) {
      int s = 0;
      dotimes(j, H) {
        int k = 1;
        dotimes(i, W)
          if (board[j][i+1] == board[j][i])
            k++;
          else {
            if (k >= K) {
              s += board[j][i] * k;
              dotimes(l, k)
                board[j][i-l] = 0;
            }
            k = 1;
          }
      }
      if (!s)
        break;
      g += t * s;
      dotimes(i, W) {
        int k = 0;
        dotimes(j, H)
          if (board[j][i])
            board[k++][i] = board[j][i];
        while (k < H)
          board[k++][i] = 0;
      }
    }
    maxs(r, g);
  }
  wint(r);
  return 0;
}


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var n = o.a();
  var a = o.a(1);
  var b = o.a(1);
  var c = o.a(1);
  var ans = 0;
  for(var i = 0; i < n; i++){
    if(a[i] === b[i]){
      if(b[i] !== c[i])ans++;
    }else if(a[i] === c[i]){
      ans++;
    }else if(b[i] === c[i])ans++;
    else ans += 2;
  }
  return ans;
}

Measured memory_bytes: 7372
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n, m = LI()
    print((n-1)*(m-1))
    return

#B
def B():
    s = S()
    print(s[0]+str(len(s)-2)+s[-1])
    return

#C
def C():
    n, m = LI()
    x = -1
    y = -1
    z = -1
    for i in range(n + 1):
        a = m - 9000 * i - 1000 * n
        if a % 4000 == 0 and a >= 0 and n - i - a / 4000 >= 0:
            y = a / 4000
            z = n - i - y
            x = i
            break
    print(int(x),int(y),int(z))
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 4208
#include <cstdio>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <algorithm>
#include <time.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <cmath>
#include <memory.h>
#include <deque>
using namespace std;

#define lightkuriboh
#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define CL(x) (x << 1)
#define CR(x) ((x << 1) + 1)
#define sqr(x) ((x) * (x))
#define Task ""

const bool OnLineJudge = 1;

typedef long long cc;
typedef long double ld;
typedef pair <int, int> pt;
const int N = 200005;
int a[N];
int n, T;
int res;

int main()
{
    if (!OnLineJudge)
    {
        freopen("input.inp", "r", stdin);
        //freopen(Task".inp", "r",  stdin);
        //freopen(Task".out", "w", stdout);
    }
    //-------------------------------------------------------------------------------------------------------
    std :: ios_base :: sync_with_stdio(false); cin.tie(0);
    //-------------------------------------------------------------------------------------------------------
    cin >> n >> T;
    for (int i = 1; i <= n; i++) cin >> a[i];
    int i = 1;
    while (i <= n) {
        int j = i;
        while (j < n && a[j + 1] - a[j] <= T) j++;
        res += T + a[j] - a[i];
        i = j + 1;
    }
    cout << res;
    //-------------------------------------------------------------------------------------------------------
    return 0;
}


Measured memory_bytes: 1024