akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
char c[10][10];
int main(void){
    c[1][0]='.';
    c[1][1]=',';
    c[1][2]='!';
    c[1][3]='?';
    c[1][4]=' ';
    char alpha='a';
    for(int i=2;i<=9;i++){
        int index=0;
        if(i==7|| i==9){
            while(index<4){
                c[i][index]=alpha;
                index++;
                alpha++;
            }
        }
        else{
            while(index<3){
                c[i][index]=alpha;
                index++;
                alpha++;
            }
        }
    }
    int n;
    string s;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s;
        int cnt=0;
        char d='0';
        for(int i=0;i<s.length();i++){
            if(s[i]=='0'){
                if(d!='0'){
                    int x=d-'0';
                    if(x==7||x==9){
                        cout<<c[x][(cnt-1)%4];
                        cnt=0;
                        d='0';
                    }
                    else if(x==1){
                        cout<<c[x][(cnt-1)%5];
                        cnt=0;
                        d='0';
                    }
                    else{
                        cout<<c[x][(cnt-1)%3];
                        cnt=0;
                        d='0';
                    }
                }
            }
            else{
                d=s[i];
                cnt++;
            }
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

struct Point{
  double x, y;
};

void koch(int n, Point a, Point b){
  if(n == 0) return;
  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n - 1, t, b);
  
}

int main(){
  Point a, b;
  int n;

  cin >> n;

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);


  return 0;
}



Measured memory_bytes: 3232
import copy
from itertools import combinations
h, w, k = map(int, input().split())
c =[input() for i in range(h)]
ans = 0
y = []
for i in range(h):
    y.append(i)
x = []
for i in range(w):
    x.append(i)
for i in range(h+1):
    ty = list(combinations(y, i))
    for j in range(w+1):
        tx = list(combinations(x, j))
        for l in ty:
            for m in tx:
                cnt = 0
                for p in l:
                    for q in m:
                        if c[p][q] == '#':
                            cnt += 1
                if cnt == k:
                    ans += 1
print(ans) 

Measured memory_bytes: 9304
from fractions import gcd
a,b,c,d = map(int,input().split())
lcm = c*d//gcd(c,d)
ac = (a-1)//c
ad = (a-1)//d
la = (a-1)//lcm
a_ = a-(ac+ad-la)
bc = b//c
bd = b//d
lb = b//lcm
b_ = b-(bc+bd-lb)
ans = b_ - a_ + 1
print(ans)


