akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

char map[50][51];
int w,h,table[50][50],d_row[4] = {-1,0,0,1},d_col[4] = {0,-1,1,0};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= h-1 && col >= 0 && col <= w-1)return true;
	else{
		return false;
	}
}

void paint(int row,int col){
	if(table[row][col] == 2 || table[row][col] == 1){
		for(int i = 0; i < 4; i++){
			if((rangeCheck(row+d_row[i],col+d_col[i]) == true) && (table[row+d_row[i]][col+d_col[i]] == 0 || table[row+d_row[i]][col+d_col[i]] == 10)){
				table[row+d_row[i]][col+d_col[i]] += 1;
				paint(row+d_row[i],col+d_col[i]);
			}
		}

	}else if(table[row][col] == 4 || table[row][col] == 10){
		for(int i = 0; i < 4; i++){
			if((rangeCheck(row+d_row[i],col+d_col[i]) == true) && (table[row+d_row[i]][col+d_col[i]] == 0 || table[row+d_row[i]][col+d_col[i]] == 1)){
				table[row+d_row[i]][col+d_col[i]] += 10;
				paint(row+d_row[i],col+d_col[i]);
			}
		}
	}else if(table[row][col] == 11){
		for(int i = 0; i < 4; i++){
			if((rangeCheck(row+d_row[i],col+d_col[i]) == true) && (table[row+d_row[i]][col+d_col[i]] == 0 || table[row+d_row[i]][col+d_col[i]] == 1 || table[row+d_row[i]][col+d_col[i]] == 10)){
				table[row+d_row[i]][col+d_col[i]] = 11;
				paint(row+d_row[i],col+d_col[i]);
			}
		}
	}

}


void func(){

	for(int i = 0; i < h; i++){
		for(int k = 0; k < w; k++)table[i][k] = 0;
	}

	for(int i = 0; i < h; i++){
		scanf("%s",map[i]);
	}

	for(int i = 0; i < h; i++){
		for(int k = 0; k < w; k++){
			if(map[i][k] == 'B'){
				table[i][k] = 2;
			}else if(map[i][k] == 'W'){
				table[i][k] = 4;
			}
		}
	}

	for(int i = 0; i < h; i++){
		for(int k = 0; k < w; k++){
			if(table[i][k] == 2 || table[i][k] == 4){
				paint(i,k);
			}
		}
	}

	int black = 0,white = 0;

	for(int i = 0; i < h; i++){
		for(int k = 0; k < w; k++){
			if(table[i][k] == 1){
				black++;
			}else if(table[i][k] == 10){
				white++;
			}

		}
	}

	printf("%d %d\n",black,white);

}


