akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;
public class Main extends PrintWriter {
    Main()
    {
        super(System.out);
    }
    public static void main(String args[]) {
      Main o=new Main();
      o.main();
      o.flush();
      o.close();
    }
    void main()
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int d=sc.nextInt();
        int c=0;
        while(n-->0)
        {
            int x=sc.nextInt();
            int y=sc.nextInt();
            double sp=Math.sqrt(Math.pow(x,2)+Math.pow(y,2));
            if(sp<=d)
            c++;
        }
        println(c);
        
    }
}

Measured memory_bytes: 60880
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
template<class T> using vv=vector<vector< T > >;

int main() {
  ll a, b, x;
  scanf("%lld %lld %lld", &a, &b, &x);
  ll pa = a % x;
  ll cnt = 0;
  ll na;
  if (pa == 0) {
    cnt += 1;
    na = a;
  } else {
    cnt += 1;
    na = a + x - pa;
  }
  if (na <= b) {
    cnt += (b - na) / x;
  } else {
    cnt = 0;
  }
  printf("%lld\n", cnt);

  return 0;
}


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

const int MOD = 1e9+7;

int modpow(int m, int n){
  if(n == 0) return 1;
  else if(n % 2 == 0) return modpow(m * m % MOD, n/2);
  else{
    return modpow(m, n - 1) * m % MOD;
  }
}

signed main(){
    int n, a, b; cin >> n >> a >> b;
    int ans = modpow(2, n) - 1;
    int num_a = 1, num_b = 1;
    for(int i = n - a + 1; i <= n; i++){
        num_a *= i;
        num_a %= MOD;
    }
    for(int i = n - b + 1; i <= n; i++){
        num_b *= i;
        num_b %= MOD;
    }
    int Y_a = 1, Y_b = 1;
    for(int i = 1; i <= a; i++){
         Y_a *= i;
         Y_a %= MOD;
    }
    for(int i = 1; i <= b; i++){
         Y_b *= i;
         Y_b %= MOD;
    }
    num_a *= modpow(Y_a, MOD - 2); num_a %= MOD;
    num_b *= modpow(Y_b, MOD - 2); num_b %= MOD;
    ans -= (num_a + num_b);
    ans %= MOD;
    while(ans < 0){
        ans += MOD;
    }
    cout << ans << endl;
}

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

int main() {
  int X;
  cin >> X;
  
  for(int i=X/100;i>0;i--){
    int n = X - i*100;
    if(n<=5*i){
      cout << 1 << endl;
      return 0;
    }
  }
  
  cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 256
import math
k=int(input())
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

pl=primes(k)
ans=[]
m=math.factorial(k)
for i in range(len(pl)):
    tmp=0
    while m%pl[i]==0:
        m=m//pl[i]
        tmp+=1
    ans.append(tmp)
a=1
for i in range(len(ans)):
    a=a*(ans[i]+1)%(10**9+7)
print(a)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        long n ;
        cin >> n ;
        long a , b;
        cin >> a;
        int flg;
        flg = 0;
        long ans = 1;
        for(long i = 1 ; i < n ; i++){
            cin >> b;
            //cout << a << " " << b << " " << flg << endl;
            if( a < b  && flg == 1){
                
            }else if(a > b  && flg == -1){
                
            }else if(a == b){
                
            }else if(a < b  && flg == 0){
                flg = 1;
            }else if(a > b  && flg == 0){
                flg = -1;
            }else{
                ans += 1;
                flg = 0;
            }
            
            a = b;
            
        }
        cout << ans << endl;
        return 0;
    }

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> picture(H);
  for(int i = 0; i < H; i++){
    cin >> picture.at(i);
  }
  for(int i = 0; i < H + 2; i++){
    if(i == 0 or i == H + 1){
      string line = "";
      for(int a = 0; a < W + 2; a++){
        line += "#";
      }
      cout << line << endl;
    }
    else{
      cout << "#" + picture.at(i - 1) + "#" << endl;
    }
  }
}


