akhauriyash/Code-Regression huggingface dataset:
use std::collections::VecDeque;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut graph = vec![vec![]; n];
    let a: Vec<usize> = (0..n).map(|_| sc.read()).collect();

    for _ in 0..m {
        let x: usize = sc.read();
        let y: usize = sc.read();
        graph[x].push(y);
        graph[y].push(x);
    }

    let mut queue = VecDeque::new();
    let mut used = vec![false; n];
    let mut groups = Vec::new();
    for i in 0..n {
        if used[i] {
            continue;
        }
        queue.push_back(i);
        used[i] = true;
        let mut group = vec![a[i]];
        while let Some(v) = queue.pop_front() {
            for &to in &graph[v] {
                if used[to] {
                    continue;
                }
                used[to] = true;
                queue.push_back(to);
                group.push(a[to]);
            }
        }

        group.sort();
        groups.push(group);
    }

    let mut required = (n - 1 - m) * 2;
    if required == 0 {
        println!("0");
        return;
    }
    let mut ans = 0;
    let mut rest = Vec::new();
    for &ref v in &groups {
        ans += v[0];
        required -= 1;
        for i in 1..v.len() {
            rest.push(v[i]);
        }
    }
    if required > rest.len() {
        println!("Impossible");
        return;
    }

    rest.sort();
    for i in 0..required {
        ans += rest[i];
    }
    println!("{}", ans);
}

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            ptr: 0,
            length: 0,
            buf: vec![0; 1024],
            small_cache: vec![0; 1024],
        }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool {
        b == b'\n' || b == b'\r' || b == b'\t' || b == b' '
    }

    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)])
                    .parse()
                    .unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}


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

void solve(long long K, long long A, long long B)
{
    auto AdivK = A / K;
    auto BdivK = B / K;
    if (AdivK < BdivK || A % K == 0 || B % K == 0) {
        cout << "OK\n";
    } else {
        cout << "NG\n";
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n);
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin>>b[i];
    }
    set<pair<int,int>>s;
    for (int i = 0; i < n; i++)
    {
        s.emplace(b[i],i);
    }
    ll ans=0;
    while(!s.empty()){
        int i=s.rbegin()->second;
        s.erase(--s.end());
        int step = b[(i+1)%n]+b[(i+n-1)%n];
        if((b[i]-a[i])%step == 0){
            ans+=(b[i] - a[i]) / step;
            b[i]=a[i];
            continue;
        }
        if(step>=b[i]){
            cout<<-1<<endl;
            return 0;
        }
        ans+=b[i]/step;
        b[i]%=step;
        if(b[i]<a[i]){
            cout<<-1<<endl;
            return 0;
        }
        s.emplace(b[i],i);
    }
    cout<<ans<<endl;
   
    return 0;
}

Measured memory_bytes: 17920
H,W=map(int,input().split())
L=[]
l=["*" for i in range(W+2)]
L.append(l)
for i in range(H):
    s=["*"]+list(input())+["*"]
    L.append(s)
L.append(l)
#print(L)

X=[1,0,-1,0]
Y=[0,1,0,-1]

cnt=0
if L[1][1]=="#":
    cnt+=1

C=[[10000 for i in range(W+2)]for j in range(H+2)]
Q=[(0,1,1)]
#print(L)
import heapq
heapq.heapify(Q)
for i in range(10**6):
    if len(Q)==0:
        break
    d,h,w=Q[0]
    heapq.heappop(Q)
    if C[h][w]==10000:
        C[h][w]=d
        for j in range(2):
            if C[h+X[j]][w+Y[j]]==10000 and L[h+X[j]][w+Y[j]]!="*":
                if L[h+X[j]][w+Y[j]]=="#" and L[h][w]==".":
                    heapq.heappush(Q,(d+1,h+X[j],w+Y[j]))
                else:
                    heapq.heappush(Q,(d,h+X[j],w+Y[j]))
print(C[H][W]+cnt)

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

using namespace std;
typedef long long ll;

