akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace _034_RailwayLines
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] inputNum = inputStr.Split (',').Select (int.Parse).ToArray ();

				int[] velocity = inputNum.Skip (10).ToArray ();
				int distanceSum = inputNum.Take (10).Sum ();

				//time = distance / (velocity1 + velocity2)
				double crossTime = 1.0 * distanceSum / velocity.Sum ();
				double crossDistance = velocity[0] * crossTime;

				int stationNumber = 0;
				while (0 < crossDistance)
				{
					crossDistance -= inputNum[stationNumber];
					stationNumber++;
				}

				Console.WriteLine (stationNumber);
			}
		}
	}
}

Measured memory_bytes: 9460
package main

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

func main() {
	scanner := getScanner()
	writer := bufio.NewWriter(os.Stdout)

	h := getNextInt(scanner)
	w := getNextInt(scanner)
	ss := make([]string, h)
	for i := 0; i < h; i++ {
		ss[i] = getNextString(scanner)
	}

	horizontal := make([][]int, h)
	for y := 0; y < h; y++ {
		horizontal[y] = make([]int, w)
		stack := make([]int, w)
		i := 0
		for x := 0; x < w; x++ {
			if ss[y][x] == '.' {
				stack[i] = x
				i++
				continue
			}
			count := i
			for i > 0 {
				i--
				horizontal[y][stack[i]] = count
			}
		}
		count := i
		for i > 0 {
			i--
			horizontal[y][stack[i]] = count
		}
	}
	vertical := make([][]int, w)
	for x := 0; x < w; x++ {
		vertical[x] = make([]int, h)
		stack := make([]int, h)
		i := 0
		for y := 0; y < h; y++ {
			if ss[y][x] == '.' {
				stack[i] = y
				i++
				continue
			}
			count := i
			for i > 0 {
				i--
				vertical[x][stack[i]] = count
			}
		}
		count := i
		for i > 0 {
			i--
			vertical[x][stack[i]] = count
		}
	}
	max := 0
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			counts := horizontal[y][x] + vertical[x][y] - 1
			if max < counts {
				max = counts
			}
		}
	}
	fmt.Fprintln(writer, max)
	writer.Flush()
}

func getScanner() *bufio.Scanner {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}


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

int main() {

    int x,y;
  
    cin >> x >> y;


    int tmp = x*2;
  	
    int tmp2 = y - tmp;
  
 
    int tmp3 = tmp2/2;
   if(tmp3 < 0){
    cout << "No";
     return 0;
  }
    
  
 
    int tmp4 = x - tmp3;
  if(tmp4 < 0){
    cout << "No";
    return 0;
  }
    
  
 
    int ans = (tmp3 *4) + (tmp4*2); 
  
  

    if(ans == y){
        cout << "Yes";
    }else{
        cout << "No";
    }

}

   

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	long double a,b;
	cin>>a>>b;
	printf("%ld\n",(ll)(a*b) );
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 3812
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
p = [0]*(n+1)
p[0] = 1
if 1 not in a:
  p[1] = 1

t = 1000000007

for i in range(2, n+1):
  if i in a:
    continue
  s = p[i-1] + p[i-2]
  s = s%t
  p[i] = s
  
print(p[n])  
  


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

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

