akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"6 1
3"# => r#"4"#,
r#"10 2
4
5"# => r#"0"#,
r#"100 5
1
23
45
67
89"# => r#"608200469"#,
}

fn solve(src: &str) -> String {
    let mut disp:String = "".to_string();
    input! {
        source = src,
        n: usize,
        m: usize,
        a: [usize; m],
    }

    let mut dp = vec![0; n+2];
    dp[0] = 1;

    for i in 0..m {
        dp[a[i]] = -1;
    }

    for i in 0..n + 1 {
        if dp[i] == -1 {
            dp[i] = 0;
        }
        dp[i] %= 1_000_000_007;
        if i + 1 > n {
            break;
        }
        if dp[i + 1] != -1  {
            dp[i + 1] += dp[i];
        }

        if dp[i + 2] != -1 {
            dp[i + 2] += dp[i];
        }
    }

    disp.push_str(&dp[n].to_string());
    disp.to_string()
}



Measured memory_bytes: 6396
#include "bits/stdc++.h"
using namespace std;
     
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
     
typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int m;
  cin >> m;
  cout << 48 - m << endl;

}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

const int MAX = 5100000;
const int MOD = 1000000007;

long long 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

map<Int, Int> factrization(vector<Int>& v) {
    map<Int, Int> mp;
    for (Int i = 0; i < v.size(); i++) {
        Int p = v[i];
        for (Int j = 2; j * j <= v[i]; j++) {
            if (p % j == 0) {
                Int cnt = 0;
                while (p % j == 0) {
                    p /= j;
                    cnt++;
                }
                mp[j] = max(mp[j], cnt);
            }
        }
        if (p > 1) {
            mp[p] = max(mp[p], (Int)1);
        }
    }
    return mp;
}

int main() {
    COMinit();
    Int n;
    cin >> n;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<Int, Int> mp = factrization(a);
    Int p = 1;
    for (auto i : mp) {
        for (Int j = 0; j < i.se; j++) {
            p *= i.fi;
            p %= mod;
        }
    }
    //dump(p);
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        Int add = p * inv[a[i]] % mod;
        res += add;
        res %= mod;
    }
    dump(res);
    return 0;
}


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

