akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
int main(){
int n;
int i;
double a,b,c;

scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%lf %lf %lf",&a,&b,&c);
 a=pow(a,2);
 b=pow(b,2);
 c=pow(c,2);

 if( (a+b==c) || (b+c==a) || (a+c==b) ){printf("YES\n");}
 else{printf("NO\n");}

}
return 0;
}

Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
using namespace std;
 
int main(){
  int N;
  cin >> N;
 
  int d[300000];
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
 
  int D=0;
 
  for(int i=0;i<N-1;i++){
    D=max(D,d[i]);
 
    if(D<10){
      cout << "no" << endl;
      return 0;
    }
 
    D-=10;
  }
 
  D=0;
 
  for(int i=N-1;i>0;i--){
    D=max(D,d[i]);
 
    if(D<10){
      cout << "no" << endl;
      return 0;
    }
 
    D-=10;
  }
 
  cout << "yes" << endl;
 
  return 0;
}


Measured memory_bytes: 4260
#!/usr/bin/env python3

def main():
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())
    ok = True
    if (e - a > k):
        ok = False
    print("Yay!" if ok else ":(")

if __name__ == "__main__":
    main()


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

using namespace std;

string s;

main() {
    cin >> s;
    if (s.size() < 4) {
        cout << "No";
        return 0;
    }
    if (s.substr(0, 4) == "YAKI") {
        cout << "Yes";
        return 0;
    }
    cout << "No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

const int MAX_N=101010;
ll inv[MAX_N+1], fact[MAX_N+1], ifact[MAX_N+1];

ll comb(int n, int k){
  if(n<k) return 0;
  return fact[n]*ifact[k]%MOD*ifact[n-k]%MOD;
}

void prepare(){
  inv[1]=fact[0]=fact[1]=ifact[0]=ifact[1]=1LL;
  for(int i=2;i<=MAX_N;i++){
    inv[i]=inv[MOD%i]*(MOD-MOD/i)%MOD;
    fact[i]=fact[i-1]*i%MOD;
    ifact[i]=ifact[i-1]*inv[i]%MOD;
  }
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  prepare();
  int N,K; cin>>N>>K;
  int A[N]; rep(i,N) cin>>A[i];
  sort(A,A+N);
  ll ans=0;
  for(int i=0;i<N;i++){
    if(i<=N-K){
      ans-=A[i]*comb(N-1-i,K-1)%MOD;
      ans+=MOD;
    }
    if(i>=K-1){
      ans+=A[i]*comb(i,K-1)%MOD;
      ans%=MOD;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : abs(a);}
long long lcm(long long a, long long b) {return abs(a / gcd(a, b) * b);}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, X; cin >> n >> X;
  vector<int> x(n);
  for (int i = 0; i < n; i++) cin >> x[i];
  x.push_back(X);
  int d = abs(x[0] - x[1]);
  for (int i = 1; i < n; i++) {
    d = gcd(d, x[i+1] - x[i]);
  }
  cout << d << '\n';
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<#x<<" : "<<x<<'\n';
#define int long long
#define PI 3.141592653589793238

double median(vector<int>&v){
	int n = v.size();
	if(n&1){
		return (double)v[n/2];
	}
	else{
		double ans = (v[(n-1)/2]+v[n/2])/2.0; 
		return ans;
	}
}

int cnt(int n,double l,double h){
	if(n&1){
		int x = h;
		int y = l;
		return x-y+1;
	}
	else{
		double x = (h-l)*2;
		int y = x;
		return y + 1;
	}
}

void solve()
{
	int n; cin>>n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}	
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());

	cout<<cnt(n,median(a),median(b))<<'\n';

}

main()
{
	int t=1;
	while(t--)
		solve();
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, a[max_n];
long long ans;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    sort(a, a + n);
    reverse(a, a + n);
    ans = a[0];
    int pos = 1;
    for (int i = 2; i < n; ++i) {
        ans += a[pos];
        if (i % 2) {
            ++pos;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 4544
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
    	Scanner in = new Scanner(System.in);
      	int l = in.nextInt();
      	int r = in.nextInt();
      	int d = in.nextInt();
      
      	System.out.println(r/d - (l-1)/d);
    }
}

Measured memory_bytes: 35592
from collections import Counter
M=10**7
_,*l=map(int,open(0).read().split())
d=[1]*(M)
C=Counter(sorted(l))
s=0
for a,b in C.items():
    if b != 1:d[a]=0
    elif d[a]:s+=1
    for j in range(a,M,a):d[j]=0
print(s)


Measured memory_bytes: 212048
n,k,q = map(int,input().split())
n_point = [k]*n
A = [int(input()) for x in range(q)]
for i in range(q):
    n_point[A[i]-1]+=1
for i in range(n):
    n_point[i]-=q
for i in range(n): 
    if n_point[i] > 0:
        print('Yes')
    else :
        print('No')

Measured memory_bytes: 11776
// ABC157 C

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

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

    vector<pair<int, int>> p(m);
    
    for(int i=0; i<m; i++){
        cin >> p.at(i).first >> p.at(i).second;
    }
    for(int i=0; i<1000; i++){
        int nx = i/10;
        vector<int> d(1, i%10);
        while(nx){
            d.push_back(nx%10);
            nx /= 10;
        }
        if(d.size() != n)  continue;
        bool check = true;
        reverse(d.begin(), d.end());
        for(int j=0; j<m; j++){
            if(d.at(p.at(j).first-1) != p.at(j).second){
                check = false;
            }
        }
        if(check){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    double ans;
    if (n%2 == 0) cout << 0.5 << endl;
    else {
        ans = (double)(n+1)/2/n;
        printf("%.7f\n", ans);
    }


}

Measured memory_bytes: 256
# coding: UTF-8
# ????????¢?????????????????????????????????????????????????????°????????????????????????????????????
# ????????¢?????????????????????????????¨??????????????????????????§?¨? (W,H) ????????????????????????
# ????????????????????????????????§?¨? (x,y) ??¨?????? r ??§?????????????????????

W, H, x, y, r = map(int, raw_input().split())

if r <= x <= (W-r) and r <= y <= (H-r):
	print "Yes"
else:
	print "No"

Measured memory_bytes: 6416
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    if(k > n){
    k = n;
    }
    vector<int> a;
    for(int i =0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }
    
    vector<int> dp(n);
    dp[0] = 0;
    for(int i =1;i<k;i++){
        int mini = INT_MAX;
        for(int j = 0;j<i;j++){
            mini = min(mini, dp[j] + abs(a[j] - a[i]));
        }
        dp[i] = mini;
    }
    
    for(int i = k;i<a.size();i++){
        int mini = INT_MAX;
        for(int j = i-k;j<i;j++){
            mini = min(mini, dp[j] + abs(a[i] - a[j]));
        }
        dp[i] = mini;
    }
    cout << dp[n-1];
}









Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a, b, c;
	cin >> a >> b >> c;
	cout << min(a*b*(c-(c/2)*2), min(a*c*(b-(b/2)*2), b*c*(a-(a/2)*2))) << endl;
    return 0;
}

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

int min(int a, int b){
	if(a < b)return a;
	return b;
}

int main() {
	int H, N;
	scanf("%d %d", &H, &N);
	int A[N], B[N];
	for(int i = 0;i < N;i++){
		scanf("%d %d", &A[i], &B[i]);
	}
	int dp[H + 1];
	dp[0] = 0;
	for(int i = 1;i <= H;i++){
		dp[i] = INT_MAX;
		for(int j = 0;j < N;j++){
			if(i - A[j] <= 0){
				dp[i] = min(dp[i], B[j]);
			}else{
				dp[i] = min(dp[i], dp[i - A[j]] + B[j]);
			}
		}
	}
	printf("%d\n", dp[H]);
	return 0;
}

Measured memory_bytes: 256
def doit(ary)
  return ary.first if ary.size == 1
  doit( ary.each_cons(2).map {|i, j| (i + j) % 10} )
end

$<.readlines.map {|a| a.chomp.chars.map(&:to_i)}.each do |given|
  puts doit(given)
end


Measured memory_bytes: 6880
a, b = map(int, raw_input().strip().split())

h, w = 100, 100
lines = []

orig_a = a

while a > 50:
    lines.append(list(".#" * 50))
    lines.append(list("#" * 100))
    a -= 50

if a > 1:
    left = ".#" * (a - 1)
    right = "#" * (100 - len(left))
    lines.append(list(left + right))
    lines.append(list("#" * 100))

while len(lines) < 100:
    lines.append(list("." * 100))

if orig_a != 1:
    b -= 1
cl = 99

while b > 49:
    for i in xrange(50):
        lines[cl][2 * i] = "#"
    b -= 50
    cl -= 2

if b > 0:
    for i in xrange(b):
        lines[cl][2 * i] = "#"

print h, w
for line in lines:
    print "".join(line)


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

#define INX(x) (cin >> x)
#define INXV(vec, cnt) for(ll i; i < cnt; i++) INX(vec[i])
#define OUTX(x) (cout << x << endl)
#define OUTXV(vec) for(ll i; i < (ll)vec.size(); i++) OUTX(vec[i])

#define ADD emplace_back
#define MP make_pair

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

    if(T[0] == '?')
    {
        if(T.size() == 1)
        {
            T[0] = 'D';
        }
        else if(T[1] == 'P')
        {
            T[0] = 'D';
        }
        else
        {
            T[0] = 'P';
        }
    }

    for(int i = 1; i < (int)T.size() - 1; i++)
    {
        if(T[i] == '?')
        {
            if(T[i - 1] == 'P')
            {
                T[i] = 'D';
            }
            else if(T[i + 1] == 'P')
            {
                T[i] = 'D';
            }
            else
            {
                T[i] = 'P';
            }
        }
    }

    if(T[T.size() - 1] == '?')
    {
        T[T.size() - 1] = 'D';
    }

    OUTX(T);


    return 0;
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
int main()
{
	//ifstream cin("in.txt");
	//ofstream cout("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n; cin>>n;
	cout<<n*n<<endl;	
}

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


auto solve(long long N, std::vector<long long> a){
    array<long long, 9> c{0};

    for(const auto v :a) {
        int i = 0;
        if(3200LL <= v) i++; 
        if(2800LL <= v) i++; 
        if(2400LL <= v) i++;
        if(2000LL <= v) i++;
        if(1600LL <= v) i++;
        if(1200LL <= v) i++;
        if(800LL  <= v) i++; 
        if(400LL  <= v) i++;
        c[i]++;
    }

    long long acc = 0LL;
    for(int i = 0; i < 8; ++i) {
        if(0 < c[i]) {
            acc++;
        }
    }
    long long minv = max(acc, static_cast<long long >((0LL < c.back())));
    long long maxv = acc + c.back();

    stringstream ss;
    ss << minv << " " << maxv;
    return ss.str();
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    auto result = solve(N, std::move(a));
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=104;
bool vis[N];
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int x,n,t;
int main() {
	scanf("%d%d",&x,&n);
	for (int i=1;i<=n;++i) {
		scanf("%d",&t);
		vis[t]=true;
	}
	for (int d=0;;++d) {
		int ans=-1;
		if (!vis[x-d]) ans=x-d;
		else if (!vis[x+d]) ans=x+d;
		if (~ans) {
			printf("%d\n",ans);
			return 0;
		}
	}
}

Measured memory_bytes: 3824
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(a * b, c);
}


Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func bfs(n int, s int, adj *[]map[int]struct{}) {
	depth := make([]int, n)
	prev := make([]int, n)
	for i := range prev {
		prev[i] = -1
	}
	queue := []int{s}
	for len(queue) > 0 {
		u := queue[0]
		queue = queue[1:]
		for v := range (*adj)[u] {
			if prev[v] != -1 {
				continue
			}
			prev[v] = u
			depth[v] = depth[u] + 1
			if v != n-1 {
				queue = append(queue, v)
				continue
			}
			x, y := u, v
			for depth[x] > depth[v]/2 {
				x, y = prev[x], x
			}
			delete((*adj)[x], y)
			delete((*adj)[y], x)
			return
		}
	}
}

func dfs(s int, prev int, adj []map[int]struct{}) int {
	cnt := 1
	for t := range adj[s] {
		if t == prev {
			continue
		}
		cnt += dfs(t, s, adj)
	}
	return cnt
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1000000001*3)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	adj := make([]map[int]struct{}, n)
	for i := 0; i < n; i++ {
		adj[i] = make(map[int]struct{}, 0)
	}
	for i := 0; i < n-1; i++ {
		a, b := nextInt()-1, nextInt()-1
		adj[a][b] = struct{}{}
		adj[b][a] = struct{}{}
	}

	bfs(n, 0, &adj)
	fennec, snuke := dfs(0, -1, adj), dfs(n-1, -1, adj)
	switch {
	case fennec > snuke:
		fmt.Println("Fennec")
	default:
		fmt.Println("Snuke")
	}
}


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

