akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int n;
int main()
{
	scanf("%d",&n);
	int l,r,ans=0;
	for(register int i=1;i<=n;i++)
	{
		scanf("%d%d",&l,&r);
		ans+=(r-l+1);
	}
	printf("%d",ans);
	putchar(10);
	return 0;
}

Measured memory_bytes: 256
def use_dictionary(commands):
    d = {}
    for cmd, word in commands:
        if cmd == 'insert':
            d[word] = True
        elif cmd == 'find':
            if word in d:
                print('yes')
            else:
                print('no')

if __name__ == '__main__':
    # ??????????????\???
    commands = []
    # commands.append(('insert', 'AAA'))
    # commands.append(('insert', 'AAC'))
    # commands.append(('find', 'AAA'))
    # commands.append(('find', 'CCC'))
    # commands.append(('insert', 'CCC'))
    # commands.append(('find', 'CCC'))
    num = int(input())
    for i in range(num):
        commands.append([x for x in input().split(' ')])

    # ???????????????
    use_dictionary(commands)

    # ???????????¨???

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

#define coutv(v) for (int i = 0; i < (v).size(); ++i) cout << v[i] << ' '; cout << endl;
#define coutvv(v) for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cout << v[i][j] << ' '; cout << endl;}
#define debugv(v) {for (int i = 0; i < (v).size(); ++i) cerr << v[i] << ' '; cerr << endl;}
#define debugvv(v) {for (int i = 0; i < (v).size(); ++i) {for (int j = 0; j < (v[i]).size(); ++j) cerr << v[i][j] << ' '; cerr << endl;}}
#define TC int TESTCASE; cin >> TESTCASE; while (TESTCASE--)
typedef long long ll;



int main() {
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    if (f < e - a) {
        cout << ":(";
    } else {
        cout << "Yay!";
    }
}


Measured memory_bytes: 3488
# -*- coding: utf-8 -*-
#https://atcoder.jp/contests/abc141/tasks/abc147_d
import sys
#import collections

n= int(input())

tmp = input().split()
s = list(map(lambda a: int(a), tmp))

total=0
a=[]
for i in range(0,60):
	a.append(0)

for i in range(0,n):
	tmp = s[i]
	for j in range(0,60):
		if(tmp==0):
			break
		if(tmp%2==1):
			a[j]+=1
		tmp=tmp//2

total=0
for j in range(60,0,-1):
	total*=2
	if(a[j-1]>0):
		total=total+(a[j-1])*(n-a[j-1])
	if(total>1000000007):
		total=total%1000000007
total=total%1000000007

print(total)





Measured memory_bytes: 123056
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5 + 10;
int f , d;

int valid(int year,int mon){
//	if (mon == 1 || mon == 3|| mon == 5|| mon == 7|| mon == 8|| mon == 10|| mon == 12) return day <= 31;
//	if (mon == 2) return day <= 29;
//	return day <= 30;
	return mon <= 12 && mon >= 1;
}

char s[10];
int main(){
	scanf("%s",s);
	f = (s[0]-'0') * 10 + s[1]-'0';
	d = (s[2]-'0') * 10 + s[3]-'0';
	if (valid(f , d) && valid(d , f)) {
		puts("AMBIGUOUS");
	}else
	{
		if (valid(f , d)) {
			puts("YYMM");
		}else
		if (valid(d , f)){
			puts("MMYY");
		}else{
			puts("NA");
		}
	}
	return 0;
}

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

using namespace std;

main(){
  int n,x,y;
  int i,j;
  cin >> n >> x >> y;
  
  int dist[n-1] = {0};
  for(i=1;i<=n;i++){
    for(j=i+1;j<=n;j++){
      int distance[3] = { abs(j-i), abs(x-i)+1+abs(j-y) , abs(y-i)+1+abs(x-j) };
      sort(distance,distance+3);
      ++dist[ distance[0]-1 ];
  	}
  }
  for(i=0;i<n-1;i++){
    cout << dist[i] <<endl;
  }
  
  return 0;
}
     

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


int main(){string S;
cin >> S;
string ans = "yes";
rep(i, S.size() - 1){
    for(long j = i + 1; j < S.size(); j++){
        if(S.at(i) == S.at(j)) ans = "no";
    }
}




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



Measured memory_bytes: 256
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
def getlist2():
    return [int(x) * 100000 for x in input().split()]
import math
import bisect
import heapq
from decimal import Decimal
# from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15
def main():
    n,k = getlist()
    mo = n % k
    print(min(mo, abs(mo - k)))

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

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

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var arg = Console.ReadLine();
            var d = arg.Split(' ');

            var a = int.Parse(d[1]);
            var b = int.Parse(d[2]);
            var defference = b - a;

            if (defference % 2 == 0)
            {
                Console.WriteLine("Alice");
            }
            else
            {
                Console.WriteLine("Borys");
            }
        }
    }
}