int main() {
	int N, S = 0;
	cin >> N;
	for (int i = 1;i <= N;i *= 10) S += N / i % 10;
	cout << (N % S == 0 ? "Yes" : "No");
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

S(N)さえ求めれば後はやってみるだけなので、S(N)を求めよう
*/

Measured memory_bytes: 256
import collections

def main():
  n = int(input())
  S = list(map(int, input().split()))
  q = int(input())
  T = list(map(int, input().split()))

  C = 0
  for t in T:
    if t in S:
      C += 1

  print(C)


if __name__ == '__main__':
  main()


Measured memory_bytes: 7008
import sys
readline = sys.stdin.buffer.readline
MOD = 10**9+7

def main():
    N, K = map(int, readline().split())

    def nCr(n, r):
        bunshi = 1
        bunbo = 1
        for i in range(r):
            bunshi = (bunshi * (n - i)) % MOD
            bunbo = (bunbo * (i + 1)) % MOD
        return bunshi * pow(bunbo, MOD - 2, MOD) % MOD
    for i in range(1,K+1):
        ans = nCr(N-K+1, i) * nCr(K-1, i-1) % MOD
        print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
// Copyright 2020 yaito3014
#include <bits/stdc++.h>
using namespace std;

long long int gcd(long long int a, long long int b){
  return b?gcd(b,a%b):a;
}

long long int lcm(long long int a, long long int b){
  return a / gcd(a, b) * b;
}

int main(){
  int A, B;
  cin >> A >> B;
  cout << lcm(A, B) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
#include<ctime>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;


string s;
int k;
const int MAXN = 50000;
const int MAXK = 6;
string x[MAXK], sx;


int main() {
	cin >> s >> k;
	rep(i, 0, s.length() - 1) {
		rep(j, i, min(i + 6, (int)s.length() - 1)) {
			sx.clear();
			sx = s.substr(i, j - i + 1);
			bool tf = 1;
			rep(i, 1, k) {
				if (x[i] == sx) tf = 0;
			}
			if (tf && sx < x[k] || x[k].length() <= 0) {
				int kx = k;
				while (x[kx].empty() && kx > 1) --kx;
				if (!x[kx].empty() && kx < k) ++kx;
				x[kx] = sx;
				sort(x + 1, x + 1 + kx);
			}
		}
	}
	cout << x[k] << "\n";
	return 0;
} 


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
 
using namespace std;
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;
 
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vpi hyo(n);
  rep(i,n) cin >> hyo[i].first >> hyo[i].second;
  
  ll t = hyo[0].first, a = hyo[0].second;
  for(int i=1;i < n;i++){
    if(hyo[i].first == hyo[i].second){
      if(t > a){
        a = t;
      }else{
        t = a;
      }
    }else if(hyo[i].first > hyo[i].second){
      a = hyo[i].second*(ll)ceil((long double)a/hyo[i].second);
      if(t > hyo[i].first*(a/hyo[i].second)){
        t = hyo[i].first*(ll)ceil((long double)t/hyo[i].first);
        a = hyo[i].second*(t/hyo[i].first);
      }else{
        t = hyo[i].first*(a/hyo[i].second);
      }
    }else{
      t = hyo[i].first*(ll)ceil((long double)t/hyo[i].first);
      if(a > hyo[i].second*(t/hyo[i].first)){
        a = hyo[i].second*(ll)ceil((long double)a/hyo[i].second);
        t = hyo[i].first*(a/hyo[i].second);
      }else{
        a = hyo[i].second*(t/hyo[i].first);
      }
    }
  }
  ll ans = t+a;
  printf("%lld\n", ans);
	return 0;
}


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


int main(){
    char c[2];
    cin>>c[0]>>c[1];
    if(c[0]=='H'){
        cout<<c[1]<<endl;
    }else if(c[1]=='H'){
        cout<<'D'<<endl;
    }else{
        cout<<'H'<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int N;
  cin >> N;
  int x;
  cin >> x;
  vector<int>arr(N);
  for(int i=0; i<N; i++){
    cin >> arr[i];
  }
  unsigned long long int ans=0;
  if(arr[0]>x){
    ans += arr[0]-x;
    arr[0] -= arr[0]-x;
  }
  for(int i=0; i<N-1; i++){
    if(arr[i]+arr[i+1]>x){
      ans += arr[i]+arr[i+1]-x;
      arr[i+1] = x-arr[i];
    }else{
    }
  }
  cout << ans;
  return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ans += min(k-x, x) * 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int n = fetch<int>();
	auto a = fetch_vec<int>(n);
	auto b = fetch_vec<int>(n);
	for(int i = 0; i < n; ++i) {
		int v = a[i];
		a.push_back(v);
	}
	vector<int> S;
	for(int i = 0; i < n - 1; ++i) {
		S.push_back(b[i] ^ b[i + 1]);
	}	
	S.push_back(NIL);
	for(int i = 0; i < 2 * n - 1; ++i) {
		S.push_back(a[i] ^ a[i + 1]);
	}
	DBG(S);
	int sz = len(S);
	vector<int> z(sz, 0);
	int l = NIL, r = NIL;
	for(int i = 1; i < sz; ++i) {
		if(i <= r) z[i] = min(r - i + 1, z[i - l]);
		while(i + z[i] < sz && S[i + z[i]] == S[z[i]]) ++z[i];
		if(i + z[i] - 1 >= r) {
			l = i;
			r = i + z[i] - 1;
		}
	}
	DBG(z);
	DBG(S[n]);
	for(int i = n; i < sz; ++i) {
		//DBG(i - n); DBG(z[i]);
		if(z[i] >= n - 1) {
			int pos = i - n;
			if(pos < n) {
				cout << pos << ' ' << (a[pos] ^ b[0]) << '\n';
			}
		}
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 12136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	char c;
	cin >> c;
	if (isupper(c)) cout << "A" << endl;
	else cout << "a" << endl;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
class Node{
public:
  int location;
  int p,l,r;
  Node(){}
};
class Point{
public:
  int id,x,y;
  Point(){}
  Point(int id,int x,int y): id(id),x(x),y(y){}
  bool operator < (const Point &p){return id<p.id;}
};
static const int MAX =1000000;
static const int NIL = -1;
int n;
Point P[MAX];
Node T[MAX];
int np;
bool lessX(const Point &p1,const Point &p2){return p1.x<p2.x;}
bool lessY(const Point &p1,const Point &p2){return p1.y<p2.y;}
int makeKDTree(int l,int r, int d){
  if(!(l<r))return NIL;
  int mid=(l+r)/2;
  int t=np++;
  if(d%2==0)sort(P+l,P+r,lessX);
  else sort(P+l,P+r,lessY);
  T[t].location=mid;
  T[t].l=makeKDTree(l,mid,d+1);
  T[t].r=makeKDTree(mid+1,r,d+1);
  return t;
}
void find(int v,int sx,int tx,int sy,int ty,int d,vector<Point> &ans){
  int x=P[T[v].location].x;
  int y=P[T[v].location].y;
  if(sx<=x&&x<=tx&&sy<=y&&y<=ty)ans.push_back(P[T[v].location]);
  if(d%2==0){
    if(T[v].l!=NIL)if(sx<=x)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(x<=tx)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
  else{
    if(T[v].l!=NIL)if(sy<=y)find(T[v].l,sx,tx,sy,ty,d+1,ans);
    if(T[v].r!=NIL)if(y<=ty)find(T[v].r,sx,tx,sy,ty,d+1,ans);
  }
}
int main(){
  int x,y;
  cin>>n;
  rep(i,n){
    scanf("%d %d",&x,&y);
    P[i]=Point(i,x,y);
    T[i].l=T[i].r=T[i].p=NIL;
  }
  np=0;
  int root=makeKDTree(0,n,0);
  int q;
  cin>>q;
  int sx,sy,tx,ty;
  vector<Point>ans;
  rep(i,q){
    scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
    ans.clear();
    find(root,sx,tx,sy,ty,0,ans);
    sort(ans.begin(),ans.end());
    rep(j,ans.size())printf("%d\n",ans[j].id);
    cout<<endl;
  }return 0;
}


Measured memory_bytes: 16480
INF = int(1e9 + 7)
FCT = [0] * (int(1e5) + 1)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT[0] = 1
    FCT[1] = 1
    for i in range(2, x + 1):
        FCT[i] = modmulti(FCT[i - 1], i)


def main():
    N, M = map(int, input().split())
    if N == M or N + 1 == M or N == M + 1:
        if N < M:
            factorial(M)
        else:
            factorial(N)
        print(modmulti(2, modmulti(FCT[N], FCT[M]))
              if N == M else modmulti(FCT[N], FCT[M]))
    else:
        print(0)

    return


main()


Measured memory_bytes: 6900
#include <iostream>
using namespace std;
int main(void){
    int n,i;
    cin>>n;
    long long int min=10000000;
    long long int max=-10000000;
    long long int x,sum=0;
    
    for(i=0; i<n; i++){
        cin>>x;
        if(min>x){
            min=x;
        }
        
        if(max<x){
            max=x;
        }
    sum=sum+x;
    }
    
    cout<<min<<" "<<max<<" "<<sum<<endl;
}
    


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

using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	bool d_list[10];
	fill_n(d_list, sizeof(d_list), true);
	auto r = vector<int>();
	while (k-- != 0)
	{
		int d;
		cin >> d;
		d_list[d] = false;
	}

	//最小の可能値
	int min = 0;
	for (int i = 9; i >=0; i--)
		if ( d_list[i]) 
			min = i;

	//0を含まない最小の可能値
	int min_non_zero = 0;
	for (int i = 9; i > 0; i--)
		if (d_list[i])
			min_non_zero = i;


	//最大の可能値
	int max = 0;
	for (int i = 0; i <= 9; i++)
		if (d_list[i])
			max = i;

	//払う額のとりうる最大の10^nの値
	int g = 1;
	for (; ; g *= 10)
		if (n / g == 0) {
			g /= 10; break;
		}

	auto ns = vector<int>();

	//残りの支払い額
	int nn = n;

	for (; g > 0; g /= 10) {
		ns.push_back(nn / g);
		nn -= (nn / g) * g;
	}

	//既に払う必要がなくなったか
	bool up = false;
			
	for (int i = 0; i < ns.size(); i++) {
		//繰り上がりが必要かどうか
		bool inc_need = false;
		{
			bool same = false;
			for (int j = i + 1; j < ns.size(); j++) {
				if (ns[j] > max && (j == i + 1 || same)) { inc_need = true; break; }
				if (ns[j] == max)same = true;
			}
		}
		if (up) 
			r.push_back(min);
		else {
			int target = ns[i] + (inc_need ? 1 : 0);
			if (target > max) {
				r.push_back(min_non_zero);
				r.push_back(min);
				up = true;
			}
			else {
				for (int k = 0; k < 10; k++)
					if (target <= k && d_list[k]) {
						r.push_back(k);
						if (ns[i] < k)up = true;
						break;
					}
			}
		}
	}


	for (int x : r) cout << x;
	cout << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  if (n < a + b - 1 || n > 1LL * a * b) {
    cout << -1 << endl;
    return 0;
  }

  int t = n;
  vector<int> x(a);
  x[0] = b;
  t -= b;
  for (int i = 1; i < a; i++) {
    x[i] = 1;
    t--;
  }
  for (int i = 1; i < a; i++) {
    int take = min(b - 1, t);
    x[i] += take;
    t -= take;
  }

  int curr = 0;
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < x[i]; j++) {
      cout << curr + x[i] - j << ' ';
    }
    curr += x[i];
  }
  cout << endl;
}

Measured memory_bytes: 2944
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    double nn=0;
    if(n%2==0){
       nn=n/2;
    }else{
      double nnn=n/2;
      nn=n-nnn;
    }
    System.out.println(nn/n);
  }
}