int main(){

	while(true){
		scanf("%d %d",&w,&h);
		if(w == 0 && h == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 2636
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=1;i<=(n);++i)
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
int ind[100001];
int main()
{
	int n;
	scanf("%d",&n);
	rep(i,n)scanf("%d",&ind[i]);
	sort(ind+1,ind+n+1);
	int tct=0;
	long long result=1;
	rep(i,n)
	{
		++tct;
		if(tct-1>=(ind[i]+1)/2)
		{
			result=result*tct%1000000007;
			tct--;
		}
	}
	while(tct>0)
	{
		result=result*tct%1000000007;
		--tct;
	}
	cout<<result;
	
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-

import sys

def main():
    sp = [int(e) for e in sys.stdin.readline().split(" ")]
    n = sp[0]
    m = sp[1]

    M = [0] * m

    for l in sys.stdin:
        for e in [int(e) for e in l.strip().split(" ")][1:]:
            M[e-1] += 1

    i = 0
    for e in M:
        if e == n:
            i+=1

    print(i)

main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>

int const MAXN = 300;
int N, M, L;
bool done[MAXN];
int ans[MAXN][MAXN];

// dijkstra
template<typename T, int MAXN>
struct dijkstra {
  typedef std::pair<T, int> GP; // dist, id
  std::vector<GP> G[MAXN]; //dist, id
  T d[MAXN];
  int N_, INF_;
  dijkstra(int N, T inf) : N_(N), INF_(inf) {}
  void search(int s) {
    std::priority_queue<GP, std::vector<GP>, std::greater<GP>> q;
    std::fill_n(d, N_, INF_);
    d[s] = 0;
    q.push(GP(0, s));
    while(!q.empty()) {
      GP p = q.top(); q.pop();
      int v = p.second;
      if(d[v] < p.first) continue;
      for(auto e: G[v]) {
        int newd = d[v]+e.first;
        if(newd >= d[e.second]) continue;
        if(newd >= INF_) continue;
        d[e.second] = newd;
        q.push(GP(d[e.second], e.second));
      }
    }
  }
};

int main() {
  std::cin >> N >> M >> L;
  dijkstra<int, MAXN> dij(N, L+1);
  for(int i = 0; i < M; ++i) {
    int a, b, c; std::cin >> a >> b >> c; --a; --b;
    if(c > L) continue;
    dij.G[a].emplace_back(c, b);
    dij.G[b].emplace_back(c, a);
  }
  dijkstra<int, MAXN> di2(N, N);
  for(int s = 0; s < N; ++s) {
    dij.search(s);
    for(int i = 0; i < N; ++i) if(i!=s && dij.d[i] <= L) {
      di2.G[s].emplace_back(1, i);
    }
  }
  std::fill_n(done, N, false);
  int Q; std::cin >> Q;
  for(int i = 0; i < Q; ++i) {
    int s, t; std::cin >> s >> t; --s; --t;
    if(!done[s]) {
      di2.search(s);
      for(int i = 0; i < N; ++i) {
        ans[s][i] = std::max(0, di2.d[i] - 1);
        if(ans[s][i] >= N-1) ans[s][i] = -1;
      }
      done[s] = true;
    }
    std::cout << ans[s][t] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3308
list=[]
for i in range(4):
    a,b=input().split()
    a=int(a)
    b=int(b)
    if a==1:
        m=6000*b
    elif a==2:
        m=4000*b
    elif a==3:
        m=3000*b
    else:
        m=2000*b
    print(m)


Measured memory_bytes: 5600
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();

		List<String> rows = new ArrayList<>();
		while (sc.hasNext()) {
			String a = sc.nextLine();
			if (!a.equals("")) {
				rows.add(a);
			}
		}
		sc.close();

		boolean a = true;

		for (int i = 0; i < h ; i++) {
			for (int k = 0 ; k < w ; k++) {
				if (rows.get(i).charAt(k) == '#') {
					if (i == 0) {
						if (k == 0) {
							if (rows.get(i).charAt(k+1) == '.' && rows.get(i+1).charAt(k) == '.') {
								a = false;
								break;
							}
						} else if (k == w-1) {
							if (rows.get(i).charAt(k-1) == '.' && rows.get(i+1).charAt(k) == '.') {
								a = false;
								break;
							}
						} else {
							if (rows.get(i).charAt(k+1) == '.' && rows.get(i+1).charAt(k) == '.'
									&& rows.get(i).charAt(k-1) == '.') {
								a = false;
								break;
							}
						}
					} else if (i == h-1) {
						if (k == 0) {
							if (rows.get(i).charAt(k+1) == '.' && rows.get(i-1).charAt(k) == '.') {
								a = false;
								break;
							}
						} else if (k == w-1) {
							if (rows.get(i).charAt(k-1) == '.' && rows.get(i-1).charAt(k) == '.') {
								a = false;
								break;
							}
						} else {
							if (rows.get(i).charAt(k+1) == '.' && rows.get(i-1).charAt(k) == '.'
									&& rows.get(i).charAt(k-1) == '.') {
								a = false;
								break;
							}
						}
					} else {
						if (k == 0) {
							if (rows.get(i).charAt(k+1) == '.' && rows.get(i+1).charAt(k) == '.'
									&& rows.get(i-1).charAt(k) == '.') {
								a = false;
								break;
							}
						} else if (k == w-1) {
							if (rows.get(i).charAt(k-1) == '.' && rows.get(i+1).charAt(k) == '.'
									&& rows.get(i-1).charAt(k) == '.') {
								a = false;
								break;
							}
						} else {
							if (rows.get(i).charAt(k+1) == '.' && rows.get(i+1).charAt(k) == '.'
									&& rows.get(i).charAt(k-1) == '.' && rows.get(i-1).charAt(k) == '.') {
								a = false;
								break;
							}
						}
					}
				}
			}
		}

		if (a) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for(auto &x: A) cin >> x;

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

	long long M = 0;
	for(int i = 0; i < N ; i++) {
		if(i == 0) M -= A[i];
		else if(i == N - 1) M += A[i];
		else if(A[i] < 0) M -= A[i];
		else M += A[i];
	}
	cout << M << endl;
	int P = 1, Q = 1;
	for(int i = 1; i < N - 1; i++) {
		if(A[i] < 0) P++;
		else Q++;
	}

	long long a = A[0], b = A[N - 1];

	while(Q > 1) {
		cout << a << " " << A[N - Q] << endl;
		a -= A[N - Q];
		Q--;
	}

	while(P > 1) {
		cout << b << " " << A[P - 1] << endl;
		b -= A[P - 1];
		P--;
	}

	cout << b << " " << a << endl;
}


Measured memory_bytes: 2304
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define fo(i,n) for(long long i=0;i<n;i++)
#define ll long long int
#define inf 999999999999999999
#define pb push_back
#define MOD 1000000007
#define tr(c,it) for(auto it = (c).begin(); it != (c).end(); ++it)
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms\n" ;
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a);
        a = (a * a);
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
	if(b%a==0)
	   return a;
	return gcd(b%a,a);
}
int32_t main() 
{
    fio
	ll j,i,n,t,l,r,c,h,k,m,maxi,d,x;
	cin>>n;
	d=n%10;
	if(d==0||d==1||d==6||d==8)
		cout<<"pon";
	else if(d==3)
		cout<<"bon";
	else
		cout<<"hon";
}



	

		

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

int main(){
  ll A,B,K;
  cin>>A>>B>>K;
  if(A+B<=K){
    cout<<0<<" "<<0<<endl;
  }
  else{
    if(A>=K){
      cout<<A-K<<" "<<B<<endl;
    }
    else{
      cout<<0<<" "<<B-(K-A)<<endl;
    }
  }
}

Measured memory_bytes: 3628
n, t_limit = map(int, input().split())
cts = [list(map(int, input().split())) for _ in range(n)]
min_c = 10000
for c, t in cts:
    if t <= t_limit and c < min_c:
        min_c = c
if min_c == 10000:
    print('TLE')
else:
    print(min_c)


Measured memory_bytes: 2940
#include <stdio.h>
 int f(int x){
  return x*x;
}

int area(int d)
{
 int i = 0, a, b, c = 0;
  a = 600/d;
   for(i = 0; i < a; i++) {
    b = d*f(i*d);
    c = c + b;
  }
 return c;
}

int main(void)
{
  int d;
  while(scanf("%d",&d)!=EOF){
     printf("%d\n",area(d));
  }
  return(0);
}


Measured memory_bytes: 2028
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	string st; cin >> st;
	int D; cin >> D;
	int zeronum = count(st.begin(), st.end(), '0');
	int onenum = st.size() - zeronum;
	
	string ans(st);
	int rest = D;
	for (auto &c : ans) {
		if (c == '0') {
			if (rest) {
				c = '1';
				rest--;
			}
		}
	}
	for (int i = N - 1; i >= 0; --i) {
		if (st[i] == '1') {
			if (rest) {
				rest--;
				ans[i] = '0';
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 3224
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String str = sc.next();
		char[] input = str.toCharArray();
		int n = str.length();
		int p = 2019;

		int modCount[] = new int[2019];
		int[] pCount = new int[10001];

		long tmp = 0;
		int times = 1;
		long result = 0;

		for(int j = n - 1; j >= 0; j--){
			tmp += (input[j] - '0') * times;

			int mod = (int)(tmp % p);

			result += pCount[mod];

			if(mod == 0){
				result++;
			}


			pCount[mod]++;

			times *= 10;
			//オーバーフロー対策（ただしこれはpが2や5だと使えない）
			times %= p;
		}

		System.out.println(result);
	}
}


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

using namespace std;

void Main()
{
    char b;
    cin >> b;

    if (b == 'A' || b == 'T')
        b ^= 'A' ^ 'T';
    if (b == 'C' || b == 'G')
        b ^= 'C' ^ 'G';

    cout << b;
}

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

    std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){
	if(b==0)	return a;
	if(a%b==0)	return b;
	return gcd(b,a%b);
}
int main(){
	int n,i;
	cin >> n;
	ll a[n];
	for(i=0;i<n;i++)	cin >> a[i];
	if(n==2){
		cout << max(a[0],a[1]) << endl;
		return 0;
	}
	ll L[n],R[n];
	L[0] = R[n-1] = 0;
	L[1] = a[0];
	R[n-2] = a[n-1];
	for(i=2;i<n;i++){
		L[i] = gcd(L[i-1],a[i-1]);
		R[n-1-i] = gcd(a[n-i],R[n-i]);
	}
	
	ll ans=0;
	for(i=0;i<n;i++){
		ll sub = gcd(L[i],R[i]);
		if(sub>ans)	ans=sub;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
/* ex 7_1
   unomi */

#include <stdio.h>

// 頂点を表す構造体 point
typedef struct point{
int x_elem;
int y_elem;
}point;

point shift_point(point pnt, int dist_x, int dist_y){
    // 新しい頂点の宣言
    point new_pnt={0,0};
    // 頂点の計算
    new_pnt.x_elem = pnt.x_elem + dist_y;
    new_pnt.y_elem = pnt.y_elem - dist_x;
    return new_pnt;
}

int main(void){
    int dist_x, dist_y;
    point pnt_1={0,0}, pnt_2={0,0}, pnt_3={0,0}, pnt_4={0,0};
    // 頂点の取得
    scanf("%d %d %d %d", &pnt_1.x_elem, &pnt_1.y_elem, &pnt_2.x_elem, &pnt_2.y_elem);

    // pnt_1,2のx軸方向での距離：pnt_1.x_elem - pnt_2.x_elem
    //          y軸方向での距離：pnt_1.y_elem - pnt_2.y_elem
    dist_x = pnt_1.x_elem - pnt_2.x_elem;
    dist_y = pnt_1.y_elem - pnt_2.y_elem;

    // 関数shift_point で移動した他の頂点を求める
    pnt_3 = shift_point(pnt_2, dist_x, dist_y);
    pnt_4 = shift_point(pnt_1, dist_x, dist_y);

    printf("%d %d %d %d\n", pnt_3.x_elem, pnt_3.y_elem, pnt_4.x_elem, pnt_4.y_elem);

    return 0;
}

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

int main() {
    int N; cin >> N;
    vector<long long> A(N), B(N);
    for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

    using P = pair<long long, int>;
    vector<P> C(N);
    for(int i=0; i<N; ++i) C[i] = P(A[i] + B[i], i);
    sort(begin(C), end(C), greater<P>());

    long long res = 0;
    for(int i=0; i<N; ++i) {
        if((i & 1) == 0) {
            res += A[C[i].second];
        } else {
            res -= B[C[i].second];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef  long long ll;
const int MAX_N=2e5+1,OO=0x3f3f3f3f;
int main(){
 for(int i=1,x;i<=5;i++){
     cin>>x;
     if(!x)return cout<<i,0;
 }

}

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

using namespace std;

int main(){
  int n, m, a[200009], b[200009];
  vector<int> v[200009];
  cin >>n >> m;
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
  }
  int d[200009];
  for(int i=0;i<n;i++){
    d[i] = -1;
  }
  d[0] = 0;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int cur = q.front();q.pop();
    for(int i=0;i<v[cur].size();i++){
      if(d[v[cur][i]]==-1){
        d[v[cur][i]] = d[cur] + 1;
        q.push(v[cur][i]);
      }
    }
  }
  for(int i=1;i<n;i++){
    if(d[i]==-1){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  for(int i=1;i<n;i++){
    for(int j=0;j<v[i].size();j++){
      if(d[i]==d[v[i][j]]+1){
        cout << v[i][j] + 1 << endl;
        break;
      }
    }
  }
}



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

typedef complex<int> point;
typedef long long int lli;
typedef long double ld;
#define pii pair<int,int>
#define lasB(b) (b&(-b))
#define pld pair<ld,ld>
#define mod 1000000007
#define PI acos(-1.0)
#define PB push_back
#define N   1000006
#define EPS (1e-8)
#define ss substr
#define S second
#define IM image
#define F first
#define RE real
#define B begin
#define E end

int n,c,t1,t2,sol=1000000;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>c;
    for(int i=0;i<n;i++)
    {
        cin>>t1>>t2;
        if(t2<=c)
        {
            sol=min(sol,t1);
        }
    }
    if(sol==1000000)cout<<"TLE";
        else cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510
 
const ll mod=1e9+7,N=1e5+5,INF = 1e18;

ll n,W;
ll w[105],v[105];
ll dp[100005]; // dp[i] -> min weight for value i 
int main() 
{ 
    BOOST

    cin >> n >> W;

    for(int i=0;i<=N;i++)
        dp[i] = INF;   

    ll max_v = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> w[i] >> v[i];
        max_v+=v[i];
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++)    
        for(int j = max_v; j >= v[i]; j--)
            dp[j] = min(dp[j], w[i] + dp[j - v[i]]);

    ll ans=0;

    for(int i=1;i<=max_v;i++)
        if(dp[i]<=W)
            ans = i;
    // for(int i=0;i<=max_v;i++)
    //     cout<<dp[i]<<" ";
    // cout<<"\n";
    cout << ans << "\n";

    return 0; 
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int i,j,k,n,m,l,count1=0;
void ABC140(void);
void ABC141(void);
void ABC142(void);
void ABC143(void);
void ABC144(void);
void ABC145(void);
void ABC146(void);
void ABC147(void);
void ABC148(void);
void ABC149(void);

int main(void){
    ABC148();
}

void ABC148(){
    cin>>n;
    string s,t;
    cin>>s>>t;
    for(i-0;i<n;i++){
        cout<<s[i]<<t[i];
    }
    cout<<endl;
}


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}


void solve(int &test) {
    int l, r, d;
    cin >> l >> r >> d;
    cout << r/d-l/d+(l%d == 0) << endl;
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock(); 

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

    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= t; ++i){
        solve(i); 
    }

    cerr << time(start);
    return 0;
}

Measured memory_bytes: 3796
// +build ignore
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	N := sc.nextInt()
	M := sc.nextInt()

	rooms := make(map[int][]int)
	for i := 0; i < M; i++ {
		A := sc.nextInt()
		B := sc.nextInt()
		if _, ok := rooms[A]; !ok {
			rooms[A] = make([]int, 0)
		}
		if _, ok := rooms[B]; !ok {
			rooms[B] = make([]int, 0)
		}
		rooms[A] = append(rooms[A], B)
		rooms[B] = append(rooms[B], A)
	}

	q := make([]int, 0)
	q = append(q, 1)
	dist := make(map[int]int)
	prev := make(map[int]int)

	for len(q) != 0 {
		v := q[0]
		q = q[1:]
		for _, u := range rooms[v] {
			if _, ok := prev[u]; ok {
				continue
			}
			dist[u] = dist[v] + 1
			prev[u] = v
			q = append(q, u)
		}
	}

	fmt.Println("Yes")
	for i := 2; i <= N; i++ {
		fmt.Println(prev[i])
	}

	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 30668
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            long K = in.nextInt();
            long A = in.nextInt();
            long B = in.nextInt();
            if (A >= B || A + 1 == B) {
                System.out.println(K + 1);
                return;
            }
            long b = A;
            long count = A - 1;
            b += ((K - count) / 2) * (-A + B);
            count += ((K - count) / 2) * 2;
            if (count < K) {
                b++;
            }
            System.out.println(b);
        }
    }
}


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  ll a, p;
  cin >> a >> p;
  cout << (a * 3 + p) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		long n= in.nextLong();
		System.out.println(check(n) ? "Yes" : "No");
	}

	public static boolean check(long n) {
		long nn = n;
		long sum = 0;
		while(nn>0) {
			sum += nn % 10;
			nn /= 10;
		}

		return (n % sum) == 0;
	}

}

