akhauriyash/Code-Regression huggingface dataset:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, m, x = map(int, readline().split())
ca = list(map(int, read().split()))

flg = 0
c_min = 1000000000

for i in range(1, 2**n + 1):
    sum_a = [0] * (m+1)
    check = 0
    
    s = bin(i)[2:].zfill(n)
    for j in range(n):
        if s[j] == "1":
            sum_a = [x + y for x, y in zip(sum_a, ca[(m+1)*j:(m+1)*(j+1)])]

    # 全てx以上かチェック
    for k in range(1, m+1):
        if sum_a[k] >= x:
            check += 1
        if check == m:
            c_temp = sum_a[0]
            flg = 1
            if c_temp < c_min:
                c_min = c_temp

if flg == 1:
    print(c_min)
else:
    print("-1")


Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=2e3+3;
vector<int>g[N];
bool leaf[N];
int sz[N],maybe[N],k,cnt,ans=1e5+5;
void dfs(int x,int dep,int par){
    cnt++;
    for(auto&y:g[x]){
        if(y!=par&&dep<k/2){
            dfs(y,dep+1,x);
        }
        else if(y!=par&&dep==k/2){
            maybe[y]=1;
        }
    }
}
int dfs2(int curr,int par){
    int a=maybe[curr];
    for(auto&y:g[curr]){
        if(y!=par){
            a+=dfs2(y,curr);
        }
    }
    return a;
}
int main()
{
    int n;
    scanf("%d%d",&n,&k);
    for(int i=1;i<n;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        g[x].pb(y);
        g[y].pb(x);
        sz[x]++;
        sz[y]++;
    }
    if(k==1){
        printf("%d\n",n-2);
        return 0;
    }
    for(int i=1;i<=n;i++){
        cnt=0;
        for(int j=1;j<=n;j++){
            maybe[j]=0;
        }
        dfs(i,0,-1);
        int mx=0;
        if(k%2){
            for(auto&ne:g[i]){
                mx=max(mx,dfs2(ne,i));
            }
            cnt+=mx;
        }
        ans=min(ans,n-cnt);
        //printf("i:%d ans[i]:%d\n",i,n-cnt);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    private static Scanner sc;

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

    private void solve() {
        int N = sc.nextInt();
        int D = sc.nextInt();
        int X = sc.nextInt();
        int ans = X;
        for (int i = 0; i < N; i++) {
            ans += 1;
            int A = sc.nextInt();
            ans += (D - 1) / A;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2e3+5;
ll solve(ll x,ll y){
    //printf("x:%lld y:%lld\n",x,y);
    if(x<y)return solve(y,x);
    if(y==0)return x;
    return 2*((x-1)/y)*y+solve(y,x%y);
}
int main()
{
    ll n,x,y;
    scanf("%lld%lld",&n,&x);
    printf("%lld\n",n+solve(x,n-x));
    return 0;
}


Measured memory_bytes: 764
//A-Buttons

#include <iostream>
using namespace std;

int main(void){
    
    int A;
    int B;
    int sum=0;
    
    cin >> A >> B;
    
    for(int i=0;i<2;++i){
        if(A>=B){
            sum+=A;
            A--;
        } else  {
            sum+=B;
            B--;
        }
    }
    
    cout << sum << endl;
    return 0;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void) {
  int N, M;
  cin >> N >> M;
  UnionFind tree(N);
  
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    tree.unite(A, B);
  }

  set<int> count {};
  for (int i = 0; i < N; i++) {
    count.insert(tree.root(i));
  }

  cout << count.size() - 1 << endl;
}

Measured memory_bytes: 7468
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[100005],k,mx,i,j,f[100005],p[100005],o[100005],b[100005],r,usj;
int main(){
	cin>>n>>m;
	for(k=1;k<=n;k++){
	
	cin>>a[k];
	 a[k]=a[k]/2;  b[k]=a[k];
	mx=max(mx,a[k]);
	}
	
	 
	 for(k=1;k<=n;k++){
	 	r=0;
	 	while(b[k]%2==0){
	 		b[k]/=2;
	 		r++;
		 }
		 o[k]=r;
		 
	 }
	 
	 for(k=2;k<=n;k++){
	 	if(o[k]!=o[k-1]){
	 		cout<<0; return 0;
		 }
	 }
	 if(n==1) usj=a[1];
	 else{
	 
	 usj=a[1]*a[2]/__gcd(a[1],a[2]);
	 for(k=3;k<=n;k++){
	 	usj=usj*a[k]/__gcd(usj,a[k]);
	 	if(usj>m) {
	 		cout<<0; return 0;
		 }
	 }
}
	 m=m/usj;
	 cout<<m/2+m%2;
}

Measured memory_bytes: 2560
import bisect
def nCr(n, r):
    r = min(r, n-r)
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i
    return numerator // denominator

n,m,l=map(int,input().split())
data = [[0 for i in range(m+1)]for i in range(n)]
for i in range(n):
    p,t,v=map(int,input().split())
    for j in range(m+1):
        data[i][j]=((t*j+l/v)if v!=0 else 9999999999999999, (p/100.0)**(j) * nCr(m,j) * (1-p/100.0)**(m-j))

ans=[]
for i in range(n):
    win=0
    for j in range(m+1):
        wintmp=data[i][j][1]
        for x in range(n):
            if i==x:
                continue
            tmp=0
            for a,b in data[x][bisect.bisect_right(data[x],(data[i][j][0],5)):]:
                tmp+=b
            wintmp*=tmp
        win+=wintmp
    ans.append(win)

for a in ans:
    print('%.8f'%a)


Measured memory_bytes: 6172
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val number: Int = scn.nextLine().toInt()

    val maxDoughnuts: Int = number / 7
    val doughnutsNumber = (0..maxDoughnuts).toList().filter {
        (number - 7 * it) % 4 == 0
    }.toList().size

    if (doughnutsNumber == 0) {
        println("No")
    } else {
        println("Yes")
    }

}

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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> a >> b >> c >> d;
    MSG(min(a, b) + min(c, d))
}


Measured memory_bytes: 256
a, b, c, d, e, f = list(map(int, input().split()))

# a,bの組み合わせで作れる水の量を全て計算する
water = set([])
sugar = set([])
max_all = f / 100
a_count = int(max_all // a)

# a, bで作られる全ての水
for i in range(a_count + 1):
    # i*aが存在
    j = 0
    while(True):
        if i == 0 and j == 0:
            j += 1
        if i*a + j*b <= max_all:
            water.add(i*a + j*b)
        else:
            break
        j += 1

c_count = int(f // c)

for i in range(c_count + 1):
    j = 0
    while(True):
        if i*c + j*d <= f:
            sugar.add(i*c + j*d)
        else:
            break
        j += 1

all_water = 0
all_sugar = 0
percent = 0

for i in water:
    for j in sugar:
        if j / (i*100 + j) <= e / (100 + e) and 100*i + j <= f:
            if percent <= j / (i*100 + j):
                all_water = (i*100 + j)
                all_sugar = j
                percent = j / (i*100 + j)

print(all_water, all_sugar)


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;

int main()
{
    ll  a,b;
    cin >> a >> b;
    ll r = a-2*b;
    if(r>0){
        cout << r <<endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <math.h>

using namespace std;


main(){
    int r, D;
    int x[11];
    int i;
    cin >> r >> D >> x[0];
    for(i = 0; i < 10; i++){
        x[i+1] = r*x[i] - D;
        cout << x[i+1] << "\n";
    }
    cout << flush;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline
sys.setrecursionlimit(100000)
# mod = 10 ** 9 + 7
mod = 998244353


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: int(x) - 1, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v

    def __str__(self):
        return str(self.v)

    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n)


def main():
    N, P = read_values()
    S = input().strip()

    if P in (2, 5):
        res = 0
        for i, s in enumerate(S):
            if int(s) % P == 0:
                res += i + 1
        print(res)

    else:
        r = 0
        D = {0: 1}
        res = 0
        d = 1
        for i, s in enumerate(S[::-1]):
            r += int(s) * d
            r %= P
            d *= 10
            d %= P
            c = D.setdefault(r, 0)
            res += c
            D[r] += 1
        print(res)


if __name__ == "__main__":
    main()


Measured memory_bytes: 4328
#include <bits/stdc++.h>
using namespace std;
int main() {
    int noa[26] = {0};
    char word[1201];
    while(scanf("%s",word) != EOF) {
        for(int i = 0; word[i] != '\0'; i++) {
            int x;
            if (isupper (word[i])) {
                x = tolower(word[i]) - 'a';
            }
            else {
                x = word[i] - 'a';
            }
            if(0 <= x && x <= 25) {
                noa[x]++;
            }
        }
    }
    for(int i = 0; i < 26; i++) {
        printf("%c : %d\n", i + 'a',noa[i]);
    }
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

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

    int h, w;
    cin >> h >> w;
    int K;
    cin >> K;
    V<string> s(h);
    rep(i, h) cin >> s[i];
    int ans = mod;
    rep(i, 1 << h - 1) {
        V<int> x(h);
        rep(j, h - 1) if(i >> j & 1) x[j + 1] = 1;
        rep(j, h - 1) x[j + 1] += x[j];
        int cnt = x.back();
        V<int> y(cnt + 1);
        rep(j, w) {
            bool ng = 0;
            rep(k, h) {
                if(s[k][j] == '1') y[x[k]]++;
                if(y[x[k]] > K) ng = 1;
            }
            if(ng) {
                cnt++;
                y.assign(x.back() + 1, 0);
                j--;
            }
            if(cnt > h + w) break;
        }
        chmin(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> a(n);
    ll sum = 0;
    int i;
    for (i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int cnt = 0;
    for (i = 0; i < n; i++) {
        if ((ll)4 * m*a[i] >= sum) cnt++;
    }
    if (cnt >= m) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  vector<int> a(4);
  vector<int> b = {1,4,7,9};
  cin >> a;
  sort(all(a));
  if(a==b)cout << "YES" << endl;
  else cout << "NO" << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "2", "0", "10", "20", "30" ].parse.expand.solve == 2 );
	assert( [ "3", "3", "10", "8", "7", "12", "5" ].parse.expand.solve == 1 );
	
	assert( [ "4", "1", "2", "4", "7", "3", "5", "6", "8" ].parse.expand.solve == 4 );		// 追加ケース
}



import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto as = new long[ n ];
	foreach( ref a; as )
	{
		input.popFront;
		a = input.front.to!( long );
	}
	auto bs = new long[ n ];
	foreach( ref b; bs )
	{
		input.popFront;
		b = input.front.to!( long );
	}
	return tuple( as, bs );
}

auto solve( long[] as, long[] bs )
{
	as.sort();
	bs.sort();
	
	// aとbを順番に並べる
	auto gs = [ tuple( ( as.front < bs.front ) ? 'a' : 'b', 0L ) ];
	while( !as.empty || !bs.empty )
	{
		if( bs.empty || ( !as.empty && as.front < bs.front ) )
		{
			if( gs.back[ 0 ] == 'a' ) gs.back[ 1 ]++;
			else                      gs ~= tuple( 'a', 1L );
			as.popFront;
		}
		else
		{
			if( gs.back[ 0 ] == 'b' ) gs.back[ 1 ]++;
			else                      gs ~= tuple( 'b', 1L );
			bs.popFront;
		}
	}
	
	// 接続のパターン数を計算
	auto ans = 1L;
	auto f = gs.front;
	gs.popFront;
	foreach( g; gs )
	{
		if( f[ 0 ] == g[ 0 ] )
		{
			f[ 1 ] += g[ 1 ];
			continue;
		}
		
		// ケーブルを左から右に繋げるパターンを列挙（逆走するパターンはケーブル長が伸びてしまうのでNG）
		auto p = f[ 1 ].permutationMod( min( f[ 1 ], g[ 1 ] ) );
		ans = ans.mulMod( p );
		f[ 0 ] = ( f[ 1 ] < g[ 1 ] ) ? g[ 0 ] : f[ 0 ];
		f[ 1 ] = abs( f[ 1 ] - g[ 1 ] );
	}
	return ans;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}

// 階乗
auto factorialMod( long MOD = 10L ^^ 9 + 7 )( long x )
{
	static memo = [ 1L ];
	if( memo.length <= x )
	{
		auto i = memo.length;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i % MOD;
	}
	return memo[ x ];
}

// 順列数
auto permutationMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x.factorialMod!MOD.divMod!MOD( ( x - y ).factorialMod!MOD );
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; cin >> n;
	vector<long long> a(2 * n);
	for(auto &v: a) cin >> v;
	sort(a.rbegin(), a.rend());
	double ans = 0, fac = 1. / (2 * n - 1);
	for(int i = 0; i < 2 * n; i++){
		ans += a[i] * fac * (2 * n - i - 1);
	}
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
import math

n=int(input())
a=list(map(int,input().split()))

dp=[0 for _ in range(1000001)]

for d in a:
  dp[d]+=1
  
ch1=0
for i in  range(2,1000001):
  ch=0
  x=i
  while x<=1000000:
    ch+=dp[x]
    x+=i
  if ch>1:
    ch1+=1
    
if ch1==0:
  print('pairwise coprime')
  
else:
  g=a[0]
  for h in range(1,n):
    g=math.gcd(g,a[h])
    
  if g==1:
    print('setwise coprime')
    
  else:
    print('not coprime')

Measured memory_bytes: 217232
#include<cctype>
#include<cstdio>
#include<iostream>
#include<string>
using namespace std;

int main(){
    string s;
    while(1){
        getline(cin,s);
        if(s[0]=='0') break;
        int sum=0;
        for(int i=0; i<s.size(); i++){
            sum+=(int)(s[i]-'0');
        }
        cout << sum << endl;
    }
    return 0;
}


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

constexpr int64_t INF = 1'010'000'000'000'000'017LL;
constexpr int64_t MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

void primeFactorization2(uint64_t number, list<uint64_t> &factors){
  uint64_t val = sqrt(number);
  for (uint64_t i = 2; i <= val; i++){
    while (number % i == 0){
      number /= i;
      factors.push_back(i);
	}
  }
  if(number != 1){
    factors.push_back(number);
  }
}

signed main() {
  uint64_t x, y;
  cin >> x >> y;
  
  // 4*b + 2*(x-b) = y
  double b = (((double)y)-2.0*x)/2.0;
  
  if(std::floor(b) == b && b > -0.1 && (x-b) > -0.1) {
    cout << "Yes" << endl;
    return 0;
  }
  else {
    cout << "No" << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 3688
from numpy.fft import rfft, irfft
import numpy as np

N, M = map(int, input().split())
A = list(map(int, input().split()))

a = np.zeros(2 ** 18)
for Ai in A:
    a[Ai] += 1

fa = rfft(a)
a2 = irfft(fa ** 2)
a2 = np.round(a2).astype(np.int)

cum_a2 = np.cumsum(a2)

index = np.searchsorted(cum_a2, N ** 2 - M)

a2[index] -= cum_a2[index] - (N ** 2 - M)

ans = sum(A) * 2 * N - (a2[: index + 1] * np.arange(index + 1)).sum()
print(ans)


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

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a,b;
    cin >> a >> b;
    
    int mi = ceil(a/0.08);
    int mx = int((a+1)/0.08);
    mi= max(mi, int(ceil(b/0.1)));
    mx = min(mx, int((b+1)/0.1));
    
    if(mi< mx)cout << mi << "\n";
    else cout << -1 << "\n";
    
    return 0;
}


Measured memory_bytes: 256
char buf[2000000];
unsigned sz;
char out[9];
main()
{
	read(0,buf,2000000);
	unsigned N=0;
	for(;;)
	{
		char k=buf[sz++];
		if(k<'0')break;
		N=N*10+k-'0';
	}
	unsigned now=1;
	for(unsigned i=0;i<N;i++)
	{
		unsigned A=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			A=A*10+k-'0';
		}
		now+=A==now;
	}
	out[8]='\n';
	unsigned outsz=8;
	if(now==1)
	{
		out[7]='1';
		out[6]='-';
		outsz=6;
	}
	else
	{
		N-=now-1;
		do{
			out[--outsz]=N%10+'0';
		}while(N/=10);
	}
	write(1,out+outsz,9-outsz);
}

Measured memory_bytes: 1536
MOD = 10**9 + 7
class ModInt:
    
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
    


def main():
    from sys import stdin
    input = stdin.readline
    from operator import mul
    from functools import reduce
    import math
    fact = math.factorial

    def cmb(n,r):
        n = int(str(n))
        r = int(str(r))
        r = min(n-r,r)
        if r == 0: return 1
        u = [1]
        l = [1]
        #print(n,n-r)
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1,r + 1))
        return over // under

    

    def hoge(n,r):
        num = 1
        for i in range(int(str(n)),   int(str(n-r))  ,-1):
            num *= i
        for i in range(1,int(str(r))+1):
            num //= i
        return num

    
    N,K= map(int, input().split())
    red = N-K
    blue = K
    
    print(N-K+1)
    for i in range(2,K+1):
        #print(ModInt(cmb(K-1,i-1))  ,         fact(red+1)//fact(i)//fact(red+1-i))
        print(    hoge(red+1,i)  * ModInt(cmb(K-1,i-1))       )

if __name__ == '__main__':
    main()

Measured memory_bytes: 48988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            String x = Console.ReadLine();
            String[] xarray = x.Split(' ');

            int a = int.Parse(xarray[0]);
            int b = int.Parse(xarray[1]);

            if( a < b )
            {
                Console.WriteLine("a < b");
            }
            else if( a > b )
            {
                Console.WriteLine("a > b");
            }
            else
            {
                Console.WriteLine("a == b");
            }

        }
    }
}

