akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int tab[200005];
bitset<1000005> seen;
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	int n,ans=0;
	cin>>n;
	for (int i = 0; i < n; ++i)
		cin>>tab[i];
	sort(tab,tab+n);
	for (int i = 0; i < n; )
	{
		int j=i;
		while((j<n)&&(tab[j]==tab[i]))
			j++;
		if((j-i)>1)seen[tab[i]]=1;
		bool f=1;
		for (int j = 1; j*j <= tab[i]; ++j)
		{
			if(!(tab[i]%j)){
				if(seen[j]){
					f=0;break;
				}
				if(j!=(tab[i]/j)&&seen[tab[i]/j]){
					f=0;break;
				}

			}
		}
		seen[tab[i]]=1;
		if(f)ans++;
		i=j;
	}
	cout<<ans<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 4456
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using vvint = vector<vint>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

const string YES = "Yes";
void yes() { cout << YES << endl; exit(0); }
const string NO = "No";
void no() { cout << NO << endl; exit(0); }

void solve(long long N, long long K, long long Q, std::vector<long long> A){
    vint imos(N+2, 0);
    rep(i, Q) {
        imos[0]++;
        imos[A[i]]--;
        imos[A[i]+1]++;
        imos[N+1]--;
    }
    rep(i, N+1) {
        imos[i+1] += imos[i];
    }
    FOR(i, 1, N+1) {
        if(imos[i] < K) cout << YES << endl;
        else cout << NO << endl;
    }
}

// Generated by atcoder-tools ver.1.1.6
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> A(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, Q, std::move(A));
    return 0;
}


Measured memory_bytes: 1792
import java.io.*;
import java.util.*;
import java.lang.ArrayIndexOutOfBoundsException;
import java.math.BigInteger;

/**
 * @author yoshikyoto
 */