Measured memory_bytes: 22356
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::string s;std::cin>>s;
    lint ans=0,now=0;
    for(char c:s){
        now+=c=='I'?1:-1;
        if(ans<now)ans=now;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 256
/*
时间:2020-7-30
书籍：算法和数据结构
内容：搜索的应用--计算最优解
页数：P94
*/
#include<iostream>
#include<string>
using namespace std;
int n, k;
int* T;
int check(long long int p)
{
	int j = 0;       // 记录已经装了多少货物
	for (int i = 1; i <= k; ++i)
	{
		int sum = 0;
		while (sum +T[j]<= p)                   //这里面是sum+T[i],必须确保装载后不会超载才可以装车，而不是T[j]<=p
		{
			sum += T[j];
			++j;
			if (j == n)
				return n;
		}
	}
	return j;
}
int tryLoad()
{
	long long int left = 0;              //从0开始，而不是从1开始，不然，1的解答案包含不到
	long long int right = 100000 * 100000;
	long long int mid = (left + right) / 2;
	long long int now = check(mid);
	while (right - left > 1)
	{
		if (now >= n)
		{
			right = mid;
			mid= (left + right) / 2;
			now = check(mid);
		}
		else
		{
			left = mid;
			mid = (left + right) / 2;
			now = check(mid);
		}
	}
	return right;
}
int main()
{
	cin >> n >> k;
	T = new int[n];
	for (int i = 0; i < n; ++i)
		cin >> T[i];
	long long int n = tryLoad();
	cout << n << endl;
	delete[]T;
	return 0;
}


Measured memory_bytes: 3140
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include<complex>

using namespace std;

typedef long long            ll;
typedef unsigned             ui;
typedef unsigned long long   ull;
typedef pair<int,int>        i_i;
typedef pair<ll,int>         ll_i;
typedef pair<ll,ll>          ll_ll;
typedef pair<double,int>     d_i;
typedef pair<double,double>  d_d;
typedef vector<int>          vi;
typedef vector<vector<int> > vii;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF __INT32_MAX__
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

ll dp[600][600][600];

signed main(void)
{
  bool judge=false;
  int dx[4]={0,1,0,-1};
  int dy[4]={1,0,-1,0};
  int i,x,y;
  ll mod = 1e9+7;
  in(int,R,C,ai,aj,bi,bj);
  dp[0][ai][aj]=1;
  rep(i,520){
    rep(x,R){
      rep(y,C){
        dp[i][x][y]%=mod;
        int j;
        rep(j,4){
          if(0<=x+dx[j]&&x+dx[j]<R&&
             0<=y+dy[j]&&y+dy[j]<C){
            dp[i+1][x+dx[j]][y+dy[j]]+=dp[i][x][y];
          }
        }
        dp[i+1][0  ][y  ]+=dp[i][x][y];
        dp[i+1][R-1][y  ]+=dp[i][x][y];
        dp[i+1][x  ][0  ]+=dp[i][x][y];
        dp[i+1][x  ][C-1]+=dp[i][x][y];
        if(x==bi&&y==bj&&
           dp[i][bi][bj]!=0){
          judge=true;
        }
      }
    }
    if(judge)
      break;
  }
  printf("%d %lld\n",i,dp[i][bi][bj]%mod);
    return 0;
}



Measured memory_bytes: 454036
#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<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979

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){
	ll n,a,b,mn,mx;
	cin >> n >> a >> b;
	--n;
	mn = a*n + b;
	mx = a + b*n;
	cout << (max(mx-mn+1,0ll)) << endl;
	return 0;
}



