akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	int cell[101][101];
	int x,y,r,c;
	int a;
	for(x=0;x<101;x++)
		for(y=0;y<101;y++)
			cell[x][y]=0;
	scanf("%d %d",&r,&c);
	for(y=0;y<r;y++){
		a=0;
		for(x=0;x<c;x++){
			scanf("%d",cell[x]+y);
			a+=cell[x][y];
		}
		cell[c][y]=a;
	}
	for(x=0;x<=c;x++){
		a=0;
		for(y=0;y<r;y++)
			a+=cell[x][y];
		cell[x][r]=a;
	}
	for(y=0;y<=r;y++){
		for(x=0;x<=c;x++)
			printf("%d%s",cell[x][y],(x==c)?"":" ");
		printf("\n");
	}
	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    int N, K;
    cin >> N >> K;

    ll ans = 0;
    for (int b = 1; b <= N; b++) {
        if (K >= b) continue;

        ans += N / b * (b - K);
        if (N % b) {
            int lo = 1, hi = N % b;
            lo = max(lo, K);
            if (hi >= lo) ans += hi - lo + 1;
        }
    }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
using namespace std;
// }}} End Header

int main()
{
	deque<char> que;
	lli q, n;
	string s;
	char c;
	cin >> s >> q;

	rep(i, s.length()){
		que.push_back(s[i]);
	}
	int k;
	int f = 0;
	rep(i,q){
		cin >> n;
		if(n==1){
			f = 1-f;
		}else{
			cin >> k >> c;
			if(f){
				if(k == 1) que.push_back(c);
				else que.push_front(c);
			}else{
				if(k == 1) que.push_front(c);
				else que.push_back(c);
			}
		}
	}
	if(f) reverse(all(que));
	for(char ch : que){
		cout << ch;
	}
	return 0;
}


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

const ll MOD=1e9+7;
const double EPS=1e-9;
const double PI=acos(-1.0);
//const long double PI=acos(-1.0L);

struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}

    Point operator +(const Point &b) const {return Point(x+b.x,y+b.y);}
    Point operator -(const Point &b) const {return Point(x-b.x,y-b.y);}
    Point operator *(const double b) const {return Point(x*b,y*b);}
    Point operator /(const double b) const {return Point(x/b,y/b);}
};

struct Line{
    Point a,b;
    Line(){}
    Line(Point a,Point b):a(a),b(b){}
};

int sgn(double a) {return (a>EPS)-(a<-EPS);}
int sgn(double a,double b) {return sgn(a-b);}

double dot(const Point &a,const Point &b) {return (a.x*b.x+a.y*b.y);}
double cross(const Point &a,const Point &b) {return (a.x*b.y-a.y*b.x);}
double norm(const Point &p) {return dot(p,p);}
double abs(const Point &p) {return sqrt(norm(p));}

//1:Counter_Clockwise -1:Clockwise
//2:a-b-c -2:c-a-b 0:a-c-b
int ccw(const Point &p,const Point &q){
    int s=sgn(cross(p,q));
    if(s!=0) return s;
    if(dot(p,q)<0) return -2;
    if(norm(p)<norm(q)) return 2;
    return 0;
}
int ccw(const Point &a,const Point &b,const Point &c){return ccw(b-a,c-a);}

bool isConvex(vector<Point> &g){
    int n=g.size();
    for(int i=0;i<n;i++){
        if(ccw(g[i],g[(i+1)%n],g[(i+2)%n])==-1) return false;
    }
    return true;
}

vector<Point> ConvexHull(vector<Point> &ps,bool linear){
    sort(ps.begin(),ps.end(),[](Point &a,Point &b){
        return (a.x!=b.x?a.x<b.x:a.y<b.y);
    });
    int n=ps.size();
    vector<Point> res(2*n);
    int lim=linear?0:1;

    int k=0;
    for(int i=0;i<n;i++){
        while(k>=2&&sgn(cross(res[k-1]-res[k-2],ps[i]-res[k-2]))<lim) --k;
        res[k++]=ps[i];
    }
    int t=k+1;
    for(int i=n-2;i>=0;i--){
        while(k>=t&&sgn(cross(res[k-1]-res[k-2],ps[i]-res[k-2]))<lim) --k;
        res[k++]=ps[i];
    }

    res.resize(k-1);
    return res;
}

int main(){
    int N;
    cin>>N;
    vector<Point> ps(N);
    rep(i,N) cin>>ps[i].x>>ps[i].y;

    vector<Point> h=ConvexHull(ps,true);
    int st=0;
    for(int i=0;i<h.size();i++){
        int c=sgn(h[i].x-h[st].x);
        int d=sgn(h[i].y-h[st].y);
        if(d==-1) st=i;
        else if(d==0&&c==-1) st=i;
    }

    cout<<h.size()<<endl;
    for(int i=0;i<h.size();i++){
        int j=(st+i)%h.size();
        cout<<(int)h[j].x<<" "<<(int)h[j].y<<endl;
    }


    return 0;
}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll t = min(k, x/d);
  k -= t;
  x -= t*d;
  cout << (k&1?abs(x-d):x) << endl;
}

Measured memory_bytes: 3616
while true
        str = STDIN.gets.chomp
        break if str == "-"
        m = STDIN.gets.to_i
        m.times {|i|
                h = STDIN.gets.to_i
                new = ''
                (h..(str.length - 1)).each {|i| new += str[i] }
                h.times {|i| new += str[i] }
                str = new
        }
        puts str
end

