akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<vector<int>> c(3, vector<int>(3));
	rep(i, 3)rep(j, 3) cin >> c[i][j];

	vector<int> a(3);
	vector<int> b(3);

	bool elf = true;

	rep(i, 101) {
		a[0] = i;
		b[0] = c[0][0] - a[0];
		b[1] = c[0][1] - a[0];
		b[2] = c[0][2] - a[0];

		a[1] = c[1][0] - b[0];
		if (a[1] + b[1] != c[1][1] || a[1] + b[2] != c[1][2]) elf = false;

		a[2] = c[2][0] - b[0];
		if (a[2] + b[1] != c[2][1] || a[2] + b[2] != c[2][2]) elf = false;
	}
	if (elf) puts("Yes");
	else puts("No");
	return 0;
}

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

public class Program
{

	public void Proc()
	{
        int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();

        int min = Math.Max(inpt[0], inpt[2]);
        int max = Math.Min(inpt[1], inpt[3]);

        int ans = Math.Max(max - min, 0);
        Console.WriteLine(ans);
        
    
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



0 33 66 99


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 13396
<?php
fscanf(STDIN,'%s%s%s',$A,$B,$C);
$Alen=strlen($A);
$Blen=strlen($B);
$Clen=strlen($C);
if($A[$Alen-1]==$B[0]&&$B[$Blen-1]==$C[0]){
  echo 'YES';
}else{
  echo "NO";
}


 ?>


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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
  
	sort(a.begin(), a.end());
	
	vector<int> dp(1000001, 0);
	int ans = 0;
	for(auto itr : a){
        if(dp[itr] != 0){
          dp[itr] = 2;
          continue;
        }
		for(int i = itr; i < 1000001; i += itr){
			dp[i] = 1;
		}
	}
	for(auto itr : a){
		if(dp[itr] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8776
#include<cmath>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<functional>
#define INF 1e16
#define N (1000000007)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;




int main(void){
    string s;
    cin>>s;
    for(int i=0;i<3;i++){
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int f[60][60],i,k,m,n;
char a[60][60];
inline void w(int i,int k)
{
	f[i][k+1]++;
	f[i][k-1]++;
	f[i+1][k]++;
	f[i-1][k]++;
	f[i+1][k+1]++;
	f[i-1][k-1]++;
	f[i+1][k-1]++;
	f[i-1][k+1]++;
}
int main()
{
	cin>>m>>n;
	for(i=1;i<=m;i++)
	{
		for(k=1;k<=n;k++)
		{
			cin>>a[i][k];
			if(a[i][k]=='#')
			w(i,k);
		}
	}
	for(i=1;i<=m;i++)
	{
		for(k=1;k<=n;k++)
		{
			if(a[i][k]=='#')
			printf("#");
			else
			printf("%d",f[i][k]);
		}
		printf("\n");
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  sort(a.begin(), a.end());
  bool flag = true;
  for(int i=1; i<n; i++) {
    if(a.at(i-1) == a.at(i)) {
      flag = false;
      break;
    }
  }
  if(flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#define findmax(a,b) (a)>(b)?(a):(b)
#define findmin(a,b) (a)<(b)?(a):(b)
#define inout freopen("in.txt","r",stdin);freopen("out.txt","w",stdout)
#define swap(a,b) (a)+=(b);(b)=(a)-(b);(a)-=(b)
#define quicksort(a,n) qsort(a,n,sizeof(a[0]),cmp)
#define inputarr(a,n) for(int i=0;i<n;i++){scanf("%d",&a[i]);}
#define printarr(a,n) for(int i=0;i<n;i++){printf("%d ",a[i]);}puts("");
int cmp(const void *a,const void *b){return *(int *)a - *(int *)b;}

int main() {
    //inout;

  
    char s[200005];

    char t[200005];

    int cnt = 0;
    
    scanf("%s%s", s, t);

    for(int i = 0; s[i]; i++){
    	if(s[i] != t[i]){
    		cnt++;
    	}
    }

    printf("%d", cnt);

}

Measured memory_bytes: 2124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Puneet    //FastRead class is taken from different online Sources
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastInput in = new FastInput(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastInput in, PrintWriter out) {

            int a = in.ni(), b = in.ni(), c = in.ni();

            int ans = b / a;

            if (ans < c)
                out.println(ans);
            else {
                out.println(c);
            }
        }

    }

    static class FastInput {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastInput.SpaceCharFilter filter;

        public FastInput(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int ni() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22612
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

N, W, H = map(int, raw_input().split())

E = [[] for i in range(N)]
lst = []
flag = True

for i in range(N):
    x, y = map(int, raw_input().split())
    if x == 1 or y == 1 or x == W or y == H:
        flag = False
    lst.append((x, y, i))

lst.sort()
for i in range(N):
    if lst[i][0] == lst[i - 1][0]:
        E[lst[i][2]].append(lst[i - 1][2])
        E[lst[i - 1][2]].append(lst[i][2])

lst2 = []

for i in range(N):
    x, y, index = lst[i]
    lst2.append((y, x, index))

lst = lst2
lst.sort()
for i in range(N):
    if lst[i][0] == lst[i - 1][0]:
        E[lst[i][2]].append(lst[i - 1][2])
        E[lst[i - 1][2]].append(lst[i][2])

used = [False for i in range(N)]

def func(num, pre):
    if used[num]:
        return
    used[num] = True
    for to in E[num]:
        if to != pre:
            func(to, num)

cnt = 0

for i in range(N):
    if not used[i]:
        func(i, -1)
        cnt += 1

if cnt > 1 and flag:
    cnt += 1
print N - 2 + cnt


Measured memory_bytes: 20496
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] arr = new int[n];
		for(int i=0;i<n;i++)
			arr[i] = sc.nextInt();
		
		Arrays.sort(arr);
		
		int cnt = 0;
		for(int i=0;i<n-2;i++){
			for(int j=i+1;j<n-1;j++){
				for(int k=j+1;k<n;k++){
					if(arr[i]+arr[j]>arr[k])
						cnt++;
					else
						break;
				}
			}
		}
		
		System.out.println(cnt);
	}

}


Measured memory_bytes: 27560
#include<stdio.h>
int main(void){
	char S[11];
	int a=0,b=0;
	int i;
	int len;
	
	scanf("%s",S);
	
	len = strlen( S );
	
	if(S[0]=='A'&&S[1]!='C'){
		for(i=1;i<11;i++){
			{
			if(S[i]=='C')
			a++;
		}
		{
		if(S[i]>='A' && S[i]<='Z')
			b++;
		}
		}
		
		if(a==1&&b==1){
			if(S[len - 1]!='C'){
		printf("AC\n");
			}else{
			printf("WA\n");
		}
		}else{
			printf("WA\n");
		}
	}else{
		printf("WA\n");
	}
		
		
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll long long 

ll l,r;
ll mod=2019;
ll MA=10003*10003;
int main(){
    cin>>r>>l;
    
    if((r-l)*(r-l)>MA){
        cout<<0<<endl;
        return 0;
    }
    
    ll ans=10000;
    
    for(ll i=r;i<=l;i++){
        for(ll j=i+1;j<=l;j++){
            ans=min(ans,i*j%mod);        
        }
    }
    
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, m, in, inn, ans;
	vi a;
	cin >> n;
	rep(i, n) {
		cin >> in;
		a.push_back(in);
	}
	cin >> m;
	rep(i, m) {
		int sum = 0;
		cin >> in >> inn;
		rep(j, n) {
			if (j == in - 1) sum += inn;
			else sum += a[j];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;


ll vs[100000+10];
int main(void) {
  int n;
  ll x;
  scanf("%d%lld", &n, &x);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  ll res = 0;
  ll last = 0;
  REP(i, n) {
    if(last + vs[i] > x) {
      res += last + vs[i] - x;
      vs[i] = x - last;
    }
    last = vs[i];
  }
  printf("%lld\n", res);
  return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		//String t = sc.next();
		//long n = sc.nextLong();
		//long m = sc.nextLong();
		//long k = sc.nextLong();
		//long count=0;

		/*for(int i=0;i<3;i++) {
			if(s.substring(i,i+1).equals(s.substring(i+1,i+2))) {
				count++;
			}else if(i!=2){
				count=0;
			}
		}*/
		/*if(n*m<=k) {
			System.out.println(n*m);
		}else{
			System.out.println(k);
		}*/
		System.out.println(Integer.parseInt(s.substring(0,1))+Integer.parseInt(s.substring(1,2))+Integer.parseInt(s.substring(2,3)));
	}
}




Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> P;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

ll n,x,y;

int main(){
    cin>>n>>x>>y;

    vi d(n);
    x--;y--;
    rep(i,n){
        REP(j,i+1,n){
            ll dij=abs(j-i);
            ll dxy=abs(x-i)+abs(y-j)+1;
            ll dis=min(dij,dxy);
            d[dis]++; 
            
       } 
    }
    REP(i,1,n)cout<<d[i]<<endl;

    return 0;

}


Measured memory_bytes: 256
import math
n=int(input())
base = math.factorial(n-1)
p = []
for i in range(n):
    x,y=map(int,input().split())
    p.append((x,y))
# length = [[0 for i in range(n)] for j in range(n)]
l=0
for i in range(n):
    for j in range(i+1,n):
        l += math.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2)*base*2
print(l/math.factorial(n))

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N, x;
    int a[110];
    cin >> N >> x;
    for (int i = 0; i < N; i++) cin >> a[i];

    sort(a, a + N);
    int counter = 0;
    for(int i = 0; i < N; i++){
        x -= a[i];
        if (x < 0) break;
        counter++;
    }
    if (x > 0) counter--;
    cout << counter << endl;
}


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

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

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define eprintf(...) 42
#define dump(x) 42
#define debug(x) 42
#endif

typedef long long ll;

int n, m, d;

double solve() {
    double beauty_per_element =
            d == 0 ? (1.0 / n) : (max(n - 2 * d, 0) * (2.0 / n) + min(2 * d, n) * (1.0 / n)) * (1.0 / n);
    return beauty_per_element * (m - 1);
}

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

    cin >> n >> m >> d;
    printf("%.8f\n", solve());
    return 0;
}


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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define ALL(x) (x).begin(), (x).end()
#define BIT(n) (1LL<<(n))
#define SZ(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;

void Main() {
  int H, W, N;
  scanf("%d%d%d", &H, &W, &N);

  map<pii, int> co;

  rep(i, N) {
    int y, x;
    scanf("%d%d", &y, &x);
    y--; x--;
    rep(dy, 3) rep(dx, 3) {
      int t = y - dy;
      int b = t + 2;
      int l = x - dx;
      int r = l + 2;
      if (t < 0 || b > H-1) continue;
      if (l < 0 || r > W-1) continue;
      co[{t, l}]++;
    }
  }

  vl ans(10);
  ll s = 0;
  forr(c, co) {
    ans[c.snd]++;
    s++;
  }

  ans[0] = 1LL * (H-2) * (W-2);
  ans[0] -= s;

  rep(i, 10) _p("%lld\n", ans[i]);
}
int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }


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

const int INF = 1<<28;

int N, M, X;
vector<int> C;
vector<vector<int> > A;

bool isOK(vector<int> &v) {
  for (int i = 0; i < v.size(); i++)
    if (v[i] < X)
      return false;
  return true;
}

int solve(int id, vector<int> &v) {
  if (id >= N && isOK(v))
    return 0;
  else if (id >= N)
    return INF;

  int a = solve(id+1, v);
  for (int i = 0; i < M; i++)
    v[i] += A[id][i];
  int b = solve(id+1, v) + C[id];
  for (int i = 0; i < M; i++)
    v[i] -= A[id][i];
  return min(a, b); 
}

int main(void) {
  cin >> N >> M >> X;
  C.resize(N);
  A.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> C[i];
    A[i].resize(M);
    for (int j = 0; j < M; j++)
      cin >> A[i][j];
  }
  vector<int> v(M);
  int res = solve(0, v);
  if (res == INF)
    cout << -1 << endl;
  else
    cout << res << endl;
}


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

#define REP(i,n) for(int i=1;i<=n;i++)

using namespace std;


int main()
{
    int n;
    cin>>n;
    int a[n];
    REP(i,n){
        cin>>a[i];
    }
    int ans=0;
    REP(i,n){
        if(i==a[a[i]]){
            ans++;
        }
    }
    ans/=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include <stdio.h>

int main() {
	char s[101];
	bool hav[26] = { 0 };
	int res = 100, size;
	scanf("%s", s);
	for (size = 0; s[size] != 0; size++)
		hav[s[size] - 'a'] |= true;
	for (char i = 'a'; i <= 'z'; i++) {
		if (!hav[i - 'a'])
			continue;
		int prev = -1, max = 0;
		for (int j = 0; j < size; j++) {
			if (s[j] != i)
				continue;
			max = std::max(max, j - prev - 1);
			prev = j;
		}
		max = std::max(max, size - prev - 1);
		res = std::min(res, max);
	}
	printf("%d\n", res);
}


Measured memory_bytes: 128
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  s = input()
  t = input()
  cnt = 0
  sl = len(s)
  for i in range(sl):
    s = s[sl-1] + s[:sl-1]
    if s == t:
      print('Yes')
      exit()
  print('No')
  
  
if __name__ == '__main__':
  main()

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

using namespace std;
int main() {
    int n;
    cin >> n;
    string s[n];
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    int c[n][30];
    for(int i = 0; i < 30; i++){
        for(int j = 0; j < n; j++){
            c[j][i] = 0;
        }
    }
    for(int yi = 0; yi < n; yi++){
        for(int xi = 0; xi < s[yi].length(); xi++){
            c[yi][s[yi][xi] - 'a']++;
        }
    }
    int tmp[30];
    for(int i = 0; i < 30; i++){
        tmp[i] = 0;
    }
    for(int xi = 0; xi < 30; xi++){
        int min = 100;
        for(int yi = 0; yi < n; yi++){
            if(min > c[yi][xi]) min = c[yi][xi];
        }
        tmp[xi] = min;
    }
    for(int i = 0; i < 30; i++) {
        for (int count = 0; count < tmp[i]; count++) {
            cout << (char)('a' + i);
        }
    }
    cout << endl;

}

Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 500000
ll MOD=1e9+7;

main(){
    int n=in();
    int a=n%100;
    int b=n/100;
    if(a<=12&&a){
        if(b<=12&&b)cout<<"AMBIGUOUS";
        else cout<<"YYMM";
    }
    else{
        if(b<=12&&b)cout<<"MMYY";
        else cout<<"NA";
    }
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2)*pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int jo(int n) {
	int ans = 1;
	rep(i, n) {
		ans *= 2;
	}
	return ans;
}

signed main() {
	int a=0;
	string s;
	cin >> s;
	rep(i, s.size()) {
		if (s[i] == '+')a++;
		else a--;
	}
	cout << a << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<ll> a(n);
    vector<int> s(n);
    REP(i,n) cin >> a[i];
    s[0] = a[0]%m;
    for (int i = 1; i < n; ++i) s[i] += ((s[i-1]+a[i])%m);
    sort(s.begin(), s.end());
    map<ll, ll> mp;
    ll ans = 0;
    REP(i,n) {
        if (s[i] == 0) ans++;
        mp[s[i]]++;
    }
    for (auto x: mp) ans += (x.second*(x.second-1))/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5376
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}


int main()
{
  int n;
  scanf("%d", &n);
  long l[n];
  int i;
  for (i = 0; i < n; i++)
    scanf("%ld", &l[i]);
  qsort(l, n, sizeof(long), compare_int);
  int sum = 0, ans = 0, j, k;
  for (i = 0; i < n - 2; i++)
  {
    if (i >= 1 && l[i] == l[i - 1])
      ans += sum;
    else
    {
      if (i >= 1)
        sum = 0;
      for (j = i + 1; j < n - 1; j++)
      {
        if (l[j] == l[i])
          continue;
        for (k = j + 1; k < n; k++)
        {
          if (l[k] == l[j])
            continue;
          if (l[i] + l[j] <= l[k] || l[i] + l[k] <= l[j] || l[j] + l[k] <= l[i])
            break;
          else
            sum++;
        }
      }
      ans += sum;
    }
  }
  printf("%d", ans);
}

Measured memory_bytes: 1704
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    a = list(A)
    m = 0
    xy = []
    apnd = xy.append
    if min(a) == max(a):
        print(0)
        return
    elif min(a) < 0 and max(a) >= 0:
        if abs(min(a)) > max(a):
            x = min(a)
        else:
            x = max(a)
        idx = a.index(x)
        for i, j in enumerate(a):
            if j != x:
                a[i] += x
                m += 1
                apnd((idx + 1, i + 1))

    if min(a) >= 0:
        for i in range(N - 1):
            a[i+1] += a[i]
            m += 1
            apnd((i + 1, i + 2))
    elif max(a) < 0:
        for i in range(N - 1, 0, -1):
            a[i-1] += a[i]
            m += 1
            apnd((i + 1, i))

    print(m)
    for x, y in xy:
        print(x, y)

main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<long long> A(n);
    vector<bool> counter(1000000002);
    for(int i = 0;i < n;i++){
        cin >> A.at(i);
        if(counter.at(A.at(i))){
            cout << "NO" << endl;
            return 0;
        }else {
            counter.at(A.at(i)) = true;
        }
    }cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 126744
/*ITP1_4_B:Circle*/
#include <iostream>
#include <math.h>
using namespace std;

int main() {
    double r,l,S;
    cin >> r;
    l=2.0*r*M_PI;
    S=r*r*M_PI;
    cout << fixed << S << " " << l << endl;
    return 0;
}


Measured memory_bytes: 3276
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int N = sc.nextInt();
			if(N==0)break;
			int a[] = new int[N];
			for(int i=0;i<N;i++){
				a[i]=sc.nextInt();
			}
			boolean t =false;
			for(int i = 0; i < a.length; i++) {
				if(i==0){
					System.out.print(a[i]);
				}else{
					if(a[i-1]+1==a[i]){
						t=true;
						continue;
					}else{
						if(t)System.out.print("-"+a[i-1]);
						System.out.print(" "+a[i]);
						t=false;
						continue;
					}
				}
			}
			if(t){
				System.out.print("-"+a[a.length-1]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 34480
import heapq as hq
x, y, z, k = map(int,input().split())
arr_a = sorted(list(map(int,input().split())) ,reverse = True)
arr_b = sorted(list(map(int,input().split())) ,reverse = True)
arr_c = sorted(list(map(int,input().split())) ,reverse = True)

cnt = set()
P_q = [[-(arr_a[0] + arr_b[0] + arr_c[0]),0,0,0]]

cnt.add((0,0,0))
for _ in range(k):
    tmp = hq.heappop(P_q)
    t, i, j, k = -tmp[0],tmp[1],tmp[2],tmp[3]
    print(t)
    if i + 1 < x and (i+1,j,k) not in cnt:
        hq.heappush(P_q,[-(arr_a[i+1] + arr_b[j] + arr_c[k]) ,i + 1,j,k])
        cnt.add((i+1,j,k))
    if j + 1 < y and (i,j+1,k) not in cnt:
        hq.heappush(P_q,[-(arr_a[i] + arr_b[j+1] + arr_c[k]) ,i ,j + 1,k])
        cnt.add((i,j+1,k))
    if k + 1 < z and (i,j,k+1) not in cnt:
        hq.heappush(P_q,[-(arr_a[i] + arr_b[j] + arr_c[k + 1]) ,i,j,k + 1])
        cnt.add((i,j,k+1))
        

Measured memory_bytes: 4976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	vector<vector<int> > to(n);
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
	
		to[a].push_back(b);
		to[b].push_back(a);
	}

	vector<bool> onecan(n,false);
	for(int i=0;i<to[0].size();i++)
		onecan[to[0][i]]=true;
	
	bool flag=false;

	for(int i=0;i<n;i++)
		if(onecan[i])
			for(int j=0;j<to[i].size();j++)
				if(to[i][j]==n-1)
					flag=true;
	cout << (flag ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	

	
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> X(N);
  rep(i, N) cin >> X[i];
  vector<ll> Xcopy(N);
  copy(all(X), begin(Xcopy));
  sort(all(Xcopy));
  ll m1 = Xcopy[N/2-1], m2 = Xcopy[N/2];
  rep(i, N) cout << (X[i]<m2 ? m2 : m1) << "\n";
  return 0;
}


Measured memory_bytes: 6344
N = int(input())
h = list(map(int, input().split()))

suml = [1e5 for i in range(N)]
suml[0] = 0
suml[1] = abs(h[1] - h[0])
 
#@profile
def netMain():
    for e in range(2, N):
        suml[e] = min(
            abs(h[e]-h[e-1]) + suml[e-1],
            abs(h[e]-h[e-2]) + suml[e-2],
        )
 
netMain()
print(suml[N-1])


Measured memory_bytes: 13976
#include <stdio.h>

int n,a,b,ans;

int digit_sum(int n){
    int res=0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

int main(){
    scanf("%d%d%d",&n,&a,&b);
    for(int i = 1;i <= n;i ++){
        int s = digit_sum(i);
        if(s>=a&&s<=b) ans += i;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vector<pair<int64_t, int64_t>> p(n);
    int64_t x;
    rep(i,n){
        cin >> x;
        p.at(i) = make_pair(x,i);
    }
    sort(p.begin(), p.end());
    vector<pair<int64_t,int64_t>> pres(n);
    rep(i,n){
        if(i<n/2){
            pres.at(i) = make_pair(p.at(i).second, p.at(n/2).first);
        }else{
            pres.at(i) = make_pair(p.at(i).second, p.at(n/2-1).first);
        }
    }
    sort(pres.begin(), pres.end());
    rep(i,n) cout << pres.at(i).second << endl;
}


Measured memory_bytes: 8448
/* 
 * Project: AtCoder Beginners Contest 143 A - Curtain
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/14
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

uint32_t a;
uint32_t b;

void solve() {

    if (a < 2*b)
        printf("0\n");
    else
        printf("%d\n", a-2*b);

}

int main() {

    scanf("%d", &a);
    scanf("%d", &b);

    solve();

}

Measured memory_bytes: 3220
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>


int main()
{
	std::string a, b;

	std::cin >> a >> b;

	if (a.length() > b.length()) std::cout << "GREATER" << std::endl;
	else if (a.length() < b.length()) std::cout << "LESS" << std::endl;
	else {
		if(a == b) std::cout << "EQUAL" << std::endl;
		else {
			for (int i = 0; i < a.length(); i++) {
				if (a[i] > b[i]) {
					std::cout << "GREATER" << std::endl;
					break;
				}
				else { 
					std::cout << "LESS" << std::endl; 
					break;
				}
			}
		}
	}

	return 0;
}

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

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

def solve(N: int, K: int, Q: int, A: "List[int]"):

    a = [0] * N
    for i in range(len(A)):
       a[A[i]-1] += 1

    for i in range(len(a)):
        if K + a[i] > Q:
            print(YES)
        else:
            print(NO)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 8644
#include <bits/stdc++.h>
using namespace std;
 
#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;

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

  int ans = A[0]-1;
  int now = 2;
  for ( int i = 1; i < N; i++ ) {    
    ans += (A[i]-1)/now;
    if ( A[i] == now ) now++;
    // cout << ans << " " << now << endl;
  }

  cout << ans << endl;

  return 0;
}


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

string s;
ll ans;

void func(ll t, ll sum, int c = 0)
{
  t *= 10;
  t += s[c] - '0';
  if (c == s.size() - 1)
  {
    ans += sum + t;
    return;
  }
  func(t, sum, c + 1);
  func(0, sum + t, c + 1);
  return;
}

int main()
{
  cin >> s;
  ans = 0;
  func(0, 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    h=h*60+m;
    double d=h/720.;
    double d2=m/60.;
    double px=a*sin(d*2*PI);
    double py=a*cos(d*2*PI);
    double qx=b*sin(d2*2*PI);
    double qy=b*cos(d2*2*PI);
    double ans = (px-qx)*(px-qx)+(py-qy)*(py-qy);
    fcout(15)<<sqrt(ans)<<endl;
    return 0;
}

Measured memory_bytes: 4120
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  vector<vector<int>> v(2,vector<int>(2,0));
  v[0][0] = a;
  v[0][1] = b;
  v[1][0] = c;
  v[1][1] = d;
  int turn = 0;
  while(v[0][0]>0 and v[1][0]>0){
    v[1-turn][0] -= v[turn][1];
    turn = 1- turn;
  }
  if(v[0][0]>0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl p(N);
  rep(i, N) cin >> p[i];

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

  ll ans = accumulate(p.begin(), p.end() - 1, 0LL);
  ans += p[N - 1] / 2;

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


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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int b1,b2,b3;

  cin>>b1>>b2>>b3;

  if(b1==1&&b2== 0 &&b3==0){
    cout<<"Close"<<endl;
  }else if(b1==0&&b2== 1 &&b3==0){
    cout<<"Close"<<endl;
  }else if(b1==1&&b2== 1 &&b3==0){
    cout<<"Open"<<endl;
  }else if(b1==0&&b2== 0 &&b3==1){
    cout<<"Open"<<endl;
  }else if(b1==0&&b2==0&&b3==0){
    cout<<"Close"<<endl;
  }

  
  return 0;

}



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

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

  long long n, ans=-1e15;
  cin >> n;
  vector<ll> a(3*n);
  for(int i=0;i<3*n;i++){
    cin >> a[i];
  }
  priority_queue<int, vector<int>, greater<int> > quemi;
  priority_queue<int> quema;
  vector<ll> zenhan(n+1, 0ll), kouhan(n+1, 0ll);
  for(int i=0;i<n;i++){
    zenhan[0]+=a[i];
    quemi.push(a[i]);
  }
  for(int i=2*n;i<3*n;i++){
    kouhan[n]+=a[i];
    quema.push(a[i]);
  }
  for(int i=n;i<2*n;i++){
    quemi.push(a[i]);
    zenhan[i-n+1] = zenhan[i-n]+a[i]-quemi.top();
    quemi.pop();
  }
  for(int i=2*n-1;i>=n;i--){
    quema.push(a[i]);
    kouhan[i-n] = kouhan[i-n+1]+a[i]-quema.top();
    quema.pop();
  }
  for(int i=0;i<n+1;i++){
    ans = max(ans, zenhan[i]-kouhan[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5368
using System;

namespace abc102A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int Ans;
            if (N % 2 == 1)
                Ans = 2 * N;
            else
                Ans = N;
            Console.WriteLine(Ans);
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int m[114];
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a > c) {
		swap(a, c);
		swap(b, d);
	}
	m[a]++;
	m[b]--;
	m[c]++;
	m[d]--;
	for (int i = 0; i < 101; i++) { m[i + 1] += m[i]; }
	int ans = 0;
	for (int i = 0; i < 105; i++)if(m[i]==2)ans++;
	cout << ans << endl;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL 998244353
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)

int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) {
        if (b & 1) res = (res * a) % m;
        a = (a * a) % m; b >>= 1;
    } return res;
}

int now() {
    return chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now()
    .time_since_epoch()).count();
}

int32_t main() { fastio;
    time_t start = now();
    int n; cin >> n;
    vector<pair<int, int>> arr(n);
    for (int i = 0; i < n; i++) {
        cin >> arr[i].first >> arr[i].second;
    }
    sort(arr.begin(), arr.end());
    arr.push_back({ INF, 0 });
    vector<int> dp(n + 1);
    dp[n] = 1;
    stack<int> robos;
    robos.push(n);
    for (int i = n - 1; i >= 0; i--) {
        dp[i] = dp[i + 1];
        int p;
        while (arr[robos.top()].first < (arr[i].first + arr[i].second)) {
            p = robos.top(); robos.pop();
        }
        p = robos.top();
        robos.push(i);
        dp[i] = (dp[i] + dp[p]) % HELL;
    }
    cout << dp[0] << endl;
    cerr << "TIME => " << now() - start << endl;
    return 0;
}

Measured memory_bytes: 8448
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 1e18
#define MOD 1000000007
#define PI 4*atan(1.0)
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=1005;
//int arr[SIZE]={};
//ここまでテンプレ
typedef double Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
 
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
 
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
int main(){
	cout<<setprecision(20);
	int sx,sy,gx,gy;
	cin>>sx>>sy>>gx>>gy;
	int N;
	cin>>N;
	int x[SIZE]={},y[SIZE]={},r[SIZE]={};
	for(int i=0;i<N;i++){
		scanf("%d%d%d",&x[i],&y[i],&r[i]);
	}
	x[N]=sx,y[N]=sy,r[N]=0;
	x[N+1]=gx,y[N+1]=gy,r[N+1]=0;
	Graph G;
	for(int i=0;i<N+2;i++){
		Edges E;
		G.push_back(E);
	}
	for(int i=0;i<N+2;i++)for(int j=0;j<N+2;j++){
		double cost=max(0.0,sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2))-(double)(r[i]+r[j]));
		G[i].push_back(Edge(i,j,cost));
	}
	vector<Weight> dis;
	vector<int> prev;
 
	shortestPath(G,N,dis,prev);
	cout<<dis[N+1]<<endl;
	return 0;
}

Measured memory_bytes: 21872
#include <iostream>
using namespace std;
char chess(int h,int w){
    if((h+w)%2==0){
        return '#';
    }
    return '.';
}
int main(void){
    while(1){
        int H, W;
        cin >> H >> W;   
        if (H==0&&W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0; j<W ;j++){
                cout << chess(i,j);
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

struct RURM {
	using t1 = int;
	using t2 = int;
	static t1 id1() { return INT_MAX; }
	static t2 id2() { return -1; }
	static t1 op1(const t1& l, const t1& r) { return min(l, r); }
	static t1 op2(const t1& l, const t2& r) { return r != id2() ? r : l; }
	static t2 op3(const t2& l, const t2& r) { return r != id2() ? r : l; }
};

template <typename M>
class LazySegmentTree {
	using T1 = typename M::t1;
	using T2 = typename M::t2;
	const int h, n;
	vector<T1> data;
	vector<T2> lazy;
	void push(int node) {
		if (lazy[node] == M::id2()) return;
		if (node < n) {
			lazy[node * 2] = M::op3(lazy[node * 2], lazy[node]);
			lazy[node * 2 + 1] = M::op3(lazy[node * 2 + 1], lazy[node]);
		}
		data[node] = M::op2(data[node], lazy[node]);
		lazy[node] = M::id2();
	}
public:
	LazySegmentTree(int n_)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {}
	LazySegmentTree(int n_, T1 v1, T2 v2)
		: h(ceil(log2(n_))), n(1 << h), data(n * 2, v1), lazy(n * 2, v2) {}
	LazySegmentTree(const vector<T1>& data_)
		: h(ceil(log2(data_.size()))), n(1 << h), data(n * 2, M::id1()), lazy(n * 2, M::id2()) {
		init(data_);
	}
	void init() {
		for (int i = n - 1; i >= 1; i--) data[i] = M::op1(data[i * 2], data[i * 2 + 1]);
	}
	void init(const vector<T1>& data_) {
		for (int i = 0; i < (int)data_.size(); i++) data[i + n] = data_[i];
		init();
	}
	void update(int l, int r, T2 val) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		int tl = l, tr = r;
		r++;
		while (l < r) {
			if (l & 1) lazy[l] = M::op3(lazy[l], val), l++;
			if (r & 1) r--, lazy[r] = M::op3(lazy[r], val);
			l /= 2; r /= 2;
		}
		while (tl > 1) {
			tl >>= 1, tr >>= 1;
			if (lazy[tl] == M::id2()) data[tl] = M::op1(M::op2(data[tl * 2], lazy[tl * 2]), M::op2(data[tl * 2 + 1], lazy[tl * 2 + 1]));
			if (lazy[tr] == M::id2()) data[tr] = M::op1(M::op2(data[tr * 2], lazy[tr * 2]), M::op2(data[tr * 2 + 1], lazy[tr * 2 + 1]));
		}
	}
	T1 find(int l, int r) {
		l += n, r += n;
		for (int i = h; i > 0; i--) push(l >> i), push(r >> i);
		r++;
		T1 res1 = M::id1(), res2 = M::id1();
		while (l < r) {
			if (l & 1) res1 = M::op1(res1, M::op2(data[l], lazy[l])), l++;
			if (r & 1) r--, res2 = M::op1(M::op2(data[r], lazy[r]), res2);
			l /= 2; r /= 2;
		}
		return M::op1(res1, res2);
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q, com, x, y, val;
	cin >> n >> q;
	LazySegmentTree<RURM> st(n);
	while (q--) {
		cin >> com >> x >> y;
		if (com) {
			printf("%d\n", st.find(x, y));
		}
		else {
			cin >> val;
			st.update(x, y, val);
		}
	}
	return 0;
}

Measured memory_bytes: 5136
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}


int main(void){
    int a,b,h; cin >> a >> b >> h;
	cout << 1.*(a+b)*h/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
using namespace std;


char cot[4]={'U','D','L','R'};

void output(int times,int bar){
    for(int i=0;i<times;i++) cout<< cot[bar];
}
int main(){

    int sx,tx,sy,ty;


    cin>>sx>>sy>>tx>>ty;

    int x = tx-sx, y = ty-sy ;

    output(y,0);
    output(x,3);
    output(y,1);
    output(x,2);

    output(1,2);
    output(y+1,0);
    output(x+1,3);
    output(1,1);

    output(1,3);
    output(y+1,1);
    output(x+1,2);
    output(1,0);


    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
char masu[50][50] = {{0}};
void saiki(int x,int y){
    masu[y][x] = '0';

    if(masu[y+1][x] == '1') saiki(x,y+1);
    if(masu[y-1][x] == '1') saiki(x,y-1);
    if(masu[y][x+1] == '1') saiki(x+1,y);
    if(masu[y][x-1] == '1') saiki(x-1,y);
}
int main(){
    while(1){
        int cnt = 0;
        for(int i = 0; i < 12; i++){
            if(scanf("%s",masu[i]) == EOF)goto a;
        }
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 12; j++){
                if(masu[i][j] == '1'){
                    saiki(j,i);
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    a:;
    return 0;
}

Measured memory_bytes: 1164