akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using si = set<int>;
using sll = set<ll>;


const int mod = 1e9 + 7;
int main(){
	int n;
	cin >> n;
	vector<vi> a(n, vi(n));
	for (int i = 0; i < n;  i++){
		for (int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	
	vi dp((1 << n) + 5);
	dp[0] = 1;
	for (int mask = 0; mask < (1 << n) - 1; mask++){
		int m_cnt = __builtin_popcount(mask);
		for (int i = 0; i < n; i++){
			if (a[m_cnt][i] && !(mask & (1 << i))){
				int new_mask = mask | (1 << i);
				dp[new_mask] += dp[mask];
				dp[new_mask] %= mod;
			} 
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 8448
import sys
input = sys.stdin.readline


class Node():
    def __init__(self, parent, left, right):
        self.parent = parent
        self.left = left
        self.right = right


N = int(input())
btree = [Node(-1, -1, -1) for i in range(N)]
root_cand_list = [i for i in range(N)]


def main():
    for i in range(N):
        num, left, right = map(int, input().split())

        if left != -1:
            btree[num].left = left
            btree[left].parent = num
            root_cand_list.remove(left)
        if right != -1:
            btree[num].right = right
            btree[right].parent = num
            root_cand_list.remove(right)

    print("Preorder")
    showPreorder(root_cand_list[0])
    print()
    print("Inorder")
    showInorder(root_cand_list[0])
    print()
    print("Postorder")
    showPostorder(root_cand_list[0])
    print()


def showPreorder(num):
    print(" ", end="")
    print(num, end="")
    if btree[num].left != -1:
        showPreorder(btree[num].left)
    if btree[num].right != -1:
        showPreorder(btree[num].right)


def showInorder(num):
    if btree[num].left != -1:
        showInorder(btree[num].left)
    print(" ", end="")
    print(num, end="")
    if btree[num].right != -1:
        showInorder(btree[num].right)


def showPostorder(num):
    if btree[num].left != -1:
        showPostorder(btree[num].left)
    if btree[num].right != -1:
        showPostorder(btree[num].right)
    print(" ", end="")
    print(num, end="")



if __name__ == '__main__':
    main()



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2e5+10;
#define fi first
#define se second
#define pb push_back
int p[N],a[N],cnt;
void P(){
    for(int i=2;i<N;i++){
        if(!p[i])a[++cnt]=i;
        for(int j=1;j<=cnt&&1ll*a[j]*i<N;j++){
            p[a[j]*i]=1;
            if(i%a[j]==0)break;
        }
    }
}
int main() {
    ios::sync_with_stdio(false);
    P();
    int x;
    cin>>x;
    for(int  i=1;i<=cnt;i++){
        if(a[i]>=x)return cout<<a[i],0;
    }
    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<int> vx(m);
  for (int i = 0; i < m; ++i) {
    cin >> vx[i];
  }

  sort(vx.begin(), vx.end());
  n--;

  vector<int> dists(m - 1);
  for (int i = 0; i < m - 1; ++i) {
    dists[i] = abs(vx[i + 1] - vx[i]);
  }

  sort(dists.begin(), dists.end(), greater<int>());

  int sum = accumulate(dists.begin(), dists.end(), 0);
  for (int i = 0; i < min(n, static_cast<int>(dists.size())); ++i) {
    sum -= dists[i];
  }

  cout << sum << '\n';
  return 0;
}

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

long long n, a, b, c, d;

signed main () { 
    scanf("%lld %lld %lld %lld %lld", &n, &a, &b, &c, &d);
    for (long long m = 0; m < n; ++m) {
        if ((n - 1 - m) * c - m * d <= b - a && b - a <= (n - 1 - m) * d - m * c) {
            printf("YES\n");
            return 0;
        }
    }
    printf("NO\n");
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
using namespace std;
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n;i++) {
		string buf;
		cin >> buf;
		int pos = 0;
		deque<char> list;
		list.push_back(buf[0]);
		for (auto it = buf.begin()+1; it < buf.end(); it += 3) {
			if (*it == '-')pos++;
			else pos--;
			if (pos == list.size())list.push_back(*(it + 2));
			else if (pos < 0) {
				pos = 0;
				list.push_front(*(it + 2));
			}
		}
		string s(list.begin(), list.end());
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
#define LOCAL

#undef _GLIBCXX_DEBUG

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

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define LLINF 1e18
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

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

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

const llong MOD = 1e9 + 7;
const double PI = acos(-1);

int main() {
	IOS;
	llong a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO";
	}
	else if (abs(b - a) > abs(v - w) * t) {
		cout << "NO";
	}
	else cout << "YES";
	return 0;
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/tenka1-2019/tasks/tenka1_2019_d
//
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::fmt::*;
use std::io::*;
use std::str::*;

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, 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! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

const MOD: u64 = 998244353;
const LEN: usize = 90000;

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

    let mut dp: Vec<Vec<u64>> = vec![vec![0; LEN + 1]; 301];
    dp[0][0] = 3;
    for i in 0..n {
        for s in 0..LEN + 1 {
            let base = dp[i][s];
            if base == 0 {
                continue;
            }
            dp[i + 1][s] += base * 2;
            dp[i + 1][s] %= MOD;

            dp[i + 1][s + a[i]] += base;
            dp[i + 1][s + a[i]] %= MOD;
        }
    }

    let mut dp2: Vec<Vec<u64>> = vec![vec![0; LEN + 1]; 301];
    dp2[0][0] = 6;
    for i in 0..n {
        for s in 0..LEN + 1 {
            let base = dp2[i][s];
            if base == 0 {
                continue;
            }
            dp2[i + 1][s] += base;
            dp2[i + 1][s] %= MOD;

            dp2[i + 1][s + a[i]] += base;
            dp2[i + 1][s + a[i]] %= MOD;
        }
    }

    let mut total = 1;
    let mut two = 3;
    let mut tlen = 0;
    for i in 0..n {
        total *= 3;
        total %= MOD;
        two *= 2;
        two %= MOD;
        tlen += a[i];
    }
    total += (MOD - two);
    total %= MOD;

    for i in 1..tlen + 1 {
        let ab = tlen - i;
        if ab <= i {
            total += MOD - dp[n][i];
            total += MOD + dp2[n][i];
            total %= MOD;
        }
    }

    println!("{}", total);
}


Measured memory_bytes: 618108
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.bigint;

enum n0 = BigInt(0);
enum n1 = BigInt(1);
enum n2 = BigInt(2);
enum n3 = BigInt(3);
enum n5 = BigInt(5);

void main()
{
    auto T = readln.chomp.to!int;
    foreach (_t; 0..T) {
        auto nabcd = readln.split.to!(long[]);
        BigInt N = nabcd[0];
        BigInt A = nabcd[1];
        BigInt B = nabcd[2];
        BigInt C = nabcd[3];
        BigInt D = nabcd[4];

        auto memo = [n0: n0, n1: D];
        BigInt solve(BigInt n) {
            if (n !in memo) {
                auto res = n * D;
                res = min(res, solve(n / n2) + A + (n % n2) * D);
                if (n > n2) res = min(res, solve(n / n2 + n1) + A + (n2 - (n % n2)) * D);
                res = min(res, solve(n / n3) + B + (n % n3) * D);
                res = min(res, solve(n / n3 + n1) + B + (n3 - (n % n3)) * D);
                res = min(res, solve(n / n5) + C + (n % n5) * D);
                res = min(res, solve(n / n5 + n1) + C + (n5 - (n % n5)) * D);
                memo[n] = res;
            }
            return memo[n];
        }
        writeln(solve(N));
    }
}

Measured memory_bytes: 56464
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
 
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
 
const int INF = 1e9;
 
using namespace std;
 
int main() {
    long double a, b, C;
    long double S, L, h;
    cin >> a >> b >> C;
    long double rad = 2 * M_PI * C / 360;
    S = a * b * sin(rad) / 2;
    L = a + b + sqrt(square(a) + square(b) - 2 * a * b * cos(rad));
    h = b * sin(rad);
    cout << setprecision(10);
    cout << S << " " << L << " " << h << endl;
 
    return 0;
}

Measured memory_bytes: 1296
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD (long long)1e9+7
#define LINF (long long)4e18


int main(){
    int N; cin >> N;
    string S;
  	cin >> S;
    int num = 0;
    repr(i,1,N){
        if(S[i] == 'E') ++num;
    }
    int ans = num;
    rep(i,N-1){
        if(S[i] == 'W') ++num;
        if(S[i+1] == 'E')--num;
        ans = min(ans,num);
    }
    cout << ans << endl;
}
   

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


int main() {
    int N;
    cin >> N;
    vector<int> s(N);
    rep(i,N) cin >> s.at(i);
    sort(s.begin(), s.end());
    int sum = 0;
    rep(i,N) sum += s.at(i);
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    } else {
        rep(i,N) {
            if ((sum - s.at(i)) % 10 != 0) {
            cout << sum - s.at(i) << endl;
            return 0;
            } 
        }
        cout << 0 << endl;
        return 0;
    }
}



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

inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {
        w|=ch=='-';ch=getchar();
    }
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

signed main(){
    int l=read(),r=read(),d=read();

    int a=r/d,b=l/d;

    int ans=a-b;

    if(l%d==0)
        ans++;

    writeln(ans);

    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int LLI;

int main()
{
	int n;
	cin >> n;
	
	LLI arr[n], sum = 0;
	cin >> arr[0];
	
	sum += abs(arr[0]);
	
	for(int i = 1; i < n; i++)
	{
		cin >> arr[i];
		sum += abs(arr[i]-arr[i-1]);
	}
	
	sum += abs(arr[n-1]);
	
	if( (arr[0] >= 0 and arr[1] >= arr[0]) or (arr[0] <= 0 and arr[1] <= arr[0]) )
		cout << sum << "\n";
	else
		cout << sum - abs(arr[0]) - abs(arr[1]-arr[0]) + abs(arr[1]) << "\n";
		
	for(int i = 1; i < n-1; i++)
		if( (arr[i] >= arr[i-1] and arr[i+1] >= arr[i]) or (arr[i] <= arr[i-1] and arr[i+1] <= arr[i]) )
		cout << sum << "\n";
	else
		cout << sum - abs(arr[i]-arr[i-1]) - abs(arr[i]-arr[i+1]) + abs(arr[i+1]-arr[i-1]) << "\n";
		
	if( (arr[n-1] >= 0 and arr[n-1] <= arr[n-2]) or (arr[n-1] <= 0 and arr[n-2] <= arr[n-1]) )
		cout << sum << "\n";
	else
		cout << sum - abs(arr[n-1]) - abs(arr[n-1]-arr[n-2]) + abs(arr[n-2]) << "\n";		
}

Measured memory_bytes: 4348
n=int(input())
A=list(map(int,input().split()))
x,y=0,0
for a in A:
  if a%4==0:
    x+=1
  elif a%2==0:
    y+=1
if (n-y)%2==0 or y==0:
  d=(n-y)//2
else:
  d=(n-y)//2+1
print("Yes" if x>=d else "No")

Measured memory_bytes: 14252
# -coding: utf-8 -

n = int(input())
s = ["" for _ in range(n)]
for i in range(n):
    s[i] = input()

m = int(input())
t = ["" for _ in range(m)]
for i in range(m):
    t[i] = input()


s_sp = set(s)
dp = 0

for sp in s_sp:
    #青いカードカウント
    n_s = s.count(sp)
    #赤いカードカウント
    try:
        n_t = t.count(sp)
    except:
        n_t = 0
        pass
#    print(n_s - n_t)
    dp = max(dp, n_s - n_t)
    
print(dp)


Measured memory_bytes: 3064
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
  return list(map(int,input().split()))
def m(): #複数文字
  return map(int,input().split())
def onem(): #Nとかの取得
  return int(input())
def s(x): #圧縮
  a = []
  if len(x) == 0:
    return []
  aa = x[0]
  su = 1
  for i in range(len(x)-1):
    if aa != x[i+1]:
      a.append([aa,su])
      aa = x[i+1]
      su = 1
    else:
      su += 1
  a.append([aa,su])
  return a
def jo(x): #listをスペースごとに分ける
  return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
  return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
  ll = 0
  rr = r
  while True:
    mid = (ll+rr)//2

  if rr == mid:
    return ll
  if (ここに評価入れる):
    rr = mid
  else:
    ll = mid+1
"""

mod = 10**9+7 #出力の制限
N = 10**6 * 2 + 2
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def p(n,r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
# a = cmb(n,r)

r1,c1,r2,c2= m()

p1 = 0

p2 = 0

p3 = 0

p4 = 0

for i in range(1,r2+2):
  p1 += cmb(c2+i,i)
  p1 %= mod
for i in range(1,r1+1):
  p2 += cmb(c2+i,i)
  p2 %= mod
for i in range(1,r2+2):
  p3 += cmb(c1+i-1,i)
  p3 %= mod
for i in range(1,r1+1):
  p4 += cmb(c1+i-1,i)
  p4 %= mod

print((p1-p2-p3+p4)%mod)






Measured memory_bytes: 133048
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m), y(m);

	FOR(i, 0, m) {
		cin >> x[i] >> y[i];
		x[i]--, y[i]--;
	}
	// x -> y
	vector<int> ballcnt(n, 1);
	vector<bool> canbered(n, false);
	canbered[0] = true;
	FOR(i, 0, m) {
		int tx = x[i], ty = y[i];
		ballcnt[tx]--, ballcnt[ty]++;
		if (canbered[tx]) {
			canbered[ty] = true;
		}
		if (ballcnt[tx] == 0) {
			canbered[tx] = false;
		}
	}

	int num = 0;
	FOR(i, 0, n) {
		if (canbered[i])
			num++;
	}
	cout << num << endl;


	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = mod * mod/3;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

const int mn = 100000;
vector<int> p;
bool isp[mn];

void init() {
	fill(isp + 2, isp + mn, true);
	Rep(i, 2, mn) {
		if (!isp[i])continue;
		p.push_back(i);
		for (int j = 2 * i; j < mn; j += i) {
			isp[j] = false;
		}
	}
}
void solve() {
	init();
	int l, r; cin >> l >> r;
	int len = r - l + 1;
	vector<vector<int>> c(len);
	rep(i, p.size()) {
		ll d = (l+p[i]-1) / p[i];
		d *= p[i];
		for (ll j = d; j <= r; j += p[i]) {
			c[j - l].push_back(p[i]);
		}
	}
	int ans = 0;
	Rep1(i, l, r) {
		int cop = i; int num = 0;
		rep(j, c[i-l].size()) {
			while (cop%c[i-l][j] == 0) {
				cop /= c[i - l][j]; num++;
			}
		}
		if (cop > 1) {
			c[i - l].push_back(i); num++;
		}
		if (isp[num])ans++;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 60684
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
using namespace std;


vector<unsigned long long> prime_factors(unsigned long long n)
{
    vector<unsigned long long> factors;
    while (n % 2 == 0) {
      factors.push_back(2);
      n = n / 2;
    }
    
   for (unsigned long long i = 3; i <= sqrt(n); i += 2)
   {
        while (n%i == 0) {
            factors.push_back(i);
            n = n / i;
        }
   }

   if (n > 2) factors.push_back(n);
   return factors;
}

int main()
{
    unsigned long long number = 0;
    cin >> number;
    cout << number << ":";
    auto factors = prime_factors(number);
    for (int i = 0; i < factors.size(); i++) {
        cout << " " << factors[i];
    }
    cout << endl;
    //copy(begin(factors), end(factors),
    //    ostream_iterator<unsigned long long>(cout, " "));
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair

/// easy access -------------
using namespace std;
using ll = long long;
using ld = long double;
typedef pair<int,int> pii;
///-------------------------
/*
const int MAXN = 1e3+5;
vector<int> p;

void sieve()
{
    vector<bool> a(MAXN,false);
    for(int i=2; i<=MAXN; ++i)
    if (!a[i])
    {
        p.pb(i);
        for(int j=i; j<=MAXN/i; ++j)
            a[j*i]=true;
    }
    for(int x:p) cout << x << '\n';
}
*/
int main()
{
    Phuong_;
    int a,b,c;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << ' ' << b << ' ' << c;
    return 0;
}



Measured memory_bytes: 256
import sys
from collections import Counter

if sys.platform in ['ios','win32','darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

C = Counter(A).most_common()
# print(C)

double = 0
for c in C:
	num, cnt = c
	# print(cnt)
	if cnt % 2 == 0:
		double += 1

if double % 2:
	print(len(C)-1)
else:
	print(len(C))

Measured memory_bytes: 22036
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };


int main () {
	int n;
	cin >> n;
	VI a (n);
	rep (i, n) {
		cin >> a[i];
	}
	
	int l, r,cnt=0;
	int minv = 1e9;
	for (int l = 0; l < n; l++) {
		while (a[l] > 0) {
			for (r = l; r < n; r++) {
				if (a[r] == 0) break;
			}

			for (int i = l; i < r; i++) {
				a[i]--;
			}
			cnt++;
		}
	}
	cout << cnt << endl;
}

  

Measured memory_bytes: 256
#include<iostream>

using namespace std;
int main(){
    long long int N;
    cin >> N;

    string s;
    cin >> s;

    int scanw = 0;
    int scanr = N-1;
    int cnt = 0;


    while (true) {
        int i;
        for (i = scanw; i < N; ++i) {
            if(s[i]=='W') {
                scanw = i;
                break;
            }
        }
        if(i>=N) break;

        for (i = scanr; i >= 0; --i) {
            if(s[i]=='R') {
                scanr = i;
                break;
            }
        }
        if(i<0) break;

        if (scanw >= scanr) break;

        cnt++;
        scanw++;
        scanr--;
    }

    cout << cnt << endl;
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    ll sum = 0;
    rep(i, n)
    {
        cin >> a[i];
        sum += a[i];
    }

    ll base = sum/2;
    rep(i, n - 1)
        base -= a[i] * int(i % 2 == 1);
    // cout << base << ' ' << sum << endl;
    vector<int> ans(n);
    ans[0] = base;
    rep(i, n)
    {
        if (i == 0) continue;
        ans[i] = a[i - 1] - ans[i - 1];
    }

    rep(i, n)
        cout << 2 * ans[i] << ' ';
    cout << endl;
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll count(ll k)
{
	return k*k*k*k*k;
}
int main()
{
	ll x;
	cin>>x;
	for(ll i=-1000;i<=1000;i++){
		for(ll j=-1000;j<=1000;j++){
			if(count(i)-count(j)==x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
} 

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
const int N = 3e5+ 2, mod = 1e9 + 7;

void solve() {
     ll a, b, c, d;
     cin >> a >> b >> c >> d;
     ll ans = -1e18;
     ans = max(ans, a*c);
     ans = max(ans, a*d);
     ans = max(ans, b*c);
     ans = max(ans, b*d);
     cout << ans << '\n';
}    


int main() {
	int tt = 1;
	// cin >> tt;
	for (int tc = 1; tc <= tt; tc++) {
		// cout << "Case #:" << tc << " ";
		solve();
	}
}

Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;


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

    string ans = "";
    for (char c : s) {
        char change = c+n;
        if (change > 'Z') change = change - 'Z' + 'A'-1;
        ans += change;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
//url:
//problem name: Brick Break

#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vecl E(N+1);
    vecl W(N+1);
    REP(i,N) {
        if(S[i] == 'W') {
            W[i+1] = W[i] + 1;
            E[i+1] = E[i];
        }
        else {
            E[i+1] = E[i] + 1;
            W[i+1] = W[i];
        }
    }
    /*
    REP(i,N+1) {
        cout << E[i] << " " << W[i] << endl;
    }
    */
    ll ans = 1e9;
    REP(i,N) {
        ll res;
        if(i == 0) res = E[N] - E[1];
        else if(i == N-1) res = W[N-2]-W[0];
        else res = (W[i]-W[0])+(E[N]-E[i+1]);
        //cout << res << endl;
        chmin(ans,res);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define mp make_pair
#define maxn 105
using namespace std;
const int inf = 0x3f3f3f3f;
const int neginf = 0xc0c0c0c0;
typedef long long ll;
typedef pair<int,int> P;
int n,x,a[maxn];

int main(){
	scanf("%d%d",&n,&x);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a + 1,a + n + 1);
	int ans = 0;
	int rest = x;
	for(int i=1;i<n;i++){
		if(rest >= a[i]){
			ans++;
			rest -= a[i];
		}
	}
	if(rest == a[n]) ans++;
	printf("%d\n",ans);
	return 0;
}


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


int main() 
{  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
string s1;
string s2;
cin>>s1;
cin>>s2;
ll i=0;ll c=0;
while(i<3)
{
    if(s1[i]==s2[i])
    {
        c++;
    }
    i++;
}
cout<<c;    




return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define Max 100000

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

int right(int i){
  return 2 * i + 1;
}


int main(){
  int h, i, A[Max + 1];

  scanf("%d", &h);
  for(i = 1 ; i <= h ; i++) scanf("%d", &A[i]);

  for(i = 1 ; i <= h ; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i) <= h) printf("left key = %d, ", A[left(i)]);
    if(right(i) <= h) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
 
  return 0;
}


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

using namespace std;

using ll = long long;

const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;

ll solve(ll H, ll W) {
    vector<ll> diffs;
    ll h1 = H / 3;
    h1--;
    for (int i = 0; i < 3; i++) {
        ll h = h1 + i;
        if (h <= 0 || h >= H) continue;
        ll a = h * W;
        ll b = (H - h) / 2 * W;
        ll c = H * W - a - b;
        if (b > 0) diffs.push_back(max({a, b, c}) - min({a, b, c}));
        b = W / 2 * (H - h);
        c = H * W - a - b;
        if (b > 0) diffs.push_back(max({a, b, c}) - min({a, b, c}));
    }
    return *min_element(diffs.begin(), diffs.end());
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    cout << min(solve(H, W), solve(W, H)) << endl;
}

Measured memory_bytes: 256
H,W = map(int,input().split())

table = [[0]*(W+1) for i in range(H+1)]

for row in range(H):
    work = list(map(int,input().split())) #★★直にtableに代入すると、列数が変わってしまう!!!★★★
    for col in range(W):
        table[row][col] = work[col]


for row in range(H):
    for col in range(0,W):
        table[row][W] += table[row][col]


for col in range(0,W+1):
    for row in range(0,H):
        table[H][col] += table[row][col]


for row in range(0,H+1):
    print("%d"%(table[row][0]),end="")
    for col in range(1,W+1):
        print(" %d"%(table[row][col]),end = "")
    print()



Measured memory_bytes: 6208
//Created Time:2019年09月28日 星期六 20时30分36秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 5003

using namespace std;

int n, m;
int f[N], c[N], a[N];

int main(){
	scanf("%d%d", &n, &m);
	memset(f, 127, sizeof f);
	for(int i = 1; i <= m; ++i){
		scanf("%d", a + i);
		int x; scanf("%d", &x);
		while(x--){
			int y; scanf("%d", &y); c[i] |= (1 << y - 1);
		}
	}
	f[0] = 0;
	for(int i = 0; i < (1 << n); ++i){
		for(int j = 1; j <= m; ++j)
			f[i | c[j]] = min(f[i | c[j]], f[i] + a[j]);
	}
	if(f[(1 << n) - 1] > 1e9) f[(1 << n) - 1] = -1;
	cout << f[(1 << n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>

using namespace std;
#define i64  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807

void solve(void)
{

  string S;
  vector<string> text;

  cin>> S ;cin.ignore();;
    for (int i = 0; i < S.size(); i++)
    {
      if(S[i] >= 'a') S[i] -= 32;
    }
    
  while (true)
  {
    string str;
    cin>>str;
    if(str == "END_OF_TEXT") break;

    if(str[str.size() -1] == '.')
    {
      str.erase(str.size() - 1);
    }

    for (int i = 0; i < str.size(); i++)
    {
      if(str[i] >= 'a') str[i] -= 32;
    }
    

    text.push_back(str);
  }

  int count = 0;

  for (int i = 0; i < text.size(); i++)
  {
    if(text[i] == S) count++;
  }
  
  cout<<count<<endl;
  

  return;
}

int main(int argc, const char *argv[])
{

  solve();

  return 0;
}



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

int main()
{
    int k;
    scanf("%d",&k);
    int res=-1;

    int p=0;
    for(int i=1; i<=k; i++)
    {
        p=(p*10+7)%k;
        if(p==0)
        {
            res=i;
            break;
        }
    }
    printf("%d\n",res);
}


Measured memory_bytes: 3828
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)));
#define Mx(a , b) ((a) > (b) ? (a) : (b))
#define Mn(a , b) ((a) < (b) ? (a) : (b))

const double EPS = 1e-10;
const int INF = 2147483647;
const LL mod = 1e9 + 7;

int H , W , A , B;
LL con[200001];
LL rev[200001];
LL z[30];
LL ans;

LL f(LL a , LL b){
	return (rev[a] * rev[b] % mod) * con[a + b] % mod;
}

int main(){
	scanf("%d%d%d%d" , &H , &W , &A , &B);
	con[0] = 1;
	for(int i = 1 ; i < 200001 ; ++i){
		con[i] = (LL)i * con[i - 1];
		con[i] %= mod;
	}
	z[0] = con[200000];
	for(int i = 0 ; i < 29 ; ++i) z[i + 1] = z[i] * z[i] % mod;
	rev[200000] = 1;
	for(int i = 0 , j = mod - 2 ; j > 0 ; ++i , j /= 2){
		rev[200000] *= j % 2 == 1 ? z[i] : (LL)1;
		rev[200000] %= mod;
	}
	for(int i = 200000 ; i > 0 ; --i){
		rev[i - 1] = rev[i] * i % mod;
	}
	for(int i = 0 ; i < H - A ; ++i){
		ans += f(i , B - 1) * f(W - B - 1 , H - i - 1) % mod;
		ans %= mod;
	}
	printf("%lld\n" , ans);
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
int n,s[33]={1},t;main(){for(;n<33;s[n]+=t,s[n+1]+=t,s[n+2]+=t)t=s[n++];for(;std::cin>>n,n;)printf("%d\n",(s[n]-n)/10/365+1);return 0;}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m; cin>>n>>m;
  cout<<n*(n-1)/2+m*(m-1)/2;
}

Measured memory_bytes: 256
/*
ID: wangjun30
LANG: C++11
TASK:
*/
#include<iostream>
#include<algorithm>
#include<array>
#include<unordered_map>
#include<map>
#include<set>
#include<list>
#include<unordered_set>
#include<vector>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
//#include<fstream>
#define int long long
using namespace std;
//ifstream cin(".in");
//ofstream cout(".out");
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n,m;
	cin>>n>>m;
	int num[n];
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>num[i];
		sum+=num[i];
	}
	sort(num,num+n,greater<int>());
	for(int i=0;i<min(m,n);i++)
		if(num[i]*4*m<sum){
			cout<<"No";
			return 0;
		}
	cout<<"Yes";
	return 0;
}

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) {
        ll d = euclid(b, a % b, y, x);
        return y -= a / b * x, d;
    }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1)
            ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1);
        return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e)
            return Mod(1);
        Mod r = *this ^ (e / 2);
        r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

bool isgood[10005];

int main() {
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    int n, m, t;
    cin >> n >> m >> t;

    rep(i, 0, t) isgood[i] = true;

    rep(i, 0, n) {
        int q; cin >> q;
        for (int i = q; i >= q - m && i >= 0; i--)
            isgood[i] = false;
        for (int i = q; i < q + m && i < t; i++)
            isgood[i] = false;
    }

    int ans = 0;
    rep(i, 0, t) ans += isgood[i];
    cout << ans << endl;
}



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

string s, t, ans;
bool used[10];
ll Max = 0, ten = 1, a;
void dfs() {
	if (s.size() == t.size()) {
		ll b = stoll(t);
		ll k = min(abs(a - b), ten - abs(a - b));
		if (Max < k) {
			Max = k; ans = t;
		}
		else if (Max == k) {
			ll c = stoll(ans);
			if (b < c)ans = t;
		}
		return;
	}
	rep(i, 10) {
		if (!used[i]) {
			used[i] = true; t += char(i + '0');
			dfs();
			used[i] = false; t.pop_back();
		}
	}
}
int main() {
	cin >> s; a = stoll(s);
	rep(i, s.size())ten *= 10; dfs();
	cout << ans << endl;
}

Measured memory_bytes: 3240
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
//typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll h, w;std::cin >> h >> w;
  ll tmp = (h*w)/2;
  if(w==1||h==1) std::cout << 1 << '\n';
  else if(h%2==0||w%2==0) std::cout << tmp << '\n';
  else std::cout << tmp + 1 << '\n';
  return 0;
}


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

namespace abc159_b
{
  class Program
  {
    static void Main(string[] args)
    {
      var S = CIn.Read().ToCharArray();
      var N = S.Length;

      for (int i = 0; i < N / 2; i++)
      {
        if (S[i] != S[N - i - 1])
        {
          Console.WriteLine("No");
          return;
        }
      }

      for (int i = 0; i < N / 4; i++)
      {
        if (S[i] != S[N / 2 - i - 1])
        {
          Console.WriteLine("No");
          return;
        }
      }

      Console.WriteLine("Yes");
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}

Measured memory_bytes: 13268
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}
// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;
 
int main(){
    ll x,c,y=0,n,m,l,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool fw=false,fb=false;
    cin >> s;

    if(s.find_first_not_of(s[0]) == string::npos){
        cout << 0 <<endl;
        return 0;
    }

    for(int i=0; i<s.size();i++){
        if(s[i]=='W'){
            if(fw==true){
                if(fb==true){
                    sum++;
                }
                fb=false;
            }
            else{
                if(fb==true){
                    sum2++;
                }
                fb = false;
            }
            fw = true;
        }
        else{
            fb = true;
        }
    }
    if(fb==true){sum2++;}
    cout << sum*2 + sum2 << endl;
    return 0;
}

Measured memory_bytes: 512
n = 7
k = int(input())
amari = 7%k
if amari == 0:
    print(1)
    exit()
for i in range(1, 10**6):
    amari += 7*pow(10, i, k)
    amari %= k
    if amari == 0:
        print(i+1)
        exit()
print(-1)

Measured memory_bytes: 63556
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main(){
    let line: Vec<i64> = read_as_vec();

    let (r_ball, g_ball, b_ball, n) = (line[0], line[1], line[2], line[3]);
    let mut ans: u64 = 0;
    
    for r_box in (0..n/r_ball+2){
        if n - r_box*r_ball < 0{
            break;
        }
        for g_box in (0..(n-r_box*r_ball)/g_ball+2){
            if (n - r_box*r_ball - g_box*g_ball >= 0) &&
                (n - r_box*r_ball - g_box*g_ball)%b_ball == 0{
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


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

int main(void){
  int a[3]; cin >> a[0] >> a[1] >> a[2];
  sort(&a[0], &a[3]);
  int ans = (a[2] - a[0])/2 + (a[2] - a[1])/2;
  int flg = (a[2] - a[0])%2 + (a[2] - a[1])%2;
  if (flg==1) ans += 2; else if (flg==2) ans += 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<set>
#include<cstdio>
int i,n,v[9999];main(){for(;scanf("%d",&n),n;){std::set<int>t;for(i=1;i<n;i++)v[i]=0,t.insert(i*i%n);for(auto s=t.begin(),S=s,T=t.end();s!=T;S=++s)for(;++S!=T;v[i>n/2?n-i:i]+=2)i=*S-*s;for(i=0;i<n/2;)printf("%d\n",v[++i]);}}

Measured memory_bytes: 1300
#include <iostream>
using namespace std;
int main()
{
    int k;
    cin >> k;
    if (k % 7 == 0) k /= 7;
    if (k % 2 == 0 || k % 5 == 0) {
        cout << -1 << endl;
        return 0;
    }
    int n = 1, cnt = 1;
    while (n % k != 0) {
        n = (n*10 + 1) % k;
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define maxn 1010
using namespace std;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n,cnt;
int x[maxn],y[maxn],d[maxn];
bool tag[2];
int main()
{
    read(n);
    for(int i=1;i<=n;++i)
        read(x[i]),read(y[i]),tag[((x[i]+y[i])%2+2)%2]=true;
    if(tag[0]&&tag[1])
    {
        puts("-1");
        return 0;
    }
    for(int i=30;i>=0;--i) d[++cnt]=(1<<i);
    if(tag[0]) d[++cnt]=1;
    printf("%d\n",cnt);
    for(int i=1;i<=cnt;++i) printf("%d%c",d[i]," \n"[i==cnt]);
    for(int i=1;i<=n;++i)
    {
        for(int j=1;j<=cnt;++j)
        {
            if(abs(x[i])>abs(y[i]))
            {
                if(x[i]>0) x[i]-=d[j],putchar('R');
                else x[i]+=d[j],putchar('L');
            }
            else
            {
                if(y[i]>0) y[i]-=d[j],putchar('U');
                else y[i]+=d[j],putchar('D');
            }
        }
        putchar('\n');
    }
    return 0;
}

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

using namespace std;

#define sz(c) ((int)c.size())
#define	pb push_back

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;

constexpr int MAX_N = 200'074;
constexpr int SIGMA = 30;
constexpr ll INF = 1'000'000'000'000'000'000;
constexpr ll P = 9'982'443'53;
constexpr double PI = 3.14159265359;
constexpr double TO_RAD = PI/180.;
constexpr long double EPS = 1e-6;

ll A[MAX_N];
int main(){
	int N;
	cin >> N;	
	bool hasZero = false;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		hasZero |= (A[i] == 0);
	}
	if(hasZero){
		cout << "0\n";
		return 0;
	}
	ll total = 1;
	for(int i = 0; i < N; i++){
		total *= A[i];
		if(total > INF || total <= 0){
			cout << "-1\n";
			return 0;
		}
	}
	cout << total << "\n";
	return 0;
}

Measured memory_bytes: 4412