akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EDoubleFactorial solver = new EDoubleFactorial();
        solver.solve(1, in, out);
        out.close();
    }

    static class EDoubleFactorial {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long N = in.nextLong();
            if ((N & 1) == 1) {
                out.println(0);
            } else {
                long x = N / 2;
                long p5 = 0;
                while (x > 0) {
                    p5 += (x / 5);
                    x /= 5;
                }
                out.println(p5);
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public long nextLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32632
#include <iostream>
#include <algorithm>
#include<functional>
#include<stdio.h>
#include<stdlib.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
int main() {
	int x, a, b,c;
	cin >> x >> a >> b;
	c = x - a;
	c = c % b;
	cout << c;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#define ll long long
#define pb push_back
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e6+500;
const ll inf=1e18+800;
const ll mod=1e9+7;

ll a[maxn];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n,x,sum=0;
	cin>>n>>x;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+n);
	if(sum==x){
		cout<<n<<endl;
		return 0;
	}
	for(ll i=0;i<n;i++){
		if(x>=a[i]){
			x-=a[i];
		}
		else{
			cout<<i;
			return 0;
		}
	}
	cout<<n-1;


}

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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (int)(1000000007)
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 9999999999999999
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 3005
#define mxnn 2000005
double dp[mxn][mxn];
double arr[mxn];
int32_t main(){
int n;
cin>>n;
for(int i = 1;i<=n;i++) cin >>arr[i];
dp[0][0] = 1.00000000000;
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.000000000-arr[i]);
        dp[i][j] = dp[i-1][j]*(1.000000000000-arr[i]) + dp[i-1][j-1]*(arr[i]);
    }
}
double ans = 0.0000000000;
for(int i = n/2+1;i<=n;i++) ans += dp[n][i];
printf("%.10f",ans);
return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define _CRT_SECURE_NO_WARNINGS
#define ll long long
#define BUF 1e5
#define INF 1<<30
using namespace std;
ll MOD = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

struct UnionFind {
	vector<int> rank, parent, num;
	UnionFind() {};
	UnionFind(int size) :rank(size, 0), parent(size, 0), num(size, 0) {
		for (int i = 0; i < size; i++)makeset(i);
	}

	void makeset(int x) {
		parent[x] = x;
		rank[x] = x;
		num[x] = 1;
	}

	int size(int x) {
		return num[findset(x)];
	}

	bool same(int x, int y) {
		return findset(x) == findset(y);
	}

	int findset(int x) {
		if (x != parent[x]) {
			parent[x] = findset(parent[x]);
		}
		return parent[x];
	}

	void unite(int x, int y) {
		link(findset(x), findset(y));
	}

	void link(int x, int y) {
		if (rank[x] > rank[y]) {
			parent[y] = x;
			num[x] += num[y];
		}
		else {
			parent[x] = y;
			num[y] += num[x];
			if (rank[x] == rank[y])rank[y]++;
		}
	}
};

int main() {
	cin >> N >> M;
	vector<int>X(M), Y(M), Z(M);
	for (int i = 0; i < M; i++) {
		cin >> X[i] >> Y[i] >> Z[i];
		X[i]--, Y[i]--;
	}
	UnionFind uf(N);
	for (int i = 0; i < M; i++) {
		uf.unite(X[i], Y[i]);
	}
	set<int> set;
	for (int i = 0; i < N; i++) {
		set.insert(uf.findset(i));
	}
	cout << set.size() << endl;
}


Measured memory_bytes: 7296
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y

cnt=0
ans=0
LCM=1
for i in range(n):
    Q=lcm(LCM,A[i])
    cnt*=Q//LCM
    LCM=Q
    cnt+=Q//A[i]
print(cnt%mod)

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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

long long int comb(long long int a,long long int b){
	long long int n=1;
	for(int i=0; i<b; i++)	n*=(a-i);
	for(int i=1; i<=b; i++)	n/=i;
	
	return n;
}