Measured memory_bytes: 6252
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << (x) << endl
using namespace std;

const int N = 1000005;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

char str[N];
int n, a[N];

int main () {
	read(n), n--;
	scanf("%s", str);
	for (int i = 0; i <= n; i++) a[i] = str[i] - '1';

	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if ((n & i) == i) ans = (ans + a[i]) % 2;
	}
	if (!ans) {
		bool flag = true;
		for (int i = 0; i <= n; i++) {
			if (a[i] == 1) flag = false;
		}
		if (flag) {
			int x = 0;
			for (int i = 0; i <= n; i++) a[i] >>= 1;
			for (int i = 0; i <= n; i++) {
				if ((n & i) == i) x = (x + a[i]) % 2;
			}
			if (x) ans = 2;
		}
	}
	write(ans), putchar('\n');
	return 0;
}

Measured memory_bytes: 5120
/*In The Name of AintAH*/
#include <bits/stdc++.h>
#define inf 1000000007
#define mod	1000000007
#define MAX 200005 
#define ll long long
#define fr first
#define sc second
#define endl '\n'
using namespace std;
int dp[MAX][13];
int ten[MAX];
int main(){ 
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s;
	cin>>s;
	int n = s.size();
	ten[0] = 1;
	for(int i = 1; i < n ; i++)ten[i] = (ten[i-1] * 10)%13;


	if(s[0] == '?') for(int i = 0; i < 10; i++)dp[0][(i*ten[n - 1])%13]++;
	else dp[0][(1 * (s[0] - '0')*ten[n - 1])%13]++;
	for(int i = 1; i < n; i++){
		if(s[i] == '?'){
			for(int k = 0; k < 10; k++){
				for(int j = 0; j < 13; j ++){
					if(dp[i-1][j]){
						dp[i][(j + (ten[n - i - 1] * k)%13)%13] += dp[i-1][j];
						dp[i][(j + (ten[n - i - 1] * k)%13)%13] %= mod;
					}
				}	
			}
		}else{
			int k = s[i] - '0';
			for(int j = 0; j < 13; j ++){
				if(dp[i-1][j]){
					dp[i][(j + (ten[n - i - 1] * k)%13)%13] += dp[i-1][j];
					dp[i][(j + (ten[n - i - 1] * k)%13)%13] %= mod;
				}
			}
		}
	}
	cout<<dp[n-1][5];
	return 0; 
}

Measured memory_bytes: 6224
n, m = gets.strip.split.map(&:to_i)
abc = readlines.map {|line| line.strip.split.map(&:to_i) }

graph = Array.new(n+1){ [] }
r_graph = Array.new(n+1){ [] }
edges = []
abc.each do |a, b, c|
  edges << [a,b,-c]
  graph[a] << [b, -c]
  r_graph[b] << [a, -c]
end

def reachable(s, g, graph)
  result = []
  q = [s]
  result = [s]
  until q.empty?
    c=q.shift
    graph[c].each do |nex, _|
      next if result.include?(nex)
      q << nex
      result << nex
    end
  end
  result
end

from_1 = reachable(1, n, graph)
from_n = reachable(n, 1, r_graph)
available = from_1 & from_n
edges = edges.select {|a, b, c| available.include?(a) && available.include?(b) }

INF=10**14
dist = [INF]*(n+1)
dist[1]=0
updated=false
(n).times do
  updated=false

  edges.each do |from, to, cost|
    if dist[from] != INF && dist[to] > dist[from] + cost
      dist[to] = dist[from] + cost
      updated = true
    end
  end
end

if updated
  puts 'inf'
  exit
end

#p [from_1, from_n, available]
p dist[n]*-1


Measured memory_bytes: 2300
s=list(input())
t=[]
ans='yes'
for i in range(len(s)):
    if i==0:
        t.append(s[i])
    else:
        for j in range(len(t)):
            if s[i]==t[j]:
                ans='no'
            if j==len(t)-1:
                t.append(s[i])
print(ans)
            

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include "stdc++.h"
#define llint long long int
#define ldouble long double

