akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  int l, r;
  int sum = 0;
  int i = 0;
  cin >> N;
  
  while(i<N){
    cin >> l >> r;
    sum  += r-l+1;
    i++;
  }
  cout << sum; 
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;

int main(){
    string s; cin>>s;
    ll k; cin>>k;
    ll n=s.size();
    vector<ll> streak;
    ll length=1;
    rep(i,1,n){
        if(s[i]==s[i-1]){
            length++;
        }else{
            streak.push_back(length);
            length=1;
        }
    }
    streak.push_back(length);
    ll ans=0;
    for(auto i:streak){
        ans+=i/2;
    }
    ans*=k;
    if(s[0]==s[n-1] and streak[0]%2==1 and streak.back()%2==1) ans+=k-1;
    if(streak.size()==1 and streak[0]%2==1) ans-=(k-1)/2;
    cout<<ans<<endl;
}
// aaa

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

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			int min = 500, max = 0;
			for(int i=0;i<n;i++) {
				int sum = 0;
				for(int j=0;j<5;j++) sum += sc.nextInt();
				min = min(sum, min); max = max(sum, max);
			}
			System.out.println(max + " " + min);
		}
	}

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

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 33652
# load data
N, W = list(map(int, input().split()))
items = []
for _ in range(N):
    items.append(tuple(map(int, input().split())))


# dpテーブルの作成
# 今回は最大化が目的なのですべてのマスを-1で埋めることにする
dp = [[-1] * (W + 1) for _ in range(N + 1)]

# dpテーブルの初期化
# dp[:][0]が0 ∵大きさ0のナップサックには何も入れられない
# dp[0][:]が0 ∵なにもitemを考慮しないときはナップサックに何も入らない。
for i in range(N + 1):
    dp[i][0] = 0
for w in range(W + 1):
    dp[0][w] = 0

# dpテーブルの更新
# i番目のitemが入らない場合→dp[i+1][w]=dp[i][w] ∵iを考慮しないときと価値は変わらない
# i番目のitemが入る場合→dp[i+1][w]=max(dp[i][w], dp[i][w-item[i]の重さ]+item[i]の価値)
# ∵iを入れる前の最善はdp[i][w-item[i]の重さ]にあり、それにitem[i]の価値を足すことで最善になる可能性がある。
# ただしちゃんと、iを入れないときのほうが良いかもしれないことに注意しなければいけない。
from itertools import product
for i, w in product(range(N), range(W + 1)):
    dp[i + 1][w] = dp[i][w]
    value, weight = items[i]
    if w - weight >= 0:
        dp[i + 1][w] = max(dp[i][w], dp[i][w - weight] + value)

print(dp[-1][-1])


Measured memory_bytes: 25868
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
struct edge
{
	int to;
	int next;
}e[333333];
int pe=111111;
int deg[111111];
void insert(int a,int to)
{
	e[pe]=(edge){to,e[a].next};
	e[a].next=pe++;
	deg[to]++;
}
int f[111111][4];//1:ex 2:ex0
void dfs(int o,int fa)
{
	if(deg[o]==1){f[o][2]=0,f[o][1]=1;return;}
	int g[4]={0,0x3f3f3f3f};
	int cnt=0,son;
	for(register int p=e[o].next;p;p=e[p].next)
		if(e[p].to!=fa)++cnt,son=e[p].to;
	if(cnt==1){dfs(son,o);memcpy(f[o],f[son],sizeof(f[o]));return;}
	if(cnt==2)
	{
		int c1=son,c2;
		for(register int p=e[o].next;p;p=e[p].next)
			if(e[p].to!=fa){c2=e[p].to;break;}
		dfs(c1,o);
		dfs(c2,o);
		int m1=0x3f3f3f3f,m2=0x3f3f3f3f;
		cmin(m1,f[c1][0]),cmin(m1,f[c1][1]),cmin(m1,f[c1][3]);
		cmin(m2,f[c2][0]),cmin(m2,f[c2][1]),cmin(m2,f[c2][3]);
		f[o][1]=m1+m2;
		cmin(f[o][3],f[c1][1]+f[c2][2]);
		cmin(f[o][3],f[c1][2]+f[c2][1]);
		cmin(f[o][0],f[c1][0]+f[c2][2]);
		cmin(f[o][0],f[c1][2]+f[c2][0]);
		cmin(f[o][0],f[c1][2]+f[c2][3]);
		cmin(f[o][0],f[c1][3]+f[c2][2]);
		return;
	}
	for(register int p=e[o].next;p;p=e[p].next)
		if(e[p].to!=fa)
		{
			dfs(e[p].to,o);
			int mn=0x3f3f3f3f;
			for(register int i=0;i<=3;++i)if(i!=2)cmin(mn,f[e[p].to][i]);
			g[1]+=mn;
			cmin(g[1],g[0]+f[e[p].to][2]);
			g[0]+=mn;
		}
	f[o][3]=g[1];
	f[o][1]=g[0];
}
int main()
{
	int n=io::F();
	if(n==2){puts("1");return 0;}
	for(register int i=1;i<n;++i)
	{
		int x=io::F(),y=io::F();
		insert(x,y);
		insert(y,x);
	}
	memset(f,63,sizeof(f));
	for(register int i=0;i<n;++i)
		if(deg[i]!=1){dfs(i,i);printf("%d\n",dmin(f[i][1],f[i][3]));break;}
	return 0;
}



