akhauriyash/Code-Regression huggingface dataset:
/*
created on 21/4/2020
*/
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
int const mxlen = (1e5) + 5;
lli dp[mxlen];
lli v[105];
lli w[105];
int n, W;
lli memo[105][mxlen];
lli findans(int pos, int wt){
  if(pos == n && wt<=W){
    return 0;
  }
  if(wt>=W)
    return -1e18;
  if(memo[pos][wt]!=-1)
    return memo[pos][wt];
  memo[pos][wt] = max(findans(pos+1, wt+w[pos]) + v[pos], findans(pos+1, wt));
  return memo[pos][wt];
}
void solve(){
  cin>>n>>W;
  for(int i=0;i<n;i++){
    cin>>w[i]>>v[i];
  }
  memset(memo, -1, sizeof memo);
  lli ans = findans(0, 0);
  cout<<ans<<endl;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> X(N), Y(N), H(N);
    rep(i, N) cin >> X[i] >> Y[i] >> H[i];

    ll basei;
    for(ll i=0; i<N; i++) {
        if(H[i] > 0) {
            basei = i;
            break;
        }
    }

    ll resx, resy;
    for(ll x=0; x<=100; x++) {
        for(ll y=0; y<=100; y++) {
            bool f = true;
            bool zf = true;
            for(ll n=0; n<N; n++) {
                if(n == basei) continue;
                ll cb = H[basei]+abs(X[basei]-x)+abs(Y[basei]-y);
                ll now = H[n]+abs(X[n]-x)+abs(Y[n]-y);
                if(H[n] > 0 && cb != now) {
                    f = false;
                    break;
                }
                if(H[n] > 0) zf = false;
            }
            if(f) {
                ll resh;
                if(!zf) {
                    resx = x;
                    resy = y;
                    resh = H[basei]+abs(X[basei]-resx)+abs(Y[basei]-resy);
                } else {
                    resx = X[basei];
                    resy = Y[basei];
                    resh = H[basei];
                }
                cout << resx << " " << resy << " " << resh << endl;
                return 0;
            }   
        }
    }

    return 0;   
    
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#define vi vector<int>
#define vb vector<bool>
#define lli long long int
#define vvi vector<vector<int>>
#define loop(n) for (int i = 0; i < n; i++)
using namespace std;

auto SpeedUp = []() {
    std::ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

int solve()
{
    int n;
    cin >> n;
    vi arr(n, 0);
    loop(n) cin >> arr[i];

    vi dp(n, 0);
    dp[n - 2] = abs(arr[n - 2] - arr[n - 1]);
    for (int i = n - 3; i >= 0; i--)
    {
        dp[i] =  min(dp[i + 1] + abs(arr[i + 1] - arr[i]),dp[i+2]+abs(arr[i+2]-arr[i]));
    }

    // for(int ele :dp)
    //     cout << ele << " ";
    return dp[0];
}

int main()
{
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int solve(vector<int> &v,int n,int k)
{
    long long dp[n+2][k+2];
    for(int j = 0;j <= k;j++)
        dp[1][j] = (j > v[1]) ? 0:1;
    for(int i = 2;i <= n;i++)
    {
        for(int j = 0;j <= k;j++)
        {
            if(j == 0)
                dp[i][j] = dp[i-1][j];
            else
                dp[i][j] = (1000000007 + dp[i][j-1] + dp[i-1][j] - ((j-v[i] - 1 >= 0) ? dp[i-1][j-v[i] - 1] : 0))%1000000007;
        }
    }
    return dp[n][k];
}
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> v(n+1);
    for(int i = 1;i <=n;i++)
        cin>>v[i];
    cout<<solve(v,n,k);
    return 0;
}

Measured memory_bytes: 81520
#include <stdio.h>

const int Mod = 998244353;

void add_BIT(int N, long long BIT[], int i, long long k)
{
	while (i <= N) {
		BIT[i] = (BIT[i] + k) % Mod;
		i += (i & -i);
	}
}

long long sum_BIT(long long BIT[], int r)
{
	long long sum = 0;
	while (r > 0) {
		sum = (sum + BIT[r]) % Mod;
		r -= (r & -r);
	}
	return sum;
}

int main()
{
	int i, N, K, L[11], R[11];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= K; i++) scanf("%d %d", &(L[i]), &(R[i]));
	
	int j;
	long long BIT[200001] = {}, dp[200001] = {0, 1};
	add_BIT(N, BIT, 1, 1);
	for (i = 2; i <= N; i++) {
		for (j = 1; j <= K; j++) {
			if (L[j] < i) {
				dp[i] += sum_BIT(BIT, i - L[j]);
				if (R[j] < i) dp[i] += Mod - sum_BIT(BIT, i - R[j] - 1);
			}
		}
		dp[i] %= Mod;
		add_BIT(N, BIT, i, dp[i]);
	}
	printf("%lld\n", dp[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 4860
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

const int N = 1001;

struct point{ int x, y; };
static const int dy[6] = {0,1,1,0,-1,-1};
static const int dx[6] = {1,1,0,-1,-1,0};

int bfs(bool *M, int x, int y, int t){
    int temp[N * N];
    int *dis = temp + (N / 2 * N + N / 2);

    queue<point> q;
    rep(i, N * N) temp[i] = INF;
    point start_coordinate = {x, y};

    dis[start_coordinate.y * N + start_coordinate.x] = 0;
    q.push(start_coordinate);

    point u;
    while(!q.empty()){
        u = q.front(); q.pop();
        rep(i,6){
            point next;
            next.x = u.x + dx[i];
            next.y = u.y + dy[i];
            if(next.y >= -1 * N / 2 && next.y <= N / 2 && next.x >= -1 * N / 2 && next.x <= N / 2){
                if(dis[next.y * N + next.x] == INF && M[next.y * N + next.x] == 0){
                    dis[next.y * N + next.x] = dis[u.y * N + u.x] + 1;
                    //cout << next.x <<' '<<next.y<< endl;
                    q.push(next);
                }
            }
        }
    }

    int cnt = 0;
    rep(i, N * N){
        if(temp[i] <= t) cnt++;
    }
    return cnt;
}

int main(){
    int t, n, sx, sy;
    while(cin >> t >> n, t||n){
        bool M[N * N] = {0};
        bool *atl = M + (N / 2 * N + N / 2);
        rep(i,n){
            int x, y;
            cin >> x >> y;
            atl[y * N + x] = 1;
        }
        cin >> sx >> sy;
        cout << bfs(atl, sx, sy, t) << endl;
    }
}

Measured memory_bytes: 8048
//package atcoder;
 
import java.util.*;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		//int n = 0;
		if(N<10) {
			//int n = N;
			if(N==3) {
				System.out.println("bon");
			}
			if(N==0||N==1||N==6||N==8) {
				System.out.println("pon");
			}
			if(N==2||N==4||N==5||N==9||N==7) {
				System.out.println("hon");
			}
		}
		if(9<N) {
			int n = N%10;
			if(n==3) {
				System.out.println("bon");
			}
			if(n==0||n==1||n==6||n==8) {
				System.out.println("pon");
			}
			if(n==2||n==4||n==5||n==9) {
				System.out.println("hon");
			}
		}
		
		/*if(n==3) {
			System.out.println("bon");
		}
		if(n==0||n==1||n==6||n==8) {
			System.out.println("pon");
		}
		if(n==2||n==4||n==5||n==9) {
			System.out.println("hon");
		}*/
		
	}
}

Measured memory_bytes: 35696
def do():
    n=int(input())
    s="abcdefghijklmnopqrstuvwxyz"
    s1=""
    if n<=26:
        return s[n-1]
    else:
        while n>26:
            k=n%26
            n=n//26
            if k==0:
                s1+='z'
                n=n-1
            else:
                s1+=s[k-1]
        s1+=s[n-1]
        s1=s1[::-1]
        return s1
print(do())

Measured memory_bytes: 9108
#!/usr/bin/env python3
n=int(input())
w=[input() for i in range(n)]
flug=1
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        flug=0
for i in range(n-1):
    for j in range(i+1,n):
        if w[i]==w[j]:
            flug=0
print('Yes' if flug else 'No')
    

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }
template<class T>
inline T upper(T a, T b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int cnt[1009];

int main() {
	int n;
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int _i = i;
		for (int j = 2; _i > 1; ++j) {
			while (_i % j == 0) ++cnt[j], _i /= j;
		}
	}
	ll ans = 1;
	for (int i = 1; i <= n; ++i) ans = ans * (cnt[i] + 1) % mod;
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
"""import sys
input = sys.stdin.readline().strip"""
n=int(input())
T=[int(input()) for _ in range(n)]
if n==1:
    print(T[0])
    exit()
from fractions import gcd
ans=T[0]*T[1]//gcd(T[0],T[1])
for t in T:
    ans=ans*t//gcd(ans,t)
print(ans)


Measured memory_bytes: 64364
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(){
    int N;
    cin >> N;
    vector<int> T(N), X(N), Y(N);
    for(int i = 0; i < N; i++) cin >> T[i] >> X[i] >> Y[i];
    bool ok = true;
    for(int i = 0; i < N; i++){
        if(i == 0){
            int dist = X[i] + Y[i];
            if(dist <= T[i] and (T[i] - dist) % 2 == 0) continue;
                ok = false;
                break;
        }else{
            int dist = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);
            if(dist <= (T[i] - T[i - 1]) and ((T[i] - T[i - 1]) - dist) % 2 == 0) continue;
                ok = false;
                break;
        }
    }
    if(ok) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 4184
n, t = map(int, input().split())
aas = list(map(int, input().split()))
maxs = [0]*n
max_a = aas[-1]
for i in reversed(range(n)):
    maxs[i] = max_a
    if aas[i] > max_a:
        max_a = aas[i]
difs = [0]*n
for i in range(n):
    difs[i] = maxs[i] - aas[i]
print(difs.count(max(difs)))

Measured memory_bytes: 20508
#include <bits/stdc++.h>
#define  rep(i,a,b)for(int i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const int INF=1000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;

int main() {
	int t=0,h,w;
	char s[55][55];
	cin>>h>>w;
	rep(i,0,h){
		rep(j,0,w){
			cin>>s[i][j];
			if(s[i][j]=='.')++t;
		}
	}
	int kx[4]={0,0,1,-1},ky[4]={1,-1,0,0};
	queue<Pa> que;
	int c[55][55];
	rep(i,0,55){
		rep(j,0,55)c[i][j]=INF;
	}
	que.push(Pa(0,P(0,0)));
	while(!que.empty()){
		Pa pa=que.front();que.pop();
		int cost=pa.first,y=pa.second.first,x=pa.second.second;
		if(c[y][x]<=cost)continue;
		c[y][x]=cost;
		rep(i,0,4){
			if(y+ky[i]>=0&&y+ky[i]<h&&x+kx[i]>=0&&x+kx[i]<w&&s[y+ky[i]][x+kx[i]]=='.'){
				que.push(Pa(cost+1,P(y+ky[i],x+kx[i])));
			}
		}
	}
	if(c[h-1][w-1]==INF)cout<<-1<<endl;
	else cout<<t-c[h-1][w-1]-1<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using static System.Math;
using Number = System.Int32;

namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var a = Enumerate(4, x => ri).OrderBy(x => x).ToArray();
			a[0] += a[3];
			a[1] += a[2];
			Console.WriteLine(Abs(a[0] - a[1]));

		}

		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		//* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//*/
		// solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion



Measured memory_bytes: 19876
#include<iostream> 
using namespace std; 
int main(){
    int a,b,c;
    cin >> a;
    cin >> b;
    cin >> c;
    if(a>=b&&b>=c){
        cout << c <<" "<< b <<" "<< a << endl;
    }else if(b<=a&&a<=c){
        cout << b <<" "<< a <<" "<< c << endl;
    }else if(c<=a&&a<=b){
        cout << c <<" "<< a <<" "<< b << endl;
    }else if(a<=c&&c<=b){
        cout << a <<" "<< c <<" "<< b << endl;
    }else if(a<=b&&b<=c){
        cout << a <<" "<< b <<" "<< c << endl;
    }else if(b<=c&&c<=a){
        cout << b <<" "<< c <<" "<< a << endl;    
    }return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
/*ABC 136 B*/

int main(void)
{
  int N;
  int count = 0;

  scanf("%d", &N);
  if (N < 10) {
    count = N;
  }else if(N < 100){
    count = 9;
  }else if(N < 1000){
    count = N-99+9;
  }else if (N < 10000) {
    count = 9 + ( 999 - 100 + 1);
  }else if (N < 100000) {
    count = N-9999 + (9 + (999 - 100 + 1));
  }else{
      count = N-9999 + (9 + (999 - 100 + 1))-1;
  }

  printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 128
/*
[ ( ^ _ ^ ) ]
*/
// problem: atc/abc167_b
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1000000000



int main() {
    ll a, b, c, k;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);
    ll rs = min(a, k);
    k -= min(a, k);
    rs += 0*min(b, k);
    k -= min(b, k);
    rs += -1*min(c, k);
    k -= min(c, k);
    assert(k==0);
    printf("%lld\n", rs);
}


Measured memory_bytes: 3760
S = input()
if S == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
    exit()

usable = [not a in S for a in "abcdefghijklmnopqrstuvwxyz"]

for i in range(len(usable)):
    if usable[i]:
        print(S + chr(ord('a') +i))
        exit()
else:
    while True:
        poped_char = S[-1]
        usable[ord(poped_char) - ord('a')] = True
        S = S[:-1]
        # print(S, poped_char, usable)
        for i in range(ord(poped_char)-ord('a')+1,len(usable)):
            if usable[i]:
                print(S + chr(ord('a') +i))
                exit()


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

long long N, M;
int color[100000];
vector<int> edge[100000];


bool check_biparate(int vert, int c){
    if(color[vert] != 0 && color[vert] == c){
        return true;
    }else if(color[vert] != 0 && color[vert] != c){
        return false;
    }
    color[vert] = c;
    bool ret = true;
    for(int i = 0; i < edge[vert].size(); i++){
        ret =  ret && check_biparate(edge[vert][i], (c%2)+1);
    }
    return ret;
}


int main(){
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int A, B;
        cin >> A >> B;
        A--; B--;
        edge[A].push_back(B);
        edge[B].push_back(A);
    }
    bool biparate = check_biparate(0, 1);
    if(biparate){
        long long b = 0, w = 0;
        for(int i = 0; i < N; i++){
            if(color[i] == 1){
                b++;
            }else{
                w++;
            }
        }
        cout << b*w-M << endl;
    }else{
        cout << N*(N-1)/2-M << endl;
    }
}

Measured memory_bytes: 6528
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj2101/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aoj2101/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}


	long divisors(long n) {
		long sum = 0;
		for (long d = 2; d * d <= n; d++) {
			if (n % d == 0) {
				sum += d;
				if (d * d != n) sum += n / d;
			}
		}
		return sum + 1;
	}

	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		while(true) {
			int N = sc.nextInt();
			if (N == 0) break;
			if (N == 1) {
				System.out.println("deficient number");
				continue;
			}

			int s = (int) divisors(N);
			if (s > N) {
				System.out.println("abundant number");
			} else if (s < N) {
				System.out.println("deficient number");
			} else {
				System.out.println("perfect number");
			}
		}
	}


	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
}

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