Measured memory_bytes: 22740
#include<stdio.h>
#include<string.h>
#define LEN 100005

using namespace std;

typedef struct p{
    char name[100];
    int time;
} process;

process Q[LEN];
int head, tail;

void enqueue(process x) {
    Q[tail] = x;
    tail = (tail+1) % LEN;
}

process dequeue() {
    process temp = Q[head];
    head = (head+1) % LEN;
    return temp;
}

bool isEmpty() {
    return head == tail;
}

int main()
{
    int elaps = 0;
    int n, q;
    scanf("%d %d", &n, &q);

    for(int i = 0; i < n; i++) {
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].time);

        enqueue(Q[i]);
    }

    while(!isEmpty()) {
        process temp = dequeue();

        if(temp.time - q <= 0) {
            elaps = elaps + temp.time;
            printf("%s %d\n", temp.name, elaps);
        }else {
            elaps = elaps + q;
            temp.time = temp.time - q;
            enqueue(temp);
        }
    }

    return 0;
}

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

void merge_sort (int array[], int left, int right) {
  int i, j, k, mid;
  int work[100000];  // 作業用配列
  if (left < right) {
    mid = (left + right)/2; // 真ん中
    merge_sort(array, left, mid);  // 左を整列
    merge_sort(array, mid+1, right);  // 右を整列
    for (i = mid; i >= left; i--) { work[i] = array[i]; } // 左半分
    for (j = mid+1; j <= right; j++) {
      work[right-(j-(mid+1))] = array[j]; // 右半分を逆順
    }
    i = left; j = right;
    for (k = left; k <= right; k++) {
      if (work[i] < work[j]) { array[k] = work[i++]; }
      else                   { array[k] = work[j--]; }
    }
  }
}