class Main {
	public static void main(String[] args) throws Exception{
		
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int m = Integer.parseInt(br.readLine());
		
		long[] cnt = new long[2];
		
		for (int i = 0; i < m; i++) {
			String[] in = br.readLine().split(" ");
			int c = (int)(in[1].charAt(0) - '(');
			int n = Integer.parseInt(in[2]);
			cnt[c] += n;
			if(cnt[0] == cnt[1]){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

// --- ここから下はライブラリ ----------
/**
 * MyUtil
 * @author yoshikyoto
 */
class MyUtil {
	public static int toInt(boolean[] a){
		int pow = 1, ret = 0, l = a.length;
		for(int i = 0; i < l; i++){
			if(a[i]) ret += pow;
			pow *= 2;
		}
		return ret;
	}
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	public static int ins[];
	public static int[] readIntMap() throws IOException{return parseInt(readLine().split(" "));}
	public static int readIntMap(int i) throws Exception{
		if(i == 0) ins = readIntMap();
		return ins[i];
	}
	public static int[][] readIntMap(int n, int m) throws IOException{
		int[][] ret = new int[n][];
		for(int i = 0; i < n; i++) ret[i] = readIntMap();
		return ret;
	}
	public static int[] readIntToMap(int n) throws IOException{
		int[] ret = new int[n];
		for(int i = 0; i < n; i++) ret[i] = readInt();
		return ret;
	}
	public static int[] readNoDistIntMap() throws IOException{
		String[] strs = readLine().split("");
		int l = strs.length;
		int[] ret = new int[l-1];
		for(int i = 1; i < l; i++)
			ret[i-1] = parseInt(strs[i]);
		return ret;
	}
	public static String readLine() throws IOException{return br.readLine();}
	public static int readInt() throws IOException{return Integer.parseInt(br.readLine());}
	public static int[] parseInt(String[] arr){
		int[] res = new int[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Integer.parseInt(arr[i]);
		return res;
	}
	public static double[] parseDouble(String[] arr){
		double[] res = new double[arr.length];
		for(int i = 0; i < arr.length; i++)res[i] = Double.parseDouble(arr[i]);
		return res;
	}
	public static boolean[] parseBool(String[] arr){
		int[] t = parseInt(arr);
		boolean[] res = new boolean[t.length];
		for(int i = 0; i < t.length; i++){
			if(t[i] == 1){res[i] = true;
			}else{res[i] = false;}
		}
		return res;
	}
	public static int parseInt(Object o){
		return Integer.parseInt(o.toString());
	}
}

Measured memory_bytes: 38628
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 503

double dp[2][102][102];
bool is_exist[NUM];
int line_loc[NUM],can_write_num[NUM];

int main(){

	int H,N,P,M,K;
	scanf("%d %d %d %d %d",&H,&N,&P,&M,&K);

	for(int i = 0; i <= H+1; i++){
		is_exist[i] = false;
		can_write_num[i] = 1;//その高さ以下で、横棒を引ける高さの数
	}

	int height,loc;
	for(int loop = 0; loop < M; loop++){
		scanf("%d %d",&height,&loc);
		is_exist[height] = true;
		line_loc[height] = loc;
		can_write_num[height] = 0;
	}

	for(int h = 2; h <= H+1; h++)can_write_num[h] += can_write_num[h-1];

	for(int i = 0; i < 2; i++){
		for(int k = 0; k <= K; k++){
			for(int pos = 1; pos <= N; pos++)dp[i][k][pos] = 0; //dp[高さ][横棒の設置本数][位置] = ゴール確率
		}
	}

	int CURRENT = 0,NEXT = 1;

	dp[CURRENT][0][P] = 1.0;

	double loc_possi = 1.0/(double)(N-1),height_possi;

	for(int h = H; h >= 1; h--){
		if(is_exist[h]){ //既に横棒が引かれている場合:該当する2箇所の確率を交換する

			for(int num = 0; num <= K; num++){
				swap(dp[CURRENT][num][line_loc[h]],dp[CURRENT][num][line_loc[h]+1]);
			}

		}else{ //横棒が引かれていない場合

			for(int num = 0; num <= K; num++){
				for(int pos = 1; pos <= N; pos++)dp[NEXT][num][pos] = 0.0;
			}

			for(int num = 0; num <= K; num++){

				height_possi = (double)(K-num)/(double)can_write_num[h]; //その高さが選ばれる確率

				for(int pos = 1; pos <= N; pos++){

					//右に動く(★交換回数が1増える!!★)
					if(pos != N){
						dp[NEXT][num+1][pos+1] += height_possi*loc_possi*dp[CURRENT][num][pos];
					}

					//左に動く(★交換回数が1増える!!★)
					if(pos != 1){
						dp[NEXT][num+1][pos-1] += height_possi*loc_possi*dp[CURRENT][num][pos];
					}

					//★変わらず★
					//自分の高さが選ばれない場合
					dp[NEXT][num][pos] += (1-height_possi)*dp[CURRENT][num][pos];

					//自分の高さが選ばれ、かつ自分以外の場所が選ばれる場合
					if(pos != 1 && pos != N){
						dp[NEXT][num+1][pos] += height_possi*(1.0-loc_possi*2)*dp[CURRENT][num][pos];
					}else{ //pos == 1 || pos == N
						dp[NEXT][num+1][pos] += height_possi*(1.0-loc_possi)*dp[CURRENT][num][pos];
					}
				}
			}
			swap(CURRENT,NEXT);
		}
	}

	double ans = 0.0;
	for(int pos = 1; pos <= N; pos++)ans = max(ans,dp[CURRENT][K][pos]);

	printf("%.10lf\n",ans);

	return 0;
}



Measured memory_bytes: 3372
import math

def Show(n):
	s = str(n)
	m = len(s)
	for i in range(6 - m):
		print("0",end = "")
	print("{0}".format(n),end = "")

class city:
	year = 0
	p = 0
	number = 0
	def __init__(self,y,pi,n):
		self.year = y
		self.p = pi
		self.number = n

s = input().split()
n = int(s[0])
m = int(s[1])
cities = []
for i in range(m):
	s = input().split()
	p = int(s[0])
	y = int(s[1])
	cities.append(city(y,p,i))
x = [[] for i in range(n)]
for i in range(m):
	x[cities[i].p - 1].append(cities[i])
for i in range(n):
	x[i].sort(key = lambda x : x.year)
ans = []
for i in range(m):
	ans.append([0,0])
for i in range(n):
	for j in range(len(x[i])):
		ans[x[i][j].number][0] = x[i][j].p
		ans[x[i][j].number][1] = j + 1
for i in range(m):
	Show(ans[i][0])
	Show(ans[i][1])
	print()

Measured memory_bytes: 54064
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = new List<double>();
            var b = new List<string>();
            for (int i = 0; i < n; i++)
            {
                var x = ReadLine().Split(' ');
                a.Add(double.Parse(x[0]));
                b.Add(x[1]);
            }

            double sum = 0;
            for (int i = 0; i < n; i++)
            {
                if (b[i] == "JPY") sum += a[i];
                else sum += a[i] * 380000.0;
            }

            WriteLine(sum);
        }
    }
}



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

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> dp(2,0);
  dp[1] = 1;
  //dp[0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int> next(2, 0);
    for (int d = 0; d <= 101; d++) {
      if (abs(a[i] - d) > 1) continue;
      if (d & 1) {
        next[0] += dp[0];
        next[1] += dp[1];
      } else {
        next[0] += dp[0] + dp[1];
      }
    }
    dp = next;
  }
  cout << dp[0] << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <complex>
using namespace std;

int main() {
    string a, b;
    int c;
    cin >> a >> b;
    c = stoi(a + b);
    int sq = floor(sqrt(c));
    cout << (sq * sq == c ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, i, j, k, max = 0, sum = 0;
    int List[n];

    scanf("%d", &n);
    
    for (i = 0; i < n; i++ ){
        scanf("%d", &List[i]);
    }
  
    for (j = 0; j < n; j++){
        if (List[j] > max){
            max = List[j];
        }
    }

    for (k = 0; k < n; k++){
        sum = sum + List[k];
    }


    if (sum > 2 * max){
        printf("Yes");
    }
    else{
        printf("No");
    }
    
    return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

// consts
int MOD = 1000000007;  // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a


int main() {
    int n, t;
    cin >> n;
    vector<int> p, q, r;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        p.emplace_back(t);
    }
    for (int i = 0; i < n; ++i) {
        cin >> t;
        q.emplace_back(t);
    }
    for (int i = 1; i <= n; ++i) r.emplace_back(i);

    int a, b, i = 1;
    do {
        bool ok = true;
        for (int k = 0; k < n; ++k) {
            if (p[k] != r[k]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            a = i;
        }
        ok = true;
        for (int k = 0; k < n; ++k) {
            if (q[k] != r[k]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            b = i;
        }
        ++i;
    } while (next_permutation(r.begin(), r.end()));
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
cnt = 0

while cnt <= 10**6:
    if (a%2 != 0 or b%2 != 0 or c%2 != 0):
        print(cnt)
        exit()
    
    if a==b==c:
        print(-1)
        exit()
    
    a_ = b//2 + c//2
    b_ = a//2 + c//2
    c_ = a//2 + b//2

    a = a_
    b = b_
    c = c_

    cnt += 1

Measured memory_bytes: 38384
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
	
def main():
	A, B = map(int, input().split(" "))
	
	print((A-1)*(B-1))
	
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3444
import os

def main():
	n = int(input())
	a_list = list(map(int, input().split()))
	b_list = list(map(int, input().split()))
	c_list = list(map(int, input().split()))
	result_num = sum(b_list)

	for i,v in enumerate(a_list):
		count = v
		if i == (len(a_list)-1):
			break
		if (count+1) == a_list[i+1]:
			result_num += c_list[count-1]
	print(result_num)		

	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (100000)
#define pii pair<int, int>

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

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

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

void Main() {
  ll N, C, K; cin >> N >> C >> K;
  vector<ll> T(N);
  rep(i, 0, N) cin >> T[i];
  sort(all(T));
  ll cnt = 0;
  ll res = 0;
  while(cnt < N){
    ll t = T[cnt] + K;
    ll board = 0;
    while(board < C){
      if(T[cnt] <= t){
        board++;
        cnt++;
        if(cnt == N) break;
      }else{
        break;
      }
    }
    res++;
  }
  cout << res << endl;
}

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

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

  Main();
}


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

int main(void) {
  string S, T;
  cin >> S >> T;
  int pos = -1;
  for (int i = 0; i < S.length() - T.length() + 1; i++) {
    bool flag = true;
    for (int j = 0; j < T.length(); j++) {
      if (S[i + j] != T[j] && S[i + j] != '?') {
        flag = false;
        break;
      }
    }
    if (flag) {
      pos = i;
    }
  }

  if (pos == -1) {
    cout << "UNRESTORABLE" << endl;
  } else {
    for (int i = 0; i < T.length(); i++) {
      S[pos + i] = T[i];
    }
    for (int i = 0; i < S.length(); i++) {
      if (S[i] == '?') S[i] = 'a';
      cout << S[i];
    }
    cout << endl;
  }
  return 0;
}

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,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int number = 100 * r + 10 * g + b;
    if (number % 4 == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	a %= p;
	return a >= 0 ? a : a + p;
}

signed main(){
	int N, A, B, C, i, j, s, k, l, t, ans = 0;
	scanf("%lld%lld%lld%lld", &N, &A, &B, &C);
	if(B % 2 == 1){
		printf("0\n");
		return 0;
	}
	int *fact = (int *)malloc(sizeof(int) * (N + 1));
	int *fact_inv = (int *)malloc(sizeof(int) * (N + 1));
	fact[0] = 1;
	for(i = 1; i <= N; i++){
		fact[i] = MOD(fact[i - 1] * i);
	}
	fact_inv[0] = 1;
	fact_inv[1] = 1;
	for(i = 2; i <= N; i++){
		fact_inv[i] = MOD(-(p / i) * fact_inv[p % i]);
	}
	for(i = 1; i <= N; i++){
		fact_inv[i] = MOD(fact_inv[i] * fact_inv[i - 1]);
	}
/*	for(i = 0; i <= N; i++){
		printf("(fact * fact_inv)[%lld] = %lld\n", i, MOD(fact[i] * fact_inv[i]));
	}
*/	for(i = 0; i <= A; i++){
		for(j = 0; i + 3 * j <= C; j++){
			s = C - i - 3 * j;
			k = B / 2;
			l = A + j;
			if(k == 0){
				if(s == 0){
					t = 1;
				}
				else{
					continue;
				}
			}
			else{
				t = MOD(fact[s + k - 1] * MOD(fact_inv[s] * fact_inv[k - 1]));
			}
			t = MOD(t * MOD(fact[l + k] * MOD(fact_inv[l] * fact_inv[k])));
			t = MOD(t * MOD(fact[l] * MOD(fact_inv[A - i] * MOD(fact_inv[i] * fact_inv[j]))));
			ans = MOD(ans + t);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

fn input_char_vec() -> Vec<char> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().chars().collect()
}

fn main() {
    let s: Vec<char> = input_char_vec();
    let mut buf: Vec<char> = Vec::new();
    let mut candidates: Vec<Vec<char>> = Vec::new();
    for c in s {
        if c == 'A' || c == 'T' || c == 'G' || c == 'C' {
            buf.push(c);
        } else {
            candidates.push(buf);
            buf = Vec::new();
        }
    }
    candidates.push(buf);
    let mut max = 0;
    for candidate in candidates {
        if candidate.len() > max {
            max = candidate.len();
        }
    }
    println!("{}", max);
}


Measured memory_bytes: 4352
#!/usr/bin/ruby
def vec_product(a,b)
	a.zip(b).reduce(0){|s,(x,y)|s+x*y}
end
def matrix_mul(a,_b)
	b=_b.transpose
	a.size.times.map{|i|
		b.size.times.map{|j|
			vec_product(a[i],b[j])
		}
	}
end
n,m=gets.split.map(&:to_i)
matrix_mul(*[n,m].map{|e|e.times.map{gets.split.map(&:to_i)}}).each{|e|puts e*' '}

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

using namespace std;

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

  vector<long long> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }

  long long aa = a[0], bb = b[0];
  for (int i = 0; i < n; i++) {
    long long t = max((aa + a[i] - 1) / a[i], (bb + b[i] - 1) / b[i]);
    aa = a[i] * t;
    bb = b[i] * t;
  }
  cout << aa + bb << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double cnt=0,ans;
    for(int i=1;i<=n;i++)
    {
        if(i%2==1)
        {
            cnt++;
        }
    }

    ans=cnt/n;
    cout<<ans<<endl;
    exit(0);
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N;
  map<ll,ll> a;
  ll res=1;
  cin >> N;

  rep(i,N) {
    ll aa;
    cin >> aa;
    auto it = a.find(-aa);
    if(it==a.end()) a.insert(make_pair(-aa,1));
    else it->second++;
  }

  int cnt=0;
  for(auto it:a){
    //cout << it.first << ":" << it.second << endl;                             
    if(cnt==0 && it.second>=4) {
      res*= it.first*it.first;
      cnt += 2;
    }
    else if(it.second>=2){
      if(cnt==0||cnt==1) {
        res*= -it.first;
        cnt++;
      }
    }
    if(cnt>=2) break;
  }
  if(cnt<2) res=0;

  cout << res << endl;

}

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

const int N = 1e5 + 1;

void solve() {
    int n; cin >> n;
    ll sm = 0;
    vector<int> a(n), f(N, 0);
    for (int i = 0; i < n; i++)
        cin >> a[i], f[a[i]]++, sm += a[i];
    int q; cin >> q;
    for (int i = 0, b, c; i < q; i++) {
        cin >> b >> c;
        ll x = f[b];
        sm += x * (c - b);
        f[c] += f[b];
        f[b] = 0;
        cout << sm << '\n';
    }
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    // int _; cin >> _; while (_--)
    solve();
    return 0;
}


Measured memory_bytes: 3912
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())


print(int(math.sqrt(int(input())))**2)


Measured memory_bytes: 4212
#include <cstdio>
#include <climits>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> Star; 
#define SEG_SIZE (1<<18)
int MinX[2*SEG_SIZE-1];
int MinY[2*SEG_SIZE-1];
int MaxX[2*SEG_SIZE-1];
int MaxY[2*SEG_SIZE-1];
int x[SEG_SIZE];
int y[SEG_SIZE];
int b[SEG_SIZE];
int N,segN;
void init(int *x,int *MinX,int *MaxX) {
	segN=1;
	while(N>segN) segN*=2;
	for(int i=0;i<segN;i++) {
		if(i<N) {
			MinX[i+segN-1]=x[i];
			MaxX[i+segN-1]=x[i];
		}else {
			MinX[i+segN-1]=INT_MAX;
			MaxX[i+segN-1]=INT_MIN;
		}
	}
	for(int i=segN-2;i>=0;i--) {
		MinX[i]=min(MinX[i*2+1],MinX[i*2+2]);
		MaxX[i]=max(MaxX[i*2+1],MaxX[i*2+2]);
	}
}
int min_query(int *MinX,int a,int b,int k,int l,int r) {
	if(a<=l&&r<=b) {
		return MinX[k];
	}else if(l>=b||r<=a) {
		return INT_MAX;
	}
	return min(min_query(MinX,a,b,k*2+1,l,(l+r)/2),min_query(MinX,a,b,k*2+2,(l+r)/2,r));
}
int max_query(int *MaxX,int a,int b,int k,int l,int r) {
	if(a<=l&&r<=b) {
		return MaxX[k];
	}else if(l>=b||r<=a) {
		return INT_MIN;
	}
	return max(max_query(MaxX,a,b,k*2+1,l,(l+r)/2),max_query(MaxX,a,b,k*2+2,(l+r)/2,r));
}
int main() {
	int d;
	scanf("%d %d",&N,&d);
	vector<Star> V;
	for(int i=0;i<N;i++) {
		int x,y,b;
		scanf("%d %d %d",&x,&y,&b);
		V.push_back(Star(b,P(x,y)));
	}
	sort(V.begin(),V.end());
	for(int i=0;i<N;i++) {
		x[i]=V[i].second.first;
		y[i]=V[i].second.second;
		b[i]=V[i].first;
	}
	init(x,MinX,MaxX);
	init(y,MinY,MaxY);
	long long ans=0;
	for(int i=0;i<N;i++) {
		int idx=upper_bound(b,b+N,b[i]+d)-b;
		int minX=min_query(MinX,i,idx,0,0,segN);
		int maxX=max_query(MaxX,i,idx,0,0,segN);
		int minY=min_query(MinY,i,idx,0,0,segN);
		int maxY=max_query(MaxY,i,idx,0,0,segN);
		ans=max(ans,(long long)(maxY-minY)*(maxX-minX));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 14724
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 文字列の入力
		String s = sc.next();
		// 出力
      switch(s) {
      case "SUN" :
    	  System.out.println(7);
    	  break;
      case "MON" :
    	  System.out.println(6);
    	  break;
      case "TUE" :
    	  System.out.println(5);
    	  break;
      case "WED" :
    	  System.out.println(4);
    	  break;
      case "THU" :
    	  System.out.println(3);
    	  break;
      case "FRI" :
    	  System.out.println(2);
    	  break;
      case "SAT" :
    	  System.out.println(1);
    	  break;
    	  
      }
	}
}

Measured memory_bytes: 21332
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

ll H, W;
vector<string> A;

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

int main() {
    cin >> H >> W;
    A.resize(H);
    for (ll i = 0; i < H; i++) {
        cin >> A[i];
    }

    struct Element {
        ll cost, x, y;
        bool operator<(const Element& rhs) const {
            return cost > rhs.cost;
        }
    };

    priority_queue<Element> pq;

    vector<vector<ll>> cost(H, vector<ll>(W, INT_MAX));

    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            if (A[i][j] == '#') {
                pq.push({ 0, j, i });
                cost[i][j] = 0;
            }
        }
    }


    while (!pq.empty()) {
        auto t = pq.top();
        pq.pop();

        for (ll i = 0; i < 4; i++) {
            ll nx = t.x + dx[i];
            ll ny = t.y + dy[i];
            ll nc = t.cost + 1;
            if (0 <= nx && nx < W && 0 <= ny && ny < H && nc < cost[ny][nx]) {
                cost[ny][nx] = nc;
                pq.push({ nc, nx, ny });
            }
        }
    }

    ll ans = 0;
    for (ll i = 0; i < H; i++) {
        for (ll j = 0; j < W; j++) {
            ans = max(ans, cost[i][j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 35436
#include<stdio.h>
#include<string.h>

int main(){
	char sa[101],p[100];
	char sb[200];
	scanf("%s",sa);
	scanf("%s",p);
	if(strstr(sa,p) !=NULL){
		printf("Yes\n");
	}else{
		strcpy(sb,sa);
		strcat(sb,sa);
		if(strstr(sb,p) != NULL){
			printf("Yes\n");
		}else{
			printf("No\n");
			}
	}
}

Measured memory_bytes: 972
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	string s;
	int c[2]={0,0},n,i;
	cin >> s;
	n = s.l_ength();
	for(i=0; i<n; ++i){
		++c[s[i]-'0'];
	}
	cout << (min(c[0],c[1])*2) << endl;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    vector<int> A(N), Ac(N);
    rep(i, N) {
        cin >> A[i];
        Ac[i] = A[i];
    }
    sort(A.rbegin(), A.rend());
    rep(i, N) {
        // cout << A[i] << " " << Ac[i] << endl;
        if (A[0] == Ac[i]) {
            cout << A[1] << endl;
        } else {
            cout << A[0] << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3200
n,m,x,y = map(int,input().split())
X = list(map(int,input().split()))
Y = list(map(int,input().split()))
xeast = max(X)
ywest = min(Y)
if xeast < ywest and xeast < y and x < ywest:
  print('No War')
else:
  print('War')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>

using namespace std;

int N;

int main()
{
    cin >> N;
    long long sum = 0;
    long long ans = 0;
    long long A;
    for (int i = 0; i < N; i++)
    {
        cin >> A;
        if(A != 0)
        {
            sum += A;
        }
        else
        {
            ans += sum / 2;
            sum = 0;
        }
    }

    ans += sum / 2;

    cout << ans << endl;

    return 0;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout<< #i<< "= "<< i << endl
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i,n) cin >> a[i];

	ll money=1000 ,s=0;

	REP(i, n-1){
		if(a[i+1]-a[i]<=0)continue;
		s =money/a[i];
		money-=s*a[i];
		money+=s*(a[i+1]);
	}
	cout << money << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
#include<stdbool.h>

int main()
{
  int a,b;
  
  scanf("%d%d",&a,&b);
  
  char s[a+b+1];
  
  scanf("%s",s);
  
  int i;
  bool flag=true;
  
  if(s[a]!='-')
  {
    flag=false;
  }
  
  if(s[a]=='-')
  {
    for(i=0;i<a+b+1;i++)
    {
      if(i!=a)
      {
        if('0'>s[i]||s[i]>'9')
        {
          flag=false;
        }
      }
    }
  }
  
  if(flag==true)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  
  return 0;
}
    

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

int N, A, B, C, X;
vector<int> Y;

int solve() {
  int cnt = 0;
  for (int i = 0; i <= 10000; ++i) {
    if (Y[cnt] == X) ++cnt;
    if (cnt == N) return i;
    X = (A * X + B) % C;
  }
  return -1;
}

int main() {
  while (cin >> N >> A >> B >> C >> X, N) {
    Y = vector<int>(N);
    for (int i = 0; i < N; ++i) cin >> Y[i];
    cout << solve() << endl;

  }
  return 0;
}



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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

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

  while(true){

    c -= b;

    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }

    a -= d;

    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }



  }



  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;


int FACT(int n, int k) {
    int ret = 1;
    for (int i = 0; i < k; ++i) {
        ret = ret * (n - i);
    }
    return ret;
}

int POW(int n, int k) {
    int ret = 1;
    for (int i = 0; i < k; ++i) {
        ret = ret * n;
    }
    return ret;
}


int COM(int n, int k) {
    if (n==0 || n <= k ) return 1;
    int x = FACT(n, k);
    int y = FACT(k, k);
    return x / y; 
}

int main() {
    string s; 
    int k;
    cin >> s;
    cin >> k;
    int n = s.size();
    int ret = 0;
    rep(i, s.size()) {
        int is = s[i] - '0';
        n--;
        if (is == 0) continue;
        if (n >= k) ret += COM(n, k) * POW(9, k);
        if (n >= k -1) ret += COM(n, k-1) * (is-1) * POW(9, k-1);
        k--;
        if (k==0) {
            ret++; 
            break;
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

#define int long long
#define double long double

//main.cpp-Sample


namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
}


using namespace std;
signed main (){
	int n;
	cin >> n;
	string s;
	cin >> s;
	s.erase(unique(s.begin(), s.end()),s.end());
	cout<<s.size()<<endl;
	return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, T;
  cin >> N >> T;
  vector<vector<int>> vec(N,vector<int>(2));
  for(int i=0; i<N; i++){
    for(int j=0; j<2; j++){
      cin >> vec.at(i).at(j);
    }
  }
  int MINF = -10000;
  int dp1[N+1][T+1];
  int dp2[N+1][T+1];
  for(int i=0; i<N+1; i++){
    for(int j=0; j<T+1; j++){
      dp1[i][j] = 0;
      dp2[i][j] = 0;
    }
  }
  
  for(int i=0; i<N; i++){
    int a = vec.at(i).at(0);
    int b = vec.at(i).at(1);
    if(a <= T){
      dp1[i+1][a] = max(dp1[i+1][a],b);
    }
    for(int j=0; j<T+1; j++){
      int x = MINF;
      if(j - a >= 0){
        x = dp1[i][j-a];
      }
      dp1[i+1][j] = max({dp1[i+1][j], dp1[i][j], x + b});
    }
  }
  
  
  for(int i=0; i<N; i++){
    int a = vec.at(N-i-1).at(0);
    int b = vec.at(N-i-1).at(1);
    if(a <= T){
      dp2[i+1][a] = max(dp2[i+1][a],b);
    }
    for(int j=0; j<T+1; j++){
      int x = MINF;
      if(j - a >= 0){
        x = dp2[i][j-a];
      }
      dp2[i+1][j] = max({dp2[i+1][j], dp2[i][j], x + b});
    }
  }
  
  /*for(int i=0; i<N+1; i++){
    for(int j=0; j<T+1; j++){
      cout << dp1[i][j] << " ";
    }
    cout << endl;
  }*/
  
  
  int ans = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<T; j++){
      ans = max(ans,dp1[i][j] + dp2[N-i-1][T-j-1] + vec.at(i).at(1));
    }
  }
  cout << ans << endl;
}


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

using namespace std;

long long a[100005], n, res = 0, s[100005];
int main()
{
    cin >> n;
    for (long long i = 1; i <= n; i++) cin >> a[i];
    sort(a+1, a+n+1);
    for (long long i = 1; i <= n; i++) s[i] = s[i-1] + a[i];
    res = 1;
    for (long long i = n-1; i >= 1; i--)
        if (s[i]*2 >= a[i+1]) res++;
        else break;
    cout <<res;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

int main()
{
    int n; cin >> n;
    vector<int> a(n+2, 0);
    for (int i = 1; i < n+1; ++i) cin >> a[i];

    int s = 0;
    for (int i = 0; i <= n; ++i) {
        s += abs(a[i] - a[i+1]);
    }

    for (int i = 1; i <= n; ++i) {
        int ans = s + abs(a[i-1] - a[i+1]) -
                    (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]));
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cstdio>
#include<cmath>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
int MOD=1000000007;
signed main(){
    int a,b;cin>>a>>b;
    if(b%a==0)cout<<a+b<<endl;
    else cout<<b-a<<endl;
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
array = [0] * N
ans = 0

for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    array[A] = max(array[A], H[B])
    array[B] = max(array[B], H[A])

for j in range(N):
    if array[j] < H[j]:
      ans += 1

print(ans)

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

#include <atcoder/all>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using namespace atcoder;
typedef long long ll;

int main() {
  ll n, m, ans = 0, a, b;
  cin >> n >> m;
  dsu d(n);

  rep(i, m) {
    cin >> a >> b;
    a--, b--;
    d.merge(a, b);
  }

  rep(i, n) for (int j = i + 1; j < n; ++j) {
    if (d.size(i) == n) break;
    if (d.same(i, j))
      continue;
    else
      d.merge(i, j), ans++;
  }

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


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

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

int main(){
 
  int a,b;
  cin >> a >> b;
  if(a>=b)
    rep(i,a)
    cout << b;
  else
    rep(i,b)
    cout << a;
    
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
main=do
    [d,n] <- map read.words<$>getLine::IO[Int]
    print $ case d of
        0 -> head $ drop (n-1) [a | a<-[1..], (a `mod` 100) /= 0] :: Int
        1 -> head $ drop (n-1) [a | a<-[100,200..], (a `mod` 10000) /= 0] :: Int
        2 -> head $ drop (n-1) [a | a<-[10000,20000..], (a `mod` 1000000) /= 0] :: Int


Measured memory_bytes: 508
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define umap unordered_map
#define all(v) v.begin(),v.end()
#define st first
#define nd second
#define L (no<<1)
#define R L|1
#define mid (s + e) / 2
#define ln '\n'
#define MAX (1<<31)
#define MOD 1000000007
#define N 300005
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pii;
typedef vector<int> vi;
int n, m;
ll ans;
int main(){
    //#ifndef ONLINE_JUDGE
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //#endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL );cout.tie(NULL);
    cin >> n >> m;
    cout << ((n * (n - 1)) + (m * (m - 1))) / 2;
    
}


Measured memory_bytes: 256
$N=<>;@A=glob<>;
++$\;
while($i+1<$N){
	($x,$y)=@A[$i,$i+1];
	if($f==0){
		$f=$y-$x
	}elsif($f<0){
		if($y-$x>0){
			$f=!++$\
		}
	}else{
		if($y-$x<0){
			$f=!++$\
		}
	}
	++$i
}
print


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

import numpy as np


def solv(x, l_):
    ok = np.add.accumulate(l_) <= x
    return np.count_nonzero(ok) + 1


if __name__ == '__main__':

    n, x = map(int, input().split())

    l_ = np.fromstring(input(), dtype=np.uint16, sep=' ')

    ans = solv(x, l_)

    print(ans)


Measured memory_bytes: 12500
#include<iostream>

using namespace std;

int main(){
    int N, Y;
    bool TF = false;
    cin >> N >> Y;
    for(int x = 0; x <= Y / 10000; x++){
        for(int y = 0; y <= (Y - 10000 * x) / 5000; y++){
            int z = N - x - y;
            if(x * 10000 + y * 5000 + z * 1000 == Y){
                cout << x << ' ' << y << ' ' << z << endl;
                TF = true;
                break;
                }
        }
        if(TF == true) break;
    }
    if(TF == false) cout << -1 << ' ' << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
int co[200010];long long pre[200010];
priority_queue<long long>v;

int main(){
	int n;read(n);
	rep(i,1,n){read(co[i]);pre[i]=pre[i-1]+co[i];v.push(pre[i]);}
	v.push(0);
	
	long long ans=0;
	while(!v.empty()){
		long long nop=v.top();v.pop();int cnt=1;
		while(!v.empty()&&nop==v.top()){cnt++;v.pop();}
		ans+=1ll*cnt*(cnt-1)/2;
	}
	write(ans);
	return 0;
}


Measured memory_bytes: 4336
#include <iostream>
#include<string>

using namespace std;
int main(void){
      string s;
      cin >> s;
      bool a=false,b=false,c=false;
      for(int i=0;i<3;i++){
          if(s[i] == 'a'){
              a = true;
          }
          if(s[i] == 'b'){
              b = true;
          }
          if(s[i] == 'c'){
              c = true;
          }
      }
      if(a & b & c){
          cout << "Yes" << endl;
      }else{
          cout << "No" << endl;
      }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int A, B, C;
const ll mod = 1'000'000'007;
ll fact[1'000'010];
ll finv[1'000'010];
ll pow3[1'000'010];

ll Pow(ll b, ll e){
	ll ret = 1;
	while(e){
		if(e % 2 == 1) ret = ret * b % mod;
		e /= 2;
		b = b * b % mod;
	}
	return ret;
}

void Build(){
	fact[0] = finv[0] = pow3[0] = 1;
	for(int i=1; i<=1'000'000; ++i){
		fact[i] = fact[i-1] * i % mod;
		finv[i] = Pow(fact[i], mod - 2);
		pow3[i] = pow3[i-1] * 3 % mod;
	}
}

ll Comb(ll n, ll r){
	if(n<0 || r<0 || r>n) return 0;
	return fact[n] * finv[r] % mod * finv[n-r] % mod;
}

int main()
{
	Build();
	cin >> A >> B >> C;
	ll ans = 0;
	ll v3 = 0;
	for(ll s = 0; s <= B+C; ++s){
		ll v1 = Comb(A+s-1, A-1);
		ll v2 = pow3[B+C-s];
		if(s == 0) v3 = 1;
		else {
			v3 = v3 * 2;
			v3 += mod - Comb(s-1, C);
			if(s >= B) v3 += mod - Comb(s-1, B);
			v3 %= mod;
		}
		ll t;
		ans += t = v1 * v2 % mod * v3 % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

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

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

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


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

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


#define MAX_N 20
#define MAX_M 20
i64 A[MAX_N][MAX_M];


int main() {
    i64 N, M, C; cin >> N >> M >> C;
    vector<i64> B(M);
    REP(i, M) cin >> B[i];
    REP(i, N) REP(j, M) cin >> A[i][j];

    i64 cnt = 0;
    REP(i, N) {
        i64 s = C;
        REP(j, M) {
            s += A[i][j] * B[j];
        }
        if (s > 0) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X, L):
    ans = 0
    D = 0
    for l in L:
        if D <= X:
            ans += 1
        D += l
    if D <= X:
        ans += 1

    return ans


def main():
    N, X = read_int_n()
    L = read_int_n()
    print(slv(N, X, L))


if __name__ == '__main__':
    main()


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}
ll V,E;
const int MAX_V = 1000000;
vector<int> g[MAX_V];
vector<int> rg[MAX_V];
vector<ll> vs;
array<bool,MAX_V> use;
array<int,MAX_V> cmp;

void add_edge(int from,int to){
  g[from].push_back(to);
  rg[to].push_back(from);
}

void dfs(int v){
  use[v] = true;
  rep(i,g[v].size()){
    if(!use[g[v][i]]){
      dfs(g[v][i]);
    }
  }
  vs.push_back(v);
}

void rdfs(int v,int k){
  use[v] = true;
  cmp[v] = k;
  rep(i,rg[v].size()){
    if(!use[rg[v][i]]) rdfs(rg[v][i],k);
  }
}

int scc(){
  fill(all(use),false);
  vs.clear();
  rep(i,V){
    if(!use[i]) dfs(i);
  }
  fill(all(use),false);
  int k = 0;
  for(int i = vs.size()-1; i >= 0; --i){
    if(!use[vs[i]]) rdfs(vs[i],k++);
  }
  return k;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V >> E;
  int s,t;
  rep(i,E){
    cin >> s >> t;
    add_edge(s,t);
  }
  scc();
  ll q;
  cin >> q;
  rep(i,q){
    cin >> s >> t;
    cout << (cmp[s] ==cmp[t]) <<endl;
  }
  return 0;
}

Measured memory_bytes: 52452
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) (((n % k) + k ) % k)

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

    int n, m, k;
    bool res = false;

    cin >> n >> m >> k;

    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            res |= i * (m - j) + j * (n - i) == k;
        }
    }

    if (res)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}  

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

is_ball_contains = [0] * (n+1)
for i in range(n, 0, -1):
    if sum(is_ball_contains[i::i]) % 2 != a[i-1]:
        is_ball_contains[i] = 1

print(sum(is_ball_contains))
print(' '.join([str(i) for i, v in enumerate(is_ball_contains) if v]))


Measured memory_bytes: 14780
#include<cstdio>
#include<iostream>
#include<vector>
using namespace std;

int main(void) {
	int N, K;
	scanf("%d %d", &N, &K);
	int ans = 0;
	while (N > 0) {
		N /= K;
		ans++;
	}

	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<vector>
#include<queue>
#include<set>

using ll = long long;
using namespace std;

const int INF = 1001001001;
const int MOD = 1000000007;

int main(void){
	int n;
	cin >> n;
	set<string> s;
	for (int i = 0;i < n;i++){
		string tmp;
		cin >> tmp;
		s.insert(tmp);
	}
	cout << s.size() << endl;
	
	return 0;
}

Measured memory_bytes: 19220