Measured memory_bytes: 11092
import heapq

(n, m) = map(int, input().split())
jobs = {}
for _ in range(n):
    (a, b) = map(int, input().split())
    if not a in jobs:
        jobs[a] = []
    jobs[a].append(-b)

heap = []
sum = 0
for i in range(1, m + 1):
    if i in jobs:
        for j in jobs[i]:
            heapq.heappush(heap, j)
    if 0 < len(heap):
        sum -= heapq.heappop(heap)
print(sum)


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

int main() {
  int n; cin >> n;
  vector<int> vs(n); 
  vector<int> cs(n); 


  rep(i, n) {
    cin >> vs[i];
  }

  rep(i, n) {
    cin >> cs[i];
  }

  vector<int> ss(n); 

  rep(i, n) {
    ss[i] = vs[i] - cs[i];
  }

  int max  = 0;
  rep(i,n){
    if (ss[i] > 0){
      max += ss[i] ;
    }
  }


    cout << max << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int max(int a, int b) { return (a > b)? a : b; }

long long int knapSack(long long int W, long long int wt[], long long int val[], int n)
{
int i, w;
long long int K[n+1][W+1];


for (i = 0; i <= n; i++)
{
	for (w = 0; w <= W; w++)
	{
		if (i==0 || w==0)
			K[i][w] = 0;
		else if (wt[i-1] <= w)
				K[i][w] = max(val[i-1] + K[i-1][w-wt[i-1]], K[i-1][w]);
		else
				K[i][w] = K[i-1][w];
	}
}

return K[n][W];

}

int main()
{
    int n;
    long long int W;
    cin>>n>>W;


	long long int val[n],wt[n];

	for(int i=0;i<n;i++){
        long long int a,b;
        cin>>a>>b;
        wt[i] = a;
        val[i] = b;
	}

	 //n = sizeof(val)/sizeof(val[0]);
	printf("%lld", knapSack(W, wt, val, n));
	return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
 
int main() {
  ios_base::sync_with_stdio(false);
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//end

typedef pair<ll,ll> P;

constexpr ll C=1000000007;
//傾きと作る箱の個数から必要なボールの個数
P need(int k,int p){
   int q=C-p; ll lb=0,rb=C*2020;
   while(rb-lb>1){
      ll mid=(lb+rb)/2,cnt=0;
      rep(x,0,mid/p+1){
         cnt+=(mid-x*p)/q+1;
         if(cnt>=k)break;
      } if(cnt<k)lb=mid; else rb=mid;
   }
   P res({0,0});
   rep(x,0,rb/p+1){
      ll y=(rb-x*p)/q;
      res.first+=x*(y+1); res.second+=y*(y+1)/2;
   } return res;
}

//箱の個数とボールの個数から判定
bool check(int k,int r,int b){
   int lb=0,rb=C+1; P x,y;
   while(rb-lb>1){
      int mid=(lb+rb)/2; P p=need(k,mid);
      if(p.first<=r&&p.second<=b)return true;
      if(p.first>r&&p.second>b)return false;
      if(p.first>r)x=p,lb=mid; else y=p,rb=mid;
   } return (y.first-x.first)*(b-x.second)<=(y.second-x.second)*(r-x.first);
}

//reference:https://physics0523.hatenablog.com/entry/2020/02/05/024612
int main(){
   int r,b; cin>>r>>b; if(r>b)swap(r,b);
   int lb=0,rb=1341398*2;
   while(rb-lb>1){
      int mid=(lb+rb)/2;
      if(check(mid,r,b))lb=mid; else rb=mid;
   } cout<<lb-1<<endl;
   return 0;
}


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

int main() {
	int n;
	cin>>n;
	int f=0;
	for(int i=1;i<=9;i++)
	{
	    if(n%i==0)
	    {
	        if((n/i)>=1&&(n/i)<=9)
	        {
	            f=1;
	            break;
	        }
	    }
	}
	if(f==1)
	cout<<"Yes";
	else
	cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		var n = sc.nextInt();
		var m = sc.nextInt();
		var a = new int[m];
		for(var i = 0; i < m; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();

		var sum = 0;
		for(var i = 0; i < m; i++) {
			sum += a[i];
		}

		System.out.println(sum <= n ? n - sum : -1);
	}
}

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

int main(void)
{
    int N;
    cin >> N;
    
    ll total = 0;

    vector<int> a(N);

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        total += (ll) a[i];
    }

    vector<ll> candidates(N-1, 0);
    ll sum = 0;
    for(int i = 0; i < N-1; i++){
        sum+=(ll) a[i];
        candidates[i] = abs(sum - (total - sum));
    }

    ll result = *min_element(candidates.begin(), candidates.end());
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 5504
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N, M;
    cin >> N >> M;

    vector<int> b(N);
    for (int i = 0; i < N; i++) cin >> b[i];

    int WHITE = 0, BLACK = 0;
    for (int i = 0; i < N; i++) {
        if (b[i] == 0) WHITE++;
        if (b[i] == 1) BLACK++;
    }

    vector<int> p(M);
    for (int i = 0; i < M; i++) cin >> p[i];

    vector<vector<int>> a(2, vector<int>());
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < M; j++) {
            for (int k = 0; k < p[j]; k++) {
                a[i].push_back((j + i) % 2);
            }
        }
    }

    int ans = INT_MAX;
    for (int obeee = 0; obeee < 2; obeee++) {
        auto d = a[obeee];
        int w_count = 0, b_count = 0;
        for (int j = 0; j < d.size(); j++) {
            if (d[j] == 0) w_count++;
            if (d[j] == 1) b_count++;
        }
        if (w_count != WHITE || b_count != BLACK) continue;

        int sum = 0;
        for (int i = 0; i < N; i++) {
            if (b[i] != d[i]) {
                int index;
                for (int j = N - 1; j > i; j--) if (d[j] == b[i]) index = j;
                for (int j = index; j > i; j--) sum++, swap(d[j - 1], d[j]);
            }
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}






























































Measured memory_bytes: 3148
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 2e3 + 5;

void chk_min(int &a,int b){ if(a>b) a=b;}
int Abs(int x){ return x<0? -x: x;}

int ans[MAXN];

int main(void)
{
	int n,x,y;
	scanf("%d%d%d",&n,&x,&y);
	
	for(int i=1; i<=n; ++i)
		for(int j=i+1; j<=n; ++j)
		{
			int dis=n-1;
			chk_min(dis, j-i);
			chk_min(dis, Abs(i-x) + 1 + Abs(j-y));
			chk_min(dis, Abs(j-x) + 1 + Abs(i-y));
			++ans[dis];
		}
	for(int i=1; i<n; ++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 128
import java.math.BigInteger;
import java.util.Scanner;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n;
		BigInteger a, b, sum;
		n = sc.nextInt();

		for(int i = 0; i < n; i++){
			a = sc.nextBigInteger();
			b = sc.nextBigInteger();
			sum = a.add(b);

			if(sum.toString().length() > 80){
				System.out.println("overflow");
			}else{
				System.out.println(sum);
			}
		}
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
	char tmp[100];
	int points[3];
	char judge[100];

	int i,cnt;
	//???????????????????????°??????????¨??????????????????????????????°?????\???
	//??¨??????-1??????????????§??\???
	while (fgets(tmp, sizeof(tmp), stdin)) {
		points[0] = atoi(strtok(tmp, " "));
		for (i = 1; i < 3; i++) {
			points[i] = atoi(strtok(NULL, " "));
		}
		if (points[0] == -1 && points[1] == -1 && points[2] == -1)break;
		int sum = points[0] + points[1];

		//?¬????1?????§???????????°??????F???30?????????F
		if (sum < 30 || points[0] == -1 || points[1] == -1) {
			judge[cnt] = 'F';

		//????¨??????°80??????A
		}else if(sum>=80){
			judge[cnt] = 'A';


		//65???79??????B
		}else if(sum>=65&&sum<80){
			judge[cnt] = 'B';


		//50???64??????????¨????50??\?????????C
		}else if ((sum >= 50 && sum<65) ||points[2]>=50) {
			judge[cnt] = 'C';

		//30???49??????D
		}else{
			judge[cnt] = 'D';

		}
		cnt++;
	}
	for (i = 0; i < cnt; i++) {
		printf("%c\n",judge[i]);
	}

	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007

const ll mod = 998244353;
ll modpow(ll n,ll r){
  ll res = 1;
  while(r){
    if(r & 1)res = res*n%mod;
    n = n*n%mod;
    r >>= 1;
  }
  return res;
}

int main(){

  int  n;
  cin >> n;
  vector<int> v(n,0);
  bool is = true;
  rep(i,n){
    int x;cin >> x;
    v[x]++;
    if(i == 0 && x != 0)is =false;
  }
  int mx = 0;
  rep(i,n)if(v[i] != 0)mx = i;
  ll res = 1;
  for(int i = 1;i <= mx;i++)(res *= modpow(v[i-1],v[i]))%=mod;
  if(v[0] != 1 || !is)res = 0;
  cout << res << endl;




  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define flush fflush(stdout)
#define debug printf("Hello\n")
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
int n, m, k, x, y, sum, cnt, ans;
vector<pair<int, ll> >edges[100005];
priority_queue<pair<ll, int>, vector<pair<ll, int> >, greater<pair<ll, int> > > pq;
ll w, dist[100005];
bool vis[100005];
int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  FOR(i, 1, m) {
    cin >> x >> y >> w;
    edges[x].pb({y, w});
    //edges[y].pb({x, w});
  }
  FOR(i, 2, n) {
    edges[i].pb({i-1, 0});
  }
  FOR(i, 2, n) dist[i] = 1e15;
  pq.push({0, 1});
  while (!pq.empty()) {
    auto tmp = pq.top();
    pq.pop();
    int u = tmp.se;
    if (vis[u] || tmp.fi != dist[u]) continue;
    vis[u] = true;
    for (auto it: edges[u]) {
      if (dist[u] + it.se < dist[it.fi] && !vis[it.fi]) {
        dist[it.fi] = dist[u] + it.se;
        pq.push({dist[it.fi], it.fi});
      }
    }
  }
  if (dist[n] == 1e15) cout << "-1\n";
  else cout << dist[n] << endl;
  return 0;
}

Measured memory_bytes: 9464
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,p[300030];
void no()
{
	printf("No");
	exit(0);
}
void check(int l,int r)
{
	int mx1=0,mx2=0;
	for(int i=l;i<=r;i+=2)
	{
		if(p[i]<l||p[i]>r)no();
		if(i<p[i])
		{
			if(mx1>p[i])no();
			mx1=p[i];
		}
		else
		{
			if(mx2>p[i])no();
			mx2=p[i];
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",&p[i]);
	for(int i=1,r;i<=n;++i)
	{
		if(p[i]==i)continue;
		r=i;
		while(r<=n-2&&p[r+1]==r+1&&p[r+2]!=r+2)r+=2;
		check(i,r);
		i=r;
	}
	printf("Yes");
	return 0;
}


Measured memory_bytes: 1408
# -*- coding: utf-8 -*-
from math import factorial

N, M = map(int, input().split())
a = [int(input()) for x in range(M)]

def fibo(dan):
    tmp = [1, 1]
    for i in range(2, dan+1):
        tmp.append(tmp[i-1] + tmp[i-2])
    return tmp[dan]

routes = 1
prev = 0
for x in a:
    if x == prev:
        routes = 0
        break
    else:
        dan = (x-1) - prev
        routes = (routes * fibo(dan))
        prev = x+1

routes = (routes * fibo(N-prev)) % 1000000007
print(int(routes))

Measured memory_bytes: 464040
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  string A;
  cin >> A;
  rep(i, A.size()) {
    cout << "x";
  }
  ENDL;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;
 
int main() {
	ll N; cin >> N;
	ll p[100001] = {};
 
	rep(i, 0, N) {
		ll a; cin >> a;
 
		if (a > 0) {
			p[a - 1]++;
		}
		p[a]++;
		p[a + 1]++;
	}
	ll maxV = 0;
	repe(i, 0, 100001) {
		maxV = max(maxV, p[i]);
	}
	cout << maxV << endl;
 
	return 0;
}

Measured memory_bytes: 1024
use std::io;
use std::str::FromStr;
use std::str::Chars;
use std::i32;
use std::u8;
use std::f64;
use std::ascii::AsciiExt;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::io::prelude::*;
use std::time::Duration;
use std::cmp;

macro_rules! println_stderr(
    ($($arg:tt)*) => { {
        let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

macro_rules! print_stderr(
    ($($arg:tt)*) => { {
        let r = write!(&mut ::std::io::stderr(), $($arg)*);
        r.expect("failed printing to stderr");
    } }
);

fn main() {
    let v = next_ints();
    if v[0] <= 0 && v[1] >= 0 {
        println!("Zero");
    }
    else if v[0] > 0 && v[1] > 0 {
        println!("Positive");
    }
    else if v[0] < 0 && v[1] < 0 {
        println!("{}",match v[1] - v[0] + 1 {
            n if n % 2 == 0 => "Positive",
            _ => "Negative",
        })
    }
}

#[allow(dead_code)]
fn next_string() -> String {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    input
}

#[allow(dead_code)]
fn next_strings() -> Vec<String> {
    let input = next_string();
    input.split_whitespace().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn next_int() -> i64 {
    let input = next_string();
    i64::from_str(input.trim()).unwrap()
}

#[allow(dead_code)]
fn next_ints() -> Vec<i64> {
    let input = next_string();
    input.split_whitespace().map(|x| x.parse().unwrap()).collect()
}


Measured memory_bytes: 380
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	ll n, a, b;
    cin >> n >> a >> b;
    
    if(a%2 == b%2) {
        cout << (b-a)/2 << endl;
    } else {
        ll vl = a + (b-a-1)/2;
        ll vr = n-b+1 + (b-a-1)/2;
        cout << min(vl, vr) << endl;
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n, s = 0, h, c = 0;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> h;
        if (s <= h){
            s = h;
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(Q: int, H: int, S: int, D: int, N: int):
    H = min(H, 2*Q)
    S = min(S, 2*H)
    if 2 * S <= D:
        print(N*S)
    else:
        print(N//2 * D + (N % 2) * S)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    H = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    N = int(next(tokens))  # type: int
    solve(Q, H, S, D, N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5688
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr ll INF = 1e18 + 10;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

int main()
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int a, b;
    cin >> a >> b;
    cout << a * b << "\n";
    return 0;
}


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

int main(){
    int a, b;
    cin >> a >> b;
    for(int i = 1; i < 4; i++){
        int d;
        d = a * b * i;
        if(d % 2 != 0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    char c[4], s[4];
    int i;
    
    for (i = 0; i < 3; i++) {
        scanf("%s", c);
        s[i] = c[i];
    }
    printf("%c%c%c", s[0], s[1], s[2]);
    
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

 
 
 using namespace std;

 
 
 int main()
{
   int i, a, b, temp;
   for(i=1; i<=3000 ; i++)
   {
   cin >> a >> b;
   if( a==0 && b==0 )
   break;
   if(a > b)
   {
     temp = a;
     a = b;
     b = temp;
   }
    cout << a << " " << b << endl;
   }
}


Measured memory_bytes: 3084
isExist = Array.new( 2000, false );
n = gets.to_i
arrA = gets.split( " " ).map { |val| val.to_i }
s = 0
for val in arrA
	( 2000 - val ).downto(1) { |j|
		if isExist[ j ]
			isExist[ j+val ] = true
		end
	}
	isExist[ val ] = true
end
q = gets.to_i
arrM = gets.split( " " ).map { |val| val.to_i }
for i in ( 0 ... q )
	if isExist[ arrM[i] ]
		puts( "yes" )
	else
		puts( "no" )
	end
end

Measured memory_bytes: 6128
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: u64,
        m: u64,
    }

    let ans_max: u64 = (m as f64 / n as f64).floor() as u64;

    for ans in (1..(ans_max+1)).rev() {
        if m % ans == 0 {
            println!("{}", ans);
            return;
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	string s;
	int a,b,t;
	cin>>a>>b>>t ;
	cout<<t/a*b<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTI 2000000000

struct Card{
  char suit;
  int value;
};
struct Card L[MAX/2+2],R[MAX/2+2];

void merge(struct Card A[],int n, int left,int mid,int right){
  int i,j,k;
  int n1=mid-left;
  int n2=right-mid;
  for(i=0;i<n1;i++)L[i]=A[left+i];
  for(i=0;i<n2;i++)R[i]=A[mid+i];
  L[n1].value=R[n2].value=SENTI;
  i=j=0;
  for(k=left;k<right;k++){
    if(L[i].value<=R[j].value){
      A[k]=L[i++];
    }
    else{
      A[k]=R[j++];
    }
  }
}
void mergeS(struct Card A[],int n,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeS(A,n,left,mid);
    mergeS(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}
int partition(struct Card A[],int n,int p,int r){
  int j,i;
  struct Card t,x;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j].value<=x.value){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}
void quickS(struct Card A[],int n,int p,int r){
  int q;
  if(p<r){
    q=partition(A,n,p,r);
    quickS(A,n,p,q-1);
    quickS(A,n,q+1,r);
  }
}

int main(){
  int n,i,v;
  struct Card A[MAX],B[MAX];
  char S[10];
  int stable=1;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s %d",S,&v);
    A[i].suit=B[i].suit=S[0];
    A[i].value=B[i].value=v;
  }
  mergeS(A,n,0,n);
  quickS(B,n,0,n-1);

  for(i=0;i<n;i++){
    if(A[i].suit!=B[i].suit)stable=0;
  }
  if(stable==1)printf("Stable\n");
  else printf("Not stable\n");
  for(i=0;i<n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<int> vrow(10);
    vector<vector<int>> values(10,vrow);
    for (int i=0; i<10; i++) for (int j=0; j<10; j++) cin >> values[i][j];
    vector<vector<pair<int,ll>>> paths(10);
    for (int i=0; i<10; i++) {
        for (int j=0; j<10; j++) {
            if (i!=j) paths[i].push_back(make_pair(j,values[i][j]));
        }
    }
    vector<ll> finalvalues(10,0);
    priority_queue<pair<ll,int>> moves;
    for (int i=0; i<10; i++) {
        vector<ll> dists(10,1000000000);
        dists[i] = 0;
        moves.push(make_pair(0,i));
        while (moves.size()>0) {
            pair<ll,int> curr = moves.top();
            moves.pop();
            for (auto j : paths[curr.second]) {
                if (-curr.first+j.second >= dists[j.first]) continue;
                dists[j.first] = -curr.first+j.second;
                moves.push(make_pair(curr.first-j.second,j.first));
            }
        }
        finalvalues[i] = dists[1];
    }
    int val;
    ll res = 0;
    for (int i=0; i<h; i++) for (int j=0; j<w; j++) {
        cin >> val;
        if (val==-1) continue;
        res+=finalvalues[val];
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int[]a = new int[N];
			long []s = new long[N+1];
			long min = Long.MAX_VALUE;
			for(int i = 0;i<N;i++) {
				a[i] = scan.nextInt();
				s[i+1] = a[i]+s[i];
			}
			
			for(int i = 1;i<N;i++) {
				long sunuke = s[i];
				long araigu = s[N]-s[i];
				long ze = Math.abs(sunuke-araigu);
				
				if(min>ze)min = ze;
				
				
			}
			
			System.out.println(min);
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 82828
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, s;
bool check(int xb)
{
	if(xb < 2ll) return false;
	int res = 0ll, tmp = n;
	while(tmp >= xb)	{
		res += tmp % xb;
		tmp /= xb;
	}
	res += tmp;
	return (res == s);
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	if(s == n) {
		cout << n + 1; 
		return 0;
	}
	for(int i = 2; i <= min(n, 1000000*1ll); ++i)	{
		if(check(i)) {
			cout << i;	return 0;
		}
	}
	int ans = -1;
	for(int i = 1; i <= min(s, 100000*1ll) && s - i <= n; ++i)	{
		int rem = s - i;
		int tmp = n - rem;
		if(tmp % i == 0 && check(tmp / i)){
			if(ans > tmp/i || ans == -1) ans = tmp/i;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;


int n, M[MAX][MAX];
  
void dijkstra() {
  int minv;
  int d[MAX], color[MAX];

  for(int i = 0; i< n; i++) {
    d[i] = INFTY;
    color[i] = WHITE;
  }


  d[0] = 0;
  color[0] = GRAY;
  while(1) {
    minv = INFTY;
    int u = -1;
    for (int i = 0; i < n; i++) {
      if (minv > d[i] && color[i] != BLACK ) {
        u = i;
        minv = d[i];
      }
    }
    if ( u == -1) break;
    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] != INFTY ) {
        if (d[v] > d[u] + M[u][v] ) {
          d[v] = d[u] + M[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
 for (int i = 0; i < n; i++ ){
  cout << i << " " << (d[i] == INFTY ? -1 : d[i] ) << endl;
 }
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  int k, c, u, v;
  for (int i = 0; i < n; i++ ){
    cin >> u >> k;
    for (int j = 0; j< k; j++) {
      cin >> v >> c;
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}




Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    REP(i, N - 1){
        cin >> C[i] >> S[i] >> F[i];
    }
    REP(i, N){
        int ans = 0;
        FOR(j, i, N - 1){
            if(ans < S[j]){
                ans = S[j];
            }else{
                if(ans % F[j] == 0){
                    ans = ans;
                }else{
                    ans = F[j] * (ans / F[j] + 1);
                }
            }
            ans += C[j];
        }
        cout << ans;
        if(i != N - 1) cout << endl;
    }
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		List<List<Hen>> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new ArrayList<>());
		}
		for (int i = 0; i < m; i++) {
			sa = br.readLine().split(" ");
			Hen h = new Hen();
			h.l = Integer.parseInt(sa[0]) - 1;
			h.r = Integer.parseInt(sa[1]) - 1;
			h.d = Integer.parseInt(sa[2]);
			list.get(h.l).add(h);
			list.get(h.r).add(h);
		}
		br.close();

		long[] x = new long[n];
		boolean[] fix = new boolean[n];
		for (int i = 0; i < n; i++) {
			if (!fix[i]) {
				fix[i] = true;
				x[i] = 0L;
				Queue<Integer> que = new ArrayDeque<>();
				que.add(i);
				while (!que.isEmpty()) {
					int cur = que.poll();
					for (Hen h : list.get(cur)) {
						int next = h.r;
						int d = h.d;
						if (cur == h.r) {
							next = h.l;
							d = -d;
						}
						if (!h.used) {
							h.used = true;
							if (!fix[next]) {
								fix[next] = true;
								x[next] = x[cur] + d;
								que.add(next);
							} else {
								if (x[next] - x[cur] != d) {
									System.out.println("No");
									return;
								}
							}
						}
					}
				}
			}
		}
		System.out.println("Yes");
	}

	static class Hen {
		int l, r, d;
		boolean used;
	}
}


Measured memory_bytes: 79084
/*************************************************************************
    > File Name: AtLevelC.cpp
    > Author: KyrieL
    > Mail: 443999592@qq.com
    > Created Time: Mon May 21 19:37:07 2018
 ************************************************************************/
//C - Sequence Growing Easy

#include<iostream>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;

const int MAXN = 200000+10;
typedef long long ll;
int a[MAXN];
int main(){
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	bool flag = true;
	for(int i = 0; i < n; ++i){
		if(a[0] != 0){
			flag = false;
			break;
		}
		if(a[i] > i){
			flag = false;
			break;
		}
		if(i && a[i]-a[i-1] > 1){
			flag = false;
			break;
		}
	}
	if(!flag){
		cout << -1 << endl;
		exit(0);
	}
	ll cnt = 0;
	for(int i = 1; i < n; ++i){
		if(a[i] == a[i-1]+1)
			cnt++;
		else 
			cnt += a[i];
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
from heapq import heappush, heappop

INF = 10000 * 100000

def dijkstra(s: int):
	d[s] = 0
	H = []
	for v in range(n):
		heappush(H, (d[v], v))
	while len(H) >= 1:
		_, u = heappop(H)
		color[u] = "BLACK"
		for v, c in M[u]:
			if color[v] != "BLACK" and d[u] + c < d[v]:
				d[v] = d[u] + c
				pi[v] = u
				color[v] = "GRAY"
				heappush(H, (d[v], v))

if __name__ == "__main__":
	n = int(input())
	G = []
	M = [[] for _ in range(n)]
	color = ["WHITE" for _ in range(n)]
	d = [INF for _ in range(n)]
	pi = [None for _ in range(n)]

	for _ in range(n):
		l = list(map(int, input().split()))
		u = l[0]
		k = l[1]
		for i in range(k):
			v = l[2 * (i + 1)]
			c = l[2 * (i + 1) + 1]
			M[u].append([v, c])
	dijkstra(0)
	for v in range(n):
		print(f"{v} {d[v]}")


Measured memory_bytes: 76728
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int L = sc.nextInt();
		double tmp = (double)L / 3;

		System.out.println(BigDecimal.valueOf(Math.pow(tmp, 3)).toPlainString());
	}
}

Measured memory_bytes: 20820
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    b = list(map(int, input().split()))
    a = [0] * n
    a[0] = b[0]
    for i in range(1, n - 1):
        a[i] = min(b[i - 1], b[i])
    a[n - 1] = b[n - 2]
    print(sum(a))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9016
#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 main(void){
    int h,a;
    cin >> h >> a;
    int c =0;
    while(h>0){
        h-=a;
        c++;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

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

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){

    int a, b;
    cin >> a >> b;

    int i;
    int ans = min(a, b);
    int cnt = max(a, b);

    for(i=0; i<cnt; i++)
        cout << ans;
    cout << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int sums(int a,int b,int i)
{
    int s=0,k=i;
    while(k!=0)
    {
        s+=k%10;
        k=k/10;
    }
    if(a<=s&&s<=b)
    return i;
    return 0;
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=a;i<=n;i++)
    {
        ans+=sums(a,b,i);
    }
    cout<<ans<<endl;
    return 0;
}

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

#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prtd(n, var)  cout << fixed << setprecision(n) << var << endl
#define prt2(var1, var2) cout << var1 << " " << var2 << endl

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

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

  if(e-a>k){
    prt(":(");
  } else {
    prt("Yay!");
  }
}


Measured memory_bytes: 256
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n/3<<endl;
} 
	

Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length-1;i+=2){if(eval(a+op+arr[i])){return arr[i+1];}}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const objvs =(a)=>{const b=[];for(const v in a){b.push(a[v])}return b};
const main=()=>{
  let n=tn(),c=0
  let ar=desc(tnn(n))
  let t=101;
  for(let i=0;i<n;i++){
    if(t>ar[i]){
      c++
      t=ar[i]
    }
  }
  to(c)
}
main()


Measured memory_bytes: 7500
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int main(void){
  int n ;
  while(cin>>n,n){
    int cnt = 0;
    vector<int> vec(n);
    for(int i = 0 ; i < n ; i ++){
      cin>>vec[i];
    }
    int find;
    cin>>find;
    bool ans = false;
    int l = 0 , r = n-1;
    while(l<=r){
      int mid = (l + r)/2;
      if(vec[mid]<find){
        l = mid + 1; 
      }else if(vec[mid]>find){
        r = mid - 1;
      }else{
        ans = true;
        cnt++;
        break;
      }
      cnt++;
    }
    cout<<cnt<<endl;
  }
  
}

Measured memory_bytes: 1196
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}
static const ll INF = 1e18;

int main() {
  ll a; double b; cin >> a >> b;
  ll s = b * 100 + 0.5;
  ll ans = (a * s) / 100;
  cout << ans << endl;
}

Measured memory_bytes: 3724
import math

def mycounter(d,i):
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    return d
    
def ABC159D(a):
    if a<2:
        return 0
    else:
        return math.factorial(a)//math.factorial(a-2)//2

n=int(input())
a=list(map(int,input().split()))
d = dict()
for i in a:
    d=mycounter(d,i)
p=0
for i in d.values():p+=ABC159D(i)
for i in a:
    print(p-d[i]+1)

Measured memory_bytes: 26140
N,K=map(int, input().split())
ls=[]
for i in range(N):
    ls.extend([i])
for i in range(K):
    input()
    temp=list(map(int,input().split()))
    for j in temp:
        try:
            ls.remove((j-1))
        except:
            pass
print(len(ls))

Measured memory_bytes: 9184
import java.util.*;

class Main {
        public static void main(String args[]) {
                Scanner sc = new Scanner(System.in);
                while (true) {
                        int maxnum = 0;
                        int id = 0;
                        for (int i = 0; i < 5; i++) {
                                int now = sc.nextInt() + sc.nextInt();
                                if (now == 0) {
                                        return;
                                }
                                if (now > maxnum) {
                                        maxnum = now;
                                        id = i;
                                }
                        }
                        System.out.println((char)('A' + id) + " " + maxnum);
                }
        }
}

Measured memory_bytes: 30036
#include <iostream>

using namespace std;

void solve()
{
	int pos[3] = {1, 0, 0};
	char a, b;
	while(~scanf("%c,%c%*c", &a, &b))
	{
		swap(pos[a - 'A'], pos[b - 'A']);
	}
	for(int i = 0; i < 3; ++i)
	{
		if(pos[i] == 1)
		{
			printf("%c\n", i + 'A');
		}
	}
}

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

Measured memory_bytes: 0
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
#include<functional>
using namespace std;

int main(void) {
    int N,X,d=0,ans=0;
    int L[10000];
    cin >>N >>X;
    for(int i=0;i<N;i++)
        cin >>L[i];
    for(int i=0;i<N;i++){
        ans=i;
        d+=L[i];
        if(d>X){
        cout <<ans+1<<endl;
        return 0;
        }
    }
    cout <<ans+2<<endl;
    return 0; 
}

Measured memory_bytes: 256
N,K=map(int,input().split())
MOD=10**9+7

m,M=0,N
ans=0

if K==1:
    ans+=N+1

#print(1,m,M)
for i in range(2,N+2):
    m+=(i-1)
    M+=N-(i-1)
    #print(i,m,M)
    if i<K:
        continue
    else:
        ans+=M-m+1
        ans%=MOD

print(ans)

Measured memory_bytes: 9196