class segTree {
public:
	long long N;
	int *T;
	void init(int num) {
		N = 1;
		while (N < num) {
			N *= 2;
		}
		T = (int *)calloc((2 * N - 1), sizeof(int));
	}
	int act(int l, int r) {
		return l + r;
	}
	void add(int x, int v) {
		long long k = x + N - 1;
		T[k] += v;
		while (k > 0) {
			k = int(floor((k - 1) / 2));
			T[k] += v;
		}
	}
	int getV(int l, int r) {
		return getVs(l, r, 0, 0, N - 1);
	}
	int getVs(int l, int r, int k, int kl, int kr) {
		if (l <= kl && r >= kr) {
			return T[k];
		}
		int t = int(floor((kl + kr) / 2));
		if (l > t) {
			return getVs(l, r, 2 * k + 2, t + 1, kr);
		}
		if (r < t + 1) {
			return getVs(l, r, 2 * k + 1, kl, t);
		}
		return act(getVs(l, r, 2 * k + 1, kl, t),
			getVs(l, r, 2 * k + 2, t + 1, kr));
	}
	~segTree()
	{
		free(T);
	}
};

bool judge(int x, long long N, int *a) {
	int *v;
	v = (int *)malloc((N + 1) * sizeof(int));
	int mi = 0;
	int ma = 0;
	v[0] = 0;
	for (int i = 0; i < N; i++) {
		v[i + 1] = v[i] + (a[i] < x ? -1 : 1);
		if (mi > v[i + 1])
			mi = v[i + 1];
		if (ma < v[i + 1])
			ma = v[i + 1];
	}
	segTree b;
	b.init(ma - mi + 1);

	long long Ans = 0;
	for (int i = 0; i < N + 1; i++) {
		Ans += b.getV(0, v[i] - mi);
		b.add(v[i] - mi, 1);
	}
	return Ans >= N * (N + 1) / 4;
}