Measured memory_bytes: 3616
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    A, B = map(int, line_input())
    if A >= 13: print(B)
    elif A >= 6: print(B//2)
    else: print(0)
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3824
N = int(input())
b = list(map(int, input().split()))
a = [1, 2, 3, 4, 5]

def f(a, ans):
    if len(a) == 0:
        for i in range(len(ans)):
            print(ans[len(ans) - i - 1])
        exit()
    for i in range(len(a) - 1, -1, -1):
        if i + 1 == a[i]:
            f(a[0:i] + a[i + 1:len(a)], ans + [i + 1])
            break


f(b, [])
print(-1)



Measured memory_bytes: 3188
N,M=map(int,input().split())
H=list(map(int,input().split()))
box=[[] for i in range(N)]
count=0
for i in range(M):
    a,b=map(int,input().split())
    box[a-1].append(b-1)
    box[b-1].append(a-1)
for i in range(N):
    queue=box[i]
    hmax=H[i]
    count+=1
    for x in queue:
        if H[x]>=hmax:
            count-=1
            break
print(count)


Measured memory_bytes: 29352
#[allow(unused_macros)]
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 ( 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 ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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! {
        mut o: chars,
        mut e: chars
    }
    o.reverse();
    e.reverse();
    let mut acc = vec![];
    while !(o.len() == 0 && e.len() == 0) {
        if let Some(src) = o.pop() {
            acc.push(src);
        }
        if let Some(src) = e.pop() {
            acc.push(src);
        }
    }
    println!("{}", acc .iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <iterator>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define vl vector<ll>
#define pll pair<ll, ll>
#define F first
#define S second

int main() {
    // input
    ll A, B, X;
    cin >> X >> A >> B;
    
    // calculation
    X -= A;
    X %= B;
    
    cout << X << "\n";
    
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0189
AC
"""
import sys
from sys import stdin
input = stdin.readline


def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                dp_ik = dp[i][k]
                dp_kj = dp[k][j]
                if dp[i][j] > dp_ik + dp_kj:
                    dp[i][j] = dp_ik + dp_kj


def main(args):
    while True:
        n_max = 9+1
        n = int(input())
        if n == 0:
            break
        dp = [[float('inf')] * n_max for _ in range(n_max)]
        for i in range(n_max):
            dp[i][i] = 0

        max_town = 0
        for _ in range(n):
            a, b, c = map(int, input().split())
            dp[a][b] = c
            dp[b][a] = c
            max_town = max(max_town, a, b)

        warshallFloyd(max_town + 1, dp)


        min_dist = float('inf')
        town_live = -1
        for i, d in enumerate(dp[:max_town+1]):
            sum_dist = 0
            for ele in d[:max_town+1]:
                sum_dist += ele
            if sum_dist < min_dist:
                min_dist = sum_dist
                town_live = i

        print('{} {}'.format(town_live, min_dist))



if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7760
x=int(input())
value=0
index=0
hashmap=dict()
while value<int(1e18)+1:
    value=pow(index,5)
    hashmap[value]=index
    index+=1
#print(hashmap)    

for i in range(1,1000):
    b1=x+int(pow(i,5))
    b2=x+int(pow(-i,5))
    if hashmap.get(b1)!=None:
        print(hashmap[b1],i)
        break
    if hashmap.get(abs(b2))!=None:
        print(hashmap[abs(b2)],-i)
        break     

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

int main() {
    int l,r;
    cin >> l >> r;
    int output;
    int width = r - l;
    if(width >= 2018){
        output = 0;
    }
    else{
        int minmod = 2019;
        for (int i=l;i<r;i++){
            for(int j=i+1;j<=r; j++){
                int amari = ((i%2019)*(j%2019))%2019;
                if(amari < minmod){
                    minmod = amari;
                }
            }
        }
        output = minmod;
    }
    cout << output;
}

Measured memory_bytes: 256
a = []
3.times do
  a.push(gets.split.map(&:to_i))
end

n = gets.to_i

ans = 'No'
n.times do
  b = gets.to_i
  3.times do |i|
    3.times do |j|
      a[i][j] = '○' if a[i][j] == b
      if a[i].count('○') > 2
        ans = 'Yes'
      end
    end
  end
end

3.times do |i|
  if a[0][i] == '○' && a[1][i] == '○' && a[2][i] == '○'
    ans = 'Yes'
  end
end

if a[0][0] == '○' && a[1][1] == '○' && a[2][2] == '○'
  ans = 'Yes'
end

if a[0][2] == '○' && a[1][1] == '○' && a[2][0] == '○'
  ans = 'Yes'
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main() {
  set<int> s;
  int n;
  cin >> n;
  while (n --) {
    int a;
    cin >> a;
    if (s.count(a)) {
      s.erase(a);
    } else {
      s.insert(a);
    }
  }
  cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define ll long long int
#define __ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main ()
{
__

int n,cnt=0;

cin >> n;

for(int i=1;i<=n;i++)
{
stringstream ss;

ss <<i;

string s = ss.str();

if(s.size()%2) cnt++;
}

cout << cnt;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int A, B, M, x, y, c, kk = 1e9;
	cin >> A >> B >> M;
	
	int a[A], b[B];
	
	for (int i = 0; i < A; i++) cin >> a[i];
	for (int i = 0; i < B; i++) cin >> b[i];
	
	for (int i = 0; i < M; i++)
	{
		cin >> x >> y >> c;
		if (a[x-1]+b[y-1]-c < kk) kk = a[x-1]+b[y-1]-c;
	}
	int hh = *min_element(a, a+A) + *min_element(b, b+B);
	if (kk < hh) cout << kk << "\n";
	else cout << hh << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  int T, A;
  cin >> T >> A;
  
  vector<int> arr;
  int a;
  for (int n = 0; n < N; n++) {
	cin >> a;
	arr.push_back(a);
  }

  double closestTemp = -1.0;
  int index = 0;

  for (int i = 0; i < (int) arr.size(); i++) {
	double temp = A - (T - arr[i] * 0.006);
	if (temp < 0)
	  temp = temp * -1;
	//cout << temp << endl;

	if (temp < closestTemp || closestTemp < 0) {
	  closestTemp = temp;
	  index = i+1;
	}

  }

  cout << index << endl;


  return 0;
}


Measured memory_bytes: 256
/*
2020-04-25
atcoder ABC
C - Rally
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;

int main() {
    int N, min_x = INF, max_x = 0;
    ll ans = INF;
    cin >> N;

    vector<int> points(N);
    for(int i = 0; i< N; i++) {
        cin >> points[i];
        min_x = min(min_x, points[i]);
        max_x = max(max_x, points[i]);
    }
    for(int i = min_x; i < max_x + 1; i++) {
        ll d = 0;
        for(int j = 0; j < N; j++) {
            d += (points[j] - i) *  (points[j] - i);
        }
        ans = min(ans, d);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**********************************************
 *Author*        :TRDD
 *reated Time*  : 2017/8/26 19:46:53

 *********************************************/
#include<cstdio>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef long long LL;
LL Q, H, S, D, N;
LL sum;
void solve() {
	H = min(H, Q * 2);
	S = min(H * 2, S);
	S = min(Q * 4, S);
	D = min(H * 4, D);
	D=min(S * 2, D);
	D=min(Q * 8, D);
	sum = N / 2 * D + N % 2 * S;
	printf("%lld\n", sum);
}
int main()
{
	scanf("%lld%lld%lld%lld%lld", &Q, &H, &S, &D, &N);
	solve();
	return 0;
}

Measured memory_bytes: 128
H,W = map(int,input().split())
S = [input() for i in range(H)]

rs = [[0]*W for i in range(H)]
ls = [[0]*W for i in range(H)]
ds = [[0]*W for i in range(H)]
us = [[0]*W for i in range(H)]

for i in range(H):
    tmp = 0
    for j in range(W):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            rs[i][j] = tmp
    tmp = 0
    for j in reversed(range(W)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ls[i][j] = tmp

for j in range(W):
    tmp = 0
    for i in range(H):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            ds[i][j] = tmp
    tmp = 0
    for i in reversed(range(H)):
        if S[i][j] == '#':
            tmp = 0
        else:
            tmp += 1
            us[i][j] = tmp

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        tmp = rs[i][j] + ls[i][j] + ds[i][j] + us[i][j] - 3
        ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 180612
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int m;

int which(int a, int b);

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    in_arr(int, a, n);
    m = accumulate(a.begin(), a.end(), 0, [](int a, int b){ return max(a, b); });
    int suit = accumulate(a.begin(), a.end(), 0, [](int a, int b){ return which(a, b); });
    cout << m << " " << suit << endl;
    return 0;
}

int which(int a, int b){
    int val_a = min(a, m - a);
    int val_b = min(b, m - b);
    return val_a < val_b ? b : a;
}


Measured memory_bytes: 640
from string import ascii_lowercase as alph
from operator import itemgetter

def gen_pattern(N, pre=[]):
  for i in range(max(pre or [-1])+2):
    indexes = pre+[i]
    if len(indexes) == N:
      print("".join(itemgetter(*indexes)(alph)))
    else:
      gen_pattern(N, indexes)

gen_pattern(int(input()))


Measured memory_bytes: 5024
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    H = il()
    tmp = -1
    for n in range(N):
        if tmp-1 <= H[n]:
            tmp = max(tmp, H[n])
        else:
            print('No')
            exit()
    else:
        print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 13048
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
    int n,k,l,d[10]={};
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>l;
        d[l]=1;
    }
    string retstr;
    bool flag=true;
    int x;
    while(flag){
        flag=false;
        retstr=to_string(n);
        x=n;
        while(x>0){
            if(1==d[x%10]){
                n++;
                flag=true;
                break;
            }
            x/=10;
        }
    }
    cout<<n;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define out(S) cout<<(S)<<endl;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define beginend(v) v.begin(),v.end()
#define Foreach(item,collection) for(auto item : collection)

using pii=pair<int,int>;
using vb=vector<bool>;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vvc=vector<vector<char>>;
using ti3=tuple<int,int,int>;
using ulong=unsigned long;
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
#define OCB(c) (c&1)|(c&2)<<2|(c&4)<<4|(c&8)<<6|(c&16)<<8|(c&32)<<10|(c&64)<<12|(c&128)<<14

int main(){
    int n,d,x,ans=0;
    cin >> n>>d>>x;
    rep(i,n){
        int ai;
        cin >> ai;
        int k=1;
        while(k<=d){
            k+=ai;
            ans++;
        }
    }
    out(ans+x);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int64_t kRem = 998244353;

int64_t pow_rem(int64_t x, int64_t m, int64_t rem)
{
	if (m == 0) {
		return 1;
	}
	if (m == 1) {
		return x;
	}

	if (m & 1) {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		val *= x;
		val %= rem;
		return val;
	}
	else {
		int64_t val = pow_rem(x, m / 2, rem);
		val = val * val;
		val %= rem;
		return val;
	}
}

int64_t pow_remdiv(int64_t val, int64_t rem)
{
	return pow_rem(val, rem - 2, rem);
}

int64_t divide_rem(int64_t divident, int64_t dividor, int64_t rem)
{
	int64_t ret = pow_remdiv(dividor, rem);
	ret *= divident;
	ret %= rem;

	return ret;
}


vector<int64_t> factors;
vector<int64_t> finvs;
void precalc_nCr(int n, int64_t rem) {
	factors = vector<int64_t>(n + 1);
	finvs = vector<int64_t>(n + 1);

	{
		int64_t f = 1;
		factors[0] = 1;
		FOR_LE(i, 1, n) {
			f *= i;
			f %= rem;
			factors[i] = f;
		}
	}
	{
		int64_t inv = divide_rem(1, factors[n], rem);
		finvs[n] = inv;
		FOR_DW(i, n - 1, 0) {
			inv *= i + 1;
			inv %= rem;
			finvs[i] = inv;
		}
	}
}

int64_t nCr(int n, int k) {
	int64_t val = factors[n];
	val *= finvs[n - k];
	val %= kRem;
	val *= finvs[k];
	val %= kRem;
	return val;
}

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

	int64_t n; cin >> n;

	precalc_nCr(n, kRem);

	int64_t ans = 0;
	FOR_LE(k, n / 2 + 1, n) {
		int64_t val = nCr(n, k);
		val *= pow_rem(2, n - k, kRem);
		val %= kRem;
		ans += val;
		ans %= kRem;
	}

	ans *= 2;
	ans %= kRem;

	ans = pow_rem(3, n, kRem) - ans;
	if (ans < 0) ans += kRem;

	cout << ans << endl;

	return 0;
}

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

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

	if ((x == 1) || (x == 2*N - 1)) {
		cout << "No" << endl;
		return 0;
	}
	if (N == 2) {
		cout << "Yes" << endl;
		for (int i = 1; i <= 3; ++i) { cout << i << endl; }
		return 0;
	}

	vector<int> res(2*N - 1);
	if (x == 2) {
		res[N - 2] = x + 1;
		res[N - 1] = x;
		res[N] = x - 1;
		res[N + 1] = x + 2;
	} else {
		res[N - 2] = x - 1;
		res[N - 1] = x;
		res[N] = x + 1;
		res[N + 1] = x - 2;
	}
	int cnt = 1;
	for (int i = 0; i < res.size(); ++i) {
		if ((i >= N - 2) && (i <= N + 1)) { continue; }

		if (x == 2) {
			if (cnt == x - 1) { cnt = x + 3; }
		} else {
			if (cnt == x - 2) { cnt = x + 2; }
		}

		res[i] = cnt++;
	}

	cout << "Yes" << endl;
	for (int i = 0; i < res.size(); ++i) {
		cout << res[i] << endl;
	}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef set<int> si;
typedef map<string, int> msi;
typedef map<int, int> mii;

#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define clr(a) memset(a,0,sizeof(a))
#define SET(a,b) memset(a,b,sizeof(a))

#define trace(x) cout << '>' << #x << ':' << x << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);
const int oo = 0x3f3f3f3f;

template<class T> inline T gcd(T a,T b) //NOTE:__gcd(0,0) gives exception
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}

int cmp(double x, double y = 0, double tol = EPS) {
    return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

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

/*bool sortby(const pair<ll,ll> &a,const pair<ll,ll> &b)
{
    return (a.second < b.second);
}*/

const int MAX_N = 3*123456;

//int arr[MAX_N];

int main(){
    int x;
    vi V;
    for(int i=0;i<3;i++){
        cin>>x;
        V.PB(x);
    }
    SORT(V);
    cout<<V[2]*10+V[1]+V[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::io;

macro_rules! get {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.parse::<$t>().unwrap()
        }
    };
    ($($t: ty), *) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            let mut inter = x.split_whitespace();
            (
                $(inter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
}

macro_rules! insert_vec {
    ($t: ty) => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.split_whitespace().map(|x| x.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
}

macro_rules! word_chars_vec {
    () => {
        {
            let mut x = String::new();
            io::stdin().read_line(&mut x).ok();
            x = x.trim_right().to_owned();
            x.chars().collect::<Vec<_>>()
        }        
    };
}
fn main() {
    let s = word_chars_vec!();
    if s[0] == s[1] || s[1] == s[2] || s[2] == s[3] {
        println!("Bad");
    } else {
        println!("Good");
    }

}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  while(cin >> N) {
    vector<long long> H(N);
    for(int i = 0; i < N; ++i) cin >> H[i];
    if(N == 1) { cout << 0 << '\n'; continue; }
    long long mx = -1, c = 0;
    for(int i = 1; i < N; ++i) {
      if(H[i - 1] < H[i]) {
        mx = max(mx, c);
        c = 0;
      } else ++c;
    }
    mx = max(mx, c);
    cout << mx << '\n';
  }
  return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
v = gets.split.map(&:to_i)
p = Hash.new(0)
q = Hash.new(0)
n.times do |i|
  p[v[i]] += 1 if i.even?
  q[v[i]] += 1 if i.odd?
end
ps = Hash[p.sort_by{|k, v| -v}].keys
qs = Hash[q.sort_by{|k, v| -v}].keys
x, y, ans = 0, 0, n / 2
f = false
ps.size.times do |i|
  x = ps[i]
  qs.size.times do |j|
    if x != qs[j]
      y = qs[j]
      f = true
      break
    end
  end
  break if f
end
ans = n - p[x] - q[y] if f
x, y = 0, 0
f = false
qs.size.times do |i|
  x = qs[i]
  ps.size.times do |j|
    if x != ps[j]
      y = ps[j]
      f = true
      break
    end
  end
  break if f
end
ans = n - q[x] - p[y] if f && ans > n - q[x] - p[y]
puts ans

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

int main(){
	int l=0,r=1,N,max=INT_MIN,count=1;
	long long T;
	cin >> N >> T;
	vector <long long> A(N);
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	while(r<N){
		if(A[l]>A[r]){l=r;}
		else if(max<A[r]-A[l]){max=A[r]-A[l];count=1;}
		else if(max==A[r]-A[l]){count++;}
		r++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,i,j,k,l,dp[300005][2][2][3],suf[300005],ans;// s[1..i]    j evens     k 0s    last:l
string st;
int main(){
	cin>>st;
	n=st.size();
	suf[n]=1;
	for(i=n-1;i>=0;i--){
		suf[i]=suf[i+1];
		if(st[i]=='?') suf[i]=2ll*suf[i]%mod;
	}
	dp[0][0][0][0]=1;
	for(i=0;i<n;i++){
		if(st[i]!='1'){
			for(j=0;j<2;j++){
				for(k=0;k<2;k++){
					for(l=0;l<3;l++){
						dp[i+1][j][k][(l&1)+1]=(dp[i+1][j][k][(l&1)+1]+dp[i][j][k][l])%mod; 
					}
				}
			}
		}
		if(st[i]!='0'){
			for(j=0;j<2;j++){
				for(k=0;k<2;k++){
					if(!j&&!k){
						dp[i+1][1][1][0]=(dp[i+1][1][1][0]+dp[i][j][k][0])%mod;
					}
					if(j&&k){
						ans=(ans+1ll*dp[i][j][k][0]*suf[i+1])%mod;
					}
					if(!j&&k){
						dp[i+1][!j][k][0]=(dp[i+1][!j][k][0]+dp[i][j][k][0])%mod;
					}
					if(j&&!k){
						dp[i+1][!j][k][0]=(dp[i+1][!j][k][0]+dp[i][j][k][0])%mod;
					}
					dp[i+1][j][k][0]=(dp[i+1][j][k][0]+dp[i][j][k][1])%mod;
					dp[i+1][!j][k][0]=(dp[i+1][!j][k][0]+dp[i][j][k][2])%mod;
				}
			}
		}
	}
	cout<<(ans+dp[n][1][1][0])%mod<<endl;
	return 0;
}

Measured memory_bytes: 15876
#include <iostream>
#include <vector>
using namespace std;
#pragma warning (disable: 4996)

long long mod = 1000000007;
long long N, P[1 << 18];
long long dp[5009][5009];
long long fact[1 << 18];
long long power[1 << 18];
vector<int> G[1 << 18];

int col[1 << 18], cnts;
int sz[1 << 18];

void dfs(int pos) {
	col[pos] = cnts;
	sz[cnts]++;
	for (int i : G[pos]) {
		if (col[i] >= 1) continue;
		dfs(i);
	}
}

void init() {
	fact[0] = 1;
	for (int i = 1; i <= N; i++) fact[i] = (1LL * i * fact[i - 1]) % mod;
	power[0] = 1;
	for (int i = 1; i <= N; i++) power[i] = (1LL * (N - 1LL) * power[i - 1]) % mod;
}

int main() {
	cin >> N; init();
	for (int i = 1; i <= N; i++) {
		cin >> P[i];
		if (P[i] == -1) continue;
		G[i].push_back(P[i]);
		G[P[i]].push_back(i);
	}
	for (int i = 1; i <= N; i++) {
		if (col[i] >= 1) continue;
		cnts++; dfs(i);
	}

	vector<long long> R;
	for (int i = 1; i <= N; i++) {
		if (P[i] != -1) continue;
		R.push_back(sz[col[i]]);
	}
	dp[0][0] = 1;
	for (int i = 0; i < R.size(); i++) {
		for (int j = 0; j <= R.size(); j++) {
			if (dp[i][j] == 0) continue;
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] += dp[i][j] * R[i];
			dp[i + 1][j] %= mod;
			dp[i + 1][j + 1] %= mod;
		}
	}

	// 計算
	long long TOKU = 0, BASE = power[R.size()];
	for (int i = 2; i <= R.size(); i++) {
		TOKU += (1LL * fact[i - 1] * dp[R.size()][i] % mod) * power[R.size() - i] % mod;
		TOKU %= mod;
	}
	for (int i : R) {
		TOKU += 1LL * (i - 1) * power[R.size() - 1] % mod;
		TOKU %= mod;
	}
	BASE *= 1LL * (N - (cnts - R.size()));
	BASE %= mod;

	cout << (BASE - TOKU + mod) % mod << endl;
	return 0;
}

Measured memory_bytes: 126576
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void)
{
    int n,i,t,cnt,ans=0;

    scanf("%d",&n);

    for(i=1;i<=n;i=i+2){
        t=1;
        cnt=0;
        while(t<=i){
            if(i%t==0){
                cnt++;
            }
            t++;
        }
        if(cnt==8){
            ans++;
        }
    }
     
    printf("%d\n",ans);

}

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

int main() {
	int H, W;

	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 1; i <= H; i++) {
			if (i == 1 || i == H) {
				for (int j = 1; j <= W; j++) {
					cout << "#";
				}cout << endl;
			}
			else {
				for (int j = 1; j <= W; j++) {
					if (j == 1 || j == W) {
						cout << "#";
					}
					else {
						cout << ".";
					}
				}cout << endl;
			}

		}cout << endl;
	}
	return 0;
}



Measured memory_bytes: 3016
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] += a[i][k] * b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;
#define REV(T) greater<T>()

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

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N = 0, d = 0, i = 1;
  multiset<ll> A;

  cin >> N;

  REP(i, N) {
    ll po = 0;
    cin >> po;
    A.insert(po);
  }
  while (!A.empty()) {
    ll x = *A.rbegin();
    A.erase(A.find(x));

    for (ll l = 30; l >= 1; l--) {
      if (A.find((1 << l) - x) != A.end()) {
        d++;
        A.erase(A.find((1 << l) - x));
        break;
      }
    }
  }
  cout << d << endl;
  return 0;
}


Measured memory_bytes: 9600
# 幅優先探索 Breadth first search: BFS
import queue

n = int(input())
Adj = [[] for i in range(n)]
for i in range(n):
    dat = [int(i) for i in input().split()]
    Adj[dat[0] - 1] = dat[2:]

D = [-1 for i in range(n)]
D[0] = 0
Q = queue.Queue()
Q.put(1)
while not Q.empty():
    u = Q.get()
    for v in Adj[u - 1]:
        if D[v - 1] == -1:
            Q.put(v)
            D[v - 1] = D[u - 1] + 1

for i in range(n):
    print(i + 1, D[i])



Measured memory_bytes: 6876
#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#define ll long long
#define rg register
#define INF 0x3f3f3f3f
using namespace std;
struct node{
	ll x,y;
}a[200001];
ll ans1,ans2=INF,maxl=-1,maxr=-1,minl=INF,minr=INF,x[200001],y[200001],n;
ll maxx[200001],minn[200001];
bool cmp(const node &one,const node &two){return one.x<two.x;}
int main()
{
	scanf("%lld",&n);
	for(rg ll u=1;u<=n;u+=1)
	{
		scanf("%lld %lld",&x[u],&y[u]);
		if(x[u]>y[u])swap(x[u],y[u]);
		maxl=max(maxl,x[u]);
		minl=min(minl,x[u]);
		maxr=max(maxr,y[u]);
		minr=min(minr,y[u]);
		a[u].x=x[u];a[u].y=y[u];
	}
	ans1=(maxl-minl)*(maxr-minr);
	sort(a+1,a+n+1,cmp);
	maxx[1]=minn[1]=a[1].y;
	for(rg ll u=2;u<n;u+=1)
	{
		maxx[u]=max(maxx[u-1],a[u].y);
		minn[u]=min(minn[u-1],a[u].y);
		ans2=min(ans2,max(maxx[u],a[n].x)-min(minn[u],a[u+1].x));
	}
	ans2*=(maxr-minl);
	printf("%lld",min(ans1,ans2));
	return 0;
}

Measured memory_bytes: 9600
#define ll long long

#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>

using namespace std;

// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);

// 1e15 1e15 1e15

void solve()
{
    ll x, k, d;
    cin >> x >> k >> d;
    ll bestK = - llround((double)x/d);
    // cout << "bestK: " << bestK << '\n';
    // remember to treat zero
    if (abs(bestK) < k)
    {
        // cout << "BestK < k\n";
        x = x + bestK * d;
        // cout << "x after first jump: " << x << '\n';
        k -= abs(bestK);
        // cout << "k left: " << k << '\n';
        // if k left is even, waste all k's going forward and backward
        if (k%2 == 0) cout << abs(x) << '\n';
        // else, waste all k's but the last
        else
        {
            cout << min(abs(x + d), abs(x - d)) << '\n';
            // cout << x + d << '\n';
            // else cout << abs(x - d) << '\n';
        }
    }
    else if(abs(bestK) >= k)
    {
        // cout << "BestK >= k\n";
        cout << min(abs(x + k*d), abs(x - k*d)) << '\n';
        // if(bestK > 0) cout << abs(x + k*d) << '\n';
        // else cout << abs(x - k*d) << '\n';
    }
}

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

    int nCases = 1;
    // cin >> nCases;

    while(nCases--)
        solve();

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; vll H; vi V;
void input(){
    cin>>N;
    rep(i,N){
        ll a; cin>>a; H.emplace_back(a);
    }
    return;
}

void solve(){
    int h=0;
    V.emplace_back(h);
    rep(i,N-1){
        if(H[i]>=H[i+1]) ++h;
        else h=0;
        V.emplace_back(h);
    }
    int ans=0;
    rep(i,N) ans=max(ans,V[i]);
    cout<<ans<<endl;
    return;
}

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

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

int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (t*s>=d) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3640
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;
#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll K;
    cin >> K;
    ll C;
    cin >> C;
    string S;
    cin >> S;
    vector<ll> low(K,0);
    vector<ll> high(K,0);
    ll now=0;
    for(ll i=0;i<K;++i){
        while(S[now]!='o')now++;
        low[i]=now;
        now+=C+1;
    }
    now=N-1;
    for(ll i=K-1;i>=0;--i){
        while(S[now]!='o')now--;
        high[i]=now;
        now-=C+1;
    }
    ll ans=0;
    for(ll i=0;i<K;++i)if(low[i]==high[i])prt(low[i]+1);

    return 0;
}



Measured memory_bytes: 6612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w; cin >> h >> w;
  vector<string> S(h); rep(i, h) cin >> S[i];
  int dx[] = {-1, 0, 1, 0};
  int dy[] = {0, 1, 0, -1};
  bool ok = true;
  rep(i, h) rep(j, w) {
    if(S[i][j] == '.') continue;
    int cnt = 0;
    rep(k, 4) {
      int nx = i+dx[k];
      int ny = j+dy[k];
      if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
      if(S[nx][ny] == '#') cnt++;
    }
    ok &= (cnt != 0);
  }
  cout << (ok ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 3664
var input = require('fs').readFileSync('/dev/stdin', 'utf8');

var N = +input

var alpha = 'abcdefghijklmnopqrstuvwxyz'.split('');

var name = [];
do {
    N = N - 1;
    name.unshift(alpha[N % 26])
    N = Math.floor(N / 26)
} while(N > 0)

console.log(name.join(''));

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

int main(){
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y;

    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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,
    }
    let mut ans = vec![0u64; n + 1];
    ans[0] = 2;
    ans[1] = 1;
    for i in 2..n + 1 {
        ans[i] = ans[i - 2] + ans[i - 1]
    }
    println!("{}", ans.last().unwrap());
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
static int aa[100005],bb[100005],x[100005],y[100005],cc[100005];
static int aaa[100005],bbb[100005];

int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return 1;}
    else if(*(int*)a<*(int*)b){return -1;}
    else {return 0;}
}

int main(void){
int a,b,m;
int min;
scanf("%d %d %d",&a,&b,&m);

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

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

for(int i=0;i<m;i++){
    scanf("%d %d %d",&x[i],&y[i],&cc[i]);
}
qsort(aaa,a,sizeof(int),cmp);
qsort(bbb,b,sizeof(int),cmp);
///割引なし最小
min=aaa[0]+bbb[0];
//printf("%d\n",min);

for(int i=0;i<m;i++){
    if(aa[x[i]-1]+bb[y[i]-1]-cc[i]<=min){min=aa[x[i]-1]+bb[y[i]-1]-cc[i];}
    //printf("a/b %d %d %d\n",aa[x[i]-1],bb[y[i]-1],cc[i]);
      //  printf("%d\n",min);
    }
    printf("%d\n",min);
}


Measured memory_bytes: 3324
N, M = map(int,input().split())
A_li = list(map(int,input().split()))
CB_li = []
for i in range(M):
    B,C = map(int,input().split())
    CB_li.append([C,B])

CB_li.sort()
CB_li.reverse()

counter = 0
for i in range(M):
    li = [CB_li[i][0]]*CB_li[i][1]
    A_li.extend(li)
    counter += CB_li[i][1]
    if counter > N:
        break

A_li.sort()
ans = sum(A_li[-N:])
    
print(str(ans))

Measured memory_bytes: 84120
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>
#include <deque>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;
Graph G;
const int AMAX = 100000;
/*int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}



int n;
vll a;

ll solve(bool isp)
{
	ll sum = 0ll;
	ll ret = 0ll;

	for (int i = 0; i < n; i++)
	{
		sum += a[i];
		if (isp and sum <= 0)
		{
			ret += -sum + 1;
			sum = 1ll;
		}
		if (not isp and sum >= 0)
		{
			ret += sum + 1;
			sum = -1ll;
		}
		isp ^= 1;
	}
	return ret;
}

*/


/*
 * 最大公約数計算
 */
int gcd(int a, int b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n,m;
	cin >> n >> m;
	
	

		
	
		cout << (n-1) * (m-1) << endl;

	return 0;

	


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e3+10,mxm=4e5+10,modl=1e9+7;
ll nm,n,m,p,t,ans,sum;
int a[mxn],b[mxn],h[mxn];
//string s[mxn];
//bool in[mxn][mxn];
//int tr[][2]={{0,-1},{-1,0},{0,+1}};
//struct pos{
//    int x,y;
//    bool operator < (const pos b)const{
//        return h[x][y]>h[b.x][b.y];
//    }
//};
bool cmp(string a,string b){
    return a+b<b+a;
}
int main(){
    ios_base::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
//    cin>>nm;
//    string s,s2;
    while(cin>>n>>p>>t){
//        priority_queue<int,vector<int>,greater<int>>q;
        if(!p&&!t){cout<<"0";return 0;}
        cout<<n/(p+t)*p+min(p,n%(p+t));
        //cout<<t;
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256