Measured memory_bytes: 5296
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;

int N, M;

vector<int> dijkstra(int s, vector<vector<pair<int, int>>>& adj) {
    vector<bool> visit(N);
    vector<int> dist(N, 1e9), par(N);
    priority_queue<pair<int, int>> q;
    dist[s] = 0; q.push(make_pair(0, s)); visit[s] = true; par[s] = s;
    while (!q.empty()) {
        pair<int, int> tmp = q.top(); q.pop();
        int t = tmp.second; visit[t] = true;
        if (dist[t] < tmp.first * (-1) ) continue;  //別のルートでdist[t]が更新されていれば無視
        for (int i = 0; i < adj[t].size(); i++) {
            int next = adj[t][i].first;
            if (visit[next]) continue;
            if (dist[next] > dist[t] + adj[t][i].second) {
                dist[next] = dist[t] + adj[t][i].second;
                par[next] = t;
                q.push(make_pair(dist[next] * (-1), next));
            }
        }
    }
    return par;
}

int main() {
    cin >> N >> M;
    vector<vector<pair<int, int>>> adj(N, vector<pair<int, int>>());
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c; --a; --b;
        adj[a].push_back(make_pair(b, c));
        adj[b].push_back(make_pair(a, c));
    }
    set<pair<int, int>> need;
    for (int i = 0; i < N; i++) {
        vector<int> par = dijkstra(i, adj);
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            need.insert((par[j] < j? make_pair(par[j], j): make_pair(j, par[j])));
        }
    }
    cout << M - need.size() << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b)for(int i=(a);i<=(b);i++)
