akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> a(H,vector<char>(W));

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> a.at(i).at(j);
    }
  }

  vector<bool> row(H, false);
	vector<bool> col(W, false);

  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(a.at(i).at(j)== '#'){
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }

  for(int i=0;i<H;i++){
    if(row[i]) {
      for(int j=0;j<W;j++) {
        if(col[j]) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X,Y;
  cin >> X >> Y;
  
  X = (4 - X) * 100000;
  Y = (4 - Y) * 100000;
  
  if(X <= 0){
  	X = 0;
  }
  if(Y <= 0){
  	Y = 0;
  }
  if(X == 300000 && Y == 300000){
  	cout << X+Y+400000 << endl;
  }else{
  	cout << X+Y << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def GCD(a, b):
    # a < b
    if a == 0:
        return b
    else:
        return GCD(b % a, a)


def solve(N: int, X: int, x: "List[int]"):
    y = [abs(item-X) for item in x]
    ans = y[0]
    for a in y:
        ans = GCD(a, ans)

    print(ans)
    return


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


if __name__ == '__main__':
    main()


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

using namespace std;

int T1, T2;
long long A1, A2, B1, B2, P, Q;
int main()
{
    cin >> T1 >> T2;
    cin >> A1 >> A2;
    cin >> B1 >> B2;
    P = (A1 - B1) * T1;
    Q = (A2 - B2) * T2;
    if(P > 0){
        P *= -1;
        Q *= -1;
    }
    if( P + Q < 0){
        cout << 0 << endl;
    }
    else if(P + Q == 0)
    {
        cout << "infinity" << endl;
    }
    else
    {
        long long int S = (-P) / (P+Q);
        long long int T = (-P) % (P+Q);
        if (T!=0)
            cout << S * 2+1 << endl;
        else
            cout << S * 2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import collections
import sys
import numpy as np
input = sys.stdin.readline
table = collections.defaultdict(set)
N = int(input())
S = [list(input().rstrip()) for i in range(N)]
T = [[""] * (N*2) for i in range(2*N)]
table2 = [[set() for j in range(N)] for i in range(N)]

for i in range(2*N):
    if i < N:
        T[i] = S[i] + S[i]
    else:
        T[i] = S[i - N] + S[i-N]
ans = 0
T = np.array(T)
for i in range(N):
    tmp = T[0:N, i:i+N]
    if (tmp == tmp.T).all():
        ans += N

    tmp = T[i+1:i+N+1, N-1-i:2*N-1-i]
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;

int main(void) {
    ll count = 0;
    ll N;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        while(temp % 2 == 0) {
            count++;
            temp /= 2;
        }
    }
    cout << count << endl;
    return 0;
}


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


int main() {
  int N; cin >> N;
  vector<tuple<string, int, int>> t(N);
  rep(i, N) cin >> get<0>(t[i]) >> get<1>(t[i]);
  rep(i, N) get<1>(t[i]) = 100 - get<1>(t[i]);
  rep(i, N) get<2>(t[i]) = i+1;
  
  sort(t.begin(), t.end());
  
  rep(i, N) cout << get<2>(t[i]) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      if (!(x % 3 == 0 || x % 5 == 0)) {
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
import fractions
import math
#gcd = math.gcd
gcd = fractions.gcd
n, m = [int(_) for _ in input().split()]
a = sorted([int(_) // 2 for _ in input().split()])
lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
    if lcm > 10**10:
        print(0)
        exit()
for b in a:
    if (lcm // b) % 2 == 0:
        print(0)
        exit()
ans = m // lcm
if ans % 2 == 0:
    ans -= 1
if ans < 0:
    print(0)
    exit()
print(ans // 2 + 1)


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

int n;
int A[100100];
ll mem[100100];
int dp(int at){
 	if(at == n-1) return 0;
  	if(at >= n) return 100000000;
  if(mem[at] != -1) return mem[at];
  return mem[at] = min(abs(A[at]-A[at+1]) + dp(at+1), abs(A[at]-A[at+2]) + dp(at+2));
}

int main(){
  	cin >> n;
  	memset(mem,-1,sizeof(mem));
  	for(int i = 0; i < n; i++) cin >> A[i];
  	cout << dp(0);
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>

using namespace std;

int main()
{
    using ull = unsigned long long;
    auto keta = [](ull i) {
        decltype(i) k = 0;
        while (i > 0)
        {
            ++k;
            i /= 10;
        }
        return k;
    };
    auto f = [&keta](ull a, ull b) {
        return max(keta(a), keta(b));
    };

    ull N;
    cin >> N;

    // 素因数分解
    vector<ull> primes;
    ull i = 2;
    while (N >= i * i)
    {
        if (N % i == 0)
        {
            N /= i;
            primes.push_back(i);
        }
        else
        {
            ++i;
        }
    }
    primes.push_back(N);

    ull min_f = INT_MAX;
    int dim = primes.size();
    for (int i = 0; i < (1 << dim); ++i)
    {
        bitset<32> bit(i);
        ull a = 1;
        ull b = 1;
        for (int j = 0; j < dim; ++j)
        {
            if (bit[j])
            {
                a *= primes[j];
            }
            else
            {
                b *= primes[j];
            }
        }
        min_f = min(min_f, f(a, b));
    }
    cout << min_f << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int, input().split()))
    for i in range(1, n):
        a[i] += a[i - 1]
    ans = float("inf")
    for i in range(n - 1):
        ans = min(ans, abs(a[-1] - 2 * a[i]))
    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 30680
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll maxn=2e5+1;
void solve()
{
	ll N;
	cin>>N;
	ll a[maxn],sum=0;
	for(ll i=0;i<N;i++)
	{
		cin>>a[i];
		sum+=a[i];
	}
	ll prefix=0,ans=4e18;
	for(ll i=1;i<N;i++)
	{
		prefix=prefix+a[i-1];
		ll suffix=sum-prefix;
		ll d=abs(suffix-prefix);
		ans=min(d,ans);
	}
	cout<<ans<<"\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1,p=0;
	//cin>>T;
	do
	{
		solve();
		p++;
	}while(p<T);
	return 0;
}



Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            int m = N / 4;
            string ans = "No";
            if (m != 0)
            {
                for(var i = 0; i <= m; i++)
                {
                    int r = N - 4 * i;
                    if (r % 7 == 0) 
                    {
                        ans = "Yes";
                    }
                }
            }
            
            Console.WriteLine(ans);

            Console.Out.Flush();
        }
    }
    


    public class Calculation
    {

    }

    public class Graph
    {

    }
}
    

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(){
  int N;
  cin >>N;
  
  vector<string> W(N);
  map<string,int> mp;
  rep(i,0,N){
    cin >> W[i];
    mp[W[i]]++;
  }
  
  string ans = "Yes";
  rep(i,1,N){
    if(mp[W[i]]>1) ans = "No";
    else if(W[i][0]!=W[i-1][W[i-1].size()-1]) ans = "No";
  }
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    ll n, m; cin >> n >> m;
    vector<ll> p(m);
    vector<string> s(m);
    rep(i, m) cin >> p[i] >> s[i];
    vector<ll> a(n);
    vector<bool> b(n);
    rep(i, n) a[i] = 0;
    rep(i, n) b[i] = false;
    rep(i, m) {
        if(s[i] == "AC") {
            b[p[i]-1] = true;
        }
        else if(s[i] == "WA" && !b[p[i]-1]) {
            a[p[i]-1]++;
        }
    }
    ll sei = 0;
    ll pe = 0;
    rep(i, n) if(b[i]) sei++;
    rep(i, n) {
        if(b[i]) pe += a[i];
    }
    cout << sei << ' ' << pe << endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int ans = k;
    for (int i = 0; i < n - 1; ++ i) {
        ans *= k - 1;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, j;
  int sum = 0;
  
  cin >> N;
  
  vector<int> a(N);
  
  for (i = 0; i < N; i++) cin >> a.at(i);

  int max = 0;
  int maxj = 0;
  
  for (i = 0; i < N; i++) {
    if (i % 2 == 1) {
      for (j = 0; j < N; j++) {
        if (max < a.at(j)) {
          max = a.at(j);
          maxj = j;
        }
      }
      sum -= max;
      a.at(maxj) = 0;
      max = 0;
    }
    if (i % 2 == 0) {
      for (j = 0; j < N; j++) {
        if (max < a.at(j)) {
          max = a.at(j);
          maxj = j;
        }
      }
      sum += max;
      a.at(maxj) = 0;
      max = 0;
    }
  }
  
cout << sum << endl;
  
}

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

char str[MAX];

int main(void)
{
	int N;
	cin >> N;
	cin >> str;
	int ans = 1;
	for (int i = 1; i < N; i++) ans += (str[i] != str[i - 1]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n,q; cin>>n>>q;
    vector<vector<ll>> edge(n+1);
    rep(i,n-1){
        ll a,b; cin>>a>>b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    vector<ll> res(n+1,0);
    rep(i,q){
        ll p,x; cin>>p>>x;
        res[p]+=x;
    }
    map<ll,ll> used;
    queue<ll> que;
    que.push(1);
    while(!que.empty()){
        ll node=que.front();
        que.pop();
        used[node]=1;
        for(ll i: edge[node]){
            if(used[i]==0){
                que.push(i);
                res[i]+=res[node];
            }
        }
    }
    rep(i,n) cout<<res[i+1]<<' ';
    cout<<endl;
    return 0;
}


Measured memory_bytes: 30448
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)


def solve(N, l):
    nt, nx, ny = 0, 0, 0
    for i in range(len(l)):
        t, x, y = l[i]
        a = abs(x - nx) + abs(y - ny)
        k = t - nt
        if (k >= a and k % 2 == a % 2):
            pass
        else:
            return False
    return True


def main():
    
    N = int(input())
    l = []
    for i in range(0, N):
        t, x, y = map(int, input().split())
        l.append((t, x, y))
    print("Yes" if solve(N, l) else "No")


if __name__ == '__main__':
    main()


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

int main()
{
    int N;
    cin >> N;
    int NN = N;
    int fx = 0;
    while(NN > 0){
        fx += NN % 10;
        NN /= 10;
    }
     if(N % fx == 0){
         cout << "Yes";
     }
     else
     {
         cout << "No";
     }
}

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

priority_queue<int> pq;

signed main(){
    int n, m;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        pq.push(x);
    }
    for(int i=0;i<m;i++){
        int x = pq.top();
        pq.pop();
        pq.push(x/2);
    }
    int ans = 0;
    while(!pq.empty()){
        int x = pq.top();
        pq.pop();
        ans += x;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}

int main() {
  Int n;
  cin >> n;
  vector<Int> as(n + 1);
  for (Int i = 1; i <= n; i++) cin >> as[i];

  vector<Int> bs(n + 1, 0), cs;
  for (Int i = n; i >= 1; i--) {
    Int sum = as[i];
    for (Int j = i + i; j <= n; j += i) sum += bs[j];
    bs[i] = sum % 2;
    if (bs[i]) cs.emplace_back(i);
  }

  Int m = cs.size();
  cout << m << endl;
  for (Int i = 0; i < m; i++) {
    if (i) cout << " ";
    cout << cs[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 7260
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
const ll LINF = 1e18;
const int INF = 1e9;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,y;
    cin >> x >> y;
    for(int i=0;i<=x;i++){
        if(2*i+4*(x-i)==y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main()
{
    int bingo[3][3], grid[3][3];
    for (int in1 = 0; in1 < 3; in1++)
    {
        for (int in2 = 0; in2 < 3; in2++)
        {
            cin >> bingo[in1][in2];
            grid[in1][in2] = 0;
        }
    }

    int n;
    cin >> n;
    for (int in = 0; in < n; in++)
    {
        int x;
        cin >> x;

        for (int in1 = 0; in1 < 3; in1++)
            for (int in2 = 0; in2 < 3; in2++)
                if (bingo[in1][in2] == x)
                    grid[in1][in2] = 1;
    }

    for (int i = 0; i < 3; i++)
    {
        if (grid[i][0] && grid[i][1] && grid[i][2]) 
        {
            cout << "Yes\n";
            return 0;
        }
        if (grid[0][i] && grid[1][i] && grid[2][i]) 
        {
            cout << "Yes\n";
            return 0;
        }
    }
    if (grid[0][0] && grid[1][1] && grid[2][2]) 
    {
        cout << "Yes\n";
        return 0;
    }
    if (grid[2][0] && grid[1][1] && grid[0][2]) 
    {
        cout << "Yes\n";
        return 0;
    }

    cout << "No\n";
}

Measured memory_bytes: 3592
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int total = 0;
    int bigger = 0;
    int smaller = 0;
    for (int i = 0; i < A; i++) {
      int B = sc.nextInt();
      int C = sc.nextInt();
      bigger = Math.max(B, C);
      smaller = Math.min(B, C);
      total += bigger - smaller + 1;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 26344
#include <stdio.h>
#include <cstdlib>
#include <cassert>
#include <iostream>
#include <set>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <map>
#include <queue>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef long double ld;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<pii> vii;
typedef vector<string> vs;
//typedef long long int;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  string s;
  cin >> s;
  vi v(26);
  for (int i = 0; i < s.size(); ++i) v[s[i] - 'a']++;
  ll n = s.size();
  ll res = 0;
  for (int i = 0; i < v.size(); ++i) res += v[i] * (n - v[i]);
  cout << res / 2 + 1 << endl;
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i ++) {
    cin >> a.at(i) >> b.at(i);
  }

  vector<int> c(n + 1);
  for (int i = 1; i <= n; i ++) {
    for (int j = 0; j < m; j ++) {
      if (i == a.at(j)) {
        c.at(i) ++;
      }
      if (i == b.at(j)) {
        c.at(i) ++;
      }
    }
  }

  for (int i = 1; i <= n; i ++) {
    cout << c.at(i) << endl;
  }
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
def euc(x,y):
  x,y=max(x,y),min(x,y)
  if x%y==0:
    return y
  else:
    return euc(y,x%y)
k=a[0]
for i in range(1,n):
  k=euc(a[i],k)
print(k)


Measured memory_bytes: 62704
use std::io::stdin;

fn main() {
    let n = {
        let mut s = String::new();
        stdin().read_line(&mut s).unwrap();

        let n: i32 = s.trim_right().parse().unwrap();
        n
    };

    for i in 1..10 {
        let a = n % i;
        if a == 0 && n / i < 10 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const int maxn=200010;
typedef long long ll;
const ll INF=9000000000000000;
ll sum[maxn],sum2[maxn],a[maxn],s[100],s2[100],tmp[100],tmpsum2[maxn];
int hf(int l,int r,int now)
{
    if (now>=l&&now<=r-1) return 1;
    return 0;
}
int main()
{
   // freopen("text.in","r",stdin);
    int i,n,j,l,m,k,k2,top,top2;
    ll ans,ma,mi,num,num2;
    scanf("%d",&n);
    for (i=1;i<=n;i++) {
        scanf("%lld",&a[i]);
    }
    memset(sum,0,sizeof(sum));
    memset(sum2,0,sizeof(sum2));
    for (i=1;i<=n;i++) {
        sum[i]=sum[i-1]+a[i];
    }
    for (i=n+1;i>=1;i--) {
        sum2[i]=sum2[i+1]+a[i];
    }
    for (i=1;i<=n;i++) {
        tmpsum2[i]=sum2[n-i+1];
    }
    /*for (i=1;i<=n;i++) {
        printf("%lld ",sum2[i]);
    }
    printf("\n");*/
    ans=INF;
    for (i=2;i<=n-2;i++) {
        //printf("i=%d\n",i);
        num=sum[i]; num2=sum2[i+1];
        //printf("num==%lld num2=%lld\n",num,num2);
        num=num/2; num2=num2/2;
        //printf("2===num==%lld num2=%lld\n",num,num2);
        top=0; top2=0;
        k=lower_bound(sum+1,sum+n+1,num)-sum;
        for (j=-1;j<=1;j++) {
            if (hf(1,i,k+j)) s[++top]=k+j;
        }
        //printf("k==%d\n",k);
        k2=lower_bound(tmpsum2+1,tmpsum2+n+1,num2)-tmpsum2;
        k2=n-k2+1;
        //k2=lower_bound(sum2+i+1,sum2+n+1,num2)-sum2;
        //printf("k2==%d\n",k2);
        for (j=-1;j<=1;j++) {
            if (hf(i+1,n,k2+j)) s2[++top2]=k2+j;
        }
        /*for (j=1;j<=top2;j++) {
            printf("s2==%lld\n",s2[j]);
        }*/
        for (j=1;j<=top;j++) {
            for (l=1;l<=top2;l++) {
                tmp[1]=sum[s[j]]; tmp[2]=sum[i]-sum[s[j]];
                tmp[3]=sum[s2[l]]-sum[i]; tmp[4]=sum[n]-sum[s2[l]];
                ma=0; mi=INF;
                for (m=1;m<=4;m++) {
                    ma=max(ma,tmp[m]);
                    mi=min(mi,tmp[m]);
                }
                ans=min(ans,ma-mi);
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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



int main()
{
	int N ,M ;
	
	while( 1 )
	{
		int p ;
		int way[ 1000 + 1 ] = { 0 } ;

		scanf( "%d %d" ,&N ,&M ) ;

		if( N | M )
		{
			int i ;
			for( i = 0 ; i < N ; ++i )
			{
				scanf( "%d" ,&p ) ;

				way[ i ] = i + p ;
			}

			for( i = 1 ,p = 0 ; i <= M ; ++i )
			{
				int input ;
				scanf( "%d" ,&input ) ;

				if( p > INT_MIN )
				{
					if( p + input + 1 >= N )
					{
						p = N ;
					}

					else
					{
						p = way[ p + input ] ;
					}


					if( p + 1 >= N )
					{
						printf( "%d\n" ,i ) ;

						p = INT_MIN ;
					}
				}
			}
		}

		else
		{
			return 0 ;
		}
	}
}

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

using namespace std;

const int MOD = 1e9 + 7;

const int N = 1e6 + 5;
vector<int> pf[N];
void sieve() {
    for (int i = 2 ;i < N ;i++)
        if (!pf[i].size())
            for (int j = i ;j < N ;j += i)
                pf[j].push_back(i);
}

int add (int a , int b) {
    a += b;
    while (a >= MOD) a -= MOD;
    while (a < 0) a += MOD;
    return a;
}

long long mul(long long a , long long b) {
    return a * b % MOD;
}

long long power(long long a , long long b) {
    if (!b) return 1;
    long long r = power(a , b / 2);
    r = mul(r , r);
    if (b&1) return mul(r , a);
    return r;
}

long long mod_inv(long long x) {
    return power(x , MOD - 2);
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    sieve();

    int n;
    cin >> n;

    map<int , int> mx;

    vector<int> a(n);
    for (int i = 0 ;i < n ;i++) {
        cin >> a[i];
        auto &v = pf[a[i]];
        for (int x : v) {
            int org = a[i] , cnt = 0;
            while (org % x == 0)
                org /= x , cnt++;

            mx[x] = max(mx[x] , cnt);
        }
    }

    int lcm = 1;
    for (auto &p : mx)
        lcm = mul(lcm , power(p.first , p.second));

    int ans = 0;
    for (int i = 0 ;i < n ;i++) {
        auto &v = pf[a[i]];
        int m = 1;
        for (int x : v) {
            int org = a[i] , cnt = 0;
            while (org % x == 0)
                org /= x , cnt++;
            m = mul(m , power(x , cnt));
        }
        ans = add(ans , mul(lcm , mod_inv(m)));
    }

    cout << ans;
}

Measured memory_bytes: 59468
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i,j;
	ll dp[3][123456],t=1ll;;
	fill(dp[0],dp[3],0ll);
	string s;
	cin >> s;
	n=s.l_ength();
	for(i=0;i<n;++i){
		for(j=0;j<3;++j){
			dp[j][i+1] = dp[j][i];
			if(s[i]=='?'){
				mul_mod(dp[j][i+1],3ll);
			}
			if(s[i]=='A'+j||s[i]=='?'){
				add_mod(dp[j][i+1],(j)?dp[j-1][i]:t);
			}
		}
		if(s[i]=='?'){
			mul_mod(t,3ll);
		}
	}
	cout << dp[2][n] << endl;
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main{
	public static void main(String[]args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int a1,a2,a3,a4,a5;
		int count=0;
		for(int i=a;i<=b;i++){
			a1=i/10000;
			a2=i/1000-a1*10;
			a3=i/100-a1*100-a2*10;
			a4=i/10-a1*1000-a2*100-a3*10;
			a5=i-a1*10000-a2*1000-a3*100-a4*10;
			if(a1==a5 && a2==a4){
				count++;
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 23380
#include<iostream>

using namespace std;

int main(){
    int a, b;
    double c;
    cin >> a >> b;
    c = (double) (b - 1)/(a - 1);
    if(c == (b - 1)/(a - 1)) cout << (b - 1)/(a - 1) << endl;
    else cout << (b - 1)/(a - 1) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int dp[N],ans=-1;
int n,m,x[N],y[N];
vector<int>vf[N],vb[N],e,v[N];
bool f[N];
int dfs(int now)
{
	if(dp[now]==-1){
		if(v[now].empty())
		{
			dp[now]=0;
			return dp[now];
		}
		int res=-1;
		for(int i=0;i<v[now].size();i++)
			res=max(res,dfs(v[now][i])+1);
		dp[now]=res;
		return res;
	}
	else
		return dp[now];
}
int main()
{
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=m;i++)
	{
		cin>>x[i]>>y[i];
		v[x[i]].push_back(y[i]);
		f[y[i]]=true;
	}
	for(int i=1;i<=n;i++)
		if(!f[i])
			ans=max(ans,dfs(i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 16384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

constexpr int MOD = 998244353;

int main(void){
    Cin(int, a, b, c, d);
    vc<vc<array<ll, 3>>> dp(c+1, vc<array<ll, 3>>(d+1));
    // 1
    // 0 2
    
    dp[a][b][0] = 1;
    for(int i = a+1; i <= c; i ++){
        dp[i][b][0] = dp[i-1][b][0] * b % MOD;
    }
    for(int j = b+1; j <= d; j ++){
        dp[a][j][0] = dp[a][j-1][0] * a % MOD;
    }
    
    for(int i = a+1; i <= c; i ++){
        for(int j = b+1; j <= d; j ++){
            dp[i][j][0] = (dp[i-1][j][0] + dp[i-1][j][1]) % MOD * (j-1) % MOD;
            dp[i][j][1] = (dp[i][j-1][0] + dp[i][j-1][2] + dp[i][j-1][1] * i % MOD) % MOD;
            dp[i][j][2] = (dp[i-1][j][0] + dp[i-1][j][1] + dp[i-1][j][2] * j % MOD) % MOD;
        }
    }
    /*For(i, c+1){
        For(j, d+1){
            cout << dp[i][j][0] << " " << dp[i][j][1] << " " << dp[i][j][2] << " | ";
        }
        Cout();
    }*/
    Cout((dp[c][d][0] + dp[c][d][1] + dp[c][d][2]) % MOD);
}


Measured memory_bytes: 214368
n = int(input())
st = [list(map(str, input().split())) for _ in range(n)]
x = input()
ans = 0
sleep = 0
for i in range(n):
    if sleep == 1:
        ans += int(st[i][1])
    if st[i][0] == x:
        sleep = 1
print(ans)
   

Measured memory_bytes: 3060
#include<stdio.h>
#define N 1000
int main(){
  int A[N];
  int i,key,j,n,k;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d",A[n-1]);
  printf("\n");
  for(i = 1;i<=n-1;i++){
    key = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > key)
      {
	A[j+1] = A[j];
	j--;
	A[j+1] = key;
      }
    for(k=0;k<n-1;k++){
      printf("%d ",A[k]);
    }
    printf("%d",A[k]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2060
N = int(input())
S = input()

ct_sum = []
ct_E, ct_W = 0, 0
for i in S:
    if i == 'E':
        ct_E += 1
    else:
        ct_W += 1
    ct_sum.append((ct_E, ct_W))

Max = 0
for i in range(N):
    if i == 0:
        E_l = 0
    else:
        E_l = ct_sum[i-1][0]
    W_i, W_e = ct_sum[i][1], ct_sum[N-1][1]
    W_r = W_e - W_i
    ct = E_l + W_r
    Max = max(Max, ct)

ans = N-1 - Max

print(ans)

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

using namespace std;

typedef long long int LL;

LL q, h, s, d, n, ans;

int main() {
  cin >> q >> h >> s >> d >> n;
  if (2 * q < h) {
    h = 2 * q;
  }
  if (2 * h < s) {
    s = 2 * h;
  }
  if (2 * s < d) {
    d = 2 * s;
  }
  if (n >= 2) {
    ans = (n / 2) * d;
  }
  if (n % 2 == 1) {
    ans += s;
  }
  cout << ans;
}


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

#define print(a)        for (auto x : a) cout << x << " "; cout << endl
#define print_upto(a,n)        for(int i=0;i<n;i++)    cout<<a[i]<<" "; cout<<endl
#define take(x,n)           for(int i=0;i<n;i++)  cin>>x[i];

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll, ll> pll;
typedef map< ll, ll> mll;


int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt" , "w" , stderr);
#endif

	ll n;
	cin >> n;

	vector<ll> add, sub;

	for (ll i = 1; i <= n; i++) {
		ll a, b;
		cin >> a >> b;

		add.pb(a + b);
		sub.pb(a - b);
	}

	sort(add.begin(), add.end());
	sort(sub.begin(), sub.end());

	ll ans = max( add[n - 1] - add[0] , sub[n - 1] - sub[0] );

	cout << ans << nl;


	return 0;
}


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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL x=100,n;
    cin>>n;
    LL cnt=0;
    while(x<n)
    {
        cnt++;
        x+=x/100;
    }
    cout<<cnt;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<'='<<x<<endl
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    a=a%MOD;
    while(b>0){
        if(b&1){res=(res*a)%MOD;b--;}
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int h,w,i=0,j=0,k=0,m,n,p,e,f,sum=0,cnt=0;
	cin>>n;
	vi arr,joo;
	for(i=0;i<n;i++)
	{
	    cin>>j;
	    arr.pb(j);
	}
    sort(arr.rbegin(),arr.rend());
    joo.pb(arr[0]);
    for(i=1;i<arr.size();i++)
    {
        joo.pb(arr[i]);
        joo.pb(arr[i]);
    }
    for(i=0;i<n-1;i++)
    sum+=joo[i];
    cout<<sum;
	
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

Measured memory_bytes: 8944
import sys
sys.setrecursionlimit(2*10**9)

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

adj_list = [[] for _ in range(N)]
counter = [0 for _ in range(N)]
reached = [0 for _ in range(N)]

for _ in range(N-1):
    a,b = map(int,input().split())
    a-=1
    b-=1
    adj_list[a].append(b)
    adj_list[b].append(a)

def df(current, score):
    next_nodes = adj_list[current]
    reached[current]=1
    for node in next_nodes:
        if reached[node]==0:
            counter[node]+=score
            df(node, counter[node])

for _ in range(Q):
    p,x=map(int, input().split())
    counter[p-1]+=x
df(0, counter[0])
print(*counter)


Measured memory_bytes: 234692
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

pair<int, int> fact(int i)
{
    pair<int, int> p;
    p.second = i % 10;
    
    int n = i;
    while(i/10) {
        i /= 10;
    }
    p.first = i;

    return p;
}

void solve(int i, map<pair<int, int>, int> &num)
{
    num[fact(i)]++;
}


int main(void)
{
    int n;
    cin >> n;
    map<pair<int, int>, int> num;

    irep2(i, 1, n) {
        solve(i, num);
    }

    ll ans = 0;
    irep2(i, 1, n) {
        pair<int, int> p = fact(i);
        pair<int, int> q = make_pair(p.second, p.first); 
        ans += num[q];
    }
    cout << ans << endl;
    return 0;
}
/** atcodr **/


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  bool ok = true;
  for(int i=0; i<3; i++) if(s[i] == s[i+1]) ok = false;
  cout << (ok ? "Good" : "Bad") << "\n";

}


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

int main()
{
    int n;
    cin >> n;
    
    vector<vector<int>> vec(n, vector<int>(3));
    vector<vector<int>> dp(n, vector<int>(3,0));
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            cin >> vec[i][j];
        }
    }
    
    dp[0][0] = vec[0][0];
    dp[0][1] = vec[0][1];
    dp[0][2] = vec[0][2];

    for(int i=1; i<n; i++)
    {
        for(int j=0; j<3; j++)
        {
            for(int k=0; k<3; k++)
            {
                if(k==j) continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k] + vec[i][j]);
            }
        }
    }

    cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));

}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a+b > c+d){
    cout<<"Left"<<endl;
  }
  else if(a+b == c+d){
    cout<<"Balanced"<<endl;
  }
  else {
    cout<<"Right"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const double PI=3.1415926535;
using namespace std;
int main(){
	double a,b,x;
	scanf("%lf%lf%lf",&a,&b,&x);
	if(x>a*a*b/2)printf("%.10lf\n",atan((2.*b-(2.*x)/a/a)/a)/PI*180.);
	else printf("%.10lf\n",atan(0.5*b*b*a/x)/PI*180.);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int n = sc.nextInt();
		String[] nums = new String[n];
		for (int i = 0; i < n; i++){
			nums[i] = sc.next();
		}
		sc.close();
		for(int count = 0;;count++){
			if (!(Arrays.asList(nums).contains(String.valueOf(x-count)))){
				System.out.println(x-count);
				break;
			}
			if (!(Arrays.asList(nums).contains(String.valueOf(x+count)))){
				System.out.println(x+count);
				break;
			}
		}
	}
}


Measured memory_bytes: 27140
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();

		koch(0, 0, 100, 0, 0, n);
		System.out.format("%.4f %.4f\n", (double)100, (double)0);

    	sc.close();
	}
	
	public static void koch(double x1, double y1, double x2, double y2, int level, int n) {
		if (level == n) {
			System.out.format("%.4f %.4f\n", x1, y1);
		} else {
			double xs = (x2 - x1) / 3 + x1;
			double ys = (y2 - y1) / 3 + y1;
			double xt = (x2 - x1) * 2 / 3 + x1;
			double yt = (y2 - y1) * 2 / 3 + y1;
			double l = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) / 3;
			double theta = Math.atan2(y2 - y1, x2 - x1) + Math.PI / 3;
			double xu = xs + l * Math.cos(theta);
			double yu = ys + l * Math.sin(theta);
			
			koch(x1, y1, xs, ys, level + 1, n);
			koch(xs, ys, xu, yu, level + 1, n);
			koch(xu, yu, xt, yt, level + 1, n);
			koch(xt, yt, x2, y2, level + 1, n);
		}
	}
}

Measured memory_bytes: 36728
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
#define qr queries();
void solve();
void YN(bool b){if (b){ctn("YES");}else{ctn ("NO");}};
void yn(bool b){if (b){ctn("Yes");}else{ctn ("No");}};
void queries(){int n;cin >> n;while (n--)solve();}
// // // // // // // // // // // // // // // // // // // // // // 
/*                  TEMPLATE - VANILLA                         */
// // // // // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n;
    cin >> n;
    vec arr (n);
    for (int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int rs = 0;
    for (int i = 0; i < n; i++){
        if ((i + 1) % 2 == 1 && arr[i] % 2 == 1){
            rs++;
        }
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 3644
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static int n,S,ans;
	static int[]a;
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		while(true){
			n=cin.nextInt();
			S=cin.nextInt();
			if(n+S==0)break;
			a=new int[n];
			ans=0;
			for(int i=0;i<n;i++){
				a[i]=cin.nextInt();
			}
			Arrays.sort(a);
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					if(a[j]>S-a[i]){
						ans=ans+n-j;
						break;
					}
				}
			}
			System.out.println(ans);
			/*
			for(int i=0;i<n;i++){
				int s=Arrays.binarySearch(a,i,n, S-a[i]+1);
				if(s<0){
					s*=-1;
					s--;
					System.out.println("-");
				}
				else{
					int tmp=s;
					for(int j=s;j<n;j++){
						if(S-a[i]<a[j]){
							s=j;
							break;
						}
					}
				}
				System.out.println(s);
				ans+=n-s;
			}
			System.out.println(ans);
			*/
		}

	}

}

Measured memory_bytes: 136988
#include <bits/stdc++.h>
#include<list>
#include<algorithm>
#define ll long long int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define rep(a,b,c) for(a=b;a<c;a++)
#define repj(a,b,c) for(a=b;a<c;a++)
#define repr for(i=n-1;i>=0;i--)
#define pii pair<ll,ll>
#define pll pair<ll, ll>
#define inf 100000001
const double pie  =3.141592653589793238463;
#define mod 1000000007
#define lb lower_bound
#define up upper_bound
#define rep1 for(i=1;i<=n;i++)
#define vr vector
#define POP(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define ef else if
#define all(x) (x).begin(), (x).end()
#define SORT(A) sort(A.begin(),A.end());
#define REV(A) reverse(A.begin(), A.end());
#define lenth length()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n" 
const ll dx[4] = { -1, 1, 0, 0};
const ll dy[4] = {0, 0, -1, 1};
ll XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
ll YY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
#define precise(x) cout<<fixed<<setprecision(x)
#define t1(x)                cerr<<#x<<": "<<x<<endl
#define t2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define t4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define t5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define t6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
using namespace std;
void SieveOfEratosthenes(ll n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (ll p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (ll i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // for (ll p=2; p<=n; p++) 
       // if (prime[p]) 
          // cout << p << " "; 
} 

ll power(ll x, ll y) 
{ 
    ll res = 1; 
    while (y > 0) 
    { 
        if (y & 1) 
            res = res * x; 
        y = y >> 1; 
        x = x * x; 
    } 
    return res; 
}
int main()
{
    fastio
    ll t,i,j,k,l,m,n,a,x,b,y,z,c,h,d,e,p,nl,np,q,r;

    string s;
    ll mx = INT_MIN;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
    {
        cout<<1<<endl;
    }
    else if(b==0)
    {
        cout<<2<<endl;
    }
    else if(c==0)
    {
        cout<<3<<endl;
    }
    else if(d==0)
    {
        cout<<4<<endl;
    }
    else
        cout<<5<<endl;


}

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

ll mod = 1e9+7;
vector<ll> fac(1000010);
vector<ll> ifac(1000010);

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

ll comb(ll a, ll b){
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0) return 0;
    ll tmp = ifac[a-b] * ifac[b] % mod;
    
    //printf("comb(%lld,%lld) : %lld\n",a,b,(tmp * fac[a]) % mod);
    return tmp * fac[a] % mod;
}

void calc(){
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i < 1000008; i++){
        fac[i+1] = fac[i] * (i+1) % mod;
        ifac[i+1] = ifac[i]*mpow(i+1,mod-2) % mod;
    }
}

int main(){
    calc();
    ll n;
    cin >> n;
    ll ans = 1;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }else if(n == 2){
        cout << 2 << endl;
        return 0;
    }
    

    ans = (mpow(10,n)) % mod;
    ll tmp = (mpow(9,n)+mpow(9,n))%mod;
    tmp = (tmp + mod - mpow(8,n))%mod;
    ans = (ans + mod - tmp)%mod;

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


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

int main() {
  int a,b,c;
  string ans = "YES";
  cin >> a >> b >> c;

  for(int i = 1; i < 1000; i++)
    if(a*i % b == c) goto Exit;
  
  ans = "NO";
  Exit: ;
  cout << ans << endl;
}

Measured memory_bytes: 3564
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
 
int main(void)
{
    int n, k,a=1;
    cin >> n >> k;
    for(int i = 0;i < n;i++){
        if(2*a <= a+k)
            a *=2;       
        else
            a +=k;  
    }
    cout << a << endl;
}

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


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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).length()%2 == 1) ans++;
    }

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


Measured memory_bytes: 3704