using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<int> A(N+1,0);
  rep(i,N){
    int input ;
    cin >> input;
    A[input] ++;
    //cout << A[input] << endl;
  }
  //rep(i,N+1) cout << A[i] << " ";
  //cout << endl;
  sort(A.begin(),A.end());
  //rep(i,A.size()) cout << A[i] << " ";
  //cout << endl;
  int index = 0;
  while(A[index] == 0) index++;
  //cout << index << endl;
  int ans = 0;
  while(N - index >= K){
    //cout << A[index] << endl;
    ans += A[index];
    index++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
string a;bool flag;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>a;
	for(int i=0;i<a.size();i++){
		if(a[i]=='C'){
			for(int j=i+1;j<a.size();j++)
			if(a[j]=='F')flag=1;
		}
	}
	if(flag)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    long long N;
    cin >> N;
    bool kanou = 0;
    long long i, j;
    for(i = 1; i <= 9; i++){
        for(j = 1; j <= 9; j++){
            if(i*j == N) kanou = 1;
        }
    }
    if(kanou) cout << "Yes" << endl;
    else cout << "No" << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#define MOD 1000000007
#define MAX(a,b) (a>b?a:b)
#define MAX3(a,b,c) MAX(a,MAX(b,c))
#define MIN(a,b) (a<b?a:b)
#define MIN3(a,b,c) MIN(a, MIN(b,c))
typedef long long lli;
typedef struct {
    int tate;
    int yoko;
} lamp;

int main()
{
    int h,w,i,j,max=0;
    scanf("%d%d",&h,&w);
    char **s = malloc(h * sizeof(char*));
    lamp **a = malloc(h * sizeof(lamp*));
    for(i=0; i<h; i++) {
        s[i] = malloc(w * sizeof(char));
        a[i] = malloc(w * sizeof(lamp));
    }
    for(i=0; i<h; i++) {
        scanf("%s",s[i]);
    }

    for(i=0; i<h; i++) {
        for(j=0; j<w; j++) {
            int ii, jj, fi=0, fj=0, sum;
            a[i][j].tate=0; a[i][j].yoko=0;
            if(i != 0) {
                if(s[i-1][j] =='.') {
                    a[i][j].tate = a[i-1][j].tate;
                    fi = 1;
                }
            }
            if(fi == 0) {
                for(ii=i; ii>=0 && s[ii][j]=='.'; ii--) a[i][j].tate++;
                for(ii=i+1; ii<h && s[ii][j]=='.'; ii++) a[i][j].tate++;
            }
            if(j != 0) {
                if(s[i][j-1] == '.') {
                    a[i][j].yoko = a[i][j-1].yoko;
                    fj = 1;
                }
            }
            if(fj == 0) {
                for(jj=j; jj>=0 && s[i][jj]=='.'; jj--) a[i][j].yoko++;
                for(jj=j+1; jj<w && s[i][jj]=='.'; jj++) a[i][j].yoko++;
            }
            sum = a[i][j].yoko + a[i][j].tate - 1;
            max = MAX(max, sum);
        }
    }
    printf("%d",max);
    return 0;
}


Measured memory_bytes: 35456
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <functional>
using namespace std;
using ll = long long;

class Int2 {
public:
	int x, y;
	Int2() {}
	Int2(int x, int y) :x(x), y(y) {}
	Int2(const Int2& ano) :x(ano.x), y(ano.y) {}

	bool operator<(const Int2& ano) const {
		if (x != ano.x)
			return x < ano.x;
		return y < ano.y;
	}
	bool operator>(const Int2& ano) const {
		if (x != ano.x)
			return x > ano.x;
		return y > ano.y;
	}
};
int costs[10][10];
int min_cost(int x) {
	int dp[10];
	priority_queue<Int2, vector<Int2>, greater<Int2>> que;
	for (int i = 0; i < 10; i++) {
		dp[i] = costs[x][i];
		que.emplace(dp[i], i);
	}
	while (!que.empty()) {
		Int2 top = que.top();
		que.pop();

		for (int i = 0; i < 10; i++)
			if (dp[top.y] + costs[top.y][i] < dp[i]) {
				que.emplace(dp[top.y] + costs[top.y][i], i);
				dp[i] = dp[top.y] + costs[top.y][i];
			}
	}
	return dp[1];
}
int main() {
	int H, W, nums[10] = { 0 };
	scanf("%d %d", &H, &W);

	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)
			scanf("%d", &costs[i][j]);

	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) {
			int temp;
			scanf("%d", &temp);
			if (temp != -1)
				nums[temp]++;
		}

	int total = 0;
	for (int i = 0; i < 10; i++)
		total += min_cost(i) * nums[i];
	printf("%d\n", total);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define PB push_back
using namespace std;
typedef pair<int, int> P1;
typedef pair<int, pair<int, int> > P2;
static const int INF = 1ll<<60;
static const int dx[] = { 1, -1, 0, 0, };
static const int dy[] = { 0, 0, 1, -1 };
static const int mod = 1000000007;

int N,K;
int a[200005];

int kind;
int flag[200005];
int v[200005];
int ans;