int main() {
	string s; cin >> s;
	int p = 0;
	int g = 0;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		char top = s.at(i);
		if (p == g) {
			g++;
			if (top == 'p')ans--;
		}
		else {
			p++;
			if (top == 'g') ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
import bisect

q = int(input())
plist = [2]
like2017 = []
n = 3
while n <= 10 ** 5:
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            break
    else:
        plist.append(n)
        if (n + 1) // 2 in plist:
            like2017.append(n)
    n += 2
for _ in range(q):
    l, r = map(int, input().split())
    print(bisect.bisect_right(like2017, r) - bisect.bisect_left(like2017, l))


Measured memory_bytes: 3724
from collections import deque
N, M = map(int, input().split())
tree = [[] for _ in range(N)]
happend = set()
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    if (a, b) not in happend and (b, a) not in happend:
        tree[a].append(b)
        tree[b].append(a)
        happend.add((a, b))
        happend.add((b, a))
visited = [False]*N
q = deque()
ans = 0
for i in range(N):
    if visited[i]:
        continue
    visited[i] = True
    q.append(i)
    tmp = 1
    while len(q):
        v = q.popleft()
        for e in tree[v]:
            # print("v , e", v, e)
            if visited[e]:
                continue
            visited[e] += 1
            tmp += 1
            q.append(e)
            # print("tmp : ", tmp)
    ans = max(tmp, ans)
# print(tree)
print(ans)


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

int main()
{
    int n,i,j;
    cin>>n;
    vector<int>v;
    for(i=0;i<n;i++)
    {
        cin>>j;
        v.push_back(j);
    }
    sort(v.begin(),v.end());
    if(v[n/2]!=v[n/2]- 1){
        cout<<v[n/2]-v[n/2-1]<<endl;
    }
    else{
        cout<<0<<endl;
    }
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int h,w,vis[30][30],a[30][30],ans=-1;
int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
void bfs(int x,int y) {
	queue<int> num;
	queue< pair<int,int> > q;
	memset(vis,0,sizeof(vis));
	vis[x][y]=1;
	q.push(make_pair(x,y));
	num.push(0);
	while(!q.empty()) {
		pair<int,int> f=q.front();q.pop();
		int tmp=num.front();num.pop();
		x=f.first,y=f.second;
		ans=max(ans,tmp);
		for(int i=0;i<4;++i) {
			int x1=x+dx[i],z1=y+dy[i];
			if(!a[x1][z1]&&!vis[x1][z1]) {
				vis[x1][z1]=1;
				q.push(make_pair(x1,z1));
				num.push(tmp+1);
			}
		}
	}
}
int main()
{
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;++i) {
		string s;
		cin>>s;
		for(int j=1;j<=w;++j)
			if(s[j-1]=='#')
				a[i][j]=1;
	}
	for(int i=0;i<=h;++i) a[i][0]=a[i][w+1]=1;
	for(int i=0;i<=w;++i) a[0][i]=a[h+1][i]=1;
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
			if(!a[i][j])
				bfs(i,j);
	printf("%d",ans);
	return 0; 
}

Measured memory_bytes: 256
n, c = map(int, input().split())
program = [tuple(map(int, input().split())) for _ in range(n)]
program.sort()
recorder = [(0, -1)] * c
# greedy
for s, t, co in program:
    done = 0
    for i in range(c):
        #search same channel
        f, cp = recorder[i]
        if (f == s or f == s-1) and co == cp:
            recorder[i] = (t, co)
            done = 1
            break
    if done == 0:
        for i in range(c):
            f, cp = recorder[i]
            if f < s:
                recorder[i] = (t, co)
                break
ret = 0
for i in range(c):
    if recorder[i][0] != 0:
        ret += 1
print(ret)

Measured memory_bytes: 63960
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
#define showm(m) for(auto i: m){cout << m.x << " ";}
typedef long long ll;
typedef pair<int, int> P;


int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> h;
    rep(i, n){ ll tmp; cin >> tmp; h.push_back(tmp);}

    sort(h.begin(), h.end());

    ll ans = 0;
    if (n <= k){
        ans = 0;
    } else {
        rep(i, n-k){
            ans += h[i];
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int W, H, N; cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  rep(i, N) cin >> x[i] >> y[i] >> a[i];
  
  vector<vector<bool>> v(W, vector<bool>(H, true));
  rep(i, N) {
    if(a[i] == 1) {
      rep(w, W) rep(h, H) if(w < x[i]) v[w][h] = false;
    }
    if(a[i] == 2) {
      rep(w, W) rep(h, H) if(w >= x[i]) v[w][h] = false;
    }
    if(a[i] == 3) {
      rep(w, W) rep(h, H) if(h < y[i]) v[w][h] = false;
    }
    if(a[i] == 4) {
      rep(w, W) rep(h, H) if(h >= y[i]) v[w][h] = false;
    }
  }
  
  int ans = 0;
  rep(w, W) rep(h, H) if(v[w][h]) ans++;
  cout << ans << endl;

}


Measured memory_bytes: 3576
def resolve():
    S = input().strip()
    T = input().strip()

    for i in range(len(S)):
        if S == T:
            print('Yes')
            return
        S = S[len(S) - 1] + S[0:len(S) - 1]
    if S == T:
        print('Yes')
    else:
        print('No')
resolve()


Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  if(s == "hi" or s=="hihi" or s=="hihihi" or s=="hihihihi" or s=="hihihihihi")
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";

}


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

int main(void){

  char *x, *y;
  int i;

  x = (char*)malloc(100000);

  y = "1";

  while(strcmp(y, "0") != 0){
    int len = 0;
    int sum = 0;
    scanf("%s", x);
    if(strcmp(x, "0") == 0){
      break;
    }
    while(x[len]){
      len++;
    }

    for(i = 0; i < len; i++){
      sum += 1 + (x[i] - '1');
    }
    printf("%d\n", sum);
    y = x;
  }

  free(x);

  return 0;
}


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

using namespace std;

using ll = long long;

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

    std::vector<int> A(N), B(N), C(N - 1);
    std::for_each(A.begin(), A.end(), [](auto &x) { cin >> x; });
    std::for_each(B.begin(), B.end(), [](auto &x) { cin >> x; });
    std::for_each(C.begin(), C.end(), [](auto &x) { cin >> x; });

    int sum = 0;
    for (int i = 0; i < N; ++i) {
        sum += B[A[i] - 1];
        if (i > 0 && A[i] == A[i - 1] + 1) {
            sum += C[A[i - 1] - 1];
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){

	int a, b, c;
	while (1){
		scanf("%d %d", &a, &b);
		if (a == 0 && b==0){
			break;
		}
		else if (a > b){
			c = a;
			a = b;
			b = c;
			printf("%d %d\n", a, b);
		}
		else
		printf("%d %d\n", a, b);
	}
	
	return 0;
}

Measured memory_bytes: 1028
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[] for i in range(N)]
for i in range(N): A[i] = list(map(int, input().split()))
ans, sum = 0, 0
for i in range(N):
    sum = C
    for j in range(M):
        sum += A[i][j] * B[j]
    if (sum > 0): ans += 1
print(ans)


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n, k; cin >> n >> k;
  vector <bool> mark(n + 1, 0);
  for (int i = 1; i <= k; i++){
    int d; cin >> d;
    while (d--){
      int x; cin >> x;
      mark[x] = true;
    }
  }
  int res = 0;
  for (int i = 1; i <= n; i++) res += !mark[i];
  cout << res;
  return 0;
}

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

#define rep(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (a); i >= (int)(b); i--)
#define all(x) (x).begin(), (x).end()
using i32 = int32_t;
using i64 = int64_t;
using f32 = float;
using f64 = double;
using P   = pair<int, int>;

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

template <class T>
void dump_vec(const vector<T>& v) {
    auto len = v.size();
    rep(i, 0, len) {
        cout << v[i] << (i == (int)len - 1 ? "\n" : " ");
    }
}

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} FASTIO;