using namespace std;

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

    int rct=0,bct=0;

    for(int i=0;i<N;i++){
        if(s.at(i)=='R'){
            rct++;
        }
        else{
            bct++;
        }
    }

    if(rct>bct){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int n,l;
double t[3003],x,y;
inline void add(double rad,int cnt)
{
    x+=cos(rad)*cnt;
    y+=sin(rad)*cnt;
}
int main()
{
    scanf("%d%d",&n,&l);
    for(int i=0;i<n;i++) scanf("%lf",&t[i]),t[i]=t[i]/l*2*pi;
    sort(t,t+n);
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
		{
            double m1=(t[i]+t[j])/2,m2=m1+pi;
            add(m1,i+n-j-1);
            add(m2,j-i-1);
        }
    double all=1.0*n*(n-1)*(n-2)/6;
    x/=all,y/=all;
    printf("%.11f %.11f\n",x,y);
}

Measured memory_bytes: 512
#include<stdio.h>

int main(){

  int a, b, c;

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

  if(a<b){

    c = a;

    a = b;

    b = c;
  }

  while(a%b!=0){

    c = a%b;

    a = b;

    b = c;

  }

  printf("%d\n", b);

  return 0;

}

    



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

int main() {
  int a, b, X;
  cin >> a >> b;
  X = a * b % 2;
  
  if (X == 0) {
    cout << "Even" << endl;
  } 
  else {
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int,int>
#define vvi vector<vector<int> >
#define vpi vector<pii>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 998244353
#define lowbit(x) x&(-x)
#define N 55
using namespace std;
int n,m,cnt=0,num=0,dfsnum[N],low[N];
vector<int> edge[N];
void dfs(int x,int par)
{
	dfsnum[x]=++num;
	low[x]=dfsnum[x];
	for(int i=0;i<edge[x].size();i++)
	{
		if(edge[x][i]==par) continue;
		if(!dfsnum[edge[x][i]])
		{
			dfs(edge[x][i],x);
			low[x]=min(low[x],low[edge[x][i]]);
		}
		else low[x]=min(low[x],dfsnum[edge[x][i]]);
	}
	if(low[x]==dfsnum[x]) cnt++;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		edge[x].push_back(y);
		edge[y].push_back(x);
	}
	dfs(1,-1);
	cout<<cnt-1<<endl;
	return 0;
}

Measured memory_bytes: 3588
from bisect import bisect_left
N=int(input())
y=list(map(int, input().split()))
y.sort()
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bisect_left(y,tmp)-j-1
print(ans)


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

typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

using namespace std;

int main(void) {
    int n;
    cin >> n;
    int s[n];
    int w[n];  // Wの人数(左から累積和)
    int e[n];  // Eの人数(右から累積和)

    int w_count = 0;
    REP(i, n) {
        char input;
        cin >> input;
        if (input == 'W') {
            s[i] = 1;
            w_count++;
        }
        else s[i] = 0;
        w[i] = w_count;
    }

    int e_count = 0;
    for (int i = n-1; i >= 0; i--) {
        if (s[i] == 0) e_count++;
        e[i] = e_count;
    }

    int minimum = 1000000000;
    REP(i, n) {
        int cnt;
        if (i - 1 < 0) cnt = e[i+1];
        else if (i + 1 >= n) cnt = w[i-1];
        else cnt = w[i-1] + e[i+1];
        if (cnt < minimum) {
            minimum = cnt;
        }
    }

    cout << minimum << endl;

    return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define ll long long
#define p 2019
using namespace std;
int main()
{
	int l, r;
	cin >> l >> r;
	if (r - l >= p) {puts("0"); return 0;}
	ll ans = p;
	for (ll i = l; i < r; i ++) for (ll j = i + 1; j <= r; j ++) ans = min(ans, i * j % p);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int one_pair(int hand[])
{
	int i, j;
	
	for (i = 0; i < 5 - 1; i++){
		for (j = i + 1; j < 5; j++){
			if (hand[i] == hand[j]){
				return (1);
			}
		}
	}
	
	return (0);
}

int two_pair(int hand[])
{
	int i, j, k, pair[2];
	
	for (k = 0; k < 2; k++){
		for (i = 0; i < 5 - 1; i++){
			for (j = i + 1; j < 5; j++){
				if (hand[i] == hand[j] && i != pair[0] && i != pair[1] && j != pair[0] && j != pair[1]){
					pair[0] = i;
					pair[1] = j;
					
					if (k == 1){
						return (1);
					}
				}
			}
		}
	}
	
	return (0);
}

int three_card(int hand[]){
	int i, j, k;
	
	for (i = 0; i < 5 - 2; i++){
		for (j = i + 1; j < 5 - 1; j++){
			for (k = j + 1; k < 5; k++){
				if (hand[i] == hand[j] && hand[j] == hand[k]){
					return (1);
				}
			}
		}
	}
	
	return (0);
}

int straight(int hand[]){
	int i, j, hand1[5], hand2[5];
	
	for (i = 0; i < 5; i++){
		hand1[i] = hand[i];
	}
	
	for (i = 0; i < 5; i++){
		hand2[i] = hand[i];
		if (hand2[i] == 1){
			hand2[i] = 14;
		}
	}
	
	sort(hand1, hand1 + 5);
	sort(hand2, hand2 + 5);
	
	for (i = 0; i < 5 - 1; i++){
		if (hand1[i] != hand1[i + 1] - 1){
			break;
		}
	}
	
	if (i == 5 - 1){
		return (1);
	}
	
	for (i = 0; i < 5 - 1; i++){
		if (hand2[i] != hand2[i + 1] - 1){
			break;
		}
	}
	
	if (i == 5 - 1){
		return (1);
	}
	
	return (0);
}

int full_house(int hand[])
{
	int i, j, k, l, m, hand1[5];
	
	for (i = 0; i < 5; i++){
		hand1[i] = hand[i];
	}
	
	for (i = 0; i < 5 - 2; i++){
		for (j = i + 1; j < 5 - 1; j++){
			for (k = j + 1; k < 5; k++){
				if (hand1[i] == hand1[j] && hand1[j] == hand1[k]){
					hand1[i] = -1;
					hand1[j] = -2;
					hand1[k] = -3;
					for (l = 0; l < 5 - 1; l++){
						for (m = l + 1; m < 5; m++){
							if (hand1[l] == hand1[m]){
								return (1);
							}
						}
					}
				}
			}
		}
	}
	
	return (0);
}

int four_card(int hand[]){
	int i, j, k, l;
	
	for (i = 0; i < 5 - 3; i++){
		for (j = i + 1; j < 5 - 2; j++){
			for (k = j + 1; k < 5 - 1; k++){
				for (l = k + 1; l < 5; l++){
					if (hand[i] == hand[j] && hand[j] == hand[k] && hand[k] == hand[l]){
						return (1);
					}
				}
			}
		}
	}
	
	return (0);
}

void poker_hand(int hand[]){
	if (four_card(hand)) puts("four card");
	else if (full_house(hand)) puts("full house");
	else if (straight(hand)) puts("straight");
	else if (three_card(hand)) puts("three card");
	else if (two_pair(hand)) puts("two pair");
	else if (one_pair(hand)) puts("one pair");
	else puts("null");
}

int main()
{
	int hand[5];
	
	while (scanf("%d,%d,%d,%d,%d", &hand[0], &hand[1], &hand[2], &hand[3], &hand[4]) != EOF){
		poker_hand(hand);
	}
	
	return (0);
}

Measured memory_bytes: 1024
local function use_strict()
    local mt = {
        __index = function(t,k) error("_G __index:" .. k) end,
        __newindex = function(t,k,v) error("_G __newindex:" .. k) end
    }
    setmetatable(_G, mt)
end
local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local function dbgpr_t(tbl, use_pairs)
    if DBG then
        local enum = ipairs
        if use_pairs then
            enum = pairs
        end
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in enum(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

local function dbgpr_tp(tbl)
    dbgpr_t(tbl, true)
end

local function str2tbl(s)
    local t = {string.byte(s, 1, #s)}
    for i=1, #t do
        t[i] = string.char(t[i])
    end
    return t
end

--
use_strict()
local YES, NO = "YES", "NO"

local H, W, N = io.read("*n", "*n", "*n", "*l")
local sr, sc = io.read("*n", "*n", "*l")
local S = str2tbl(io.read("*l"))
local T = str2tbl(io.read("*l"))

local opposite = {
    L="R",
    R="L",
    D="U",
    U="D"
}

local function solve(size, move_lower, init_pos)
    local direc = move_lower == "L" and "horiz" or "verti"
    local move_upper = opposite[move_lower]
    -- Aoki wins when position p satisfies lower_bound <= p <= upper_bound
    local lower_bound = 1
    local upper_bound = size
    local math_max = math.max
    local math_min = math.min
    for n=N,1,-1 do
        if T[n] == move_lower then
            upper_bound = math_min(upper_bound + 1, size)
        elseif T[n] == move_upper then
            lower_bound = math_max(lower_bound - 1, 1)
        end
        if S[n] == move_lower then
            lower_bound = lower_bound + 1
        elseif S[n] == move_upper then
            upper_bound = upper_bound - 1
        end
        if lower_bound > size then
            return NO
        end
        if upper_bound < 1 then
            return NO
        end
        if lower_bound > upper_bound then
            return NO
        end
        dbgpr(direc, n, S[n], T[n], lower_bound, upper_bound)
    end
    if lower_bound <= init_pos and init_pos <= upper_bound then
        return YES
    else
        return NO
    end
end

local horiz_ans = solve(W, "L", sc)
dbgpr("horiz", horiz_ans)
if horiz_ans == NO then
    print(NO)
    return
end
local vert_ans = solve(H, "U", sr)
dbgpr("vert", vert_ans)
if vert_ans == NO then
    print(NO)
    return
end
print(YES)


Measured memory_bytes: 13900
// -*- coding:utf-8-unix -*-

use proconio::input;

// v[i] >= k を満たす最小の i
fn lower_bound(v: &[u32], k: u32) -> usize {
    let mut low = 0;
    let mut high = v.len();

    while low < high {
        let mid = (low + high) / 2;
        if v[mid] < k {
            low = mid + 1;
        } else {
            high = mid;
        }
    }
    low
}

fn main() {
    input! {
        n: usize,
        mut l: [u32; n],
    }

    l.sort();
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            // let k = lower_bound(&l, l[i] + l[j]);
            // ans += k - (j + 1);
            let k = lower_bound(&l[j + 1..], l[i] + l[j]);
            ans += k;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int b[n],max=2147483647,sum=0;
	for(int i=0;i<n-1;i++)cin>>b[i];
	sum+=min(max,b[0]);
	sum+=min(max,b[n-2]);
	for(int i=0;i<n-2;i++)sum+=min(b[i],b[i+1]);
	cout<<sum<<'\n';
} 

Measured memory_bytes: 256
#include <iostream>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
using namespace std;

//Write your function here!



int main()
{
	int N, A;
	cin >> N >> A;
	int ans = 0;
	for (int i = 1;i < A;i++) {
		if (1 + i * (N - 1) >= A) {
			ans = i;
          break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y,z;
};
Point operator-(const Point& a,const Point& b)
{
  Point ret={a.x-b.x,a.y-b.y,a.z-b.z};
  return ret;
}
double dot(Point a,Point b)
{
  return a.x*b.x+a.y*b.y+a.z*b.z;
}
Point cross(Point a,Point b)
{
  Point ret={a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x};
  return ret;
}
double norm(Point a)
{
  return a.x*a.x+a.y*a.y+a.z*a.z;
}

typedef pair<int,int> P;
int n,w,d;

class cake
{
public:
  int w,h,squ;
  cake(){};
  cake(int w,int h): w(w),h(h),squ(w*h){}
  bool operator < (const cake &you) const {return squ<you.squ;};
};
int area(const cake &tmp) {return tmp.w*tmp.h;};
int main(int argc,char const* argv[])
{
  while(cin >> n >> w >> d && (n!=0 || w!=0 || d!=0))
    {
      vector<cake> c;
      c.push_back(cake(w,d));
      int lastindex=0;
      for(int i=0;i<n;i++)
	{
	  lastindex++;
	  int id,s;
	  cin >> id >> s;
	  id--;
	  int width=c[id].w;
	  int height=c[id].h;
	  s%=(c[id].w*2+c[id].h*2);
	  cake c1,c2;
	  if(s>0 && s<width) 
	    {
	      c1=cake(s,height);
	      c2=cake(width-s,height);
        
	    }
	  else if(s>width && s<(width+height))
	    {
		  c1=cake(width,s-width);
		  c2=cake(width,height-(s-width));
	    }
	  else if(s>(width+height) && s<(2*width+height))
	    {
		  c1=cake(width-(s-width-height),height);
		  c2=cake(s-width-height,height);
	    }
	  else if(s>(2*width+height))
	    {
		  c1=cake(width,s-2*width-height);
		  c2=cake(width,height-(s-2*width-height));
	    }
	  c.erase(c.begin()+id);
	  if(area(c1)<area(c2))
	    {
	      c.push_back(c1);
	      c.push_back(c2);
	    }
	  else
	    {
	      c.push_back(c2);
	      c.push_back(c1);
	    }
	}
      sort(c.begin(),c.end());
	for(int i=0;i<c.size();i++)
	  {
	    if(i) cout << ' ';
	    cout << c[i].squ;
	  }
      cout << endl;
    }
  return 0;
}



Measured memory_bytes: 3084
#include<cstdio>
int main(void){
	int ww;
	int n;
	int a[1001][1001];
	int w[1001];
	int p[1001];
	int max;
	int mm;
	for (int tt=1;;tt++){
		scanf("%d", &ww);
		if (ww == 0)break;
		scanf("%d", &n);
		for (int i = 0; i<1001; i++){
for(int j=0;j<1001;j++){
a[i][j]=0;
}
}
		for (int i = 1; i <= n; i++){
			scanf("%d,%d", &p[i], &w[i]);
for(int j=0;j<w[i];j++){
a[i][j]=a[i-1][j];
}
			for (int j = w[i]; j <= ww; j++){
				if (a[i - 1][j] > a[i - 1][j - w[i]] + p[i]){
					a[i][j] = a[i - 1][j];
				}
				else{
					a[i][j] = a[i - 1][j - w[i]] + p[i];
				}
			}
		}
		max = 0;
		mm = 0;
		for (int i = 0; i <= ww; i++){
			if (max < a[n][i]){
				max = a[n][i];
				mm = i;
			}
		}
		printf("Case %d:\n%d\n%d\n", tt, max, mm);
	}
}

Measured memory_bytes: 6592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    ll D, T, S;
    cin >> D >> T >> S;
    long double ans = (long double)(D)/(long double)(S);
    //cout << (long double)(ans);
    if((long double)(ans) <= (long double)(T))cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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


int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a >= k)cout << k << endl;;
    if(a < k && k <= (a+b))cout << a << endl;
    if(k > a+b)cout << a - (k - a -b) << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main() {
  int K;
  int sum=0;
  cin>>K;
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        sum+=gcd(a,gcd(b,c));
        
      }
    }
  }
	cout<<sum<<endl;
}


Measured memory_bytes: 3588
# N, X = map(int, input().split())
#
# LLL = list(map(int, input().split()))  # 長さN
#
# d = [0]
# for i in range(len(LLL)):
#     d.append(d[-1]+LLL[i])
#
# hoge = 0
# for i in range(1, len(d)):
#     if X >= d[i]:
#         hoge += 1
#     else:
#         print(hoge)
#         exit()

N, X = map(int, input().split())

LLL = list(map(int, input().split()))  # 長さN

d = [0]
for i in range(len(LLL)):
    d.append(d[-1]+LLL[i])

for i in range(1, len(d)):
    if d[i] > X:
        print(i)
        exit()

print(N+1)


Measured memory_bytes: 3060
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

ll f(ll a, ll b) {
	ll ar = 0; ll br =0;
	while(a > 0) {
		ar+=1;
		a/=10;
	}

	while(b > 0) {
		br += 1;
		b/=10;
	}
	// cout << a << " " <<  b << " " << ar << " " << br << endl;
	return max(ar,br);
}

int main() {
	ll N; cin >> N;
	ll ans = 10e5;
	for(ll i = 1; i * i <= N; i++) {
		if(N % i != 0) continue;
        ans = min(ans, f(i, N/i));
	}
	cout << ans << endl;
	
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <unistd.h>
#include <bits/stdc++.h>

#define pii pair<int,int>
#define REP(i, n) for (long long i = 0; i < (n); i++) 
using namespace std;

using Graph = vector<vector<int>>;

vector< vector< pair<int,int> > > v(100010);	
int V[100010] = {0};
int X[100010] = {0};
typedef long long ll;
static const ll INF = 1000000000000000000LL;
static const ll MOD = 1000000007;

ll N,A,B;

bool isOK(ll i, vector <ll> h)
{
    ll kai = 0;
    // i で達成できるか
    ll zenin = B * i;
    REP(i, N)
    {
        ll zan = h[i] - zenin;
        if(zan <= 0)break;
        kai += (zan - 1)/ (A-B) + 1;
    }

    if(kai <= i)return true;
    else return false;
}

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

    vector<ll> h(N);
    REP(i,N)cin >> h[i];

    sort(h.rbegin(), h.rend());
    ll zenin = 0;

    //1から10^5の二分探索

    ll l = 0;
    ll r = 1000000000;
    while(l + 1 < r)
    {
        ll m = (l + r) / 2;

        if(isOK(m, h))
        {
            //cout << m << endl;
            r = m;
        }
        else l = m;

    }
    ll res = r;

    cout << res << endl;

    return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	ll n;
	cin>>n;
	repi(i,1,50000){
		if(floor(i*1.08)==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}

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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var B = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var C = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            Array.Sort(A);
            Array.Sort(B);
            Array.Sort(C);
            long sum=0;
            
            for(var b=0;b<N;b++){
                long count_a = UpperBound(A,B[b]-1);
                long count_c = N-LowerBound(C,B[b]+1);
                sum += count_a*count_c;
            }
            System.Console.WriteLine(sum);
        }

        public static int UpperBound<T>(T[] a, T v){ 
            return UpperBound(a, v, Comparer<T>.Default);
        }
        public static int UpperBound<T>(T[] a, T v,Comparer<T> cmp){
            var l=0;
            var r=a.Length -1;
            while(l<=r){
                var mid = l+(r-l)/2;
                var res = cmp.Compare(a[mid],v);
                if(res<=0) l = mid+1;
                else r = mid-1;
            }
            return l;
        }


        public static int LowerBound<T>(T[] a, T v){ 
            return LowerBound(a, v, Comparer<T>.Default);
        }
       public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp){
            var l = 0;
            var r = a.Length - 1;
            while (l <= r){
            var mid = l + (r - l) / 2;
            var res = cmp.Compare(a[mid], v);
            if (res == -1) l = mid + 1;
            else r = mid - 1;
        }
        return l;
        }
    }
}


Measured memory_bytes: 45972
import java.util.*;

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 = sc.nextInt();
        
        boolean all  = ((a == b) && (b == c));
        boolean all_not = ((a != b) && (a != c) && (b != c));
        
        if(all || all_not) System.out.println("No");
        else System.out.println("Yes");
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int d[40320],f,l,i,j,k;
char Q[50000][9];

int h(char n[8])
{
	char c[8];
	int f[8]={5040,720,120,24,6,2,1,0},i,j,v= 0;
	memcpy(c,n,8);
	for(i=0;i<7;i++){
		v += f[i] * (c[i]-'0');
		for(j=i+1;j<8;j++){
		if(c[i]<c[j])c[j]--;
		}
	}
	return v;
}

void enq(char s[9])
{
	strcpy(Q[l++],s);
}

int main()
{
	int m[4]={1,4,-4,-1};
	char s[9]={48,49,50,51,52,53,54,55,0},c[18],w[9],t;
	memset(d,-1,sizeof(d));
	d[h("01234567")]=0;
	enq(s);
	while(l!=f)
	{
		strcpy(s,Q[f++]);
		strcpy(w,s);
		for(i=0;i<8;i++)
			if(s[i]=='0')
				break;
		if(i==3)
			j=1,k=4;
		else if(i==4)
			j=0,k=3;
		else
			j=0,k=4;
		for(;j<k;j++)
			if(i+m[j]>=0&&i+m[j]<8)
			{
				t=s[i+m[j]];
				s[i+m[j]]=s[i];
				s[i]=t;
				int x=h(s);
				int y=h(w);
				if(d[x]==-1||d[x]>d[y]+1)
				{
					d[x]=d[y]+1;
					enq(s);
				}
				strcpy(s,w);
			}
	}
	while((c[0]=getchar())!=-1)
	{
		for(i=1;i<16;i++)
			c[i]=getchar();
		for(i=0,j=0;i<8;i++,j+=2)
			s[i]=c[j];
		printf("%d\n",d[h(s)]);
	}
	return 0;
}

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

int main(){
	
	int time, h;
	string str, a, b;
	
	
	while(1){
		
		cin >> str;
		if(str == "-") break;
		
		cin >> time;
		
		
		for(int i = 0; i < time; ++i){
			cin >> h;
			
			a = str.substr(0, h);
			b = str.substr(h);
			str = b + a;
		}
		
		cout << str << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1216
a=int(input())
b=int(input())
c=int(input())
x=int(input())
x=int(x/50)
p=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 10*i + 2*j + k == x:
                p=p+1


print(p)



Measured memory_bytes: 3060
x=int(input())
if 400<=x<=599:
  print(8)
elif 600<=x<=799:
  print(7)
elif 800<=x<=999:
  print(6)
elif 1000<=x<=1199:
  print(5)
elif 1200<=x<=1399:
  print(4)
elif 1400<=x<=1599:
  print(3)
elif 1600<=x<=1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 9188
sa = list(input())
sb = list(input())
sc = list(input())
sa += ['A']
sb += ['B']
sc += ['C']
k = 'a'
while True:
    if k == 'a':
        if len(sa) == 1:
            print(sa[0])
            exit()
        s = sa.pop(0)
        k = s
    if k == 'b':
        if len(sb) == 1:
            print(sb[0])
            exit()
        s = sb.pop(0)
        k = s
    if k == 'c':
        if len(sc)==1:
            print(sc[0])
            exit()
        s = sc.pop(0)
        k = s

Measured memory_bytes: 3064
N, W = [int(i) for i in input().split()]
V = [[int(i) for i in input().split()] for j in range(N)]

DP = [0] * (W+1)
V.sort(key=lambda x: x[1])

for w, v in V:
    for i in range(W, -1, -1):
        if w > i:
            break
        DP[i] = max(DP[i], DP[i-w] + v)

print(DP[W])

Measured memory_bytes: 43740
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ll long long
 
int main(){
  ll int n,m,ans=0,w=0;
  scanf("%lld %lld",&n,&m);
  ll int s[m],c[m];
  for(ll int i=0;i<m;i++){
  scanf("%lld %lld",&s[i],&c[i]);
  }
 
  if(n==1 && m==0){
    printf("0");
    return 0;
  }
  
  for(int i=0;i<m;i++){
    if(c[i]!=0){
      w++;
    }
  }
  
  if(w==0 && n==1){
    printf("0");
    return 0;
  }
  
  if((s[0]==s[1] && c[0]!=c[1])||(s[0]==s[2] && c[0]!=c[2]) || (s[0]==s[3] && c[0]!=c[3])|| (s[0]==s[4] && c[0]!=c[4])|| (s[1]==s[2] && c[1]!=c[2])|| (s[1]==s[3] && c[1]!=c[3])|| (s[1]==s[4] && c[1]!=c[4])|| (s[2]==s[3] && c[2]!=c[3])|| (s[2]==s[4] && c[2]!=c[4])|| (s[4]==s[3] && c[4]!=c[3])){
    printf("-1");
    return 0;
  }
  
  for(ll int i=0;i<m;i++){
  if(s[i]==1 && c[i]==0){
    printf("-1");
    return 0;
  }
  }
  
 ll int sum[m];
  for(ll int i=0;i<m;i++){
    sum[i]=c[i]*pow(10,n-s[i]);
  }
  
  ll int compare(const void *a, const void *b){
  return (*(ll int *)a)- (*(ll int *)b);
}
 
qsort(sum,m,sizeof(ll int),compare);
for(ll int i=0;i<m;i++){
  if(sum[i]!=sum[i+1]){
    ans+=sum[i];
  }
}
 
  if(ans<pow(10,n-1)){
    ans+=pow(10,n-1);
  }
  
  printf("%lld",ans);
  
  return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  ll N,M;cin>>N>>M;
  vl a(M);rep(i,M)cin>>a[i];
  vl b(M+1);if(M>=1){b[0]=a[0]-1;b[M]=N-a[M-1]-1;f(i,1,M)b[i]=a[i]-a[i-1]-2;}
  else b[0]=N;//段差の数
  sort(all(b));
  if(b[0]<0)cout<<0<<endl;
  else{
    vl dp(N+10);//MOD
    dp[0]=1;dp[1]=1;dp[2]=2;
  
    f(i,1,N){
      dp[i+2]=(dp[i+1]%MOD+dp[i]%MOD)%MOD;
    }
    ll ans=1;
    rep(i,M+1){
      ans *=dp[b[i]];
      ans %= MOD;
    }
    cout<<ans<<endl;
  }
  
}





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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; i++) cin >> s[i];

    int cnt = 0;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '.') cnt++;
        }
    }

    queue<pii> q;
    pii g (h-1, w-1);
    q.push(pii(0,0));
    int stp = -1;
    for (int i = 1; 1; i++) {
        int j = q.size();
        for (int k = 0; k < j; k++) {
            if (q.front() == g) {
                stp = i;
                break;
            }
            int a = q.front().first;
            int b = q.front().second;
            q.pop();
            if (s[a][b] != '.') continue;
            s[a][b] = ':';
            if (a > 0)   q.push(pii(a-1, b));
            if (a < h-1) q.push(pii(a+1, b));
            if (b > 0)   q.push(pii(a, b-1));
            if (b < w-1) q.push(pii(a, b+1));
        }
        if (stp >= 0) break;
        if (q.empty()) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << cnt - stp << endl;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long int a,b,c;
  cin>>a>>b>>c;
  
  if((c-a-b)*(c-a-b)>4*a*b && c-a-b>0){
    cout<<"Yes";
  }else{
    cout<<"No";
  }



}

Measured memory_bytes: 256
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
//*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll ans = 5e18;
ll a[maxn];
ll mn[maxn];
ll x;
int n;

ll sum(){
    ll sum = 0;
    for(int i = 0 ; i < n ; i ++)
        sum += mn[i];
    return(sum);
}

int32_t main(){
    migmig
    cin >> n >> x;
    for(int i = 0 ; i < n ; i ++)
        cin >> a[i] , mn[i] = a[i];
    ans = sum();
    for(ll i = 0 ; i < n ; i ++){
        ans = min(ans , sum() + x*i);
        for(int j = 0 ; j < n ; j ++)   
            mn[j] = min(mn[j], a[((j-i-1)+n)%n]);
    }
    cout << ans;
    return(0);
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define EPS 0.0000000001
#define pb push_back
#define space " "
#define ar array
#define pi pair<int,int>
#define ff first
#define ss second

void solve() {
    int n;
    int maxN = 1000000;
    cin >> n;
    bool pairwise = true;
    bool setwise = true;
    vector<int> a(n), f(maxN + 1, 0), s(maxN + 1, 1);
    vector<int> primes;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        f[a[i]]++;
        if ((a[i] != 1) && (f[a[i]] > 1)) {
            pairwise = false;
        }
    }
    int g = a[0];
    for (int i = 1; i < n; i++) {
        g = __gcd(a[i], g);
    }
    if (g != 1) setwise = false;

    if (pairwise) {
        s[0] = 0;
        s[1] = 0;
        for (int i = 2; i <= maxN; i++) {
            if (s[i] == 1) {
                primes.push_back(i);
                for (ll j = i * 1ll * i; j <= maxN; j += i) {
                    s[j] = 0;
                }
            }
        }
        for (auto p : primes) {
            int cnt = 0;
            for (int i = p; i <= maxN; i += p) {
                if (f[i] > 0) cnt++;
                if (cnt > 1) {
                    pairwise = false;
                }
            }
            if (!pairwise) {
                break;
            }
        }


    }
    if (pairwise) {
        cout << "pairwise coprime" << endl;
    } else if (setwise) {
        cout << "setwise coprime " << endl;
    } else {
        cout << "not coprime" << endl;
    }
}

int main() {
//    freopen("input.txt" , "r" , stdin) ;
//    freopen("output.txt" , "w" , stdout) ;
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 15368
#include<bits/stdc++.h>
using namespace std; 
using lint =                            long long int;
using plint =                           pair<lint, lint>;
#define vli                             vector<lint>
#define pb                              push_back
#define ALL(x)                          begin(x),end(x)
#define inf                             (1LL<63)-1
#define MOD 1000000007
#define SZ(x)                           ((lint)(x).size())
#define                                 FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define                                 IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define                                 REP(i, n) FOR(i,0,n)
#define                                 IREP(i, n) IFOR(i,0,n)
#define                                 f_ip   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define                                 debug(x) cerr << #x << " " << (x) << endl
struct fast_ios                         { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T>                    istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T>                    bool mmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T>                    bool mmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }


/* -------
         |
    **   |
   -------      
   |
   ---------------------------------------------------------------------------------------------------------------------------------*/

void solve(){  
  lint A;
  cin>>A;
  lint B;
  cin>>B;
  lint K;   
  cin>>K;
  lint T = min(A,K);
  A -= T;
  K -= T;
  lint AOKI = min(B,K);
  B -= AOKI;
  cout <<A <<" " << B << endl;
}

int main(){   
  
 solve();

 return 0;
}


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

void solve(int TestCase) {
    long long n, k;
    cin >> n >> k;

    n %= k;
    long long ret = min(n, k - n);
    cout << ret << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
    //    cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ARB ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define bp  __builtin_popcount
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;
const  double EPS = 1e-14;
int main()
{
    ARB
    ll n;
    cin >> n;
    map<string, ll> mp;
	for(int i =0; i<n; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	ll ans = 0;
	for(auto &it:mp)
	{
		ll cur = it.second;
		ans += 1LL*((cur*(cur - 1))/2);
	}
	cout << ans;
}


Measured memory_bytes: 11264
#include <iostream>
#include <cmath>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pdd pair<double, double>
#define mp make_pair

double dis(pdd a, pdd b)
{
	pdd x = mp(a.first - b.first, a.second - b.second);
	return sqrt(x.first * x.first + x.second * x.second);
}

pdd find(pdd a, pdd b)
{
	pdd v = mp(a.first - b.first, a.second - b.second);
	double d = sqrt(v.first * v.first + v.second * v.second);
	// double d = dis(a, b);
	if (d > 2.0) return mp(1000, 1000);
	// pdd o = mp(a.first + 0.5 * v.first, a.second + 0.5 * v.second);
	pdd o = mp((a.first + b.first) / 2.0, (a.second + b.second) / 2.0);
	pdd g = mp(v.second, - v.first);
	double s = sqrt(1.0 - d * d / 4.0);
	// double g_size = sqrt(g.first * g.first + g.second * g.second);
	double g_size = d;
	pdd ret = mp(o.first + g.first / g_size * s, o.second + g.second / g_size * s);
	return ret;
}

int main(void)
{
	while(1) {
		int n;
		cin >> n;
		if (n == 0) break;
		vec<pdd> a(n);
		rep(i, n) cin >> a[i].first >> a[i].second;
		if (n == 1) {
			cout << 1 << endl;
			continue;
		}

		int MAX = 0;
		rep(i, n) rep(j, n) {
			if (i == j) continue;
			pdd c = find(a[i], a[j]);
			// cout << i << " " << j << " " << c.first << " " << c.second << endl;

			int p = 0;
			if (c.first == 1000) p = 1;
			else {
					rep(k, n) {
					// cout << dis(a[k], c) << " ";
					if (dis(a[k], c) <= 1.0001) p++;
				}
			}
			// cout << p << endl;
			MAX = max(p, MAX);
		}

		cout << MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include <stdio.h>
int main(void){
  long long int x,y;
  long long int ans=0;
  scanf("%lld %lld",&x,&y);
  while(1){
    ans++;
    if(x*2 > y){
      break;
    }
    x *= 2;
  }
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 128
N, M = map(int,input().split())
H = list(map(int,input().split()))
MAX = [0 for _ in range(N)]
for _ in range(M):
    a, b = map(int,input().split())
    MAX[a-1] = max(MAX[a-1],H[b-1])
    MAX[b-1] = max(MAX[b-1],H[a-1])

ans = 0
for i in range(N):
    if H[i] > MAX[i]:
        ans += 1

print(ans)



Measured memory_bytes: 19972
H, W, K = map(int, input().split())
cake = [input() for i in range(H)]
ans = [[0 for i in range(W)] for j in range(H)]

first_found = False
count = 0
for h in range(H):
    if '#' in cake[h]:
        count += 1
        for w in range(W):
            ans[h][w] = count
            if cake[h][w] == '#' and '#' in cake[h][w+1:]:
                count += 1

        if not first_found:
            first_found = True
            for i in range(h):
                ans[i] = ans[h]
    elif first_found:
        ans[h] = ans[h-1]

for h in range(H):
    print(' '.join(map(str, ans[h])))


Measured memory_bytes: 7284