ll comp(ll a, ll b) {
    if (a > b)
        return comp(b, a);
    if (b%a == 0)
        return (2*b/a - 1)*a;
    return 2*(b/a)*a+comp(b%a, a);
}

int main() {
    ll n, x;
    cin >> n >> x;
    cout << n + comp(x, n-x) << endl;
}

Measured memory_bytes: 256
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    s = input()
    div = 0
    for tmp in s:
        i = int(tmp)
        div += i
        div %= 9
    if div == 0:
        print(yes)
    else:
        print(no)


main()


Measured memory_bytes: 10128
h,w,k=map(int,input().split())
c=[0]*h
for i in range(h):
  c[i]=list(str(input()))
l=h+w
ans=0
M = 2#bit探査をしたい時はM=2
def dfs(A):
    global ans
    # 終端条件 --- l 重ループまで回したら処理して打ち切り
    if len(A) == l:
        b=0
        for i in range(h):
          if A[i]==0:
            continue
          else:
            for j in range(w):
              if A[h:l][j]==1 and c[i][j]=='#':
                b+=1
        if b==k:
          ans+=1
        return
    for v in range(M):
        A.append(v)
        dfs(A)
        A.pop() # これが結構ポイント
dfs([])
print(ans)

Measured memory_bytes: 76312
#include<bits/stdc++.h>
using namespace std;
#define f(i,a,b)  for(int (i)=int(a);i<=int (b);i++)
#define ff(i,a,b) for(int (i)=int (a);i<int (b);i++)
#define F(i,a,b) for(int (i)=int (a);i>=int (b);i--)
#define gcd(a,b) __gcd(a,b)
int main(){
	int k;cin>>k;
long long sum=0;
  f(i,1,k)
    	f(j,1,k)
   	 f(l,1,k){
  		sum+=gcd(l,gcd(j,i));
  	}
  cout<<sum;
}

Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
long long n,ans=0;
long long l[205];
int main()
{
    scanf("%d",&n);n*=2;
    for(int i=1;i<=n;i++)
        scanf("%d",&l[i]);
    sort(l+1,l+n+1);
    for(int i=1;i<=n;i+=2)
        ans+=l[i];
    printf("%d\n",ans);
    return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
    int N;
    cin >> N;
    ll A_sum = 0;
    map<ll, int> count;
    ++count[0];
    ll result = 0;
    REP(_, N) {
        int A;
        cin >> A;
        A_sum += A;
        result += count[A_sum]++;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 12800
// A - Divide a Cuboid
// https://atcoder.jp/contests/agc004/tasks/agc004_a
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007      //10^9+7
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b >> c;
  ans = a * b * c;
  vlli d = {a, b, c};
  SORTR(d);
  if (d[0] % 2 == 0)
  {
    cout << 0 << endl;
  }
  else
  {
    count = ans - d[1] * d[2] * (d[0] / 2);
    ans = count - d[1] * d[2] * (d[0] / 2);
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
def main():
    n, m = [int(x) for x in input().split()]
    s = input()
    c = n
    h = []
    while(True):
    	d = m
    	while d > 0:
    		if c - d >= 0:
    			if s[c - d] == '0':
    				break
    		d -= 1
    
    	if d == 0:
    		print(-1)
    		break
    	
    	c -= d
    	h.append(str(d))
    	if c == 0:
    		h.reverse()
    		print(' '.join(h))
    		break
main()

Measured memory_bytes: 10100
n = int(input())
l = list(map(int, input().split()))

if 0 in l:
    print(0)
    exit()

j = 1
ans = l[0]
while j < n:
    ans = ans * l[j]
    j += 1
    if ans > 10**18:
        print(-1)
        exit()

print(ans)

Measured memory_bytes: 21524
#include <stdio.h>

int main()
{
    long long N, A, B;
    scanf("%lld%lld%lld", &N, &A, &B);
    long long count1 = N / (A + B) * A;
    long long count2 = N % (A + B);
    if(count2<=A) printf("%lld",count1+count2);
    else printf("%lld",count1+A);


    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath> 
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
int n;
int main()
{
	double r;
	cin>>r;
	cout<<2*r*PI<<endl;
	return 0;
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	string s; cin >> s;
	cout << string(s.size(), 'x') << endl;
	
	return 0;
}

Measured memory_bytes: 256
package main

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

const INF = 1000000000

func main() {
  input := Input{bufio.NewReaderSize(os.Stdin,100)}
  n,m,p := input.NextInts()
  raw := NewEdges(m)
  gn := make([][]int,n)
  gr := make([][]int,n)
  for i:=0;i<m;i++ {
    a,b,c := input.NextInts()
    a,b,c = a-1,b-1,p-c
    raw[i] = Edge{a,b,c}
    gn[a] = append(gn[a],b)
    gr[b] = append(gr[b],a)
  }
  okn := reachable(gn,0)
  okr := reachable(gr,n-1)
  es := NewEdges(0)
  for i:=0;i<m;i++ {
    if okn[raw[i].fm] && okr[raw[i].fm] &&
    okn[raw[i].to] && okr[raw[i].to] { es = append(es,raw[i]) }
  }
  ans := es.BellmanFord(0,n-1)
  if ans == -INF {
    fmt.Println(-1)
  } else {
    ans = -ans
    if ans < 0 { ans = 0 }
    fmt.Println(ans)
  }
}

func reachable(g [][]int,start int) []bool {
  n := len(g)
  ok := make([]bool,n)
  var dfs func(int)
  dfs = func(v int) {
    ok[v] = true
    for _,u := range g[v] {
      if !ok[u] { dfs(u) }
    }
  }
  dfs(start)
  return ok
}

type Edge struct { fm,to,cost int }
type Edges []Edge
func NewEdges(n int) Edges { return make([]Edge,n) }
func(es Edges) BellmanFord(start int,end int) int {
  n := 0
  for i:=0;i<len(es);i++ {
    if n < es[i].fm+1 { n = es[i].fm+1 }
    if n < es[i].to+1 { n = es[i].to+1 }
  }
  c := make([]int,n)
  for i:=0;i<n;i++ { c[i] = INF }
  c[start] = 0
  updated := true
  step := 0
  for updated {
    updated = false
    for i:=0;i<len(es);i++ {
      if c[es[i].to] > c[es[i].fm]+es[i].cost {
        c[es[i].to] = c[es[i].fm]+es[i].cost
        updated = true
      }
    }
    step++
    if step > n { return -INF }
  }
  return c[end]
}

type Input struct { reader *bufio.Reader }
func(i *Input) NextLine() string {
  var buffer []byte
  for {
    line,isPrefix,err := i.reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func(i *Input) NextInts() (int,int,int) {
  s := strings.Fields(i.NextLine())
  x,_ := strconv.Atoi(s[0])
  y,_ := strconv.Atoi(s[1])
  z,_ := strconv.Atoi(s[2])
  return x,y,z
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;   
#define ll long long
#define ull unsigned long long
// #define ordered_set tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> 
ll mod=1e9+7;
#define PI 3.1415926535897932385
#define inf 9e18
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
typedef pair<long long, long long> ii;
#define S second
#define F first
ll max(ll a,ll b){if(a>b){return a;}return b;}
ll min(ll a,ll b){if(a<b){return a;}return b;}
#define MAXN 200005
// Comment this out for interactice problem
// #define endl '\n'
// string to integer stoi() Remember: it takes string not character
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
// To compile--> g++ -std=c++0x -o output one.cpp
// To run--> ./output

int main()
{ 
    fastio;
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
    }
    ll dp[k+1];
    for (int j = 0; j < k+1; ++j)
    {
        dp[j]=1;
    }

    for (int i = 0; i < k+1; ++i)
    {
        ll fg=0;
        for (int j = 0; j < n; ++j)
        {
            if((i-a[j])>=0){
                if(dp[i-a[j]]==1){
                    fg=1;
                    break;
                }
            }
        }
        if(fg==1){
            dp[i]=2;
        }
    }

    if(dp[k]==1){
        cout<<"Second";
    }
    else{
        cout<<"First";
    }

    return 0;
}


Measured memory_bytes: 4452
tailrec fun calc(h: Long, cur: Long = 0L): Long = if (h == 1L)
        (1..cur).fold(1L) { acc, v -> acc * 2 + 1 }
    else
        calc(h / 2, cur + 1)

fun main(args: Array<String>) {
    calc(readLong()).let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 33692
def solve(string):
    flag, *ab = map(int, string.split())
    return str(sum(ab)) if flag - 1 else "Hello World"


if __name__ == '__main__':
    flag = int(input())
    if flag - 1:
        flag = "{}\n".format(flag) + "\n".join([input(), input()])
    print(solve(str(flag)))


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int n;
    ll cost[310][310];
    vector<pair<int, P>> v;

    cin >> n;
    REP(i, n)
    REP(j, n)
    {
        int a;
        cin >> a;

        v.push_back(make_pair(a, make_pair(i + 1, j + 1)));

        cost[i + 1][j + 1] = INF;
    }

    SORT(v);

    for (int i = 1; i <= n; i++)
        cost[i][i] = 0;

    ll res = 0;

    for (auto p : v)
    {

        if (cost[p.second.first][p.second.second] == p.first)
            continue;

        if (cost[p.second.first][p.second.second] < p.first)
        {
            res = -1;
            break;
        }

        cost[p.second.first][p.second.second] = p.first;
        cost[p.second.second][p.second.first] = p.first;

        for (int i = 1; i <= n; i++)
        {
            cost[p.second.first][i] = min(cost[p.second.first][i], cost[i][p.second.second] + p.first);
            cost[i][p.second.first] = min(cost[i][p.second.first], cost[i][p.second.second] + p.first);
        }

        for (int i = 1; i <= n; i++)
        {
            cost[p.second.second][i] = min(cost[p.second.second][i], cost[i][p.second.first] + p.first);
            cost[i][p.second.second] = min(cost[i][p.second.second], cost[i][p.second.first] + p.first);
        }

        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
            {
                cost[i][j] = min(cost[i][j], cost[i][p.second.second] + cost[j][p.second.first] + p.first);
                cost[i][j] = min(cost[i][j], cost[j][p.second.second] + cost[i][p.second.first] + p.first);
                cost[j][i] = min(cost[j][i], cost[i][p.second.second] + cost[j][p.second.first] + p.first);
                cost[j][i] = min(cost[j][i], cost[j][p.second.second] + cost[i][p.second.first] + p.first);
            }

        res += p.first;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 2424
#include <stdio.h>

int main(void)
{
  int i, j, k, n = 0, ch = 0;
  char kai[100];
  
  scanf("%s" , kai);
  
  for( i = 0; kai[i] != '\0'; i++ ){
    n++;
  }
  //printf("%d\n", n);
  
  for( i = 0; i < n/2; i++ ){
    if( kai[i] != kai[n-i-1] ){
      printf("No\n");
  		return 0;
    }
  }
  
  for( i = 0; i < n/4; i++ ){
    if( kai[i] != kai[n/2 -i-1] ){
      printf("No\n");
  		return 0;
    }
  }
  
  for( i = n/2; i < n/4; i++ ){
    if( kai[i] != kai[n-i-1] ){
      printf("No\n");
  		return 0;
    }
  }
  
  printf("Yes\n");
  return 0;
}

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

using namespace std;
#define LL long long 

int main(){
    int r,g,b;
    LL ans = 0;
    cin >> r >> g >> b;
    int tmp = 100 * r + 10 * g + b;
    if(tmp % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  cout << fixed << setprecision(7) << (double)((n + 1) / 2) / n << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 28;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};


int main() {
    int n, m, a, b, c;
    cin >> n >> m;
    int dist[n][n], edges[n][n];
    fill_n(dist[0], n*n, INF);
    fill_n(edges[0], n*n, INF);
    for(int i=1;i<=m;++i) {
        cin >> a >> b >> c;
        --a; --b;
        dist[a][b] = min(dist[a][b], c);
        dist[b][a] = min(dist[b][a], c);
        edges[a][b] = c;
    }

    for(int k=0;k<n;++k) {
        for(int i=0;i<n;++i) {
            for(int j=0;j<n;++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    for(int i=0;i<n;++i) {
        for(int j=0;j<n;++j) {
            if(edges[i][j] == INF) continue;
            if(edges[i][j] > dist[i][j]) ++ans;
        }
    }

    cout << ans << endl;

}

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

using namespace std;

#define pan(i,n) for(int i=0;i<n;i++)
#define pans(i,n,a) for(int i=a;i<n;i++)
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define INF 1000000007
#define PI 3.141592653
#define inf 100007
#define pll pair<ll,ll>
#define pii pair<int,int>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

int main(){
    int n;
    cin>>n;
    vl dp(n+1,inf),a(n+1,inf);
    ll ans=0;
    pans(i,n+1,1) cin>>a[i];
    dp[0]=0,dp[1]=0;
    pans(i,n+1,2){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n];
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
inline bool I(int iNum,int iLBound,int iUBound){
    int iSum=0;
    while(iNum){
        iSum+=iNum %10;
        iNum/=10;
    }
    return(iLBound<=iSum &&iSum<=iUBound);
}
int main(){
    ios::sync_with_stdio(false);
    int ie,il,iu;
    cin>>ie>>il>>iu;
    register int i;
    register long long isum=0;
    for(i=1;i<=ie;++i){
        if(I(i,il,iu))isum+=i;
    }
    cout<<isum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int R;
    cin >> R;
    cout << std::setprecision(10) << R * 2*3.1415926535 << endl;
}

Measured memory_bytes: 3772
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vint v(n), p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    iota(v.begin(), v.end(), 1);
    int count=0, a,b;
    do {
        count++;
        bool p_flag=1, q_flag=1;
        rep(i,n){
            if(v[i] != p[i]) p_flag = 0;
            if(v[i] != q[i]) q_flag = 0;
        }
        if(p_flag) a=count;
        if(q_flag) b=count;
    } while ( next_permutation(v.begin(), v.end()) );
    cout << abs(a-b) << endl;
}


Measured memory_bytes: 256
n = int(input())
arr = list(map(int, input().split())) #i_1 i_2を取得し、iに値を入れる

pure_arr = []
for i in range(n):
    pure_arr.append(i+1)
count=0
for (num, value) in zip(pure_arr, arr):
    if num!=value:
        count += 1

if count<=2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b;cin>>a>>b;
  if(b%a){
    cout << b-a << endl;
  }else{
    cout << a+b << endl;
  }
}


Measured memory_bytes: 256
//
// Created by yijiezhu on 12/21/16.
//
#include <iostream>
#include <queue>
#include <set>
#include <map>

using namespace std;

int delta[] {-1, 1, -4, 4};
map<int, int> dp;

void bfs(int origin) {
    queue<int> que;
    que.push(origin);
    dp.insert(make_pair(origin, 0));

    while (!que.empty()) {
        int v = que.front(); que.pop();
        int z(0);
        for (int i = 1; i < 8; i++) {
            if ((v >> (i << 2) & 0xF) == 0) z = i;
        }
        for (int q = 0; q < 4; q++) {
            if (z == 4 && delta[q] == -1) continue;
            if (z == 3 && delta[q] == 1) continue;
            int nz = z + delta[q];
            if (nz < 0 || nz >= 8) continue;
            int nk = 0;
            for (int j = 0; j < 8; j++) {
                int t = v >> (j << 2) & 0xF;
                if      (j == z)  nk |= t << (nz << 2);
                else if (j == nz) nk |= t << (z << 2);
                else              nk |= t << (j << 2);
            }
            if (dp.find(nk) == dp.end()) {
                que.push(nk);
                dp[nk] = dp[v] + 1;
            }
        }
    }
}

void print(int k) {
    for (int i = 0; i < 8; i++) {
        cout << (k >> (i << 2) & 0xF);
    }
}

int main() {
    // freopen("wa.out", "w", stdout);
    int origin = 0;
    for (int i = 0; i < 8; i++) {
        origin |= i << (i << 2);
    }
    bfs(origin);
    /*for (auto p : dp) {
        print(p.first); cout << " " << p.second << endl;
    }*/
    int k = 0;
    while (~scanf("%d", &k)) {
        for (int i = 1; i < 8; i++) {
            int t;
            scanf("%d", &t);
            k |= t << (i << 2);
        }
        cout << dp[k] << endl;
        k = 0;
    }
}

Measured memory_bytes: 4140
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	while(n--){
		int num[8];
		for(int i=0; i<8; i++){scanf("%1d",&num[i]);}
		sort(num,num+8);
		int x=num[0]*1+num[1]*10+num[2]*100+num[3]*1000+num[4]*10000+num[5]*100000+num[6]*1000000+num[7]*10000000;
		int y=num[7]*1+num[6]*10+num[5]*100+num[4]*1000+num[3]*10000+num[2]*100000+num[1]*1000000+num[0]*10000000;
		printf("%d\n",x-y);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
long long a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    long long x=max(a*c,a*d);
    long long y=max(b*c,b*d);
    cout<<max(x,y)<<endl;
    return 0;
}

Measured memory_bytes: 3628
data = [
        [
            [
                0 for r in range(10)
            ] for f in range(3)
        ] for b in range(4)
]

n = int(input())

for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v


for b in range(4):
    for f in range(3):
        for r in range(10):
            print('', data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)

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

#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(c) (c).begin(),(c).end()

using namespace std;
typedef long long ll;

bool is_uruu(ll y)
{
  return (y%4==0&&y%100!=0)||(y%400==0);
}

ll fairfield(ll y,ll m,ll d) {
  if(m<=2) y--,m+=12;
  ll t= 365LL*(y%7)+y/4-y/100+y/400+153*(m+1)/5+d-428;
  while(t<=0) t+=7;
  return t;
}
ll ans=0;
ll cnt=688;

ll func(ll y1,ll m1,ll d1,ll y2,ll m2,ll d2) {
  ll dd[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  ll c=0;
  for(ll y = y1;y <= y2; y++) {
    ll m_st = 1, m_end=12;
    if(y == y1) 
      m_st = m1;
    if(y == y2) 
      m_end = m2;
    for(ll m = m_st; m <= m_end; m++) {
      ll d_st = 1, d_end = dd[m];
      if(m == 2 && is_uruu(y)) 
        d_end++;
      if(y == y1 && m == m1) 
        d_st = d1;
      if(y == y2 && m == m2) 
        d_end = d2;
      for(ll d = d_st; d <= d_end; d++) {
        if(d == 13 && fairfield(y,m,d) % 7 == 5) c++;
      }
    }
  }
  return c;
}

int main()
{
  ll y1,m1,d1;
  ll y2,m2,d2;

	cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2;
	ll y_fir, y_sec;
	y_fir = y1 + 400L - (y1 % 400L);
	y_sec = y2 - y2 % 400L;
  if(y_fir >= y2)
    cout << func(y1, m1, d1, y2, m2, d2) << endl;
  else
    cout <<	func(y1, m1, d1, y_fir-1, 12, 31) + func(y_sec, 1, 1, y2, m2, d2) + (y_sec - y_fir)/400 * func(400, 1, 1, 799, 12, 31) << endl;
}


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

#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define PI 3.14159265358979
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

vector<pair<int,ll>> vec[100000];
ll cost[100000];
void dfs(int now,ll COST){
    cost[now]=COST;
    int next;
    REP(i,vec[now].size()){
        next=vec[now][i].first;
        if(cost[next]<0){
            dfs(next,COST+vec[now][i].second);
        }
    }
}
int counter(int x){
    if(!x)return 0;
    return counter(x>>1)+(x&1);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;cin>>S;
    string w[3]={"Sunny", "Cloudy", "Rainy"};
    REP(i,3){
        if(S==w[i]){
            cout<<w[(i+1)%3]<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

string S[10], T[10];
int main()
{
	int H, W, K;
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	int ans = 0;
	for (int bi = 0; bi < (1 << H); bi++) {
		for (int bj = 0; bj < (1 << W); bj++) {
			int tmpi = bi;
			int tmpj = bj;
			for (int i = 0; i < H; i++) T[i] = S[i];
			for (int i = 0; i < H; i++) {
				if (tmpi % 2 == 1) {
					for (int j = 0; j < W; j++) {
						T[i][j] = '?';
					}
				}
				tmpi /= 2;
			}
			for (int i = 0; i < W; i++) {
				if (tmpj % 2 == 1) {
					for (int j = 0; j < H; j++) {
						T[j][i] = '?';
					}
				}
				tmpj /= 2;
			}
			int cnt = 0;
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if (T[i][j] == '#') cnt++;
				}
			}
			if (cnt == K) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, A, B, C; cin >> N >> A >> B >> C;
    int c[N];
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        if(s == "AB") c[i] = 0;
        else if(s == "AC") c[i] = 1;
        else c[i] = 2;
    }

    vector<char> x(N);
    for (int i = 0; i < N; i++)
    {
        if(c[i] == 0) {
            if(A == 1 && B == 1 && C == 0) {
                if (c[i+1] == 1) {
                    A++; B--;
                    x[i] = 'A';
                }
                else {
                    A--; B++;
                    x[i] = 'B';
                }
            }
            else if(A == 0 && B == 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(A > B) {
                    A--; B++;
                    x[i] = 'B';
                }
                else {
                    A++; B--;
                    x[i] = 'A';
                }
            }
        }
        else if(c[i] == 1) {
            if(A == 1 && B == 0 && C == 1) {
                if (c[i+1] == 0) {
                    A++; C--;
                    x[i] = 'A';
                }
                else {
                    A--; C++;
                    x[i] = 'C';
                }
            }
            else if(A == 0 && C == 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(A > C) {
                    A--; C++;
                    x[i] = 'C';
                }
                else {
                    A++; C--;
                    x[i] = 'A';
                }
            }
        }
        else {
            if(A == 0 && B == 1 && C == 1) {
                if (c[i+1] == 0) {
                    B++; C--;
                    x[i] = 'B';
                }
                else {
                    B--; C++;
                    x[i] = 'C';
                }
            }
            else if(C == 0 && B == 0) {
                cout << "No" << endl;
                return 0;
            }
            else {
                if(B > C) {
                    B--; C++;
                    x[i] = 'C';
                }
                else {
                    B++; C--;
                    x[i] = 'B';
                }
            }
        }
    }

    cout << "Yes" << endl;
    for (int i = 0; i < N; i++)
    {
        cout << x[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
using namespace std;
string s[3], ss;
int main(){
    cin>>ss;
    s[0]="Sunny";s[1]="Cloudy";s[2]="Rainy";
    for (int i=0;i<3;++i){
        if(ss==s[i]){
            cout<<s[(i+1)%3]<<"\n";
        }
    }
    return 0;
}


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

using namespace std;

int main()
{

    int d,n;
    cin>>n;
    if(n%2==0)
        d=n/2;
    else
        d=(n/2)+1;
    double p;
    p=(double)d/(double)n;
    //cout<<p;
    cout.precision(10);
    cout<<fixed<<p<<endl;
    return 0;
}


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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int nDividend)
{
  int nDgtCnt = 1;

  while (nDividend /= 10)
    nDgtCnt++;

  return nDgtCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nDivisor = sqrt(nNum);

  while (nNum % nDivisor)
    nDivisor--;

  int nDividend = nNum / nDivisor;
  return fnDigitsCheck(nDividend);  
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

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

int n, m;
bool used[5000];
vector<int> e[5000];
int num = 0;
int ans[5000];

void dfs(int x){
	for(int i = 0; i < e[x].size(); i++){
		if(used[e[x][i]]) continue;
		used[e[x][i]] = true;
		dfs(e[x][i]);
	}
	ans[num] = x;
	num++;
}

int main(){
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--; b--;
		e[b].push_back(a);
	}
	for(int i = 0; i < n; i++){
		if(!used[i]){
			used[i] = true;
			dfs(i);
		}
	}
	for(int i = 0; i < n; i++) printf("%d\n", ans[i]+1);
	for(int i = 1; i < n; i++){
		bool ok = false;
		for(int j = 0; j < e[ans[i]].size(); j++){
			if(e[ans[i]][j] == ans[i-1]){
				ok = true;
				break;
			}
		}
		if(!ok){
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
}

Measured memory_bytes: 1776