#define repR(i,n) for(int i=n;i>=0;i--)
#define P pair<int, int>
#define sz(x) x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<int>
#define COUT(x) cout<<(x)<<endl
#define MA map<int,int>
#define SE set<int>
#define PQ priority_queue
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 50;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))
int n;
int s[10];
int ans = 0;

void dfs(int i, int sum, int now) {
	if (i == n - 1) {
		ans += sum + now;
	}
	else {
		dfs(i + 1, sum + now, s[i + 1]);
		dfs(i + 1, sum, now * 10 + s[i + 1]);
	}
}

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string str; cin >> str;
	n = str.size();
	rep(i, n){
		s[i] = str[i] - '0';
	}
	dfs(0, 0, s[0]);
	cout << ans << endl;
	return 0;
}

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

signed main(){
	int N; cin >> N;
	vector<int> t(N);
	for(int i = 0; i < N; i++){
		cin >> t[i];
	}
    int ans = t[0];
	for(int i = 1; i < N; i++){
		ans = ans / __gcd(ans, t[i]) * t[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque, defaultdict

n, m = list(map(int, input().split()))
d = defaultdict(list)
for i in range(m):
    data = list(map(int, input().split()))
    d[data[0]].append(data[1])
    d[data[1]].append(data[0])

mindist = defaultdict(lambda: 1000000)
mindist[1] = 0
sign = defaultdict(int)

dq = deque()
dq.append([1, 0])
while len(dq) > 0:
    room, dist = dq.popleft()
    for nroom in d[room]:
        if dist + 1 < mindist[nroom]:
            mindist[nroom] = dist + 1
            sign[nroom] = room
            dq.append([nroom, dist + 1])

print('Yes')
for i in range(2, n+1):
    print(sign[i])

Measured memory_bytes: 60156
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int N;
	vector<int> p, a, b;
	
	cin>>N;
	p.resize(N);
	a.resize(N);
	b.resize(N);
	for(int i=0; i<N; i++){
		cin>>p[i];
		a[i]=20000*(i+1);
		b[N-1-i]=20000*(i+1);
	}

	for(int i=0; i<N; i++){
		a[p[i]-1]+=i;
	}
	
	for(int i=0; i<N-1; i++){
		cout<<a[i]<<" ";
	}
	cout<<a[N-1]<<endl;
	
	for(int i=0; i<N-1; i++){
		cout<<b[i]<<" ";
	}
	cout<<b[N-1]<<endl;

	return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
int main(){
	int i=1,x,y,min,max;
	while(i<=3000){
		scanf("%d %d",&x,&y);
		if(x==0 && y==0){
			break;
		}
		min=fmin(x,y);
		max=fmax(x,y);
		printf("%d %d\n",min,max);
		i++;
	}
	return 0;
}

Measured memory_bytes: 1756
#include <stdio.h>
int check[4];
int main(void) {
	int n, m, s, c, i, arr[4], flag=0;
	scanf("%d %d", &n, &m);
//	if(m==0)
//		flag=1;
	for(i=0; i<m; i++){
		scanf("%d %d", &s, &c);
		if(s==1 && c==0 && n!=1)
			flag=1;
		if(check[s]==0){
			arr[s]=c;
			check[s]=1;
		}
		if(check[s]==1 && arr[s]!=c){
			flag=1;
		}
	}
	if(flag==1)
		printf("-1");
	else{
		if(m!=0){
			if(check[1]==0)
				arr[1]=1;
			printf("%d", arr[1]);
			for(i=2; i<=n; i++){
				if(check[i]==0)
					arr[i]=0;
				printf("%d", arr[i]);
			}
		}
		else{
				if(n==1)
					printf("0");
				else{
					printf("1");
					for(i=2; i<=n; i++)
						printf("0");
				}
		}
	}
	return 0;
}


Measured memory_bytes: 256
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define inf  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 100005;
using namespace std;

vector<pair<int,int>>v[N];
int color[N];
void  dfs(int s,int pr,int c)
{
  color[s] = c;
  for (auto g : v[s])
  {
    if (g.ff != pr)
    {
      if(g.ss % 2 == 0)
        dfs(g.ff,s,c);
      else
        dfs(g.ff,s,(c ^ 1));
    }
  }
}
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n,x,y,w;
  cin >> n;
  for (int i = 0; i < n-1; ++i)
  {
    cin >> x >> y >> w;
    v[x].push_back({y,w});
    v[y].push_back({x,w});
  }
  dfs(1,0,0);
  for (int i = 1; i <= n; ++i)
  {
    cout << color[i] << "\n";
  }
  return 0;
}


Measured memory_bytes: 9088
// C - Dice and Coin
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N,K; cin>>N>>K;
	double ans = 0;
	for(int n=N; n; --n){
		int k = n; while(k<K) k*=2;
		ans += (double)n/k/N;
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N;

int main() {
  cin >> N;
  long long int a = 2;
  long long int b = 1;
  while (N--) {
    b += a;
    a = b - a;
  }
  cout << a << endl;

  return 0;
}


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

S = input()
r = len(S) - 1
l = 0
cnt = 0
f = True
while l <= r:
    if S[l] == S[r]:
        l += 1
        r -= 1
    elif S[l] == 'x':
        cnt += 1
        l += 1
    elif S[r] == 'x':
        cnt += 1
        r -= 1
    else:
        f = False
        break
if f:
    print(cnt)
else:
    print(-1)

Measured memory_bytes: 3316
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int ketasum(int x) {
  int sum  = 0;
  while (x > 0) {
    sum += x % 10;
    x = x / 10;
  }
  return sum;
}

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;

  for (int i = 1; i <= N; i++) {
    if (ketasum(i) >= A && ketasum(i) <= B) ans += i;
  }

  cout << ans << endl;


}


Measured memory_bytes: 256
import fractions
from functools import reduce
def _lcm(x, y):
    return (x*y)//fractions.gcd(x, y)
def lcm(*l):
    return reduce(_lcm, l)

N = int(input())
a = [int(x) for x in input().split()]
l = lcm(*a)
print(sum((l-1)%a[i] for i in range(N)))


Measured memory_bytes: 5332
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split().Select(int.Parse).OrderBy(o => o).ToArray();
            var B = Console.ReadLine().Split().Select(int.Parse).OrderBy(o => o).ToArray();
            var C = Console.ReadLine().Split().Select(int.Parse).OrderBy(o => o).ToArray();

            var total = 0L;
            var aBin = new BinarySearch<int>() { Data = A, Flag = true };
            var cBin = new BinarySearch<int>() { Data = C, Flag = false };

            for (var i = 0; i < N; i++)
            {
                long aCount = 0, cCount = 0;
                aBin.Target = B[i];
                aCount = aBin.Search();
                cBin.Target = B[i];
                cCount = N - cBin.Search();

                total += aCount * cCount;
            }
            Console.WriteLine(total);
        }
    }
    public class BinarySearch<T> where T : IComparable
    {
        public T[] Data { get; set; }
        public T Target { get; set; }
        public bool Flag { get; set; }

        public int Search()
        {
            int ng = -1;
            int ok = (int)Data.Length;

            while (Math.Abs(ok - ng) > 1)
            {
                int mid = (ok + ng) / 2;

                if (IsOK(mid)) ok = mid;
                else ng = mid;
            }
            
            return ok;
        }

        public bool IsOK(int index)
        {
            // 0を含まない
            if (Data[index].CompareTo(Target) > 0) return true;
            else if (Flag && Data[index].CompareTo(Target) == 0) return true;
            else return false;
        }

    }
}