signed main(){
    cin>>N>>K;
    for(int i=0;i<N;++i)v[i]=INF;
    for(int i=0;i<N;++i){
        cin>>a[i];
        a[i]--;
        if(!flag[a[i]]){
            kind++;
            v[a[i]]=0;
        }
        flag[a[i]]=1;
        v[a[i]]++;
    }
    if(kind<=K){
        cout<<0<<endl;
        return 0;
    }
    sort(v,v+N);
    for(int i=0;;++i){
        if(kind==K)break;
        ans+=v[i];
        kind--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
N,M,C = map(int,input().split())
B = list(map(int,input().split()))

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




Measured memory_bytes: 3060
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
ans = 0
N = int(input())
for a in make_divisors(N):
    b = N//a
    m = a -1
    if m < 1:
        continue
    if N%m == b:
        ans += m
print(ans)

Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
#define cout_set(n) cout << setprecision(10) << (n) << endl; 
const double PI=3.14159265358979323846;
using namespace std;
const int mod = 1000000007; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

int main(){
    int h1,m1,h2,m2,k; cin >> h1 >> m1 >> h2 >> m2 >> k;
    if(m2 < m1) {
        h2--; m2 += 60;
    }
    int h = h2 - h1,m = m2 - m1;
    int t = h*60 + m - k; 
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
		int W,H,x,y,r;
		cin >> W >> H >> x >> y >> r;
		bool j = true;
		if(x-r<0) j = false;
		if(x+r>W) j = false;
		if(y-r<0) j = false;
		if(y+r>H) j = false;
		if(j) cout << "Yes" << endl;
		else  cout << "No"  << endl;
		return 0;
}

Measured memory_bytes: 1160
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n = I()
L = [-INF] + LI()
flag = True
cnt = 0
j = 0
while flag:
    flag = False
    for i in range(n):
        if L[i] <= j < L[i+1]:
            cnt += 1
            flag = True
    j += 1



print(cnt)

Measured memory_bytes: 40048
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    double result,result2;
    double r;
    double pie=3.14159265358979;
    cin>>r;
    result2=2*r*pie;
    result=r*r*pie;
    cout<<fixed<<setprecision(6)<<result<<" "<<result2<<endl;
}



Measured memory_bytes: 3216
#include <stdio.h>

int main(void){
  int i, j, n ,y, m, d, result;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d %d %d", &y, &m, &d);
    result = 0;

    for(j = y + 1; j < 1000; j++){
      if(j % 3 == 0){
        result += 10 * 20;
      }
      else{
        result += 10 * (20 + 19) / 2;
      }
    }

    if(y % 3 == 0){
      result += (10 - m) * 20;
      result += 20 - d + 1;
    }
    else{
      if(m % 2 == 0){ //small
        result += (10 - m) * (20 + 19) / 2;
        result += 19 - d + 1;
      }
      else{ // big
        result += (10 - m - 1) * (20 + 19) / 2 + 19;
        result += 20 - d + 1;
      }
    }

    printf("%d\n", result);
  }

  return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

constexpr auto BASE = 2019;

int L,R;

int main()
{

	int ans = 0;

	cin >> L;
	cin >> R;

	if (R - L > BASE) {
		R = L + BASE;
	}

	int best = BASE;

	for (int i = L; i <= R - 1; i++) {
		for (int j = i+1; j <= R; j++) {
			int tmp = (i % BASE) * (j % BASE) % BASE;

			if (tmp < best) {
				best = tmp;
			}
		}
	}

	cout << best << endl;


	return 0;
}


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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << max({a*c, a*d, b*c, b*d}) << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  lll a,b,n,x;

  cin >> a >> b >> n;

  lll cal;
  lll ans =  (1L << 63);
  ans *= -1;

  //for(ii=1;ii<=n;ii++){
  //  cal = a*ii/b - a * (ii/b);
  //  if(cal > ans){
  //    cout << "ii:" << ii << endl;
  //    ans = cal;
  //  }
  //}
  //ii = b -1;
  //ans = a*ii/b - a * (ii/b);
  // xがb未満の場合大きい法が良い
  if(b > n){
    ii = n;
    ans = a*ii/b - a * (ii/b);
  }
  else{
    ii = b -1;
    ans = a*ii/b - a * (ii/b);    
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
import Data.Char(digitToInt)

sumAllDigit = sum . (map digitToInt) . show
main :: IO ()
main = do
    [n,a,b] <- map read . words <$> getLine 
    print $ sum $ filter (\xs -> a <= (sumAllDigit xs) && (sumAllDigit xs) <=  b) [x | x <- [1..n]]


Measured memory_bytes: 892
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N = INT()

ans = INF
for i in range(1, N//2 + 1):
	j = N - i
	tmp = sum([int(x) for x in list(str(i))]) + sum([int(x) for x in list(str(j))])
	ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 5204
#define ll long long
#include<bits/stdc++.h>
using namespace std;
ll arr[30];
ll brr[30];
ll crr[30];
int main()
{
    ll n,i,sum=0;

    cin>>n;

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

    for(i=1;i<=n;i++)
    {
        cin>>brr[i];
    }

    for(i=1;i<=n-1;i++)
    {
        cin>>crr[i];
    }
    sum+=brr[arr[1]];

    for(i=2;i<=n;i++)
    {
        if(arr[i]-arr[i-1]==1)
        {
            sum+=brr[arr[i]];
            sum+=crr[arr[i-1]];
        }

        else
            sum+=brr[arr[i]];
    }

    cout<<sum<<endl;
}


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

bool is_kaibun(string s) {
  for ( int i = 0; i < s.size(); i++ ) {
    if ( s[i] != s[s.size()-i-1] ) { return false; }
  }
  return true;
}

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string ans = (
    is_kaibun(s) &&
    is_kaibun(s.substr(0, (n-1)/2)) &&
    is_kaibun(s.substr((n+3)/2-1, (n-1)/2))
  ) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3600
#include<stdio.h>
#include<stdlib.h>

int i,j,r[2];
char a[5],b[5];
void p()
{
	for(i=r[0]=0;i<4;i++)
		a[i]==b[i]?r[0]++:0;
	printf("%d ",r[0]);
}

void q()
{
	for(i=r[1]=0;i<4;i++)
		for(j=0;j<4;j++)
			a[i]==b[j]?r[1]++:0;
	printf("%d\n",r[1]-r[0]);
}

main()
{
	for(;scanf("%s%s",&a,&b),atoi(a),atoi(b);p(),q());
}

Measured memory_bytes: 548
from re import sub

raw_s = input()

s = sub("BC","D",raw_s)

#print(s)

ac = 0
ans = 0
for c in s:
    if c == 'A':
        ac += 1

    elif c == 'D':
        ans += ac
        
    else:
        ac = 0
        
print(ans)

Measured memory_bytes: 5480
#include <stdio.h>
#include <algorithm>
int n,m,a[101],s;
main(){
    scanf("%d%d",&n,&m);for(register int i=1;i<=n;i++) scanf("%d",&a[i]),s+=a[i];std::sort(a+1,a+1+n);int x=m;
    for(register int i=n;i>=1;i--) if(a[i]*4*x>=s){m--;if(!m) return puts("Yes"),0;}return puts("No"),0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;

vector<int> vec;

const int N = 300030;
int A[N];
int P[N];
int n;

int qu(int o) {
  int lo=0, hi=n;
  while (lo<hi) {
    int mid = (lo+hi+1)/2;

    if (mid != 0 && vec[mid-1] < o) {
      hi = mid-1;
    }
    else {
      lo = mid;
    }
  }

  int ans = lo+(P[n]-P[lo])/o;
  //cerr << " o = " << o << " :: " << ans << " ,, " << lo << " + (" << P[n] << "-" << P[lo] << ")/" << o << endl;
  return ans;
}

int solve(int k) {
  int lo = 0, hi = n;
  while (lo < hi) {
    int o = (lo+hi+1)/2;

    int va = n;
    if (o != 0) {
      va = qu(o);
    }

    if (va < k) {
      hi = o-1;
    } else {
      lo = o;
    }
  }
  return lo;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i=1; i<=n; ++i) {
    int x;
    cin >> x;
    ++A[x];
  }
  for (int i=1; i<=n; ++i) {
    vec.push_back(A[i]);
  }
  sort(vec.rbegin(), vec.rend());
  for (int i=1; i<=n; ++i) {
    P[i] = P[i-1]+vec[i-1];
  }
 
  for (int i=1; i<=n; ++i) {
    cout << solve(i) << "\n";
  }


  return 0;
}


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

using namespace std;

typedef long long ll;


int main(int, char**)
{
	ll n, k, ans = 0;
	cin >> n >> k;

	if ((n + 1)/2 > (k -1))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <assert.h>

using namespace std;

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

    long x,y,z;
    x = B - (B/C+B/D-B/(C*D/__gcd(C,D)));
    y = A- 1-((A-1)/C+(A-1)/D-(A-1)/(C*D/__gcd(C,D)));
    cout<<x-y<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main(void){

  int x = 1;

  int n;
  cin >> n;
  while( n-- ){
    
    double num;
    cin >> num;
    
    cout << "Case " << x++ << ":" <<  endl;
    for( int i = 0 ; i < 10 ; i++ ){
      
      num = pow( num , 2 );
      
      int N[4];
      N[0] = (int)num % 1000;
      N[1] = (int)num % 10000;
      N[2] = (int)num % 100000;
      N[3] = (int)num % 1000000;    

      //cout << N[0] << endl;
      //cout << N[1] << endl;
      //cout << N[2] << endl;
      //cout << N[3] << endl;

      N[0] /= 100;
      N[1] /= 1000;
      N[2] /= 10000;
      N[3] /= 100000;

      //cout << N[0] << endl;
      //cout << N[1] << endl;
      //cout << N[2] << endl;
      //cout << N[3] << endl;

      int ans = 0;
      ans = N[3]*1000 + N[2]*100 + N[1]*10 + N[0];

      cout << ans << endl;

      num = ans;      

    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007ll;
int main(){
	int a,b;
	std::cin >> a;
	set<int> s;
	rep(i,9)rep(j,9){
		s.insert((i+1)*(j+1));
	}
	if(s.find(a)==s.end()){
		std::cout << "No" << std::endl;
	}
	else std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    string s;
    cin>>s;
    ll r=0,l=0,n=s.size();
    s+='R';
    vector<ll> v(n,0);
    for(ll i=0;i<s.size();i++){
        if(s[i]=='L') l++;
        if(s[i]=='R'){
            if(l==0) r++;
            else{
                if((l+r)%2==0) v[i-l-1]=v[i-l]=(l+r)/2;
                else{
                    if((r<l && l%2==0)||(r>l && r%2!=0)){
                        v[i-l-1]=(l+r)/2+1;
                        v[i-l]=(l+r)/2;
                    }else{
                        v[i-l-1]=(l+r)/2;
                        v[i-l]=(l+r)/2+1;
                    }
                }
                r=1;
                l=0;
            }
        }
    }
    for(ll i=0;i<n;i++) cout<<v[i]<<' ';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
using namespace std;
const int MAXN = 1e5+5;
typedef long long ll;
ll v[MAXN],w[MAXN];
ll dp[MAXN]={0};
int main(){
	int N,M;
	ll maxx=0;
	cin>>N>>M;
	for(int i=0;i<N;++i){
		cin>>v[i]>>w[i];
	}
	for(int i=0;i<N;++i){
		for(int j=M;j>=v[i];--j){
			dp[j]=max(dp[j],dp[j-v[i]]+w[i]);
			maxx=max(maxx,dp[j]);
		}
//		for(int j=0;j<=M;++j)
//			cout<<dp[j]<<" ";
//		cout<<endl;
	}
	cout<<maxx<<endl;
	return 0;
}

Measured memory_bytes: 1024
l = [int(input()) for i in range(5)]
a = min(l, key=lambda x: (x-1)%10)
ret = 0
flag = 0
for i in l:
    if i != a or flag == 1:
        ret += i
    else:
        flag = 1
        
    if ret%10 != 0:
        ret += 10-(ret%10)
ret += a
print(ret)

Measured memory_bytes: 61140
//2018.09.23

#include <iostream>
#include <vector>
using namespace std;

int main() {

    int n,m,x,y;
    cin >> n >> m >> x >> y;

    int i,tmp;
    int maxv=-100,minv=100;
    for(i=0;i<n;i++){
        cin >> tmp;
        maxv = max(maxv,tmp);
    }
    for(i=0;i<m;i++){
        cin >> tmp;
        minv = min(minv,tmp);
    }

    maxv = max(maxv,x);
    minv = min(minv,y);

    if(maxv<minv) cout << "No War" << endl;
    else cout << "War" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

constexpr int MAX = 1001;
long long fac[MAX], inv[MAX], finv[MAX];
void CombInit(){
    fac[0] = inv[0] = finv[0] = 1;
    fac[1] = inv[1] = finv[1] = 1;
    for(int i=2; i<MAX; ++i){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

long long Comb(int n,int k){
    if(n < 0 || k < 0 || n < k) return 0;
    return (fac[n] * finv[n-k] % MOD) * finv[k] % MOD;
}

ll mod_pow(ll x,int e){
    ll y = 1;
    while(e) {
        if(e & 1) y = y * x % MOD;
        x = x * x % MOD;
        e >>= 1;
    }
    return y;
}


int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    CombInit();

    ll ans = 0;
    for(int i = 1; i < k; ++i) {
        ll num = (mod_pow(k - i, n) * Comb(k, i)) % MOD;
        if(i & 1) ans = (ans + num) % MOD;
        else ans = (ans - num + MOD) % MOD;
    }
    cout << (mod_pow(k, n) - ans + MOD) % MOD << '\n';
    return 0;
}


Measured memory_bytes: 3232
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * vertices
    queue = deque()
    queue.append(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if not visited[adj] and cp > 0:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graphFordFulkerson(source, sink):
    parent = [-1] * vertices
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            path_flow = min(path_flow, adj_table[parent[bk_1]][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(v_table):
    for each in v_table:
        source, target, cp = map(int, each)
        init_adj_table[source][target] = cp

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(vertices)]
    adj_table = generate_adj_table(v_info)
    ans = graphFordFulkerson(source=0, sink=vertices - 1)
    print(ans)

Measured memory_bytes: 8184
total = 0

relatives = int(input())
input_array = [input() for i in range(relatives)]

for input_string in input_array:
  price_type = input_string.split()
  if price_type[1] == 'JPY':
    total += float(price_type[0])
  else:
    total += float(price_type[0]) * 380000
    
print(total)

Measured memory_bytes: 3060
import sys
from functools import lru_cache

read = sys.stdin.read


def com(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    numer = denom = 1
    for i in range(n - r + 1, n + 1):
        numer = numer * i
    for i in range(1, r + 1):
        denom = denom * i
    return numer // denom


def main():
    N, K = map(int, read().split())

    S = str(N)
    L = len(S)

    @lru_cache(maxsize=None)
    def rec(i, k, smaller):
        if i == L:
            if k == 0:
                return 1
            else:
                return 0
        if k == 0:
            return 1
        if smaller:
            return com(L - i, k) * pow(9, k)
        if S[i] == '0':
            return rec(i + 1, k, False)

        ans = 0
        ans += rec(i + 1, k, True)
        ans += rec(i + 1, k - 1, True) * (int(S[i]) - 1)
        ans += rec(i + 1, k - 1, False)
        return ans

    ans = rec(0, K, False)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67428
#include <iostream>

using namespace std;

int N, total=0;

void dfs(long long n, unsigned char flag357) {
	if (n <= N) {
		if (flag357 == 07)
			total++;
		dfs(n * 10 + 3, flag357 | 01);
		dfs(n * 10 + 5, flag357 | 02);
		dfs(n * 10 + 7, flag357 | 04);
	}
}

int main() {
	cin >> N;
	dfs(0, 0);
	cout << total << endl;


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdbool.h>
#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool X[N][N];

void initilize(){
  int i;
  for( i=0;i<N;i++){
    row[i] = FREE;
    col[i] = FREE;
  }
  for( i=0;i<2*N-1;i++){
    dpos[i] = FREE;
    dneg[i] = FREE;
  }
}
void printBoard(){
  int i,j;
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(X[i][j]){
        if(row[i] != j)return;
      }
    }
  }
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      printf("%c",(row[i] == j)?'Q':'.');
    }
    printf("\n");
  }
}
void recursive(int i){
  int j;
  if(i == N){//クイーンの配置に成功                                             
    printBoard();
    return;
  }
  for(j=0;j<N;j++){
    //(i,j)が他のクイーンに襲撃されている場合は無視                             
    if(NOT_FREE == col[j] ||
       NOT_FREE == dpos[i+j] ||
       NOT_FREE == dneg[i-j+N-1])continue;
    //(i,j)にクイーンを配置する                                                 
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
    //次の行を試す                                                              
    recursive(i+1);
    //(i,j)に配置されているクイーンを取り除く                               
        row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
  }
  //クイーンの配置に失敗                                                        
}
int main(){
  int i,j;
  initilize();
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      X[i][j] = false;
    }
  }
  int k;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    int r,c;
    scanf("%d %d",&r,&c);
    X[r][c] = true;
  }
  recursive(0);

  return 0;
}





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

using namespace std;

int main(void) {
    int A, B;
    cin >> A >> B;
    //cout << A << "," << B << endl;

    if (A >= 13) 
        cout << B << endl;
    else if ( A <= 5) 
        cout << "0" << endl;
    else 
        cout << B /2 << endl;

}


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

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

	const int m = 9;
	vector<int> c(m, 0);

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

		if (tmp_a < 3200) c[tmp_a / 400] = 1;
		else c[m - 1]++;
	}
	
	int ans = 0;
	for (int i = 0; i < m - 1; i++) ans += c[i];
	
	if (ans == 0) {
			cout << 1 << " " << c[m - 1] << endl;
	}
	else {
		cout << ans << " " << ans + c[m - 1] << endl;
	}
	return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  double ans = 0;
  for(int i=0; i<N; i++){
    double tmp = 1.0/N;
    int now = i+1;
    while(now<K){
      now *= 2;
      tmp /= 2;
    }
    ans += tmp;
  }
      
  printf("%1.10lf\n", ans);
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

#define PI ((ld)3.141592653589793238) 

using namespace std;

int main() {
	ld a, b, x;
	cin >> a >> b >> x;
	x /= a;
	if (x >= 0.5 * a * b) {
		printf("%.10Lf\n",90 - (180 / PI) * atan2l(a * a, 2 * (a * b - x)));
	} else {
		printf("%.10Lf\n", 90 - (180 / PI) * atan2l(2 * x, b * b));
	}
	return 0;
}


Measured memory_bytes: 3840
#include<stdio.h>
int main()
{
     int  x,a,b,c,n=0;
     int answer=0;
      scanf("%d ",&x);
      scanf("%d ",&a);
      scanf("%d ",&b);
      n=x-a;
      c=n/b;
      answer=n-b*c;
    printf("%d",answer);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int ,int> pii;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define sll(n) scanf("%lld",&n)
#define sll2(x,y) scanf("%lld%lld",&x,&y)
#define sll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define REP(i,x,y) for(ll i = x;i <= y;++i)
#define debug(x) cerr<<#x<<"::"<<x<<endl
#define debug2(x,y) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n"
#define debug3(x,y,z) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n"
#define debug4(x,y,z,w) cerr<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<"\n"
ll power(ll x,ll y,ll z) {
	ll ret = 1;
	while(y > 0) {
		if(y & 1) ret = (ret*x)%z;
		x = (x*x)%z;
		y >>= 1;
	}
	return ret;
}
int main() {
	
	ll n, ans = 0;
	sll(n);
	vector<ll> A(n + 1);
	map<ll, ll> has;
	REP(i, 1, n) sll(A[i]);
	REP(i, 1, n) {
		ans += has[i - A[i]];
		has[i + A[i]]++;
	} 
	printf("%lld\n", ans);
	

	return 0;
}

Measured memory_bytes: 27480
# -*- coding: utf-8 -*-
import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N, M = zz()
P, Y = [], []
years = defaultdict(list)
ids = defaultdict(list)
# years: [city_id, year]
for i in range(M):
    p, y = zz()
    years[p].append(y)
    ids[p].append(i)
# print(years)
ans = ['']*M
for p in years:
    c = zip(years[p], ids[p])
    c = sorted(c)
    year, id = zip(*c)
    for i, id_ in enumerate(id):
        i = i + 1
        ans[id_] = str(p).zfill(6) + str(i).zfill(6)
for a in ans:
    print(a)
# print(*ans)

# .zfill(6)


Measured memory_bytes: 72684
N,A,B = map(int, input().split())
li = input()
pl_type = list(li)
tuuka_sum = 0
fore_rank = 1
for i in range(N):
 if pl_type[i] == 'c':
     print('No')
 elif pl_type[i] == 'a' and tuuka_sum < A+B:
     print('Yes')
     tuuka_sum += 1
 elif pl_type[i] == 'b' and tuuka_sum < A+B:
     if fore_rank <= B:
         print('Yes')
         fore_rank += 1
         tuuka_sum += 1
     else:
         print('No')
 else:
     print('No')


Measured memory_bytes: 9972
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  FOR(i, K, N) yes(A[i] > A[i-K]);
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

int main() {
    cin>>s>>k;
    rep(i,s.size()){
        if(s[i]!='1'){p(s[i]);break;}
        if(i==k-1){p(s[i]);break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>

namespace cp {

struct union_find {
  std::vector<int> p; union_find(int n) : p(n, -1) { }
  int find(int x) { return p[x] < 0 ? x : p[x] = find(p[x]); }
  bool unite(int x, int y) {
    int xp = find(x), yp = find(y);
    if (xp == yp)       return false;
    if (p[xp] > p[yp])  std::swap(xp,yp);
    p[xp] += p[yp], p[yp] = xp;
    return true;
  }
  int size(int x) { return -p[find(x)]; }
};

}  // namespace cp

#include <cstdio>

int main() {
  int n, q;
  scanf("%d %d", &n, &q);
  cp::union_find d(n);
  for (int i = 0; i < q; i++) {
    int t, u, v;
    scanf("%d %d %d", &t, &u, &v);
    if (t == 0)
      d.unite(u, v);
    else
      printf("%d\n", d.find(u) == d.find(v));
  }
  return 0;
}


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

int main(){
  int N,max=0,fin=0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0 ; i < N ; i++) cin >> vec.at(i);
  for(int i=0 ; i < N ; i++){
    for(int j=0 ; j < N ; j++) {
      if(max <= vec.at(j)) max = vec.at(j); //数列の最大値を入力
    }
    for(int j=0 ; j < N ; j++){
      if(max == vec.at(j)){
        vec.at(j) = 0 ; //最大値を0にする
        break;
      }
    }
    if(i%2== 0) {fin += max;}
    else {fin -= max;}
    max = 0; //maxを初期化
  }
  cout << fin;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.begin(), c.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
#define Sort(a) sort(Range(a));
#define DeSort(a) sort(RevRange(a));

using namespace std;
using ll = long long;

int main(void){
    Cin(string, a);
    Cin(string, b);
    Cin(int, c);
    Cin(int, d);
    cout << "A" << b[0] << "C\n";
    //Cout(() ? "Yes" : "No");
    //Cout(() ? "YES" : "NO");
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

typedef multimap<int, int> MII;

int main(int argc, char *argv[]) {
  int N, M;
  MII mp;
  set<int> visited;
  queue< pair<int, int> > que;

  cin >> N >> M;

  FOR(i, M) {
    int a, b;
    
    cin >> a >> b;
    
    mp.insert(make_pair(a, b));
    mp.insert(make_pair(b, a));
  }

  bool flag = false;
  int init = 1;
  visited.insert(init);
  que.push(make_pair(init, 0));

  while (!que.empty()) {
    pair<int, int> v = que.front();
    que.pop();
    
    if (v.first == N) {
      flag = true;
      break;
    }
    
    pair< MII::iterator, MII::iterator > p = mp.equal_range(v.first);
    for (auto it = p.first; it != p.second; it++) {
      if (visited.find(it->second) == visited.end()) {
        visited.insert(it->second);
        if (v.second < 2)
          que.push(make_pair(it->second, v.second + 1));
      }
    }
  }

  if (flag == true)
    cout << "POSSIBLE" << endl;
  else
    cout << "IMPOSSIBLE" << endl;

  return 0;
}


Measured memory_bytes: 24576
#include <bits/stdc++.h>
#define pb              push_back
#define ll              long long int
#define scd(a)          scanf("%d",&a)
#define mp(a,b)         make_pair(a,b)
#define scl(w)          scanf("%I64d",&w)
#define scdd(a,b)       scanf("%d %d",&a,&b)
#define srt(a)          sort(a.begin(),a.end())
#define rsrt(a)         sort(a.rbegin(),a.rend())
#define scll(a,b)       scanf("%I64d %I64d",&a,&b)
///4direction ->        int del_x[]={-1,0,1,0},del_y[]={0,1,0,-1};
#define input(v,n)      for (int i=0;i<n;i++){int a;cin >> a;v.push_back(a);}
#define inputll(v,n)    for (ll i=0;i<n;i++){ll a;cin >> a;v.push_back(a);}
#define vii             vector < int >
#define vll             vector < ll >
#define pii             pair < int , int >
#define pll             pair < ll , ll >
#define show(x)         cout << #x << " : " << x << endl
#define mk              make_pair
#define inf             10000000000000016

#define maxn            1000006

using namespace std;

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

      cout << n+n*n+n*n*n << endl;



      return 0;
}


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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0; i--)
#define for(i,a,b) for(ll i=(a); i<=(b); i++)
#define ford(i,a,b) for(ll i=(a); i>=(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main(){
    ll n; cin >> n;
    n %= 1000;
    if (n == 0) n+= 1000; 
    cout << 1000 - n << endl;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			cout << v[i][j] << "   ";
		}
		cout << endl;
	}
}





int main(){
	char c;
	cin >> c;

	//解1
	if(islower(c)) cout << 'a' << endl;
	else cout << 'A' << endl;
	
	
	//解2
	// if(isupper(c)) cout << 'A' << endl;
	// else cout << 'a' << endl;
	
	//解3
	// int a  =  c - 'A';
	// //cout << a << endl;
	// if(a < 26) cout << 'A' << endl;
	// else cout << 'a' << endl; 
 

	
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
typedef struct
{
	char data[100];
	int top;
}SqStack;
void InitStack(SqStack *&s)
{
	s=(SqStack *)malloc(sizeof(SqStack));
	s->top=-1;
}
void DestroyStack(SqStack *&s)
{
	free(s);
}
bool Push(SqStack *&s,char e)
{
	if(s->top==99)
		return false;
	s->top++;
	s->data[s->top]=e;
	return true;
}
bool Pop(SqStack *&s,char &e)
{
	if(s->top==-1)
		return false;
	e=s->data[s->top];
	s->top--;
	return true;
}
int symmetry( char str[])
{
	int i,j=0;char e;
	SqStack *st;
	InitStack(st);
	for(i=0;str[i]!='\0';i++)
	{
		Push(st,str[i]);
	}
	for(i=0;str[i]!='\0';i++)
	{
		Pop(st,e);
		if(str[i]!=e)
		{
			j++;
		}
	}
	DestroyStack(st);
	return j/2;
}
int main()
{
	char str[100];int n;
	cin>>str;
	n=symmetry(str);
	cout<<n<<endl;
	return 0;
}

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

signed main() {
  int n, d;
  int x, y;
  int cnt = 0;
  cin>>n>>d;
  while (n--){
    cin>>x>>y;
    if (x*x + y*y <= d*d) cnt ++;
  }
  cout<<cnt;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cassert>
#include <queue>

const int M = 10000000;

void connected_components(
  std::vector<std::vector<int> >& adj_list,
  std::vector<int>& component_numbers,
  int root, int current_component){
  assert(component_numbers[root] == M);

  std::queue<int> target_q;
  target_q.push(root);
  component_numbers[root] = current_component;
  // dist_q.push(0;)
  while(!target_q.empty()){
    int vtx = target_q.front(); target_q.pop();
    for(int const&  u : adj_list[vtx]){
      if(component_numbers[u] == M){
        target_q.push(u);
        component_numbers[u] = current_component;
      }
    }
  }
}

int main(int argc, char const *argv[]) {
  int n, m, q;
  std::cin >> n;
  std::cin >> m;

  std::vector<std::vector<int> > adj_list(n);

  for (size_t i = 0; i < m; i++) {
    int a, b;
    std::cin >> a;
    std::cin >> b;
    adj_list[a].push_back(b);
    adj_list[b].push_back(a);
  }

  std::vector<int> component(n, M);

  for (size_t i = 0; i < n; i++) {
    if(component[i] == M){
      connected_components(adj_list, component, i, i);
    }
  }

  std::cin >> q;

  for(size_t i =0; i < q; i++){
    int a, b;
    std::cin >> a;
    std::cin >> b;
    bool in_same_component = (component[a] == component[b]);
    std::cout << (in_same_component ? "yes" : "no") << std::endl;
  }


  return 0;
}

Measured memory_bytes: 8676
#include <stdio.h>

typedef struct {
    char mark;
    int value;
} Card;

void print(Card C[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        printf("%c%d", C[i].mark, C[i].value);
        if (i != N-1)
            printf(" ");
        else
            printf("\n");
    }
}

void BubbleSort(Card C[], int N) {
    int i, j;
    Card tmp;

    for (i = 0; i < N; i++) {
        for (j = N-1; j > i; j--) {
            if (C[j].value < C[j-1].value) {
                tmp = C[j];
                C[j] = C[j-1];
                C[j-1] = tmp;
            }
        }
    }
    print(C, N);
    printf("Stable\n");
}

void SelectionSort(Card C[], int N) {
    int i, j;
    int minj;
    Card tmp;

    for (i = 0; i < N; i++) {
        minj = i;
        for (j = i; j < N; j++){
            if (C[j].value < C[minj].value)
                minj = j;
        }
        tmp = C[i];
        C[i] = C[minj];
        C[minj] = tmp;
    }
    print(C, N);
}

int main() {
    int N, flag = 1;
    int i;
    Card C1[36], C2[36];

    scanf("%d", &N);

    for (i = 0; i < N; i++) {
        scanf(" %c%d", &C1[i].mark, &C1[i].value);
        C2[i] = C1[i];
    }

    BubbleSort(C1, N);
    SelectionSort(C2, N);

    for(i = 0; i < N; i++) {
        if(C1[i].mark != C2[i].mark) {
            flag = 0;
            break;
        }
    }

    if (flag)
        printf("Stable\n");
    else
        printf("Not stable\n");

    return 0;
}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
#define PB push_back
#define POP pop_back()
#define PII pair<int,int>
#define FI first
#define SE second
#define ULL unsigned long long
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const double pi=acos(-1),eps=1e-8;
map<ll,int>mp;
int main()
{
	ll n;
	cin>>n;
	int cnt=0;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			ll tmp=i;
			while(n%tmp==0){
				mp[tmp]=1;
				cnt++;
				n/=tmp;
				tmp*=i;
				if(tmp>n){
					break;
				}
			}
			while(n%i==0){
				n/=i;
			}
		}
	}
	if(n!=0&&n!=1&&mp[n]==0){
		cnt++;
	}
	cout<<cnt<<endl;
 	return 0;
}







Measured memory_bytes: 3644
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	ll n,h;cin >> n >> h;
	ll ans = 0;
	ll cou = 0;
	vector<ll> a(n);
	vector<ll> b(n);
	
	REP(i,n)
	{
		cin >> a[i] >> b[i];
	}
	
	sort(ALL(a),greater<ll>());
	sort(ALL(b),greater<ll>());
	
	REP(i,n)
	{
		if(b[i] >= a[0])
		{
			ans++;
			cou += b[i];
			if(cou >= h)
			{
				cout << ans << endl;
				return 0;
			}
		}
		else
		{
			break;
		}	
	}
	
	ll tmp = h - cou;
	
	ans += (tmp+a[0]-1)/a[0];
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792