Measured memory_bytes: 5076
#include<iostream>
#include<stdlib.h>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
	int N;
	cin>>N;
	int X[2*100000]={0};
	int tmp;
	for(int i=0;i<N;++i){
		cin>>tmp;
		X[tmp]++;
		X[tmp+1]++;
		X[tmp+2]++;
	}
	int ans=0;
	for(long i=0;i<2*100000;++i){
		if(X[i]>ans)ans=X[i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 1000000000+7;
    public static void main(String[] args) throws IOException {
        Main main = new Main();
//        main.solve();
//        out.flush();
        System.out.println(main.solve());
    }
    long solve() throws IOException{
        int n = sc.nextInt(), k = sc.nextInt();
        // instead of computing every time, we should conpute and record
        // therefore, starting from bigger values can help (recording)
        // exactly how many have the gcd as exactly i
        long[] arr_num = new long[k+1];
        long ans = 0;
        for(int i=k;i>0;i--){
            int bmax = k/i;
            long temp = power(bmax,n);
            for(int j=2*i;j<=k;j+=i){
                // subtract its multiples, which have already been computed and recorded
                temp = (temp+mod-arr_num[j])%mod;
            }
            arr_num[i] = temp;
            ans = (ans+temp*i)%mod;
        }
        return ans;
    }
    long power(long base, long q){
        long ans = 1;
        while(q>0){
            if(q%2==1) ans = ans*base%mod;
            base = base*base%mod;
            q /= 2;
        }
        return ans;
    }
}



Measured memory_bytes: 36596
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));
ll SumC = 0;

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
        SumC += c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    double BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1);

    double T0 = 2000;
    double T1 = 600;
    double TL = 1950;

    ll count = 0;

    while (1)
    {
        ll msec;

        auto end = chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                 // 要した時間を計算
        msec = chrono::duration_cast<chrono::milliseconds>(dur).count();

        if (msec >= TL)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        double score = scoring(t);

        if (exp((score - BestScore) / T) > 0.5)
        {
            BestT = t;
            BestScore = score;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


Measured memory_bytes: 4376
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;

#define MOD 1e9+7
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_V 100
#define MAX_E 100

//--------------------------

int dfs(int n);

int N, K, D;
int d[10];

int main() {

  cin >> N >> K;
  rep(i, K) {
    cin >> D;
    d[D] = 1;
  }

  cout << dfs(0) << endl;

  return 0;
}

int dfs(int n) {

  int min_money = INF;

  if(n>=N) {
    return n;
  }

  rep(i, 10) {
    if(n==0&&i==0) continue;
    if(d[i]==0) {
      min_money = min(min_money, dfs(n*10+i));
    }
  }

  return min_money;
}


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

int main(){
	int N;
	char s[101];
	int loop;
	int max = 0;
	int x = 0;

	cin >> N >> s;
	for (loop = 0; loop < N; loop++){
		if (s[loop] == 'I') {
			if (max < ++x)max = x;
		}
		else x--;
	}
	cout << max << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef long double ld;

int main(){
  FIO
 int a,b,c;
 cin>>a>>b>>c;
 if(a==b&&a!=c||b==c&&b!=a||c==a&&c!=b)cout<<"Yes";
 else cout<<"No";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define PI 3.1415926535897932384626433
#define ceil1(a,b)   (a+(b-1))/b
#define all(v)  v.begin(),v.end()
#define gen(arr,n,nxt)  generate(arr,arr+n,nxt)
#define base ios_base::sync_with_stdio(false);cin.tie(0);
#define open freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
const int mo=1e9+7;
int nxt(){int x;cin>>x;return x;}
int mod(int n,int m){int ans=n%m;if(ans<0)ans+=m;return ans;}
int32_t main(){
    base
    int n=nxt(),m=nxt(),k=nxt();
    double time=(double)n/k;
    if(time<=m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3620
/*
 * Pawan Harendra Mishra
 */

#include <bits/stdc++.h>
using namespace std;

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

int n;
string s;
int q1[10], q2[100], q3[1000];

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);

    cin >> n >> s;
    
    memset(q1, 0, sizeof(q1));
    memset(q2, 0, sizeof(q2));
    memset(q3, 0, sizeof(q3));

    for (ll i=0; i<n-2; i++) {
        int x = s[i] - '0';
        if (!q1[x]) {
            q1[x] = 1;
            for (ll j=i+1; j<n-1; j++) {
                int y = x * 10 + int(s[j] - '0');
                if (!q2[y]) {
                    q2[y] = 1;
                    for (ll k=j+1; k<n; k++) {
                        int z = y * 10 + int(s[k] - '0');
                        q3[z] = 1;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (ll i=0; i<1000; i++) if (q3[i]) ans++;

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

divide_4_cnt = 0
divide_2_cnt = 0
for n in A:
    if n % 4 == 0:
        divide_4_cnt += 1
    elif n % 2 == 0:
        divide_2_cnt += 1
divide_2_cnt = (divide_2_cnt // 2) * 2
N = N - divide_2_cnt

if N//2 <= divide_4_cnt:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14252
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var protoS string
var t string

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fscan(r, &protoS, &t)

	index := -1
	for i := len(protoS) - len(t); i >= 0; i-- {
		if enableReplace(i) {
			index = i
			break
		}
	}

	if index == -1 {
		fmt.Fprintln(w, "UNRESTORABLE")
		return
	}

	var s string
	if index != 0 {
		s = protoS[:index]
	}
	s += t
	if index+len(t) != len(protoS)-1 {
		s += protoS[index+len(t):]
	}
	s = strings.ReplaceAll(s, "?", "a")
	fmt.Fprintln(w, s)
}

func enableReplace(startIndex int) bool {
	if startIndex+len(t) > len(protoS) {
		return false
	}

	for i := 0; i < len(t); i++ {
		if protoS[startIndex+i] == '?' {
			continue
		}
		if protoS[startIndex+i] != t[i] {
			return false
		}
	}

	return true
}


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

using namespace std;
using ll = long long;

const int INF = 1e9;


int n, m;
int to_id(int v, int mod) {
    return v * 3 + mod;  
}

vector<int> BFS(vector<vector<int>> Hen, int s) {
    int n = Hen.size();
    vector<int> dist(n, INF);
    queue<int> que;
    dist[s] = 0;
    que.push(s);
    while(que.size()) {
        auto cur = que.front(); que.pop();
        for(auto i : Hen[cur]) {
            if(dist[i] != INF)continue;
            dist[i] = dist[cur] + 1;
            que.push(i);
        }
    }
    return dist;
}

int main()
{
    cin >> n >> m;
    vector<vector<int>> hen(n * 3);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b; a--, b--;
        for(int j = 0; j < 3; j++) {
            hen[to_id(a, j)].push_back(to_id(b, (j + 1) % 3));
        }
    }
    int s, t; cin >> s >> t; s--, t--;
    cout << (BFS(hen, to_id(s, 0))[to_id(t, 0)] == INF ? -1 : BFS(hen, to_id(s, 0))[to_id(t, 0)] / 3) << endl;

}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 90000000000000000;
int PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<pair<ll,ll>>>;

int main(){
  ll N,K;cin >> N >> K;
  ll ans = 0;
  ll z = 0;
  for(int i = K+1;i <= N;i++){
    //cout << '(' << i << ')' << N % i << ' ';
    ans += N / i * (i - K);
    //cout << N / i * (i - K) << ' ';
    if(N % i != 0 && K != 0){
      ans += max(z,N % i - K + 1);
      //cout << max(N % i - K + 1,z);
    }
    if(N % i != 0 && K == 0){
      ans += max(z,N % i - K );
      //cout << max(N % i - K ,z);
    }
    //cout << endl;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string o,e;
  cin >> o >> e;
  int a=o.size(),b=e.size();
  for(int i=0;i<min(a,b);i++){
    cout << o[i] << e[i];
  }
  
  if(a>b) cout << o[a-1] << endl;
  else cout << endl;
  
}

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

int main() {
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def solve(k):
    #kの約数を求める関数
    num = int(k**0.5)
    l = []
    for i in range(1, num + 1):
        if k % i == 0:
            l.append(i)
            l.append(k//i)
    return set(l)

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

box = [0] * n
ans = [0] * n
cnt = 0
for i in range(n):
    if box[-(i + 1)] != a[-(i + 1)]:
        cnt += 1
        ans[-(i + 1)] = 1
        num = solve(n - i)
        for j in num:
            box[j - 1] = (box[j - 1] + 1) % 2
print(cnt)
for i in range(n):
    if ans[i]:
        print(i + 1)

Measured memory_bytes: 64616
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	int n;
	cin>>n;
	map<int,int> m;
	rep(i,0,n){
		int a;
		cin>>a;
		m[a]++;
	}	
	int ans=0;
	for(auto i:m){
		if(i.S<i.F)
			ans+=i.S;
		else
			ans+=i.S-i.F;
	}
	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 7976
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int r;
  cin >> r;
  if (r < 1200) cout << "ABC" << endl;
  else if (r < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
  

  
  return 0;
}

Measured memory_bytes: 256
S = list(input())

numa = S.count("a")
numb = S.count("b")
numc = S.count("c")
num = [numa, numb, numc]
num.sort()

if 0 in num:
    if len(S) in [1, 2] and 2 not in num:
        print("YES")
    else:
        print("NO")
else:
    if num[2] - 1 <= num[0] and num[2] - 1 <= num[1]:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 3956
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 6000;
int a[N];
bitset<N> L[N], R[N];
int sum[N][N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  L[0] = 1;
  for (int i = 0; i < n; ++i) {
    L[i + 1] = L[i] | (L[i] << a[i]);
  }
  R[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    R[i] = R[i + 1] | (R[i + 1] << a[i]);
  }
  // L[0][0] = true;
  // for (int i = 0; i < n; ++i) {
  //   copy(L[i], L[i] + m, L[i + 1]);
  //   for (int j = m - 1; j >= a[i]; --j) {
  //     L[i + 1][j] |= L[i][j - a[i]];
  //   }
  // }
  // R[n][0] = true;
  // for (int i = n - 1; i >= 0; --i) {
  //   copy(R[i + 1], R[i + 1] + m, R[i]);
  //   for (int j = m - 1; j >= a[i]; --j) {
  //     R[i][j] |= R[i + 1][j - a[i]];
  //   }
  // }
  for (int i = 0; i <= n; ++i) {
    sum[i][0] = 0;
    for (int j = 1; j <= m; ++j) {
      sum[i][j] = sum[i][j - 1] + R[i][j - 1];
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    int vl = max(0, m - a[i]), vr = m - 1;
    bool found = false;
    for (int j = 0; j <= vr; ++j) {
      if (!L[i][j]) continue;
      int kr = vr - j, kl = max(0, vl - j);
      if (sum[i + 1][kr + 1] - sum[i + 1][kl] > 0) {
        found = true;
        break;
      }
    }
    if (!found) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 128512
N = int(input())

happy = [list(map(int,input().split())) for i in range(N)]

dp = []
for i in range(N+1):
    dp.append([])
    for j in range(3):
        dp[i].append(0)

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i+1][k] = max(dp[i+1][k], dp[i][j] + happy[i][k])

res = 0
for i in range(3):
    res = max(res, dp[N][i])

print(res)

#print(happy)

Measured memory_bytes: 106124
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
   int x,y,a,b,c;
   cin >> x >> y >> a >> b >> c;
   vector<int> r(a);
   vector<int> g(b);
   vector<int> mu(c);
   rep(i,a) cin >> r[i];
   rep(i,b) cin >> g[i];
   rep(i,c) cin >> mu[i];
   ll ans=0;
   sort(r.begin(),r.end(),greater<int>());
   sort(g.begin(),g.end(),greater<int>());
   sort(mu.begin(),mu.end(),greater<int>());
   //for (int w:r){
   //   cout << w ;
   //}
   //printf("\n");
   //for (int w:g){
   //   cout << w ;
   //}
   //printf("\n");
   //for (int w:mu){
   //   cout << w ;
   //}
   //printf("\n");
   priority_queue<int> pq;
   rep(i,x){
      pq.push(r[i]);
   }
   rep(i,y){
      pq.push(g[i]);
   }
   rep(i,c){
      pq.push(mu[i]);
   }
   
   rep(i,x+y){
      int tmp = pq.top();
      pq.pop();
      //cout << tmp << endl;
      ans+=tmp;
   }
   cout << ans << endl;

   
   return 0;
}


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

int main(){
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int minStudy = 60*(H2-H1) + (M2-M1)-K;
  cout << minStudy << endl;
}


Measured memory_bytes: 3584
// https://atcoder.jp/contests/agc035/tasks/agc035_a

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;
using ul = unsigned long long;

void good(bool good) {
   cout << (good ? "Yes" : "No") << endl;
}

void set_numbers(set<int>const& st, ul &x, ul& y, ul& z) {
    auto it = st.begin();
    if (it != st.end()) {
        x = *it;
        ++it;
    }
    if (it != st.end()) {
        y = *it;
        ++it;
    }
    if (it != st.end()) {
        z = *it;
        ++it;
    }
}
int main() {
    int N{};
    cin >> N;
    vector<int> values;
    values.reserve(N);
    for (int i=0; i < N; ++i) {
        int x;
        cin >> x;
        values.emplace_back(x);
    }
    multiset<int> dedup{values.begin(), values.end()};
    set<int> s{values.begin(), values.end()};

    ul x{}, y{}, z{};
    switch(N % 3) {
        case 0: {
            // a1, a2, a1+a2
            // a1 - n
            // a2 - n
            // a1+a2 - n
            int n = N/3;
            set_numbers(s, x, y, z);
            switch (s.size()) {
                case 1:
                    if (x == 0) {
                        good(true);
                        return 0;
                    }
                    break;
                case 2:
                    if (x == 0 && dedup.count(0) == n && dedup.count(y) == 2*n) {
                        good(true);
                        return 0;
                    }
                    break;
                case 3:
                    if ((x xor y) == z && dedup.count(x) == n && dedup.count(y) == n && dedup.count(z) == n) {
                        good(true);
                        return 0;
                    }
                    break;
                default:
                    break;
            }
            break;
        }
        case 1: {
            // a1 == a2
            // a3 == 0
            // a1, a1, 0
            // a1 - 2n+1
            // 0 - n
            int n = (N-1)/3;
            set_numbers(s, x, y, z);
            if ((s.size() == 1 && x == 0) ||
                (s.size() == 2 && x == 0 && dedup.count(0) == n && dedup.count(y) == 2*n+1)) {
                good(true);
                return 0;
            }
            break;
        }
        case 2: {
            // a1 + a2 = a1 -> a2 = 0
            // a1, 0, a1
            // a1 - 2n+1
            // 0 - n+1
            int n = (N-2)/3;
            set_numbers(s, x, y, z);
            if ((s.size() == 1 && x == 0) ||
                (s.size() == 2 && x == 0 && dedup.count(0) == n+1 && dedup.count(y) == 2*n+1)) {
                good(true);
                return 0;
            }
            break;
        }
        default:
            abort();
    }
    good(false);
    return 0;

}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	vector<int>a(q);
	vector<int>b(q);
	vector<int>c(q);
	vector<int>d(q);
	for(int i=0;i<q;++i)
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	vector<int>A(n);
	int ans=0;
	function<void(int,int)>dfs=[&](int p,int low){
		if(p==n){
			int tot=0;
			for(int i=0;i<q;++i)
				tot+=(A[b[i]-1]-A[a[i]-1]==c[i])*d[i];
			ans=max(ans,tot);
			return;
		}
		for(int i=low;i<=m;++i){
			A[p]=i;
			dfs(p+1,i);
			A[p]=0;
		}
	};
	dfs(0,1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3604
def main():
	N = int(input())
	red = [[0, 0] for _ in range(N)]
	blue = [[0, 0] for _ in range(N)]
	for i in range(N):
		red[i] = list(map(int, input().split()))
	for i in range(N):
		blue[i] = list(map(int, input().split()))

	blue.sort(key=lambda x: x[0])

	ans = 0
	for b in blue:
		removes = []
		for i, r in enumerate(red):
			if r[0] < b[0] and r[1] < b[1]:
				removes.append([r[1], i])
		if len(removes) > 0:
			removes.sort(key=lambda x: -x[0])
			ans += 1
			red.pop(removes[0][1])

	print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;

namespace Project
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			string[] s = Console.ReadLine().Split(' ');
			Stack<string> stack = new Stack<string>();
			for (int i = 0; i < s.Length; i++)
			{
				stack.Push(s[s.Length - 1 - i]);
			}
			while (stack.Count > 1)
			{
				Ope(stack);
			}
			Console.WriteLine(stack.Pop());

		}

		public static void Ope(Stack<string> stack)
		{
			string s1 = stack.Pop();
			string s2 = stack.Pop();
			string s3 = stack.Pop();
			int tmp;
			switch (s3)
			{
				case "+":
					tmp = int.Parse(s1) + int.Parse(s2);
					stack.Push(tmp.ToString());
					break;
				case "-":
					tmp = int.Parse(s1) - int.Parse(s2);
					stack.Push(tmp.ToString());
					break;
				case "*":
					tmp = int.Parse(s1) * int.Parse(s2);
					stack.Push(tmp.ToString());
					break;
				default:
					stack.Push(s3);
					stack.Push(s2);
					Ope(stack);
					stack.Push(s1);
					break;
			}
		}
	}
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;


#define rep(i,n) for(ll i=0;i<n;i++)



int main() {

  cout<<fixed<<setprecision(10);

  string x; cin>>x;

  while(x != "0"){
    ll sum = 0;

    rep(i, x.size()){
      sum += x[i]-'0';
    }
    cout<<sum<<endl;
    cin>>x;
  }

  return 0;
}




//





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

using namespace std;


int main(){
	long long int N;
	cin >> N;
	for( long long int h = 1; h <= 3500; h++ ){
		for( long long int n = h; n <= 3500; n++ ){
			if( ( 4 * h*n - N*n - N*h ) != 0 )
				if( ( N*h*n ) % ( 4 * h*n - N*n - N*h ) == 0 ){
					long long int w = ( N*h*n ) / ( 4 * h*n - N*n - N*h );
					if( w >= n ){
						cout << h << " " << n << " " << w << endl;
						return 0;
					}
				}
		}
	}
}


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

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

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


int main() {
    ll A,B;
    cin>>A>>B;
    for(int i=1;i<=B;i++){
        if(A*i%B==0){
            cout<<A*i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
  
int main(void){
int a[10000];
int n;
int i;
long s=0;
int h,l;
  
scanf("%d",&n);
  
for(i =0; i<n; i++){
scanf("%d",&a[i]);
s += a[i];
}
  
l =1000001;
h=-1000001;
  
for(i=0;i<n;i++){
if(l>a[i])l = a[i];
if(h<a[i])h = a[i];
}
  
printf("%d %d %ld\n",l, h,s);
  
return 0;
}

Measured memory_bytes: 640
n = int(input())
a = input().split()
b = input().split()
c = input().split()

x = 0
iii=-2

i=0

for i in range(n):

    ii = int(a[i])
    x += int(b[ii-1])

    if ii == iii+1 :
        x += int(c[iii-1])
        
    iii = ii
    
print(x)
    

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


int h, w, a[30][30], ans = 10000000;

int main(){
    cin >> h >> w;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) cin >> a[i][j];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            int p = 0;
            for (int k = 0; k < h; k++){
                for (int l = 0; l < w; l++){
                    p += min(abs(i - k), abs(j - l)) * a[k][l];
                }
            }
            ans = min(ans, p);
        }
    }
    cout << ans << endl;
}


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

int main() {
  int T, A, B;
  cin >> T >> A >> B;
  int plan1 = T * A;
  int plan2 = B;
  if (plan1 < plan2) {
    cout << plan1 << endl;
  } else {
    cout << plan2 << endl;
  }
}

Measured memory_bytes: 256
/**
 *  winners never quit
**/

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define pp pop_back
#define mp make_pair
typedef long long Long;
void FastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
}

const int N = 1e7;

int dp[N+1];

void make(){
  for (Long i = 1;i <= N;i++){
    for (Long j = 1;i*j <= N;j++){
      dp[i*j]++;
    }
  }
}

int main()
{
  FastIO();
  int tc, ca = 0;
  make();
//  for (int i = 1;i <= 10;i++){
//    cout << dp[i] << ' ';
//  }cout << '\n';
  Long x;
  cin >> x;
  Long ans = 0;
  for (Long i = 1;i <= x;i++){
    Long a = dp[i];
    ans += a*i;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 42700
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 0;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n, m;
H a[200000];
signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (m > a[i].y) {
			m -= a[i].y;
			ans += a[i].x*a[i].y;
		}
		else {
			ans += a[i].x*m;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;


int main(){
    
    cout<<setprecision(10);
    
    ll N,K;
    double p[200010],MAX;
    cin>>N>>K;
    rep(i,0,N){
        cin>>p[i];
        p[i]=(p[i]+1.0)/2.0;
    }
    rep(i,0,N-1){
        p[i+1]=p[i]+p[i+1];
    }
    
    MAX=p[K-1];
    
    rep(i,0,N-K){
        MAX=max(p[K+i]-p[i],MAX);
    }
    cout<<MAX<<endl;
}




Measured memory_bytes: 1792
fun main(args: Array<String>) = yorukatsu20d()

fun yorukatsu20d() {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()
    val bList = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()
    val cList = readLine()!!.split(' ').map { it.toLong() }.sorted().toLongArray()

    fun lowerBound(list: LongArray, key: Long): Int {
        var ng = -1
        var ok = list.size

        while (ok - ng > 1) {
            val mid = (ok + ng) / 2
            if (list[mid] >= key) ok = mid else ng = mid
        }
        return ok
    }

    val answer = bList
        .map { lowerBound(aList, it) * (cList.lastIndex + 1 - lowerBound(cList, it + 1)).toLong() }.sum()

    println(answer)
}


Measured memory_bytes: 109308
#include <iostream>
#include <cstdio>                                               //scanf,printf
#include <algorithm>                                            //max,min
#include <string>                                               //string
#include <cstring>                                              //strlen,strcat
#include <cctype>                                               //isalpha,tolower
#include <cmath>                                                //sqrt,sin
#include <stack>                                                //top,push
#include <queue>                                                //front,push
#include <vector>                                               //push_back,sort
#include <set>                                                  //insert,begin
#include <map>                                                  //insert,find
#include <list>                                                 //push_front,begin
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>                                               //pow,powf
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl;
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define rep(i,n) for(int i=0; i<n; i++)
#define MAX 200005

int main(){
  int n,x[MAX];
  vector<int> v;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>x[i];
    v.push_back(x[i]);
  }
  
  sort(v.begin(), v.end());
  for(int i=0; i<n; i++){
    int a=x[i];
    if(a<v[n/2]){
      cout<<v[n/2]<<en
    }else if(a==v[n/2]){
      cout<<v[n/2-1]<<en
    }else{
      cout<<v[n/2-1]<<en
    }
  }
}

Measured memory_bytes: 3828
/* One original thought is worth a thousand mindless quotings */

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<bitset>
#include<queue>
#define ll long long
#define ld long double
#define ull unsigned long long
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(10);cout << fixed;
#define dbset(x) for(int i=0 ; i<x.size(); i++) cerr << x[i] << " "; cerr << endl;
#define inf 1000000007
#define INF 1000000000000000000LL
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 1000696969
#define flusz fflush(stdout);
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define BIT bitset<N>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)

#define int long long
const int N = 5 * 100*1000 + 7;

int test;

int n,m;

int t[N],par[N],rnk[N];

int res;

multiset<int>akt;

multiset<int>tu[N];

set<int>ile;

int fnd(int x){
    if (par[x] != x){
        par[x] = fnd(par[x]);
    }

    return par[x];
}

void uni(int a,int b){
    a = fnd(a);
    b = fnd(b);

    if (rnk[a] > rnk[b]){
        rnk[a] += rnk[b];
        par[b] = a;
    }else{
        rnk[b] += rnk[a];
        par[a] = b;
    }
}

void solve()
{   
    cin >> n >> m;

    FOR(i,1,n){
        cin >> t[i];

        par[i] = i;
        rnk[i] = 1;

        akt.insert(t[i]);
    }

    FOR(i,1,m){
        int a,b;
        cin >> a >> b;

        a++,b++;

        uni(a,b);
    }

    FOR(i,1,n){
        fnd(i);

        ile.insert(par[i]);
        tu[par[i]].insert(t[i]);
    }

    int xx = (ile.size()-1)*2;

    if ( xx > n ){
        cout << "Impossible";
        return;
    }

    if (xx == 0){
        cout << 0;
        return;
    }

    for(auto it:ile){
        akt.erase(akt.find(*tu[it].begin()));
        res += *tu[it].begin();
        xx--;
    }

    for(auto it:akt){
        if (xx <= 0)
            break;

        res += it;
        xx--;
    }

    cout << res;

    return;
}

int32_t main()
{
    boost

    test=1;

    while(test--)
    {
        solve();
    }

  return 0;
}


Measured memory_bytes: 43008
def solve():
    MOD = 10**9 + 7

    strN = input().rstrip()
    D = int(input())

    maxD = len(strN)

    dpLt = [0] * D
    NmodD = 0
    for d, Nd in enumerate(strN):
        Nd = int(Nd)
        dpLt2 = [0] * D
        for modD in range(D):
            dpLt[modD] = dpNow = dpLt[modD] % MOD
            for x in range(10):
                modD2 = (modD+x) % D
                dpLt2[modD2] += dpNow
        for x in range(Nd):
            modD2 = (NmodD+x) % D
            dpLt2[modD2] += 1
        NmodD = (NmodD+Nd) % D
        dpLt = dpLt2

    print((dpLt[0] + (NmodD == 0) - 1) % MOD)


solve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int M = 1e9+7;
using ll = long long;

int main(){
    ll n;cin>>n;
    vector<ll> arr(n);
    for(int i = 0; i < n; i++) cin>>arr[i];
    
    ll ans = 0;
    for(int i = 0; i < 60; i++){
        ll cnt = 0;
      for(int j = 0; j < n; j++) if((arr[j]>>i)&1) cnt++;
       ll x = cnt*(n-cnt)%M;
      for(int j = 0; j < i; j++) x=x*2%M;
      ans+=x;
      ans%=M;
     }     
   cout<<ans;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, ma = 0, mi = 1000000001;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ma = max(ma, a[i]);
    mi = min(mi, a[i]);
  }
  cout << (ma - mi) << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
const ll INF = 1000000007;
const ld PI = 3.141592653589;
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (a*b)/__gcd(a,b);}

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
		ll a,b,v,w,t;
		cin>>a>>v>>b>>w>>t;
		//if(v<=w)cout<<"NO";
      	//else
      {
          ll d = abs(a-b);
          ll dd = (v-w)*t;
          cout<<((d<=dd)?"YES":"NO");
        }
	}
	//cout<< "Done in " <<fixed<<setprecision(15)<<(double)clock()/7.33e8<<"sec"<< endl;
    return 0;
}


Measured memory_bytes: 3692
/*
░░░░░░░░░░░░░░░░▄▄█▀▀██▄▄░░░░░░░
░░░░░░░░░░░░░▄█▀▀░░░░░░░▀█░░░░░░
░░░░░░░░░░░▄▀░░░░░░░░░░░░░█░░░░░
░░░░░░░░░▄█░░░░░░░░░░░░░░░█░░░░░
░░░░░░░██▀░░░░░░░▄▄▄░░▄░█▄█▄░░░░
░░░░░▄▀░░░░░░░░░░████░█▄██░▀▄░░░
░░░░█▀░░░░░░░░▄▄██▀░░█████░██░░░
░░░█▀░░░░░░░░░▀█░▀█▀█▀▀▄██▄█▀░░░
░░░██░░░░░░░░░░█░░█░█░░▀▀▄█▀░░░░
░░░░█░░░░░█░░░▀█░░░░▄░░░░░▄█░░░░
░░░░▀█░░░░███▄░█░░░░░░▄▄▄▄█▀█▄░░
░░░░░▀██░░█▄▀▀██░░░░░░░░▄▄█░░▀▄░
░░░░░░▀▀█▄░▀▄▄░▄░░░░░░░███▀░░▄██
░░░░░░░░░▀▀▀███▀█▄░░░░░█▀░▀░░░▀█
░░░░░░░░░░░░▄▀░░░▀█▄░░░░░▄▄░░▄█▀
░░░▄▄▄▀▀▀▀▀█▀░░░░░█▄▀▄▄▄▄▄▄█▀▀░░
░▄█░░░▄██▀░░░░░░░░░█▄░░░░░░░░░░░
█▀▀░▄█░░░░░░░░░░░░░░▀▀█▄░░░░░░░░
█░░░█░░░░░░░░░░░░░░░░░░█▄░░░░░░░
*/
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
#define int ll
const ll mod = 1000000007;
const ll nmax=1000003;
int a, b, d, ans;

int gcd(int x, int y){
	if(x==0) return y;
	else return gcd(y%x, x);
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin>>a>>b;
    d=gcd(a, b);
    for(int i=2; i*i<=d; i++){
		if(d%i==0) ans++;
		while(d%i==0) d/=i;
	}
	if(d>1) ans++;
	cout<<++ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

inline int gcd(int a, int b)
{
    if(!b)
        return a;
    else return gcd(b,a%b);
}

int main()
{
    int N,X,Y;
    ios_base::sync_with_stdio(0);
    cin >> N >> X;
    for(int i = 2; i <= N; ++i)
    {
        cin >> Y;
        Y = gcd(X,Y);
        X = Y;
    }
    cout << Y;
    return 0;
}


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

int main() {
  string a,b;
  cin >> a >> b;
  string ab=a+b;
  int c=0;
  for (char C:ab) {
    c*=10;
    c+=C-'0';
  }
  int d=sqrt(c);
  if (c==d*d) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3572
import qualified Data.ByteString.Char8 as B
import Data.Maybe(fromJust)
import Control.Arrow
main=putStrLn.unwords.map show.solve.map(fst.fromJust.B.readInt).B.words=<<B.getContents
solve(n:xs)=if odd n then reverse ys++zs else reverse zs++ys where(ys,zs)=(f odd&&&f even)xs
f g=map snd.filter(g.fst).zip[1..]

Measured memory_bytes: 54140
"use strict";
    
const main = arg => {
    const S = arg.split("\n")[0].split("");
    let streak = [];
    let temp = 0;
    
    for(let i in S) {
        if(S[i] == "A" || S[i] == "T" || S[i] == "C" || S[i] == "G") {
            temp++;
        } else {
            streak.push(temp);
            temp = 0;
        }
    }
    
    if(temp !== 0) {
        streak.push(temp);
    }

    console.log(Math.max(...streak));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7500
//
//  main.cpp
//  每个人都喜欢的食物
//
//  Created by 姚欣 on 2020/7/29.
//  Copyright © 2020 任奕霏. All rights reserved.
//

#include <iostream>
using namespace std;
int main()
{
    int N,M,i,j,k;
    cin >> N >> M;
    int K[N],a[N][M],sum = 0,b = 0;
    for(i = 0; i < N; i ++)
    {
        for(j = 0; j < M; j ++)
            a[i][j] = 0;
    }
    for(i = 0; i < N; i ++)
    {
        cin >> K[i];
        for(j = 0; j < K[i]; j ++)
        {
            cin >> a[i][j];
        }
    }
    for(k = 1; k <= M; k ++)
    {
        for(i = 0; i < N; i ++)
        {
            for(j = 0; j < M; j ++)
            {
                if(a[i][j] == 0)
                    continue;
                if(a[i][j] == k)
                    sum ++;
            }
        }
        if(sum == N)
            b ++;
        sum = 0;
    }
    cout << b << endl;
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
using namespace std;

vector<vector<ll>> adj;
bool vis[300000];

ll dfs(ll x){
	vis[x] = true;
	ll cnt = 1;
	for (int i = 0; i < adj[x].size(); ++i)
	{
		if (vis[adj[x][i]] == false)
		{
			cnt += dfs(adj[x][i]);
		}
	}
	return cnt;
}

void solve(int test){
	ll n,m;
	cin>>n>>m;
	adj.clear();
	adj.resize(n + 1);
	memset(vis, false, sizeof(vis));
	ll a,b;
	while(m--){
		cin>>a>>b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	ll ans = 0, cnt;
	for (int i = 1; i <= n; ++i)
	{
		if (vis[i] == false)
		{
			cnt = dfs(i);
			ans = max(ans, cnt);
			//cout<<cnt<<endl;
		}
	}
	cout<<ans;
}
  
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1,k;
	//cin>>t;
	k = t;
	while(t--){
		solve(k - t);
	}
	cerr<<"Timpe elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " mps\n" ;
	return 0;
}

Measured memory_bytes: 23668
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;
using namespace std;

int main(){
    const double PI=3.14159265358979323846;
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double a_x, a_y, b_x, b_y;
    double hh, mm;
    mm = m / 60.0;
    hh = (h + mm) / 12.0;
    a_x = a * cos(PI * 2.0 * hh);
    a_y = a * sin(PI * 2.0 * hh);
    b_x = b * cos(PI * 2.0 * mm);
    b_y = b * sin(PI * 2.0 * mm);
    double r = (a_x - b_x)*(a_x - b_x) + (a_y - b_y)*(a_y - b_y);
    r = sqrt(r) ;
    cout << setprecision(15) << r << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b, c, d;
  	cin >> a;
  	b = a / 100;
  	c = ( a - 100 * b ) / 10;
  	d =  a - 100 * b - c * 10;
  	cout <<b + c + d << endl;
}

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

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

Measured memory_bytes: 256
/* Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
#define ll long long

using namespace std;



ll calc(string s){
    if(s.size() == 1){
        ll c = s[0]-'0';
        return c/2;
    }
    ll val = 0;
    ll ans = 4LL;
    if(s.size() > 2){
      ll prod = 10LL*(pow(10LL, s.size()-2)-1LL)/9LL;
      ans *= prod;
    }
    for(int i = 0; i < s.size()-1; i++){
        ll c = s[i] - '0';
        c = 9LL-c;
        c /= 2LL;
        ll prod = 10LL*(pow(10LL, i)-1LL)/9LL;
        val -= c*prod;
    }
    ll c = s[s.size()-1] - '0';
    c /= 2LL;
    ll prod = 10LL*(pow(10LL, s.size()-1)-1LL)/9LL;
    val += c*prod;
    cout << ans << " " << val << endl;
    if(c > 1) ans += val;
    return ans;
}

int main()
{
    int a, b;
    cin >> a >> b;
    cout << (a^b);

}


Measured memory_bytes: 256