Measured memory_bytes: 44008
def main():
    a, b, c, d = map(int, input().split())
    i = 1
    while a > 0 and c > 0:
        if i%2:
            c -= b
        else:
            a -= d
        i += 1
    if a <= 0:
        print("No")
    else:
        print("Yes")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
h, w = map(int, input().split())
l = [input() for _ in range(h)]
s = "#" * (w + 2)
print(s)
for i in range(h):
    m = "#"
    for j in range(w):
        m += str(l[i])[j]
    m += "#"
    print(m)
print(s)

Measured memory_bytes: 3060
#include<iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>

using namespace std;


int main()
{
    double n, x;
    int t;
    cin >> n>>x>>t;

    int count=0;
    count = ceil(n / x);
    count = count * t;


    cout << count;

    return 0;
}



Measured memory_bytes: 3708
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>

using namespace std;

const bool debug = false;

#ifndef M_PI
    const double M_PI = acos(-1.0);
#endif // M_PI

#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e16;
//const int MX2 = 10100500; //  e7
//const long long INF = 1e18 + 0.5;
const int MX = 100500; //       e5
//const int SZ = 105;

long long go(long long a){
    int cnt = 0;
    while(a % 2 == 0){
        cnt++;
        a >>= 1;
    }
    a++;
    while(cnt--){
        a <<= 1;
    }
    return a;
}

