akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

typedef vector<int> Row;
typedef vector<Row> Sheet;

int main()
{
    int r, c;
    cin >> r >> c;
    Sheet sheet(r, Row(c));
    
    for(int i = 0; i < r; ++i){
        for(int j = 0; j < c; ++j){
            cin >> sheet[i][j];
        }
    }
    
    for(int i = 0; i < r; ++i){
        int sum = 0;
        for(int j = 0; j < c; ++j){
            sum += sheet[i][j];
        }
        sheet[i].push_back(sum);
    }
    Row sumRow(c+1, 0);
    for(int i = 0; i < r; ++i){
        for(int j = 0; j < c+1; ++j){
            sumRow[j] += sheet[i][j];
        }
    }
    sheet.push_back(sumRow);

    for(int i = 0; i < r+1; ++i){
        for(int j = 0; j < c+1; ++j){
            if(j) cout << " ";
            cout << sheet[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3220
import java.util.Scanner;
public class Main{
	public static void main(String[] argv) {
		Scanner scan = new Scanner(System.in);
		thumbnail(scan);

	}

	public static void thumbnail(Scanner scan) {
		int N = scan.nextInt();
		int[] array = new int[N];
		double ave=0;
		for(int i=0;i<N;i++) {
			int mid = scan.nextInt();
			ave += mid;
			array[i] = mid;
		}
		ave /= (double)N;
		int resultIndex = 0;
		double min = Math.abs(array[0]-ave);
		for(int i=1;i<N && min!=0;i++) {
			double mid = Math.abs(array[i]-ave);
			if(mid<min) {
				resultIndex = i;
				min = mid;
			}
		}
		System.out.println(resultIndex);
	}
}

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

int main() {
  ll h, w;
  cin >> h >> w;
  if (w==1 || h ==1){
    cout << 1 << endl;
    return 0;
  }
  cout << (h * w + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
#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 chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n;
	cin >> n;
	if (n % 1000)
		cout << 1000 - (n % 1000) << endl;
	else
		cout << 0 << endl;
}

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

	solve();
}



Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cstdlib>
#include<time.h>
#include<math.h>
#include<cstring>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define gcd __gcd
using namespace std;
typedef long long ll;
int a,b,c,ans,N,M,K,T,t,q[200007],dui[200007],pos[200007];
int nl[200007],nr[200007];
int main(){
	scanf("%d%d",&N,&K);
	rep(i,1,N) scanf("%d",&q[i]);
	int l=1,r=0,nn=0;
	rep(i,1,N){
		if (q[i]>dui[l]) nn++; else nn=0;
		while (r>=l&&dui[r]<q[i]) r--; 
		dui[++r]=q[i],pos[r]=i;
		if (i-K+1>pos[l]) l++; 
		if (i>=K) nr[i]=min(nn,K);
	}
	l=1,r=0,nn=0;
	for (int i=N;i>=1;i--){
		if (q[i]<dui[l]) nn++; else nn=0;
		while (r>=l&&dui[r]>q[i]) r--; 
		dui[++r]=q[i],pos[r]=i;
		if (i+K-1<pos[l]) l++; 
		if (i<=N-K+1) nl[i+K-1]=min(nn,K);
	}
	int lal,lar,kk=0;
	rep(i,K,N){
		//cout<<nl[i]<<" "<<nr[i]<<endl;
		if (i-K+nl[i]+1<i-nr[i]){
			if (i-K+nl[i]+1!=lal||i-nr[i]!=lar) ans++;
		}
		else kk=1;
		lal=i-K+nl[i]+1; lar=i-nr[i];
	} 
	
	printf("%d\n",ans+kk);
	return 0;
}

Measured memory_bytes: 2688
#include "bits/stdc++.h"

using namespace std;

void solve()
{
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int h;
        cin >> h;
        if (h >= k)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<stdio.h>

int main(int argc, char *argv[]){

  int n;
  scanf("%d", &n);

  char s[n+1];
  scanf("%s", &s);
  //printf("%s\n", s);
  // s[0], s[1], s[2],..., s[n-2], s[n-1]

  int cnt = 0;
  int i = 0; // reader index
  for(int j=1; j<n; j++){
    //printf("%c\n", s[i]);
    if(s[j] == 'E') cnt++;
  }
  int cnt_min = cnt;

  for(i=1; i<n; i++){
    if(s[i-1] == 'W') cnt++;
    if(s[i] == 'E') cnt--;
    if(cnt < cnt_min){
      cnt_min = cnt;
    }
  }
  printf("%d\n", cnt_min);

  return 0;
}


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

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

    map<int, vector<pair<int, int>>> uv;
    // map<int, vector<pair<int, int>>> vu; // 区別する必要がなかった

    int E = N - 1;
    for (int i = 0; i < E; i++) {
        int u, v, w;
        cin >> u;
        cin >> v;
        cin >> w;
        u--;
        v--;
        w = (w % 2 == 0) ? 2 : 1;
        uv[u].push_back(pair<int, int>(v, w));
        uv[v].push_back(pair<int, int>(u, w));
        // vu[v].push_back(pair<int, int>(u, w));
    }

    vector<int> colors(N);
    for (int i = 0; i < N; i++) {
        colors[i] = -1;
    }
    colors[0] = 1;

    stack<int> nodeids;
    nodeids.push(0);
    while (!nodeids.empty()) {
        int nod = nodeids.top();
        nodeids.pop();
        for (auto e : uv[nod]) {
            int v = e.first;
            int w = e.second;
            if (colors[v] == -1) {
                if (w == 2) {
                    colors[v] = colors[nod];
                } else {
                    colors[v] = 1 - colors[nod];
                }
                nodeids.push(v);
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << colors[i] << endl;
    }
}


Measured memory_bytes: 15032
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        if(n==19||n==29||n==39||n==49||n==59||n==69||n==79||n==89||n==90||n==91||n==92||n==93||n==94||n==95||n==96||n==97||n==98||n==99){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
        
        
     
    }
}

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

template <typename INTTYPE> 
class matrix {
	int row;
	int col;
	INTTYPE **cells;
public:
	matrix(int row,int col);
	matrix* multiple(matrix *b);
	~matrix();
	INTTYPE getCells(int r, int c);
	void setCells(int r, int c, INTTYPE x);
	void input();
	void output();
private:
	INTTYPE multiple_sum(matrix *a,matrix *b, int i, int j);
};

template <typename INTTYPE> 
INTTYPE matrix<INTTYPE>::getCells(int r, int c){
        return cells[r][c];
}

template <typename INTTYPE> 
void matrix<INTTYPE>::setCells(int r, int c, INTTYPE x){
        cells[r][c] = x;
}

template <typename INTTYPE> 
matrix<INTTYPE>::matrix(int row, int col){
        this->row = row;
        this->col = col;
        cells = new INTTYPE*[row];
        for(int i = 0; i < row; i++){
                cells[i] = new INTTYPE[col];
        }
}

template <typename INTTYPE> 
matrix<INTTYPE>* matrix<INTTYPE>::multiple(matrix *b){
	matrix<INTTYPE>* c = new matrix<INTTYPE>(this->row,b->col);
	for(int i = 0; i < c->row; i++){
		for(int j = 0; j < c->col; j++){
			c->setCells(i,j, multiple_sum(this,b,i,j));
		}
	}
	return c;
}

template <typename INTTYPE> 
INTTYPE matrix<INTTYPE>::multiple_sum(matrix *a,matrix *b, int i, int j){
	INTTYPE sum = 0;
	assert(b->row == a->col);
	int m = a->col;
	for(int k = 0; k < m; k++){
		sum += a->getCells(i,k) * b->getCells(k, j);
	}
	return sum;
}

template <typename INTTYPE> 
matrix<INTTYPE>::~matrix(){
        for(int i = 0; i < row; i++){
                delete[] cells[i];      
        }
        delete[] cells;
}

template <typename INTTYPE> 
void matrix<INTTYPE>::input(){
	for(int i = 0; i < this->row; i++){
		for(int j = 0; j < this->col; j++){
			int data;
			cin >> data;
			this->setCells(i,j,data);
		}
	}
}

template <typename INTTYPE> 
void matrix<INTTYPE>::output(){
	for(int i = 0; i < this->row; i++){
		for(int j = 0; j < this->col; j++){
			cout << this->getCells(i,j);
			if (j == this->col - 1){
				cout << endl;
			}else{
				cout << " ";
			}
		}
	}
}

template <typename INTTYPE>
void run(void){
	int n,m,l;
	cin >> n >> m >> l;
	matrix<INTTYPE> *a = new matrix<INTTYPE>(n, m);
	a->input();
	matrix<INTTYPE> *b = new matrix<INTTYPE>(m, l);
	b->input();
	matrix<INTTYPE> *c = a->multiple(b);
	c->output();
	delete c;
	delete b;	
	delete a;
}

int main(int argc, char *argv[]){
	run<long long int>();
}

Measured memory_bytes: 3212
import itertools
import math

n = int(input())
x = []
y = []
index = []
for i in range(n):
    xi, yi = map(int, input().split())
    x.append(xi)
    y.append(yi)
    index.append(i)

distance = 0
for v in itertools.permutations(index):
    for i in range(n-1):
        distance += math.sqrt((x[v[i]] - x[v[i+1]]) **
                              2 + (y[v[i]]-y[v[i+1]])**2)


print(distance/math.factorial(n))

Measured memory_bytes: 40556
x = input().split()
K = int(x[0])
N = int(x[1])
A = input().split()
A = [int(x) for x in A]

L = min(A[N-1] - A[0],K - A[1] + A[0])
L1 = min(A[N-1] - A[0],K - A[N-1] + A[N-2])
L = min(L,L1)
for i in range(1,N-1):
    n = min(K-A[i]+A[i-1],K-A[i+1]+A[i])
    L = min(L,n)
print(L)

Measured memory_bytes: 26444
#include <iostream>
#include <string>
#include <cmath>
#include <cstdio>
using namespace std;

int main() {

  double sum = 0;

  double  x[21],y[21];
  double hen[30];
  double shen;
  int count = 0;
  double z;
  while(scanf("%lf,%lf",&x[count],&y[count]) != EOF) {
    if(count > 0) {
      hen[count-1] =  sqrt((x[0]-x[count])*(x[0]-x[count]) + (y[0]-y[count])*(y[0]-y[count]));
    }
    if(count >1) {
      shen = sqrt((x[count]-x[count-1])*(x[count]-x[count-1]) + (y[count]-y[count-1])*(y[count]-y[count-1]));
      z = (hen[count-1] + hen[count -2] + shen ) /2;
      // cout << sqrt(z*(z-shen)*(z-hen[count-1])*(z-hen[count-2])) << endl;
	sum += sqrt(z*(z-shen)*(z-hen[count-1])*(z-hen[count-2]));
    }
    count ++;
    
  }

 
    
  printf("%.8lf\n",sum);

  return 0;
}
  

Measured memory_bytes: 1240
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var w = next(), h = next();
  var a = [];
  for(var i = 0; i < w; i++){
    a.push([next(),0]);
  }
  for(var i = 0; i < h; i++){
    a.push([next(),1]);
  }
  a.sort((a,b)=>a[0]-b[0]);
  var ans = 0n;
  var x = 0, y = 0;
  for(var i = 0; i < h+w; i++){
    if(a[i][1] === 0){
      ans += BigInt(h-y+1) * BigInt(a[i][0]);
      x++;
    }else{
      ans += BigInt(w-x+1) * BigInt(a[i][0]);
      y++;
    }
  }
  return ans;
}

Measured memory_bytes: 98048
#include <stdio.h>

int main(void)
{
  int x, i;

  scanf("%d", &x);
  if(x == 2) {
    printf("%d\n", x);
  } else {
    if(x % 2 == 0) x++;
    
    for(;;) {
      for(i = 3; i < x; i += 2) {
	if(x % i == 0) break;
      }
      if(i == x) break;
      x++;
    }
    
    printf("%d\n", x);
  }
  return 0;
}


Measured memory_bytes: 128
# ABC168F .(Single Dot)
from collections import deque

g=lambda:map(int,input().split())

N,M=g()

sortx=[]
sorty=[]

y_line=[0]*N
x_line=[0]*M

for i in range(N):
    a,b,c=g()
    sortx.append(a)
    sortx.append(b)
    sorty.append(c)
    y_line[i]=(a,b,c)
    
for i in range(M):
    d,e,f=g()
    sortx.append(d)
    sorty.append(e)
    sorty.append(f)
    x_line[i]=(d,e,f)
    
from bisect import bisect_left as bl
    
sortx=sorted(list(set(sortx)))
sorty=sorted(list(set(sorty)))

for i in range(N):
    a,b,c=y_line[i]
    a=bl(sortx,a)
    b=bl(sortx,b)
    c=bl(sorty,c)
    y_line[i]=(a,b,c)
    
for i in range(M):
    d,e,f=x_line[i]
    d=bl(sortx,d)
    e=bl(sorty,e)
    f=bl(sorty,f)
    x_line[i]=(d,e,f)
    
W=len(sortx)*2-1
H=len(sorty)*2-1
    
G=[1]*W*H

def make_graph(i,j,s=0):
    G[i+j*W]=s
    
def isOK(x,y):
    if 0<=x+y*W<W*H:
        return G[x+y*W]==1
    else:
        return False
    
def isSoto(x,y):
    return (not 0<=x+y*W<W*H)

def get_score(i,j):
    if i<=0 or j<=0  or i>=W or j>=H:
        return float('inf')
    elif i%2 and j%2:
        dx=sortx[(i+1)//2]-sortx[(i-1)//2]
        dy=sorty[(j+1)//2]-sorty[(j-1)//2]
        return dx*dy
    else:
        return 0

dic=[(-1,0),(1,0),(0,1),(0,-1)]
def search(i,j):
    res=[]
    for dx,dy in dic:
        if isOK(i+dx,j+dy) and (isOK(i+2*dx,j+2*dy) or isSoto(i+2*dx,j+2*dy)):
            res.append((i+2*dx,j+2*dy))
    return res

for a,b,c in y_line:
    for i in range(2*a,2*b+1):
        make_graph(i,2*c)
        
for d,e,f in x_line:
    for j in range(2*e,2*f+1):
        make_graph(2*d,j)
        
x0,y0=2*bl(sortx,0)-1,2*bl(sorty,0)-1

stack=deque()

for dx,dy in [(-1,-1),(-1,1),(1,1),(1,-1)]:
    if isOK(x0+dx,y0) or isOK(x0,y0+dy):
        stack.append((x0+dx,y0+dy))

stack.append((x0,y0))
res=0
make_graph(x0,y0,1)
while stack:
    x,y=stack.popleft()
    if isSoto(x,y):
        res+=get_score(x,y)
        break
    if not isOK(x,y):
        continue
    res+=get_score(x,y)
    for nx,ny in search(x,y):
        stack.append((nx,ny))
    make_graph(x,y)

print(res if res<float('inf') else 'INF')

Measured memory_bytes: 481056
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)
const ll INF=1LL << 60;
int main(){
  ll n,x;
  string s;
  cin >> n >> x;
  vector<ll> v(n);
  rep(i,n){
    cin >> v[i];
  }
  ll now;
  ll ans=0;
  for(int i=1;i < n;i++){
    now=v[i-1]+v[i];
    ll tmp;
    tmp=v[i];
    //printf("now : %lld\n",now);
    if (now > x) {
      if (v[i] < now - x){
          v[i]=0;
      }
      else v[i]-=(now-x);
      ans+=(now-x);
    }
    //printf("+%lld\n",now-x);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

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

	    int m1=gi();
	    int d1=gi();
	    int m2=gi();
	    int d2=gi();
	    
	    //System.out.print(n[k-1]);
	    if (m1==m2) {
	    	System.out.print("0");
	    }else {
	    	System.out.print("1");
	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], M = l[1];
            var box = new Model[N];
            for (var i = 0; i < N; i++)
                box[i] = new Model(){IsRed=false, BallCount=1};
            
            box[0].IsRed = true;
            for (var i = 0; i < M; i++) {
                var xy = Console.ReadLine().Split().Select(int.Parse).ToArray();
                xy[0]--;
                xy[1]--;
                box[xy[0]].BallCount--;
                
                if (box[xy[0]].IsRed)
                    box[xy[1]].IsRed = true;
                if (box[xy[0]].BallCount == 0)
                    box[xy[0]].IsRed = false;
                box[xy[1]].BallCount++;
            }
            
            Console.WriteLine(box.Count(z => z.IsRed));
        }
    }

    class Model {
       public bool IsRed {get; set;}
       public int BallCount {get; set;}
    }
}


Measured memory_bytes: 21832
h,w,k = gets.split.map(&:to_i)
g = []
aaa = 0
h.times do
  c = gets.chomp
  g << c
end
for i in 0..((2**(h+w))-1)
  a = []
  ans = 0
  for j in 0..(h+w-1)
    a << i[j]
  end
  for x in 0..(h-1)
    for l in 0..(w-1)
      if a[x] == 0 && a[h+l] == 0 && g[x][l] == "#"
        ans += 1
      end
    end
  end
  aaa += 1 if ans == k
end
puts aaa

Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s;
  cin >> s;
  bool ok = true;
  string t = "";
  while (sz(s)) {
    t += s.back();
    s.pop_back();
    if (sz(t) >= 8) break;
    if (t == "maerd" || t == "esare" || t == "remaerd" || t == "resare") {
      t = "";
    }
  }
  if (sz(t)) ok = false;
  puts(ok ? "YES" : "NO");
  return 0;
}

Measured memory_bytes: 3732
/* A - A?C */

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

int main(void){
  char S[3];
  scanf("%s", S);
  if(strcmp(S, "ABC") == 0){
    printf("ARC\n");
  }else if(strcmp(S, "ARC") == 0){
    printf("ABC\n");
  }
}


Measured memory_bytes: 1612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF 2 << 29
#define MOD 1000000007
#define Yes(f) puts((f)? "Yes" : "No")
#define YES(f) puts((f)? "YES" : "NO")
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

using Graph = vector<vector<int>>;

int main(){
	int n; cin >> n;
	Yes(n / 100 == 7 || n % 10 == 7 || n % 100 / 10 == 7);
}


Measured memory_bytes: 3636
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#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>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)



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

	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}



	return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n, d, x;
  cin >> n >> d >> x;
  int choco = x;
  rep(i, n){
    int a;
    cin >> a;
    for(int j = 0; j*a + 1 <= d; j++){
      choco++;
    }
  }
  cout << choco << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a,b;
    cin>>a>>b;
    if(a.SZ==b.SZ)
    {
        if(a>b)
        {
            cout<<"GREATER"<<endl;
        }
        else if(b>a)
        {
            cout<<"LESS"<<endl;
        }
        else
        {
            cout<<"EQUAL"<<endl;
        }
    }
    else
    {
        if(a.SZ>b.SZ)
        {
             cout<<"GREATER"<<endl;
        }
        else
        {
             cout<<"LESS"<<endl;
        }
    }
}



Measured memory_bytes: 256
N, K = [ int(i) for i in input().strip().split(' ') ]
counter = [ 0 for _ in range(N) ]
for k in range(K):
    d = int(input())
    for a in [ int(i) for i in input().strip().split(' ') ]:
        counter[a-1] += 1

c_0 = [ c for c in counter if c == 0]
print(len(c_0))

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

int main(){
    int antenna[5],k;
    int i,j;
    bool flag = false;

    for(i=0;i<5;i++){
        cin >> antenna[i];
    }

    cin >> k;

    for(i=0;i<5;i++){
        for(j=0;j<5;j++){
//            int dist = fabs(antenna[i]-antenna[j]);
            if(fabs(antenna[i]-antenna[j]) > k){
                flag = true;
            }
        }
    }

    if(flag){
        cout << ":(" << endl;
    }
    else{
        cout << "Yay!" << endl;        
    }

    return 0;

}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <LL,LL>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

LL n,d,ans=0;
LL a[200010],par[200010];
vector <pair <LL,pii> > v;

LL FIND(LL pos)//dsu
{
	if(par[pos]!=pos) par[pos]=FIND(par[pos]);
	return par[pos];
}

void UNION(LL pos1,LL pos2)
{
	par[FIND(pos1)]=FIND(pos2);
}

void solve(LL lb,LL ub)//分治
{
	if(lb==ub) return;//只剩一个 
	LL mid=(lb+ub)/2,mn=1e18,lbest,rbest;
	for(LL i=lb;i<=mid;i++)
	{
		if(a[i]-d*i<mn)//左边是编号较小的一组，所以是减 
		{
			mn=a[i]-d*i;
			lbest=i;
		}
	}
	mn=1e18;
	for(LL i=mid+1;i<=ub;i++)
	{
		if(a[i]+d*i<mn)//右边是编号较大的一组，所以是加 
		{
			mn=a[i]+d*i;
			rbest=i;
		}
	}
	for(LL i=lb;i<=mid;i++)
	{
		LL val1=a[i]-d*i,val2=a[rbest]+d*rbest;
		v.pb({val1+val2,{i,rbest}});
	}
	for(LL i=mid+1;i<=ub;i++)
	{
		LL val1=a[i]+d*i,val2=a[lbest]-d*lbest;
		v.pb({val1+val2,{lbest,i}});
	}
	solve(lb,mid);
	solve(mid+1,ub);
} 

int main()
{
	rep(i,200005) par[i]=i;
	cin>>n>>d;
	rep(i,n) scanf("%I64d",&a[i]);
	solve(0,n-1);
	sort(v.begin(),v.end());
	rep(i,v.size())
	{
		if(FIND(v[i].se.fi)==FIND(v[i].se.se)) continue;
		UNION(v[i].se.fi,v[i].se.se);
		ans+=v[i].fi;
	}
	cout<<ans<<endl;
	rt0;
}
/*
在连通两个区域时，只连接两边的最好的点是不行的
比如：
如果只连接两边的最好的点： 
(1,val:200)-(2,val:10)
           /
(3,val:100)-(4,val:200)
这时，总消费是623；
 
如程序中的，连接一边的所有点和另一边的最好的点
(1,val:200)-(2,val:10)
           / |
(3,val:100) (4,val:200)
这时，总消费是534
因为，一开始被分在某一边的某个点不一定连自己这边的某个点是最优的，
可能连另一边的最好的点更佳 
*/

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll i, j, k;

int main(){
    scanf("%lld%lld%lld", &i,&j,&k);
    if(j/i<k){
        printf("%lld", j / i);
    }else{
        printf("%lld", k);
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8


def solve(*args: str) -> str:
    abcd = tuple(map(int, args[0]))
    ret = str(abcd[0])
    for p in range(2**3):
        tmp = abcd[0]
        for i in range(3):
            if p >> i & 1:
                tmp += abcd[i+1]
            else:
                tmp -= abcd[i+1]
        if tmp == 7:
            op = '{:03b}'.format(p).replace('0', '-').replace('1', '+')[::-1]
            for i in range(3):
                ret += '{}{}'.format(op[i], abcd[i+1])
            ret += '=7'
            break
    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
using namespace std;
const int num1 = 1046527;
const int num2 = 13;
char c[num1][num2];
inline int getInt(char ch) {
	if (ch == 'A') return 1;
	else if (ch == 'C') return 2;
	else if (ch == 'G') return 3;
	else if (ch == 'T') return 4;
	return 0;
}
inline int getKey(char str[]) {
	int p = 1, sum = 0;
	for (int i = 0; i < strlen(str); i++) {
		sum += p*getInt(str[i]);
		p *= 5;
	}
	return sum;
}
int h1(int key) { return key % num1; }
int h2(int key) { return 1 + key % (num1 - 1); }
inline int insert(char str[]) {
	int i, key = getKey(str);
	for (i = 0; ; i++) {
		int h = (h1(key) + i*h2(key)) % num1;
		if (strcmp(c[h], str) == 0) return 1;//?????´??????return 0
		else if (strlen(c[h]) == 0) {
			strcpy(c[h], str);
			return 0;
		}
	}
	return 0;
}
inline int find(char str[]) {
	int i;
	int sum = 0, key = getKey(str);
	for (i = 0; ; i++) {
		int h = (h1(key) + i*h2(key)) % num1;
		if (strcmp(c[h], str) == 0) return 1;
		else if (strlen(c[h]) == 0) return 0;
	}
	return 0;
}
int main() {
	int n;
	char com[9], str[num2];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> com >> str;
		if (com[0] == 'i')
			insert(str);
		else {
			if (find(str))
				cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 16388
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
	int A,B,C,D;
	while(~scanf("%d%d%d%d",&A,&B,&C,&D))
	{
		if(C>=B || A>=D)
		{
			printf("0\n");
			continue;
		}
		if(C>=A && D>=B)
		{
			printf("%d\n",B-C);
			continue;
		}
		if(A>=C && B>=D)
		{
			printf("%d\n",D-A);
			continue;
		}
		if(A<=C && D<=B)
		{
			printf("%d\n",D-C);
			continue;
		}
		if(A>=C && B <= D)
		{
			printf("%d\n",B-A);
			continue;
		}
	}
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int a[1000][1000],ans[250010][10];
inline int read()
{
	register char ch;register bool aa=1;
	while(ch=getchar(),ch>57||ch<48)ch=='-'?aa=0:0;register int x=ch^48;
	while(ch=getchar(),ch>47&&ch<58)x=x*10+(ch^48);
	return aa?x:-x;
}
int main()
{
	register int h=read(),w=read(),num=0;
	for(int i=1;i<=h;i++)
	  for(int j=1;j<=w;j++)
	    a[i][j]=read();
	for(int i=1;i<=h;i++)
	  for(int j=1;j<=w;j++)
	  {
	  	if(a[i][j]&1)
	  	{
	  		ans[++num][1]=ans[num][3]=i,ans[num][2]=ans[num][4]=j;
	  		if(i>1)
	  		{
	  			if(a[i-1][j]&1)
				  {
				  	a[i][j]--;
				  	a[i-1][j]++;
				  	ans[num][3]--;
				  	continue;
				  }
			}
			if(j>1)
			{
				if(a[i][j-1]&1)
				  {
				  	a[i][j]--;
				  	a[i][j-1]++;
				  	ans[num][4]--;
				  	continue;
				  }
			}
			if(i<h)
			{
				if(a[i+1][j]&1)
				  {
				  	a[i][j]--;
				  	a[i+1][j]++;
				  	ans[num][3]++;
				  	continue;
				  }
			}
			if(j<w)
			{
				if(a[i][j+1]&1)
				  {
				  	a[i][j]--;
				  	a[i][j+1]++;
				  	ans[num][4]++;
				  	continue;
				  }
			}
			/////
			a[i][j]--;
			if(i<h)
			{
				a[i+1][j]++;
				ans[num][3]++;
				continue;
			}
			if(j<w)
			{
				a[i][j+1]++;
				ans[num][4]++;
				continue;
			}
			num--;
		}
	  }
	printf("%d\n",num);
	for(int i=1;i<=num;i++)printf("%d %d %d %d\n",ans[i][1],ans[i][2],ans[i][3],ans[i][4]);
}

Measured memory_bytes: 12288
from itertools import accumulate
from bisect import bisect_right
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def ruiseki(lst):
    return [0]+list(accumulate(lst))

ar = ruiseki(A)
br = ruiseki(B)
ans = 0
for i in range(1+N):
    left = K - ar[i]
    if left < 0:
        continue
    bidx = bisect_right(br, left) - 1
    ans = max(ans,i+bidx)

print(ans)


Measured memory_bytes: 49384
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll dp[3001][6001];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, t, i, ans = 0, j;
    cin>>n>>t;
    vector<pair<ll, ll>> v(n+1);
    v[0].ff = v[0].ss = 0;
    for(i=1; i<=n; i++) {
    	cin>>v[i].ff>>v[i].ss;
    }
    sort(all(v));
    for(i=1; i<=n; i++) {
    	for(j=0; j <= 6000; j++) {
    		if(j - v[i].ff + 1 < 0 || (j - v[i].ff + 1 > (t - 1) )) {
    			dp[i][j] = dp[i-1][j];
    			continue;
    		}
    		if(j - v[i].ff == -1) {
    			dp[i][j] = max(dp[i-1][j], v[i].ss);
    			ans = max(ans, dp[i][j]);
    			continue;
    		}
    		dp[i][j] = max(dp[i-1][j], dp[i-1][j - v[i].ff] + v[i].ss);
    		ans = max(ans, dp[i][j]);
    	}
    }
    cout<<ans<<"\n";
}	

Measured memory_bytes: 140928
#include <iostream>
#include <vector>

int main(){
    std::vector<int> vec{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    std::cin >> k;

    std::cout << vec.at(k - 1) << std::endl;

    return 0;
}

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

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

  int ball;
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> ball;
    if(ball <= K - ball){
      sum += ball * 2;
    }
    else{
      sum += (K - ball) * 2;
    }
  }
  cout << sum << endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    p[i]--;
  }
  vector< vector<int> > g(n);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].emplace_back(v);
    g[v].emplace_back(u);
  }

  vector<bool> was(n, 0);
  function<void(int,vector<int>&,vector<int>&)> dfs = [&](int v, vector<int> &a, vector<int> &b) {
    was[v] = true;
    for (auto u : g[v]) {
      if (!was[u]) dfs(u, a, b);
    }
    a.emplace_back(p[v]);
    b.emplace_back(v);
  };

  int res = 0;
  for (int i = 0; i < n; i++) {
    if (!was[i]) {
      vector<int> a, b;
      dfs(i, a, b);
      sort(a.begin(), a.end());
      sort(b.begin(), b.end());
      int x = 0, y = 0;
      while (x < (int) a.size() && y < (int) b.size()) {
        if (a[x] == b[y]) {
          res++;
          x++; y++;
        }
        else if (a[x] < b[y]) x++;
        else if (a[x] > b[y]) y++;
      }
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 11052
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
using namespace std;
using ll = long long;
constexpr ll INF = 1010000000000000017LL;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll GCD(ll a, ll b) { if(b==0) return a; else return GCD(b, a%b); }
ll LCM(ll a, ll b) { return a/GCD(a,b)*b; }

class BNotFound {
public:
	void solve(std::istream& in, std::ostream& out) {
        string s;in>>s;
        vector<ll> v(26,0);

        rep(i,s.size()){
            v.at(s.at(i)-'a')++;
        }
        rep(i,26) {
            if(v.at(i)==0){
                out<<(char)('a'+i)<<endl;
                return;
            }
        }
        out<<"None"<<endl;
	}
};


int main() {
	BNotFound solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> s;
  rep(i, Size(s)) {
    if (s[i] != '?') continue;
    s[i] = 'D';
  }
  Cout(s);
  return 0;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define mp make_pair
#define ll long long
#define pb push_back


void solve()
{

  int n,m;
  cin>>n>>m;

  int num;
  cin>>num;

  vector<int>row(n,0);
  vector<int>col(m,0);

  int i,j;

  set<pair<int,int> >s;

  for(i=0;i<num;i++)
  {
      int a,b;
      cin>>a>>b;

      a--;b--;
      row[a]++;
      col[b]++;
      s.insert(mp(a,b));
  }
  int x = row[0];
  vector<int> r;
  vector<int>c ;
  for(i=0;i<n;i++)
    {
        if(row[i] > x)
        {
            x = row[i];

        }
    }
  int y = col[0];
  for(i=0;i<m;i++)
    {
        if(col[i] > y)
        {
            y = col[i];

        }
    }

  for(i=0;i<n;i++)
  {
      if(row[i] == x)r.pb(i);
  }
  for(i=0;i<m;i++)
  {
      if(col[i]==y)c.pb(i);
  }

  for(i=0;i<r.size();i++)
  {
      for(j=0;j<c.size();j++)
      {
          if(s.find(mp(r[i],c[j]))==s.end())
          {
              cout<<x+y;
              return;
          }
      }
  }
  cout<<x+y-1;

}

int main()
{

  int t = 1;
  //cin>>t;

  while(t--)
    solve();

  return 0;
}


Measured memory_bytes: 23864
#include <bits/stdc++.h>
using namespace std;
                                                                                                
  
int main(){
                                                                     

    int a, b;

    cin >> a >> b;

    if( a > b ){

        cout << a - 1 << endl;

        return 0;

        }

    if( a == b ){

          cout << a << endl;

          return 0;

          }

    if( a < b ){

          cout << a << endl;

          return 0;

          }


    return 0;

    }

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
 
int main(){
    char str1[100], str2[100];
    int n, point[2] = {0}, tmp, i;
     
    scanf("%d", &n);
     
    for(i = 0; i < n;i++){
        scanf("%s %s", str1, str2);
        tmp = strcmp(str1, str2);
        if(tmp == 0)  point[0] += 1, point[1] += 1;
        if ( tmp > 0) point[0] += 3;
        if ( tmp < 0) point[1] += 3;
    }
     
    printf("%d %d\n", point[0], point[1]);
    return 0;
     
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 1000000+5;
const int dx[] = {0,0,-1,1,-1,-1,1,1};
const int dy[] = {-1,1,0,0,-1,1,-1,1};
using namespace std;
struct Edge {
    int to,next,val;
    Edge(){}
    Edge(int to,int next,int val):to(to),next(next),val(val){}
    bool operator < (const Edge& rhs)const{
        return val>rhs.val;
    }
}edge[N*2];
int tot,head[N];
void addEdge(int from,int to,int val) {
    edge[tot].next=head[from];
    edge[tot].to=to;
    edge[tot].val=val;
    head[from]=tot++;
}
bool vis[N];
int dis[N];
int SPFA(int s,int e) {
    memset(vis,false,sizeof(vis));
    memset(dis,INF,sizeof(dis));
    dis[s]=0;
 
    priority_queue<Edge> Q;
    Q.push(Edge(s,0,0));
    while (!Q.empty()) {
        Edge temp=Q.top();
        Q.pop();
        if(vis[temp.to])
            continue;
        vis[temp.to]=true;
 
        for(int i=head[temp.to]; i!=-1; i=edge[i].next) {
            if(dis[edge[i].to]>dis[temp.to]+edge[i].val) {
                dis[edge[i].to]=dis[temp.to]+edge[i].val;
                Q.push(Edge(edge[i].to,0,dis[edge[i].to]));
            }
        }
    }
    if(dis[e]!=INF)
        return dis[e]/2;
    return -1;
}
map<int,int> mp[N];
int allPoint;
int getPoint(int x,int y) {
    if (!mp[x][y])
        mp[x][y]=++allPoint;
    return mp[x][y];
}
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    allPoint=n;
    for (int i=1; i<=m; i++) {
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
 
        int newX=getPoint(x,w);
        int newY=getPoint(y,w);
 
        addEdge(x,newX,1);
        addEdge(newX,x,1);
        addEdge(newX,newY,0);
        addEdge(newY,newX,0);
        addEdge(y,newY,1);
        addEdge(newY,y,1);
    }
    int res=SPFA(1,n);
    printf("%d\n",res);
    return 0;
}

Measured memory_bytes: 93044
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
const int M = 5000;
char s[M + 5][M + 5], str[M + 5];
int A[M + 5], lcp[M + 5];
bool cmp(int a, int b)
{
	return strcmp(s[a], s[b]) < 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", str);
	for(int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
			s[i][j - i] = str[j];
	}
	for(int i = 0; i < n; i++) A[i] = i;
	sort(A, A + n, cmp);
	for(int i = 0; i < n - 1; i++)
	{
		int k = 0;
		while(k < n - A[i] && k < n - A[i + 1] && s[A[i]][k] == s[A[i + 1]][k]) k++;
		lcp[i] = k;
	}
	int ans = 0;
	for(int i = 0; i < n - 1; i++)
	{
		int j = i + 1, k = lcp[i];
		while(k && j < n)
		{
			ans = max(ans, min(k, abs(A[i] - A[j])));
			k = min(k, lcp[j]);
			j++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 24448
//#pragma GCC optimize("trapv")
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pi = pair<ll, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int go(string s, char x) {
//	cout << s.size() << " " << count(all(s), x) << "\n";
	if(count(all(s), x)==s.size()) return 0;
	string t;
	for(int i = 1; i < s.size(); i++)
		if(s[i]==x||s[i-1]==x) t.pb(x);
		else t.pb(s[i]);
	return go(t, x)+1;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	int ans = INT_MAX;
	for(int i = 0; i < 26; i++)
		ans = min(ans, go(s, 'a'+i));
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int S,h,m,s;
  cin>>S;
  h=S/60/60;
  m=S/60-h*60;
  s=S-(m*60+h*60*60);
  cout<<h<<":"<<m<<":"<<s<<'\n';
  return(0);
}



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

int main(){
    int n,k,s;
    cin>>n>>k>>s;
    rep(i,n){
        if(i<k){
            if(i+1==n) cout<<s;
            else cout<<s<<" ";
        }
        else{
            if(1e9>s){
                if(i+1==n) cout<<s+1;
                else cout<<s+1<<" ";
            }
            else{
                if(i+1==n) cout<<s-1;
                else cout<<s-1<<" ";
            }
        }
    }
}

Measured memory_bytes: 3684
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import defaultdict

    n, m = map(int, readline().split())
    cum = [0] * n

    war = defaultdict(list)

    for _ in range(m):
        a, b = map(int, readline().split())
        war[a].append(b)

    ans = 0
    cur = n + 1
    for i in range(1, n + 1):
        if cur == i:
            ans += 1
            cur = n + 1
        ng = war[i]
        if ng:
            cur = min(cur, min(ng))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61276
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

const int MAXN = 1e6 + 10;
int lp[MAXN];
ll d[MAXN];
void solve() {
    for(int i = 2; i < MAXN; i += 2) lp[i] = 2;
    for(ll i = 3; i * i < MAXN; i += 2) {
        if(!lp[i]) {
            lp[i] = i;
            for(ll j = i * i; j < MAXN; j += (i + i))
                if(!lp[j])
                    lp[j] = i;
        }
    }
    for(int i = 2; i < MAXN; ++i) if(!lp[i]) lp[i] = i;
    d[1] = 1;
    for(int i = 2; i < MAXN; ++i) {
        int j = i, alp = 0;
        while(j % lp[i] == 0) j /= lp[i], alp++;
        d[i] = d[j] * (alp + 1);
    }
    int n;
    cin >> n;
    ll ans = 0;
    for(int c = 1; c < n; ++c) {
        int x = n - c;
        ans += d[x];
    }
    cout << ans;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 15340
def main():
    from itertools import accumulate
    n, *ab = map(int, open(0).read().split())
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    t = 0
    f = False
    for i, j in c:
        t += i
        f = f or t > j

    print('No' if f else 'Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 48724
#include <stdio.h>

int main(){
    int a, b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op=='?'){
            break;
    	}else if(op=='+'){
    	    printf("%d\n", a+b);
    	}else if(op=='-'){
    	    printf("%d\n", a-b);
    	}else if(op=='*'){
    	    printf("%d\n", a*b);
    	}else if(op=='/'){
    	    printf("%d\n", a/b);
        }
    }
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,x,y,z,max1=0,ans;
    string s,t,u;
    cin>>a>>b>>k;
    
    
    cout<<k/a*b<<endl;
}




Measured memory_bytes: 256
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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






template<unsigned long long m> class comb_perm{
private:
    int n;
    std::vector<long long> fact, fact_inv;
public:
    comb_perm(): n(0), fact(1), fact_inv(1){
        fact[0] = fact_inv[0] = 1;
    }
    comb_perm(int N): n(N), fact(N+1), fact_inv(N+1){
        fact[0] = fact[1] = fact_inv[0] = fact_inv[1] = 1;
        for(int i(2); i <= n; ++i) fact[i] = fact[i - 1] * i % m;
        for(int i(2); i <= n; ++i) fact_inv[i] = inv(fact[i]);
    }
 
    void resize(int N){
        fact.resize(N+1);
        fact_inv.resize(N+1);
        if(!n && N){
            fact[1] = fact_inv[1] = 1;
        }
        for(int i(std::max(2, n+1)); i <= N; ++i) fact[i] = fact[i - 1] * i % m;
        for(int i(std::max(2, n+1)); i <= N; ++i) fact_inv[i] = inv(fact[i], m);
        n = N;
    }
 
    long long power(long long a, unsigned long long b){
        long long ret(1);
        while(b){
            if(b & 1) ret = (ret * a) % m;
            a = (a * a) % m;
            b /= 2;
            if(ret < 0) ret += m;
            if(a < 0) a += m;
        }
        return ret;
    }
 
    long long inv(long long a){ // GCD(a, m) = 1
        return power(a, m-2);
    }
 
    long long permutation(int n, int r){
        if(n < r) return 0;
        if(n < 0 || r < 0) return 0;
        long long ret(fact[n]);
        ret = ret * fact_inv[n - r] % m;
        return ret;
    }
 
    long long combination(int n, int r){
        if(n < r) return 0;
        if(n < 0 || r < 0) return 0;
        long long ret(permutation(n, r));
        return ret * fact_inv[r] % m;
    }
 
    long long factorial(int a){
        return fact[a];
    }
 
    long long inv_factorial(int a){
        return fact_inv[a];
    }
};

int main(){
    int S; std::cin >> S;
    comb_perm<MOD> cp(S + 3);
    int ans(0);
    for(int i(1), i_len(S/3); i <= i_len; ++i){
        (ans += cp.combination(S - 2*i - 1, S - 3*i)) %= MOD;
        if(ans < 0) ans += MOD;
    }
    std::cout << ans << std::endl;
    return 0;
}


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

using namespace std;

int n;
int main()
{
  	cin >> n;
  	if(n == 1)
    {
		cout << 1 << endl;
      return 0;
    }
  	if(n == 2 || n == 3)
    {
      	cout << 3 << endl;
      	return 0;
    }
  	if(n == 4)
    {
		cout << 7 << endl;
    }
  	long long sum = 7;
  for(int i = 6; i <= n; i++)
  {
    if(i % 3 == 0 || i % 5 == 0)
    {
		continue;
    }
    else
    {
		sum += i;
    }
  }
  cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3684