int main(){
	int n;
	long long int cnt=0,ans=0;
	vector<int> tmp(35);
	bool eq=false;
	
	cin >> n;
	
	vector<string> s(n);
	vector<vector<int>> alphabet(n,vector<int>(35,0));
	
	for(int i=0; i<n; i++)	cin >> s[i];
	
	for(int i=0; i<n; i++){
		for(int j=0; j<10; j++){
			alphabet.at(i).at(s[i].at(j)-97)++;
		}
	}
	
	sort(all(alphabet));
	
	tmp=alphabet.at(0);
	cnt=1;
	for(int i=1; i<n; i++){
		if(tmp!=alphabet.at(i)){
			if(cnt>=2){
				ans+=comb(cnt,2);
			}
			tmp=alphabet.at(i);
			cnt=1;
		}else{
			cnt++;
		}
	}
	if(cnt>=2){
		ans+=comb(cnt,2);
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 200010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

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

int n, l;

signed main() {
	n = read();
	cout << n + n * n + n * n * n;
}

Measured memory_bytes: 3588
import os
from functools import lru_cache

import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M = list(map(int, sys.stdin.readline().split()))
C = list(map(int, sys.stdin.readline().split()))


@lru_cache(maxsize=None)
def solve(n):
    if n == 0:
        return 0
    if n < 0:
        return IINF
    ret = IINF
    for c in C:
        ret = min(ret, solve(n - c) + 1)
    return ret


print(solve(N))



Measured memory_bytes: 94852
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
 
#define N 1000003
 
int getChar(char);
int getKey(char*);
int Insert(char*);
int Find(char*);
 
int H1(int key){return key%N;}
int H2(int key){return 1+(key%(N-1));}
int H0(int key,int i){return (H1(key)+i*H2(key))%N;}
 
char dic[N][14];
 
int main(void){
  int n,i;
  char order[9],str[14];
 
  for(i=0;i<N;i++) dic[i][0]='\0';
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s%s", order, str);
 
    if(order[0]=='i') Insert(str);
    else{
      if(Find(str)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}
 
int getChar(char c){
  if(c=='A') return 1;
  else if(c=='C') return 2;
  else if(c=='G') return 3;
  else if(c=='T') return 4;
}
 
int getKey(char str[]){
  int sum=0,p=1,i;
 
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
 
  return sum;
}
 
int Insert(char str[]){
  int key,i,j;
 
  key=getKey(str);
  i=0;
 
  while(i<N){
    j=H0(key,i);
 
    if(dic[j][0]=='\0'){
      strcpy(dic[j],str);
      return j;
    }else{
      i++;
    }
  }
}
 
int Find(char str[]){
  int i,j,key;
 
  key=getKey(str);
 
  i=0;
  while(1){
    j=(H1(key)+i*H2(key))%N;
    if(dic[j][0]=='\0' || i==N) return 0;
    if(strcmp(dic[j],str)==0) return 1;
    else i++;
  }
}

Measured memory_bytes: 14280
a,b,c=map(int,input().split())
if a==b==c and a%2==0 and b%2==0 and c%2==0:
    print(-1)
else:
    ans=0
    while a%2==0 and b%2==0 and c%2==0:
        A=a
        B=b
        C=c
        a=B//2+C//2
        b=A//2+C//2
        c=B//2+A//2
        ans+=1
        if a==b==c:
            ans=-1
            break
    print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

void make(int a[],int n){
	int mx=-1;
	for(int i=0;i<n;i++){mx=max(mx,a[i]);a[i]=mx;}
}

int find(int a[],int n){
	int mx=-1;
	for(int i=0;i<n;i++){
		mx=max(a[i],mx);
	}
	return(mx);
}

int32_t main(){
    IOS;
    int n,t;
    cin>>n>>t;
    pair<int,int> p[n];
    for(int i=0;i<n;i++){
    	int x,y;
    	cin>>x>>y;
    	p[i]={x,y};
    }
    sort(p,p+n);
    int dp[t+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<n;i++){
    	for(int j=t-1;j>=0;j--){
    		int x=p[i].ff;
    		int y=p[i].ss;
    		if(j+x>=t) dp[t]=max(dp[t],dp[j]+y);
    		else{
    			dp[j+x]=max(dp[j+x],dp[j]+y);
    		}
    	}	
    	make(dp,t+1);
    }
    cout<<find(dp,t+1);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    string n;
    int i;

    cin >> n ;

    for (i = 0; i < 3; i++){
        if(n[i] == '1')
            n[i] = '9';
        else
            n[i] = '1';
        }

    cout << n << endl;
 }


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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0;

	int i,j,k,c=0;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	cin>>s1;


	f(i,0,s1.length()-1){
        if(s1[i]!='-') c++;
        else {
            k=i;
            break;
        }
	}

	f(i,k+1,s1.length()-1){
        if(s1[i]!='-') count++;
        else break;
	}
	if(c==n && count==m) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int n,m,x;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m>>x;

    vi c(n);
    vector<vi> a(n, vi(m));
    REP(i,n){
        cin>>c[i];
        REP(j,m) cin>>a[i][j];
    }

    ll ans = LONG_MAX;
    for(int i=0; i<(1<<n); i++){
        ll tmpsum = 0;
        vi v(m,0);
        REP(j,n){
            if(i & (1<<j)){
                tmpsum += c[j];
                REP(k,m){
                    v[k] += a[j][k];
                }
            }
        }

        bool isok = true;
        REP(j,m){
            if(v[j] < x){
                isok = false;
                break;
            }
        }
        //DEBUG(tmpsum);
        if(isok) ans = min(ans,tmpsum);

        //DEBUG2(i,ans);
    }
    if(ans==LONG_MAX) ans = -1;//目標未達成
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
from collections import defaultdict

N = int(input())
balls = input()
balls = balls.split()
balls = list(map(int, balls))

count = defaultdict(int)
for i in balls:
  count[i] += 1

def cmb(M):
  return M*(M-1)//2

sum = 0
for i in count:
   sum += cmb(count[i])
#sum = defaultdict(int)
#for i in count:
#  for j in count:
#    if i==j:
#      sum[i] += cmb(count[j]-1)
#    else:
#      sum[i] += cmb(count[j])
#      
for i in balls:
  print(sum - (count[i]-1))

  
    

Measured memory_bytes: 88140
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

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

    int n;
    cin >> n;
    vector res(10, vector(10, 0));
    FOR(x, 1, 9)
    {
        FOR(y, 1, 9)
        {
            FOR(s, 0, 9999)
            {
                if (100'000 * x + 10 * s + y <= n)
                {
                    ++res[x][y];
                }
            }
            FOR(s, 0, 999)
            {
                if (10'000 * x + 10 * s + y <= n)
                {
                    ++res[x][y];
                }
            }
            FOR(s, 0, 99)
            {
                if (1000 * x + 10 * s + y <= n)
                {
                    ++res[x][y];
                }
            }
            FOR(s, 0, 9)
            {
                if (100 * x + 10 * s + y <= n)
                {
                    ++res[x][y];
                }
            }
            if (10 * x + y <= n)
            {
                ++res[x][y];
            }
            if (x == y and x <= n)
            {
                ++res[x][y];
            }
        }
    }

    i64 ans = 0;
    FOR(x, 1, 9)
    {
        FOR(y, 1, 9)
        {
            ans += res[x][y] * res[y][x];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<stack>
#include<iostream>
#include<cstdio>
#include<string>

using namespace std;

int main(){
    stack<char> st;
    string S;
    int N;
    cin >> N;
    cin >> S;
    int open = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == '('){
            st.push('(');
        }else{
            if(!st.empty()){
                st.pop();
            }else{
                open++;
            }
        }
    }
    for(int i = 0; i < open; i++){
        cout << '(';
    }
    cout << S;
    for(int i = 0; i < st.size(); i++){
        cout << ')';
    }
    cout << endl;
}

        
    

Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int h = sc.nextInt();
        int w = sc.nextInt();
        
        out.println(n*m-h*m-w*n+h*w);
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(l,r)     ((l)+((r)-(l))/2) 

#define fo(i,a,b)    for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    int i=0;
    string s;rd(s);
    int ans = 0 ; 
    while(i<3){
        if(s[i]=='S'){
            i++;continue;
        }
        int j = i;
        while(j+1<3 and s[j+1]=='R')j++;
        ans = max(ans, j-i+1);
        i = j + 1;
    }   
    cout<<ans<<endl;
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
bool sortbysec(const tuple<int, int, int> &a,
               const tuple<int, int, int> &b)
{
    return (get<1>(a) < get<1>(b));
}

int main()
{
    ll n, m, T;
    cin >> n >> m >> T;
    ll a[n];
    ll b[m];
    cn(a, n);
    cn(b, m);
    ll ans = 0;
    ll sum_a = 0;
    for (ll i = 0; i < n; i++)
        sum_a += a[i];
    ll j = 0;
    ll sum_b = 0;
    for (ll i = n; i >= 0; i--)
    {
        if (i < n)
            sum_a -= a[i];
        if (sum_a <= T)
        {
            while (j < m and (sum_a + sum_b + b[j]) <= T)
            {
                sum_b += b[j];
                j++;
            }
            ans = max(ans, i + j);
        }
    }
    cout << ans;
}

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
    //freopen("test.in", "r+", stdin);
    cin >> s;
    int n = s.size();
    int w1 = 0, b1 = 0, w2 = 0, b2 = 0;
    for(int i = 0; i < n; i+=2){
        if(s[i] == '1')w1++;
        else b1++;
    }
    for(int i = 1; i < n; i+=2){
        if(s[i] == '1')w2++;
        else b2++;
    }
    cout << min(n - b1 - w2, n - w1 - b2) << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int n;
  cin >> n;
  int r = 0, sr = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if(a == 1) r++, sr = max(sr, r);
    else r = 0;
  }
  cout << sr + 1 << endl;
}



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

using namespace std;

const int N = 3005;

int f[N][N];

int main() {
  string a, b;
  cin >> a >> b;
  int n = a.size();
  int m = b.size();
  for (int i = 1; i <= n; i++) {
  	for (int j = 1; j <= m; j++) {
  		f[i][j] = max(f[i - 1][j], f[i][j - 1]);
  		f[i][j] = max(f[i][j], (a[i - 1] == b[j - 1]) + f[i - 1][j - 1]);
  	}
  }
  int i = n;
  int j = m;
  string ans = "";
  while (i > 0 && j > 0) {
		if (f[i][j] == f[i - 1][j]) {
			i--;
		} else if (f[i][j] == f[i][j - 1]) {
		  j--;
		} else {
			if (a[i - 1] == b[j - 1]) ans += a[i - 1];
			i--;
			j--;
		}
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
	return 0;
}

Measured memory_bytes: 35456
import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)

    val line = argList.nextLine().split(" ")
    val a = line[0].toInt()
    val b = line[1].toInt()

    val e = PlusMinusX()
    println(e.execute(a, b))

}

class PlusMinusX {
    fun execute(a: Int, b: Int): Int? {
        val plus = a + b
        val minux = a - b
        val multiple = a * b

        return listOf(plus, minux, multiple).max()
    }
}

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

main() {
	int S;	cin>>S;
	int p = 1000000000;
	if(S % p == 0) {
		cout<<"0 0 0 1000000000 "<<S/p<<" 0";
	}
	else {
		int x3 = S / p + 1;
		int y3 = S % p;
		cout<<"0 1000000000 1 0 "<<x3<<" "<<y3;
	}
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef unsigned long ul;
const ul INF = 1LL<<60;
ul N,i,j,x,y,cnt;
vector<pair<ul,ul> > P,Q;
bool used_p[200][200];
inline void solve(){
  IN(N);
  REP(i,N){
    cin>>x>>y;
    P.push_back(make_pair(y,x));
  }
  REP(i,N){
    cin>>x>>y;
    Q.push_back(make_pair(x,y));
  }
  sort(RALL(P));sort(ALL(Q));
  REP(i,N){
    REP(j,N){
      if(used_p[P[j].first][P[j].second])continue;
      if(P[j].second<Q[i].first&&P[j].first<Q[i].second){
        used_p[P[j].first][P[j].second]=true;
        cnt++;
        break;
      }
    }
  }
  OUT(cnt);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	string s; cin >> s;

	if (s.size() == 2) {
		if (s[0] == s[1]) {
			cout << 1 << " " << 2 << endl;
			return 0;
		}
	}

	for (int i = 0; i < s.length()-2; i++) {
		if (s[i] == s[i + 1] ) {
			cout << i+1<<" "<<i+2 << endl;
			return 0;
		}

		if (s[i] == s[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}

	cout << "-1" << " " << "-1" << endl;

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  string ans = "Yes";
  if(s.at(0) == s.at(1) && s.at(1) == s.at(2)) ans = "No";
  cout << ans << endl;
  
}

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

using namespace std;

int main(void) {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  if(a + b < 2 * c) {
    cout << (long long)a * x + b * y << endl;
    return 0;
  }
  else {
    long long ans = 0;
    if(x < y) {
      ans += c * 2 * x;
      ans += (y - x) * min(b, 2 * c);
    }
    else {
      ans += c * 2 * y;
      ans += (x - y) * min(a, 2 * c);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import sys

INF = float('inf')

n, ma, mb = map(int, sys.stdin.readline().split())
a, b, c = [], [], []
for _ in range(n):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    a.append(ai); b.append(bi); c.append(ci)

def main():
    sa = sum(a)
    sb = sum(b)
    res = [[[INF] * (sb + 1) for _ in range(sa + 1)] for _ in range(n + 1)]
    res[0][0][0] = 0
    for i in range(n):
        for j in range(sa + 1):
            for k in range(sb + 1):
                if j >= a[i] and k >= b[i]:
                    res[i+1][j][k] = min(res[i][j-a[i]][k-b[i]] + c[i], res[i][j][k])
                else:
                    res[i+1][j][k] = res[i][j][k]
    ans = INF
    for i in range(1, min(sa//ma, sb//mb)+1):
        ans = min(ans, res[n][ma * i][mb * i])
    
    if ans == INF:
        return -1
    else:
        return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 71132
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;


int main() {

	int N;
	cin >> N;

	ll ans = 0;

	rep(i, N) {

		if (i % 3 == 0 || i % 5 == 0) {

		}
		else {
			
			ans += i;
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
def resolve():
    N = int(input())
    D, X = map(int, input().split())
    A = [int(input()) for _ in range(N)]
    ans = 0
    for i in range(N):
        count = 1
        while count <= D:
            count += A[i]
            ans += 1
    print(ans+X)
resolve()

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define INF (((long long)1<<62))
#define ll long long

struct edge { int from, to, cost; };
edge es[2010];
ll d[1010];
int V, E;
void Bellman_Ford(int S)
{
	
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < E; j++) {
			edge e = es[j];
			if (d[e.from] != -INF && d[e.to] < d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
			}
		}
	}
}

int main()
{
	cin >> V >> E;
	for (int i = 0; i < E; i++) {
		cin >> es[i].from >> es[i].to >> es[i].cost;
		es[i].from--;
		es[i].to--;
	}
	ll ans1, ans2;
	for (int i = 0; i < V; i++) d[i] = -INF;
	d[0] = 0;
	Bellman_Ford(0);
	ans1 = d[V - 1];
	Bellman_Ford(0);
	if (ans1 != d[V - 1]) {
		cout << "inf" << endl;
	}
	else {
		cout << d[V - 1] << endl;
	}
}


Measured memory_bytes: 256
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";n.r(t);var r=n(0);!function(e){e.split("\n")[0];var t=e.split("\n")[1].match(/ABC/g);t?console.log(t.length):console.log(0)}(r.readFileSync("/dev/stdin","utf8").trim())}]);

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

  int main() {

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

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

    int sum = 0;
    vector<int> a(n);

    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      sum += a[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    bool good = 1;

    sum = (sum + 4 * m - 1) / (4 * m);
    for (int i = 0; i < m; ++i) {
      if (a[i] < sum) good = 0;
    }

    if (good) cout << "Yes\n";
    else cout << "No\n";
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int n;
    cin>>n;
    vector<int64_t> a(3*n);
    rep(i,3*n){
        cin>>a[i];
    }
    int64_t sum=0;
    all(a);
    rep(i,n){
        sum += a[3*n-2-2*i];
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
int n,k,ans,lg[200005];
int a[20][200005];
int b[20][200005];
int Qmn(int l,int r){
	int k=lg[r-l+1];
	return min(a[k][l],a[k][r-(1<<k)+1]);
}
int Qmx(int l,int r){
	int k=lg[r-l+1];
	return max(b[k][l],b[k][r-(1<<k)+1]);
}
int main(){
	scanf("%d%d",&n,&k);
	For(i,1,n) scanf("%d",&a[0][i]),b[0][i]=a[0][i];
	For(i,2,n) lg[i]=lg[i/2]+1;
	For(i,1,18) For(j,1,n-(1<<i)+1){
		a[i][j]=min(a[i-1][j],a[i-1][j+(1<<(i-1))]);
		b[i][j]=max(b[i-1][j],b[i-1][j+(1<<(i-1))]);
	}
	int ans=n-k+1;
	int pre=1;
	For(i,1,n-k){
		//printf("%d\n",Qmx(i+1,i+k-1));
		//printf("%d\n",Qmn(i+1,i+k-1));
		if (Qmx(i+1,i+k-1)<a[0][i+k])
			if (Qmn(i+1,i+k-1)>a[0][i])
				ans--;//printf("%d\n",i);
	}
	int S=0;
	For(i,2,n+1)
		if (a[0][i]<a[0][i-1]||i==n+1){
			//printf("%d %d\n",i,pre);
			if (i-pre>=k) ++S;
			pre=i;
		}
	ans-=max(S-1,0);
	printf("%d\n",ans);
}
/*
10 4
2 0 1 3 7 5 4 6 8 9


0 1 2 3 7 5 4 6 8 9
2 0 1 3 7 5 4 6 8 9
2 0 1 3 5 7 4 6 8 9
2 0 1 3 4 5 7 6 8 9
2 0 1 3 4 5 6 7 8 9
2 0 1 3 7 4 5 6 8 9
2 0 1 3 7 5 4 6 8 9
*/

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
    bool ret = true;
    if (x < 2) {
        ret = false;
    }
    for (LL i = 2; i <= sqrt(x); i++) {
        if (x%i == 0) {
            ret = false;
        }
    }
    return ret;
}

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

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

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

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

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

//main code
int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    int count_odd = 0;
    int count_2 = 0;
    int count_4 = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a % 2 == 1) {
            count_odd++;
        }
        else if (a % 4 == 0) {
            count_4++;
        }
        else {
            count_2 = 1;
        }
    }

    if (count_odd + count_2 <= count_4  + 1) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
const MOD: usize = 1000000007;

fn gcd(a: usize, b: usize) -> usize {
    match b {
        0 => a,
        _ => gcd(b, a % b),
    }
}

fn powmod(base: usize, exp: usize, m: usize) -> usize {
    let b: Vec<bool> = format!("{:b}", exp)
        .chars()
        .map(|x| x.to_digit(10).unwrap() != 0)
        .collect();
    let mut v = 1;
    for bi in b {
        v *= v;
        v %= m;
        if bi {
            v *= base;
            v %= m
        }
    }
    return v % m;
}

fn invmod(x: usize, m: usize) -> usize {
    powmod(x, m - 2, m)
}

fn prime_factors(x: usize) -> Vec<usize> {
    let mut res = vec![];
    let mut y = x;
    let mut p = 2;
    let upper = (y as f64).sqrt() as usize;
    while y > 1 && p <= upper {
        match y % p {
            0 => {
                res.push(p);
                y /= p;
            }
            _ => {
                p += 1;
            }
        }
    }
    if y > 1 {
        res.push(y)
    }
    return res;
}

fn get_factorials(n: usize, m: usize) -> Vec<usize> {
    let mut res = vec![0; n as usize];
    res[0] = 1;
    for i in 1..(n as usize) {
        res[i] = (res[i - 1] * (i as usize)) % m;
    }
    res
}

fn get_facinvs(n: usize, m: usize, facts: &Vec<usize>) -> Vec<usize> {
    let mut res = vec![0; n];
    res[n - 1] = invmod(facts[n - 1], m);
    for i in (0..(n - 1)).rev() {
        res[i] = (res[i + 1] * (i + 1)) % m;
    }
    res
}

fn combmod(a: usize, b: usize, m: usize, facts: &Vec<usize>, invs: &Vec<usize>) -> usize {
    if a < b {
        0
    } else {
        (((facts[a as usize] * invs[b as usize]) % m) * invs[(a - b) as usize]) % m
    }
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: ident) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (n, k): (usize, usize) = parse!(it, 2);
    let r = if k > n { 0 } else { n - k };
    let facts = get_factorials(200100, MOD);
    let invs = get_facinvs(200100, MOD, &facts);
    let mut ret = 0;
    for i in 0..std::cmp::min(k + 1, n) {
        let a = combmod(n, i, MOD, &facts, &invs);
        let b = combmod(n - 1, n - i - 1, MOD, &facts, &invs);
        ret += (a * b) % MOD;
        ret %= MOD;
    }
    println!("{}", ret % MOD);
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

struct Eda{
	int l;
	unordered_map<int, int> d;//出た色と端からの距離
};

static unordered_map<int, bool> e[200000];
static Eda ed[200000];

int main(){
	int n;
	cin>>n;
	int c[200000];
	rep(i, n){
		cin>>c[i]; c[i]--;
	}
	rep(i, n-1){
		int a, b;
		cin>>a>>b; a--; b--;
		e[a][b]=true;
		e[b][a]=true;
	}

	rep(i, n){
		ed[i].l=1;
		ed[i].d[c[i]]=1;
	}

	ll mcnt[200000]={0};

	stack<int> s;
	rep(i, n) if(e[i].size()==1) s.push(i);
	if(!s.empty()) s.pop();

	while(!s.empty()){
		int u=s.top(); s.pop();
		if(e[u].size()==0){
			rep(c, n){
				int num= ed[u].l - ed[u].d[c];
				mcnt[c] += (ll)(num+1)*num/2;
			}
			break;
		}
		if(e[u].size()>1) continue;

		int v=e[u].begin()->first;
		e[u].erase(v);
		e[v].erase(u);

		int num= ed[u].l - ed[u].d[c[v]];
		mcnt[c[v]]+= (ll)(num+1)*num/2;
		ed[u].d[c[v]] = ed[u].l;

		//merge
		ed[v].l+=ed[u].l;
		if(ed[u].d.size() > ed[v].d.size()) swap(ed[u].d, ed[v].d);
		repit(it, ed[u].d){
			ed[v].d[it->first] += it->second;
		}

		s.push(v);
	}

	ll allpat=(ll)(n+1)*n/2;
	rep(i, n) cout << (allpat-mcnt[i]) << endl;
	return 0;
}


Measured memory_bytes: 85740
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define IL inline
#define RG register
#define db double
#define pi acos(-1.0)
#define inf 0x3f3f3f3f
#define LL long long
using namespace std;
IL int gi()
{
    RG int res=0,s=1;RG char ch;
    for(ch=getchar(); (ch<'0'||ch>'9')&&ch!='-' ;ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=10*res+ch-48;
    return res*s;
}
int n,a,b;
int main()
{
   // freopen("1.in","r",stdin);
  //  freopen("1.out","w",stdout);
	n=gi(),a=gi(),b=gi();
	if(abs(b-a-1)&1) printf("Alice\n");
	else printf("Borys\n");
    //fclose(stdin);fclose(stdout);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
INF = 1000000
d = [INF] * n
for hi, hv in enumerate(h):
    d[hi] = abs(a - (t - hv * 0.006))

ans = d.index(min(d)) + 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
 
#define rep(i, n) for(int i = 0; (int)(i) < n; i++)
 
using namespace std;
 
int main() {
  int N, M, A;
  cin >> N >> M;
  int sum = 0;
  rep(i, M) {
    cin >> A;
    sum += A;
  }
  if(sum > N) cout << -1 << endl;
  else cout << N - sum << endl;
}
  

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N; cin >> N;
	string s; cin >> s;
	vector<int> cnt(26);
	REP(i, N) {
		if ( 'a' <= s[i] && s[i] <= 'z' ) {
			cnt[(int)(s[i]-'a')]++;
		}
	}
	map<int, int> m;
	REP(i, cnt.size()) {
		if (cnt[i] > 0) {
			m[cnt[i]]++;
		}
	}
	ll ans = 0;
	EACH(p, m) {
		int coe = p.first;
		int n = p.second;
		if (ans > 0) ++ans;
		if (coe == 1) {
			ans += n * 2 - 1;
		}
		else if (n == 1) {
			ans += 1 + (n * 2 - 1) + 1;
		}
		else {
			ans += 2 + 1 + (n * 2 - 1) + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3212