//---------------------------------------------------------------------------------------------------
/// 最長共通接頭辞
/// 文字列Sの左からi番目について、SとS[i..|S|]が何文字が一致しているかを処理
/// O(|S|)
namespace z_algorithm {

vector<int> run(const string& s) {
    const int len = s.size();
    vector<int> prefix(len);
    for (int i = 1, j = 0; i < len; i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < len && s[k] == s[i + k]) {
                k++;
            }
            prefix[i] = k;
            j         = i;
        }
    }
    prefix[0] = len;
    return prefix;
}

/// Tと一致する部分についてのSの左端の位置
vector<int> search(const string& s, const string& t) {
    const auto zs  = run(t + s);
    const int tlen = t.size();
    vector<int> res;
    for (int i = 0; i < (int)s.size(); i++) {
        if (zs[tlen + i] >= tlen) {
            res.push_back(i);
        }
    }
    return res;
}

}; // namespace z_algorithm
//---------------------------------------------------------------------------------------------------

signed main() {
    string S, T;
    cin >> S >> T;

    auto ans = z_algorithm::search(S, T);
    rep(i, 0, ans.size()) {
        cout << ans[i] << "\n";
    }
}



Measured memory_bytes: 12772
// --------------
// Tejas Pandey  |
// 19 - 09 - 20  |
// Atcoder BC 179|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int f = s.size();
  if(s[f - 1] != 's') cout << s << "s\n";
  else cout << s << "es\n"; 
  return 0;
}