long long go(long long a, long long b){
    while(true){
        long long z = go(a);
        if(z > b) return a;
        a = z;
    }
}

long long to_st(long long q){
    if((q & (q - 1)) == 0) return q;
    int x = 0;
    while(q){
        q >>= 1;
        x++;
    }
    q = 1;
    q <<= x;
    return q;
}

long long intersect(long long a, long long b, long long c, long long d){
    if(b < c) return -1;
    if(d < a) return -1;
    if(a > c) a = c;
    if(b < d) b = d;
    return b - a + 1;
}

int main()
{
    for(int i = 1; i < 10; i++){
     //   cout << i << ' ' << to_st(i) << endl;
    }
    ios_base::sync_with_stdio(false);
    //freopen("/Users/ozzy/Documents/in.txt","r", stdin);
    long long a, b;
    cin >> a >> b;

    long long z = go(a, b);
     b = z + to_st(b - z + 1) - 1;

    long long a1 = a | z;
    long long b1 = a | b;
    if(a != z) b1 = (z - 1) | b;

    long long ans = intersect(a, b, a1, b1);
    if(ans == -1) ans = b1 - a1 + 1 + b - a + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/xxxyyyy/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/xxxyyyy/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			table = new char[8][];
			for(int i = 0; i < 8; i++) {
				String s = sc.next();
				table[i] = s.toCharArray();
			}
			System.out.println(solve());
		}
	}
	
	char[][] table;
	char solve() {
		int[][] mask = {
				{0, 1, 1, 0, 1, 1},
				{1, 0, 2, 0, 3, 0},
				{0, 1, 0, 2, 0, 3},
				{1, -1, 1, 0, 2, -1},
				{0, 1, 1, 1, 1, 2},
				{1, 0, 1, 1, 2, 1},
				{0, 1, 1, -1, 1, 0},
		};
		
		for(int row = 0; row < 8; row++)
			for(int col = 0; col < 8; col++) {
				if( table[row][col] == '1' ) {
					for(int k = 0; k < 7; k++) {
						boolean ok = true;
						for(int i = 0; i < 3; i++) {
							int x = row + mask[k][i * 2];
							int y = col + mask[k][i * 2 + 1];
							if( !(0 <= x && x < 8 && 0 <= y && y < 8) ){
								ok = false;
								break;
							}
							if( table[x][y] != '1' ) {
								ok = false;
								break;
							}
						}
						if( ok )
							return (char) ('A' + k);
					}
				}
			}
		return '?';
	}
	
	void debug(Object... os) {
		System.err.println(deepToString(os));
	}
}

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

