akhauriyash/Code-Regression huggingface dataset:
r = int(input())


import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1

    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True


if r == 2:
    print(2)
else:
    if r % 2 == 0:
        r += 1

    while True:
        if is_prime3(r):
            break
        r += 2

    print(r)


Measured memory_bytes: 4336
import math

def calc(op, a, b):
    if op == '+':
        return int(a) + int(b)
    elif op == '-':
        return int(a) - int(b)
    elif op == '*':
        return int(a) * int(b)
    elif op == '/':
        return math.floor(float(a) / float(b))

while True:
    a, op, b = input().split()

    if op == "?":
        break

    print(calc(op, a, b))


Measured memory_bytes: 5668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int a=0;
  string s[100];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>s[i];
  for(int i=0;i<n;i++)
  {
    
    if(s[i]=="Y")
      a=1;
  }
  if(a==0)
    cout<<"Three";
  else
    cout<<"Four";
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  ll ans = 0;

  if (s[0] != s[s.size() - 1]) {
    rep(i, s.size()) {
      int j = i;
      while (j + 1 < s.size() && s[i] == s[j + 1]) j++;
      ans += (j - i + 1) / 2;
      i = j;
    }
    ans *= k;
  } else {
    int l = 0;
    int r = 0;
    while (l < s.size() && s[0] == s[l]) l++;
    while (r < s.size() && s[s.size() - 1] == s[s.size() - 1 - r]) r++;
    if (l == s.size()) {
      ans = k * s.size() / 2;
    } else {
      rep(i, s.size()) {
        int j = i;
        while (j + 1 < s.size() && s[i] == s[j + 1]) j++;
        ans += (j - i + 1) / 2;
        i = j;
      }
      ans *= k;
      if (l % 2 && r % 2) ans += (k - 1);
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a + 1):
    for j in range(b + 1):
        res = x - (500 * i + 100 * j)
        # print(i, j, res)
        if res >= 0 and res % 50 == 0 and res // 50 <= c:
            ans += 1

print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
using namespace std;
 
typedef long long int       lint;
typedef vector<int>         vi;
typedef vector<lint>        vl;
typedef pair<int, int>      pii;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
 
#define pb(n)           push_back(n)
#define ALL(n)          (n.begin(), n.end())
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define M               10000000
#define MOD             10000007
#define INF             1e9+7
#define REP(i,a,b)      for(int i = int(a); i <= int(b); i++)
#define REPL(i,a,b)     for(lint i = lint(a); i <= lint(b); i++)
#define fastIO()        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    lint n, base;
    cin>>n>>base;

    vl k;
    while(n){
        k.pb(n % base);
        n /= base;
    }
    cout<<k.size()<<endl;

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


def solve(N: int, p: "List[int]"):
    B = sorted(p)
    count = 0
    for bb, pp in zip(B, p):
        if bb != pp:
            count += 1
    if count <= 2:
        yes()
    else:
        no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
cnt = int(input())
chain = 0
first = 0
second = 0

for i in range(cnt):
    nList = list(map(int, input().split()))
    first = nList.pop()
    second = nList.pop()
    if first == second:
        chain = chain + 1
        if chain >= 3:
            break
    else:
        chain = 0

if chain >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9092
n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
aa = [0]
bb = [0]

for s in range(n):
    aa.append(aa[s] + a[s])
for s in range(m):
    bb.append(bb[s] + b[s])      
ans = 0
j = m

for i in range(n+1):
    if aa[i] > k:
        break
    while bb[j] > k - aa[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)

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

using namespace std;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod;
#define N 21
ll f[(1<<21)],n;
bool t[N][N];
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
     for(int j=0;j<n;j++)cin>>t[i][j];   
    }
    for(int i=0;i<(1<<n);i++)f[i]=0; f[0]=1;
    for(int i=0;i<(1<<n);i++){
     ll cnt=0;
     for(int j=0;j<n;j++)if((1<<j)&i)cnt++;
     for(int j=0;j<n;j++){
      if(t[cnt][j]==0)continue;
      if((1<<j)&i)continue;
      mad(f[i+(1<<j)],f[i]);
     }
    }
    cout<<f[(1<<n)-1]<<endl;
 return 0;   
}

Measured memory_bytes: 16640
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