Measured memory_bytes: 3644
s = input()
x, y = int(s[:2]), int(s[2:])

if (1 <= x <= 12) & (1 <= y <= 12):
    print('AMBIGUOUS')
elif 1 <= x <= 12:
    print('MMYY')
elif 1 <= y <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 2940
#pragma region Template
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(int i = 0; i < n; i++)
#define RNG(i, a, b) for(int i = a; i < b; i++)
#define RBF(i, v) for(auto& i : v)
#define ALL(x) x.begin(), x.end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;
template<typename T> using VP = vector<pair<T, T>>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }
#pragma endregion

std::vector<LL> yaku_num;
template<typename T> void segment_sieve(T num) {
	yaku_num = std::vector<T>(num, 2);
	yaku_num[1] = 1;
	T lim = ceil(sqrt(num));
	std::vector<bool> is_prime_small(num, true);
	std::vector<int> vec(num, 0);
	V<bool> flg(num, true);

	for (T i = 2; i < lim; i++) {
		if (is_prime_small[i]) {
			for (T j = i * i; j < num; j += i) {
				is_prime_small[j] = false;
				if (vec[j] == 0) vec[j] = j;
				LL yaku = 1;
				while (vec[j] % i == 0) {
					yaku++;
					vec[j] /= i;
				}
				yaku_num[j] *= yaku;
				if (vec[j] == 1 && flg[j]) {
					yaku_num[j] /= 2;
				}
			}
		}
	}
}