typedef long long int int64;
static const int64 mod = 1000000007LL;

int64 dp[2][4][3];
char s[300003];
int main()
{
	scanf("%s",s);
	int x = 0;dp[0][0][0] = 1;
	for(int i = 0;s[i] != 0;++i) {
		memset(dp[x^1],0,sizeof(dp[x^1]));
		if(s[i] == '0' || s[i] == '?') {
			for(int j = 0;j < 4;++j) {
				for(int k = 0;k < 3;++k) {
					int kk = k == 2 ? 1 : k+1;
					dp[x^1][j][kk] = (dp[x^1][j][kk]+dp[x][j][k])%mod;
				}
			}
		}
		if(s[i] == '1' || s[i] == '?') {
			for(int j = 0;j < 4;++j) {
				for(int k = 0;k < 3;++k) {
					int jj, kk;
					if(k == 0) {
						jj = std::min(j+1,3), kk = 0;
					} else {
						jj = j, kk = k-1;
					}
					dp[x^1][jj][kk] = (dp[x^1][jj][kk]+dp[x][j][k])%mod;
				}
			}
		}
		x ^= 1;
	}
	int64 ans = 0;
	for(int j = 1;j < 4;++j) {
		for(int k = 0;k < j;++k) {
			ans += dp[x][j][k];
		}
	}
	printf("%lld\n", ans % mod);
}