int main()
{
  ll n;
  cin >> n;
  vector<vector<pair<int, int>>> mems(n, vector<pair<int, int>>{});
  for (auto i = 0; i < n; i++)
  {
    int a;
    cin >> a;
    for (int j = 0; j < a; j++)
    {
      int x, y;
      cin >> x >> y;
      mems[i].push_back(make_pair(x, y));
    }
  }

  // xの発言内容に注目する
  // 正直者だと言っている
  // 嘘つきだといっている
  // 両方
  // なし

  // 矛盾が発生するということはどういうことか

  int pattern_max = 1 << n;
  int ans = 0;
  for (auto i = 0; i < pattern_max; i++)
  {
    int cur_true_num = 0;
    vector<int> pattern = {};
    for (auto j = 0; j < n; j++)
    {
      auto x = (i >> j) & 1;
      // cout << x;
      pattern.push_back(x);
      if (x)
      {
        cur_true_num++;
      }
    }
    // cout << " " << cur_true_num << endl;

    bool is_honest = true;
    for (auto j = 0; j < pattern.size(); j++)
    {
      if (pattern[j] == 0)
      {
        continue;
      }

      auto m = mems[j];
      for (auto k = 0; k < m.size(); k++)
      {
        auto target_index = m[k].first - 1;
        auto honest = m[k].second;
        if (pattern[target_index] == honest)
        {
          continue;
        }
        else
        {
          is_honest = false;
          // cout << "contradict "
          //      << "k: " << k << endl;
          break;
        }
      }

      if (!is_honest)
      {
        break;
      }
    }
    if (is_honest)
    {
      ans = max(ans, cur_true_num);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;

int[] A, B;
int K;
void main() {
    string[] input = readln.split;
    A = input[0].to!(char[]).map!(a=>(a-'0').to!int).array;
    B = input[1].to!(char[]).map!(a=>(a-'0').to!int).array;
    K = input[2].to!int;
    while (B.length < A.length) B = 0~B;
    A.reverse; B.reverse;
    func(0, 0, new int[A.length], 0).writeln;
}
long func(int index, int b, int[] C, int k) {
    if (index == A.length) {
        return connect(C);
    } else {
        long result;
        if (A[index] - b >= B[index]) {
            C[index] = A[index]-b-B[index];
            result = max(result, func(index+1, 0, C, k));
        } else {
            C[index] = A[index]-b+10-B[index];
            result = max(result, func(index+1, 1, C, k));
            if (k+1 <= K) {
                result = max(result, func(index+1, 0, C, k+1));
            }
        }
        return result;
    }
}
long connect(int[] C) {
    long result = 0;
    for(int i=0; i<C.length; i++) {
        result += C[i]*10^^i;
    }
    return result;
}

Measured memory_bytes: 2516
n = int(input())
a = 0
num = []
from functools import reduce
num = [int(x) for x in list(str(n))]
if n != 100000 and n != 10000 and n != 1000 and n != 100 and n != 10:
  for i in num:
    a = a + i
else:
    a = 10
print(a) 

Measured memory_bytes: 3828
N = int(input())
cnt = 0
f = False
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        f = True
if f:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include<bits/stdc++.h>
#define int long long
#define float double
#define endl "\n"
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

using namespace std;

const int inf = 1e17 + 7;
const int MOD = 1e7 + 9;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	//CODE FOR SPECIFIED INPUT AND OUTPUT
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	int red[a];
	for(int i=0;i<a;i++) cin>>red[i];
	int green[b];
	for(int i=0;i<b;i++) cin>>green[i];
	int color[c];
	for(int i=0;i<c;i++) cin>>color[i];
	sort(red,red+a,greater<int>());
	sort(green,green+b,greater<int>());
	sort(color,color+c,greater<int>());
	int ans[x+y];
	int ptr = 0;
	for(int i=0;i<x && i<a;i++) ans[ptr++] = red[i];
	for(int i=0;i<y && i<b;i++) ans[ptr++] = green[i];
	sort(ans,ans+x+y,greater<int>());
	int back = x+y-1;
	int front = 0;
	while(front<c && back>=0 && ans[back]<color[front]) ans[back--]=color[front++];
	int sum = 0;
	for(int i=0;i<x+y;i++) sum += ans[i];
	cout<<sum<<endl;
	return 0;
}



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

int main(){
	
	int k;
	ll sum = 0;
	cin >> k;
	
	for(int i=1; i<=k; i++){
		for(int j=1; j<=k; j++){
			int a = __gcd(i, j);		
			for(int l=1; l<=k; l++){
				sum+= __gcd(a, l);
			}
		}
	}
	
	cout << sum << endl;	
	
	return 0;
}


Measured memory_bytes: 3632
# coding: utf-8
# Your code here!
def main():
    import sys
    line = sys.stdin.readline
    A,B,N = map(int,input().split())
    if B>N:
        ans = A*N//B
    else:
        ans = A*(B-1)//B
    print(ans)

if __name__== "__main__":
    main()


Measured memory_bytes: 9048
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;
    string A, B, C;
    cin >> A >> B >> C;

    int ans =0;
    REP(i, N) {
        int a = A[i];
        int b = B[i];
        int c = C[i];
        if (a == b && b == c) {

        }
        else if (a == b || b == c || c == a) {
            ans += 1;
        }
        else {
            ans += 2;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(s[1] == s[2] && (s[0] == s[1] || s[2] == s[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int abs (int X, int Y) {
    if(X >= Y) {
        return X - Y;
    } else {
        return Y - X;
    }
}

int main() {
    int X, N;
    cin >> X >> N;
    if(N == 0) {
        cout << X << endl;
        return 0;
    }
    vector<int> p(N);
    for (int i = 0; i < N; i++) {
        cin >> p.at(i);
    }

    sort(p.begin(), p.end());


    vector<int> V(102);
    for (int i = 0; i < 102; i++) {
        V.at(i) = i;
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 102; j++) {
            if (p.at(i) == V.at(j)) {
                V.at(j) = -1;
            }
        }
    }

    sort(V.begin(), V.end());

    int ans;

    for (int i = 1; i < 102; i++){
        ans = V.at(i);

        if (X < V.at(i)){
            if (abs(X, V.at(i - 1)) <= abs(X, V.at(i))) {
                ans = V.at(i - 1);
                if (ans == -1) {
                    ans = V.at(i);
                }
                break;
            } else {
                ans = V.at(i);
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>

using std::cin;using std::cout;using std::cerr;using std::endl;

#define rep(i,a,b) for(int i = a;i <= b;++i)
#define per(i,a,b) for(int i = a;i >= b;--i)



int main(){

	std::ios::sync_with_stdio(0);
	cin.tie(0);
	int x; 
	cin>>x;

	if(x >= 30){
		cout<<"Yes";
	}
	else cout<<"No";


	return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL x,k,d;
    cin >> x >> k >> d;
    if (x < 0) x *= -1;
    LL t = x / d;
    if (t > k) {
        cout << x - k * d << endl;
        return;
    }
    x -= t * d;
    k -= t;
    if (k % 2 == 0) {
        cout << x << endl;
    } else {
        cout << min(x + d, abs(x - d)) << endl;
    }
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 3620
N, M = [int(i) for i in input().split()]
L = [[int(i) - 1 for i in input().split()] for _ in range(M)]
P = [int(i) for i in input().split()]

ans = 0
for i in range(2 ** N):
    su = 0
    for k in range(M):
        count = 0
        for l in L[k][1:]:
            if (i >> l) & 1:
                count += 1
        if count % 2 == P[k]:
            su += 1
    if su == M:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;


struct UnionFind {
	VI par;
	UnionFind(int N) :par(N) {
		REP(i, N)par[i] = i;
	}
	int root(int x) {
		if (par[x] == x)return x;
		return par[x] = root(par[x]);
	}
	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry)return;
		par[rx] = ry;
	}
	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N; cin >> N;
	VI A(N);
	int ans = 0;
	REP(i, N) {
		cin >> A[i];
		ans += A[i];
	}
	int M;
	cin >> M;
	REP(i, M) {
		int a, b; cin >> a >> b; a--;
		cout << ans - A[a] + b << endl;
	}
	return 0;
}



Measured memory_bytes: 256
# 9_A
# w = input().upper()
# t = ""
# while True:
#     tmp = input()
#     if tmp == "END_OF_TEXT":
#         break
#     t += tmp.upper() + " "
# list = t.split()
# print(list.count(w))

# 9_B
# while True:
#     t = input()
#     if t == "-":
#         break
#     m = int(input())
#     for i in range(m):
#         h = int(input())
#         t = t[h:] + t[:h]
#     print(t)

# 9_C
# n = int(input())
# score_t, score_h = 0, 0
# for i in range(n):
#     t, h = input().split()
#     if t > h:
#         score_t += 3
#     elif h > t:
#         score_h += 3
#     else:
#         score_t += 1
#         score_h += 1
# print(f"{score_t} {score_h}")

# 9_D
t = str(input())
o_list = []
for i in range(int(input())):
    o_list = input().split()
    a, b = int(o_list[1]), int(o_list[2])
    if o_list[0] == "print":
        print(t[a : b + 1])
    elif o_list[0] == "reverse":
        t = t[:a] + t[a : b + 1][::-1] + t[b + 1 :]
    elif o_list[0] == "replace":
        t = t[:a] + o_list[3] + t[b + 1 :]



Measured memory_bytes: 5612
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
using namespace std;
long long  dp[3005][6005]={0};
#define debug(x) cout<<"###"<<x<<"###"<<endl;
struct node{
	long long  time,hap;
}dish[3005];
bool cmp(struct node a,struct node b)
{
	return a.time<b.time;
}
int main()
{
	long long  n,t;
	scanf("%lld%lld",&n,&t);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&dish[i].time,&dish[i].hap);
	}
	sort(dish+1,dish+1+n,cmp);//i  件  j  时间 
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<t+dish[i].time;j++)
		{
			if(j<dish[i].time)
			{
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=max(dp[i-1][j-dish[i].time]+dish[i].hap,dp[i-1][j]);
			}
		}
	}
	long long  Max=0;
	for(int i=1;i<=n;i++)
	{
		Max=max(Max,dp[n][t+dish[i].time-1]);
	}
	printf("%lld\n",Max);
}

Measured memory_bytes: 141056
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl;
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)
#define INF INT_MAX/2

const ll mo = 1000003;
ll fac[2*mo];
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mo;
		a = a * a % mo;
		n >>= 1;
	}
	return res;
}

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

	fac[0] = 1;
	rep(i, 1, 2 * mo) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mo;
	}


	rep(i, 0, q) {
		ll x, d, n;
		cin >> x >> d >> n;
		if (d == 0) {
			puts(modpow(x, n));
			continue;
		}

		ll ans = modpow(d, n);
		x = x * modpow(d,mo-2);
		x %= mo;
		if (x + n - 1 >= mo) {
			ans *= 0;
		}
		else {
			ans *= fac[x + n - 1];
			ans %= mo;
			ans *= modpow(fac[x-1],mo-2);
			ans %= mo;
		}
		puts(ans);
	}

	return 0;
}


