akhauriyash/Code-Regression huggingface dataset:
function pint(s)   { return parseInt(s);   }
function pfloat(s) { return parseFloat(s); }
function even(s)   { return (s % 2) === 0; }
function odd(s)    { return (s % 2) === 1; }
Array.prototype.sortNumAsc  = function ()  { return this.sort((a, b) => (a - b)); }
Array.prototype.sortNumDesc = function ()  { return this.sort((a, b) => (b - a)); }
Array.prototype.sortStrAsc  = function ()  { return this.sort();                  }
Array.prototype.sortStrDesc = function ()  { return this.sort().reverse();        }
Array.prototype.without     = function (x) { return this.filter(e => e !== x);    }
function main(lines) {
  var arr = lines[0].split(' ').map(pint);
  var H = arr[0];
  var W = arr[1];
  var K = arr[2];
  var S = [];
  var stage = lines.slice(1).map(l => l.split(''));
  outer: for (var h = 0; h < H; h++) {
    for (var w = 0; w < W; w++) {
      if (stage[h][w] === 'S') {
        S = [[h, w]];
        break outer;
      }
    }
  }
  for (var i = 0; i < K; i++) {
    var N = [];
    for (var s = 0, l = S.length; s < l; s++) {
      var hw = S[s];
      var h = hw[0];
      var w = hw[1];
      var p = 4;
      while (p--) {
        var nh, nw;
        switch(p) {
          case 3:
            nh = h-1; nw = w;
            break;
          case 2:
            nh = h+1; nw = w;
            break;
          case 1:
            nh = h; nw = w-1;
            break;
          case 0:
            nh = h; nw = w+1;
            break;
        }
        if (0 <= nh && nh < H &&
            0 <= nw && nw < W &&
            (stage[nh][nw] === '.')
        ) {
          stage[nh][nw] = 'S';
          N.push([nh, nw]);
        }
      }
    }
    S = N;
  }
  var minimum = Infinity;
  outer: for (var h = 0; h < H; h++) {
    for (var w = 0; w < W; w++) {
      var p = stage[h][w];
      if (p === 'S') {
        var step = Math.min(w, h, W-1-w, H-1-h);
        if (step === 0) {
          minimum = 1;
          break outer;
        }
        minimum = Math.min(minimum, Math.ceil(step / K) + 1);
      }
    }
  }
  console.log(minimum);
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n').map(l => l.trim()));

Measured memory_bytes: 28476
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> dp(100020, INF);
  dp.at(0) = 0;
  for (ll i = 0; i <= N; ++i) {
    dp.at(i + 1) = min(dp.at(i + 1), dp.at(i) + 1);\
    ll cnt  = 1;
    while (i + pow(6, cnt) <= N) {
      dp.at(i + pow(6, cnt)) = min(dp.at(i + pow(6, cnt)), dp.at(i) + 1);
      cnt += 1;
    }
    cnt = 1;
    while (i + pow(9, cnt) <= N) {
      dp.at(i + pow(9, cnt)) = min(dp.at(i + pow(9, cnt)), dp.at(i) + 1);
      cnt += 1;
    }
    dp.at(i + 9) = min(dp.at(i + 9), dp.at(i) + 1);
  }
  cout << dp.at(N) << endl;
}


Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
        int i;
        ArrayList<String> out = new ArrayList<>();
        String beforeString = "Hoshino";
        String afterString = "Hoshina";
        int numDataRaws;
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        try { // read num of dataRaws
            line = input.readLine();
        } catch (IOException e1) {
            System.out.println("IOException in first raw");
        }
        numDataRaws = Integer.parseInt(line);

        try {
            for (i = 0; i < numDataRaws; i++) {
                line = input.readLine();
                out.add(line.replace(beforeString, afterString));
            }
        } catch (NumberFormatException e) {
            System.out.println(line + " include not int");
        } catch (IOException e) {
            System.out.println("IOException in raws after first");
        }

        for (String raw : out) {
            System.out.println(raw);
        }
    }

}


Measured memory_bytes: 24572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(){
    char n[256]; scanf("%s", n);
    int sum=0;
    for(int i=0;i<strlen(n);i++){
        sum += n[i] - '0';
    }

    printf("%s\n", atoi(n) % sum ==0? "Yes":"No");

}

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

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

