akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <queue>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
ll intpow(int n,int m){
    if(m==0)return 1;
    return n*intpow(n,m-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main() {
    int h,w;cin>>h>>w;
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h){
        rep(j,w)cin>>s[i][j];
    }
    /////dif of dir///
    int dx[4]={1,0,-1,0};
    int dy[4]={0,1,0,-1};

    // BFS のためのデータ構造
    queue<pair<int,int>> que;
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#')continue;
            vector<vector<int>> dist(h, vector<int>(w,-1)); // 全頂点を「未訪問」に初期化
            dist[i][j]=0;
            que.push(make_pair(i,j));
    while (!que.empty()) {
        pair<int,int> v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        int y=v.first;
        int x=v.second;
        // v から辿れる頂点をすべて調べる
        rep(dir,4) {
            int nx=x+dx[dir];
            int ny=y+dy[dir];
            if(nx<0||nx>=w||ny<0||ny>=h)continue;
            if(s[ny][nx]=='#')continue;
            if(dist[ny][nx]!=-1)continue;
            dist[ny][nx]=dist[y][x]+1;
            que.push(make_pair(ny,nx));
            ans=max(ans,dist[ny][nx]);
        }
            }
        }
    }
cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
   Push yourself, because no one else is going to do it for you.
*/
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define set_zero(a) memset(a,0,sizeof(a));
#define ll long long int
#define PI 2 * acos(0.0)
#define MAX 10000000000000000
#define in(a) scanf("%d",&a);
#define out(a) printf("%d",a);
#define INF 1000000 
#define M 1000000007
using namespace std;
bool comp(ll a, ll b) 
{ 
    return (a < b); 
} 
int main(){ 
   fast_io
   ll n;
   cin>>n;
   bool ok = false;
   for(ll i = 1;i<=9;i++){
      if(n%i == 0){
         ll y = n/i;
         if(y <= 9 && y >= 1){
            ok = true;
            break;
         }
      }
   }
   if(ok == true) cout<<"Yes";
   else cout<<"No";
   return 0; 
}  

Measured memory_bytes: 3644
// ------------------------------------
// Date:2018/ 3/20
// Problem:Ice Tea Store a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") <<　endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const ll LINF = 1e18 + 7;
static const int INF = 1e9 + 1;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LCIN(Q, H, S, D, N);
  ll pQ, pH;
  pQ = Q * 4;
  pH = H * 2;
  ll ans = LINF;
  if (!(N & 1)) {
    // Nが2で割り切れるとき
    ans = min(ans, min(min(min(pQ, pH), S) * N, D * N / 2));
  } else {
    ll tmp = (N / 2) * D; 
    ans = min(min(ans, min(min(pQ, pH), S) * N) , tmp + min(ans, min(min(pQ, pH), S)));
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
K = int(input())

history = {}
tmp = 0
for i in range(1, K + 2):
    tmp = (tmp * 10 + 7) % K
    key = str(tmp)
    if tmp == 0:
        ans = i
        break
    elif history.setdefault(key, False) == True:
        ans = -1
        break
    else:
        history[key] = True
        continue

print(ans)


Measured memory_bytes: 223008
import sys
input = sys.stdin.readline
import fractions

x = int(input())
def isPrime(x):
    for p in range(2, int(x**0.5)+1):
        if x % p == 0:
            return False
    return True
while 1:
    if isPrime(x)==True:
        print(x)
        exit()
    else:
        x += 1


Measured memory_bytes: 5688
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())
l = [int(i) for i in input().split()]
l.sort()

lset = set(l)

if len(lset) == 1:
    if l[0] == 0:
        print("Yes")
    else:
        print("No")

elif N%3 == 0:
    if len(lset) == 2:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[1] and l[int(N/3)] == k[1] and l[int(N/3 - 1)] == 0:
            print("Yes")
        else:
            print("No")
    
    elif len(lset) == 3:
        k = list(lset)
        k.sort()
        if k[0]^k[1] == k[2] or k[0]^k[2] == k[1]:
            c0 = 0
            c1 = 0
            for i in l:
                if i == k[0]:
                    c0 += 1
                elif i == k[1]:
                    c1 += 1
            if c0 == N/3 and c1 == N/3:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
    
else:
    print("No")


Measured memory_bytes: 14212
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1024)

func readLine() string {
	buf := make([]byte, 0, 1024)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func atoi(s string) int {
	i, e := strconv.Atoi(s)
	if e != nil {
		panic(e)
	}
	return i
}

func readStringArray() []string {
	return strings.Split(strings.TrimSpace(readLine()), " ")
}

func readInt() int {
	return atoi(readLine())
}

func readIntArray() []int {
	var a []int
	sa := readStringArray()
	for _, s := range sa {
		a = append(a, atoi(s))
	}
	return a
}

func main() {
	N := readInt()
	S := readLine()

	if N%2 != 0 {
		fmt.Println("No")
		os.Exit(0)
	}
	if S[0:N/2] == S[N/2:N] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	static boolean [] changed;
	static boolean end = false;
	static int array[];
	static String ans = "Yes";
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		changed = new boolean[n];
		array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
			changed[i] = false;
			}
		while(!end){
			end = solved(n);
		}
		System.out.println(ans);
		
	}
	
	public static boolean solved(int n) {
		boolean check = true;
		for (int i = 0; i < n-1; i++) {
			if(array[i]>array[i+1]){
				check = false;
				if(changed[i]){
					ans = "No";
					return true;
				}else{
					array[i] = array[i]-1;
					changed[i] = true;
				}
			}
		}
		return check;
	}
}