Measured memory_bytes: 16512
//AtCoder Begginner Contest 091 A
#include <iostream>
//#include <algorithm>
using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	int res;
	if(a>b){
		res = a-1;
	}else{
		res = a; 
	}
	/*
	char S[10];
	for(int i=0;i<10;++i){
		cin >> S[i];
	}
	//S[3] = "8";
	/*int N;
	int d[110];
	cin >> N;
	for(int i=0;i<N;++i){
		cin >> d[i];
	}
	sort(d,d+N);
	int res = 1;
	for(int i=1;i<N;++i){
		if(d[i-1]<d[i]){
			++res;
		}
	}
	/*
	
	string res;
	if(amari<=A){
		res = "Yes";
	}else{
		res = "No";
	}
	*/
	cout << res << endl;
}


Measured memory_bytes: 256
program minor

 implicit none
 character::s*200000,t*200000,ss*200000,tt*200000
 integer::length,i,ans

 read*,s,t
 length=len_trim(s)
 !print*,length
 !ss=s(1:length)
 !tt=t(1:length)
 !print*,s,t


 ans=0
 do i=1,length
  if(s(i:i)/=t(i:i)) then
   ans=ans+1
  end if
 end do

 print*,ans

end program minor

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef long double ld;
typedef vector<ll>VI;
typedef pair<int,int>P;
#define VV(T) vector<vector<T>>
#define sz(x) int(x.size())
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i,n) for (ll i=(ll)n-1;i>=0;i--)
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX6 1001001//6
#define MAX7 10010010//7
#define SENTINEL 2000000000//9
#define INF 1<<30
#define INFTY 1LL<<60
#define MAX_INT INT_MAX
#define Endl '\n'
#define CLR(mat) memset(mat, 0, sizeof(mat))
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}//最大公約数
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}//最小公倍数
template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}
const int MOD = 1000000007;