void Main(){
  int N; cin >> N;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  map<int, int> m;
  rep(i, 0, N){
    if (m.find(a[i]) == m.end()){
      m.insert(make_pair(a[i], 1));
    }
    else{
      m[a[i]]++;
    }
  }
  ll res = 0;
  for(auto &el : m){
    if(el.first > el.second) res += el.second;
    else if(el.first < el.second) res += el.second - el.first;
  }
  cout << res << endl;
}

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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int>v[(int)2e5+9];
int cnt;
bool visited[(int)2e5+9];
void dfs(int x)
{
    visited[x]=1;
    cnt++;
    for (auto child:v[x])
    {
        if (!visited[child])
            dfs(child);
    }
}
int main()
{
    FASTINOUT;
    int x,m;
    cin>>x>>m;
    int l,r;
    for (int i=0; i<m; i++)
    {
        cin>>l>>r;
        v[l].push_back(r);
        v[r].push_back(l);
    }
    int ans=0;
    for (int i=1; i<=x; i++)
    {
        if (!visited[i])
            dfs(i),ans=max(ans,cnt),cnt=0;
    }
    cout<<ans;
    return 0;
}


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

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

struct SHEET{
    int num;
    bool flag = false;
};

using namespace std;

int main(void)
{ 
    struct SHEET sheet[9];
    int N = 0;
    bool bingo = false;
    
    rep(i, 9){
        cin >> sheet[i].num;
        sheet[i].flag = false;
    }

    cin >> N;

    int in[N];

    rep(i, N){
        cin >> in[i];
    }

    rep(i, N){
        rep(j, 9){
            if(in[i] == sheet[j].num){
                sheet[j].flag = true;
            }
        }
    }

    // 縦 
    if(
        (sheet[0].flag == true) &&
        (sheet[3].flag == true) &&
        (sheet[6].flag == true)
    )
    {
        bingo = true;
    }

    if(
        (sheet[1].flag == true) &&
        (sheet[4].flag == true) &&
        (sheet[7].flag == true)
    )
    {
        bingo = true;
    }

    if(
        (sheet[2].flag == true) &&
        (sheet[5].flag == true) &&
        (sheet[8].flag == true)
    )
    {
        bingo = true;
    }

    // 横 
    if(
        (sheet[0].flag == true) &&
        (sheet[1].flag == true) &&
        (sheet[2].flag == true)
    )
    {
        bingo = true;
    }

    // 横 
    if(
        (sheet[3].flag == true) &&
        (sheet[4].flag == true) &&
        (sheet[5].flag == true)
    )
    {
        bingo = true;
    }

    // 横 
    if(
        (sheet[6].flag == true) &&
        (sheet[7].flag == true) &&
        (sheet[8].flag == true)
    )
    {
        bingo = true;
    }

    // ななめ 
    if(
        (sheet[0].flag == true) &&
        (sheet[4].flag == true) &&
        (sheet[8].flag == true)
    )
    {
        bingo = true;
    }

    // 横 
    if(
        (sheet[2].flag == true) &&
        (sheet[4].flag == true) &&
        (sheet[6].flag == true)
    )
    {
        bingo = true;
    }

    if(bingo){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;        
    }

    return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
struct edge { int to, cost; };
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int a, b, m;
int aa[114514];
int bb[114514];
int x[114514], y[114514], z[114514];
int ss[114514];
signed main() {
	cin >> a >> b >> m;
	rep(i, a)cin >> aa[i];
	rep(i, b)cin >> bb[i];
	rep(i, m)cin >> x[i] >> y[i] >> z[i];
	rep(i, m)ss[i] = aa[x[i] - 1] + bb[y[i] - 1] - z[i];
	sort(ss, ss + m);
	sort(aa, aa + a);
	sort(bb, bb + b);
	cout << min(ss[0], aa[0] + bb[0]) << endl;
	ggr
}


Measured memory_bytes: 6144
//                                    ∴In the name of God∴
//                     ✫✗⚡😳😳😄😄😝😝😁😁😎😎😛😛😄😄😮😮⚡✗✫
//                                       H.Pouya  ◠?◠
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<vector>
#include<math.h>
#include<bitset>
#include<iostream>
#include<algorithm>
using namespace std;
typedef short int ss;
typedef long double dd;
typedef long long int ll;
#define give_up return 0;
#define mix(x,y) x*pow(10,y)+10
const int maxn=mix(1,5);
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<(a*3+b)/2;
    give_up
}
//  🙄


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main()
		{
            var rgb = Console.ReadLine().Replace(" ", "");
            Console.WriteLine(int.Parse(rgb) % 4 == 0 ? "YES" : "NO");
#if DEBUG
			Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 11092
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  if(a==b){
    printf("%d",c);
  }
  else if(b==c){
    printf("%d",a);
  }
  else if(c==a){
    printf("%d",b);
  }
  return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    lint n,x; cin>>n>>x;
    vector<lint> a(n);
    REP(i,n) cin>>a[i];
    lint ans = 0;
    REP(i,n-1){
        if(a[i+1]+a[i]>x){
            if(a[i]>x){
                ans+=a[i+1];
                a[i+1]=0;
                ans+=a[i]-x;
                a[i]-=x;
            } else {
                ans+=a[i+1]+a[i]-x;
                a[i+1]-= a[i+1]+a[i]-x;
            }
        }
    }
    print(ans);
    return 0;
}

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

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

    if(s=="abc" || s=="acb" || s=="bac" || s=="bca" || s=="cab" || s=="cba"){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000

int main()
{
  int n; cin >> n;
  vector<int> b(n-1);
  REP(i, n-1) cin >> b.at(i);

  ll res = 0;
  res += b.at(0);
  res += b.at(n - 2);
  for (int i = 1; i <= n - 2; i++) {
    res += min(b.at(i), b.at(i - 1));
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
using System;

namespace AtCoder
{
    static class Program
    {
        static void Main()
        {
            Console.ReadLine();
            int[] nbrs = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            double[] res = new double[nbrs.Length];

            for(int i = 0; i < nbrs.Length; i++)
                res[i] = 0;

            for (int i = 0; i < nbrs.Length; i++)
                res[nbrs[i] - 1] = i + 1;

            for(int i = 0; i < res.Length; i++)
            {
                Console.Write(res[i] + " ");
            }
        }
    }
}

Measured memory_bytes: 27352
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <complex>
#include <random>
#include <bitset>
// #include <prettyprint.hpp>
using namespace std;
#define repi(i,n) for(int i=0;i<n;++i)
#define rep(i,n) for(ll i=0;i<n;++i)
#define repinvi(i,n) for(int i=n-1;i>=0;--i)
#define sll(n) scanf("%lld", &n);
#define sii(n) scanf("%d", &n);
#define slf(n) scanf("%lf", &n);
#define pll pair<ll,ll>
#define pii pair<int,int>
#define psi pair<si,si>
typedef long long ll;
typedef double lf;
typedef short int si;


void Main(){
    ll P, N;
    string S;
    sll(N);
    sll(P);
    cin >> S;

    ll ans = 0;

    if(P==2 || P==5){
        for(ll i=N-1;i>=0;i--){
            ll digit = S[i] - '0';
            if(digit % P == 0){
                ans += i+1;
            }
        }
    }else{
        vector<ll> res(P,0);

        ll tmp_res = 0;
        res[0] = 1;
        ll base10_res = 1;
        for(ll i=N-1;i>=0;i--){
            tmp_res = (tmp_res + base10_res * (S[i]-'0')) % P;
            base10_res = (10 * base10_res) % P;
            ++res[tmp_res];
            // cout << "base10 res, i=" << i << " = " << base10_res <<" tmp res=" << tmp_res <<endl;
        }

        rep(i, P){
            ans += res[i] * (res[i]-1)/ 2;
        }

        // cout << "res:" << res <<endl;


    }
    cout << ans <<endl;


}

int main(){
    Main();
}

Measured memory_bytes: 640
from operator import itemgetter
sp=[]
for i in range(int(input())):
	t=list(input().split())
	t[1]=100-int(t[1])
	t.append(i+1)
	sp.append(t)
sp=sorted(sp, key=itemgetter(0, 1))
print('\n'.join([str(i[2]) for i in sp]))

Measured memory_bytes: 3060
n = int(input())
a = input()
b = input()
c = input()

count = 0
for i in range(n):
  if a[i] == b[i]== c[i]:
    continue
  elif a[i] == b[i] or a[i] == c[i] or b[i] == c[i]:
    count += 1
  else:
    count += 2
print(count)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn gcd(mut a: i64, mut b: i64) -> i64 {
    while b != 0 {
        let r = a % b;
        a = b; b = r;
    }
    a
}
fn lcm(x: i64, y: i64)->i64{
    return x /gcd(x, y) * y;
}
fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        a: i64, b: i64, c: i64, d: i64,
    }
    let a = a - 1;
    let mut total = 0;
    total =  b/c + b/d -  b/lcm(d, c);
    total -=  a/c + a/d - a/lcm(d, c);
    let ans = b - a - total;
    println!("{}", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>
int main()
{
    int a[101],i,m,n,sum=0;
    scanf("%d %d",&n,&m);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        sum=sum+a[i];
    }
    double x;
    int c=0;
    x=sum/(4.0*m);
    for(i=0; i<n; i++)
    {
        if(x<=a[i])
        {
            c++;
        }
    }
    if(c>=m)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using ull = unsigned long long;

int gcd(int x, int y);

const int INF = 1001001001;

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int n;
    string s;
    cin >> s;
    
    string ans = "";
    rep(i, 3) {
        ans += s[i];
    }
    cout << ans << endl;
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// 10進数から2進数
int binary(int bina){
    int ans = 0;
    for (int i = 0; bina>0 ; i++)
    {
        ans = ans+(bina%2)*pow(10,i);
        bina = bina/2;
    }
    return ans;
}







int main() {
  string s;
  cin >> s;
  ll q;
  cin >> q;
  int t[q+1],f[q+1];
  char c[q+1];
  int ok = 0;
  rep (i,q){
    cin >> t[i];
    if (t[i]==1){
      ok = 1 - ok;
    }
    else{
      cin >> f[i] >> c[i];
      --f[i];
      if (ok) f[i]=1-f[i];
      if (f[i]==0){
        s.insert(s.begin(),c[i]);
      }
      else {
        s.push_back(c[i]);
      }
    }
    
  }
  if (ok) reverse(s.begin(),s.end());
  cout << s << endl;
  

}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

while 1:
    w,h = LI()
    if w == 0 and h == 0:
        break
    c = [LI() for _ in range(h)]
    check = [[True]*w for _ in range(h)]

    dx,dy = [1,1,0,-1,-1,-1,0,1],[0,1,1,1,0,-1,-1,-1]
    ans = 0
    for i in range(h):
        for j in range(w):
            if c[i][j] and check[i][j]:
                que = deque()
                que.append((i,j))
                check[i][j] = False
                ans += 1
                while que:
                    y,x = que.popleft()
                    for k in range(8):
                        ny,nx = y+dy[k],x+dx[k]
                        if 0 <= ny < h and 0 <= nx < w:
                            if check[ny][nx]:
                                if c[ny][nx]:
                                    que.append((ny,nx))
                                    check[ny][nx] = False
    print(ans)



Measured memory_bytes: 6124
#include <iostream>
#include <fstream>
#include <algorithm>
#include <utility>
#include <vector>
#include <unordered_map>

using ll = long long;
class KnapsackZDD {
	const int n;
	const int W;
	const int* w;
	const ll* v;
	using P = std::pair<int, int>;
	struct Node { P child[2]; Node() { child[0] = child[1] = P(0, 0); } };
	std::vector<std::unordered_map<int, Node>> g;
	std::vector<std::unordered_map<int, ll>> value;
public:
	KnapsackZDD(int n, int W, int* w, ll* v) : n(n), W(W), w(w), v(v) {}

	int getRoot(int& state) const {
		state = 0;
		return n;
	}

	// n + 0 : 1-end
	// n + 1 : 0-end
	int getChild(int& state, int level, int value) const {
		if (value == 1) state += w[level];
		++level;
		if (state > W) return n + 1; // infeasible
		return level;
	}

	void construct() {
		int vRoot = 0;
		g.resize(getRoot(vRoot) + 1);
		g[0][vRoot] = Node();
		g[n][0] = g[n][1] = Node();

		for (int i = 0; i < n; ++i) {
			for (auto& pair : g[i]) {
				auto& node = pair.second;
				int state = pair.first;
				for (int x = 0; x < 2; ++x) {
					int nextLevel = getChild(state, i, x);
					if (nextLevel >= n) {
						node.child[x] = P(n, n + 1 - nextLevel);
					}
					else {
						if (!g[i + 1].count(state)) {
							g[i + 1][state] = Node();
						}
						node.child[x] = P(i + 1, state);
					}
				}
			}
		}
	}

	ll evaluate() {
		value.resize(n + 1);
		return evalNode(0, 0);
	}
	ll evalNode(const P& pair) { return evalNode(pair.first, pair.second); }
	ll evalNode(const int& level, const int& state) {
		{ // check memo
			auto it = value[level].find(state);
			if (it != value[level].end()) return it->second;
		}
		auto& res = value[level][state];
		if (level == n) return res = state ? 0 : (1 << 31);
		auto&& node = g[level][state];
		return res = std::max(evalNode(node.child[0]), evalNode(node.child[1]) + v[level]);
	}
};

constexpr int MAX_N = 102;
int w[MAX_N];
ll v[MAX_N];
int main() {
	int n, W;
	auto input = [&](std::istream& ifs) {
		ifs >> n >> W;
		for (int id = 0; id < n; ++id) {
			ifs >> v[id] >> w[id];
		}
	};
	//std::ifstream ifs("in.txt");
	//input(ifs);
	input(std::cin);

	KnapsackZDD knapsack(n, W, w, v);
	knapsack.construct();

	std::cout << knapsack.evaluate() << std::endl;
	return 0;
}


Measured memory_bytes: 88100
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

class BIT {
	vector<int> d;
	int num;

public:
	BIT(int N) {
		num = N;
		d.resize(N + 1);
		fill(d.begin(), d.end(), 0);
	}

	void add(int p, const int x = 1) {
		while (p <= num) {
			d[p] += x;
			p += p & -p;
		}
	}

	int sum(int p) {
		int ans = 0;
		while (p) {
			ans += d[p];
			p ^= p & -p;
		}
		return ans;
	}
};

int main(void) {
	int num, i, j, a, n = 0;
	cin >> num;
	vector<int> ans(num + 1), k(num), d(num + 1);
	BIT bit(num);
	rep(i, num) {
		cin >> k[i];
		cin >> d[k[i]];
	}
	a = num;
	for (i = 1; i <= num; i++) {
		bit.add(d[i]);
		n++;
		if (bit.sum(a - n) == 0) {
			rep(j, n)
				ans[i - j] = n;
			a -= n;
			n = 0;
		}
	}
	rep(i, num) {
		cout << ans[k[i]] << "\n";
	}
	return 0;
}

Measured memory_bytes: 6424
#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;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; i++) {
        cout << S.at(i) << T.at(i);
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=0;
int k,n;
int a[111111],b[111111];
signed main(){
	
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	int l=a[0],r=a[n-1];
	for(int i=1;i<n-1;i++){
		if(a[i]<0){
			r-=a[i];
		}
		else{
			l-=a[i];
		}
	}
	cout<<abs(r-l)<<endl;
	l=a[0],r=a[n-1];
	for(int i=1;i<n-1;i++){
		if(a[i]<0){
			cout<<r<<" "<<a[i]<<endl;
			r-=a[i];
		}
		else{
			cout<<l<<" "<<a[i]<<endl;
			l-=a[i];
		}
	}
	cout<<r<<" "<<l<<endl;
}


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

public class Main {
	public static void main (String args[]) {
		Scanner sc = new Scanner(System.in);
		Integer[] intArray = Arrays.asList(sc.nextLine()
			.split(" "))
			.stream()
			.map(str -> Integer.parseInt(str))
			.toArray(Integer[]::new);
		int n = intArray[0];
		int m = intArray[1];
		long[] larray = new long[n];
		long sum = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			larray[i] = sc.nextLong();
			sum += larray[i];
			cnt++;
			m -= larray[i];
		}
		Arrays.sort(larray);
		cnt += m / larray[0];
		System.out.println(cnt);
	}
}



Measured memory_bytes: 29524
import java.util.Scanner;
public class Main{
	public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		int[] A = new int[10000];
		int a = sc.nextInt();
		int hoz = 1;
		int hoz2 = 0;
		int Cnt = 0;
		while(a != 0){
			for(int cnt = 0;cnt < a;cnt++){
				int b = sc.nextInt();
				if(b >= 2){
					hoz++;
				}else if(b == 1){
					hoz2++;
				}
				if(hoz >= 2){
					A[Cnt] = hoz + hoz2;
				}else{
					A[Cnt] = 101;
				}
			}
			Cnt++;
			hoz = 1;
			hoz2 = 0;
			a = sc.nextInt();
		}
		for(int n = 0; n < Cnt; n++){
			if(A[n] != 101){
				System.out.println(A[n]);
			}else{
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 158880
module ABC126

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_A

  ! constants for this <module>
  integer(INT32), parameter, private :: len_string_max = 50_INT32

  ! variables for this <module>
  character(len=len_string_max, kind=1), private :: given_string
  integer(INT32),                        private :: index
  integer(INT32),                        private :: len_string

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_A

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the given data
    read(unit=INPUT_UNIT, fmt=*    ) len_string, index
    read(unit=INPUT_UNIT, fmt='(A)') given_string

    ! STEP.02
    ! lowercasing the target string
    if( ichar(given_string(index:index)) .eq. ichar('A') )  given_string(index:index) = 'a'
    if( ichar(given_string(index:index)) .eq. ichar('B') )  given_string(index:index) = 'b'
    if( ichar(given_string(index:index)) .eq. ichar('C') )  given_string(index:index) = 'c'

    ! STEP.03
    ! calculate & output the summation
    write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') trim(given_string)

    ! STEP.END
    return

  end subroutine task_A

end module ABC126


program main

  ! <module>s to import
  use, non_intrinsic :: ABC126

  ! require all variables to be explicitly declared
  implicit none

  call task_A

end program main

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define int long long

typedef pair<int, int> P;

signed main() {
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  map<P, int> m;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = a - 2; j <= a; j++) {
      for (int k = b - 2; k <= b; k++) {
        if (1 <= j && j + 2 <= h && 1 <= k && k + 2 <= w) {
          m[P(j, k)]++;
        }
      }
    }
  }
  int count[10];
  fill(count, count + 10, 0);
  for (auto i = m.begin(); i != m.end(); i++) {
    count[i->second]++;
  }
  /*
  for (auto i = m.begin(); i != m.end(); i++) {
    cout << i->first.first << " " << i->first.second << " " << i->second << endl;
  }
  */
  int sum = 0;
  for (int i = 1; i < 10; i++) {
    sum += count[i];
  }
  cout << (h - 2) * (w - 2) - sum << endl;
  for (int i = 1; i < 10; i++) {
    cout << count[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  bool ans = false;
  for(int i = 1;i<=9;i++)if(a%i == 0 && a/i <= 9)ans = true;
  if(ans)cout << "Yes" <<endl;
  else cout << "No" <<endl;
}


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

using namespace std;

//#define MD 100010

int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    int ans=0;
    if(n>=k){
        ans=k*x;
        ans+=(n-k)*y;
    }else{
        ans=n*x;
    }
    
    cout<<ans<<endl;
    return 0;
}

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

int main() {
	int N; cin >> N;
	int A[N], tmpA[N];
	for (int i = 0; i < N; ++i) {
    	cin >> A[i];
    	tmpA[i] = A[i];
    }
	sort(A,A+N);
	for (int i = 0; i < N; ++i) {
    	if (A[N-1] == A[N-2]) {
        	cout << A[N-1] << endl;
        	continue;
        }
    	if (tmpA[i] == A[N-1]) {
        	cout << A[N-2] << endl;
        } else {
        	cout << A[N-1] << endl;
        }
    }
}

Measured memory_bytes: 3200
using System;
using System.Collections.Generic;

namespace std
{
    class Test {
        static void Main(string[] args) {
            List<int> ary_H = new List<int>();
            List<int> ary_W = new List<int>();
     
            while(true) {
                var input = Console.ReadLine().Split(' ');
                var H = int.Parse(input[0]);
                var W = int.Parse(input[1]);
         
            if(H == 0 && W == 0) break;
       
            ary_H.Add(H);
            ary_W.Add(W);
         
            }  
     
            for (int k = 0; k < ary_H.Count; k++) {
                for (int i= 0; i < ary_H[k]; i++) {
                    for (int j = 0; j < ary_W[k]; j++) {
                       
                       if(i % 2 == 0){
                            if(j % 2 == 0)   Console.Write("#"); // 偶数のとき
                            else{  Console.Write("."); } //奇数のとき
                        } else {
                            if(j % 2 != 0)   Console.Write("#"); // 偶数のとき
                            else{  Console.Write("."); } //奇数のとき
                        }
                        
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");//空行
            }
     
        }
    }
}


Measured memory_bytes: 7872
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (b <= c || d <= a)
	{
		print(0);
		return 0;
	}
	print(abs(max(a, c) - min(b, d)));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
n = int(input())
lst_plus = []
lst_minus = []

for i in range(n):
  x,y = map(int,input().split())
  lst_plus.append(x+y)
  lst_minus.append(y-x)
  
lst_plus.sort()
lst_minus.sort()

A = lst_plus[-1] - lst_plus[0]
B = lst_minus[-1] - lst_minus[0]

print(max([A,B]))
  

Measured memory_bytes: 104596
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int A = 1000000, MD = 1000000007;

int kk[A];

int power(long long a, int k) {
	long long p = 1;
	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int main() {
	int n; cin >> n;
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		ans = (ans + power(a, MD - 2)) % MD;
		for (int p = 2; p <= a / p; p++)
			if (a % p == 0) {
				int k = 0;
				while (a % p == 0) {
					k++;
					a /= p;
				}
				kk[p] = max(kk[p], k);
			}
		if (a > 1)
			kk[a] = max(kk[a], 1);
	}
	for (int a = 2; a < A; a++)
		if (kk[a])
			ans = ans * power(a, kk[a]) % MD;
	cout << ans << '\n';
	return 0;
}


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

#define EPS (1e-9)
#define EQ(a, b) (abs((a) - (b)) < EPS)

typedef complex<double> Vector2;

double dot(Vector2 a, Vector2 b) { return real(conj(a) * b); }
double cross(Vector2 a, Vector2 b) { return imag(conj(a) * b); }

vector<Vector2> CircleIntersections(Vector2 a, Vector2 b, double ra, double rb) {
  double d = abs(b - a);
  if (ra + rb < d) return {};
  double c = acos((ra * ra + d * d - rb * rb) / (2 * ra * d));
  double t = atan2(b.imag() - a.imag(), b.real() - a.real());
  Vector2 p1 = a + Vector2(cos(t + c) * ra, sin(t + c) * ra);
  Vector2 p2 = a + Vector2(cos(t - c) * ra, sin(t - c) * ra);
  return {p1, p2};
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<Vector2> v(n);
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y >> c[i];
    v[i] = Vector2(x, y);
  }
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }

  double a = 1e9;
  for (int top0 = 1; top0 < 1e9; top0 *= 10) {
    double bot = 0, top = top0, mid;
    while (!EQ(bot, top)) {
      mid = bot + (top - bot) / 2;
      bool valid = false;
      for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
          auto u = CircleIntersections(v[i], v[j], mid / c[i], mid / c[j]);
          //
          if (!u.empty()) u.push_back((u[0] + u[1]) / 2.0);
          //
          for (auto e : u) {
            int x = 2;
            for (int l = 0; l < n; l++) {
              if (l == i || l == j) continue;
              x += abs(e - v[l]) <= mid / c[l];
            }
            if (x >= k) valid = true;
          }
        }
      }
      if (valid) {
        top = mid;
      } else {
        bot = mid;
      }
    }
    if (!EQ(top, top0)) a = min(a, bot);
  }
  cout << fixed << setprecision(9);
  cout << a << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int f(int n,int k){
    int cnt = 1;
    while(n<k){
        n *= 2;
        cnt *= 2;
    }
    return cnt;
}
int main(){
   long n,k;
   long a = -1,b = 0;
   cin >> n >> k;
   vector<long> v(n);
   for(int i=1;i<n+1;i++){
      if(f(i,k) > a)a = f(i,k);
      v[i-1] = f(i,k);
   }
   for(int i:v){
       b += a/i;
   }
   a *= n;
   double c = (double)b/a;
   cout << fixed << setprecision(13) << c << endl;
 }

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

using namespace std;

template <long long Mod> struct ModInt { /* {{{ */
  long long v;
  constexpr ModInt(const long long x = 0) {
    v = x % Mod;
    if (v < 0) {
      v += Mod;
    }
  }
  constexpr ModInt operator+(const ModInt rhs) const { return ModInt(*this) += rhs; }
  constexpr ModInt operator-(const ModInt rhs) const { return ModInt(*this) -= rhs; }
  constexpr ModInt operator*(const ModInt rhs) const { return ModInt(*this) *= rhs; }
  constexpr ModInt operator/(const ModInt rhs) const { return ModInt(*this) /= rhs; }
  const ModInt &operator+=(const ModInt rhs) {
    v += rhs.v;
    if (v >= Mod) {
      v -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) {
    if (v < rhs.v) {
      v += Mod;
    }
    v -= rhs.v;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) {
    v = v * rhs.v % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) {
    long long exp = Mod - 2;
    while (exp) {
      if (exp & 1) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp >>= 1;
    }
    return *this;
  }
  friend ostream &operator<<(ostream &s, ModInt<Mod> m) {
    s << m.v;
    return s;
  }
  friend istream &operator>>(istream &s, ModInt<Mod> m) {
    s >> m.v;
    return s;
  }
}; /* }}} */

const int mod = 1e9 + 7;
using modint = ModInt<mod>;

modint memo[100005][2]; // 0: white, 1: black
bool visited[100005];

void dp(vector<vector<int>> &edges, int v) {
  visited[v] = true;
  memo[v][0] = memo[v][1] = 1;
  for (int e : edges[v]) {
    if (visited[e]) {
      continue;
    }
    dp(edges, e);
    memo[v][0] *= memo[e][0] + memo[e][1];
    memo[v][1] *= memo[e][0];
  }
}

int main() {
  int N;
  cin >> N;
  vector<vector<int>> edges(N, vector<int>());
  for (int i = 0; i < N - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    edges[x].push_back(y);
    edges[y].push_back(x);
  }
  dp(edges, 0);
  modint ans = memo[0][0] + memo[0][1];
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n); i > 0; i--)
#define print(n) cout << n << "\n"

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

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

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class ATableTennisTraining {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll N, A, B;
	    in >> N >> A >> B;
	    if ((B-A) % 2 == 0) {
	        out << (B-A) / 2 << "\n";
	        return;
	    } else {
	        vector<ll> candidates = {
                    max(A-1, B-1),
                    max(N-A, N-B),
                    ((A-1) + (B-1) + 1) / 2,
                    ((N-A) + (N-B) + 1) / 2
	        };
            out << *min_element(all(candidates)) << "\n";
	        return;
	    }
	}
};


signed main() {
	ATableTennisTraining solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#line 1 "sparse_table.test.cpp"
#include <cstdio>
#include <algorithm>
using namespace std;

#define call_from_test
#line 2 "/mnt/hdd1/cpp_library/structure/strc_007_sparsetable.cpp"

// @brief Sparse Table
// @docs ./docs/sparse_table.md

#include <vector>
#include <functional>
#include <cassert>

template <typename Tp>
struct SparseTable {
    size_t N, LN;
    vector<Tp> A, logs;
    vector< vector<Tp> > node;
    function<Tp(Tp, Tp)> f;

    SparseTable() = default;
    SparseTable(vector<Tp> A_, function<Tp(Tp, Tp)> f_) :
        A(A_), f(f_) {
        N = LN = 1;
        while(N < A.size()) N <<= 1, LN++;
        N = A.size();
        logs.resize(N+1);
        node.resize(N, vector<int>(LN));
        build();
    }

    void build() {
        for(size_t i=2; i<N; i++) {
            logs[i] = logs[i>>1] + 1;
        }
        for(size_t i=0; i<N; i++) {
            node[i][0] = A[i];
        }
        for(size_t k=0; k+1<LN; k++) {
            for(size_t i=0; i+(1<<k)<N; i++) {
                Tp x = node[i][k];
                Tp y = node[i+(1<<k)][k];
                node[i][k+1] = f(x, y);
            }
        }
    }

    inline Tp query(size_t l, size_t r) {
        assert(l < r and r <= N);
        int d = logs[r-l];
        Tp x = node[l][d];
        Tp y = node[r-(1<<d)][d];
        return f(x, y);
    }
};
#line 7 "sparse_table.test.cpp"
#undef call_from_test

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

    SparseTable<int> sp(A, [](int x, int y) { return min(x, y); });
    for(int i=0; i<N-L+1; i++) {
        printf("%d%c", sp.query(i, i+L), " \n"[i == N-L]);
    }
    return 0;
}



Measured memory_bytes: 135220
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    int digits[N];
    for (int i = 0; i < N; i++)
    {
        digits[i] = -1;
    }
    for (int i = 0; i < M; i++)
    {
        int s, c;
        cin >> s >> c;
        if (s > N || (digits[s - 1] != -1 && digits[s - 1] != c))
        {
            cout << -1 << endl;
            return 0;
        }
        digits[s - 1] = c;
    }
    for (int i = 0; i < N; i++)
    {
        if (i == 0)
        {
            if (digits[i] == 0 && N != 1)
            {
                cout << -1 << endl;
                return 0;
            }
            if (digits[i] == -1)
            {
                digits[i] = N == 1 ? 0 : 1;
            }
        }
        else if (digits[i] == -1)
        {
            digits[i] = 0;
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << digits[i];
    }
    cout << endl;
}


Measured memory_bytes: 256