akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

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

        int c = 1;
        for (int i = 1; i < b-a; i++) {
            c = c + i+1;
        }

        System.out.println(c - b);
    }
}


Measured memory_bytes: 21844
import heapq
import math
import numpy as np

N, M = map(int, input().rstrip().split(' '))
products = map(float, input().rstrip().split(' '))
#products.sort()

h = []
for value in products:
	heapq.heappush(h, -value)

while(M > 0):
  heapq.heappush(h, heapq.heappop(h) / 2)  
  M -= 1
  #print(h)
  
sum = -sum(map(math.ceil, h))
print(sum)

Measured memory_bytes: 22444
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vector<pair<ll,ll>> a(N);
  rep(i,N){
    cin>>a[i].first;
    a[i].second=i+1;
  }
  sort(all(a));
  rep(i,N) cout<<a[i].second<<endl;
}

Measured memory_bytes: 4736
input_list = list(map(int, input().split()))
a = input_list[0]
b = input_list[1]
c = input_list[2]
d = input_list[3]

Alice_range = set(range(a,b))
Bob_range = set(range(c,d))
same_time = len(Alice_range & Bob_range)

print(same_time)


Measured memory_bytes: 3060
import collections
N,K = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
a = collections.Counter(A)

value = list(a.values()) #種類ごとの個数
value.sort()
n = len(value)  #最初の種類数

if n <= K:
  print(0)
  exit()

print(sum(value[:n-K]))

Measured memory_bytes: 116612
from collections import deque
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

h, w, K = na()
x1, y1, x2, y2 = na()
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1

bd = [ns() for _ in range(h)]

q = deque()
ds = [9999999999999999] * (h*w)

q.append((x1, y1))
ds[x1*w+y1] = 0
dr = (1, 0, -1, 0)
dc = (0, 1, 0, -1)
while len(q) > 0:
    r, c = q.popleft()
    for i in range(4):
        for j in range(1, K+1):
            nr, nc = r + dr[i] * j, c + dc[i] * j
            if 0 <= nr < h and 0 <= nc < w and bd[nr][nc] != "@":
                nd = ds[r*w+c] + 1
                if nd < ds[nr*w+nc]:
                    ds[nr*w+nc] = nd
                    q.append((nr, nc))
                elif nd <= ds[nr*w+nc]:
                    continue
                else:
                    break
            else:
                break
ans = ds[x2*w+y2]
if ans < 999999999999:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 96116
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007

/* add vars here */

ll N;

/* add your algorithm here */

int main() {
  cin >> N;
  if (N < 1200) {
    cout << "ABC" << endl;
  } else if (N < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }

  
}


Measured memory_bytes: 256
H,W = map(int,input().split())
class UnionFind:
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for _ in range(size)]

    # 集合の代表を求める
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 併合
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                # 小さいほうが個数が多い
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False


S = [input() for i in range(H)]
u = UnionFind(H*W)
d = [(-1,0),(1,0),(0,-1),(0,1)]
for x in range(H):
    for y in range(W):
        for dx,dy in d:
            if x+dx<0 or x+dx>=H or y+dy<0 or y+dy>=W:
                continue
            if S[x+dx][y+dy] == S[x][y]:
                continue
            u.union(x+H*y,x+dx+H*(y+dy))

from collections import defaultdict
d = defaultdict(lambda:[[],[]])

for x in range(H):
    for y in range(W):
        if S[x][y] == '#':
            d[u.find(x+H*y)][0].append((x,y))
        else:
            d[u.find(x+H*y)][1].append((x,y))

ans = 0
for key in d:
    ans += len(d[key][0])*len(d[key][1])
print(ans)

Measured memory_bytes: 62808
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <climits>
#include <functional>

#define REP(i,n) for(int i = 0;i < n;i++)
#define pyfor(j,s,n,i) for(int j = s;j < n;j += i)

using namespace std;
typedef long long ll;
const int INF = INT_MAX;

const int max_n = 100;
const int max_w = 10000;
int pack_hist[max_n + 1][max_w + 1];
int v_s[max_n];
int w_s[max_n];
int N, W;

int pack(int ni, int wl) {
  if (ni >= N) return 0;
  if (pack_hist[ni][wl] != -1) return pack_hist[ni][wl];
  int ans;
  if (wl >= w_s[ni]){
    ans = max(v_s[ni] + pack(ni + 1, wl - w_s[ni]), pack(ni + 1, wl));
  } else {
    ans = pack(ni + 1, wl);
  }
  pack_hist[ni][wl] = ans;
  // cerr << "pack(" << ni << " " << wl << "): " << ans << "\n";
  return ans;
}



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

  cin >> N >> W;

  REP(i, N) {
    cin >> v_s[i] >> w_s[i];
  }

  REP(i, N + 1) REP(j, W + 1) pack_hist[i][j] = -1;

  cout << pack(0, W) << "\n";
  return 0;
}

Measured memory_bytes: 7152
#include <cstdio>
#include <vector>
using namespace std;

int n;
int x[10000];