signed main() {
	LL n;
	cin >> n;

	segment_sieve(n+1);

	LL k = 1, ans = 0;
	while (k <= n) {
		ans += k * yaku_num[k];
		k++;
	}
	
	col(ans);
	return 0;
}


Measured memory_bytes: 122856
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	st := make(map[int]struct{})
	for i := 0; i < N; i++ {
		st[A[i]] = struct{}{}
	}
	if len(st) == N {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 9984
n,q = map(int,raw_input().split(" "))
task = [raw_input().split(" ") for i in range(n)]
c= 0
while task:
	name,time = task.pop(0)
	e = int(time) - q
	if e > 0:
		c+= q
		task.append([name,e])
	else:
		c+= int(time)
		print name+" "+str(c)

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

using namespace std;

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

    int sum = 0;

    vector<int> data1(N);
    vector<int> data2(N);

    // 入力
    for (int i = 0; i < N; i++) {
        cin >> data1.at(i);
    }

    for (int i = 0; i < N; i++) {
        cin >> data2.at(i);
    }

    for (int i = 0; i < N; i++) {
        if (data1.at(i) > data2.at(i)) {
            sum += data1.at(i) - data2.at(i);
        }
    }

    cout << sum << endl;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mod 1000000007
#define mp make_pair
#define fi first
#define se second
#define merge(a,b) a##b //concat a and b
#define mkstr(a) #a  //convert a to string a. a is not variable
#define flush fflush(stdout);
#define debug(x) cout<<#x<<endl;
#define debug1(x) cout<<x<<endl;
#define inf 1e18
#define endl "\n"
#define epsilon 1e-9

typedef long long int ll;
typedef long double   ld;
typedef unsigned long long int ull;

/************************************TEMPLATE**********************************/

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

/*************************************CODE*************************************/



int main()
{
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  fastIO
  ll test_case=1;
  //cin>>test_case;
  while(test_case--)  {
    int h,w,m;
    cin>>h>>w>>m;
    int row_count[h],column_count[w];
    set<pair<int,int>> target;
    memset(row_count,0,sizeof(row_count));
    memset(column_count,0,sizeof(column_count));
    int x,y,max_row=0,max_column=0;
    for(int i=0;i<m;i++)	{
    	cin>>x>>y;
    	x--,y--;
    	target.insert(mp(x,y));
    	row_count[x]++;
    	max_row=max(max_row,row_count[x]);
    	column_count[y]++;
    	max_column=max(max_column,column_count[y]);
    }
    vector<int> row_idx,column_idx;
    //cout<<max_row<<" "<<max_column<<endl;
    for(int i=0;i<h;i++)	{
    	//cout<<row_count[i]<<" ";
    	if(row_count[i]==max_row)
    		row_idx.pb(i);
    }
    //cout<<endl;
    for(int i=0;i<w;i++)	{
    	//cout<<column_count[i]<<" ";
    	if(column_count[i]==max_column)
    		column_idx.pb(i);
    }
    //cout<<endl;
    int ans=0;
    for(int i:row_idx)	{
    	for(int j:column_idx)	{
    		//cout<<"("<<i<<","<<j<<")"<<endl;
			ans=max(ans,row_count[i]+column_count[j]-1);
    		if(target.count(mp(i,j))==0)	{
    			ans++;
    			goto out;
    		}
    	}
    }
    out:
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 23780
import os,io
input=io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
n,m=map(int,input().split())
uf=UnionFind(n)
for i in range(m):
  x,y=map(int,input().split())
  uf.union(x-1,y-1)
print(uf.group_count()-1)

Measured memory_bytes: 73940
#include <iostream>
//#include <numeric>
//#include <vector>
//#include <cstdint>
//#include <string>
//#include <cstdlib>
using namespace std;

int main() {
	int n;
	cin >> n;
	string str;
	cin >> str;
	int k = 1;
	char l=str[0];

	for (int i = 1; i < str.length(); i++) {
		char c = str[i];
		if (c != l) {
			k++;
			l = c;
		}
	}

	cout << k;

	return 0;

}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

bool check(pair<int,int> a, pair<int,int> b) {
	return a < b;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//aCbを1000000007で割った余りを求める
llint convination(llint a, llint b) {
	llint ans = 1;
	for (llint i = 0; i < b; i++) {
		ans *= a - i;
		ans %= 1000000007;
	}
	for (llint i = 1; i <= b; i++) {
		ans *= modinv(i, 1000000007);
		ans %= 1000000007;
	}
	return ans;
}

int main() {
	double n, m, d;
	cin >> n >> m >> d;
	double ans;
	if (d == 0) {
		ans = 1 / n * (m - 1);
	}
	else {
		ans = (2 / n - 2 * d / n / n) * (m - 1);
	}
	printf("%.15f\n", ans);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s, ans string
	fmt.Scan(&s)
	
	for i, _ := range s {
		if i == 5 || i == 13 {
			ans += " "
		} else {
			ans += s[i : i+1]
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    unordered_map<char,int> mp;
    int f=1;
    for(int i=0;i<s.length();i++)
    {
        mp[s[i]]++;
    }
    for(auto i:mp)
    {
        if(i.second%2==1)
        {
            f=0;
            break;
        }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

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

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

  vector<ll> h(n + 1);
  rep(i, n) cin >> h.at(i);
  h.at(n) = 1e9;

  // cout << h.at(n);

  ll now = 0;

  rep(i, n)
  {
    now = max(h.at(i), now);
    if (now > h.at(i))
    {
      if (now-1 != h.at(i))
      {
        cout << "No";
        return 0;
      }
    }
  }

  cout << "Yes";
}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll claw[2000003];
ll infant[2000003];
 
int main() 
{
    int a;cin>>a;
    cout<<a*(1+a+a*a);	
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	char c;
	cin >> c;
	cout << (char)(c+1);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001;
//int arr[SIZE]={};
//ここまでテンプレ
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

pair<Weight, Edges> minimumSpanningForest(const Graph &g) {
  int n = g.size();
  UnionFind uf(n);
  priority_queue<Edge> Q;
  REP(u, n) FOR(e, g[u]) if (u < e->dst) Q.push(*e);

  Weight total = 0;
  Edges F;
  while (F.size() < n-1 && !Q.empty()) {
    Edge e = Q.top(); Q.pop();
    if (uf.unionSet(e.src, e.dst)) {
      F.push_back(e);
      total += e.weight;
    }
  }
  return pair<Weight, Edges>(total, F);
}
int main(){
	Graph G;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		Edges E;
		G.push_back(E);
	}
	vector<tuple<int,int,int>> X,Y;
	for(int i=0;i<N;i++){
		int x,y;
		cin>>x>>y;
		X.push_back(make_tuple(x,y,i));
		Y.push_back(make_tuple(y,x,i));
	}
	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());
	for(int i=1;i<N;i++){
		G[get<2>(X[i])].push_back(Edge(get<2>(X[i]),get<2>(X[i-1]),get<0>(X[i])-get<0>(X[i-1])));
		G[get<2>(X[i-1])].push_back(Edge(get<2>(X[i-1]),get<2>(X[i]),get<0>(X[i])-get<0>(X[i-1])));
		G[get<2>(Y[i])].push_back(Edge(get<2>(Y[i]),get<2>(Y[i-1]),get<0>(Y[i])-get<0>(Y[i-1])));
		G[get<2>(Y[i-1])].push_back(Edge(get<2>(Y[i-1]),get<2>(Y[i]),get<0>(Y[i])-get<0>(Y[i-1])));
	}

	cout<<minimumSpanningForest(G).first<<endl;
	return 0;
}

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

int main()
{
	string S;
    cin>>S;
    ll sum=0;
    
    map<ll,ll> hash;
    
    for(ll i=0;i<S.length();i++)
    {
        hash[S[i]]+=1;
    }
    
    for(auto it:hash)
    {
        sum+=(it.first-48)*(it.second);
    }
    cout<<(sum%9==0?"Yes":"No");
  
	return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i < n + 1 ; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			b[i] = sc.nextInt();
		}

		long ans = 0;


		for (int i = 0; i < n; i++) {

			if (a[i] >= b[i]) {
				ans += b[i];
			} else {

				if (a[i] < b[i]) {

					int zan = b[i] - a[i];

					ans += a[i];

					if (a[i+1] >= zan) {
						ans += zan;
						a[i+1] = a[i+1] - zan;
					// 2番目の街までしか倒せない
					} else if(a[i+1] < zan) {
						ans += a[i+1];
						a[i+1] = 0;
					}
				}
			}
		}

		System.out.println(ans);

	}
}


Measured memory_bytes: 86964
# include "bits/stdc++.h"
using namespace std;
using LL = long long;

int n;
vector<pair<LL, LL>> v;

int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        LL a, b;
        cin >> a >> b;
        v.emplace_back(make_pair(b, a));
    }
    sort(v.begin(), v.end());
    LL t = 0;
    for(int i = 0;i < n;i++){
        t += v[i].second;
        if(t > v[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6256
fun main(args : Array<String>) {
    val N = readLine()!!.toInt()

    for (x in 0..(N)) {
    	for (y in 0..(N)) {
            val sum = 4 * x + 7 * y
            if (sum == N) {
                println("Yes")
                return
            }
    	}
    }
    println("No")
}


Measured memory_bytes: 31772