template <typename T>
struct BIT {
private:
    vector<T> v;
public:
    BIT(int n) : v(n, 0) {}
    T sum(int i) const {
        T s = 0;
        while (i > 0) {
            s += v[i];
            i = (i & (i + 1)) - 1;
        }
        return s;
    }
    void add(int i, T x) {
        while (i < (int)v.size()) {
            v[i] += x;
            i |= i + 1;
        }
    }
    int size() const { return v.size(); }
};

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto &e: a) cin >> e;

    BIT<int> cnt(n+1);

    int ans = 1;
    cnt.add(a[0], 1);
    for (int i = 1; i < n; ++i) {
        if (cnt.sum(a[i]) == 0) ++ans;
        cnt.add(a[i], 1);
    }

    cout << ans << endl;




    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
const int N=55;
struct Edge{
	int next,to,w,v;
}edge[N<<2];
struct Node{
	long long val;int u,s;
	bool operator < (const Node &b)const{return val>b.val;}
}u;
int fi[N],se,s,s1,c[N],d[N];long long dis[N][N*N];
bool vis[N][N*N];
inline void add_edge(int u,int v,int a,int b){edge[++se]={fi[u],v,a,b},fi[u]=se;}
inline void add(int u,int v,int a,int b){add_edge(u,v,a,b),add_edge(v,u,a,b);}
priority_queue<Node>q;
void dijk(){
	memset(dis,0x1f,sizeof(dis));dis[1][s]=0;
	q.push(Node{0,1,s});
	while(!q.empty()){
		u=q.top();q.pop();
		if(vis[u.u][u.s])continue;
		vis[u.u][u.s]=1;
		if(dis[u.u][min(s1,u.s+c[u.u])]>dis[u.u][u.s]+d[u.u]){
			dis[u.u][min(s1,u.s+c[u.u])]=dis[u.u][u.s]+d[u.u];
			q.push(Node{dis[u.u][min(s1,u.s+c[u.u])],u.u,min(s1,u.s+c[u.u])});
		}
		for(int i=fi[u.u];i;i=edge[i].next){
			int v=edge[i].to;
			if(u.s>=edge[i].w&&dis[v][u.s-edge[i].w]>dis[u.u][u.s]+edge[i].v){
				dis[v][u.s-edge[i].w]=dis[u.u][u.s]+edge[i].v;
				q.push(Node{dis[v][u.s-edge[i].w],v,u.s-edge[i].w});
			}
		}
	} 
}
int main(){
	int n,m,u,v,a,b;scanf("%d%d%d",&n,&m,&s);
	for(int i=0;i<m;i++)scanf("%d%d%d%d",&u,&v,&a,&b),add(u,v,a,b),s1=max(s1,a);
	for(int i=1;i<=n;i++)scanf("%d%d",c+i,d+i);
	s=min(s,s1*=n);
	dijk();
	for(int i=2;i<=n;i++){
		long long ans=0x1f1f1f1f1f1f1f1f;
		for(int j=0;j<=s1;j++)ans=min(ans,dis[i][j]);
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 6608
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int antenna[5];
      int i,j,distance;
      string answer = "Yay!";
      for (i=0;i<5;i++) {
          cin >> antenna[i];
      }
      cin >> distance;
      for (i=0;i<5;i++) {
          for (j=4;j>i;j--) {
              if (antenna[j] - antenna[i] > distance) {
                  answer = ":(";
              }
          }
      }

      cout << answer << endl;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<set>
#define ll long long
using namespace std;
const int N=1e5+5,inf=0x7f7f7f7f;
struct node{
	int num,x,y;
}a[N],b[N];
int n,vis[N];
ll s1,s2;
int cmp(node l,node r)
{
	return l.x-r.y>r.x-l.y;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
		b[i].x=a[i].y;
		b[i].y=a[i].x;
		a[i].num=b[i].num=i;
	}
	sort(a+1,a+n+1,cmp);
	sort(b+1,b+n+1,cmp);
	int h1=1,h2=1;
	for(int i=1;i<=n;i++)
	{
		if(i%2)
		{
			while(vis[a[h1].num])  h1++;
			s1+=a[h1].x;
			vis[a[h1].num]=1;
		}
		else
		{
			while(vis[b[h2].num])  h2++;
			s2+=b[h2].x;
			vis[b[h2].num]=1;
		}
	}
	cout<<s1-s2;
	return 0; 
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin>>h[i];
  }
  int MIN=0,cnt=0;;
  for(int i=0;i<N;i++){
    if(h[i]>MIN){cnt+=(h[i]-MIN);}
    MIN=h[i];
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>

std::vector<int> a[100000], b[100000], group;
int n, m, k, x, y, tmp, cnt, ans[100001], lbl[100001];
bool done[100001];
std::queue<int> idx;

void solve() {
	std::cin >> n >> m >> k;
    for (int i=0; i<m; ++i) {
		std::cin >> x >> y;
		a[x].push_back(y);
		a[y].push_back(x);
	}

	cnt = 0;
	for (int i=0; i<100001; ++i) {
		done[i] = 0;
		ans[i] = 0;
	}
    for (int i=1; i<n+1; ++i) {
		group.clear();
		if (done[i] == true)
            continue;
		done[i] = true;
		group.push_back(i);
		for (int p : a[i]) {
			idx.push(p);
			done[p] = true;
			group.push_back(p);
		}
		while (!idx.empty()) {
			tmp = idx.front();
			idx.pop();
			for (int p : a[tmp]) {
				if (done[p] == true)
                    continue;
				idx.push(p);
				done[p] = true;
				group.push_back(p);
			}
		}
		for (int s : group) {
			ans[s] = group.size();
			lbl[s] = cnt;
		}
		++cnt;
	}

    for (int i=0; i<k; ++i) {
		std::cin >> x >> y;
		if (lbl[x] == lbl[y]) {
			b[x].push_back(y);
			b[y].push_back(x);
		}
	}

    for (int i=1; i<n+1; ++i)
		std::cout << ans[i] - a[i].size() - b[i].size() - 1 << " ";
    std::cout << std::endl;
}

int main() {
    std::ios_base::sync_with_stdio(0);
    solve();
    return 0;
}


Measured memory_bytes: 15448
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,L=LI()
AJI=[L+i-1 for i in range(1,N+1)]

mi = INTMAX
hikuyatsu = 0
for i in AJI:
    if mi > abs(i):
        mi = abs(i)
        hikuyatsu = i

# print(AJI)
print(sum(AJI)-hikuyatsu)

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

int main(void)
{
	int n;
	// ??????????????°n???????????????
	scanf("%d", &n);

	int *ip;
	// ???????????¨????????????????????????????????????????????????????¢????
	ip = (int *)malloc(n * sizeof(int));

	int i, j;
	int temp;
	// ?¶??????????n?????????????????\??????????????????
	for (i=0; i<n; i++) {
		scanf("%d", &ip[i]);
	}

	/*
	//???????????????needs improvement in time-efficiency
	int max = ip[1]-ip[0];
	for (i=0; i<n; i++) {
		for (j=i+1; j<n; j++) {
			if (ip[j] - ip[i] > max) {
				max = ip[j] - ip[i];
			}
		}
	}
	printf("%d\n", max);
	*/

	int max_difference = ip[1]-ip[0];
	int min_idx = 0;
	for (i=1; i<n; i++) {
		if (ip[i]-ip[min_idx] > max_difference) {
			max_difference = ip[i]-ip[min_idx];
		}
		if (ip[i] < ip[min_idx]) {
			min_idx = i;
		}
	}
	printf("%d\n", max_difference);

	free(ip);
	return 0;
}

Measured memory_bytes: 3176
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, gcd
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 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 TUPLE(): return tuple(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 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, D, A = MAP()
XH = [LIST() for _ in range(N)]

XH.sort(key = lambda x: x[0])

X = [XH[i][0] for i in range(N)]
H = [XH[i][1] for i in range(N)]

ans = 0
imos = [0]*(N+1)
tmp = 0
for i in range(N):
	x, h = XH[i]
	tmp += imos[i]
	left = h-tmp
	if 0 < left:
		cnt = -(-left//A)
		damage = A*cnt
		idx = bisect(X, x+2*D)
		tmp += damage
		imos[idx] -= damage
		ans += cnt

print(ans)



Measured memory_bytes: 57644
MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  123
  55
  1000
  0
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end

n=0
s=nil
while true
  s = line[n]
  break if s == "0"
  n += 1  
  puts s.chars.map(&:to_i).inject(&:+)
end

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
  int N;
  cin >> N;
  long long int X[N], Y[N];
  for(int i = 0 ; i < N ; i++){
    cin >> X[i];  Y[i] = X[i];
  }
  sort(Y, Y+N);
  int medl = Y[N/2-1];
  int medr = Y[N/2];
  for(int i = 0 ; i < N ; i++){
    if(X[i] <= medl){
      cout << medr << endl;
    }else{
      cout << medl << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5248
n=int(input())
h=list(map(int, input().split()))
h.reverse()
a=0
for i in range(len(h)-1):
  if h[i]+1 < h[i+1]:
    a+=1
    break
  elif h[i]+1==h[i+1]:
    h[i+1]=h[i+1]-1
  else:
    pass
if a==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 14396
bingo = [list(map(int, input().split())) for i in range(3)]
seen = [[False] * 3 for i in range(3)]

def check(seen):
    ans = 0
    if seen[0][0] and seen[0][1] and seen[0][2]:
        ans = 1
    if seen[1][0] and seen[1][1] and seen[1][2]:
        ans = 1
    if seen[2][0] and seen[2][1] and seen[2][2]:
        ans = 1
    if seen[0][0] and seen[1][0] and seen[2][0]:
        ans = 1
    if seen[0][1] and seen[1][1] and seen[2][1]:
        ans = 1
    if seen[0][2] and seen[1][2] and seen[2][2]:
        ans = 1
    if seen[0][0] and seen[1][1] and seen[2][2]:
        ans = 1
    if seen[2][0] and seen[1][1] and seen[0][2]:
        ans = 1
    if ans == 1:
        print("Yes")
        exit()
    else:
        print("No")

N = int(input())
for i in range(N):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k] == b:
                seen[j][k] = True

check(seen)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb push_back
#define LL long long
using namespace std;
char S[100];
int is_it(int x){
	printf("%d\n",x);
	fflush(stdout);
	scanf("%s",S);
	if(S[0]=='V')	exit(0);
	if(S[0]=='M')	return 0;
	return 1;
}
int main(){
	int n,s,e,sx,mid,x,cnt=0;
	scanf("%d",&n);
	x=is_it(0);
	cnt++;
	sx=x;
	s=0;e=n-1;
	while(s<=e){
		mid=(s+e)/2;
		if(cnt==20)	exit(0);
		sx=is_it(mid);
		cnt++;
		if((mid-s)%2==x^sx)	s=mid,x=sx;
		else	e=mid;
		if(e-s==1){
			return !is_it(e);
		}
	}
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      S[i].emplace_back(s - 1);
    }
  }
  vector<int> P(M);
  for (int i = 0; i < M; i++) {
    cin >> P[i];
  }

  int res = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    auto check = [&]() -> bool {
      for (int i = 0; i < M; i++) {
        int cnt = 0;
        for (int j = 0; j < (int)S[i].size(); j++) {
          if ((bit >> S[i][j]) & 1) cnt++;
        }
        if (cnt % 2 != P[i]) return false;
      }
      return true;
    };

    if (check()) res++;
  }

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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    ll n,m,l;
    cin >> n >> m >> l;
    vector<vector<ll>> dist(n,vector<ll>(n,INF));
    vector<vector<ll>> dist2(n,vector<ll>(n,INF));
    rep(i,m){
        ll a,b,c;
        cin >> a >> b >> c;
        a--; b--;
        dist[a][b]=c;
        dist[b][a]=c;
    }
    rep(k,n){
        rep(i,n){
            if(i==k) continue;
            rep(j,n){
                if(j==k || j==i) continue;
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    rep(i,n){
        rep(j,n){
            if(j==i) continue;
            if(dist[i][j]<=l){
                dist2[i][j]=1;
            }
        }
    }
    rep(k,n){
        rep(i,n){
            if(i==k) continue;
            rep(j,n){
                if(j==k || j==i) continue;
                dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j]);
            }
        }
    }
    ll q;
    cin >> q;
    rep(i,q){
        ll s,t;
        cin >> s >> t;
        s--; t--;
        cout << ((dist2[s][t]==INF)?-1:dist2[s][t]-1) << endl;
    }
    return 0;
}


Measured memory_bytes: 1920
a = int(input())
b = int(input())
c = int(input())
x = int(input())
d = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                d +=1
print(d)

Measured memory_bytes: 9080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
int main(){
    ll n, t;
    cin >> n >> t;
    vector<ll> time(n);
    for (ll i = 0; i < n; i++) cin >> time[i];
    ll ans = 0;
    for (ll i = 0; i < n - 1;i++){
        ans += min(t, time[i + 1] - time[i]);
    }
    ans += t;
    cout << ans << endl;
}

Measured memory_bytes: 4768
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  int n=a+b>2*c?min(x,y):0;
  cout<<c*2*n+min(a,c*2)*(x-n)+min(b,c*2)*(y-n)<<endl;
}

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

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int A, B, C, D;
    cin >> A >> B >> C >> D;

    string result;
    while(true){
        C -= B;
        if(C <= 0){
            result = "Yes";
            break;
        }
        A -= D;
        if(A <= 0){
            result = "No";
            break;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	bool fs=1;
	while(true){
		int n,a,b,c,d,mna,mnb,mnc,mnd,mn=1e8;
		scanf("%d",&n);
		if(!n) break;
		if(!fs) printf("\n");
		fs=0;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int allen=10*a+50*b+100*c+500*d,allmai=a+b+c+d;
		rep(i,a+1) rep(j,b+1) rep(k,c+1) rep(l,d+1){
			int en=10*i+50*j+100*k+500*l,mai=i+j+k+l;
			if(en<n) continue;
//			printf("%d %d %d %d\n",i,j,k,l);
			int ch=en-n;
			int chm=0;
			chm+=ch/500;
			ch%=500;
			chm+=ch/100;
			ch%=100;
			chm+=ch/50;
			ch%=50;
			chm+=ch/10;
			if(mn>chm+allmai-mai){
				mna=i,mnb=j,mnc=k,mnd=l;
				mn=chm+allmai-mai;
			}
		}
//		printf("%d\n",mn);
		if(mna>0) printf("%d %d\n",10,mna);
		if(mnb>0) printf("%d %d\n",50,mnb);
		if(mnc>0) printf("%d %d\n",100,mnc);
		if(mnd>0) printf("%d %d\n",500,mnd);
	}
	return 0;
}

Measured memory_bytes: 1016
using System;

class Program
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();
        bool flag = false;

        char[] s = S.ToCharArray();

        for (int j = 0; j < S.Length; j++)
        {
            char tmp = s[s.Length - 1];
            for (int i = s.Length - 1; i > 0; i--)
                s[i] = s[i - 1];
            s[0] = tmp;
            S = new string(s);
            if (S == T) flag = true;
            if (flag == true) break;
        }

        if (flag == true) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

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

typedef long long ll;

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];
int cntx = 0;
int cnty = 0;

void dfs(int v){
  if (visited[v]) return;
  visited[v] = true;
  if (v < V) cntx++;
  else cnty++;
  for (int u : to[v]) dfs(u);
  return;
}

int main(){
  int N;
  cin >> N;
  for (int i=0;i<N;i++){
    int x, y;
    cin >> x >> y;
    y += V;
    to[x].push_back(y);
    to[y].push_back(x);
  }
  ll ans = 0;
  for (int i=0;i<2*V;i++){
    if (visited[i]) continue;
    cntx = 0;
    cnty = 0;
    dfs(i);
    ans += (ll)cntx*cnty;
  }
  ans -= N;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define DEBUG_VARIABLE(variable) cout << #variable << ":" << variable << endl

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {-1, 0, 1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

void printArray(int *array, int);
void printDimention(DVector);



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

    cin >> n;
    int a[n];
    rep(i, n)   cin >> a[i];
    
    //今の状態を表す
    bool flg = true;
    ll tmp = 0;
    ll d;
    ll res1 = 0;
    rep(i, n){
        tmp += a[i];
        if(flg){
            if(tmp <= 0){
                d = 1 - tmp;
                res1 += d;
                tmp = 1;
            }
            flg = false;
        }else{
            if(tmp >= 0){
                d = 1 + tmp;
                res1 += d;
                tmp = -1;
            }
            flg = true;
        }
    }
    
    flg = false;
    tmp = 0;
    ll res2 = 0;
    rep(i, n){
        tmp += a[i];
        if(flg){
            if(tmp <= 0){
                d = 1 - tmp;
                res2 += d;
                tmp = 1;
            }
            flg = false;
        }else{
            if(tmp >= 0){
                d = 1 + tmp;
                res2 += d;
                tmp = -1;
            }
            flg = true;
        }
    }
    //DEBUG_VARIABLE(res1);
    //DEBUG_VARIABLE(res2);
    cout << min(res1, res2) << endl;
}

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

//二次元配列の表示
void printDimention(DVector &dv){
    rep(i, (int)dv.size()){
        rep(j, (int)dv[i].size()){
            if(j)   cout << " ";
            cout << dv[i][j];
        }
        cout << endl;
    }
}

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

int main(){
    int x , y;
    
    for(int i = 0;;i++){
        cin >> x >> y;
        if(x >= y && !(x == 0 && y == 0)){
            cout << y << " " << x << endl;
        }
        if(x < y){
            cout << x << " " << y << endl;
        }
        if(x == 0 && y == 0){
            break;
        }
    }
}


Measured memory_bytes: 3084
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder124
{
    class Program
    {
        public static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int[] ss = new int[2];
            ss[0] = int.Parse(s[0]);
            ss[1] = int.Parse(s[1]);
            ss = ss.OrderByDescending(x => x).ToArray();
            int res = 0;
            res += ss[0];
            ss[0]--;
            ss = ss.OrderByDescending(x => x).ToArray();
            res += ss[0];
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 13268
while True:
  a,b,c = input().split()
  a = int(a)
  c = int(c)
  if b == "?":
      break
  if b == "+":
    print(a + c)
  if b == "-":
    print(a - c)
  if b == "*":
    print(a * c)
  if b == "/":
    print(a // c)
 


Measured memory_bytes: 5596
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;


int selectionsort(int A[], int N) {

    int cnt = 0;
    for (int i = 0; i < N; i++)
    {
        bool flag = false;
        int min = i;

        for (int j = i; j < N; j++) 
        {
            if (A[min] > A[j]) 
            {
                min = j;
                flag = true;
            }
        }

        swap(A[i], A[min]);
        if (flag)
            cnt++;
            
    }

    return cnt;

}

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

    int cnt = selectionsort(A, N);
    for (int i = 0; i < N; i++) {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << '\n';
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 3096
def main():
    H,W = map(int,input().split())
    root = [list(str(input())) for _ in range(H)]
    _long = [[0 for _ in range(W)] for _ in range(H)]
    _long[0][0] = 1
    al = 0
    for i in range(H):
        for j in range(W):
            if root[i][j] == "#":
                al += 1
    
    if al != H+W-1:
        print("Impossible")
        exit()
    
    print("Possible")
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
x = str(input())
s = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(s)):
    if x == s[i]:
        print(s[i + 1])

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
A,B = map(int,input().split())
h,w = 100, 100
grid = [['.' if j < 50 else '#' for i in range(w)] for j in range(h)]
A -= 1
B -= 1
reg = ['.' if i % 2 == 0 else '#' for i in range(w)]
for i in range(25):
    if B >= 50:
        grid[i*2] = reg
        B -= 50
    else:
        for j in range(B):
            grid[i*2][j*2] = '#'
        break
for i in range(25):
    if A >= 50:
        grid[99 - i*2] = reg
        A -= 50
    else:
        for j in range(A):
            grid[99 - i*2][j*2] = '.'
        break
print(h,w)
for row in grid:
    print(''.join(row))
    

Measured memory_bytes: 3188
import sys
from itertools import combinations, permutations

input = sys.stdin.readline

N = int(input())
xy = [list(map(int,input().split())) for i in range(N)]

ans = 0
npath = N*(N-1)
for i,j in permutations(range(N),2):
	dist = ( (xy[i][0]-xy[j][0])**2 + (xy[i][1]-xy[j][1])**2 )**0.5
	ans += dist/npath*(N-1)

print(ans)

Measured memory_bytes: 38512
#include<iostream>
#include<vector>
#define inf 1000000007
#include<cstring>
#define ll long long int
using namespace std;
ll N,W;
vector<ll> w(104);
vector<ll> v(104);

ll dp[105][100005];

ll maxval(ll i ,ll val)
{
    if(val==0)
     return 0;
    if(i==N || val <0)
      return inf;
    if(dp[i][val]!=-1)
       return dp[i][val];
    
    return dp[i][val]=min(maxval(i+1,val-v[i])+w[i], maxval(i+1,val));
}


int main()
{
    ll sum=0;

    cin>>N>>W;
  
    memset(dp,-1,sizeof dp );
    for(ll i=0;i<N;i++)
    {
        cin>>w[i]>>v[i];
        sum+=v[i];
    }
    ll maxv;
    
    for(ll val=sum;val>=0;val--)
    {
        if(maxval(0,val)<=W)
        {
            maxv=val;
            break;
        }
    }
    
    cout<<maxv<<"\n";
}

Measured memory_bytes: 85556
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
using namespace std;
const double PI = acos(-1);  // PI = 3.141593...

int main() {
    int n, s[1000];
    while(true) {
        double sum=0, m, a=0;
        cin >> n;
        if(n==0) break;
        for(int i = 0; i < n; ++i) {
            cin >> s[i];
            sum += s[i];
        }
        m = sum/n;
        for(int i = 0; i < n; ++i) {
            a += (s[i]-m)*(s[i]-m);
        }
        a = sqrt(a/n);
        printf("%.8lf\n", a);
    }
    return 0;
}


Measured memory_bytes: 3164
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse", "sse2", "avx", "avx2")

#include<bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using ull = unsigned long long;

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void accell() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int mod = 1e9 + 7;
const int K = 120;



signed main() {
    accell();
    int n;
    cin >> n;
    int s = 0;
    for (int i = 1; i <= n; ++i) {
        int aa = i;
        if (aa % 3 != 0 && aa % 5 != 0)
        s += aa;
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3648
n = int(input())
a = list(map(int,input().split()))
def d4(x,y):
  ret = 0
  while x > y:
    y *= 4
    ret += 1
  return ret
def cost(ls):
  l = len(ls)
  ret = [0]*l
  stack = [(l-1,10**18)]
  for i in range(l-1)[::-1]:
    ret[i] = ret[i+1]
    if ls[i] <= ls[i+1]:
      d = d4(ls[i+1],ls[i])-1
      if d > 0:
        stack.append((i,d))
    else:
      d = d4(ls[i],ls[i+1])
      while d:
        idx,num = stack.pop()
        if d > num:
          ret[i] += (idx-i)*num
          d -= num
        else:
          ret[i] += (idx-i)*d
          num -= d
          d = 0
          if num:
            stack.append((idx,num))
  return ret
cp = cost(a)
cn = cost(a[::-1])
for i in range(n):
  cp[i] *= 2
  cn[i] *= 2
  cn[i] += n-i
ansls = [cp[0],cn[0]]
for i in range(1,n):
  ansls.append(cp[i]+cn[n-i])
print(min(ansls))

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

using namespace std;
typedef long long ll;

#define out(ans) cout << ans << endl
#define in(n) cin >> n
#define floop(i, N) for (ll i = 0; i < N; i++)
#define floop1(i, N) for (ll i = 1; i <= N; i++)
#define floopi(i, j, N) for (ll j = i + 1; j < N; j++)

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

void solve();

int main()
{
    solve();
}

void solve()
{
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int ans = (H - h) * (W - w);
    out(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
  int n;cin>>n;
  int a[n];rep(i,n)cin>>a[i];
  ll s[n+1]={};rep(i,n)s[i+1]=s[i]+a[i];
  ll f[n-3];
  f[0]=0;
  int fbar=0;
  rep(i,n-4){
    ll lsum=s[i+3]-s[0];
    while(true){
      ll sumq=s[fbar+1]-s[0];
      ll sumqnext=s[fbar+2]-s[0];
      if(abs((lsum-sumq)-sumq)>abs((lsum-sumqnext)-sumqnext)){
        fbar++;
      }
      else{
        f[i+1]=fbar;break;
      }
    }
  }
  ll g[n-3];
  g[0]=0;
  int gbar=0;
  rep(i,n-4){
    ll rsum=s[n]-s[n-i-3];
    while(true){
      ll sumq=s[n]-s[n-gbar-1];
      ll sumqnext=s[n]-s[n-gbar-2];
      if(abs((rsum-sumq)-sumq)>abs((rsum-sumqnext)-sumqnext)){
        gbar++;continue;
      }
      else{
      g[i+1]=gbar;break;
      }
    }
  }
  ll res=1e18;
  rep(i,n-3){
    ll ans[4];
    ans[0]=s[f[i]+1];
    ans[1]=s[i+2]-ans[0];
    ans[2]=s[n]-s[n-1-g[n-4-i]];
    ans[3]=s[n]-s[i+2]-ans[2];
    sort(ans,ans+4);
    chmin(res,abs(ans[3]-ans[0]));
  }
  cout<<res<<endl;
}
      



Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

const ll MOD = 1000000007;

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {
    }
    mint operator-() const {
        return mint(-x);
    }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t/2);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

ostream &operator<<(ostream &os, const mint &a) {
    return os << a.x;
}

int main() {
    int N;
    cin >> N;
    
    vec<string> S(2);
    rep(i, 2) cin >> S[i];

    mint ans = 1;
    rep(i,N){
        bool tate = S[0][i] == S[1][i];
        bool yoko = !tate;
        if(i==0 && tate){
            ans*=3;
            continue;
        } else if(i==0 && !tate){
            ans*=6;
            continue;
        }

        bool _tate =  S[0][i-1] == S[1][i-1];
        bool _yoko = !_tate;
        bool yokoyoko = yoko&&_yoko&&(S[0][i] == S[0][i-1]);
        if(_tate && tate){
            ans*=2;
        } else if(_tate && yoko){
            ans*=2;
        } else if(_yoko && tate){
            ans*=1;
        } else if(yokoyoko){
            ans*=1;
        } else if(_yoko&&yoko){
            ans*=3;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
#include<iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	int tmp=0;
	for(int i=1; i*i<N+1; i++){
		tmp = N/i;
		if(N%i==0 && tmp<10){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import math
import queue

mod = 1e9+7

def swap(a,b):
    return (b,a)

def gcd(a,b):
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def divisors(a):
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def main():
    n = int(input())
    h = [x for x in map(int,input().split())]
    h.insert(0,0)
    x = []
    for i in range(1,n+1):
        if h[i]<=h[i-1]:
            x.append(x[-1]+1)
        else:
            x.append(0)
    print(max(x))
    return

if __name__ == '__main__':
    main()

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

using namespace std;

typedef long long ll;

ll cur = 0;

struct node{
  ll x, y;
  bool operator < (node other)const{
    return x + (cur - y) < other.x + (cur - other.y);

  }
};

int main(){

  ll n;

  cin >> n;

  ll x;

  priority_queue<node>pq;

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


    cin >> x;
    pq.push(node{x, 0});



  }


  while(pq.top().x + (cur - pq.top().y) >= n){

    ll x = pq.top().x + (cur - pq.top().y);
    pq.pop();

    ll lo = 0, hi = 1e17;

    while(lo < hi){

      ll md = lo + (hi - lo)/2;

      if(x - (n * md) < n)hi = md;
      else
        lo = md + 1;
    }
    cur += lo;
    x -= (n * lo);
    pq.push(node{x, cur});

  }

  printf("%lld\n", cur);



}


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

int min(const void *a,const void *b){
  return *(char *)a-*(char *)b;
}
int max(const void *a,const void *b){
  return *(char *)b-*(char *)a;
}
int main(){
  int i,n,ans;
  char num[9];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",num);
    qsort(num,8,sizeof(char),max);
    ans=atoi(num);
    qsort(num,8,sizeof(char),min);
    ans-=atoi(num);
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <map>
using namespace std;
 
#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif
#define PI 3.1415926535897932384626433832795
#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
typedef long long ll;
#define vv(t) vector<t>
 
template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}
 
int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}
 
 
 
int main(){
    int N, K;
    cin >> N;
    printf("%.20f\n", 2*N*PI);
    return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){
	int n;
	I(n);
	
	while(n){
		if(n%10==7){

			cout<<"Yes"<<endl;
			return 0;
		}
		n/=10;
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 3752
#include <stdio.h>

void trace(int A[], int N){
  int i;
  for (i = 0; i < N; i++) {
    if (i > 0) printf(" "); //put space
    printf("%d",A[i]);
  }
  printf("\n");
}

void InsertionSort(int A[], int N){
  int j, i, v;
  for (i = 1; i < N ; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main() {
    int N, i, j;
    int A[100];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
      scanf("%d", &A[i]);
    }

    trace(A, N);
    InsertionSort(A, N);

  return 0;
}



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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

ll bpow(ll x,ll n,ll m=MD,ll r=1LL){for(;n>0;n>>=1,x=x*x%m) if(n&1) r=r*x%m; return r;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	ll ans =0;
	auto sms=[](ll l, ll r){return (l+r)*(r-l+1)/2;};
	rep2(i, k, n+2){
		ll st = sms(0, i-1);
		ll ed = sms(n-i+1, n);;
		//dbg(i,st,ed);
		(ans += ed +1 - st) %=MD;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    int n;

    cin >> n;

    if (n%2) cout << n*2;
    else cout << n;

    return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
A=map(int,input().split())
B=map(int,input().split())
Y=[0]*N*M
X=[0]*N*M
for a in A:
	if Y[a-1]:
		print(0)
		exit()
	Y[a-1]=1
for b in B:
	if X[b-1]:
		print(0)
		exit()
	X[b-1]=1
z=1
h=w=0
MD=10**9+7
for i in range(N*M)[::-1]:
	z*=[h*w-(N*M-1-i),h,w,1][Y[i]*2+X[i]]
	z%=MD
	h+=Y[i]
	w+=X[i]
print(z)


Measured memory_bytes: 18804
A = tuple(map(int,input().split()))

res = A[1]

p = A[0],A[3],A[4]

res += max(sum(v//2 for v in p)*2,
    sum((v-1)//2 for v in p)*2+3 if all(v>0 for v in p) else 0)

print(res)

Measured memory_bytes: 61896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 1e5 + 20, inf = 1e9+1;

int H, W, h, w;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> H >> W >> h >> w;
	if (H % h == 0 && W % w == 0)
		return cout << "No" << endl, 0;
	if (H % h)
	{
		cout << "Yes" << endl;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++)
				if (i % h == 0)
					cout << 1000*(h-1)-1 << ' ';
				else
					cout << -1000 << ' ' ;
			cout << endl;
		}
	}
	else
	{
		cout << "Yes" << endl;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++)
				if (j % w == 0)
					cout << 1000*(w-1)-1 << ' ';
				else
					cout << -1000 << ' ' ;
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1792