akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static int A;
        static int B;
        static int C;
        static int D;

        static int[] H;

        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            A = int.Parse(s[0].ToString());
            B = int.Parse(s[1].ToString());
            C = int.Parse(s[2].ToString());
            D = int.Parse(s[3].ToString());

            H = new int[4] { A, B, C, D };

            Saiki(0, A,A.ToString());
            
        }

        static void Saiki(int i,int sum,string f)
        {
            if(i == 3)
            {
                if(sum == 7)
                {
                    Console.WriteLine(f +"=7");
                    Environment.Exit(0);
                }
            }
            else
            {
                Saiki(i + 1, sum + H[i+1], $"{f}+{H[i+1]}");
                Saiki(i + 1, sum - H[i+1], $"{f}-{H[i+1]}");

            }

        }


    }
    

    

}


Measured memory_bytes: 15188
#include <stdio.h>
int main(){
    int X,par,impar;
    scanf("%d", &X);
    if(X%2){
        impar = X/2+1;
        par = X/2;
    }
    else {
        par = X/2;
        impar = par;
    }
    printf("%d\n", impar*par);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll prime[10]= {2,3,5,7,11,13,17,19,23,29};
ll Quick_Multiply(ll a,ll b,ll c)
{
    long long ans=0,res=a;
    while(b)
    {
        if(b&1)
            ans=(ans+res)%c;
        res=(res+res)%c;
        b>>=1;
    }
    return (ll)ans;
}
ll Quick_Power(ll a,ll b,ll c)
{
    ll ans=1,res=a;
    while(b)
    {
        if(b&1)
            ans=Quick_Multiply(ans,res,c);
        res=Quick_Multiply(res,res,c);
        b>>=1;
    }
    return ans;
}
bool Miller_Rabin(ll x)
{
    ll i,j,k;
    ll s=0,t=x-1;
    if(x==2)
        return true;
    if(x<2||!(x&1))
        return false;
    while(!(t&1))
    {
        s++;
        t>>=1;
    }
    for(i=0; i<10&&prime[i]<x; ++i)
    {
        ll a=prime[i];
        ll b=Quick_Power(a,t,x);
        for(j=1; j<=s; ++j)
        {
            k=Quick_Multiply(b,b,x);
            if(k==1&&b!=1&&b!=x-1)
                return false;
            b=k;
        }
        if(b!=1)
            return false;
    }
    return true;
}
int main()
{
    ll a,b;
    cin>>a>>b;
    ll g=gcd(a,b);
    ll ans=1;
    if(g==1)
    {
        cout<<1<<endl;
        return 0;
    }
    if(Miller_Rabin(g))
    {
        cout<<2<<endl;
        return 0;
    }
    ll x=sqrt(g);
    for(int i=2; i<=x; i++)
    {
        if(g%i==0)
        {
            if(Miller_Rabin(i))
                ans++;
            if(Miller_Rabin(g/i))
                ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>

#include<algorithm>

using namespace std;

int main(){

  double h[50];
  int n=0;

  while(cin>>h[n]){
    n++;
  }

  sort(h,h+n);

  cout<<h[n-1]-h[0]<<endl;

  //h[0]???????°?
  //h[n-1]????????§

  return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
cin>>a>>b>>c;
int flg=0;
for(int i=0;i<=b;i++){
	if(a*i%b==c)flg=1;
	}
	if(flg)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	}


Measured memory_bytes: 256
n=int(input())
h_list=[int(s) for s in input().split()]

if n==1:
    print('Yes')
    exit()

left=h_list[0]
for i in range(1,n):
    right=h_list[i]

    if left<right:
        left=right-1
        continue
    if left==right:
        continue
    print('No')
    exit()


print('Yes')

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

const int N = 5e5;
int Bit[26][N+100];
char str[N+100];

void update(int id,int idx,int val)
{
	while(idx<=N)
	{
		Bit[id][idx] += val;
		idx += (idx&-idx);
	}
}
int query(int id,int idx)
{
	int total = 0;
	while(idx>0)
	{
		total += Bit[id][idx];
		idx -= (idx&-idx);
	}
	return total;
}
int main()
{
	int n,q;
	scanf("%d%s%d",&n,str+1,&q);
	for(int i=1;i<=n;i++){
		update(str[i]-'a',i,1);
	}
	while(q--)
	{
		int type;
		scanf("%d",&type);
		if(type==1){
			int idx;
			char s[3];
			scanf("%d%s",&idx,s);
			update(str[idx]-'a',idx,-1);
			update(s[0]-'a',idx,1);
			str[idx] = s[0];
		}
		else{
			int l,r,ans = 0;
			scanf("%d%d",&l,&r);
			for(int i=0;i<26;i++){
				if(query(i,r)-query(i,l-1)){
					ans++;
				}
			}
			printf("%d\n",ans);
		}
	}
}


Measured memory_bytes: 55064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int[] tt = new int[n];
        for (int i = 0; i < n; i++) {
            tt[i] = sc.nextInt();
        }
        int pos = 0;
        int ans = 0;
        int time = 0;
        while (pos < n) {
            int on = tt[pos] + t;
            if (time <= tt[pos]) {
                time = on;
                ans += t;
                pos++;
            } else {
                ans += on - time;
                time = on;
                pos++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 64408
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = 1LL << 60;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;

}

signed main() {
	string l;

	cin >> l;

	ll ans = 1;
	ll cnt = 0;
	vector<ll> x;
	vector<ll> v(l.size(), 0);
	vector<ll> vv(l.size(), 0);

	REP(i, l.size()) {
		if (l[i] == '1') {
			cnt++;
		}
		else {
			v[i] = cnt;
		}
	}

	RREP(i, l.size()) {
		vv[i] = ans;
		ans *= 3;
		ans %= MOD;
	}

	x.push_back(1);

	REP(i, l.size()) {
		x.push_back((x[i] * 2) % MOD);
	}

	ll now = 0;

	RREP(i, l.size()) {
		if (l[i] == '0') {
			ll z = (((x[v[i]] * 2) % MOD) * vv[i]) % MOD;
			ans += MOD;
			ans -= z;
			ans %= MOD;
		}
	}

	cout << ans % MOD << endl;
}

Measured memory_bytes: 3192
using System;
namespace ABC086A_Product
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            Console.WriteLine((a * b) % 2 == 0 ? "Even" : "Odd");
        }
    }
}


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

int main(){
int n;
cin >> n;
while(n > 10){
    n=n % 10;
}
if(n ==2 || n == 4 || n == 5 || n== 7 || n==9)
cout << "hon" << endl;
else if(n == 0 || n == 1 || n == 6 || n ==8)
cout << "pon" << endl;
else
{
    cout << "bon" <<endl;
}


}


Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}










Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    int k = n % 10;
    string ans = "hon";
    if (k == 3)
    {
        ans = "bon";
    }
    if (k == 0 || k == 1 || k == 6 || k == 8)
    {
        ans = "pon";
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3624
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

    # divisors.sort()
    return divisors
u=len(make_divisors(n-1))-1
lis=make_divisors(n)
lis.remove(1)
#print(lis)
def divsub(n,k):
    flag=True
    while flag==True:
        n//=k
        if n%k==1:
            return 1
            flag=False
        elif n%k!=0:
            return 0
            flag=False
#print(divsub(10,5))
ans=0
for i in range(len(lis)):
    ans+=divsub(n,lis[i])
print(ans+u)

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll n;
ll d[e5];
ll abc,arc;
ll ans;

int main(){
  cin >> n;
  for(ll i = 0;i < n;i++) cin >> d[i];
  sort(d,d+n);
  abc = 0;
  arc = n;
  for(ll i = 0,j = 0;i <= 100001;i++){
    while(j < n && d[j] < i){
      j++;
      abc++;
      arc--;
    }
    if(abc == arc) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define N 100009
 
using namespace std;
 
char s1[10];
int final[20],temp[20];

int main(){
	int i,j,t1,t2,t3,t4,n,ans,low,mid,high,tempans,digits=1;
	long long int num;
	t1=1;
	for(i=1;i<=9;i++){
		t1*=10;
		printf("? %d\n",t1);
		fflush(stdout);
		scanf("%s",s1);
		if(s1[0]=='Y'){
			digits++;
		}
		else{
			break;
		}
	}
	if(digits==10){
		digits=0;
		t1=2;
		for(i=1;i<=10;i++){
			if(i>1){
				t1*=10;
			}
			printf("? %d\n",t1);
			fflush(stdout);
			scanf("%s",s1);
			if(s1[0]=='Y'){
				digits=i;
				break;
			}
		}
		printf("! 1");
		fflush(stdout);
		for(i=0;i<digits-1;i++){
			printf("0");
			fflush(stdout);
		}
		printf("\n");
		fflush(stdout);
		return 0;
	}
	for(i=0;i<digits;i++){
		if(i!=digits-1){
			low=(i==0)?1:0;
			high=9;
			tempans=-1;
			while(low<=high){
				mid=(low+high)/2;
				for(j=0;j<digits;j++){
					temp[j]=final[j];
				}
				temp[i]=mid;
				num=0;
				for(j=0;j<=i;j++){
					num=num*10+temp[j];
				}
				printf("? %lld\n",num);
				fflush(stdout);
				scanf("%s",s1);
				if(s1[0]=='Y'){
					tempans=mid;
					low=mid+1;
				}
				else{
					high=mid-1;
				}
			}
			final[i]=tempans;
		}
		else{
			low=(i==0)?1:0;
			for(j=low;j<=9;j++){
				num=0;
				for(t1=0;t1<=i;t1++){
					num=num*10+final[t1];
				}
				num+=j;
				num*=10;
				printf("? %lld\n",num);
				fflush(stdout);
				scanf("%s",s1);
				if(s1[0]=='Y'){
					num/=10;
					ans=num;
					break;
				}
			}
		}
	}
	printf("! %d\n",ans);
	fflush(stdout);
	return 0;		
}

Measured memory_bytes: 596
#include <iostream>

constexpr int MAX = 1010;

using ll = long long int;

constexpr ll INF = 1e15;

ll a[MAX], b[MAX], c[MAX];

int d(bool x)
{

    return x ? 1 : -1;
}

ll getScore(int bit, int index)
{

    return d(bit & 4) * a[index] + d(bit & 2) * b[index] + d(bit & 1) * c[index];
}

ll dp[MAX][MAX];

int main()
{

    int n, m;

    std::cin >> n >> m;

    for (int i = 1; i <= n; ++i)
        std::cin >> a[i] >> b[i] >> c[i];

    for (int i = 1; i <= m; ++i)
        dp[i][0] = -INF;

    ll ans = 0;
    for (int bit = 0; bit < 8; ++bit)
    {
        for (int i = 1; i <= m; ++i)
        {
            for (int j = 1; j <= n; ++j)
                dp[i][j] = std::max(dp[i][j - 1], dp[i - 1][j - 1] + getScore(bit, j));
        }
        ans = std::max(ans, dp[m][n]);
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 8192
void main(){
	int[] vals = inln();
	( ((vals[2]+0.5)/vals[0]).to!int()*vals[1] ).writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2684
n = gets.to_i
ds = gets.split.map(&:to_i)
mod = 998244353
cnt = Array.new(ds.max+1, 0)
(0..n-1).each do |i|
  if (i == 0 && ds[i] != 0) || (i != 0 && ds[i] == 0)
    puts 0
    exit
  end
  cnt[ds[i]] += 1
end
cnt.shift
ans = 1
(0..cnt.length-2).each do |i|
  ans = ans * (cnt[i] ** cnt[i + 1])
end
ans %= mod
puts ans


Measured memory_bytes: 47220
#include<iostream>
#include<stdio.h>
#include<vector>
#include<ctype.h>
#include<string>
#include<cmath>
#include<string.h>
#include<sstream>
#include<limits.h>
using namespace std;

int N,K;
vector <int> A;

int main(){
    cin>>N>>K;
    A.resize(N);
    for(int i=0;i<N;++i){
        cin>>A[i];
    }
    for(int i=0;i<K;++i){
        if(i>=N)break;
        vector<int> B(N);
        for(int j=0;j<N;++j){
            int l = max(0,j-A[j]);
            int r = min(N-1,j+A[j]);
            B[l]++;
            if(r+1<N)B[r+1]--;
        }
        for(int j=1;j<N;++j){
            B[j]+=B[j-1];
        }
        if(A==B)break;
        A=B;
    }
    for(int i=0;i<N;++i){
        if(i!=0)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 4828
#include <iostream>
using namespace std;
int box[100001];
int red[100001];
int x,y;
void init(){
	for(int i = 0;i < 100001;i++){
		box[i] = 1;
		red[i] = 0;
	}
	red[1] = 1;
}

void show(int n){
	cout << "Box:";
	for(int i = 1;i <= n;i++){
		cout << box[i];
	}
	cout << endl;
	cout << "Red:";
	for(int i = 1;i <= n;i++){
		cout << red[i];
	}
	cout << endl;
}

void move(){
	if(red[x] == 1){
		if(box[x] == 1){
			red[x] = 0;
		}
		box[x] -= 1;
		box[y] += 1;
		red[y] = 1;
	}else{
		box[x] -= 1;
		box[y] += 1;
	}
}

int main(){
	int N,M;
	cin >> N >> M;
	init();
	//show(N);
	while(cin >> x >> y){
		move();
		//show(N);
	}
	int ans = 0;
	for(int i = 0;i < 100001;i++){
		ans += red[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
A, B, C = map(int, input().split())

A, B, C = sorted([A, B, C])

x = C - B
y = C - A
def func(x, y):
  return ((y-x)//2 + x)

if ((x-y) % 2) == 1:
  print(1 + func(x, y+1))
else:
  print(func(x, y))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
 
int main() {
 
    int d, t, s;
    cin >> d >> t >> s;
 
    //Calculate the duration of Takahashi's journey
    double time = (double)d / s;
 
    //Output depending on the inequality between T and time
    if (t >= time) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3504
import itertools
while True:
  n, x = map(int, input().split())
  if n == x == 0:
    break
  else:
    list_com = list(itertools.combinations(range(1, n+1), 3))
    list_cnt = []
    for i in range(len(list_com)):
      if sum(list_com[i]) == x:
        list_cnt.append(list_com[i])
      else:
        continue
  print(len(list_cnt))


Measured memory_bytes: 31424
#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void){
  int n;
  while(cin >> n && n){
    int a[n],sum,ret = 1<<29;
    for(int i=0;i<n;i++) cin >> a[i];
    sum = accumulate(a,a+n,0);
    for(int i=1;i<(1<<n)-1;i++){
      int tmp=0;
      for(int j=0;j<n;j++){
	if(i&(1<<j)) tmp+=a[j];
      }
      ret = min(ret, abs(tmp - (sum-tmp)));
    }
    cout << ret << endl;
  }
}

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= c && c <= b) {
        cout << "Yes" << endl;
        return 0;
    }
    if (b <= c && c <= a) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}

int main() {
    string a;
    cin >>  a;
    if (a[a.size()-1] != 's') {
        cout << a << 's' <<endl;
    } else{
        cout << a << "es" <<endl;
    }
}

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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = abc[0];
            var b = abc[1];
            var c = abc[2];

            var g = 1;

            for(int i = 2; i <= Math.Min(a,b); i++)
            {
                while(a % i == 0 && b % i == 0)
                {
                    g *= i;
                    a /= i;
                    b /= i;
                }
            }
            if(c % g == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 28280
#include <iostream>
#include <string>
using std::cin;
using std::cout;
using std::endl;
int main(){
  int a = 0, b = 0;
  std::string sta;
  cin >> sta;
  for(int i = 0; i < sta.size(); i++){
    if(sta.at(i) == 'A'){
      a++;
    }
    else if(sta.at(i) == 'B'){
      b++;
    }
  }
  if(a != 0  && b != 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

ll a[N],c[N];
int main(){
    ios_base::sync_with_stdio(0);
    ll n,t;
    cin>>n>>t;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    c[1]=a[1];
    for(int i=2;i<=n;i++){
        c[i]=min(c[i-1],a[i]);
    }
    ll m=0;
    for(int i=2;i<=n;i++){
        m=max(a[i]-c[i],m);
    }
    int sum=0;
    for(int i=1;i<=n;i++)
        if(a[i]-c[i]==m)
            sum++;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
////////////////////////
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
namespace my {
char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }
ll gcd(ll a, ll b) {
  a = abs(a);
  b = abs(b);
  if (a < b) swap(a, b);
  while (b != 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
ll lcm(ll a, ll b) { return a * b / my::gcd(a, b); }
vector<pair<ll, ll>> primeFac(ll n) {
  vector<pair<ll, ll>> ret;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll exp = 0;
    while (n % i == 0) {
      n /= i;
      exp++;
    }
    ret.push_back(make_pair(i, exp));
  }
  if (n != 1) ret.push_back(make_pair(n, 1));
  return ret;
}
}  // namespace my
////////////////////////

int main() {
  ll n, d;
  cin >> n >> d;
  vector<pair<ll, ll>> vp;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    vp.push_back(make_pair(x, y));
  }

  int ans = 0;
  for (auto vpi : vp) {
    if (vpi.first * vpi.first + vpi.second * vpi.second <= d * d) ans++;
  }

  cout << ans << endl;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  a = (a == 1) ? 14 : a;
  b = (b == 1) ? 14 : b;

  if(a == b) cout << "Draw";
  else if(a > b) cout << "Alice";
  else cout << "Bob";
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.141592653589793238
#define dcout cout<<fixed<<setprecision(20)

const long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long
#define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

int fact[500000], invfact[500000];

int invmod(int a, int p){ // a^-1 mod p
  int b = p, u = 1, v = 0;
  while(b){
    int t = a / b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= p;
  if(u < 0) u += p;
  return u;
}

void factmod(int m){
  fact[0] = invfact[0] = 1;
  for(int i = 1; i < 500000; i++){
    fact[i] = (fact[i-1] * i) % m;
    invfact[i] = (invfact[i-1] * invmod(i, m)) % m;
  }
}

int nCrmod(int n, int r, int m){
  return (((fact[n] * invfact[r]) % m) * invfact[n-r]) % m;
}

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

  int N, A, B, C; cin >> N >> A >> B >> C;
  factmod(MOD);
  int PA[250000], PB[250000], PH[250000];
  PA[0] = PB[0] = PH[0] = 1;
  int invh = invmod(A+B, MOD);
  REP(i, 2*N+100){
    PA[i+1] = PA[i]*A; PA[i+1] %= MOD;
    PB[i+1] = PB[i]*B; PB[i+1] %= MOD;
    PH[i+1] = PH[i]*invh; PH[i+1] %= MOD;
  }

  int ans = 0;
  for(int M = N; M < 2*N; M++){
    ans += nCrmod(M-1, N-1, MOD)*((PA[N]*PB[M-N] % MOD + PA[M-N]*PB[N] % MOD)%MOD) % MOD * M % MOD * PH[M+1] % MOD * 100 % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 13568
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <algorithm>
#include <bitset>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int L, N;
  ll ans, aft=0;
  std::cin >> L >> N;
  std::vector<int> x(N);
  range(i, N) std::cin >> x[i];
  sort(x.begin(), x.end());
  ans = max(x[N-1], L-x[0]);
  for(int i=N-1;i>0;i--){
    if(i==N-1) aft+=L-x[i];
    else {
      aft += x[i];
      if((N-1-i)%2==0){
        aft -= x[(N-1+i)/2];
        aft += L-x[(N-1+i)/2];
      }
    }
    //std::cout << (x[i-1]+aft)*2 << '\n';
    ans = max(ans, (x[i-1]+ aft)*2- ((N-1-i)%2==0?L - x[(N-1+i)/2]:x[((N-1+i)/2)]));
    //std::cout << (x[i-1]+ aft)*2- ((N-1-i)%2==0?L - x[(N-1+i)/2]:x[((N-1+i)/2)]) << '\n';
  }
  aft = 0;
  for(int i=0;i<N-1;i++){
    if(i==0) aft += x[i];
    else{
      aft+=L-x[i];
      if(i%2==0){
        aft -= L - x[i/2];
        aft += x[i/2];
      }
    }
    ans = max(ans, (L - x[i+1] + aft)*2-(i%2==0?x[i/2]:L-x[1+(i/2)]));
    //std::cout << (L - x[i+1] + aft)*2-(i%2==0?x[i/2]:L-x[1+(i/2)]) << '\n';
  }
  std::cout << ans << '\n';

}


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

int main()
{
	long long  n;
	while(cin>>n && n!=0){
		int ans=1;
		long long  count=3;
		while(count<n){
			ans++;
			count*=3;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    int cnt = 0;
    rep(i,S.size()) {
        if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
            ++cnt;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
        if (i == S.size() - 1) ans = max(ans, cnt);
    } 
    cout << ans << endl;
}


Measured memory_bytes: 3588
N, K = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
arr.sort()
mem = [False for i in range(K+1)]
mem[0] = False
for i in range(K):
  local_result = mem[i]
  for j in arr:
    if i+j <= K:
      mem[i+j] =  mem[i+j] or not local_result
mem[0] = True
#print(mem)
if mem[K]:
  print("First") 
else:
  print("Second")

Measured memory_bytes: 45344
from collections import Counter
inpl = lambda: list(map(int,input().split()))
H, W, M = inpl()
Shw = set()
Sh = []
Sw = []
for _ in range(M):
    h, w = inpl()
    h -= 1
    w -= 1
    Sh.append(h)
    Sw.append(w)
    Shw.add((h,w))

Gh = Counter(Sh).most_common()
Gw = Counter(Sw).most_common()
mh = Gh[0][1]
mw = Gw[0][1]
Lh = len(Gh)
Lw = len(Gw)
i = j = 0
while i < Lh and Gh[i][1] == mh:
    j = 0
    while j < Lw and Gw[j][1] == mw:
        if not (Gh[i][0],Gw[j][0]) in Shw:
            ans = mh + mw
            break
        j += 1
    else:
        i += 1
        continue
    break
else:
    ans = mh + mw - 1

print(ans)


Measured memory_bytes: 254864
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
struct Res{
    int time;
    int place;
    int judge;
};
Res info[400000];
int comp(Res G,Res H){
    if(G.time<H.time) return 1;
    if(G.time>H.time) return 0;
    if(G.place<H.place) return 1;
    if(G.place>H.place) return 0;
    return G.judge<H.judge;
}
int main(){
    int n,q,s[200000],t[200000],x[200000],d[200000],j=0,inf=1e9+7;
    cin>>n>>q;
    rep(i,n){
        cin>>s[i]>>t[i]>>x[i];
        info[2*i].time=s[i]-x[i],info[2*i].place=x[i],info[2*i].judge=1;
        info[2*i+1].time=t[i]-x[i],info[2*i+1].place=x[i],info[2*i+1].judge=-1;
    }
    sort(info,info+2*n,comp);
    rep(i,q) cin>>d[i];
    set<int> A;
    rep(i,q){
        while(d[i]>=info[j].time&&j<2*n){
            if(info[j].judge==1) A.insert(info[j].place);
            else A.erase(info[j].place);
            j++;
        }
        if(A.empty()) cout<<-1<<endl;
        else cout<<*A.begin()<<endl;
    }
}

Measured memory_bytes: 18432
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<utility>
#include<set>
#include<bitset>
#include<vector>
#include<functional>
#include<deque>
#include<cctype>
#include<climits>
#include<complex>
#include<bits/stdc++.h>
#include<ctime>

using namespace std;

typedef long long LL;
typedef double DB;
typedef pair<int,int> PII;
typedef pair<DB,DB> PDD;
typedef complex<DB> CP;
typedef vector<int> VI;

#define mmst(a,v) memset(a,v,sizeof(a))
#define mmcy(a,b) memcpy(a,b,sizeof(a))
#define fill(a,l,r,v) fill(a+l,a+r+1,v)
#define re(i,a,b)  for(i=(a);i<=(b);i++)
#define red(i,a,b) for(i=(a);i>=(b);i--)
#define fi first
#define se second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define two(k) (1<<(k))
#define SZ(x) (int(x.size()))
#define all(x) (x).begin(),(x).end()
#define ire(i,v,x) for(i=0,v=i<SZ(x)?x[i]:0;i<SZ(x);v=x[++i])
#define ls (rt<<1)
#define rs (rt<<1|1)
#define MID ((l+r)>>1)

template<class T>inline T sqr(T x){return x*x;}
template<class T>inline void upmin(T &t,T tmp){if(t>tmp)t=tmp;}
template<class T>inline void upmax(T &t,T tmp){if(t<tmp)t=tmp;}

inline int sgn(DB x){if(fabs(x)<1e-9)return 0;return(x>0)?1:-1;}
const DB Pi=acos(-1.0);

int gint()
  {
		int res=0;bool neg=0;char z;
		for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
		if(z==EOF)return 0;
		if(z=='-'){neg=1;z=getchar();}
		for(;z!=EOF && isdigit(z);res=(res<<3)+(res<<1)+z-'0',z=getchar());
		return (neg)?-res:res;
	}
LL gll()
  {
  	LL res=0;bool neg=0;char z;
		for(z=getchar();z!=EOF && z!='-' && !isdigit(z);z=getchar());
		if(z==EOF)return 0;
		if(z=='-'){neg=1;z=getchar();}
		for(;z!=EOF && isdigit(z);res=res*10+z-'0',z=getchar());
		return (neg)?-res:res;
	}
int gdb()
  {
  	string s;
  	cin>>s;
  	size_t p=s.find('.');
  	if(p==string::npos)
  	  s+="000";
  	else
  	  {
  	  	int d=s.length()-p-1;
  	  	s=s.substr(0,p)+s.substr(p+1);
  	  	while(d<3)s+="0",d++;
  	  }
  	istringstream is(s);
  	int res=0;
  	is>>res;
  	return res;
  }

const int maxn=110000;

int n;
int a[maxn];
int m;
PII b[3];

int main()
  {
  	/*freopen("C.in","r",stdin);
  	freopen("C.out","w",stdout);*/
  	int i;
  	n=gint();
  	re(i,1,n)a[i]=gint();
  	sort(a+1,a+n+1);
  	red(i,n,2)if(a[i]==a[i-1])
  	  {
  	  	int j=i;
  	  	while(i-1>=1 && a[i]==a[i-1])i--;
  	  	b[++m]=mp(a[i],j-i+1);
  	  	if(m==2)break;
  	  }
  	LL ans=0;
  	if(m==2)upmax(ans,1LL*b[1].fi*b[2].fi);
  	re(i,1,m)if(b[i].se>=4)upmax(ans,1LL*b[i].fi*b[i].fi);
  	cout<<ans<<endl;
  	return 0;
  }
  	

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
const int N = 3e5 + 9;
 
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n; int tot = 0;
	vector<array<int, 3>> pos, neg;
	for (int i = 1; i <= n; i++) {
		string s; cin >> s;
		int mn = 0, cur = 0;
		for (auto x: s) {
			if (x == '(') cur++;
			else cur--;
			mn = min(mn, cur);
		}
		if (cur >= 0) pos.push_back({-mn, -cur, i});
		else neg.push_back({mn - cur, -cur, i});
		tot += cur;
	}
	if (tot != 0) return cout << "No\n", 0;
	sort(pos.begin(), pos.end());
	int cur = 0; vector<int> ans;
	for (auto x: pos) {
		if (x[0] > cur) return cout << "No\n", 0; 
		cur -= x[1];
		ans.push_back(x[2]);
	}
	sort(neg.begin(), neg.end());
	for (auto x: neg) {
		if (x[1] - x[0] > cur) return cout << "No\n", 0;
		cur -= x[1];
		ans.push_back(x[2]);
	}
	cout << "Yes\n";
    return 0;
}

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

using namespace std;

typedef pair<int, int> P;

vector<int> G[50];
bool used[50];

void dfs(int v, P p){
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        if(!used[G[v][i]]){
            if(v == p.first && G[v][i] == p.second) continue;
            if(v == p.second && G[v][i] == p.first) continue;
            dfs(G[v][i], p);
        }
    }
}

void clear(){
    for(int i = 0; i < 50; i++) used[i] = false;
}

int main(){
    int N, M;
    int ans = 0;
    cin >> N >> M;
    vector<P> es;
    for(int i = 0; i < M; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
        es.push_back(P(a, b));
    }
    for(int i = 0; i < M; i++){
        clear();
        dfs(0, es[i]);
        for(int j = 0; j < N; j++){
            if(!used[j]){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

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

int main(void){
    string S;
    cin>>S;
    
    int N=S.length();
    int i;
    int num;
    long long count=0;
    
    for(i=N-1;i>=0;i--){
        if(S.at(i)=='B'){
            count+=N-i-1;
            N--;
        }
        
    }
    
    cout<<count<<endl;
    
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,m;
    cin>>a>>b>>m;
    int amin=100000;
    int bmin=100000;
    vector<int>aa(a);
    vector<int>bb(b);
    for(int i=0;i<a;i++)
    {
        cin>>aa[i];
        if(aa[i]<amin)
            amin=aa[i];
    }
    for(int i=0;i<b;i++)
    {
        cin>>bb[i];
        if(bb[i]<bmin)
            bmin=bb[i];
    }
    int ANS=amin+bmin;
    int X[100000],Y[100000],C[100000];
    for(int i=0;i<m;i++)
    {
        cin>>X[i]>>Y[i]>>C[i];
        if((aa[X[i]-1]+bb[Y[i]-1]-C[i])<ANS)
        {
            ANS=aa[X[i]-1]+bb[Y[i]-1]-C[i];
        }
    }
    cout<<ANS;
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
 
int main(){
    string q,e;
    cin >> q >> e ;
    for(int i=0;i<q.length();i++){
        cout << q[i];
        if(i<e.length()) cout << e[i];
    }
    cout << "\n" ;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e5 + 5;
const ll mo = 1e10 +7;
const int M = 100+50;
int main (){
	ll a,b,c;
	scanf("%lld %lld %lld",&a,&b,&c);
	if(a+b>=c)
	    printf("%lld\n",b+c);
//	else if(a+b*2<c)
//		printf("%lld\n",a+b*2+1);
	else
	    printf("%lld\n",a+b*2+1);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[2*n];
    for(int i=0;i<2*n;i++){
        cin>>a[i];
    }
    sort(a,a+2*n);
    int sum=0;
    for(int i=0;i<2*n;i+=2){
        sum+=a[i];
    }
    cout<<sum;
}

Measured memory_bytes: 3636
n,q = map(int,input().split())
s = input()
ac = [0] * (n+1)
num = 0

for i in range(n):
    if i != 0:
        if s[i-1:i+1] == "AC":
            num += 1
            
    ac[i+1] = num
    
for i in range(q):
    l,r = map(int,input().split())
    print(ac[r]-ac[l])

Measured memory_bytes: 6140
<?php
    fscanf(STDIN, "%d", $S);
    $h = (int)( ($S / 3600) );
    $m = (int)( ($S % 3600) / 60 );
    $s = (int)($S % 60);

    echo $h.":";
    echo $m.":";
    echo $s."\n";
?>


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

template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  using P = function<E(E,size_t)>;
  Int n;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  P p;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(Int n_,F f,G g,H h,T ti,E ei,
	      P p=[](E a,size_t b){b++;return a;}):
    f(f),g(g),h(h),ti(ti),ei(ei),p(p){
    init(n_);
  }
  void init(Int n_){
    n=1;
    while(n<n_) n*=2;
    dat.assign(2*n-1,ti);
    laz.assign(2*n-1,ei);
  }
  void build(Int n_, vector<T> v){
    for(Int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(Int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  inline void eval(Int len,Int k){
    if(laz[k]==ei) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1],laz[k]);
      laz[k*2+2]=h(laz[k*2+2],laz[k]);
    }
    dat[k]=g(dat[k],p(laz[k],len));
    laz[k]=ei;
  }
  T update(Int a,Int b,E x,Int k,Int l,Int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k]=h(laz[k],x);
      return g(dat[k],p(laz[k],r-l));
    }
    return dat[k]=f(update(a,b,x,k*2+1,l,(l+r)/2),
		    update(a,b,x,k*2+2,(l+r)/2,r));
  }
  T update(Int a,Int b,E x){
    return update(a,b,x,0,0,n);
  }
  T query(Int a,Int b,Int k,Int l,Int r){
    eval(r-l,k);
    if(r<=a||b<=l) return ti;
    if(a<=l&&r<=b) return dat[k];
    T vl=query(a,b,k*2+1,l,(l+r)/2);
    T vr=query(a,b,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  T query(Int a,Int b){
    return query(a,b,0,0,n);
  }
  void update(Int k,T x){
    query(k,k+1);//evaluate
    k+=n-1;
    dat[k]=x;
    while(k){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,q;
  cin>>n>>q;
  vector<vector<Int> > G(n);
  for(Int i=1;i<n;i++){
    Int p;
    cin>>p;
    G[p-1].emplace_back(i);
  }
  vector<char> c(n);
  for(Int i=0;i<n;i++) cin>>c[i];

  Int pos=0;
  vector<Int> r(n);
  vector<Int> ds(n),dt(n);
  function<void(Int)> dfs=[&](Int v){
    ds[v]=pos;
    for(Int u:G[v]) dfs(u);
    dt[v]=++pos;
  };
  dfs(0);
  //for(Int i=0;i<n;i++) cout<<i<<":"<<ds[i]<<" "<<dt[i]<<endl;

  vector<Int> v(n);
  for(Int i=0;i<n;i++) v[dt[i]-1]=c[i]=='G';
  SegmentTree<Int, Int>::F f=[](Int a,Int b){return a+b;};
  SegmentTree<Int, Int>::G g=[](Int a,Int b){return b?b-a:a;};
  SegmentTree<Int, Int>::H h=[](Int a,Int b){return a^b;};
  SegmentTree<Int, Int>::P p=[](Int a,Int b){return a*b;};

  SegmentTree<Int, Int> seg(n,f,g,h,0,0,p);
  seg.build(n,v);

  for(Int i=0;i<q;i++){
    Int x;
    cin>>x;
    x--;
    seg.update(ds[x],dt[x],1);
    Int y=seg.query(0,n);
    //cout<<y<<endl;
    cout<<(y*2>n?"broccoli":"cauliflower")<<endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 22716
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int i = (s); i < (e); i++)
#define FOE(i,s,e) for(int i = (s); i <= (e); i++)
#define FOD(i,s,e) for(int i = (s); i >= (e); i--)
#define ll long long
#define pb push_back
#define mp make_pair

int n, m, x, y, z, k, w, t;
bitset<4000005> s;
int A[2005];

int main ()
{
	scanf("%d", &n);
	FOR(i, 0, n) scanf("%d", &A[i]), x += A[i];
	
	y = x;
	s &= 0;
	s[0] = 1;
	
	FOR(i, 0, n) s = s = (s | (s << A[i]));
	
	if (x % 2 == 0) x /= 2;
	else x = x / 2 + 1;
	
	FOE(i, x, y) if (s[i] == 1) { printf("%d\n", i); return 0; }
	return 0;
}

Measured memory_bytes: 2304
// https://atcoder.jp/contests/dp/tasks/
#include <bits/stdc++.h>

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

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    // speedup cin
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<double> p(n + 1);
    vector<vector<double>> dp(n + 1, vector<double>(n + 1));

    rep(i, n) { cin >> p[i + 1]; }

    dp[0][0] = 1.0L;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0) {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]);
            } else if (j == i) {
                dp[i][j] = dp[i - 1][j - 1] * p[i];
            } else {
                dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
            }
        }
    }

    double ans = 0.0L;
    int start = (n % 2) == 0 ? n / 2 : n / 2 + 1;

    for (int j = start; j <= n; j++) {
        // printf("j=%d, dp=%f\n", j, dp[n][j]);
        ans += dp[n][j];
    }

    printf("%0.10f\n", ans);
    return 0;
}


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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
int N,A[101010],ans,Al[101010],Ar[101010];
int i,j;
int gcd(int a,int b){
    if(b==0)
        return a;
    return gcd(b, a % b);
}
int main(){
    scanf("%d", &N);
    fornum(i,0,N){
        scanf("%d", &A[i]);
    }
    Al[0]=A[0];
    Ar[N - 1] = A[N - 1];
    fornum(i,1,N){
        Al[i] = gcd(A[i], Al[i - 1]);
        Ar[N - 1 - i] = gcd(A[N - 1 - i], Ar[N - i]);
    }
    /*
    fornum(i,0,N){
        printf("%d ", Al[i]);
    }
    printf("\n");
    fornum(i,0,N){
        printf("%d ", Ar[i]);
    }*/
    ans = Ar[1];
    if(ans<Al[N-2])
        ans = Al[N - 2];
    fornum(i,1,N-1){
        int a = gcd(Al[i-1], Ar[i+1]);
        if(a>ans)
            ans = a;
    }
    
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func solve(in io.Reader, out, err io.Writer) {
	N, cost, retValue, retBorder := 0, 800, -200, 15
	fmt.Fscan(in, &N)

	fmt.Fprintln(out, N*cost+(N/retBorder)*retValue)
}

func main() {
	br := bufio.NewReaderSize(os.Stdin, int(1e7))
	solve(br, os.Stdout, os.Stderr)
}


Measured memory_bytes: 2944
import sys

sys.setrecursionlimit(10 ** 7)
# import bisect
# import numpy as np
# from collections import deque
from collections import deque
# map(int, sys.stdin.read().split())
import itertools
import heapq


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    res = 0
    mons = 0
    for i in range(N):
        if B[i] + res > A[i]:
            mons += A[i]
            res = min(B[i], B[i] + res - A[i])
        else:
            mons += B[i] + res
            res = 0
    ##saigo
    if res > A[N]:
        mons += A[N]
    else:
        mons += res
    print(mons)

if __name__ == "__main__":
    main()


Measured memory_bytes: 96964
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#define  rep(i,n) for(int i=0;i<(n);i++)
#define  REP(i,n) for(int i=1;i<(n);i++)
#define  rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define  VI	vector<int>
#define	 VS vector<string>
#define  all(a) (a).begin(),(a).end()
#define  debug(x) cout<<#x<<": "<<x<<endl

using namespace std;
vector<int> perse(string s,char c){
	int pre=0;
	vector<int>v;
	rep(i,s.size()){
		if(s[i]==c){
			v.push_back(atoi(s.substr(pre,i-pre).c_str()));
			pre=i+1;
		}
	}
	v.push_back(atoi(s.substr(pre,s.size()-pre).c_str()));
	return v;
	
}

int main(){
	int m[100][100];
	int sz;
	string s;
	
	rep(i,100)rep(j,100) m[i][j]=-1;
	
	for(sz=0;getline(cin,s);sz++){
		vector<int> v=perse(s,',');
		rep(i,v.size())m[sz][i]=v[i];
	}
	int dp[100][100]={m[0][0]};
	REP(i,sz){
		if(i>=sz/2){
			for(int j=0;j<i+1;j++){
				dp[i][j]=m[i][j]+max(dp[i-1][j],dp[i-1][j+1]);
			}
		}
		else{
			for(int j=0;j<sz-1;j++)
			dp[i][j]=m[i][j]+max(dp[i-1][j-1],dp[i-1][j]);
		}
	}
	
	cout<<dp[sz-1][0]<<endl;

}

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

const ll N = 2e6 + 7;

ll n , m , cnt , a;
vector<int>g[N];
ll used[N] , p[N];
string s;
int main(){
    cin >> n >> m;
    for( int i = 0; i < m;i ++ ){
            ll x , y;
        cin >> x >> y;
    g[x].pb(y);
    g[y].pb(x);
    }
    queue<int>q;
    q.push(1);
    p[1] = 1;
    used[1] = 1;
    while( !q.empty() ){
        int v = q.front();
        q.pop();
        for( int i = 0;i < g[v].size();i ++ ){
            int to = g[v][i];
            if( !used[to] ){
                used[to] ++;
                q.push(to);
                p[to] = (v);
            }
        }
    }
    for( int i = 2;i <= n;i ++ ){
        if( !used[i] )
            return cout << "No" , 0;
    }
    cout << "Yes" << endl;
    for( int i = 2;i <= n;i ++ ){
        cout << p[i] << "\n";
    }
}



Measured memory_bytes: 56148
#include<bits/stdc++.h>
using namespace std;
int main()
{
    double mod, n;
    cin>>n;
     double no;
    for(int i=1;i<=n;i++)
    {
        cin>>no;
        mod=mod+1/no;
    }
    mod=1/mod;
    printf("%0.14lf\n",mod);
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  int n;cin>>n;
  vector<ll> v(n);
  rep(i,0,n){
      cin>>v[i];
  }

  ll ans=1;
  vector<ll> u(3,0);
  rep(i,0,n){
      ll x=0;
      rep(j,0,3){
          if(v[i]==u[j])x++;
      }
      ans*=x;
      ans%=mod;
      rep(j,0,3){
          if(v[i]==u[j]){
              u[j]++;
                break;
          }
      }
  }
  cout<<ans<<endl;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 1024