inline ll mod_add(ll a,ll b){return (a+b)%MOD;}
inline ll mod_sub(ll a,ll b){return (a+MOD-b)%MOD;}
inline ll mod_mul(ll a,ll b){return ((a%MOD)*(b%MOD))%MOD;}
inline ll mod_pow(ll x,ll n,ll mod=(ll)MOD){ll res=1;while(n>0){
if(n&1)res=res*x%mod;
x=x*x%mod;n>>=1;}return res;}
inline ll mod_inv(ll x){return mod_pow(x,MOD-2);}
inline ll mod_div(ll a, ll b){return mod_mul(a,mod_inv(b));}
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
//push_back -> emplace_back

#include <atcoder/fenwicktree>
using namespace atcoder;


int main(){
  int n, q;
  scanf("%d %d", &n, &q);
  
  fenwick_tree<long long> fw(n);
  for (int i = 0; i < n; i ++) {
    int a;
    scanf("%d", &a);
    fw.add(i, a);
  }
  
  for (int i = 0; i < q; i ++) {      
    int t, u, v;
    scanf("%d %d %d", &t, &u, & v);
    if (t == 0){
      fw.add(u, v);
    }
    else{
      printf("%lld\n", fw.sum(u, v));
    }
    
  }
    
  return 0;
  
}  