Measured memory_bytes: 52104
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    A2IN(ll, L, ll, R, N);
    vector<vii> A(2, vii(N));
    REP(i, N)
    {
        A[0][i] = {L[i], i};
        A[1][i] = {R[i], i};
    }
    RSORT(A[0]);
    SORT(A[1]);
    auto f = [&](ll l) {
        vector<bool> used(N);
        ll s = 0;
        ll p = 0;
        vi i(2);
        REP(k, N)
        {
            ll j = (k + l) & 1;
            while (used[A[j][i[j]].second])
            {
                ++i[j];
            }
            used[A[j][i[j]].second] = true;
            if (p < L[A[j][i[j]].second] or p > R[A[j][i[j]].second])
            {
                s += abs(p - A[j][i[j]].first);
                p = A[j][i[j]].first;
            }
        }
        s += abs(p);
        return s;
    };
    ll ans = max(f(0), f(1));
    OUT(ans);
}

Measured memory_bytes: 9564
import java.util.Scanner;

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

        int tHp = sc.nextInt();
        int tAtk = sc.nextInt();
        int aHP = sc.nextInt();
        int aAtk = sc.nextInt();
        boolean Tattack = true;

        while (tHp > 0 && aHP > 0) {
            if (Tattack) {
                aHP -= tAtk;
                Tattack = false;
            } else {
                tHp -= aAtk;
                Tattack = true;
            }
        }
        if (tHp > 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

auto chmin = [](auto&& a, auto b) { return b < a ? a = b, 1 : 0; };

struct edge {
  int from, to;
  string label;
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m, s, t;
  while (cin >> n >> m >> s >> t, n) {
    vector<edge> edges(m);
    for (auto&& e : edges) {
      cin >> e.from >> e.to >> e.label;
    }
    vector<int> d(n, n);
    d[s] = 0;
    for (int _ = n; _--; ) {
      for (auto&& e : edges) {
        chmin(d[e.to], d[e.from] + 1);
      }
    }
    if (d[t] == n) {
      cout << "NO\n";
      continue;
    }
    vector<string> dp(n, "~");
    dp[t] = "";
    for (int _ = n; _--; ) {
      for (auto&& e : edges) {
        if (max(d[e.from], d[e.to]) == n) continue;
        if (dp[e.to] == "~") continue;
        chmin(dp[e.from], e.label + dp[e.to]);
      }
    }
    if (dp[s].find('~') != string::npos) {
      cout << "NO\n";
      continue;
    }
    auto a = dp[s];
    for (int _ = n * n; _--; ) {
      for (auto&& e : edges) {
        if (max(d[e.from], d[e.to]) == n) continue;
        if (dp[e.to] == "~") continue;
        chmin(dp[e.from], e.label + dp[e.to]);
      }
    }
    if (dp[s] == a) {
      cout << dp[s] << '\n';
    } else {
      cout << "NO\n";
    }
  }
}



Measured memory_bytes: 6252
import sys

#a=0 b=1 ...
def chr2idx(c):
    return ord(c)-ord("a")
def idx2chr(x):
    return chr(ord("a")+x)

N=int(input())
ar=[["a","a"]]
if N==1:
    print("a")
    sys.exit()

for i in range(N-1):
    new_ar=[]
    L=len(ar)
    for j in range(L):
        lastchr=chr2idx(ar[j][1])
        for k in range(lastchr+1):
            new_ar+=[[ar[j][0]+idx2chr(k),idx2chr(lastchr)]]
        new_ar+=[[ar[j][0]+idx2chr(lastchr+1),idx2chr(lastchr+1)]]

    ar=new_ar[:]

L=len(ar)
for i in range(L):
    print(ar[i][0])

Measured memory_bytes: 26572
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
h, w = map(int, input().split())
c = [[j for j in input()] for i in range(h)]
# print(c)
ans = [["" for j in range(w)] for i in range(2 * h)]
for i in range(2 * h):
    for j in range(w):
        # print((i + 1) // 2)
        ans[i][j] = c[i // 2][j]
for i in range(2 * h):
    for j in range(w):
        print(ans[i][j], end="")
    print()

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0;i<4;i++){
        if(s[i] == '+'){
            ans += 1;
        }
        else{
            ans -= 1;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    ll n,d;
    cin >> n >>d;
    ll ans = 0;
    rep(i,n) {
        ll x,y;
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }
    cout << ans << endl;
}


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

int main(){
  int64_t L, R;
  cin >> L >> R;
  int64_t Ans=2019;
  for(int64_t i=L; i<min(R, L+2019); i++){
    for(int64_t j=i+1; j<=min(R, i+2019); j++){
      Ans=min(Ans, (i*j)%2019);
    }
  }
  cout << Ans << endl;
}

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

using vi = std::vector<int64_t>;
using vvi = std::vector<vi>;
struct N { int64_t w; int64_t v; };
using vN = std::vector<N>;

int main() {
    int n; int64_t w; std::cin >> n >> w;
    vN items(n);
    for (auto &u : items) std::cin >> u.w >> u.v;

    auto w1 = items.front().w;
    vvi k(4, {0}); // will contain summed values for selecting n items of weight w1 + x (0..3)
    for (const auto &u : items) k[u.w - w1].push_back(u.v);
    for (auto &u : k) std::sort(next(u.begin()), u.end(), std::greater<int64_t>());
    for (auto &u : k) for (auto it = next(u.begin()); it != u.end(); ++it) *it += *prev(it);
    int64_t vmax = 0;
    for (int i0 = 0; i0 < k[0].size(); i0++) {
        for (int i1 = 0; i1 < k[1].size(); i1++) {
            for (int i2 = 0; i2 < k[2].size(); i2++) {
                for (int i3 = 0; i3 < k[3].size(); i3++) {
                    auto wsum = i0 * (w1 + 0) + i1 * (w1 + 1) + i2 * (w1 + 2) + i3 * (w1 + 3);
                    if (wsum <= w) {
                        auto vsum = k[0][i0] + k[1][i1] + k[2][i2] + k[3][i3];
                        vmax = std::max(vmax, vsum);
                    }
                }
            }
        }
    }
    std::cout << vmax << std::endl;
}



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

using std::cin;
using std::cout;
// using namespace atcoder;
typedef long long ll;

#ifdef _DEBUG
#define DEBUG(x) cout << #x << ": " << x << endl;
#else
#define DEBUG(x)
#endif

#define ALL(obj) (obj).begin(), (obj).end()
#define BIT(n) (1LL << (n))

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

ll mod_pow(ll x, ll n)
{
    ll ret = 1;
    while (n > 0)
    {
        if (n & 1)
            (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    // write code below
    int n;
    cin >> n;
    ll res;
    res = mod_pow(10, n) - 2 * mod_pow(9, n) + mod_pow(8, n);
    res = res % MOD;
    if (res < 0)
    {
        res += MOD;
    }
    cout << res << std::endl;

    // write code above
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<stack>
#include<queue>

using namespace std;

int main() {
	vector<int> vec;
	stack<int> sta;
	queue<int> que;
	int n;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		vec.push_back(t);
	}
	
	if (n % 2 == 0) {
		sta.push(vec[1]);
		for (int i = 1; i < vec.size() / 2; i++) sta.push(vec[i * 2 + 1]);
		for (int i = 0; i < n / 2; i++) {
			cout << sta.top() << ' ';
			sta.pop();
		}
		for (int i = 0; i < vec.size(); i += 2)cout << vec[i] << ' ';
		cout << endl;
	}

	else {
		sta.push(vec[0]);
		for (int i = 1; i < vec.size() / 2+1; i++) sta.push(vec[i * 2]);
		for (int i = 0; i < n / 2+1; i++) {
			cout << sta.top() << ' ';
			sta.pop();
		}
		for (int i = 1; i < vec.size(); i += 2)cout << vec[i] << ' ';
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3320
///not today

#include<bits/stdc++.h>
using namespace std;

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

const int mod = 1000* 1000* 1000 + 7, maxn = 55;
int dp[maxn];

int32_t main(){
    int n;
    string s1, s2;
    cin >>n >>s1 >>s2;
    int pt = 0;
    if(s1[0] == s2[0]){
        dp[0] = 3;
        pt ++;
    }
    else{
        dp[0] = 6;
        dp[1] = 6;
        pt += 2;
    }
    while(pt < n){
        if(s1[pt - 1] == s2[pt - 1]){
            if(s1[pt] == s2[pt]){
                dp[pt] = (dp[pt - 1]* 2)% mod;
                pt ++;
            }
            else{
                dp[pt] = (dp[pt - 1]* 2)% mod;
                dp[pt + 1] = dp[pt];
                pt += 2;
            }
        }
        else{
            if(s1[pt] ==  s2[pt]){
                dp[pt] = dp[pt - 1];
                pt ++;
            }
            else{
                dp[pt] = (dp[pt - 1]* 3)% mod;
                dp[pt + 1] = dp[pt];
                pt += 2;
            }
        }
    }
    cout <<dp[pt - 1] <<endl;
    return false;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
ll mod=1e9+7;

struct perm {
private:
	int sz;
	vector<long long> p, invp;
public:
	perm(int n) {
		sz = n + 1;
		p.resize(sz), invp.resize(sz);
		p[0] = 1;
		for(int i=1;i<=sz - 1;i++) {
			p[i] = p[i - 1] * i%mod;
		}
		invp[sz - 1] = 1;
		ll cop = mod - 2, x = p[sz - 1];
		while (cop) {
			if (cop % 2)invp[sz - 1] = invp[sz - 1] * x%mod;
			cop >>= 1; x = x * x % mod;
		}
		for(int i=sz-2;i>=0;i--) {
			invp[i] = invp[i + 1] * (i + 1) % mod;
		}
	}
	ll comb(ll x, ll y) {
		if (x < y || y < 0)return 0;
		ll ret = p[x];
		(ret *= invp[y]) %= mod;
		(ret *= invp[x - y]) %= mod;
		return ret;
	}
	ll combP(ll x, ll y) {
		if (x < y || y < 0)return 0;
		return p[x] * invp[x - y] % mod;
	}
};
perm p(1 << 18);

void solve(){
	ll n,m,k; cin >>n>>m>>k;
	ll ans=0;
	for(int i=1;i<=n-1;i++){
		ll num=m*m%mod*(n-i)%mod;
		ll score=num*i%mod*p.comb(n*m-2,k-2)%mod;
		ans+=score;
		ans%=mod;
	}
	swap(n,m);
	for(int i=1;i<=n-1;i++){
		ll num=m*m%mod*(n-i)%mod;
		ll score=num*i%mod*p.comb(n*m-2,k-2)%mod;
		ans+=score;
		ans%=mod;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n;
	ll l0 = 2, l1 = 1;
	ll l;
	cin >> n;
	if (n == 1) {
		cout << "1" << endl;
		return 0;
	}
	else {
		for (int i = 2; i <= n; i++) {
			l = l0 + l1;
			l0 = l1;
			l1 = l;
		}
	}
	cout << l << endl;
	return 0;
}



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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

    vector<int> t(N+1),x(N+1),y(N+1);
    rep(i,1,N+1) cin >> t[i] >> x[i] >> y[i];

    rep(i,0,N){
        if(t[i+1]-t[i]<abs(x[i+1]-x[i])+abs(y[i+1]-y[i])){
            print("A");
            cout << "No" << endl;
            return;
        }
        if(((t[i+1]-t[i])-(abs(x[i+1]-x[i])+abs(y[i+1]-y[i])))%2){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  char a[H][W];
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cin >> a[i][j];
    }
  }

  int count = 0;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (a[i][j] != '#') {
        for (int k=-1; k<2; k++) {
          for (int l=-1; l<2; l++) {
            if (i+k >=0 && i+k < H && j+l >=0 && j+l < W && a[i+k][j+l] == '#') {
              count++;
            }
          }
        }
        a[i][j] = count + 48;
        count = 0;
      }
    }
  }
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      cout << a[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

#include <stdlib.h>
int main(){
  int j,*a[100000],n,m,i,ndnm,parent[100000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    parent[i]=-1;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&ndnm,&m);
    a[ndnm]= malloc(sizeof(int)*(m+1));
    
    for(j=0;j<m;j++){
     scanf("%d",&a[ndnm][j]);
     parent[a[ndnm][j]]=ndnm;
    }
    a[ndnm][m]=-1;
  }
  int ins,count;
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, ",i,parent[i]);
    ins=parent[i];
    while(ins!=-1){
      ins=parent[ins];
      count++;
    }
    printf("depth = %d, ",count);
    count=0;
    if(parent[i]==-1){
      printf("root, ");
    }else if(a[i][0]==-1){
      printf("leaf, ");
      printf("[]\n");
      continue;
    }else{
      printf("internal node, ");
    }
    printf("[");
    for(j=0;a[i][j]!=-1;j++){
      printf("%d",a[i][j]);
    if(a[i][j+1]!=-1)
      printf(", ");
    }
    printf("]\n");
    
  }
  for(i=0;i<n;i++){
    free(a[i]);
  }
}



Measured memory_bytes: 6328
S=list(input())
P=0
M=2019
D=[0]*M
D[0]=1
X,Y=0,1
for i in range(len(S)):
  X+=Y*int(S[-i-1])
  X%=M
  P+=D[X]
  D[X]+=1
  Y=Y*10%M
print(P)

Measured memory_bytes: 82180
import static java.lang.System.*;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(in);
		
		int n = sc.nextInt();
		int[] num = new int[n];
		
		for(int i=0; i<n; i++) num[i] = sc.nextInt();
		Arrays.sort(num);
		
		int[] ans = new int [2];
		Arrays.fill(ans, -1);
		for(int i=n-1; i>0; i--) {
			int l = 0;
			int h = i-1;
			
			int mid = l;
			while(l < h) {
				mid = (l+h)/2;
				
				if(num[mid] < num[i] / 2) l = mid;
				else if(num[mid] > num[i] / 2) h = mid;
				else break;
				
				if(l == h-1) {
					if(Math.abs(num[l] - num[i] / 2) < Math.abs(num[h] - num[i] / 2)) mid = l;
					else mid = h;
					
					break;
				}
				
			}
			
			if(ans[0] == -1 && ans[1] == -1) {
				ans[0] = num[i];
				ans[1] = num[mid];
				//continue;
				break;
			}
			
			/*
			if(ans[0] > num[i] && ans[1] > num[mid]) continue;
			
			BigInteger b = new BigInteger("1");
			BigInteger a = new BigInteger("1");
			
			for(int j=ans[0]; j>num[i]; j--) b = b.multiply(new BigInteger("" + j));

			int bs = ans[0] - ans[1] + 1;
			int as = num[i] - num[mid] + 1;
			if(bs > as) for(int j=bs-1; j>=as; j--) a = a.multiply(new BigInteger("" + j));
			else if(bs < as) for(int j=as-1; j>=bs; j--) b = b.multiply(new BigInteger("" + j));
			
			if(ans[1] > num[mid]) for(int j=ans[1]; j>num[mid]; j--) a = a.multiply(new BigInteger("" + j));
			else if(ans[1] < num[mid]) for(int j=num[mid]; j>ans[1]; j--) b = b.multiply(new BigInteger("" + j));
			
			out.println(ans[0] + " " + ans[1] + " , " + num[i] + " " + num[mid] + " , " + b + " " + a);
			
			if(b.compareTo(a) < 0) {
				ans[0] = num[i];
				ans[1] = num[mid];
			}
			*/
		}
		
		out.println(ans[0] + " " + ans[1]);
		
		return;
	}

}


Measured memory_bytes: 50600
use std::io::*;

struct Stdio {
    sin : Stdin,
    sout : Stdout,
    buf : Vec<String>,
    len : usize,
    cnt : usize,
}

#[allow(dead_code)]
impl Stdio {
    fn new() -> Stdio  {
        Stdio {
            len : 0,
            cnt : 0,
            sin : stdin(),
            sout : stdout(),
            buf : Vec::new(),
        }
    }
    
    fn read_line(&mut self) {
        let mut s = String::new();
        let mut loc = self.sin.lock();
        loc.read_line(&mut s).unwrap();
        self.buf = s.trim().split_whitespace().map(|s| s.to_string()).collect();
        self.len = self.buf.len();
        self.cnt = 0;
    }
    
    fn read_next(&mut self) ->&str {
        if self.len == self.cnt {
            self.read_line();
        }
        let ret = &self.buf[self.cnt];
        self.cnt += 1;
        ret
    }
    
    fn read_num<T: std::str::FromStr>(&mut self) -> T {
        self.read_next().parse::<T>().ok().unwrap()
    }

    fn read_string(&mut self) -> &str {
        self.read_next().clone()
    }
    
}

fn main() {
    let mut stdio = Stdio::new();
    let n = stdio.read_num::<usize>();
    let mut a = vec![0;n];
    for i in &mut a {
        *i = stdio.read_num::<i32>();
    }
    let max = a.iter().max().unwrap();
    let min = a.iter().min().unwrap();
    writeln!(stdio.sout, "{}" , max-min).unwrap();

}


Measured memory_bytes: 4352
S = input()
N = len(S)

ans = [0]*N

now = 'R'
r = 0
l = 0
p = 0
for n in range(N):
    if now == 'R':
        if S[n] == 'R':
            r +=1
        else:
            p = n
            l = 1
            now = 'L'
            continue
    if now == 'L':
        if S[n] == 'L':
            l += 1
        else:
            ans[p] = r//2 + (l-1)//2 + 1
            ans[p-1] = (r-1)//2 + l//2 +1
            r = 1
            now = 'R'


ans[p] = r//2 + (l-1)//2 + 1
ans[p-1] = (r-1)//2 + l//2 +1

for n in range(N):
    print(ans[n], end=" ")

Measured memory_bytes: 4864
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long k = sc.nextLong();
    if(k%2==0){
      System.out.println(-1);
      return;
    }
    long b = 7l;
    int count = 1;
    while(count<10000000){
      if(b%k==0){
        System.out.println(count);
        return;
      }
      b*=10;
      b+=7;
      b%=k;
      count++;
    }
    System.out.println(-1);

  }
}


Measured memory_bytes: 35824
from collections import Counter
n = int(input())
s = []
for i in range(n):
    s.append(input())
c = Counter(s).most_common()
ans = []
for i in range(len(c)):
    if c[0][1] == c[i][1]:
        ans.append(c[i][0])
    else:
        break
ans.sort()
for i in ans:
    print(i)


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;
const int logn = 20;

int n, k, q;
int a[maxn];
int r[maxn][logn], l[maxn][logn];
ll lsum[maxn][logn], rsum[maxn][logn];

int main(){
	scanf("%d%d", &n, &k);
	FOR(i, 0, n)
		scanf("%d", a + i);
		
	for(int i = 0, j = 0; i < n; ++i){
		for(; j < n && a[j] < a[i] + k; ++j);
		r[i][0] = j;
		rsum[i][0] = j;
	}
	for(int i = n - 1, j = n - 1; i >= 0; --i){
		for(; j >= 0 && a[j] > a[i] - k; --j);
		l[i][0] = j;
		lsum[i][0] = j;
	}
	
	FOR(j, 1, logn) FOR(i, 0, n){
		l[i][j] = l[i][j - 1] == -1 ? -1 : l[l[i][j - 1]][j - 1];
		r[i][j] = r[i][j - 1] == n ? n : r[r[i][j - 1]][j - 1];
		lsum[i][j] = l[i][j - 1] == -1 ? lsum[i][j - 1] : lsum[i][j - 1] + lsum[l[i][j - 1]][j - 1];
		rsum[i][j] = r[i][j - 1] == n ? rsum[i][j - 1] : rsum[i][j - 1] + rsum[r[i][j - 1]][j - 1]; 
	}
	
	scanf("%d", &q);
	FOR(i, 0, q){
		int x, y, len = 0;
		ll sumx = 0, sumy = 0;
		scanf("%d%d", &x, &y); --x; --y;
		int a = x, b = y;
		for(int i = logn - 1; i >= 0; --i){
			if(r[a][i] <= y){
				sumx += rsum[a][i];
				a = r[a][i];
				len += 1 << i;
			}
			if(l[b][i] >= x){
				sumy += lsum[b][i];
				b = l[b][i];
			}
		}
		sumy += y;
		sumx += x;
		++len;
		printf("%lld\n", sumy - sumx + len);
	}
	return 0;
}


Measured memory_bytes: 98332
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int L[n+1], R[n+1];
    L[n] = 0; R[n] = 0;
    for (int i = 0; i < n; i++) {
        cin >> L[i] >> R[i];
    }

    sort(L, L+n+1, greater<int>());
    sort(R, R+n+1);

    long ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += (long)max(0, 2*(L[i]-R[i]));
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
import scala.io.Source

object Main extends App {
  val lines = Source.stdin.getLines.map(_.split(" ").map(_.toInt).toList).toList
  val (rows, cols) = (lines(0)(0), lines(0)(1)+1)
  val linesOfNum: List[List[Int]] = lines.tail

  def appendSum(xs: List[Int]): List[Int] = {
    val newLine =  xs :+ xs.sum
    println(newLine.mkString(" "))
    newLine
  }


  def addEachElement(acc: List[Int], ixx: List[List[Int]]): List[Int] = ixx match {
    case Nil => acc
    case h :: tail => addEachElement((acc zip appendSum(h)).map { case (i, j) => i + j }, tail)
  }

  println(addEachElement(List.fill(cols)(0), linesOfNum).mkString(" "))
}

Measured memory_bytes: 50008
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 19 16:25:46 2020

@author: NEC-PCuser
"""


K, T = map(int, input().split())

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

a.sort()

sum_cake = 0
for i in range(len(a) - 1):
   sum_cake += a[i]

if a[len(a) - 1] <= sum_cake + 1:
   print(0)
else:
    print(a[len(a) - 1]  - sum_cake - 1)

Measured memory_bytes: 9044
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>
#include <utility>

using namespace std;

int main()
{
	string n;
	cin >> n;
	int i;
	for ( i = 0; n[i] != '\0'; i++)
		if (n[i] == '7')
			break;

	if (n[i] == '\0')
		cout << "No";
	else
		cout << "Yes";

	return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <string.h>

int main(void) {
	char s[100];
	int i;

	scanf("%s", s);

	for (i = 0; s[i] != '\0'; i ++) {
	s[i] = 'x';
	}

	printf("%s", s);

	return 0;
}


Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        t: usize,
        a: [usize; n],
    }

    let mut min = a[0];
    let mut max = a[0];
    let mut diff = 0;
    let mut result = 0;
    for i in 1..n {
        // println!("  {} {}", a[i], result);
        if a[i] < min {
            let new_diff = max - min;
            // println!("{} {}", diff, new_diff);
            if new_diff == diff {
                result += 1;
            } else if new_diff > diff {
                diff = new_diff;
                result = 1;
            }
            max = a[i];
            min = a[i];
        } else if a[i] > max {
            max = a[i];
        }
    }
    let new_diff = max - min;
    // println!("{} {}", min, max);
    // println!("{} {}", diff, new_diff);
    if new_diff == diff {
        result += 1;
    } else if new_diff > diff {
        result = 1;
    }
    
    println!("{}", result);
}


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

struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
#define int long long

signed main(){
    int a, b;
    cin >> a >> b;
    cout << ((a*b) % 2 == 1 ? "Odd" : "Even") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(){
	int a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(v<=w)puts("NO");
	else if(abs(a-b)<=1ll*t*(v-w))puts("YES");
	else puts("NO");
} 

Measured memory_bytes: 3636
/* ****TCIITB**** */

#include<bits/stdc++.h>
#define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;

#define N  100005

int main()
{
    
    io
    
    ll n;
    cin>>n;
    ll fl=0;
    while(n)
    {
        ll zz=n%10;
        if(zz==7)
        {
            cout<<"Yes";
            exit(0);
        }
        n/=10;
    }
    cout<<"No";
}

Measured memory_bytes: 3656
N, M, X = map(int, input().split())
books = []
for _ in range(N):
    books.append(list(map(int, input().split())))

INF = 10**9
ans = INF
for i in range(1, 2**N):
    bk = [0 for _ in range(N)]
    tmp = i
    tmpi = 0
    while tmp > 0:
        if tmp&1 == 1:
            bk[tmpi] = 1
        tmp //= 2
        tmpi += 1
    und = [0 for _ in range(M+1)]
    cost = 0
    for i in range(N):
        if bk[i] == 1:
            cost += books[i][0]
            for j in range(1, M+1):
                und[j] += books[i][j]
    flag = True
    for j in range(1, M+1):
        if und[j] < X:
            flag = False
            break
    if flag:
        ans = min(ans, cost)

if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define pb push_back
using namespace std;
const int N=2100;
priority_queue<int> Q;
vector<int> E[N],W[N];
int n,a[N],d[N],vis[N];
void dfs(int x)
{
	vis[x]=1;
	for(auto R:E[x]) if(!vis[R]) W[x].pb(R);
	for(auto R:E[x]) if(!vis[R]) dfs(R);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(__gcd(a[i],a[j])>1) E[i].pb(j),E[j].pb(i);
	for(int i=1;i<=n;i++) sort(E[i].begin(),E[i].end());
	for(int i=1;i<=n;i++) if(!vis[i]) dfs(i);
	for(int i=1;i<=n;i++) for(auto R:W[i]) d[R]++;
	for(int i=1;i<=n;i++) if(!d[i]) Q.push(i);
	while(!Q.empty())
	{
		int x=Q.top();Q.pop();
		printf("%d ",a[x]);
		for(auto R:W[x])
			if(--d[R]==0) Q.push(R);
	}
}


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

int main(){
  int n;
  cin >> n;
  vector<int> inputVec;
  for(int i=1; i<=n; i++){
    int num;
    cin >> num;
    inputVec.push_back(num);
  }
  vector<int> ansVec(n, 0);
  vector<int> ansNum;
  for(int i=n; i>=1; i--){
    int issum = 0;
    for(int j=2; j<=n; j++){
      if(i*j > n) break;
      else if(ansVec[i*j-1] == 1) issum++;
    }
	if(issum % 2 == inputVec[i-1]) ansVec[i-1] = 0;
    else{
      ansVec[i-1] = 1;
      ansNum.push_back(i);
    }
  }
  cout << ansNum.size() << endl;
  for(int i=0; i<ansNum.size(); i++){
    if(i != ansNum.size()-1){
      cout << ansNum[i] << " ";
    }else{
      cout << ansNum[i];
    }
  }
  return 0;
}

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <climits>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
 
#define barsik ios::sync_with_stdio(false)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair <int, int> pii;
typedef std::unordered_set <int> u_si;
const double PI = acos(-1);
const long double EPS = 1e-9;
using namespace std;

 
void solve(){
    int n, t, a;
    cin >> n >> t >> a;
    double ans = 1e9;
    int idx = -1;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        double as = t - x * 0.006;
        if(abs(as - a) < ans){
            ans = abs(as - a);
            idx = i + 1;
        }
    }
    cout << idx;
}

 
int main() {
    barsik;
    int q = 1;
    //cin >> q;
    while(q--) solve();
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A==B && B!=C) {
    cout << "Yes" << endl;
  }
  else {
    if (B==C && C!=A) {
      cout << "Yes" << endl;
    }
    else {
      if (C==A && A!=B) {
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 3520
def check(p):
  _N = N
  while _N%p == 0:
    _N //= p
  return (_N-1)%p == 0

def calc_divisors(n):
    m = int(n**0.5)
    left = []
    right = []
    for i in range(1, m+1):
        if n%i == 0:
            left.append(i)
            right.append(n//i)
    if left[-1] == right[-1]:
        right.pop()
    return left + right[::-1]

N = int(input())
P0 = calc_divisors(N)[1:] # [:1]で1を除外
P1 = calc_divisors(N-1)[1:] # 同上
ans = len(P1)
for p in P0:
  ans += check(p)

print(ans)

Measured memory_bytes: 3316
import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        break
Q = collections.deque([[i, j, 0]])
sH = set()
sW = set()
while Q:
    h, w, dist = Q.popleft()
    sH.add(h)
    sW.add(w)
    if dist < K:
        for nh, nw in [[h - 1, w], [h + 1, w], [h, w - 1], [h, w + 1]]:
            if 0 <= nh < H and 0 <= nw < W and A[nh][nw] == '.':
                A[nh][nw] = '#'
                Q += [[nh, nw, dist + 1]]
print(1 + min([
    math.ceil(_ / K)
    for _ in (min(sH), H - 1 - max(sH), min(sW), W - 1 - max(sW))
]))


Measured memory_bytes: 77020
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
using namespace std;

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

int main(){

    int A, B;
    cin >> A >> B;

    if(A + B >= 10) cout << "error" << endl;
    else cout << A + B << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
 
int main() {
	string str;
	int a,b,C;
	cin >> a>>b>>C;
	double s,l,h,c,rad,PI;
	PI = acos(-1);
	rad = C * PI/180;
	s = 1/2.0 * a * b * sin(rad);
	printf("%lf\n", s);
	c = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(rad));
	printf("%lf\n", a+b+c);
	h = s / a * 2;
	printf("%lf\n", h);
	return 0;
}


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

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

  if ( c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o' )
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define take freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);freopen("error.txt","w",stderr);
#define speed ios_base::sync_with_stdio(false);
#define int long long
#define endl "\n"
#define maxi 10000007
#define rof(i,a,b) for(int i=a;i<b;i++)
int32_t main()
{
    speed
    //take
    int n,x,t;
    cin>>n>>x>>t;
    int x1=(n%x!=0)?t:0;
    int cost=(n/x)*t+x1;
    cout<<cost;
}

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

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long>> s
// , std::vector<long long> t, long long M, std::vector<long long> d, std::vector<long long> q
){
    vector<vector<long long>> last(D, vector<long long>(26));
    vector<vector<long long>> score(D, vector<long long>(26));
    long long ans = 0;
    std::vector<long long> t;
    for (int d = 0; d < D; d++) {
        vector<pair<long long, long long>> v;
        // ひとまず選んだ時の利益が最大になるのを選んでみる
        for (int i = 0; i < 26; i++) {
            v.push_back({s[d][i] + c[i] * (d - last[d][i]), i});
        }
        sort(v.begin(), v.end());
        t.push_back(v[25].second + 1);

        for (int i = 0; i < 26; i++) {
            if (i == t[d] - 1) {
                last[d][i] = d;
                ans += s[d][i];
            } else {
                last[d][i] = d == 0 ? -1 : last[d-1][i];
                ans -= c[i] * (d - last[d][i]);
            }
        }
        // cout << ans << endl;
        cout << t[d] << endl;
    }

    // for (int m = 0; m < M; m++) {
    //     long long d1 = d[m] - 1;
    //     long long q1 = t[d1] - 1;
    //     long long q2 = q[m] - 1;

    //     long long i = q1;
    //     last[d1][i] = -1;   // ループの都合で別の値を入れておく
    //     for (int d = d1; d < D && last[d][i] != d; d++) {
    //         if (d == d1) {
    //             ans -= s[d][i];
    //         } else {
    //             ans += c[i] * (d - last[d][i]);
    //         }
    //         last[d][i] = d == 0 ? -1 : last[d-1][i];
    //         ans -= c[i] * (d - last[d][i]);
    //     }

    //     i = q2;
    //     for (int d = d1; d < D && last[d][i] != d; d++) {
    //         ans += c[i] * (d - last[d][i]);
    //         if (d == d1) {
    //             last[d][i] = d;
    //             ans += s[d][i];
    //         } else {
    //             last[d][i] = d == 0 ? -1 : last[d-1][i];
    //             ans -= c[i] * (d - last[d][i]);
    //         }
    //     }
    //     cout << ans << endl;

    //     t[d1] = q2 + 1;
    // }

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long D;
    scanf("%lld",&D);
    std::vector<long long> c(26);
    for(int i = 0 ; i < 26 ; i++){
        scanf("%lld",&c[i]);
    }
    std::vector<std::vector<long long>> s(D, std::vector<long long>(26));
    for(int i = 0 ; i < D ; i++){
        for(int j = 0 ; j < 26 ; j++){
            scanf("%lld",&s[i][j]);
        }
    }
    // std::vector<long long> t(D);
    // for(int i = 0 ; i < D ; i++){
    //     scanf("%lld",&t[i]);
    // }
    // long long M;
    // scanf("%lld",&M);
    // std::vector<long long> d(M);
    // std::vector<long long> q(M);
    // for(int i = 0 ; i < M ; i++){
    //     scanf("%lld",&d[i]);
    //     scanf("%lld",&q[i]);
    // }
    solve(D, std::move(c), std::move(s)
    // , std::move(t), M, std::move(d), std::move(q)
    );
    return 0;
}


Measured memory_bytes: 3976
#include<iostream>
using namespace std;
int main(){
  int n,m,q,ans;
  cin >> n >> m >> q;
  int c[n][n];
  int l,r;
  fill(c[0],c[n],0);
  for(int i=0;i<m;i++){
    cin >> l >> r;
    l--;
    r--;
    c[l][r]++;
  }
  for(int i=0;i<n;i++){
    for(int j=1;j<n;j++){
      c[i][j] += c[i][j-1];
    }
  }
  for(int i=0;i<q;i++){
    cin >> l >> r;
    l--; 
    r--;
    ans=0;
    for(int i=l;i<=r;i++){
      if(l==0){
        ans += c[i][r];
      }else{
        ans += c[i][r]-c[i][l-1];
      }
    }
    cout << ans <<endl;
  }
}


Measured memory_bytes: 1920
n=int(input())
l=list(map(int,input().split()))
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i]:
        if l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
          ans+=1
print(ans)

Measured memory_bytes: 73936
#include<iostream>
#include<string>
#include<stdio.h>
#include <algorithm>
#include <set>
#include<map>
#include<vector>

using namespace std;

int main(){
    int x,n;
    cin >> n;
    int y = n/15;
    if(y !=0){
       cout <<  n*800 - y*200 << endl;
    }else{
        cout << n*800 << endl;
        }
}

Measured memory_bytes: 256
inputs = raw_input().replace("\n", "").split(" ")
H, W = map(int, inputs)

m = [ [-1 for x in range(W)] for y in range(H)]

count = 0
zero_coords = []
for y in range(H):
    #line = list(input())
    line = list(raw_input().replace("\n", ""))
    for x, point in enumerate(line):
        if point == "#":
            m[y][x] = 0
            zero_coords.append([y, x])
            count += 1

tmp_coords = zero_coords
#mawari_soutais = [[-1, -1], [-1, 0], [-1, 1], [0, -1], [0, 1], [1, -1], [1, 0], [1, 1]]
mawari_soutais = [[-1, 0], [0, -1], [0, 1], [1, 0]]

val = 0
while count < H*W:
    val += 1
    new_tmp_coords = []
    for center_coord in tmp_coords:
        for mawari_soutai in mawari_soutais:
            mawari_coord = [mawari_soutai[i] + center_coord[i] for i in range(2)]
            y, x = mawari_coord
            if y < 0 or H <= y or x < 0 or W <= x or m[y][x] != -1:
                continue
            else:
                m[y][x] = val
                count += 1
                new_tmp_coords.append([y, x])
    tmp_coords = new_tmp_coords
    #print(m)

out = val
print(out)

Measured memory_bytes: 171656