Measured memory_bytes: 640
//AtCoder ABC043 C - いっしょ / Be Together
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
    int N;
    cin>>N;
    vector<int> atbl(N);
    for(auto&&a:atbl){
        cin>>a;
    }
    lli cost=INT64_MAX;
    for(int v=-100;v<=100;++v){
        lli cc=0;
        for(const auto&a:atbl){
            cc+=(a-v)*(a-v);
        }
        cost=min(cost,cc);
    }
    cout<<cost<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll H,W,N;
ll g[1002][1002];
ll visited[1002][1002];

bool ok(ll y,ll x){
	return 0<=y&&y<H&&0<=x&&x<W;
}

P dfs(ll y,ll x){
	if(x>=W) return P(y,x);
	if(y>=H) return P(y,x);
	if(g[y][x]==0) return dfs(y+1,x);
	else return dfs(y,x+1);
}

int main()
{while(1){
	cin>>H>>W>>N;
	if(!N) break;
 	memset(visited,0,sizeof(visited));
	H;
	W;
	rep(i,H) rep(j,W) cin>>g[i][j];
	visited[0][0]=N-1;
	rep(i,H) rep(j,W){
		if(g[i][j]==0){
			if(ok(i+1,j)) visited[i+1][j]+=(visited[i][j]+1)/2;
			if(ok(i,j+1)) visited[i][j+1]+=visited[i][j]/2;
			if(visited[i][j]%2) g[i][j]^=1;
		}
		else{
			if(ok(i+1,j)) visited[i+1][j]+=visited[i][j]/2;
			if(ok(i,j+1)) visited[i][j+1]+=(visited[i][j]+1)/2;
			if(visited[i][j]%2) g[i][j]^=1;
		}
	}
	P p = dfs(0,0);
	cout<<p.fr+1<<" "<<p.sc+1<<endl;
}}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  sort(A.rbegin(), A.rend());

  int X = 0, Y = 0;

  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) X += A.at(i);
    else Y += A.at(i);
  }

  cout << X - Y << "\n";
}