Measured memory_bytes: 256
s = list(input())
a = []
# print(s)
 
for i in range(len(s)):
    if s[i]== "0":
        a.append("0")
    elif s[i] == "1":
        a.append("1")
    else:
        if len(a)> 0:
            a.pop()
print("".join(a))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline ll read(){ll w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
ll N,P,res=1;ll Pr[1000100],tong[1000100],cnt;
inline ll ksm(ll x,ll y){ll ret=1;while(y){if(y&1) res=res*x;x=x*x;y>>=1;} return ret;}
int main()
{	cin>>N>>P;
	ll Sqr=sqrt(P);
	for(ll i=2;i<=Sqr;++i)
	{
		if(P%i==0)
		{
			ll tot=0;
			while(P%i==0) P/=i,tot++;
			if(tot>=N) res=res*ksm(i,(tot/N));
		}
	}
	if(P!=1&&N==1) res=res*P;
	cout<<res; 
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.awt.geom.*;
import static java.lang.Math.*;
public class Main {
	final Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main().init();
	}
	void init(){
		new AOJ0010();
	}
	
	class AOJ0010{
		AOJ0010(){
			int n=sc.nextInt();
			while(--n>=0)	solve();
		}
		void solve(){
			Point2D p1=new Point2D.Double(sc.nextDouble(), sc.nextDouble()),
					p2=new Point2D.Double(sc.nextDouble(), sc.nextDouble()),
					p3=new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			Line2D l1=perpendicularBisector(p1, p2);
			Line2D l2=perpendicularBisector(p2, p3);
			Point2D p=intersectionPoint(l1, l2);
			System.out.printf("%.3f %.3f %.3f\n", p.getX(), p.getY(), p.distance(p1));
		}
	}
	
	
	// test
	
	final double EPS=1.0e-8;
	
	// 外積
	double cross(Point2D p1,Point2D p2){
		return p1.getX()*p2.getY() - p2.getX()*p1.getY();
	}
	
	// 内積
	double dot(Point2D p1,Point2D p2){
		return p1.getX()*p2.getX() + p2.getY()*p2.getY();
	}
	
	// 和
	Point2D sum(Point2D p1,Point2D p2){
		return new Point2D.Double(p1.getX()+p2.getX(), p1.getY()+p2.getY());
	}
	
	// 差
	Point2D diff(Point2D p1,Point2D p2){
		return new Point2D.Double(p1.getX()-p2.getX(), p1.getY()-p2.getY());
	}
	
	// スカラー倍
	Point2D mul(Point2D p1,double n){
		return new Point2D.Double(p1.getX()*n, p1.getY()*n);
	}
	
	// 長さ
	double abs(Point2D p1){
		return Math.sqrt(p1.getX()*p1.getX() + p1.getY()*p1.getY());
	}
	
	// 角度(radian)
	double angleR(Point2D p1,Point2D p2){
		return Math.acos(dot(p1,p2)/abs(p1)/abs(p2));
	}
	// 角度(degree)
	double angleD(Point2D p1,Point2D p2){
		return Math.toDegrees(angleR(p1, p2));
	}
	
	// 中点
	Point2D mid(Line2D l1){
		return mid(l1.getP1(),l1.getP2());
	}
	Point2D mid(Point2D p1,Point2D p2){
		return new Point2D.Double((p1.getX()+p2.getX())/2, (p1.getY()+p2.getY())/2);
	}
	
	// 垂直二等分線
	Line2D perpendicularBisector(Line2D l1){
		return perpendicularBisector(l1.getP1(), l1.getP2());
	}
	Line2D perpendicularBisector(Point2D p1,Point2D p2){
		Point2D mid=mid(p1,p2),
				diff=diff(p1,p2);
		return new Line2D.Double(mid, sum(mid, new Point2D.Double(diff.getY(), -diff.getX())));
	}
	
	// 2直線の交点（平行でない）
	Point2D intersectionPoint(Line2D l1,Line2D l2){
		return intersectionPoint(l1.getP1(), l1.getP2(), l2.getP1(), l2.getP2());
	}
	Point2D intersectionPoint(Point2D a1,Point2D a2,Point2D b1,Point2D b2){
		Point2D a=diff(a2,a1),
				b=diff(b2,b1);
		return sum(a1, mul(a, cross(b, diff(b1,a1))/cross(b,a)));
	}
	
	String lineToStr(Line2D l){
		return "Line2D "+l.getP1()+"-"+l.getP2();
	}
	
}

Measured memory_bytes: 20840
using System;

namespace Tenka1
{
    class Program
    {
        static void Main(string[] args)
        {
            var hoge = Console.ReadLine().Split(' ');
            var a = int.Parse(hoge[0]);
            var b = int.Parse(hoge[1]);
            var k = int.Parse(hoge[2]);
            int cnt = 1;
            while (cnt<=k)
            {
                if (cnt % 2 == 1) { //A
                    if (a % 2 == 1)
                    {
                        a-=1;
                    }
                    var c = a / 2;
                    a -= c;
                    b += c;
                }
                else
                {//B
                    if (b % 2 == 1)
                    {
                        b-=1;
                    }
                    var d = b / 2;
                    b -= d;
                    a += d;
                }
                //Console.WriteLine(a + " " + b);

                cnt++;
            }
           // Console.WriteLine(cnt);
            Console.WriteLine(a + " " + b);
        }
    }
}


Measured memory_bytes: 11092
x,y,a,b,c=map(int,input().split())
P=sorted(list(map(int,input().split())))[::-1]
Q=sorted(list(map(int,input().split())))[::-1]
R=list(map(int,input().split()))
L=sorted(P[:x]+Q[:y]+R)[::-1]
print(sum(L[:x+y]))

Measured memory_bytes: 23392
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	public static void main(String[] args){
		int a=sc.nextInt();
		int b=sc.nextInt();
		solveEuclid(a,b);
	}
	public static void solveEuclid(int a,int b){
		int r_0=a, r_1=b;
		int a_0=1, a_1=0;
		int b_0=0, b_1=1;
		while(r_1>0){
			int q_1=r_0/r_1;
			int r_2=r_0%r_1;
			int a_2=a_0-q_1*a_1;
			int b_2=b_0-q_1*b_1;
			r_0=r_1;
			r_1=r_2;
			a_0=a_1;
			a_1=a_2;
			b_0=b_1;
			b_1=b_2;
		}
		System.out.println(a_0+" "+b_0);
	}

}

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

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
	cin >> n >> k;
	ld num ;
	num = log(n)/log(k);
	cout << floor(num) + 1;
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#define P pair<char, int>