int main(){
	while(scanf("%d", &n),n){
		vector<int> tmp(n);
		vector<int> num(n);
		int t = 0;
		for(int i = 0; i < n; i++) scanf("%d", &num[i]);
		while(true){
			tmp = num;
			for(int i = 0; i < 1000; i++) x[i] = 0;
			for(int i = 0; i < n; i++) x[num[i]]++;
			for(int i = 0; i < n; i++) num[i] = x[num[i]];
			if(tmp == num){
				printf("%d\n%d", t, num[0]);
				for(int i = 1; i < n; i++) printf(" %d", num[i]);
				printf("\n");
				break;
			}
			t++;
		}
	}
}

Measured memory_bytes: 1076
using System;

class Program
{
    static void Main()
    {
        while (true)
        {
            string[] raw = Console.ReadLine().Split(' ');
            if(raw[0]=="0")break;
            int h = int.Parse(raw[0]);
            int w = int.Parse(raw[1]);
            for (int y = 0; y < h; y++)
            {
                for (int x = 0; x < w; x++)
                {
                    if ((x + y) % 2 == 1) Console.Write('.');
                    else Console.Write('#');
                }
                Console.WriteLine();
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 5296
#include <bits/stdc++.h>
#define ll long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
using namespace std;

void printV(vll v){
	cout << "size (" << v.size() << "): ";
	for(ll i = 0; i < v.size(); i++){
		cout << v[i] << " ";
	}
	cout << "\n";
}

void printM(vector<vll> v){
	cout << "size (" << v.size() << "," << v[0].size() << "): ";
	for(ll i = 0; i < v.size(); i++){
		for(ll j = 0; j < v[i].size(); j++){
			cout << v[i][j] << " ";
		}
		cout << "\n";
	}
}

/*
ll powermod(ll x, ll y){
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1){
			res = (res * x) % mod;
		}
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}

ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i){
			res = (res * i) % mod;
		}
		n /= mod;
	}
	res %= mod;
	return res;
}
*/

void solve(){
	ll n, d, x, y, dist;
	long long count = 0;
	cin >> n >> d;
	for(long long i = 0; i < n; i++){
		cin >> x >> y;
		dist = sqrt(x * x + y * y);
		if(dist <= d) count++;
	}
	cout << count <<"\n";
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll t = 1;
//	cin >> t;
	while (t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define LL long long
#define LD long double
#define VI vector<int>
#define VPII vector<PII>
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define FOR(a,s,d) for (int a = (s); a <= (int)(d); ++a)
#define FORD(a,s,d) for (int a = (s); a >= (int)(d); --a)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(x) x.begin(), x.end()
#define siz(x) ((int)x.size())
#define Sim template <class s
Sim, class d> ostream & operator<<(ostream &os, pair<s,d> x){return os << "<" << x.f << ", " <<
  x.s << "> ";}
Sim> auto operator<<(ostream &os, s x) -> typename enable_if<!is_same<s,string>::value,
  decltype(x.begin(), os)>::type
{ int o = 0; os << "{"; for (auto c : x) {if(o++) os << ", "; os << c;}return os << "} ";}
void dor() {cerr << endl;}
Sim, class ...t> void dor(s x, t...y) {cerr << x << " "; dor(y...);}
#ifdef DEB
#define debug(c...) dor(__FUNCTION__, ":", __LINE__, ": ", c)
#else
#define debug(...)
#endif

int n, mini = 2e9;
LL sum;
bool eq = true;

int main()
{
  //ios_base::sync_with_stdio(0);
  //cin.tie(0);
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a != b)
    {
      eq = false;
    }
    if (a > b)
    {
      mini = min(mini, b);
    }
    sum += a;
  }
  if (eq)
  {
    printf("0\n");
  }
  else
  {
    printf("%lld\n", sum - mini);
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {

  static long n, k;

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] in = br.readLine().split(" ");
    n = Long.parseLong(in[0]);
    k = Long.parseLong(in[1]);

    br.close();

    long ans = Math.min(n, k - n);

    if(n >= k){
      ans = Math.min(n%k, k - n%k);
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21332
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <set>

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

using namespace std;

const int INF = 1 << 30;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 80;

int A[N][N], B[N][N];
bool dp[N+1][N+1][2*N*N+1];

int main() {
	int h, w; cin >> h >> w;
	rep(i, h) rep(j, w) cin >> A[i][j];
	int diff_max = 0;
	rep(i, h) { rep(j, w) {
		cin >> B[i][j];
		diff_max = max(diff_max, abs(A[i][j]-B[i][j]));
	} }
	int sum_max = (h+w)*diff_max;
	rep(i, h) rep(j, w) rep(k, sum_max+1) dp[i][j][k] = false;

	dp[1][1][abs(A[0][0]-B[0][0])] = true;
	rep(i, h) { rep(j, w) {
		if (i == 0 && j == 0) continue;
		int diff_ab = abs(A[i][j]-B[i][j]);
		rep(k, sum_max+1) {
			dp[i+1][j+1][k] = dp[i][j+1][abs(k-diff_ab)] || dp[i+1][j][abs(k-diff_ab)];
			if (k+diff_ab<=sum_max && (dp[i][j+1][k+diff_ab] || dp[i+1][j][k+diff_ab]))
				dp[i+1][j+1][k] = true;
		}
	} }
	int ans = 0;
	rep(i, sum_max+1) {
		if (dp[h][w][i]) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 82304
#include <vector>
#include <iostream>
#include <utility>
#include <bitset>
using namespace std;

int dp[1 << 18][10];
int main() {
  int N;
  while(cin >> N) {
    vector< pair<int, int> > dominoes(N);
    for(int i=0; i<N; i++) {
      int val; cin >> val;
      int A = val / 10, B = val % 10;
      dominoes[i] = make_pair(A, B);
    }

    fill(dp[0], dp[1 << N], false);
    dp[0][0] = true;
    for(int bit=0; bit<(1<<N); bit++) {
      for(int pre=0; pre<10; pre++) {
        if(dp[bit][pre] == false) continue;
        for(int i=0; i<N; i++) {
          if(bit >> i & 1) continue;

          for(int k=0; k<2; k++) {
            if(bit != 0 and pre != dominoes[i].first) {
              swap(dominoes[i].first, dominoes[i].second);
              continue;
            }

            int nbit = bit | (1 << i);
            int npre = dominoes[i].second;
            dp[nbit][npre] |= dp[bit][pre];
            swap(dominoes[i].first, dominoes[i].second);
          }
        }
      }
    }

    /*
    for(int bit=0; bit<(1<<N); bit++) {
      bool ok = false;
      for(int pre=0; pre<10; pre++) {
        ok |= dp[bit][pre];
      }
      if(ok) {
        cout << bitset<10>(bit).to_string();
        cout << ":";
        for(int pre=0; pre<10; pre++) {
          if(dp[bit][pre]) cout << " " << pre;
        }
        cout << endl;
      }
    }
    */

    bool ans = false;
    for(int i=0; i<10; i++) ans |= dp[(1<<N)-1][i];
    cout << (ans ? "Yes" : "No") << endl;
  }
  return 0;
}



Measured memory_bytes: 13256
#include <iostream>
#include <string>
using namespace std;
 
int main(){
  string x;
  int i, sum;
   
  while(1){
      sum=0;
      cin >> x;
       
      if(x == "0")
    break;
 
      for(i=0; i<(int)x.size(); i++)
    sum += (int)x[i]-'0';
 
      cout << sum << endl;
 
    }
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int V=170,E=500,N=85;
struct graph{
	struct edge{int to,next;ll w;int f;}e[E<<1];
	int h[V],xb,n;
	inline void addedge(int x,int y,ll w,int f){
		e[++xb]=(edge){y,h[x],w,f};h[x]=xb;
		e[++xb]=(edge){x,h[y],-w,0};h[y]=xb;
	}
	inline pair<int,ll>mcmf(int S,int T){
		static int q[V],mi[V],lv[V],le[V];static bool inq[V];static ll d[V];
		int t,w,ans1=0,u,i;ll ans2=0;
		for(;;){
			memset(inq+1,0,n);inq[S]=1;
			for(i=1;i<=n;++i)d[i]=-(1ll<<60);d[S]=0;
			t=0;w=1;q[1]=S;mi[S]=1<<30;
			for(;t!=w;){
				inq[u=q[t=t==n?1:t+1]]=0;
				for(int i=h[u];i;i=e[i].next)if(e[i].f && d[e[i].to]<d[u]+e[i].w){
					d[e[i].to]=d[u]+e[i].w;
					mi[e[i].to]=min(mi[u],e[i].f);
					lv[e[i].to]=u;le[e[i].to]=i;
					if(!inq[e[i].to])inq[q[w=w==n?1:w+1]=e[i].to]=1;
				}
			}
			if(d[T]==-(1ll<<60))return make_pair(ans1,ans2);
			ans1+=mi[T];
			for(u=T;u!=S;u=lv[u]){
				ans2+=mi[T]*e[le[u]].w;
				e[le[u]].f-=mi[T];
				e[le[u]^1].f+=mi[T];
			}
		}
	}
};
struct G2{
struct edge{int fr,to,lo,hi;ll w;}e[E];
int n,xb,id[V],in[V];
graph g;
inline void add(int u,int v,int l,int r,ll w){e[++xb]=(edge){u,v,l,r,w};}
inline ll mcmf(){
	int i;
	memset(in+1,0,n<<2);for(i=1;i<=xb;++i)in[e[i].to]+=e[i].lo,in[e[i].fr]-=e[i].lo;
	g.xb=1;g.n=n+2;memset(g.h+1,0,g.n<<2);memset(id+1,0,n<<2);
	for(i=1;i<=n;++i){
		if(in[i]<0)g.addedge(i,n+2,0,-in[i]),id[i]=g.xb-1;
		if(in[i]>0)g.addedge(n+1,i,0,in[i]),id[i]=g.xb-1;
	}
	for(i=1;i<=xb;++i){
		if(e[i].hi>e[i].lo)g.addedge(e[i].fr,e[i].to,e[i].w,e[i].hi-e[i].lo);
		if(e[i].hi<e[i].lo)return 0;
	}
	ll ret=g.mcmf(n+1,n+2).second;
	for(i=1;i<=n;++i)if(g.e[id[i]].f)
		return 0;
//cerr<<ret<<' '<<endl;
	return ret;
}
}g;
int n,x[N],y[N],i,j,a,b,xx[N],yy[N],xxb,yxb,m,mn,v1[N],v2[N],v3[N],v4[N];
ll v[N],ans;
char op[9];
int main(){
//	freopen("1","r",stdin);
	scanf("%d",&n);mn=n;
	for(i=1;i<=n;++i)scanf("%d%d%lld",x+i,y+i,v+i),xx[++xxb]=x[i],yy[++yxb]=y[i];
	sort(xx+1,xx+xxb+1);xxb=unique(xx+1,xx+xxb+1)-xx-1;
	sort(yy+1,yy+yxb+1);yxb=unique(yy+1,yy+yxb+1)-yy-1;
	for(i=1;i<=n;++i)x[i]=lower_bound(xx+1,xx+xxb+1,x[i])-xx,y[i]=lower_bound(yy+1,yy+yxb+1,y[i])-yy;
	for(i=1;i<=xxb;++i)v1[i]=v2[i]=n;for(i=1;i<=yxb;++i)v3[i]=v4[i]=n;
	scanf("%d",&m);
	for(i=1;i<=m;++i){
		scanf("%s%d%d",op,&a,&b);
		if(*op=='L'){
			a=upper_bound(xx+1,xx+xxb+1,a)-xx-1;
			if(1<=a && a<xxb)v1[a]=min(v1[a],b);
			if(a==xxb)
mn=min(b,mn);
		}
		if(*op=='R'){
			a=lower_bound(xx+1,xx+xxb+1,a)-xx;
			if(1<a && a<=xxb)v2[a]=min(v2[a],b);
			if(a==1)
mn=min(b,mn);
		}
		if(*op=='D'){
			a=upper_bound(yy+1,yy+yxb+1,a)-yy-1;
			if(1<=a && a<yxb)v3[a]=min(v3[a],b);
			if(a==yxb)
mn=min(b,mn);
		}
		if(*op=='U'){
			a=lower_bound(yy+1,yy+yxb+1,a)-yy;
			if(1<a && a<=yxb)v4[a]=min(v4[a],b);
			if(a==1)
mn=min(b,mn);
		}
	}
	g.n=xxb+yxb;
	for(i=1;i<=mn;++i){
		g.xb=0;
		for(j=1;j<xxb;++j)g.add(j,j+1,max(0,i-v1[j]),v2[j+1],0);
		for(j=1;j<yxb;++j)g.add(xxb+j,xxb+j+1,max(0,i-v4[j+1]),v3[j],0);
		for(j=1;j<=n;++j)g.add(x[j],y[j]+xxb,0,1,v[j]);
		g.add(g.n,1,i,i,0);
//cerr<<i<<endl;
		ans=max(ans,g.mcmf());
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int balls,colors;
  char str[16];
  
  fgets(str,sizeof(str),stdin);
  sscanf(str,"%d %d",&balls,&colors);
  
  int ans = colors;
  
  for(int i=0;i<balls-1;i++)
  {
    ans *= (colors-1);
  }
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int H, W;
char table[60][60];
int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    cin >> H >> W;
    REP(i, H) {
        REP(j, W) { cin >> table[i][j]; }
    }

    REP(i, H) {
        REP(j, W) {
            bool flag = true;
            if (table[i][j] == '#') {
                flag = false;
                vector<int> dx = {1, -1, 0, 0};
                vector<int> dy = {0, 0, 1, -1};
                REP(k, 4) {
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if (0 <= x && x < H && 0 <= y && y < W && table[x][y] == '#') {
                        flag = true;
                        break;
                    }
                }
            }
            // cout << i << " " << j << endl;
            if (!flag) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
class LazySegmentTree():
    def __init__(self,n,init,merge_func=min,ide_ele=10**18):
        self.n=(n-1).bit_length()
        self.merge_func=merge_func
        self.ide_ele=ide_ele
        self.data=[0 for i in range(1<<(self.n+1))]
        self.lazy=[0 for i in range(1<<(self.n+1))]
        for i in range(n):
            self.data[2**self.n+i]=init[i]
        for i in range(2**self.n-1,0,-1):
            self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])

    def propagate_above(self,i):
        m=i.bit_length()-1
        for bit in range(m,0,-1):
            v=i>>bit
            add=self.lazy[v]
            self.lazy[v]=0
            self.data[2*v]+=add
            self.data[2*v+1]+=add
            self.lazy[2*v]+=add
            self.lazy[2*v+1]+=add

    def remerge_above(self,i):
        while i:
            i>>=1
            self.data[i]=self.merge_func(self.data[2*i],self.data[2*i+1])+self.lazy[i]

    def update(self,l,r,x):
        l+=1<<self.n
        r+=1<<self.n
        l0=l//(l&-l)
        r0=r//(r&-r)-1
        while l<r:
            self.data[l]+=x*(l&1)
            self.lazy[l]+=x*(l&1)
            l+=(l&1)
            self.data[r-1]+=x*(r&1)
            self.lazy[r-1]+=x*(r&1)
            l>>=1
            r>>=1
        self.remerge_above(l0)
        self.remerge_above(r0)

    def query(self,l,r):
        l+=1<<self.n
        r+=1<<self.n
        l0=l//(l&-l)
        r0=r//(r&-r)-1
        self.propagate_above(l0)
        self.propagate_above(r0)
        res=self.ide_ele
        while l<r:
            if l&1:
                res=self.merge_func(res,self.data[l])
                l+=1
            if r&1:
                res=self.merge_func(res,self.data[r-1])
            l>>=1
            r>>=1
        return res

import sys

input=sys.stdin.readline

N,M=map(int,input().split())
interval=[[] for i in range(N)]
for i in range(M):
    l,r,a=map(int,input().split())
    interval[l-1].append((r-1,a))

init=[0]*N
LST=LazySegmentTree(N,init,merge_func=min,ide_ele=10**18)

Max=[0]*N
for i in range(N-1,-1,-1):
    for r,a in interval[i]:
        LST.update(i,r+1,-a)
    Max[i]=max(-LST.query(0,N),0)
    if i:
        LST.update(i-1,i,-Max[i])

print(Max[0])


Measured memory_bytes: 176228
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
a = []

for i in range(n):
  s,p = nn()
  a.append([s,-int(p),i])

a = sorted(a)

for j in a:
  print(j[2]+1)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine().replace(" ", ""));
    if(Math.sqrt(n) == Math.floor(Math.sqrt(n))){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N + 1);
  for (int i = 1; i < N + 1; i++) cin >> A.at(i);

  sort(A.rbegin(), A.rend());

  int ans = 0;
  for (int i = 1, cnt = 1; i < N + 1; i++) {
    if (A.at(i - 1) == A.at(i)) cnt++;
    else {
      if (cnt % 2 == 1) ans++;
      cnt = 1;
    }
  }

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

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int n;
	scanf("%d", &n);
	long* p = new long[n];
	for (int i = 0; i < n; i++) {
		scanf("%ld", &(p[i]));
	}
	long* a = new long[n];
	long* b = new long[n];
	for (int i = 0; i < n; i++) {
		a[i] = i + 1;
		b[i] = 1000000000 - i;
	}
	for (int i = 0; i < n; i++) {
		for (int j = p[i] - 1; j < n; j++) {
			a[j] += i;
			if (j != p[i] - 1)b[j] -= i;
		}
	}
	for (int i = 0; i < n; i++) {
		printf("%ld ", a[i]);
	}
	printf("\n");
	for (int i = 0; i < n; i++) {
		printf("%ld ", b[i]);
	}
	printf("\n");
}


Measured memory_bytes: 1152
#include<vector>
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

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

li lcm(li a,li b) {return (a/gcd(a,b)*b);}

li lcm(vector<li>& v){
  li ret=1;
  for(li x: v){
    ret=lcm(ret,x);
  }
  return ret;
}

int ord(li a){
  int i=0;
  while(a%2==0){
    i++;
    a/=2;
  }
  return i;
}

int same_ord(vector<li>& v){
  int od=ord(v.at(0));
  for(li x: v){
    if(od!=ord(x))return 0;
  }
  return 1;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n,m; cin >>n >>m;
  vector<li> a(n);
  for(li& x: a) cin >>x;
  if(not same_ord(a)){
    cout << 0;
    return 0;
  }
  li l=lcm(a);l/=2;
  l=m/l;
  l=(l+1)/2;
  cout << l;
}

/// confirm df==0 ///


Measured memory_bytes: 1024
#include <iostream>
#include <fstream> 
#include <iomanip>
#include <cstdio> 
#include <vector>
#include <string>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <deque>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
const LL INF = (1LL << 60) - 1;
const LL MOD = 1e9 + 7;
const LL N = 200005;
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    string s;
    cin >> s;
    cout << s << (s.back() == 's' ? "es" : "s") << endl;
}

Measured memory_bytes: 3604
// 2013/09/17 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int p_max = -1;
		int d_max = -1;
		for(int i=0; i<n; i++){
			int p, d1, d2;
			cin >> p >> d1 >> d2;

			int d = d1+d2;

			if(d>d_max){
				p_max = p;
				d_max = d;
			}
		}

		cout << p_max << ' ' << d_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
LL x,y;
int main() {
	scanf("%lld%lld",&x,&y);
	int cnt=0;
	while (x<=y) {
		cnt++;
		x*=2;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using namespace std;

// long long gcd(long long a, long long b){
//     if (a < b){
//         a ^= b;
//         b ^= a;
//         a ^= b;
//     }
//     return b ? gcd(b, a % b) : a;
// }

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

int main(){
    char s[101],t[101];
    cin >> s >> t;
    rep(i,strlen(s)){
        for(int j=i+1;j<strlen(s);j++){
            if(s[i] > s[j]){
                char tmp = s[i];
                s[i] = s[j];
                s[j] = tmp;
            }
        }
    }
    rep(i,strlen(t)){
        for(int j=i+1;j<strlen(t);j++){
            if(t[i] < t[j]){
                char tmp = t[i];
                t[i] = t[j];
                t[j] = tmp;
            }
        }
    }
    
    // if(strlen(s) < strlen(t)){
    //     rep(i,strlen(s)){
    //         if(s[i] > t[i]){
    //             cout << "No" << endl;
    //             return 0;
    //         }else if(s[i] < t[i]){
    //             cout << "Yes" << endl;
    //             return 0;
    //         }
    //     }
    //     cout << "Yes" << endl;
    // }else{
    //     rep(i,strlen(t)){
    //         if(s[i] < t[i]){
    //             cout << "Yes" << endl;
    //             return 0;
    //         }else if(s[i] > t[i]){
    //             cout << "No" << endl;
    //             return 0;
    //         }
    //     }
    //     cout << "No" << endl;
    // }
    if(strcmp(s,t) < 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}

int fast_pow(int x, int st)
{
    if (st == 0)
        return 1;
    if (st % 2)
        return x * fast_pow(x, st - 1) % P;
    return fast_pow(x * x % P, st / 2);
}

signed main()
{
    hello();
    
    int k;
    cin >> k;
    string s;
    cin >> s;
    int res = 0;
    int n = s.size();
    vector <int> fact(n + k + 1);
    fact[0] = 1;
    for (int i = 1; i <= n + k; ++i)
        fact[i] = fact[i - 1] * i % P;

    for (int i = 0; i <= k; ++i)
    {
        int suff = fast_pow(26, i);
        int cnk = fact[n + k - i - 1] * fast_pow(fact[n - 1], P - 2) % P * fast_pow(fact[k - i], P - 2) % P;
        res += fast_pow(25, k - i) * suff % P * cnk % P;
        res %= P;
        // cout << res << endl;
    }
    cout << res << endl;
}

Measured memory_bytes: 19816
#include<bits/stdc++.h>
using namespace std;
int main(){
  string str;cin>>str;
  int num=0;
  int size=str.size();
  vector<string>s;
  vector<int>kiroku;
  vector<int>ans(size,0);
  while(num<size){
    string tmp;
    int flag=0;
    while(1){
      if(num==size){
        s.push_back(tmp);
        break;
      }
      if(str.at(num)=='R'&&flag==0){
        tmp.push_back(str.at(num));
        num++;
      }
      else if(str.at(num)=='L'&&flag==0){
        tmp.push_back(str.at(num));
        kiroku.push_back(num);
        num++;
        flag=1;
      }
      else if(str.at(num)=='L'&&flag==1){
        tmp.push_back(str.at(num));
        num++;
        flag=1;
      }
      else if(str.at(num)=='R'&&flag==1){
        s.push_back(tmp);
        flag=0;
        break;
      }
    }
  }
  int s_size=s.size();
  int sizetmp=0;
  for(int i=0;i<s_size;i++){
    int roopsize=s.at(i).size();
    for(int j=0;j<roopsize;j++){
      int jj=j+sizetmp;
      if(jj==kiroku.at(i)){
        ans.at(jj)=(kiroku.at(i)-sizetmp)/2+(roopsize+sizetmp-1-kiroku.at(i))/2+1;
      }
      else if(jj==(kiroku.at(i)-1)){
        ans.at(jj)=(kiroku.at(i)-1-sizetmp)/2+(roopsize+sizetmp-1-kiroku.at(i)+1)/2+1;
      }
      if(j==roopsize-1)sizetmp+=roopsize;
    }
  }
  for(int i=0;i<size;i++){
    cout <<ans.at(i)<<endl;
  }
}

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

using namespace std;
int main(void) {
    string in;
    cin >> in;
    int last = -1;
    unsigned int count = 0;
    unsigned int max = 0;
    for (s : in) {
        if (last == -1) {
            last = s;
            continue;
        }
        if (last == s) {
            count++;
            continue;
        }
        if (max < count) {
            max = count;
        }
            count = 0;
            last = s;
    }
    if (max < count) {
        max = count;
    }


    if (max > 1 )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import product
n,m = list(map(int,input().split()))
f = [[] for _ in range(8)]
for _ in range(n):
    a,b,c = list(map(int,input().split()))
    i = 0
    for p in product('+-', repeat=3):
        s = '{}{}{}{}{}{}'.format(p[0], a, p[1], b, p[2], c)
        f[i].append(eval(s))
        i += 1
ans = -float('inf')
if m == 0:
    print(0)
else:
    for i in range(8):
        ans = max(ans, sum(sorted(f[i])[-m:]))
    print(ans)


Measured memory_bytes: 3496
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 998244353;

int main() {
    int N,i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}

Measured memory_bytes: 256
N = int(input())
W = []
flag = True
for i in range(N):
    w = input()
    W.append(w)
if(len(set(W)) != N):
    print("No")
else:
    for i in range(1, N):
        if(W[i][0] != W[i-1][-1]):
            flag = False
    if(flag):
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#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>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b,c;
    cin >> a >> b >> c;
    if(b>=c)cout << "delicious";
    else if(a+1 <= -b+c)cout << "dangerous"; else cout << "safe";
    cout << "\n";
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

Measured memory_bytes: 256
//Author : Sukarna Paul

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/detail/standard_policies.hpp>
#define pi acos(-1)
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define MAX 300005
#define INF 0x3f3f3f3f
template <class T> inline T bigmod(T p,T e,T M){ll ret = 1LL;for(; e > 0LL; e >>= 1LL){if(e & 1LL) ret = (ret * p) % M;p = (p * p) % M;}return (T)ret;}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}   // M is prime}

using namespace std;
using namespace __gnu_pbds;

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update>pref_trie;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;




int main(){
    IOS
    //freopen("output.txt","w",stdout);
    ll a,b,c,k;
    cin>>a>>b>>c>>k;

    ll ans = min(k,a);
    k-=min(k,a);
    if(k==0){
        cout<<ans<<"\n";
        return 0;
    }

    k-=min(k,b);
    if(k==0){
        cout<<ans<<"\n";
        return 0;
    }
    ans-=min(k,c);
    k-=min(k,c);
    cout<<ans<<"\n";
}


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

// GCD, LCM
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
int main()
{
    int A,B,C,temp=0,ans=0;
    cin>>A>>B>>C;

    while(1){
        ans++;
        temp+=A;
        if(ans%7==0)temp+=B;
        if(temp>=C)break;
    }

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


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
using pii = pair<int, int>;

constexpr int INF = 1e9;

void erase(int p, int ch, vector<set<int>>& par, vector<set<int>>& child, set<int>& upset) {
    queue<pii> que;
    que.push(make_pair(p, ch));
    while(!que.empty()) {
        int pp = que.front().first;
        int c = que.front().second;
        que.pop();
        par[c].erase(pp);
        child[pp].erase(c);
        if(par[c].empty() && upset.count(c) == 0) {
            upset.insert(c);
            for(auto& cc : child[c]) {
                que.push(make_pair(c, cc));
            }
        }
    }
}

int main() {
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<vector<int>> g(N);
    vector<pii> es(M);
    for(int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        es[i].first = u;
        es[i].second = v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<int> d(N, INF);
    vector<set<int>> par(N);
    vector<set<int>> child(N);
    queue<pii> que;
    que.push(make_pair(0, 0));
    d[0] = 0;
    while(!que.empty()) {
        int v = que.front().first;
        int cost = que.front().second;
        que.pop();
        for(auto to : g[v]) {
            if(d[to] >= cost + 1) {
                child[v].insert(to);
                par[to].insert(v);
            }
            if(d[to] > cost + 1) {
                d[to] = cost + 1;
                que.push(make_pair(to, d[to]));
            }
        }
    }

    set<int> upset;
    while(Q--) {
        int r;
        cin >> r;
        r--;
        int p = es[r].first, c = es[r].second;
        if(d[p] + 1 != d[c]) {
            swap(p, c);
        }
        if(d[p] + 1 == d[c]) {
            erase(p, c, par, child, upset);
        }
        cout << upset.size() << endl;
    }
}


Measured memory_bytes: 37284
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
bool judge(vector<int> const& h,int a,int b,int n,int k){
    bool res=true;
    int all=b*k;
    int cnt=0;
    rep(i,n){
        if(h[i]-all<=0)continue;
        else{
            cnt+=(h[i]-all-1)/(a-b)+1;
        }
    }
    return cnt<=k;
}
signed main(){
  int n,a,b;cin>>n>>a>>b;
  vector<int> h(n);
  rep(i,n){
      cin>>h[i];
  }
  int d=0;int u=inf;
  while(u-d>1){
      int mid=(u+d)/2;
      if(judge(h,a,b,n,mid)){
          u=mid;
      }
      else d=mid;
  }
  cout<<u<<endl;
  return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n), f(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> f[i];

    sort(a.rbegin(), a.rend());
    sort(f.begin(), f.end());
    ll l = -1, r = 1e12;
    while (r - l > 1) {
        ll mid = (l + r) / 2;
        ll c = k;
        for (int i = 0; i < n; i++)
            c -= max(a[i] - mid/f[i], (ll)0);

        if (c >= 0)
            r = mid;
        else
            l = mid;
    }
    
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
long long a, b, n;
void bs(long long l, long long m){
    if(((l + m) / 2) * ((l + m) / 2) == n)
        cout << "Yes" << endl;
    else if(m - l <= 1)
        cout << "No" << endl;
    else if(((l + m) / 2) * ((l + m) / 2) > n){
        bs(l, (l + m) / 2);
    }
    else {
        bs((l + m) / 2, m);
    }
}
void solve(){
    cin >> a >> b;
    if(b < 10)
        n = a * 10 + b;
    else if(b < 100)
        n = a * 100 + b;
    else n = a *1000 + b;
    bs(1, n);
}
int main(){
    solve();
    return 0;
}


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

YES = "Yes"  
NO = "No"  

S = input()
T = input()

if len(T) != len(S) + 1:
    print(NO)
    sys.exit()

if S != T[0:len(S)]:
    print(NO)
    sys.exit()

print(YES)

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

template <typename T> inline void rd(T& x) {
	int si = 1; char c = getchar(); x = 0;
	while(!isdigit(c)) si = c == '-' ? -1 : si, c = getchar();
	while(isdigit(c)) x = x * 10 + c - 48, c = getchar();
	x *= si;
}
template <typename T, typename... Args>
inline void rd(T& x, Args&... args) { rd(x); rd(args...); }

#define fi first
#define se second

typedef long long ll;
typedef double ff;
typedef std::pair<int, int> pii;

const int kN = 1e5 + 5;

ll a[kN], s[kN], tot = 0; int n, k;

int main() {
	rd(n, k);
	for(int i = 1; i <= n; ++i)
		rd(a[i]), s[i] = s[i - 1] + a[i] * (a[i] < 0), tot += a[i] * (a[i] > 0);
	ll ans = 0;
	for(int i = k; i <= n; ++i) {
		ans = std::max(ans, tot + (s[i] - s[i - k]));
	}
	for(int i = 1; i <= n; ++i)
		s[i] = s[i - 1] + a[i] * (a[i] > 0);
	for(int i = k; i <= n; ++i) {
		ans = std::max(ans, tot - (s[i] - s[i - k]));
	}
	printf("%lld", ans);
	return 0;
}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var x = long.Parse(Console.ReadLine());
            var d = 0L;

            for (var i = 1; i <= x; i++)
            {
                var a = d + i;
                if (i == x || a >= x)
                {
                    Console.WriteLine(i);
                    return;
                }
                d = a;
            }
        }
    }
}


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

typedef long long ll;

ll gcd(ll a, ll b){
	return b == 0 ? a : gcd(b, a % b);
} 
int main()
{
	ll k, n;
	scanf("%lld%lld", &n, &k);
	n %= k;
	ll res = min(n, k - n);
	printf("%lld\n", res);
	return 0;
}

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

using namespace std;

typedef long long li;

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

    vector<li> xs(n);
    for (int i = 0; i < n; ++i) {
        cin >> xs[i];
    }

    li fr = 0, to = 0, ans = 0, xsum = 0, asum = 0;
    while (fr < n) {
        if (to == fr || (xsum == asum && to < n)) {
            xsum ^= xs[to];
            asum += xs[to];
            to++;
        } else {
            if (xsum == asum) {
                ans++;
            }
            xsum ^= xs[fr];
            asum -= xs[fr];
            ans += to - fr - 1;
            fr++;
        }
    }

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

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[][] A = new int[N][N];
            for (int i = 0; i < N; i++) {
                String line = in.next();
                for (int j = 0; j < N; j++) {
                    A[i][j] = line.charAt(j) == '.' ? 0 : 1;
                }
            }
            int[][] B = new int[M][M];
            for (int i = 0; i < M; i++) {
                String line = in.next();
                for (int j = 0; j < M; j++) {
                    B[i][j] = line.charAt(j) == '.' ? 0 : 1;
                }
            }

            for (int r = 0; r + M <= N; r++) {
                for (int c = 0; c + M <= N; c++) {

                    boolean match = true;
                    drLoop: for (int dr = 0; dr < M; dr++) {
                        for (int dc = 0; dc < M; dc++) {
                            if (B[dr][dc] != A[r + dr][c + dc]) {
                                match = false;
                                break drLoop;
                            }
                        }
                    }

                    if (match) {
                        System.out.println("Yes");
                        return;
                    }

                }
            }
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 27504
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[99];
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	rep(i,0,n)scanf("%lld",a+i);
	sortdown(a,n);
	ll ans=0;
	rep(i,0,k)ans+=a[i];
	printf("%lld",ans);
}

Measured memory_bytes: 128
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  char a;
  cin >> a;

  if ('a' <= a && a <= 'z')
    cout << 'a' << endl;
  else
    cout << 'A' << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	int Q;
	cin >> Q;
	while(Q--){
		ll n;
		cin >> n;
		set<ll> passed;
		int step = 0;
		while(n >= 10){
			ll next = 0, lower = 0, dig = 1;
			while(n > 0){
				lower = lower + (n % 10) * dig;
				n /= 10;
				next = max(next, lower * n);
				dig *= 10;
			}
			++step;
			if(passed.find(next) != passed.end()){
				step = -1;
				break;
			}
			passed.insert(next);
			n = next;
		}
		cout << step << endl;
	}
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast
    char s[10];
    cin >> s;
    if(s[0]>='a' && s[0]<='z') cout << "a" << endl;
    else cout << "A" << endl;
    return 0;
}



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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int ans = 0;
            for(int i = 0; i < S.Length / 2; i++)
            {
                if (S.Substring(i, 1) != S.Substring(S.Length - i - 1, 1))
                {
                    ans++;
                }
            }
            Console.WriteLine(ans);
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 25940