Measured memory_bytes: 256
program tenki
  implicit none
  character(3) :: s, t
  integer :: n = 0, i
  read(*,*) s
  read(*,*) t
  do i = 1, 3
    if (s(i:i) == t(i:i)) n = n+1
  end do
  write(*,'(i0)') n
end program tenki

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using P = pair<ll,int>;
using G = vector<vector<int>>;
const long long INF = 1LL << 60;


string S; int N, cnt;

int main() {
	cin >> N >> S;
  //マッチするのは必ず3桁（０～９）
	for (int i = 0; i < 1000; i++) {
		int c[3] = {i / 100, (i / 10) % 10, i % 10};
		int f = 0;
		for (int j = 0; j < N; j++) {
      //マッチしたらずらしていく
			if (S[j] == ('0' + c[f])) f++;
			if (f == 3) break;
		}
		if (f == 3) cnt++;
	}
	cout << cnt << endl;
	return 0;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printdbl(a) printf("%lf\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    char s[101];
    rep(i, 101) s[i] = '\0';
    bool flag = true;
    int count = 0;
    scanf("%s", s);
    while (s[count] != '\0') {
        if ((count + 1) % 2) {
            if (s[count] != 'R' &&
                s[count] != 'U' &&
                s[count] != 'D')
                flag = false;
        }
        else {
            if (s[count] != 'L' &&
                s[count] != 'U' &&
                s[count] != 'D')
                flag = false;
        }
        count++;
    }
    if (flag) printYes();
    else printNo();
    return 0;
}

Measured memory_bytes: 3740
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Numerics;

class Program {
    static void Main (string[] args) {
        var input = INP();
        long N = TOL(input[0]);

        long pay=0;
        for(int i=0;i<20;i++) {
            if(pay>=N) {
                CWL(pay-N);
                return;
            } else {
                pay += 1000;
            }
        }
    }

    public static List<int> PrimeFactors (int n) {
        var tmpList = new List<int>();
        int i = 2;
        int tmp = n;

        while(i * i <= n) {
            if(tmp % i == 0) {
                tmp /= i;
                tmpList.Add(i);
            } else {
                i++;
            }
        }

        if(tmp != 1) tmpList.Add(tmp);

        return tmpList;
    }

    static string[] INP () {
        return Console.ReadLine().Split(' ');
    }

    static void CWL (string value) {
        Console.WriteLine(value);
    }

    static void CWL (int value) {
        Console.WriteLine(value);
    }

    static void CWL (long value) {
        Console.WriteLine(value);
    }

    static void CWL (float value) {
        Console.WriteLine(value);
    }

    static void CWL (double value) {
        Console.WriteLine(value);
    }

    static int TOI (string str) {
        return int.Parse(str);
    }

    static long TOL (string str) {
        return long.Parse(str);
    }

    static float TOF (string str) {
        return float.Parse(str);
    }

    static double TOD (string str) {
        return double.Parse(str);
    }

    /*static void Main (string[] args) {
        var input = INP();
        var input2 = INP();
        var input3 = INP();

        CWL("dummy");
    }*/
}


Measured memory_bytes: 27532