using namespace std;
const int SENTINENTAL = 1e9+7;

int n;
P a[100009], b[100009];

int Partition(int p, int r){
  int x=a[r].second;
  int i=p-1;
  for(int j=p;j<r;j++){
    if(a[j].second<=x){
      i++;
      swap(a[i], a[j]);
    }
  }
  swap(a[i+1], a[r]);
  return i+1;
}

void QuickSort(int p, int r){
  if(p<r){
    int q = Partition(p, r);
    QuickSort(p, q-1);
    QuickSort(q+1, r);
  }
}

void merge(int left, int mid, int right){
  int n1 = mid - left;
  int n2 = right - mid;
  vector<P>L, R;
  for(int i=0;i<n1;i++)L.push_back(b[left+i]);
  for(int i=0;i<n2;i++)R.push_back(b[mid+i]);
  L.push_back(P(' ', SENTINENTAL));
  R.push_back(P(' ',SENTINENTAL));
  int i=0, j=0;
  for(int k=left;k<right;k++){
    if(L[i].second<=R[j].second)b[k]=L[i++];
    else b[k]=R[j++];
  }
}

void mergeSort(int left, int right){
  if(left+1<right){
    int mid=(left + right)/2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

int main(){
  cin >> n;
  char suit;
  int value;
  for(int i=0;i<n;i++){
    cin >> suit >> value;
    a[i] = P(suit, value);
    b[i] = P(suit, value);
  }  
  QuickSort(0, n-1);
  mergeSort(0, n);
  bool check = true;
  for(int i=0;i<n;i++){
    if(a[i].first!=b[i].first || a[i].second != b[i].second){
      check=false;
      break;
    }
  }
  cout << (!check?"Not stable": "Stable") << endl;
  for(int i=0;i<n;i++)cout << a[i].first << ' ' << a[i].second << endl;
}


Measured memory_bytes: 5436
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    vector<bool> a[4];
    a[0].push_back(true);
    a[0].push_back(true);
    a[1].push_back(true);
    a[1].push_back(false);
    a[2].push_back(false);
    a[2].push_back(true);
    a[3].push_back(false);
    a[3].push_back(false);
    rep(i, 4){
        for(int j = 1; j < n; j++){
            if(j == n-1)break;
            if(a[i][j]){
                if(s[j] == 'o')a[i].push_back(a[i][j-1]);
                else a[i].push_back(!a[i][j-1]);
            }
            else{
                if(s[j] == 'o')a[i].push_back(!a[i][j-1]);
                else a[i].push_back(a[i][j-1]);
            }
        }
    }

    // rep(i, 4){
    //     rep(j, n){
    //         if(a[i][j])cout << "S";
    //         else cout << "W";
    //     }cout << endl;
    // }
    rep(i, 4)rep(j, n){
        bool next;
        if(j == 0)next = (a[i].back()^a[i][j+1]);
        else if(j == n-1)next = (a[i].front()^a[i][j-1]);
        else next = (a[i][j-1]^a[i][j+1]);
        if(a[i][j]){
            if(s[j] == 'o' && next)break;
            if(s[j] == 'x' && !next)break;
        }
        else{
            if(s[j] == 'o' && !next)break;
            if(s[j] == 'x' && next)break;
        }
        if(j == n-1){
            rep(k, n){
                if(a[i][k])cout << "S";
                else cout << "W";
            }
            return 0;
        }
    }
    cout << -1;


}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
    int a, b, c, count;
    count = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(; a <= b; a++) {
        if(c % a == 0)
            count++;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 2076
import sys
input = sys.stdin.readline
from collections import defaultdict


class PrimeFactor():

    def __init__(self, n):                  # エラトステネス　O(N loglog N)
        self.n = n
        self.table = [i if i % 2 else 2 for i in range(n + 1)]
        self.table[0] = 0
        for p in range(3, n + 1):
            if self.table[p] == p:
                for q in range(p * p, n + 1, 2 * p):
                    self.table[q] = p

    def is_prime(self, x):  # 素数判定　O(1)
        if x < 2:
            return False
        return self.table[x] == x

    def prime_factors(self, x):             # 素因数分解 O(logN)
        res = []
        if x < 2:
            return res
        while self.table[x] != 1:
            res.append(self.table[x])
            x //= self.table[x]
        return res

    def prime_counter(self, x):             # 素因数分解（個数のリスト）
        res = defaultdict(int)
        if x < 2:
            return res
        while self.table[x] != 1:
            res[self.table[x]] += 1
            x //= self.table[x]
        return res

    def prime_gcd(self, X):                 # n個の最大公約数　X:n個のリスト
        exponents = self.prime_counter(X[0])
        for x in X[1:]:
            Y = self.prime_counter(x)
            for prime, exp in exponents.items():
                if Y[prime] < exp:
                    exponents[prime] = Y[prime]
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp)
        return res

    def prime_lcm(self, X, mod=None):       # n個の最小公倍数　X:n個のリスト
        exponents = defaultdict(int)
        for x in X:
            for prime, exp in self.prime_counter(x).items():
                if exp > exponents[prime]:
                    exponents[prime] = exp
        res = 1
        for prime, exp in exponents.items():
            res *= pow(prime, exp, mod)
        if mod == None:
            return res
        else:
            return res % mod

mod = 10 ** 9 + 7

N = int(input())
A = list(map(int, input().split()))
table = PrimeFactor(10**6)
num = table.prime_lcm(A,mod)

res = 0
for a in A:
    res += num * pow(a, mod - 2, mod)

print(res % mod)

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

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

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

//問題URL
//https://atcoder.jp/contests/agc019/tasks/agc019_b

//参考：
//https://oraclesqlpuzzle.ninja-web.net/kyoupro/kyoupro-10-019-b.html

//ポイント：
//A[i]とA[j]が同じ文字の時、
//それに内包される文字列を反転させたものと
//A[i],A[j]を含んだ文字列を反転させても被るので除外する
//例えば
//文字列eabceにおいてはabc,eabceどちらを反転させても
//同じecbaeができる

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string S;

LL ans = 0;

void solve(){
	LL N = S.size();
	ans = N*(N-1)/2;
	vector<LL> alpha(26,0);
	for(int i=0;i<N;i++) alpha[S[i]-'a']++;
	for(int i=0;i<26;i++) ans -= alpha[i]*(alpha[i]-1)/2;
	ans++;
}
 
int main(){
    cin >> S;
 
    solve();

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

Measured memory_bytes: 640
readlines.each{|line|
  xa, ya, xb, yb, xc, yc, xd, yd = line.split.map(&:to_f)
  v1 = [xb - xa, yb - ya]
  v2 = [xd - xc, yd - yc]
  if (v1[0] * v2[0] + v1[1] * v2[1]).abs <= 1e-12
    puts "YES"
  else
    puts "NO"
  end
}

Measured memory_bytes: 8564
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 800000000
#define MAX 1000

int main(){
  ll H,W;
  cin>>H>>W;
  if(H%3==0||W%3==0){
    cout<<0<<endl;
  }else{
    ll ans=10000000000;
    vector<ll> S(3);
    S.at(0)=H/3*W;
    S.at(1)=(H-H/3)*(W/2);
    S.at(2)=(H-H/3)*(W-W/2);
    sort(S.begin(),S.end());
    ans=min<ll>(ans,S.at(2)-S.at(0));
    S.at(0)=(H/3+1)*W;
    S.at(1)=(H-H/3-1)*(W/2);
    S.at(2)=(H-H/3-1)*(W-W/2);
    sort(S.begin(),S.end());
    ans=min<ll>(ans,S.at(2)-S.at(0));
    S.at(0)=W/3*H;
    S.at(1)=(W-W/3)*(H/2);
    S.at(2)=(W-W/3)*(H-H/2);
    sort(S.begin(),S.end());
    ans=min<ll>(ans,S.at(2)-S.at(0));
    S.at(0)=(W/3+1)*H;
    S.at(1)=(W-W/3-1)*(H/2);
    S.at(2)=(W-W/3-1)*(H-H/2);
    sort(S.begin(),S.end());
    ans=min<ll>(ans,S.at(2)-S.at(0));
    S.at(0)=W/3*H;
    S.at(1)=((W-1)/3+1)*H;
    S.at(2)=(W-W/3-(W-1)/3-1)*H;
    sort(S.begin(),S.end());
    ans=min<ll>(ans,S.at(2)-S.at(0));
    S.at(0)=H/3*W;
    S.at(1)=((H-1)/3+1)*W;
    S.at(2)=(H-H/3-(H-1)/3-1)*W;
    sort(S.begin(),S.end());
    ans=min<ll>(ans,S.at(2)-S.at(0));

    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
sx, sy, tx, ty = list(map(int, input().split()))


for i in range(ty - sy):
    print("U", end="")

for i in range(tx - sx):
    print("R", end="")

for i in range(ty - sy):
    print("D", end="")

for i in range(tx - sx + 1):
    print("L", end="")

for i in range(ty - sy + 1):
    print("U", end="")

for i in range(tx - sx + 1):
    print("R", end="")

print("D", end="")
print("R", end="")

for i in range(ty - sy + 1):
    print("D", end="")

for i in range(tx - sx + 1):
    print("L", end="")

print("U", end="")


Measured memory_bytes: 4468
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	s := nextStr()

	if s == "SUN" {
		fmt.Println("7")
		return
	}
	if s == "MON" {
		fmt.Println("6")
		return
	}
	if s == "TUE" {
		fmt.Println("5")
		return
	}
	if s == "WED" {
		fmt.Println("4")
		return
	}
	if s == "THU" {
		fmt.Println("3")
		return
	}
	if s == "FRI" {
		fmt.Println("2")
		return
	}
	if s == "SAT" {
		fmt.Println("1")
		return
	}

}

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


Measured memory_bytes: 640
// https://atcoder.jp/contests/agc039/tasks/agc039_d
//
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! dvec {
    ($t:expr ; $len:expr) => {
        vec![$t; $len]
    };

    ($t:expr ; $len:expr, $($rest:expr),*) => {
        vec![dvec!($t; $($rest),*); $len]
    };
}

#[allow(unused_macros)]
macro_rules! ifv {
    ($t:expr, $a:expr, $b: expr) => {
        if $t { $a } else { $b }
    }
}

#[allow(unused_macros)]
macro_rules! fill {
    ($t:expr, $v:expr) => {
        for i in 0..$t.len() {
            $t[i] = $v;
        }
    };
}

#[allow(unused_macros)]
macro_rules! join {
    ($t:expr, $glue:expr) => {
        $t.into_iter().map(|w| w.to_string()).collect::<Vec<_>>().join($glue)
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

use std::f64::consts::PI;

fn pt(x: i64, l: i64) -> (f64, f64) {
    let rad = 2f64 * PI * (x as f64) / (l as f64);
    (rad.cos(), rad.sin())
}

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


    let mut total_x = 0f64;
    let mut total_y = 0f64;

    let mut ptn = 0f64;
    for i in 0..n {
        for j in i+1..n {
            let inner_num = (j - i - 1) as f64;
            let outer_num = (n - 1 + i - j) as f64;
            let (inx, iny) = pt(t[i] + t[j], l*2);
            let (oux, ouy) = pt(t[i] + t[j] + l, l*2);

            total_x += inx * outer_num + oux * inner_num;
            total_y += iny * outer_num + ouy * inner_num;
            ptn += inner_num;
            ptn += outer_num;
        }
    }
    ptn /= 3f64;

    println!("{} {}", total_x / ptn, total_y / ptn);
}


Measured memory_bytes: 4476
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int N, K;
        {int[] a = in.ii(); N = a[0]; K = a[1];}
        int[] p = in.ii();
        int[] sum = new int[N+1];
        for(int i = 0; i < N; i++){
            sum[i+1] = sum[i]+p[i];
        }
        int ans = 0;
        for(int i = 0, M = N-K+1; i < M; i++){
            ans = Math.max(sum[i+K]-sum[i]+K, ans);
        }
        out.println(ans/2.0);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 51004
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;

map<string, int> dp; //记录最短路径
int direction[4] = {1, -1, 4, -4};

void bfs()
{
	queue<string> que;
	que.push("01234567");
	dp["01234567"] = 0;
	while (!que.empty())
	{
		string now = que.front();
		que.pop();
		// p是’0‘的位置
		int p = 0;
		for (int j = 0; j < 8; j++)
		{
			if (now[j] == '0')
			{
				p = j; break;
			}
		}

		for (int i = 0; i < 4; i++)
		{
			int n = p + direction[i];
			if (n >= 0 && n < 8
				&& !(p == 3 && i == 0) // 右上角不能向右移动
				&& !(p == 4 && i == 1)) // 左下角不能向左移动
			{
				string next = now;
				swap(next[p], next[n]);
				if (dp.find(next) == dp.end())
				{
					dp[next] = dp[now] + 1;
					que.push(next);
				}
			}
		}
	}
}

int main()
{
	bfs();
	string line;
	while (getline(cin, line))
	{
		line.erase(remove(line.begin(), line.end(), ' '), line.end());
		cout << dp[line] << endl;
	}
	return 0;
}


Measured memory_bytes: 5328
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> a(N);
    rep (i, 0, N) cin >> a[i];

    int ans = 0;
    rep (i, 0, N) {
        ans += a[i]-1;
    }

    cout << ans << endl;
}

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

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            //string s = Console.ReadLine();

            // 整数の入力
            //long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long A = inputLongArray[0];
            long B = inputLongArray[1];
            long N = inputLongArray[2];

            long k;
            long max = 0;


            if (B > N)
            {
                max = (A * N) / B - A * (N / B);
            }

            else
            {

                k = N / B;
                max = (A * (k * B - 1)) / B - A * ((k * B - 1) / B);
                
            }



            Console.WriteLine(max);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28080
#include<cstdio>
int main()
{
	int n,x,m,s=0,mn=1e6;
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) 
	{
		scanf("%d",&m);s+=m;
		if(m<mn) mn=m;
	}
	x-=s;
	printf("%d\n",n+x/mn);
	return 0;
}

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

int main() {
  int n,m;
  scanf("%d %d",&n,&m);
  long long a[n][3];

  for (int i=0;i<n;i++){
    cin >> a[i][0] >> a[i][1] >> a[i][2];
  }
  
  long long ans = 0;
  for (int i=0;i<(1<<3);i++){
    vector<long long> S(n);
    for (int j=0;j<n;j++){
          switch (i){
            case 0: S[j] = (-a[j][0] - a[j][1] + a[j][2]); break;
            case 1: S[j] = (-a[j][0] + a[j][1] - a[j][2]); break;
            case 2: S[j] = (a[j][0] - a[j][1] - a[j][2]); break;
            case 3: S[j] = (-a[j][0] + a[j][1] + a[j][2]); break;
            case 4: S[j] = (a[j][0] - a[j][1] + a[j][2]); break;
            case 5: S[j] = (a[j][0] + a[j][1] - a[j][2]); break;
            case 6: S[j] = (-a[j][0] - a[j][1] - a[j][2]); break;
            case 7: S[j] = (a[j][0] + a[j][1] + a[j][2]); break;
          }
    }

    sort(S.begin(),S.end());
    reverse(S.begin(),S.end());
    long long maxm =0;
    for (int i=0;i<m;i++){
      maxm+=S[i];
    }
    ans = max(ans,maxm);
  }
   cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
A=[int(i) for i in input().split()]
mod=10**9+7
deni=[1]*(N+1)#(k)!を格納
quot=[1]*(N+1)#(k)!の逆数を格納
for i in range(1,N+1):
    deni[i]=(deni[i-1]*(i+1))%mod
for i in range(1,N+1):
    t=pow(i+1,mod-2,mod)
    quot[i]=(quot[i-1]*t)%mod
deni=[1]+deni
quot=[1]+quot
box=[[0,0]]*(N+1)
for i in range(N+1):
    if box[A[i]-1][0]==1:
        k_1=box[A[i]-1][1]
        k_2=N-i
        break
    box[A[i]-1]=[1,i]
K=k_1+k_2
ans =[]
for k in range(1,N+2):
    if k==1:
        ans.append(N)
    elif K>=k-1:
        s=deni[N+1]
        s=(s*quot[k])%mod
        s=(s*quot[N+1-k])%mod
        t=deni[K]
        t=(t*quot[k-1])%mod
        t=(t*quot[K-k+1])%mod
        #print(s,t)
        ans.append((s-t)%mod)
    else:
        s=deni[N+1]
        s=(s*quot[k])%mod
        s=(s*quot[N-k+1])%mod
        #print(s)
        ans.append(s)
#print(ans)
print('\n'.join(map(str,ans)))

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

int main()
{
 string S , T ;
 cin >> S >> T ;
 sort(S.begin(),S.end());
 sort(T.rbegin(),T.rend());
 int N = S.size() ;
 int M = T.size() ;
 int count = 0 ;
 rep(i, min(N,M) ){
   if( S.at(i) < T.at(i) ){
     cout << "Yes" <<  endl;
     return 0 ;
   }
   if( S.at(i) == T.at(i) ){
     count++ ;
     if( count == min(N,M)){
        if(N<M) cout << "Yes"<<  endl;
        else    cout << "No" <<  endl;
        return 0 ;
     }
   }
   }
  cout << "No" << endl ;
} 

Measured memory_bytes: 256
# 169a
# 値 A × Bを整数として出力せよ。

# 1.入力をプログラムで扱えるように受け取る
a, b = map(int, input().split())
# print(a,b)

# 2.受け取った入力値を使って、適切に処理（計算）する
answer = a * b

# 3.計算した結果を出力する
print(answer)

Measured memory_bytes: 9160