int main()
{
	int N;
	scanf("%d", &N);
	int *a;
	int *b;
	a = (int *)malloc(N * sizeof(int));
	b = (int *)malloc(N * sizeof(int));
	for (int i = 0; i < N; i++) {
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
  	merge_sort(b, 0, N - 1);
	int re = b[0];
	int cnt = 1;

	for (int i = 1; i < N; i++) {
		if (b[i] != re) {
			re = b[i];
			b[cnt] = b[i];
			cnt++;
		}
	}
	int ok = 0;
	int ng = cnt;
	int mid;
	while (ng - ok > 1) {
		mid = int(floor((ok + ng) / 2));
		if (judge(b[mid], N, a)) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	printf("%d\n", b[ok]);
}


Measured memory_bytes: 14576
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>

using namespace std;

int tst_count;

void inserSort(int A[], int n, int g){
    if (g > n) return;
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j = j - g;
            tst_count++;
        }
        A[j + g] = v;
    }
}

void shell(int A[],int n){
    tst_count = 0;
    int m = 13;
    int G[13] = {1,4,13,40,121,364,1093,3280,9841,29524,88573,265720,797161};
    
    while (G[m-1] > n) {
        m--;
    }

    for (int i = m-1; i >= 0; i--) {
        inserSort(A,n,G[i]);
    }
    
    cout << m << endl << G[m-1];
    for (int i = m-2; i >= 0; i--) {
        cout << " " << G[i];
    }
    cout << endl << tst_count << endl;
}

int main(){
    int n;
    int A[1000001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d",&A[i]);
    }
    
    shell(A,n);
    
    for (int i = 0; i < n; i++) {
        printf("%d\n",A[i]);
    }
    
    return 0;
}

Measured memory_bytes: 5176
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
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 calc(int a, int b) {
    int d = abs(a - b);
    if (d % 2 == 1) {
        writeln("IMPOSSIBLE");
        return;
    }
    writeln(min(a, b) + d / 2);
}

void calc2(int a, int b) {
    if (a % 2 != b % 2) {
        writeln("IMPOSSIBLE");
        return;
    }
    writeln((a + b) / 2);
}