Measured memory_bytes: 12544
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int ctoi(char c){
  if(c == '#'){
    return 1;
  }
  else{
    return 0;
  }
}

inline int is_isolated(vector<vector<int> > &vec,int i ,int j,int H,int W){
  if(i > 0){
    if(vec[i-1][j]){
      return 0;
    }
  }
  if(j > 0){
    if(vec[i][j-1]){
      return 0;
    }
  }
  if(i < H -1){
    if(vec[i+1][j]){
      return 0;
    }
  }
  if(j < W -1){
    if(vec[i][j+1]){
      return 0;
    }
  }
  return 1;
}

int main(){
  int H,W;
  cin >> H >> W;
  string ans = "Yes";
  vector<vector<int> > vec(H,vector<int>(W));
  rep(i,H){
    rep(j,W){
      char c;
      cin >> c;
      vec[i][j] = ctoi(c);
    }
  }
  rep(i,H){
    rep(j,W){
      if(vec[i][j]){
        //cout << "#" << endl;
        if(is_isolated(vec,i,j,H,W)){
          ans = "No";
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//41
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(double t,tt;cin>>t>>tt;){
    const char *cls[]={"AAA","AA","A","B","C","D","E","NA"};
    double rt[]={35.5,37.5,40,43,50,55,70};
    double rtt[]={71,77,83,89,105,116,148};
    cout<<cls[max(upper_bound(rt,rt+7,t)-rt,upper_bound(rtt,rtt+7,tt)-rtt)]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
using namespace std;
using ll = long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, X, D = 0;
  cin >> N >> X;
  int ans = 1;
  rep(i, N) {
    int L;
    cin >> L;
    D += L;
    if (D <= X) ans++;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<algorithm>
using namespace std;

int par[120];
int rnk[120];
struct edge { int u, v, cost; };
bool comp(const edge&e1, const edge& e2) {
	return e1.cost < e2.cost;
}

void init(int n) {
	for (int i = 0;i < n;i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}

int find(int a) {
	if (par[a] == a)return a;
	else return par[a] = find(par[a]);
}

void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;

	if (rnk[x] < rnk[y])par[x] = y;
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}
int main() {
	int n, m;
	while (cin >> n, n) {
		cin >> m;
		edge es[10000];
		for (int i = 0;i < m;i++) {
			int a, b, c;
			scanf("%d,%d,%d", &a, &b, &c);
			es[i].cost = c;
			es[i].u = b;
			es[i].v = a;
		}
		int ans =0;
		sort(es, es + m, comp);
		init(n);
		for (int i = 0;i < m;i++) {
			edge e = es[i];
			if (!same(e.u, e.v)) {
				unite(e.u, e.v);
				ans += e.cost / 100 - 1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int> A(Q);
    map<int, int> m;
    for (int i = 0; i < Q; i++) {
        cin >> A[i];
        A[i]--;
        m[A[i]]++;
    }

    vector<int> a(N, K);
    REP(i, N){
        // pr(m[i]);
        Yes(m[i] + K - Q > 0);
    }

}

Measured memory_bytes: 6144
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int n;
	int a[3] = {0};
	int mn = 100000000;
	cin >> n;
	for(int i = 0; i < n; i++){
        cin >> a[i];
        mn = min(mn,a[i]);
	}
	for(int i = 1; i <=  mn; i++){
        bool flg = 0;
        for(int j = 0; j < n; j++){
            if(a[j]%i == 0)flg = 1;
            else {
                flg = 0;
                break;
            }
        }
        if(flg)cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc =new Scanner(System.in);
		int[] dish = new int[5];
		for(int i=0;i<5;i++){
			dish[i] = sc.nextInt();
		}

		int[] point = new int[5];
		int[] ones_place=new int[5];
		for(int i=0;i<5;i++){
			if(dish[i] >=100){
				ones_place[i] = (dish[i]%100)%10;
				if(ones_place[i] == 0)
					ones_place[i] = 10;

					point[i] = dish[i]+10-ones_place[i];
				
			}else if(dish[i]>=10){
					ones_place[i]=dish[i]%10;
					if(ones_place[i] == 0)
					ones_place[i] = 10;

					point[i] = dish[i]+10-ones_place[i];
				}else{
					ones_place[i]=dish[i];
					if(ones_place[i] == 0)
					ones_place[i] = 10;

					point[i] = dish[i]+10-ones_place[i];
				}
		}

		Arrays.sort(ones_place);
		int time=0;

		for(int i=0;i<point.length;i++){
			time=time+point[i];
		}

		System.out.println(time-10+ones_place[0]);
	}
}

Measured memory_bytes: 21460
#include <iostream>
using namespace std;
int main(){
	int X,A,B;
	cin >> X >> A >> B;
	
	if(A>=B){
		cout << "delicious" << endl;
	}else if(A<B&&B-A>X){
		cout << "dangerous" << endl;
	}else{
		cout << "safe" << endl;
	}
	return 0;
}

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

int main(){
	int n;
	cin >>n;
	int arr[n+1];

	for(int i=1;i<=n;i++)	
		cin >>arr[i];

	int dp[n+1];
	dp[0]=0;
	dp[1]=0;
	dp[2] = abs(arr[2]-arr[1]);

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

	cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
using namespace std;
using T=tuple<int,int,int>;

int main(){
    int H,W;
    int64_t L;
    while(cin>>H>>W>>L,H){
        char b[H+2][W+2];
        fill(b[0],b[H+2],'#');
        int y,x,d;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                cin>>b[i][j];
                if(b[i][j]!='.'&&b[i][j]!='#'){
                    y=i; x=j;
                    switch(b[i][j]){
                        case 'N':
                            d=0;
                            break;
                        case 'E':
                            d=1;
                            break;
                        case 'S':
                            d=2;
                            break;
                        case 'W':
                            d=3;
                            break;
                    }
                }
            }
        }
        int64_t v[H+2][W+2][4];
        fill(v[0][0],v[H+2][0],0);
        vector<T> V;
        int dy[4]={-1,0,1,0};
        int dx[4]={0,1,0,-1};
        string s="NESW";
        bool flag=false;
        while(true){
            // cout<<' '<<y<<' '<<x<<' '<<d<<endl;
            if(b[y+dy[d]][x+dx[d]]!='#'){
                if(v[y+dy[d]][x+dx[d]][d]&&!flag){
                    flag=true;
                    L=v[y+dy[d]][x+dx[d]][d]+(L-v[y+dy[d]][x+dx[d]][d])%(v[y][x][d]-v[y+dy[d]][x+dx[d]][d]+1);
                }else{
                    v[y+dy[d]][x+dx[d]][d]=v[y][x][d]+1;
                }
                y+=dy[d]; x+=dx[d];
                if(v[y][x][d]==L){
                    cout<<y<<' '<<x<<' '<<s[d]<<endl;
                    break;
                }
            }else{
                v[y][x][(d+1)%4]=v[y][x][d];
                d=(d+1)%4;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int par[114514] = {}; 
int depth[114514] = {}; 
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
	}else{
		par[y] = x; 
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int main(){
	int N; 
	cin >> N; 
	pair<pair<int, int>, int> C[100010] = {}; 
	for(int i = 0; i < N; i++){
		C[i].second = i; 
		cin >> C[i].first.first >> C[i].first.second; 
	}
	sort(C, C+N); 
	pair<int, pair<int, int>> E[200010] = {}; 
	for(int i = 0; i < N-1; i++){
		E[i].first = C[i+1].first.first - C[i].first.first; 
		E[i].second.first = C[i].second; 
		E[i].second.second = C[i+1].second; 
	}
	for(int i = 0; i < N; i++){
		swap(C[i].first.first, C[i].first.second); 
	}
	sort(C, C+N); 
	for(int i = 0; i < N-1; i++){
		E[N-1+i].first = C[i+1].first.first - C[i].first.first; 
		E[N-1+i].second.first = C[i].second; 
		E[N-1+i].second.second = C[i+1].second; 
	}
	sort(E, E+(N*2-2)); 
	for(int i = 0; i < N; i++){
		par[i] = i;	
		depth[i] = 0; 
	}
	int ans = 0; 
	for(int i = 0; i < N*2-2; i++){
		if(!same(E[i].second.first, E[i].second.second)){
			unite(E[i].second.first, E[i].second.second); 
			ans += E[i].first; 
		}
	}
	cout << ans << endl; 
}

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

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

    string s;
    int a, b;
    cin >> s >> a >> b;

    vector<int> x;
    vector<int> y;

    int count = 0;
    bool is_x = true;

    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'F') count++;
        else {
            if(is_x) x.push_back(count);
            else y.push_back(count);
            count = 0;
            is_x = !is_x;
        }
    }

    if(is_x) x.push_back(count);
    else y.push_back(count);

    if(y.size() == 0) {
        y.push_back(0);
    }

    vector<map<int, bool> > xz(x.size());
    vector<map<int, bool> > yz(y.size());

    xz[0][ x[0]] = true;
    yz[0][ y[0]] = true;
    yz[0][-y[0]] = true;

    for(int i = 1; i < x.size(); i++) {
        for(auto j = begin(xz[i - 1]); j != xz[i - 1].end(); j++) {
            xz[i][j -> first + x[i]] = true;
            xz[i][j -> first - x[i]] = true;
        }
    }

    for(int i = 1; i < y.size(); i++) {
        for(auto j = begin(yz[i - 1]); j != yz[i - 1].end(); j++) {
            yz[i][j -> first + y[i]] = true;
            yz[i][j -> first - y[i]] = true;
        }
    }

    if(xz[x.size() - 1][a] && yz[y.size() - 1][b]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 232320
# ARC080D - Grid Coloring (ABC069D)
def main():
    """
    move left to right in odd rows and vice versa in even rows
    1 s--->
    2 <----
    3 --->t
    """
    H, W, N, *A = map(int, open(0).read().split())
    grid = sum([[color] * cnt for color, cnt in enumerate(A, 1)], [])
    for i, g in enumerate(zip(*[iter(grid)] * W), 1):
        if i & 1:
            print(*g)
        else:
            print(*g[::-1])


if __name__ == "__main__":
    main()

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

using namespace std;


int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<string>> s(h, vector<string>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> s[i][j];
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(s[i][j] == "snuke") {
                cout << char(j + 65) << i + 1 << "\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int N, Y;

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


    if (Y < (N * 1000) || Y > (N * 10000)) {
	cout << "-1 -1 -1" << endl;
	return 0;
    }
    Y = Y / 1000;


    int r = -1, y = -1, z = -1;
    for (z = 0; z <= ((Y-N) / 9) + 1; z++) {
	if ((Y-N) - (z * 9) < 0) {
	    continue;
	}
	
	r = ((Y-N) - (z * 9)) % 4;
	y = ((Y-N) - (z * 9)) / 4;
	if (r == 0 && N - y - z >= 0) {
	    break;
	} else {
	    y = -1;   
	}
    }
    if (y == -1) {
	cout << "-1 -1 -1" << endl;
    } else {
	cout << z << " " << y << " " << N - y - z << endl;
    } 
    
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, k, s = map(int, readline().split())
if s != 1:
    check = s - 1
else:
    check = s + 1
ans = [s] * k + [check] * (n - k)
print(*ans)


Measured memory_bytes: 6524
import scala.io.StdIn.{readInt, readLine};
import scala.collection.mutable.PriorityQueue;

object Main {
    def main(args: Array[String]): Unit = {
        val size = readInt;
        val graph = new Array[List[(Int, Int)]](size); // (cost, index)
        for (i <- (0 until size)) {
            graph(i) = readLine.trim.split(" ").map(_.toInt).zipWithIndex.filter(_._1 != -1).toList;
        }
        println(mst(size, graph).sum);
    }
    def mst(size: Int, graph: Array[List[(Int, Int)]]): Array[Int] = {
        val dist = new Array[Int](size).map(a => Int.MaxValue);
        val stat = new Array[Int](size); // 0: 未調査, 1: 調査済み
        val pq = new PriorityQueue[(Int, Int)]()(Ordering.by((e: (Int, Int)) => e._1).reverse);
        def go(): Unit = {
            if (!pq.isEmpty) {
                val (cost, idx) = pq.dequeue();
                if (stat(idx) != 1) {
                    dist(idx) = cost;
                    stat(idx) = 1;
                    graph(idx).filter(e => stat(e._2) == 0 && e._1 < dist(e._2)).foreach {e => pq.enqueue(e)}
                }
                go();
            }
        }
        pq.enqueue((0, 0));
        go();
        dist;
    }
}


Measured memory_bytes: 54452
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nab = readints;
    int n = nab[0], a = nab[1], b = nab[2];

    int xmax = min(a, b);
    int xmin = max(0, a + b - n);
    writeln(xmax, " ", xmin);
}


Measured memory_bytes: 256
s = input()

a = set(['R','U','D'])
b = set(['L','U','D'])

ck = False
for i,data in enumerate(s):
  if (i+1) % 2 :
    if not data in a:
      break
  else :
    if not data in b:
      break
else:
  ck = True

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

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

using namespace std;
int X, Y, Z,K;
vector<long> a, b, c;

bool can(long V, int K) {
    int i,j,k, cnt = 0;
    for (i =0 ; i < X; i++) {
        for (j = 0; j < Y; j++) {
            for (k = 0; k < Z; k++){
                if (a[i]+b[j]+c[k] >= V) cnt++;
                if (cnt >= K) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    int i, j, k;
    long t;
    cin >> X >> Y >> Z >> K;
    for (i = 0; i < X; i++) {cin >> t; a.push_back(t);}
    for (i = 0; i < Y; i++) {cin >> t; b.push_back(t);}
    for (i = 0; i < Z; i++) {cin >> t; c.push_back(t);}
    vector<long> ans;
    sort(a.rbegin(),a.rend());
    sort(b.rbegin(),b.rend());
    sort(c.rbegin(),c.rend());
    for (i = 0; i < X; i++) {
        for(j=0;j<Y;j++){
            for(k=0;k<Z;k++){
                if((i+1)*(j+1)*(k+1)<=K)ans.push_back(a[i]+b[j]+c[k]);
                else break;
            }
        }
    }
    sort(ans.rbegin(),ans.rend());
    for(i=0;i<K;i++)cout<<ans[i]<< endl;

    return 0;
}

Measured memory_bytes: 1412
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    int t;
    cin >> t;
    while (t-- > 0) {
        int n;
        cin >> n;
        vector<long long> A(n);
        for (int i = 0; i < n; ++i) {
            cin >> A[i];
        }
        string s;
        cin >> s;

        int res = s.back() - '0';
        if (res == 0){
            vector<long long> X;
            for (int i = n - 1; i >= 0; --i) {
                long long x = A[i];
                for (auto y : X) {
                    x = min(x, x ^ y);
                }
                if (x != 0) {
                    if (s[i] == '1') {
                        res = 1;
                        break;
                    }
                    X.push_back(x);
                }
                for (int i = (int) X.size() - 2; i >= 0; --i) {
                    if (X[i] < X[i + 1]) {
                        swap(X[i], X[i + 1]);
                    } else {
                        break;
                    }
                }
            }
        }
        cout << res << '\n';
    }
    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  string S;
  cin >> S;
  bool ok = true;
  if (S[0] != 'A') ok = false;

  int C_cnt = 0;
  rep(i, 2, S.size()-1) {
    if (S[i] == 'C') {
      C_cnt++;
    }
  }

  if (C_cnt != 1) ok = false;

  int lower_cnt = 0;
  rep(i, 1, S.size()) {
    if (S[i] == 'C') continue;
    if ((int)S[i] - 'Z' > 0) lower_cnt++;
  }

  debug(lower_cnt);

  if (lower_cnt != S.size()-2) ok = false;

  if (ok) {
    cout << "AC" << endl;
  } else {
    cout << "WA" << endl;
  }

  return 0;
};


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


int main(){
	/*unsigned long A;
	unsigned long B;*/

	char A[100];
	char B[100];

	scanf("%s %s",A,B);

	if(strlen(A) > strlen(B)){
		printf("GREATER\n");
		return 0;
	}
	else if(strlen(A) < strlen(B)){
		printf("LESS\n");
		return 0;
	}
	else{
		for(int i=0; i<strlen(A); i++){
			if(A[i] > B[i]){
				printf("GREATER\n");
				return 0;
			}
			else if(A[i] < B[i]){
				printf("LESS\n");
				return 0;
			}
		}
		printf("EQUAL\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

using namespace std;

//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

void func() {
    int A, B;
    cin >> A >> B;
    if(A > B) {
        cout << -1 << endl;

    }
    int targetA = int(double(A) / 0.08);
    int targetB = B  * 10;
    int left = max(targetA,targetB);
     targetA = int(double(A + 1) / 0.08);
     targetB = (B + 1)  * 10;
     int right= min(targetA,targetB); 
    for (int i = left; i < right; ++i) {

        int a = int(double(i) * 0.08);
        int b = int(double(i) * 0.1);
        if(a == A && b == B) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(i,j,n) for(ll i = (ll)(j); i < (ll)(n); i++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	vector<int> a(5);
	rep(i,5) cin >> a[i];
	for(int i=1;i<=5;i++) {
		if(i!=a[i-1]) cout << i << endl;
	}
}



Measured memory_bytes: 3620
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

typedef pair<int, int> P;

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

	int count = 0;

	rep(i, s.length()/2)
	{
		if (s[i] != s[s.length() - i - 1]) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n, k := readInt(), readInt()
	var l []int
	for i := 0; i < n; i++ {
		l = append(l, readInt())
	}
	sort.Sort(sort.Reverse((sort.IntSlice(l))))
	sum := 0
	for j := 0; j < k; j++ {
		sum = sum + l[j]
	}
	fmt.Println(sum)
}


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

using namespace std;

int main(void)
{
	int N, M;
	cin >> N >> M;
	vector<vector<int>> e(N);
	int num_of_inputs[N] = {};
	for (int i = 0; i < M; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		e[x].push_back(y);
		num_of_inputs[y]++;
	}

	vector<int> s, l;
	for (int i = 0; i < N; i++) {
		if (num_of_inputs[i] == 0) {
			s.push_back(i);
		}
	}
	int d[N] = {};

	while (s.size() != 0) {
		int v = s[0];
		l.push_back(s[0]);
		s.erase(s.begin());
		for (const auto& m : e[v]) {
			num_of_inputs[m]--;
			d[m] = max(d[m], d[v]+1);
			if (num_of_inputs[m] == 0) {
				s.push_back(m);
			}
		}
	}
	
	cout << *max_element(&d[0], &d[N]) << endl;

	return 0;
}


Measured memory_bytes: 7164
n,p=map(int,input().split())
s=input()
ans=0
if p==2 or p==5:
    for i in range(n):
        if int(s[i])%p==0:
            ans+=i+1
else:
    M=[0]*p
    M[0]=1
    tmp=0
    for i in range(n):
        tmp+=(int(s[-i-1])*pow(10,i,p))
        tmp%=p
        ans+=M[tmp]
        M[tmp]+=1
print(ans)

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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  int H, A;
  cin >> H >> A;
  cout << (H+A-1)/ A << endl;
  return 0;
}


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

string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    if (s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];
    sort(A,A+n);
    cout << A[n/2] - A[n/2 - 1] << endl;

}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<stdio.h>
#include<locale.h>
#include<set>
#include<stack>
#include<queue>
using namespace std;

int main()
{
	string s,t;
	cin >> s >> t;
	int ans=20000,x=0;
	for(int i=0;i<=s.size()-t.size();i++)
	{
		for(int j=0;j<t.size();j++)
		{
		if(s[i+j]!=t[j]){x++;}
		}
	if(ans>x){ans=x;}
	x=0;
	}
	printf("%d",ans);
}

Measured memory_bytes: 3656
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut result: Vec<bool> = vec![false; n + 1];
    for i in (1..(n + 1)).rev() {
        let mut b: usize = a[i - 1];
        let mut p: usize = i + i;
        while p <= n {
            if result[p] {
                b += 1;
            }
            p += i;
        }
        result[i] = b % 2 == 1;
    }

    let mut count: usize = 0;
    let mut ans: String = String::new();
    for i in 1..(n + 1) {
        if result[i] {
            count += 1;
            ans.push_str(&format!("{} ", i));
        }
    }
    if count == 0 {
        return "0".to_string();
    }
    return format!("{}\n{}", count, ans.trim());
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define ms(x, n) memset(x,n,sizeof(x));
#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define rep1(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define PI acos(-1.0)
#define LONG_LONG_MAX 9223372036854775807
#define LONG_LONG_MIN -9223372036854775808
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

int a, b, c;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> a >> b >> c;
    int it = a - b;
    if (c >= it) {
        cout << c - it << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<ll, ll>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>


int main() {
	ll H, W, M;
	cin >> H >> W >> M;
	vector<ll>h(M), w(M);
	set<P>s;
	rep(i, M) {
		cin >> h[i] >> w[i];
		P p = make_pair(h[i] - 1, w[i] - 1);
		s.insert(p);
	}
	vector<ll>cnt1(300010),cnt2(300010);
	ll ans1(0), ans2(0);
	rep(i, M) {
		ll k;
		k = h[i];
		k--;
		cnt1[k]++;
		ans1 = max(ans1, cnt1[k]);
	}
	rep(i, M) {
		int k;
		k = w[i];
		k--;
		cnt2[k]++;
		ans2 = max(ans2, cnt2[k]);
	}
	

	vector<ll>a, b;
	rep(i, max(W,H)) {
		if (cnt1[i] == ans1) {
			a.push_back(i);
		}
		if (cnt2[i] == ans2) {
			b.push_back(i);
		}
	}
	
	rep(i, a.size()) {
		rep(j, b.size()) {
			P p = make_pair(a[i], b[j]);
			if (s.count(p)==0) {
				cout << ans1 + ans2;
				return 0;
			}
		}
	}
	cout << ans1 + ans2 - 1;
	return 0;
}

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

int main() {
  string S, T;
  cin >> S >> T;
  
  int length_S = S.size();
  int length_T = T.size();
  
  vector<int> X(length_S - length_T + 1);
  int max = 0;
  
  for(int i = 0; i < length_S - length_T + 1; i++) {
    for(int j = 0; j < length_T; j++) {
      if(T.at(j) == S.at(j+i)) X.at(i)++;
    }
    if(max < X.at(i)) max = X.at(i);
  }
  
  cout << length_T - max << endl;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))

ll lcm(ll a,ll b){
    if(a==b)return a;

    return (a/__gcd(a,b))*b;
}



void solve(){
    ll n;cin>>n;
    ll time[n];rep(i,0,n)cin>>time[i];
    ll ans=lcm(time[0],1);
    rep(i,1,n){
        ans=lcm(ans,time[i]);
    }
    cout<<ans;


}

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


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int n,m,i,j,k,save1,save2;
	scanf("%d %d",&n,&m);
	int dis[n+1],wea[m+1];
	for(i=1;i<=n;i++){
		scanf("%d",&dis[i]);
	}
	for(i=1;i<=m;i++){
		scanf("%d",&wea[i]);
	}
	int map[n+1][m+1];
	for(i=0;i<=n;i++){
		for(j=1;j<=m;j++){
			map[i][j]=999999999;
		}
	}
	for(j=1;j<=m;j++){
			map[0][j]=0;
	}
	map[1][1]=dis[1]*wea[1];
//????????????	
	
	for(i=1;i<=n;i++){
		for(j=2;j<=m;j++){
			save1=map[i-1][j-1]+dis[i]*wea[j];
			save2=map[i][j-1];
			if(save1<save2)map[i][j]=save1;
			else map[i][j]=save2;
		}
		if(i!=n){
			for(k=1;k<=i+1;k++){
				map[i+1][k]=999999999;
			}
		}
	}
	printf("%d\n",map[n][m]);
	return 0;
}

Measured memory_bytes: 4896
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;


int calc(vector<int> x, int n){
    vector<int> a(n);
    rep(i, 0, n - 1) a[i] = x[i + 1] - x[i];
    // for(int ii = 0; ii < a.size(); ii++){
    //     if(ii) cout << ' ';
    //     cout << a[ii];
    // }
    // cout << endl;
    rep(i, 0, n - 1) x[i] = a[i];
    rep(i, 1, n - 1) a[i] += a[i - 1];
    int now = 0;
    rep(i, 0, n - 1) now += a[i];
    // cout << now << endl;
    int res = now;
    rep(i, 0, n - 2){
        now -= x[i] * (n - 1 - i);
        res += now;
        res %= mod;
    }
    return res;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(m);
    rep(i, 0, n) cin >> x[i];
    rep(i, 0, m) cin >> y[i];
    int tmp = calc(x, n);
    int tmp2 = calc(y, m);
    // cout << tmp << " " << tmp2 << endl;
    cout << tmp * tmp2 % mod << endl;
}

Measured memory_bytes: 3456
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
 
using namespace std;
using ll = long long;
 
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
 
int main()
{
	int x, i, sum = 0;

	cin >> x;

	for(i = 1;;i++){
		sum += i;
		if(sum >= x){
			break;
		}
	}

	cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    int N; cin >> N;
    N = N % 10;
    switch (N) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout << "hon" << endl;
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout << "pon" << endl;
            break;
        case 3:
            cout << "bon" << endl;
    }
}


Measured memory_bytes: 3620
//解答見てやり直し
#include <bits/stdc++.h>
using namespace std;

int n, k;
string s;

int main() {
    cin >> n >> k >> s;
    vector<int> chind(1); chind[0] = 0;
    for (int i = 1; i < n; i++) if (s[i] != s[i-1]) chind.push_back(i);
    chind.push_back(n);
    int chsize = chind.size();
    int res = 0;
    if (chsize < 2*k+1) {
        res = n;
    }else {
        vector<int> sum;
        for (int i = 0; i < chsize; i++) {
            int next;
            if (s[chind[i]] == '1') {
                next = chind[min(i+2*k+1, chsize-1)]-chind[i];
            }else{
                next = chind[min(i+2*k, chsize-1)]-chind[i];
            }
            sum.push_back(next);
        }
        res = *max_element(sum.begin(), sum.end());
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1528
n = int(input())
dic = {}
def f(num):
    while(num%2==0):
        num //= 2
        if(dic.get(2) is None):
            dic[2] = 1
        else:
            dic[2] += 1
    s = 3
    while((s*s) <= num):
        if((num % s)==0):
            if(dic.get(s) is None):
                dic[s] = 1
            else:
                dic[s] += 1
            num //= s
        else:
            s += 2

    
    if num != 1:
        if(dic.get(num) is None):
            dic[num] = 1
        else:
            dic[num] += 1


f(n)

l = []
for x,y in dic.items():
    cnt = 1
    if(y==1):
        l.append(x)
        continue
    while(y >= cnt):
        l.append((x**cnt))
        y -= cnt
        cnt += 1

print(len(l))
    




Measured memory_bytes: 9240
//    >File Name: atcodeC.cpp
//    > Author: Webwei

#include<bits/stdc++.h>
using namespace std;

long long a[100010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	long long n;
	cin>>n;
	for(int i=1;i<=n;i++)   cin>>a[i];
	long long m1=0,m2=0,c1=0,c2=0;
	for(int i=1;i<=n;i++){
		c1+=a[i];
		if(i%2==1&&c1>=0) m1+=(1LL+c1),c1=-1;
		if(i%2==0&&c1<=0) m1+=(1LL-c1),c1=1;
	}
	for(int i=1;i<=n;i++){
		c2+=a[i];
		if(i%2==1&&c2<=0) m2+=(1LL-c2),c2=1;
		if(i%2==0&&c2>=0) m2+=(1LL+c2),c2=-1;
	}
	cout<<min(m1,m2)<<"\n";
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;

int main() {
  string T;
  cin >> T;
  int p,d,s;
  s = T.size();
  p = 0;
  d = 0;

  for(int i=0;i<s;++i){
    if(T[i] == '?') T[i] = 'D';
  }

  cout<<T<<endl;



}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Mll = M<ll, ll>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin(),ie=(c).rend();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n;
string s,t;

int main() {
    cin >> s >> t;

    cout << t+s << '\n';

    return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vst = vector<st>;
using vch = vector<char>;
using vbl = vector<bl>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
#define mkp(a, b) make_pair(a, b) 
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  st t;
  cin >> t;
  vrep(i, t) if(i == '?') i = 'D';
  cout << t << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
 
#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
 #define PI acos(-1)
typedef long long     ll;
 
//-*-*-*-*-*-*-*-*-
 
 
 
 
const int N=2e5+100;
//ll a[200000];
 

#define lop(i,n) for(int i=0;i<n;++i)
//ll n,m,mod;
vector<ll>edge[200000];
int visted[100][100][999];
vector<pair<ll,ll>>vv;
map<string,ll>mp;
int main()
{
  ll n;cin>>n;/*
  for(int i=0;i<n;i++){cin>>a[i]>>b[i];}
  dp[0][a[0]]=b[0];
   for(int i=1;i<n;i++){
      for(int s=0;s<t-1;s++){
          dp[i][t+b[i]]=max( dp[i][t+a[i]], dp[i-1][t]+b[i]);
      }
       
   }*/
   ll ans=0;
    for(int i=0;i<n;i++){string x;cin>>x;if(mp[x]==0){ans++;mp[x]++;}}
 cout<<ans;
 
}

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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    int ans = 0;
    int highest = 0;
    rep(i, n) {
        cin >> h[i];
        if(h[i] >= highest) ans++;
        highest = max(h[i], highest);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b[200000],i,max,min;
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d",&b[i]);
  }
  min=b[0];
  max=b[1]-b[0];
  for(i=1;i<a;i++){
    if(max<b[i]-min){
      max=b[i]-min;
    }
    if(min>b[i]){
      min=b[i];
    }
  }
  
  printf("%d\n",max);
  return 0;
}


Measured memory_bytes: 2636
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
bool u[200000];
int main() {
	fill(u, u + 200000, true);
	u[0] = false; u[1] = false;
	for (int i = 2; i < 200000; i++) {
		if (u[i]) {
			int j = 2;
			while (i*j < 200000) {
				u[i*j] = false;
				j++;
			}
		}
	}
	int n, p;
	while (cin >> n >> p&&n != -1 || p != -1) {
		int a[100], f = 0;
		for (int i = n + 1; i < 200000 && f < p; i++) {
			if (u[i]) {
				a[f] = i;
				f++;
			}
		}
		int b[10000];
		f = 0;
		for (int i = 0; i < p; i++) {
			for (int j = i; j < p; j++) {
				b[f] = a[i] + a[j];
				f++;
			}
		}
		sort(b, b + f);
		cout << b[p-1] << endl;
	}
}

Measured memory_bytes: 3288
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define ll long long
#define PI 3.141592653589
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EPS 1e-7
#define PII pair<int,int>
#define s second
#define f first
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;
ll MOD = 1e9+7;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int random_int(int l,int r){return uniform_int_distribution<int>(l,r)(rng);}
ll fast_power(ll x, ll p){
    ll res = 1;
    while(p > 0){
        if(p & 1){
            res = (res * x)%MOD;
        }
        p = p >> 1;
        x = (x*x)%MOD;
    }
    return res;
}
ll dp[101][100005];
ll prefix[100005];
ll getRangeSum(int l, int r){
    return (prefix[r] - ((l-1 >= 0) ? prefix[l-1] : 0)+MOD)%MOD;
}
int main() {
    IO;
    ll n, k;
    cin >> n >> k;
    ll arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        prefix[0] = dp[i-1][0];
        for(int j = 1; j <= k; j++){
            prefix[j] = (prefix[j-1] + dp[i-1][j])%MOD;
        }
        for(int j = 0; j <= k; j++){
            ll l = max(j-arr[i-1], 1LL*0);
            ll r = j;
            dp[i][j] += getRangeSum(l, r);
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][k];



    return 0;
}


Measured memory_bytes: 79232