Measured memory_bytes: 8224
program cm
  implicit none
  integer::N
  integer(16)::ANS=0
  integer::i,j,ij,k
read*,N
do i=1,N
  do j=1,N
    ij=gcd(i,j)
    do k=1,N
      ANS=ANS+gcd(ij,k)
    end do
  end do
end do
print"(i0)",ANS
contains
integer recursive function gcd(a, b)result(res)
  integer, intent(in)::a, b
  res=merge(b, gcd(b, mod(a, b)),mod(a, b)==0)
end function
end program cm

Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,a[N];
int main(){
//	freopen("01.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	sort(a+1,a+n+1);
	int ans=0,tmp=0;
	a[0]=-1e9;
	for(int i=1;i<=n;++i)
		if(a[i]>=0 && a[i-1]<=0){
			tmp=i;break;
		}
	if(tmp==0){
		int ans=a[n];
		for(int i=1;i<n;++i)
			ans-=a[i];
		cout<<ans<<endl;
		int res=a[n];
		for(int i=1;i<n;++i)
			cout<<res<<" "<<a[i]<<endl,res-=a[i];
		return 0;
	}
	tmp=max(tmp,2);
	for(int i=1;i<tmp;++i)
		ans-=a[i];
	for(int i=tmp;i<=n;++i)
		ans+=a[i];
	cout<<ans<<endl;
	int res=a[1];
	for(int i=tmp+1;i<=n;++i)
		cout<<res<<" "<<a[i]<<endl,
		res-=a[i];
	cout<<a[tmp]<<" "<<res<<endl;
	res=a[tmp]-res;
	for(int i=2;i<tmp;++i)
		cout<<res<<" "<<a[i]<<endl,
		res-=a[i];
	return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
  int x,y;
  cin>>x>>y;
  if(y%2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  int a = 2*x;
  int b = 4*x;
  if(a <= y && y <= b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,m,q,v[MAXN],d[MAXN],c[MAXN];
int color[MAXN],dis[MAXN];
bool vis[MAXN][11];
vector<int> G[MAXN];
void add_edge(int u,int v)
{
    G[u].push_back(v);
    G[v].push_back(u);
}
void paint(int v,int d,int c)
{
    if(vis[v][d]) return;
    vis[v][d]=true;
    if(d==0) {color[v]=c; return;}
    paint(v,d-1,c);
    for(auto to:G[v]) paint(to,d-1,c);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);G[v].push_back(u);
    }
    scanf("%d",&q);
    for(int i=0;i<q;i++) scanf("%d%d%d",&v[i],&d[i],&c[i]);
    memset(vis,false,sizeof(vis));
    for(int i=q-1;i>=0;i--) paint(v[i],d[i],c[i]);
    for(int i=1;i<=n;i++) printf("%d\n",color[i]);
    return 0;
}



Measured memory_bytes: 9464
A,B = map(int,input().split())
from fractions import gcd 

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

C = gcd(A,B)
E = make_divisors(C)
E.sort()

ans = 0
idx = 1
while C>1 and idx < len(E):
    if C%E[idx] == 0:
        ans += 1
        while C%E[idx] == 0:
            C //= E[idx]
    idx += 1
print(ans+1)            
        
        









Measured memory_bytes: 5304
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

		int c = (a - b * 2);

		sc.close();

		if (c < 0) {
			System.out.println(0);
		} else {
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n, m;
	cin >> n >> m;
	
	int ans = 1;
	for(int i = 1; i * i <= m; ++i) {
		if( m % i == 0 ) {
			if( m / i >= n ) ans = max(ans, i);
			if( i >= n ) ans = max(ans, m / i);
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b,i,j;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==b && a==0) break;
		for(i=0;i<a;i++){
			for(j=0;j<b;j++){
				if(i%2==0){
					if(j%2==0){
						printf("#");
					}else{
						printf(".");
					}
				}else{
					if(j%2==0){
						printf(".");
					}else{
						printf("#");
					}		
				}
			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2052
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
  a, b, c = map(int, input().split())
  e[a].append((b, -c))
class BellmanFord:
  def __init__(self, n, e):
    self.n = n
    self.edges = []
    for k in e.keys():
      for t in e[k]:
        self.edges.append((k, t[0], t[1]))
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    d[s] = 0
    for i in range(self.n + 1):
      for (u, v, c) in self.edges:
        if d[u] != float("inf") and (d[u] + c < d[v]):
          d[v] = d[u] + c
          if i == self.n and (v == self.n):
            return "-loop"
    return d[t]
bf = BellmanFord(N, e)
res = bf.path(1, N)
if res == "-loop": print("inf")
else: print(-res)

Measured memory_bytes: 42860
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define MP make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
#define Very_fast std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int N = 1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
inline ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll lowbit(ll x){return (x&-x);}
inline ll kissme(ll x,ll y)
{
	ll res=1;
	if(x==0)return 1;
	if(x==1)return y;
	res=kissme(x/2,y);
	res=res*res%mod;
	if(x%2==1)res=res*y%mod;
	return res;
}
int n; 
string s;
signed main()
{
	Very_fast;
	cin>>n>>s;
	for(int i=0;i<min(n,(int)s.size());i++)
		cout<<s[i];
	if(n<s.size())cout<<"...";
	return 0;
}

Measured memory_bytes: 3636
using System;
using static System.Console;

namespace A
{
  class Program
  {
    static void Main(string[] args)
    {
      string[] N = ReadLine().Split();

      bool judge = Array.IndexOf(N, "1") != -1
        && Array.IndexOf(N, "9") != -1
        && Array.IndexOf(N, "7") != -1
        && Array.IndexOf(N, "4") != -1;

      WriteLine(judge ? "YES" : "NO");
    }
  }
}


Measured memory_bytes: 13024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    vector<ll> A(3);
    int K;
    for(int i = 0;i < 3;i++)cin >> A[i];
    cin >> K;
    sort(A.rbegin(),A.rend());
    A[0] <<= K;
    cout << A[0]+A[1]+A[2] << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,k,tmp,nedan=0;
    int hako[1000];
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> hako[i];
    }
    for(int s=0;s<n;s++){
        for(int j=s+1;j<n;j++){
            if(hako[s]>hako[j]){
                tmp=hako[s];
                hako[s]=hako[j];
                hako[j]=tmp;
            }
        }
    }
    for(int g=0;g<k;g++){
        nedan=hako[g]+nedan;
    }
    cout << nedan;
    return 0;
}

Measured memory_bytes: 3636
rh=set("yuiophjklnm")
while 1:
  t=input()
  if t=="#":break
  c=0
  for (i,j) in enumerate(t):
    if i==0:
      if j in rh:
        r=True
      else:
        r=False
    else:
      if (j in rh and not r) or (not j in rh and r):
        c+=1
      r=j in rh
  print(c)


Measured memory_bytes: 5556
hp = $stdin.gets.to_i

$memo = {}
$memo[1] = 1

def attack(hp)
#  puts "hp:#{hp}"
  if hp == 1
    return 1
  else
    new_monster_hp = hp / 2
    if $memo[new_monster_hp]
      return $memo[new_monster_hp] * 2 + 1
    else
      return attack(new_monster_hp) * 2 + 1
    end
  end
end

puts attack(hp)


Measured memory_bytes: 1788
ret [] n m = max n m
ret ('T':as) n m = ret as (n + 1) m
ret ('A':as) n m = ret as (n + 1) m
ret ('C':as) n m = ret as (n + 1) m
ret ('G':as) n m = ret as (n + 1) m
ret (_:as) n m = ret as 0 $ max n m

main = do
  l <- getLine
  putStrLn $ show $ ret l 0 0


Measured memory_bytes: 380
#include <bits/stdc++.h>
  using namespace std;
  #define int long long int 
  #define vi vector<int>
  #define pii pair<long long ,long long>
  #define pll pair<int,int>
  #define mod 1000000007
  #define hell 998244353
  #define all(x) x.begin(),x.end()
  #define mp(x,y) make_pair(x,y)
  #define mem(a,val) memset(a,val,sizeof(a))
  #define eb push_back
  #define ff first
  #define ss second
  #define rep(n) for(int i=0;i<n;i++)
  #define lb lower_bound
  #define up upper_bound
  
  void solve()
  { 
    int n;
    cin>>n;
    int k;
    cin>>k;
    int ans=0;
    rep(n)
    {
       int x;
       cin>>x;
       if(x>=k)
        ans++;
    }
    cout<<ans;
    

  }



  signed main()
  {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


   
    
     
    
    int T;
    T=1;
    
    while(T--)
    {
      solve();
    }
    return 0;
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<10;i++)
	{
		for(int j=1;j<10;j++)
		{
			if(i*j==n)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
			
		}
	}
	cout<<"No"<<endl; 
	return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, T;
  cin >> N >> T;
  int ans = 10000;
  rep(i, N){
    int c, t;
    cin >> c >> t;
    if(t <= T){
      ans = min(ans, c);
    }
  }
  if(ans == 10000){
    cout << "TLE" << endl;
  }else{
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll unsigned long long
#define fi first
#define se second
#define  pb push_back
#define  pob pop_back
#define mp make_pair
#define db long double
#define up upper_bound
#define lb lower_bound
#define pll pair<ll,ll>
#define vll vector<ll>
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define sz(x) (int)x.size()
#define endl '\n'
#define int long long
#define mod 1000000007
#define MAX 100005
using namespace std;
 
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
 
    ll n,a,b;
    cin >> n >> a >> b;
    ll p = (b-a);
    ll k = min(a-1,(n-b));
    if(p&1){
       k+=1LL;
       p-=1LL;
       cout << k+(p/2LL);    
    }
    else{
        ll o = (p/2LL);
        cout << o;
    }
    
    return 0;
 
}
/*
1000000000000000000 1 99999999999999999
49999999999999999
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a); i <= int(b); i++)
#define per(i, a, b) for (int i = (a); i >= int(b); i--)
#define fir first
#define sec second
#define tct template<class type>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int maxn = 1 << 18, mod = 998244353;
int n, m, p[maxn + 5], a[maxn + 5], f[maxn + 5];

inline int& red(int &x) { return x += x >> 31 & mod; }
tct inline void cmax(type &x, type y) { x < y ? x = y : 0; }
tct inline void cmin(type &x, type y) { x > y ? x = y : 0; }

int qpow(int a, int b) {
	int c = 1;
	for (; b; b >>= 1, a = ll(a) * a % mod) if (b & 1) c = ll(a) * c % mod;
	return c;
}

void fwt(int a[], int n, int t) {
	for (int k = 0, l = 1, p; l < n; k++, l <<= 1) {
		rep(i, 0, n - 1) if (~i >> k & 1) {
			p = a[i];
			red(a[i] += a[i + l] - mod);
			red(a[i + l] = p - a[i + l]);
		}
	}
	if (t == -1) {
		int x = qpow(n, mod - 2);
		rep(i, 0, n - 1) a[i] = ll(x) * a[i] % mod;
	}
}

int main() {
	scanf("%d", &n), m = 1 << n;
	fill(a, a + m, 1), red(a[0] -= m);
	int s = 0;
	rep(i, 0, m - 1) scanf("%d", &p[i]), s += p[i];
	s = qpow(s, mod - 2);
	rep(i, 0, m - 1) p[i] = ll(mod - s) * p[i] % mod;
	red(p[0] += 1 - mod);
	fwt(a, m, 1), fwt(p, m, 1);
	int t = 0;
	rep(i, 1, m - 1) f[i] = ll(a[i]) * qpow(p[i], mod - 2) % mod, red(t -= f[i]);
	f[0] = t;
	fwt(f, m, -1);
	rep(i, 0, m - 1) printf("%d\n", f[i]);
	return 0;
}

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

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int a, b, c, k;
	cin >> a >> b >> c >> k;

	// 貪欲法
	int cnt = 0;
	while (a >= b) {
		b *= 2;
		cnt++;
	}
	while (b >= c) {
		c *= 2;
		cnt++;
	}

	if (cnt <= k) cout << "Yes" << '\n';
	else cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
import time
import random
t1 = time.time()

D = int(input())

last_list = [0 for i in range(27)]
c_list = list(map(int, input().split()))
c_list = [""] + c_list
# print(c_list)
S_list = [[]for i in range(D)]
P_list = [0 for i in range(27)]
for i in range(D):
    S_list[i] = list(map(int, input().split()))
    S_list[i] = [""] + S_list[i]
S_list = [""] + S_list
# print(S_list)


t_list = [""]
for i in range(D):
    t_list.append(random.randint(1,26))

for i in range(1,D+1):
    S = 0
    t = t_list[i]
    for j in range(1,27):
        if j == t:
            P_list[j] += S_list[i][j]
            last_list[j] = i
            # print(S_list[i][j])
        else:
            P_list[j] -= c_list[j] * (i-last_list[j])
    for i in range(1,27):
        S += P_list[i]
    # print(S)

t2 = time.time()
Time = t2 - t1
# print(M)
while t2 - t1 <= 1.5:
    last_list = [0 for i in range(27)]
    P_list = [0 for i in range(27)]
    C_A = random.randint(1,D)
    C_B = random.randint(1,26)
    t_new = t_list
    t_new[C_A] = C_B
    for i in range(1,D+1):
        S_new = 0
        t = t_new[i]
        for j in range(1,27):
            if j == t:
                P_list[j] += S_list[i][j]
                last_list[j] = i
                # print(S_list[i][j])
            else:
                P_list[j] -= c_list[j] * (i-last_list[j])
        for i in range(1,27):
            S_new += P_list[i]
    if S_new >= S:
        S = S_new
        t_list = t_new
    t2 = time.time()

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


Measured memory_bytes: 80620
#include <iostream>
#include <deque>
using namespace std;
#define MAX_N 200000
#define rep(i, n) for (int i = 0; i < (n); i++)

int main(void) {
  int N;
  cin >> N;

  int A[MAX_N];
  rep(i, N) { cin >> A[i]; }

  std::deque<int> dq;
  rep(i, N) {
    if((i % 2) != (N%2) ) {
      dq.push_front(A[i]);
    } else {
      dq.push_back(A[i]);
    }
  }

  for (auto itr = dq.begin(); itr != dq.end(); ++itr) {
    cout << *itr << " ";
  }
  cout << endl;
  return 0;
}


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

#define fr first
#define se second

using namespace std;

const long long N = 1e5 + 7;
const long long INF = 1e9;
const long long mod = 1e9 + 7;

int n;
int m;
int main()
{
    /// freopen("sum.in", "r", stdin);
    /// freopen("sum.out", "w", stdout);

    ios_base::sync_with_stdio( 0 );

    cin >> n;
    cout << 3 * n * n;
}


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


/*int f(int x){

  return x * x;
}

int g(int x){
  if(x == 0) return 1;
  return g(x-1) * x;
}
*/

int H, W;

void  solve(int Y, int X, vector<string> &vec,int &count){

   if(Y<0||Y>=H||X<0||X>=W){
    return;
  }
   else if(vec[Y][X]=='#'){
    return;
  }
  count+=1;
  vec[Y][X]='#';
  solve(Y+1,X,vec, count);
  solve(Y-1,X,vec,count);
  solve(Y,X-1,vec,count);
  solve(Y,X+1,vec,count);

}
int main(){
  //vector<vector<int>>vec(N,vector<int>(N));

  while(1){
    // int W,H
    int count;
  cin >> W >>H;
  if(W==0 &&H==0)break;
  count=0;

  vector<string>vec(H);
  int x,y;

  for(int i =0;i<H;i++){
    cin >> vec.at(i);
    for(int j=0;j<W;j++){
      if(vec[i][j]=='@'){
        x = j;
        y = i;
        break;
      }
           }
  }
  solve(y, x,  vec, count);
  cout << count <<endl;
  }


}



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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
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 += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const int MOD = 1000000007;

ll cnts[1009];


void factor(ll k) {
    ll p = 2;
    while (k > 1) {
        if (k % p == 0) {
            cnts[p]++;
            k /= p;
        } else {
            p++;
        }
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int N;
    cin >> N;
    FOR(i, 2, N) {
        factor(i);
    }
    ll ans = 1;
    FOR(i, 2, N) {
        if (cnts[i] == 0) continue;
        ans = (ans * (cnts[i] + 1)) % MOD;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    long double A, B;
    cin >> A >> B;
    cout << (ll)(A * B + 0.001) << endl;
}

Measured memory_bytes: 3724