void main() {
    int a, b; scan(a, b);
    calc2(a, b);
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;


void solve(long long N){

    long long ans;
    long long n, n3, n5, n15;
    long long n3_i, n5_i, n15_i;
    n = N*(N+1)/2;
    n3_i = N/3;
    n5_i = N/5;
    n15_i = N/15;
    n3 = n3_i*(3+n3_i*3)/2;
    n5 = n5_i*(5+n5_i*5)/2;
    n15 = n15_i*(15+n15_i*15)/2;
    //cout << n << endl;
    //cout << n3_i << endl;
    //cout << n3 << endl;
    //cout << n5 << endl;
    //cout << n15 << endl;
    ans = n - n3 - n5 + n15;

    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3764
h, w = map(int, input().split())
grid = []
for i in range(h):
  s = input()
  if '#' in s:
    grid.append(list(s))
h = len(grid)

for j in range(w)[::-1]:
  skip = False
  for i in range(h):
    if grid[i][j] == '#':
      skip = True
      break
  if not skip:
    for i in range(h):
      grid[i][j] = ''

for row in grid:
  print(''.join(row))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a[100001], b[100001], c[100001], i, j, n, s, e;
	for (i=2; i<=100000; i++) a[i]=1;
	for (i=2; i<=int(sqrt(100000)); i++)
		if (a[i]==1)
			for (j=i*2; j<=100000; j+=i) a[j]=0;
	b[1]=0;
	b[2]=0;
	for (i=3; i<=100000; i++)
		if (a[i]==1&&a[(i+1)/2]==1) b[i]=1;
	c[1]=0;
	c[2]=0;
	for (i=3; i<=100000; i++) c[i]=c[i-1]+b[i];
	cin >> n;
	for (i=1; i<=n; i++)
	{
		cin >> s >> e;
		cout << c[e]-c[s-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
from itertools import accumulate
from collections import Counter


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    S = [0] + list(accumulate(A)) + [10**9+1]
    C = Counter(S)
    ans = 0
    for k, v in C.most_common():
        if v >= 2:
            ans += v * (v-1) // 2
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 54148
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 62168
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
long long solve(string s){
	int res=0,cnt=1;
	for(int i=1;i<s.size();i++){
		if(s[i]!=s[i-1]){
			res+=cnt/2;
			cnt=1;
		}else
		cnt++;
	}
	res+=cnt/2;
	re res;
}
string s;
long long k,ans;
int main(){
	cin>>s>>k;
	bool f=true;
	for(int i=0;i<sz(s)-1;i++)
	if(s[i]!=s[i+1])
	f=false;
	if(f){
		ans=sz(s)*k;
		cout<<ans/2ll;
		re 0;
	}
	cout<<solve(s)+(solve(s+s)-solve(s))*(k-1);
	re 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


int main() {
	ll n, k; cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	vector<ll> cnt(64);
	for (int i = 0; i < n; i++) {
		for (ll j = 0; j <= 62; j++) {
			cnt[j] += (a[i] >> j) & 1;
		}
	}
	vector<vector<ll>> dp(64, vector<ll>(4, -1e18));
	dp[63][1] = 0;
	for (int i = 62; i >= 0; i--) {
		if ((1LL << i) < k) dp[i][0] = dp[i + 1][0] + (max(n - cnt[i], cnt[i]) << i);
		if ((k >> i) & 1) dp[i][0] = max(dp[i][0], dp[i + 1][1] + (cnt[i] << i));
		dp[i][1] = dp[i + 1][1] + ((k >> i) & 1 ? ((n - cnt[i]) << i) : (cnt[i] << i));
	}
	cout << max(dp[0][0], dp[0][1]) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define nMIN 2
#define nMAX 200000
#define RtMIN 1
#define RtMAX 1000000000


int main(){
int R[nMAX],Time,i,max=0,sub;

scanf("%d",&Time);
if(nMIN<=Time&&Time<=nMAX){
for(i=0;i<Time;i++){
scanf("%d",&R[i]);
if(RtMIN>R[i]||R[i]>RtMAX)exit(1);
}
max=R[i-1];
sub=R[i-1]-R[i-2];
for(i=Time-2;i>=0;i--){

if(max<R[i]&&i!=0){
max=R[i];
}
if(sub<max-R[i]&&R[i]!=max){
sub=max-R[i];
}
}
}
 else exit(1);

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



Measured memory_bytes: 2508
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<queue>
#include<map>
#include<math.h>

#define FASTREAD      ios_base::sync_with_stdio(0);cin.tie(nullptr);
#define ll long long
#define dd double
#define scl(n)        scanf("%lld",&n)
#define scd(n)        scanf("%lf",&n)
#define scc(n)        scanf("%c",&n)
#define scs(n)        scanf("%s",&n)
#define ptl(n)        printf("%lld",n)
#define ptd(n)        printf("%f",n)
#define ptc(n)        printf("%c",n)
#define pts(n)        printf("%s",n)
#define nline         printf("\n")
#define pb            push_back
#define FOR(i,a,b)    for(ll i=a;i<=b;i++)
#define FORr(i,a,b)   for(ll i=a;i<=b;i--)
#define pi            2*acos(0.0)
#define pii           pair<ll,ll>
#define uu            first
#define vv            second

using namespace std;

int main()
{
    ll x;
    scl(x);
    x=(x==0)?1:0;
    ptl(x);
    nline;
    return 0;
}


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



using namespace std;
#define mod 1000000007
int main()
{
  
   long long  int n,k,c=0,c1=0;
    cin>>n>>k;
    vector<long long int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++)
      for(int j=i+1;j<n;j++)
        if(a[i]>a[j])c++;
    c=((c%mod)*(k%mod))%mod;
   // for(int i=0;i<n;i++)a.push_back(a[i]);
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
        if(a[i]<a[j])c1++;
    c1=((k*(k-1))/2)%mod*(c1);
    cout<<(c+c1)%mod;
    return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

int main(){
	long long A, B, K;
	cin >> A >> B >> K;

	if(K>= A+B) {
		cout << "0 0"<<endl;
		return 0;
	}
	if(K>=A) {
		cout << 0 << " " << A + B - K << endl;
		return 0;
	}
	cout << A - K << " " << B << endl;


}


Measured memory_bytes: 3532
k,n=map(int,input().split(" "))
list=list(map(int,input().split(" ")))
#print(list)
dis=[]
for i in range(n-1):
    dis.append(list[i+1]-list[i])
dis.append(list[0]+k-list[n-1])
print(k-max(dis))

Measured memory_bytes: 85084
n=int(input())
a=list(map(float,input().split()))
ans=0

dp=[[0]*(n+1) for i in range(n+1)]
dp[0][0]=1

for i in range(n):
  for j in range(i+1):
    dp[i+1][j+1]=dp[i][j]*a[i]+dp[i][j+1]*(1-a[i])
    dp[i+1][j]=dp[i][j]*(1-a[i])+dp[i][j-1]*(a[i])
  
  
for i in range(n//2+1,n+1):
  ans+=dp[-1][i]
  
  
print(ans)

Measured memory_bytes: 202356
package main

/*fmtパッケージ　コンソールに出力できる*/
import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

/*　入力方法
１、簡単に書く
fmt.Scan
2,たくさん読む()
bufio.Scanner
(テキストを1行ずつ読み込む。fileからscannerを生成し、scan()が末尾に達してfalseを返すまで読み込む。Text()を呼ぶことで文字列として取り出すことができる)
3,長い行を読む
bufio.ReadLine
4, スペース区切りのデータを読み込む
sc.Split(bufio.ScanWords)
#########バッファの最大読み込みの数を変更するには
sc.Buffer(buf,MaxBuf)#MAXBUFのところにサイズをしていする
*/

/* 書き込み
１、接頭辞F（前）
書き込み先を指定できる
2,接頭辞S(前)
出力ではなくフォーマットした結果を文字列で返す
3,接頭辞 f（後ろ）
フォーマット（文字列型など）を指定することができる
４、接頭辞 ln（後ろ）
オペランドの間に半角スペースが入り、文字列の最後に開業が追加
##########PrintlnとPrintfの違いはprintlnは出力後に改行を作るがPrintfは改行を作らない


・interface{}型
どのような型がくるかわからないときに演算はできないが全ての型を受ける
new(T)
任意の型

*/
/*
フォーマット文字列（Printfでこれに埋め込むことができる）
%c 1文字を出力　　　%d　　整数を10進む
%s 文字列を出力

指定子	対応する型	説明	使用例
%c	char	１文字を出力する
%s	char *	文字列を出力する
%d	int, short	整数を10進で出力する
%u	unsigned int, unsigned short	符号なし整数を10進で出力する
%o	int, short,unsigned int, unsigned short	整数を8進で出力する
%x	int, short,unsigned int, unsigned short	整数を16進で出力する
%f	float	実数を出力する
%e	float	実数を指数表示で出力する
%g	float	実数を最適な形式で出力する
%ld	long	倍精度整数を10進で出力する
%lu	unsigned long	符号なし倍精度整数を10進で出力する
%lo	long, unsigned long	倍精度整数を8進で出力する
%lx	long, unsigned long	倍精度整数を16進で出力する
%lf	double	倍精度実数を出力する
*/
/*
strconvパッケージ→　文字列と基本データ型の双方向変換を実装
func Atob(str string)(value bool,err os.Error)
文字列で表されている論理値を返す。それ以外のときはエラー

func Atof(s string)(f float,err os.Error)
floatのサイズによってAtof32またはAtof64を呼ぶ

func Atoi(s string(i int,error os.Error))

strconv.ParseInt(文字列、１０（１０進数）,64(ビット))
戻り値がint型を返す

*/
/*
func read() string{
	sc.Scan()
	return sc.Text()
}
・スペース区切りの設定
sc.Split(bufio.Scanwords)

・int
n,_=strconv.Atoi(read())

・string
str:=read()

・array
a:=make([]int,n)
for i:=0;i<n;i++{
a[i],_=strconv.Atoi(read())
}
#中身を入れて宣言できる
array1:=[]int{}
#長さを指定して宣言できる
array2:=make([]int,)
.map
a:=make([]int,n)
for i:=0;i<n;i++{
a[i],_=strconv.Atoi(read())

}


*/
/*
変数の定義　:=
変数の再代入　=
型が違う変数に代入することができない
*/
const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

/*strings.Splitで入力したものを分ける*/
func Scanner() []string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	slice := strings.Split(s, " ")
	return slice

}

/* ---------------IO-------------------*/
func next() string {
	sc.Scan()
	return sc.Text()

}

/*型変換*/
func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		/*panic関数　　強制的にエラーを発生させるもの*/
		panic(err)
	}
	return i

}

/* 整数型に型変換したものを配列に格納する*/
func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

var fp *os.File

func delete(a []int, i int) []int {
	a = append(a[:i], a[i+1:]...)
	return a
}

/*arrayや文字列の値を一個ずつ取り出すrange s (返り値の一つ目はindex,もう一つが値)
 */
/*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""*/
func main() {
	var s, w int
	fmt.Scan(&s)
	fmt.Scan(&w)
	if s <= w {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}

}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

int n, m, q;
int a[55], b[55], c[55], d[55];
int ans[15], maxScore = 0;
void nasu(int x){
  if(x <= n){
    for(int i = ans[x - 1];i <= m;i ++){
      ans[x] = i;
      nasu(x + 1);
    }
  } else {
    int score = 0;
    reps(i, q){
      if(ans[b[i]] - ans[a[i]] == c[i]){
	score += d[i];
      }
    }
    maxScore = max(maxScore, score);
  }
  return;
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  cin >> n >> m >> q;
  reps(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  ans[0] = 1;
  nasu(1);
  cout << maxScore << '\n';
  return 0;
}


Measured memory_bytes: 3616
N = int(input())
C0 =0
C1 =0
C2 = 0
C3 = 0
for i in range(N):
  s = input()
  if s == 'AC':
    C0 += 1
  elif s == 'WA':
    C1 += 1
  elif s == 'TLE':
    C2 += 1
  else:
    C3 += 1
print('AC x ' + str(C0))
print('WA x ' + str(C1))
print('TLE x ' + str(C2))
print('RE x ' + str(C3))

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vs=vector<string>;
using msi=map<string,int>;
using mii=map<int,int>;
using pii=pair<int,int>;
using vlai=valarray<int>;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9

int n;
vs s;
int solve(int p){
    char c=s[p].back();
    if("+*"s.find(c)!=string::npos){
        vi a;
        for(int i=p+1;i<n && s[i].length()>s[p].length();i++){
            if(s[i].length()==s[p].length()+1)
                a.pb(solve(i));
        }
        if(c=='+'){
            return accumulate(all(a),0);
        }else{
            return accumulate(all(a),1,[](int _,int __){return _*__;});
        }
    }else{
        return (int)(c-'0');
    }
}


int main(){
	while(cin>>n,n){
	    s.clear();
	    s.resize(n);
		rep(i,n)cin>>s[i];
		cout<<solve(0)<<endl;
	}
	return 0;
}



Measured memory_bytes: 3132
#include <iostream>
#include <string>

using namespace std;

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

    string S; cin >> S;

    bool ans = false;
    if (S.size() % 2 == 0) {
        ans = true;
        int half = S.size() / 2;
        for (int i = 0; i < half; i++) {
            if (S[i] != S[i + half]) ans = false;
        }
    };

    cout << ((ans) ? "Yes" : "No") << endl;
}


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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++) {
    ll temp;
    cin >> temp;
    a[i]=temp-(i+1);
  }
  ll sum=0;
  for(int i=0;i<n;i++) {
    sum+=a[i];
  }
  sort(a.begin(), a.end());
  ll small=a[a.size()/2];
  ll ans=1e18;
  while(1) {
    ll tans=0;
    ll pn=0;
    ll mn=0;
    ll zn=0;
    for(ll j=0;j<n;j++) {
      tans+=abs(a[j]-small);
      if(a[j]-small<0) {
        mn++;
      }
      else if(a[j]-small>0) {
        pn++;
      }
      else {
        zn++;
      }
    }
    if(ans==tans) break;
    ans=min(ans,tans);
    if(mn>zn+pn) {
      small--;
    }
    else if(pn>zn+mn) {
      small++;
    }
    else break;
  }
  cout << ans << endl;
}

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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

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

long long f(long long j, long long i) {
  int cnt = 1;
  while (j % i == 0) {
    j /= i;
    cnt++;
  }
  return cnt;
}

int main() {
  _upgrade;
  long long n;
  cin >> n;
  vector<bool> sieve(n + 1);
  vector<long long> f_values(n + 1, 1);

  for (int i = 2; i < n + 1; i++) {
    if (!sieve[i]) {
      for (int j = i; j < n + 1; j += i) {
        sieve[j] = true;
        f_values[j] *= f(j, i);
      }
    }
  }

  long long res = 0;
  for (long long i = 1; i <= n; i++) {
    res += i * f_values[i];
  }

  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 82656
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int count = 1;
    while(true){
      int value = sc.nextInt();
      if (value == 0){
        break;
      }
      System.out.println("Case " + count + ": " + value);
      count++;
    }
  }
}


Measured memory_bytes: 42572
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000
typedef long long i64;

int n, m;
pair<int,int> a[MAXN*2];

int input() {
	if (scanf("%d %d", &n, &m) < 0) return 0;
	for (int i=0; i<n; i++) {
		int x;
		scanf("%d", &x);
		a[i] = {x, 1};
	}
	for (int i=0; i<m; i++) {
		int b, c;
		scanf("%d %d",&b, &c);
		a[n+i] = {c,b};
	}
	return 1;
}

void init() {
}

i64 solve() {
	sort(a, a+n+m, greater<pair<int,int>>());
	int c = 0;
	i64 s = 0;
	for (int i=0; i<n+m && c<n; i++) {
		i64 k = min(n-c, a[i].second);
		s += k*a[i].first;
		c += k;
	}
	return s;
}

void output(i64 ans) {
	printf("%lld\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 1792
#include <iostream>

int main() {
  	int A, B; std::cin >> A >> B;
    std::string s; std::cin >> s;
  	for (int i = 0; i < A; ++i) {
    	if (s[i] < '0' || s[i] > '9') {
        	std::cout << "No\n"; 
          	return 0;
        }
    }
    if (s[A] != '-') {
		std::cout << "No\n";
        return 0;
    }
    for (int i = A+1; i < A+B+1; ++i) {
    	if (s[i] < '0' || s[i] > '9') {
        	std::cout << "No\n";
          	return 0;
        }
    }
    std::cout << "Yes\n";
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

void Main(){
    int n;
    cin >> n;
    if (n % 1000 == 0) cout << 0 << en;
    else cout << 1000 - (n % 1000) << en; 
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 3632