akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////////

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

    int n,k;
    string s;
    cin >> n >> k >> s;

    int cnt = 0;
    for (int i = 0;i < n - 1;i++){
        if (s[i] == s[i+1]) cnt++;
    }

    cout << min(cnt + 2 * k,n - 1) << endl;
}

Measured memory_bytes: 512
# coding: utf-8
# Your code here!

# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
#n = int(input())
n,a,b = [int(i) for i in readline().split()]


if (b-a)%2 == 0:
    print((b-a)//2)

else:
    r1 = 0
    r1 += a
    r1 += (b-a-1)//2
    
    r2 = 0
    r2 += n-b+1
    r2 += (b-a-1)//2

    print(min(r1,r2))


Measured memory_bytes: 3060
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>
#include <random>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

random_device seed_gen;
mt19937 engine(seed_gen());
// 0, 1, 2 のどれかが得られる一様分布
// uniform_int_distribution<> dist(0, 2);
// cout << dist(engine) << endl;
// みたいに、先に確率分布を宣言して、そこにengineを与えて使う。

// =========ここまでテンプレ============

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if (k < x / d)
    {
        cout << x - k * d;
    }
    else
    {
        ll q = x / d;
        ll r = x % d;
        ll r2 = abs(r - d);
        ll remainedMoves = k - q;
        if (remainedMoves % 2 == 0)
        {
            cout << r << endl;
        }
        else
        {
            cout << r2 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
for _ in range(M):
    a,b = [int(x) for x in stdin.readline().rstrip().split()]
    data.append((a,b))
par = [i for i in range(N+1)]
rank = [0] * (N+1)
size = [1] * (N+1)

def find(x):
    if par[x] == x:
        return par[x]
    else:
        par[x] = find(par[x])
        return par[x]

def union(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
        size[y] += size[x]
        size[x] = 0
        
    else:
        par[y] = x
        size[x] += size[y]
        size[y] = 0
        if rank[x] == rank[y]:
            rank[x] += 1

def check_same(x,y):
    return find(x) == find(y)

def check_size(x):
    return size[find(x)]

score = (N*(N-1))//2
ans = []

while data:
    ans.append(score)
    x,y = data.pop()
    a = find(x)
    b = find(y)
    if not check_same(a,b):
        score -= (check_size(x)*check_size(y))
    union(x,y)
print(*ans[::-1],sep="\n")

Measured memory_bytes: 24840
import heapq


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

A = list(map(int,input().split()))

Q = []


for i in range(N):

    heapq.heappush(Q,-1 * A[i])


for i in range(M):

    now = heapq.heappop(Q)
    now *= -1

    heapq.heappush(Q,-1 * (now // 2))

ans = 0

for i in Q:
    ans -= i
print (ans)


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

int main() {
 ll n; cin >> n;
  vector<ll> cnt(n,0);
 rep(i,n){
  ll a; cin >> a;
  if((i==0 && a!=0) || (i!=0 && a==0)){
    cout << 0 << endl;
    return 0;
  }

  cnt[a]++;
 }
 ll d=1;
 for(ll i=1;i<n;i++){
   if(cnt[i-1]==0 && cnt[i]!=0){
     cout << 0 << endl;
     return 0;
   }
    for(ll j=0;j<cnt[i];j++){
      d*=cnt[i-1];d%=mod;
    }
 }
 cout << d%mod << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    
    for(int i=0;i<5;i++){
        int x;
        cin>>x;
        if(0==x){
            cout<<i+1<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define x first
#define y second
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rof(i,a,b) for(ll i=a;i>b;i--)
ll mod=1e9+7;

//cf dont use unordered map. use simply map<... , ... > m;

//They are Iterator minus v.begin() krna //lower_bound(v.begin(),v.end(),x)-v.begin()  //upper_bound(v.begin(),v.end(),x)-v.begin()
// lower bound tells greater than or equal to // upper bound tells strictly greater than
//int a[1001][1001] //aise global me hi// ll lcm(ll a, ll b){ return a / __gcd(a, b) * b; }
//memset can initialize to 0 or -1 ONLY //memset(str, 't', sizeof(str)); // string //memset(a, 0, sizeof(a));  //1D array    // memset(a,0,sizeof(a[0][0])*n*n); //2D array
// set.insert(),find() //for(auto it=set.begin();....) cout<<*it;   // sort(v.begin(),v.end(),compare)

void solve()
{int n;cin>>n;

    int a[1+n];
    f(i,0,1+n) a[i]=0;

    f(i,1,n)
{
    int x;cin>>x;
    a[x]++;
}


f(i,1,1+n) cout<<a[i]<<endl;
}

int main()
{

ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t=1;
   // cin>>t;
    while(t--)
    {
     solve();
    }
}

Measured memory_bytes: 4396
import sys

def main():
    input = sys.stdin.readline
    n, k = map(int, input().split())
    p = list(map(lambda x:int(x) - 1, input().split()))
    c = list(map(int, input().split()))
    seen = [0] * n
    accumulate = []
    for i in range(n):
        if seen[i] == 0:
            accumulate.append([c[i]])
            pre = i
            while True:
                if seen[pre] == 1:
                    accumulate[-1].pop()
                    break
                seen[pre] = 1
                now = p[pre]
                pre = now
                accumulate[-1].append(accumulate[-1][-1] + c[now])
    
    ans = -float("INF")
    for lst in accumulate:
        if len(lst) >= k:
            for interval in range(1, k + 1):
                for start in range(len(lst)):
                    if start + interval >= len(lst):
                        num = lst[-1] + lst[(start + interval) % len(lst)] - lst[start]                    
                    else:
                        num = lst[(start + interval)] - lst[start]
                    ans = max(ans, num)
        else:
            if lst[-1] > 0:
                for interval in range(1, len(lst) + 1):
                    for start in range(len(lst)):
                        num = (k - interval) // len(lst) * lst[-1]
                        if start + interval >= len(lst):
                            num += (lst[-1] + lst[(start + interval) % len(lst)] - lst[start])                    
                        else:
                            num += (lst[(start + interval)] - lst[start])
                        ans = max(ans, num)
                """
                for interval in range(1, k - len(lst) * (k // len(lst)) + 1):
                    for start in range(len(lst)):
                        num = (k // len(lst)) * lst[-1]
                        if start + interval >= len(lst):
                            num += (lst[-1] + lst[(start + interval) % len(lst)] - lst[start])
                        else:
                            num += lst[(start + interval)] - lst[start]
                        ans = max(ans, num)
                """
            else:
                for interval in range(1, len(lst)):
                    for start in range(len(lst)):
                        if start + interval >= len(lst):
                            num = lst[-1] + lst[(start + interval) % len(lst)] - lst[start]                    
                        else:
                            num = lst[(start + interval)] - lst[start]
                        ans = max(ans, num)
            
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 69040
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    x=int(readline())

    if x==0:
        x=1
    else:
        x=0
    print(x)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 16104
x, y = map(int, input().split())

A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
C = [2]
a = 0
if x in A and y in A:
    a = 1
else:
    if x in B and y in B:
        a = 1
    else:
        if x in C and y in C:
            a = 1

if a == 1:
    print("Yes")
else:
    print("No")


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll x, y, z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

    int a,b,max;
    scanf("%d %d",&a,&b);
    int add =a+b;
    int reduce =a-b;
    int product = a*b;

    max = add;
    if(max<reduce) max=reduce;
    if(max<product) max = product;
    printf("%d",max);
    return 0;
}

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

int main()
{
	long long a,b,k;
	cin>>a>>b>>k;
	if(a>0)
	{
		if(a>k)
		{
			a-=k;
			k=0;
		}
		else 
		{
			k-=a;
			a=0;
		}
	}
	if(b>0 && k>0)
	{
		if(b>k) b-=k;
		else b=0;
	}
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
#define rep(i,n) for (ll i = 0; i < (n); ++i)
typedef long long int ll;
using ipair = pair<int,int>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
const int MOD=1000000007;

int main(){  
    ll n;cin>>n;
    vector<ll> a(n),ans(n,0);
    ll mx = 0;
    rep(i,n){cin>>a[i];mx = max(mx,a[i]);}
    vector<vector<ll>> b(45),c(45);
    rep(i,45){   
        if(mx<(1<<i))break;
        rep(j,n){
            if(a[j]&(1<<i)){b[i].push_back(j);}
            else c[i].push_back(j);
        }
    }
    rep(i,45){
        //cout<<b[i].size()<<endl;
        if(b[i].size()%2==0){
            rep(j,b[i].size()){
                ans[b[i][j]] += pow(2,i);
            }
        }else{
            rep(j,c[i].size()){
                ans[c[i][j]] += pow(2,i);
            }
        }
    }
    rep(i,n)cout<<ans[i]<<endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0){
        cout << (a + b) / 2 << endl;
    }else{
        cout << (a + b) / 2 + 1 << endl;
    }
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int k;
	cin >> k;
	int ans = 0;
	int money = 100;
	while (money < k) {
		money *= 1.01;
		ans++;
	}
	print(ans);
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        String win_lose = sc.next();
        
        int lose_count = 0;
        
        for(int i = 0; i < win_lose.length(); i++){
            if(win_lose.charAt(i) == 'x'){
                lose_count++;
            }
        }
        
        if(lose_count >= 8){
            System.out.println("NO");
        }else{
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define int long long
#define ri register int
#define max maxx
#define min minn
using namespace std;
const int N=1e5+10;
template <class T> void in(T &x) {
	x = 0;
	bool f = 0;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') f = 1;
		c = getchar();
	}
	while ('0' <= c && c <= '9') {
		x = (x << 3) + (x << 1) + (c ^ 48);
		c = getchar();
	}
	if (f) x = -x;
}
inline int maxx(int x,int y) {
	return x>y?x:y;
}
inline int minn(int x,int y) {
	return x<y?x:y;
}
inline int gcd(int x,int y) {
	return !y?x:gcd(y,x%y);
}
int l[N],cor[N],pos[N];
int a[N],dif[N],m,k,n,cnt,x;
vector<int> v[N];
inline void dfs(int x,int p) {
	l[x]=p;
	cor[x]=cnt;
	v[cnt].push_back(x);
	if(!cor[pos[x]])
		dfs(pos[x],++p);
}
signed main() {
	in(n);
	for(ri i=1; i<=n; ++i)
		in(a[i]),pos[i]=i,dif[i-1]=a[i]-a[i-1];
	in(m),in(k);
	for(ri i=1; i<=m; ++i)
		in(x),swap(pos[x],pos[x-1]);
	for(ri i=1; i<=n; i++)
		if(!l[i])
			cnt++,dfs(i,0);
	printf("%.1lf\n",(double)a[1]);
	int last=a[1];
	for(int i=1;i<n;i++)
		last+=dif[v[cor[i]][(l[i]+k)%v[cor[i]].size()]],printf("%.1lf\n",(double)last);
	return 0;
}

Measured memory_bytes: 10880
import java.util.*;

class Main {
public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x = sc.nextInt();

        int sum = x;
        for (int i = 1; i <= 10; i++) {
            sum = r * sum - D;
            System.out.println(sum);
        }
    }
}

Measured memory_bytes: 35548
n,k,s=map(int,input().split())
if s<10**9:
    x=[s]*k
    y=[s+1]*(n-k)
else:
    x=[s]*k
    y=[1]*(n-k)
z=" ".join(map(str,x))+" "+" ".join(map(str,y))
print(z)


Measured memory_bytes: 12068
package main

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

var K = 50

func main() {
	s := IOInitialize()
	A := Int(s)
	B := Int(s)
	m := make([][]string, K*2)
	for i := 0; i < K*2; i++ {
		m[i] = make([]string, K*2)
		for j := 0; j < K*2; j++ {
			if i < K {
				m[i][j] = "#"
			} else {
				m[i][j] = "."
			}
		}
	}

	for i := 0; i < A-1; i++ {
		isDraw := false
		for i := 0; i < K-1; i++ {
			if isDraw {
				break
			}
			for j := 0; j < K*2; j++ {
				if !validate(i, j, ".", m) {
					continue
				}
				m[i][j] = "."
				isDraw = true
				break
			}
		}
	}

	for i := 0; i < B-1; i++ {
		isDraw := false
		for i := K + 1; i < K*2; i++ {
			if isDraw {
				break
			}

			for j := 0; j < K*2; j++ {
				if !validate(i, j, "#", m) {
					continue
				}
				m[i][j] = "#"
				isDraw = true
				break
			}
		}
	}

	fmt.Println(fmt.Sprintf("%d %d", K*2, K*2))
	for key, _ := range m {
		str := ""
		for _, _val := range m[key] {
			str += _val
		}
		fmt.Println(str)
	}

}

func validate(i int, j int, target string, m [][]string) bool {
	if m[i][j] == target {
		return false
	}
	if i > 0 && j > 0 {
		if m[i-1][j-1] == target {
			return false
		}
	}
	if j > 0 {
		if m[i][j-1] == target {
			return false
		}
	}
	if i > 0 {
		if m[i-1][j] == target {
			return false
		}
	}
	if i < K*2 {
		if m[i+1][j] == target {
			return false
		}
	}
	if j < K*2 {
		if m[i][j+1] == target {
			return false
		}
	}
	if i < K*2 && j < K*2 {
		if m[i+1][j+1] == target {
			return false
		}
	}
	return true
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <assert.h>
#include <queue>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define fi first
#define sc second
typedef pair<int,int> P;
typedef pair<int,P> Q;
typedef pair<int,Q> R;
int dist[32][32][4];
int n,m,f[32][32];
int c[4];

int main(){
	while(1){
		cin >> m >> n; if(n==0) return 0;
		rep(i,n)rep(j,m) cin>>f[i][j];
		rep(i,32)rep(j,32)rep(k,4) dist[i][j][k] = 1e9;
		rep(i,4) cin>>c[i];
		priority_queue<R,vector<R>,greater<R> >que;
		dist[0][0][0] = 0;
		que.push(R(0,Q(0,P(0,0))));
		int dx[4]={0,1,0,-1};
		int dy[4]={1,0,-1,0};
		while(!que.empty()){
			R r = que.top(); que.pop();
			int x = r.sc.sc.fi, y = r.sc.sc.sc, d = r.sc.fi;
			if(dist[x][y][d] != r.fi) continue;
			if(f[x][y] <= 3){
				int D = (d+f[x][y])%4;
				int nx = x+dx[D], ny = y+dy[D];
				if(0<=nx&&nx<n&&0<=ny&&ny<m&&dist[nx][ny][D] > r.fi){
					dist[nx][ny][D] = r.fi;
					que.push(R(r.fi,Q(D,P(nx,ny))));
				}
			}
			rep(go,4){
				int D = (d+go)%4;
				int nx = x+dx[D], ny = y+dy[D];
				if(0<=nx&&nx<n&&0<=ny&&ny<m&&dist[nx][ny][D] > r.fi+c[go]){
					dist[nx][ny][D] = r.fi+c[go];
					que.push(R(r.fi+c[go],Q(D,P(nx,ny))));
				}
			}
		}
		int ans = 1e9;
		rep(i,4) ans = min(ans,dist[n-1][m-1][i]);
		cout << ans << endl;
	}
}



Measured memory_bytes: 3240
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch TakahashikunTheStrider | diff TakahashikunTheStrider.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address TakahashikunTheStrider.cpp && ./a.out

/*

 6/20/2020

 5:00-

 */

int D;

const double PI = acos(-1);
double deg2rad(double deg) { return deg*PI/180.0; }

double EPS=1e-6;
int solve() {
  double x=0,y=1;
  FOR(k,1,(int)1e6) {
    double rad=deg2rad(k*D);
    x+=sin(rad),y+=cos(rad);
    //dump(x,y);
    if(abs(x)<=EPS&&abs(y)<=EPS) return k+1;
  }
  assert(false);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>D;
  cout<<solve()<<endl;

  return 0;
}


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


int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    
    for(int i=0; i<N; i++) cin >> A[i];
    
    int ans=0;
    int cnt=0;
    
    while(true){
        if(cnt==0){
            N -= K;
            cnt++;
        }
        else
            N -= K-1;
        ans++;
        //cout << N << endl;
        if(N==0) break;
        else if(N<=(K-1)){
            ans++;
            break;
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n,l;
    cin>>n>>l;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    sort(s.begin(),s.end());
    rep(i,n)cout<<s[i]; cout<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>

#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef long double dd;



int main() {
	int N;
	priority_queue<
		dd,                // 要素の型はint
		std::vector<dd>,   // 内部コンテナはstd::vector (デフォルトのまま)
		std::greater<dd>   // 昇順 (デフォルトはstd::less<T>)
	> V;
	cin >> N;
	rep(i, N) {
		dd v;
		cin >> v;
		V.emplace(v);
	}
	rep(i,N-1) {
		dd f = V.top()/2.0; V.pop();
		dd s = V.top()/2.0; V.pop();
		V.emplace(f+s);
	}
	dd ans = V.top(); V.pop();
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main() {
    int a,b,cnt = 1,tmp = 0;
    cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }
    if(a >= b){
        cout << 1 << endl;
        return 0;
    }
    tmp = a;
    while(1) {
        cnt++;
        tmp += (a-1);
        if(tmp >= b) break;
    }
    cout << cnt << endl;
   // else cout << cnt << endl;
    return 0;
}

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

int main() {
    int K, A, B;
    cin >> K >> A >> B;
    if (A / K != B / K || A % K == 0 || B % K == 0)
        cout << "OK" << endl;
    else
        cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>

int main(){
  long n, x;
  long a[100000];
  long eat = 0;
  std::cin >> n >> x;
  for(int i = 0; i < n; i++){
    std::cin >> a[i];
  }

  for(int i = 0; i < n - 1; i++){
    if(a[i] > x){
      eat += a[i] + a[i + 1] - x;
      a[i] = x;
      a[i + 1] = 0;
    }
    else if(a[i] + a[i + 1] > x){
      eat += a[i] + a[i + 1] - x;
      a[i + 1] = x - a[i];
    }
  }

  std::cout << eat << std::endl;
}

Measured memory_bytes: 1024
#include<string>
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;


int H, W, N;
int a[10000];
int c[101][101];

pair<int, int> next(pair<int, int> now){
    if(now.second == 0 && now.first % 2 == 1){
        return make_pair(now.first+1, now.second);
    }
    if(now.second == W-1 && now.first % 2 == 0){
        return make_pair(now.first+1, now.second);
    }
    if(now.first % 2 == 0){
        return make_pair(now.first, now.second + 1);
    }
    if(now.first % 2 == 1){
        return make_pair(now.first, now.second - 1);
    }
}


int main(){
    cin >> H >> W;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    pair<int, int> now = make_pair(0, 0);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < a[i]; j++){
            c[now.first][now.second] = i+1;
            now = next(now);
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(j) cout << " ";
            cout << c[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from operator import itemgetter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

      


def main():
    N, M = i2nn()
    A = [(1, x) for x in i2nn()]
    S = [0] * M
    for j in range(M):
        S[j] = tuple(i2nn())
    S.extend(A)
    R = sorted(S, key=itemgetter(1))
    sum = 0
    while True:
        p = R.pop()
        if N - p[0] > 0:
            sum += p[0] * p[1]
            N -= p[0]
        else:
            sum += p[1] * N
            break
    print(sum)
    return

main()


Measured memory_bytes: 84052
N = input()
num_list = list(map(int, input().split()))

def multiply_list(num_list):
    if 0 in num_list:
        return 0

    numlist_2 = [num for num in  num_list if num >= 2 ]


    if len(numlist_2) >= 60:
        return -1

    ans = 1
    for num in numlist_2:
        ans *= num

    if ans > 10**18:
        ans = -1

    return ans

print(multiply_list(num_list))

Measured memory_bytes: 21644
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
#define rep(i,f_start,f_end) for (int i=f_start;i<=f_end;++i)
#define per(i,n,a) for (int i=n;i>=a;i--)
#define MT(x,i) memset(x,i,sizeof(x) )
#define rev(i,start,end) for (int i=start;i<end;i++)
#define inf 0x3f3f3f3f
#define mp(x,y) make_pair(x,y)
#define lowbit(x) (x&-x)
#define MOD 1000000007
#define exp 1e-8
#define N 1000005 
#define fi first 
#define se second
#define pb push_back
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
typedef vector <int> VI;
typedef pair<int ,int> PII;
typedef pair<int ,PII> PIII;
ll gcd (ll a,ll b) {return b?gcd (b,a%b):a; }
inline int read() {
    char ch=getchar(); int x=0, f=1;
    while(ch<'0'||ch>'9') {
        if(ch=='-') f=-1;
        ch=getchar();
    } while('0'<=ch&&ch<='9') {
        x=x*10+ch-'0';
        ch=getchar();
    } return x*f;
}

const int maxn=2e4+10;


int main () {
   int d,t,s;
   scanf ("%d%d%d",&d,&t,&s);
   double time=d*1.0/s;
   double need=t*1.0;
   if (time>need) printf ("No\n");
   else printf ("Yes\n");
   
    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<bool> dp(k+1,0);
  for(int i=1;i<=k;i++)
    for(int x:a)
      if(i-x>=0&&dp[i-x]==0)
        dp[i]=1;
  cout<<(dp[k]?"First":"Second");
}

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

int main(){
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << W*H/2 << endl;
    if(2*x == W & 2*y == H){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(x...)
#endif
#define endl "\n"
#define int long long int
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define loop(i,c) for(auto i=(c).begin();i!=(c).end();i++)
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define F first
#define S second
const int mod = 1e9 + 7;

void solving() {
	int x, n;
	cin >> x >> n;
	set<int>s;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		s.insert(x);
	}
	// debug(s);
	int ans = 0, mn = INT_MAX;
	for (int i = -1; i <= 101; i++) {
		auto it = find(all(s), i);
		if (it == s.end()) {
			if (abs(x - i) < mn) {
				mn = abs(x - i);
				ans = i;
			}
		}
	}
	cout << ans << endl;
}

int32_t main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// int t{}; cin >> t; while (t--)
	solving();
	return 0;
}

Measured memory_bytes: 3668
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
for i in range(1,20):
    if 26**i>=n:
        break
    else:
        n -= 26**i
n -= 1
s = []
for j in range(i):
    s.append(n%26)
    n //= 26
s.reverse()
print(''.join([chr(ord('a')+x) for x in s]))


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

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int n=0;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s.at(i)=='x')
		{
			++n;
		}
	}
	if (n<=7)
	{
		cout<<"YES\n";
	}
	else
	{
		cout<<"NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define N 100005
int seg[4*N];
int mul(int a, int b)
{
    return a*b%mod;
}
int mypower(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b%2)
            ans = mul(ans, a);
        b=b/2;
        a=mul(a,a);
    }
    return ans;
}
void update(int st, int l, int r, int idx, int arr[], int val)
{
    if(l == r)
    {
        seg[st] = arr[l] = val;
        return;
    }
    int mid = (l+r)/2;
    if(idx <= mid)
        update(2*st+1, l, mid, idx, arr, val);
    else
        update(2*st+2,mid+1, r, idx, arr,val);
    seg[st] = min(seg[2*st+1],seg[2*st+2]);    
}
int query(int st, int l, int r, int ql, int qr)
{
    if(l > qr || r < ql)
    {
        return 0;
    }
    if(l >= ql && r <= qr)
        return seg[st];
    int mid = (l+r)/2;
    return min(query(2*st+1, l, mid, ql, qr), query(2*st+2, mid+1, r, ql, qr));
}

signed main() {
    int n;
    cin >> n;
    string ans = "";
    int prev = 0;
    while(n)
    {
        int val = n%26;
        if(val == 0)
        {
            n=n/26;
            ans+='z';
            n--;
            continue;
        }
        ans+=('a'+val-1);
        n=n/26;
        //cout << val << " " << n << '\n';
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cctype>

int
main(void)
{
  char s[1000];
  int i, sum;

  while (std::scanf("%s", s) != EOF) {
    if (s[0] == '0') break;

    sum = 0;
    for (i = 0; s[i] != '\0'; i++) {
      if (std::isdigit(s[i])) {
        sum += (int)(s[i] - '0');
      }
    }
    std::printf("%d\n", sum);
  }
  
  return 0;
}



Measured memory_bytes: 2680
#include <iostream>
#include <math.h>

using namespace std;
typedef long long ll;

int main(){
    int b;
    while(cin >> b){
        if(b == 0) break;

        int ans1 = b, ans2 = 1;
        for(int n = 2; n < 100000; ++n){
            ll sm = 1*n*(n+1)/2;
            if(b < sm) break;
            int d = b - sm;
            if(d % n == 0){
                ans1 = d/n+1;
                ans2 = n;
            }
        }
        cout << ans1 << " " << ans2 << endl;
        
    }



    return 0;
}


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

int main(){
	string target;
	cin >> target;
	int ringCount = 0;
	cin >> ringCount;
	string tempString;
	int findCount = 0;
	for(int i=0;i<ringCount;i++){
		cin >> tempString;
		if((tempString + tempString).find(target) != string::npos){
			findCount++;
		}
	}
	cout << findCount << '\n';
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  cout <<(x-a) % b;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;

ll gcd(ll a, ll b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {

	int n;
	cin >> n;
	vector<ll> a(n), f(n), b(n);
	FOR(i, n)cin >> a[i];
	f[0] = a[0]; b[n - 1] = a[n - 1];
	FOR1(i, n) {
		f[i] = gcd(f[i - 1], a[i]);
		b[n - 1 - i] = gcd(b[n - i], a[n - 1 - i]);
	}
	ll ans = max(f[n - 2], b[1]);
	FOR1(i, n - 1)ans = max(ans, gcd(f[i - 1], b[i + 1]));
	cout << ans << endl;

	return 0;
}


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	map<int, int> cnt;

	cnt[a]++;
	cnt[b]++;
	cnt[c]++;

	for (auto &&p : cnt)
	{
		if (p.second == 2)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
	int N, K; cin >> N >> K;
	vector<int> as(N); REP(i, N) cin >> as[i];
	for (int i = K + 1; i <= N; ++i)
	{
		cout << (as[i - 1] > as[i - K - 1] ? "Yes\n" : "No\n");
	}
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
    fast;
    cin.tie(0);
/*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w" , stdout);
#endif*/
    lld need;
    cin >> need;
    lld cnt = 0;
    lld have = 100;
    while (have < need) {
        have = (have) + (have / 100);
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3652
package main

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

var sc = bufio.NewScanner(os.Stdin)

func rcv() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m := rcv(), rcv()

	var k int
	bucket := make(map[int]int, m)
	for i := 0; i < n; i++ {
		k = rcv()
		for j := 0; j < k; j++ {
			bucket[rcv()]++
		}
	}

	var ans int
	for _, v := range bucket {
		if v == n {
			ans++
		}
	}
	fmt.Println(ans)
}


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

int main(){
  int N, K, R, S, P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int index = 0;
  long long score = 0;
  for(int i = 0; i < K; i++){
    if(T[i] == 'r') score += P;
    else if(T[i] == 's') score += R;
    else score += S;
    if(i == N-1) break;
  }
  if(N <= K) cout << score << endl;
  else{
    while(true){
      int rest = N - (index+1)*K;
      string subT = T.substr(index*K,K);
      for(int i = 0; i < min(K,rest); i++){
        if(T[(index+1)*K+i] == subT[i]) T[(index+1)*K+i] = 'X';
        if(T[(index+1)*K+i] == 'r') score += P;
        else if(T[(index+1)*K+i] == 's') score += R;
        else if(T[(index+1)*K+i] == 'p') score += S;
      }
      index++;
      if(rest <= K) break;
    }
    cout << score << endl;
  }
  
}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int k;cin>>k;
    string s;cin>>s;
    if(s.size()<=k)cout<<s<<endl;
    else cout<<s.substr(0,k)<<"..."<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if(a>b)
	{
		printf("a > b\n");
	}
	else if(a<b)
	
	{
		printf("a < b\n");
	}
	else if(a==b)
	{
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2552
#include <stdio.h>

//int digit( x );
int digit( x ){
  int c=1;
  while( (x / 10) != 0){
    x /= 10;
    c++;
  }
  return c;
}
int main(){
  int a, b;
  int x;

  while( scanf("%d %d", &a, &b) != EOF){
    x = digit( a+b );
    printf("%d\n", x);
  }
  return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
int main(){
    int A, B, C, X, Y;
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    int money1 = A * X + B * Y;
    int money2 = C * 2 * (X<Y?X:Y) + (X>Y?A*(X-Y):B*(Y-X));
    int money3 = C * 2 * (X>Y?X:Y);
    printf("%d\n", money1 < money2 ? money1 < money3 ? money1 : money3 : money2 < money3 ? money2 : money3);
    return 0;
}


Measured memory_bytes: 128
from collections import deque

S = input()
Q = int(input())
Query = [input().split() for _ in range(Q)]

S = deque(S)
rev = False

for TFC in Query:
    if TFC[0] == '1':
        rev = not rev
    else:
        if TFC[1] == '1':
            if rev:
                S.append(TFC[2])
            else:
                S.appendleft(TFC[2])
        else:
            if rev:
                S.appendleft(TFC[2])
            else:
                S.append(TFC[2])
if rev:
    S.reverse()
print(''.join(S))

Measured memory_bytes: 44788
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

class UnionFindTree {
private:
	std::vector<int> par;   // 親
	std::vector<int> depth; // 木の深さ

public:
	// n要素で初期化
	UnionFindTree(int n) {
		for (int i = 0; i < n; i++) {
			par.push_back(i);
			depth.push_back(0);
		}
	}

	// 木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return;

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

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) { return find(x) == find(y); }
};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>P(N);
	rep(i, N) {
		cin >> P[i];
	}
	vector<int>X(M);
	vector<int>Y(M);
	rep(i, M) {
		cin >> X[i] >> Y[i];
	}
	rep(i, N) {
		P[i]--;
	}
	rep(i, M) {
		X[i]--;
		Y[i]--;
	}
	UnionFindTree uft(N);
	rep(i, M) {
		uft.unite(X[i], Y[i]);
	}
	int ans = 0;
	rep(i, N) {
		if (uft.same(i, P[i])) {
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2428
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,l,r) for(int i=(l);i<(r);i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
const long long mod = 1e9+7;
typedef long long ll;  //ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<ll, ll> > PS;
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

// g++ -std=c++11 prac.cpp 
// g++ -O3 -mtune=native -march=native -mfpmath=both prac.cpp

int main(){
    double x=0,y=0,z=0,n,m=0,k,h,ans=0,w,sum=1,Max=-1e9-1,cnt=0,Min=1e9+1;
    string s,t,u;
    bool ok=true;
    cin >> h >> w >> n;
    if(h > w){
        n = ceil(n / h);
    }
    else{
        n = ceil(n / w);
    }
    
    cout << n << endl;
    return 0;    
}


 

Measured memory_bytes: 256
def c_a_times_b_plus_c():
    N = int(input())
    ans = 0
    for a in range(1, N + 1):
        for b in range(N // a, 0, -1):
            if N - a * b >= 1:
                ans += 1
    return ans

print(c_a_times_b_plus_c())


Measured memory_bytes: 67676
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

typedef long long ll;
const ll INF = 1e17;




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

	double v[2000];

	for (int i = 1; i <= N; i++) {
		cin >> v[i];
	}

	sort(v+1, v + N+1);

	double ans = v[1];

	for (int i = 2; i <= N; i++) {
		ans = (ans + v[i]) / 2;
	}

	cout << ans;



	system("PAUSE");
}


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

int AC() {
    cout << "AC" << endl;
    return 0;
}

int WA() {
    cout << "WA" << endl;
    return 0;
}

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

    if (s[0] != 'A') {
        return WA();
    }

    int countC = 0;
    int posC = 0;
    for (int i = 2; i <= s.length() - 2; i++) {
        if (s[i] == 'C') {
            countC++;
            posC = i;
        }
    }

    if (countC != 1) {
        return WA();
    }

    countC = 0;
    for (int i = 1; i <= s.length() - 1; i++) {
        if (i == posC) continue;
        if (!('a' <= s[i] && s[i] <= 'z')) {
            return WA();
        }
    }

    return AC();
}


Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,a,b;
	cin>>n>>a>>b;
	int x=n/(a+b);
	int y=n%(a+b);
	cout<<x*a+min(y,a);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

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

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}


int main() {
	int a, b, x;
	cin >> a >> b >> x;
	cout << (x >= a && x <= a + b ? "YES" : "NO");
}



Measured memory_bytes: 256