akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner t=new Scanner(System.in);
		int a=t.nextInt(), b=t.nextInt(), c = a +b,d = a - b,e = a *b;
		if(c>=d && c>=e) {
			System.out.println(c);
		}else {
			if(d>=c && d>=e) {
				System.out.println(d);
			}else {
				if(e>=d && e>=c) {
					System.out.println(e);
				}
			}
		}
	
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
const int p = 6;
const int MAX = 30000;

int main() {
    int n;
    cin >> n;
    if (n < p) {
        if (n == 3) printf("2\n5\n63\n");
        if (n == 4) printf("2\n5\n20\n63\n");
        if (n == 5) printf("2\n5\n20\n30\n63\n");
        return 0;
    }
    
    vector<int> id(p, 0);
    vector<vector<int>> num(p);
    for (int i = 2; i <= MAX; i++) num[i%p].push_back(i);
    
    set<int> ans;
    for (int i = 2, _ = 0; _ < n; _++) {
        ans.insert(num[i][id[i]++]);
        if (i == 0) i = 2;
        else if (i == 2) i = 3;
        else if (i == 3) i = 4;
        else i = 0;
    }
    
    long long sum = 0;
    for (const auto& e : ans) sum += e;
    if (sum % p == 2) {
        ans.erase(8); ans.insert(num[0][id[0]]);
    } else if (sum % p == 3) {
        ans.erase(9); ans.insert(num[0][id[0]]);
    } else if (sum % p == 5) {
        ans.erase(9); ans.insert(num[4][id[4]]);
    }
    
    for (const auto& e : ans) cout << e << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int H,N;
    cin >> H >> N;
    int sum=0;

    for (int i = 0; i < N;i++){
        int tmp=0;
        cin >> tmp;
        sum+=tmp;
    }

    if(sum<H){
        cout <<"No";
    }
    else{
        cout << "Yes";
    }


    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const ll sz=1<<17;
ll n, lt=1, rt=1e9, md, ans, a[sz], tr[(sz<<1)+5];

void add(int p) {
	while(p < sz<<1){
		tr[p]++;
		p += p & -p;
	}
}

int sum(int p) {
	ll res=0;
	while(p){
		res += tr[p];
		p -= p & -p;
	}
	return res;
}

bool f(int p){
	ll i, k, cnt=0;
	memset(tr, 0, sizeof(tr));
	for(i=1, k=sz; i<=n; i++) {
		add(k);
		k += a[i]>=p ? 1:-1;
		cnt += sum(k);
	}
	return cnt >= (n*(n+1)/2+1)/2;
}

int main() {
	int i;
	scanf("%lld", &n);
	for(i=1; i<=n; i++) scanf("%lld", &a[i]);
	while(lt<rt){
		md = lt+rt+1 >> 1;
		if(f(md)) lt=md;
		else rt=md-1;
	}
	printf("%lld", rt);
	return 0;
}

Measured memory_bytes: 3072
def read():
    X = int(input())
    return X,

def exchange(x0, a):
    count = 0
    while True:
        x1 = x0 - a
        if x1 < 0:
            return x0, count
        count += 1
        x0 = x1
    return x0, count

def solve(X):
    x = X
    x, c500 = exchange(x, 500)
    x, c5 = exchange(x, 5)
    return 1000 * c500 + 5 * c5
    

if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 3060
inp = input()
a = int(inp.split(" ")[0])
b = int(inp.split(" ")[1])

def gcd(x, y):
    while y:      
        x, y = y, x % y
    return x

def lcm(x, y):
    return int(x * y / gcd(x, y))

print(lcm(a,b))

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()
#define foreach(it,c) for(typeof(c.begin()) it=c.begin();it!=c.end();++it)

const int MAXM = 170;
int main()
{
    int num; cin >> num;
    
    while(num--)
    {
        int p, q; cin >> p >> q;
        int count = 0, seki = 0;
        for(int m = 0; m < MAXM; m++)for(int n = 0; n < MAXM; n++)
        {
            if((m == 1 && n == 0) ||( m == 0 && n == 1)) continue;
            //cout << m << " " << n << endl;
            seki = m * m + n * n;
            if(seki == 0) continue;
            if(seki >= 20000 ) continue;
            if((((m * p + n * q) % seki) == 0) && (((m * q - n * p) % seki) == 0))
            {
                //if((m == abs(p) && (n == abs(q))) || (m == abs(q) && (n == abs(p)) ) )
                if((m == p && n == q) ||
                        (m == -q && n == p) ||
                        (m == -p && n == -q) ||
                        (m == q && n == -p))
                {
                    continue;
                
                    //cout << m << " " << n << endl;    
                }
                count ++;
            }
        }
        if(count>0) cout << 'C' << endl;
        else cout << 'P' << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
using System;
struct Vector
{
    public decimal x;
    public decimal y;
    public Vector(decimal x, decimal y)
    {
        this.x = x;
        this.y = y;
    }
}
class P
{
    static void Main()
    {
        for (; ; )
        {
            try
            {
                string[] s = Console.ReadLine().Split();
                decimal x1, x2, x3, xp, y1, y2, y3, yp;
                x1 = decimal.Parse(s[0]);
                y1 = decimal.Parse(s[1]);
                x2 = decimal.Parse(s[2]);
                y2 = decimal.Parse(s[3]);
                x3 = decimal.Parse(s[4]);
                y3 = decimal.Parse(s[5]);
                xp = decimal.Parse(s[6]);
                yp = decimal.Parse(s[7]);
                Vector a = new Vector(x2 - x1, y2 - y1);
                Vector b = new Vector(x3 - x1, y3 - y1);
                Vector p = new Vector(xp - x1, yp - y1);
                decimal d = a.x * b.y - a.y * b.x;
                decimal k1 = (b.y * p.x - p.y * b.x) / d;
                decimal k2 = (-a.y * p.x + a.x * p.y) / d;
                bool f = 0 < k1 && 0 < k2 && k1 + k2 < 1;
                Console.WriteLine(f ? "YES" : "NO");
            }
            catch
            {
                return;
            }
        }
    }
}


Measured memory_bytes: 9236
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <set>

using namespace std;

int main() {
	int N; cin >> N;
	string s; cin >> s;
	int ans = 0;
	for (int i = 1; i < N; i++) {
		set<int> A, B;
		for (int j = 0; j < i; j++) A.insert(s[j]);
		for (int j = i; j < N; j++) B.insert(s[j]);
		int cnt = 0;
		for (auto x : A) if (B.count(x) == 1) cnt += 1;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<ll> p(N+1);
    rep(i,N+1) p[A[i]]++;
    ll ans = 0;
    rep(i,N+1) {
        if (p[i] > 1) ans += p[i]*(p[i]-1)/2;
    }
    rep(i,N) {
        if (p[A[i]] > 1) cout << ans-(p[A[i]]*(p[A[i]]-1)/2-(p[A[i]]-1)*(p[A[i]]-2)/2) << endl;
        else cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,t,a;
double b;
int ans;
double minc=20000000000;
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>t>>a;
	for(int i=1;i<=n;i++)
	  {
	  	cin>>b;
	  	if(abs(a-(t-b*0.006))<minc)
	  	  minc=abs(a-(t-b*0.006)),ans=i;
	  }
	cout<<ans;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.rmi.server.ExportException;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Main m = new Main();
        m.solve();
    }
    private void solve() throws Exception {
        FastScan scan = new FastScan(System.in);
        int N = scan.scanInt();
        List<List<Path>> graph = new ArrayList(N);
        for (int i = 0; i < N; i++) {
            graph.add(new ArrayList<>());
        }
        for (int i = 0; i < N - 1; i++) {
            int a = scan.scanInt()-1;
            int b = scan.scanInt()-1;
            long c = scan.scanLong();
            graph.get(a).add(new Path(b, c));
            graph.get(b).add(new Path(a, c));
        }
        int Q = scan.scanInt();
        int K = scan.scanInt()-1;
        Queue<Integer> queue = new ArrayDeque<>();
        long[] distances = new long[N];
        boolean[] visited = new boolean[N];
        queue.add(K);
        while(!queue.isEmpty()) {
            int current = queue.poll();
            visited[current] = true;
            for (Path p : graph.get(current)) {
                if (visited[p.to]) {
                    continue;
                }
                distances[p.to] = distances[current] + p.cost;
                queue.add(p.to);
            }
        }
        for (int i = 0; i < Q; i++) {
            int from = scan.scanInt() - 1;
            int to = scan.scanInt() - 1;
            System.out.println(distances[from] + distances[to]);
        }
    }

    class Path {
        int to;
        long cost;
        Path(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }
    }
    class FastScan {
        BufferedReader br;
        StringTokenizer st;
        FastScan(InputStream is) {
            InputStreamReader isr = new InputStreamReader(is);
            this.br = new BufferedReader(isr);
        }
        String next() throws IOException {
            while (this.st == null || !this.st.hasMoreTokens()) {
                this.st = new StringTokenizer(br.readLine().trim());
            }
            return st.nextToken();
        }
        long scanLong() throws IOException {
            return Long.parseLong(this.next());
        }
        int scanInt() throws IOException {
            return Integer.parseInt(this.next());
        }
        double scanDouble() throws IOException {
            return Double.parseDouble(this.next());
        }
        char scanCharacter() throws IOException {
            return this.next().charAt(0);
        }
        String nextLine() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 82252
#include <stdio.h>
#include <math.h>
int main(){
    int i,ban,n,s,kei;
    scanf("%d",&n);
    for(ban=1;ban<=n;ban++){
        scanf("%d",&s);
        printf("Case %d:\n",ban);
        for(i=1;i<=10;i++){
            s = s*s;
            s=s/100;
            if(s>10000){
                s=s%10000;
            }
            printf("%d\n",s);
        }
    }
    return 0;
}

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	long long r, d, x, i;
	cin >> r >> d >> x;
	for (i = 0; i < 10; i++) {
		x = r * x - d;
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
numbers = gets.split(" ").map(&:to_i)
# 箱にボールを入れる時にメモをする
memo = Array.new(n, 0)
answers = []
# 上から順番に箱に入れる
n.downto(1) do |i|
  tmp = 1
  count = 0
  # ボールが入っている箱を下から順に数え、countに加算する
  # ex. i が 3 なら、3, 6, 9, 12...の箱を全て調べる
  while tmp * i <= n
    count += memo[tmp * i - 1]
    tmp += 1
  end
  # count を 2 で割り、余りが箱に書かれた整数と一致しない場合はボールを入れる
  if count % 2 != numbers[i - 1]
    answers << i
    memo[i - 1] += 1
  end
end
puts answers.size
puts answers.join(" ") if answers.size != 0

Measured memory_bytes: 22076
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int main(void) {
  long long int n, m;
  scanf("%lld %lld", &n, &m);

  long long int ans;
  if (n == 1 && m == 1) ans = 1;
  else if (n == 1) ans = m - 2;
  else if (m == 1) ans = n - 2;
  else ans = (n - 2) * (m - 2);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[] a=new int[n];
	long sum=0;
	for(int i=0;i<n;i++){
	    a[i]=sc.nextInt();
	    sum+=a[i];
	}
	int max=a[0];
	int min=a[0];
	for(int i=1;i<n;i++){
	    if(a[i]>=max){
		max=a[i];
	    }
	    if(a[i]<=min){
		min=a[i];
	    }
	}
	System.out.println(min+" "+max+" "+sum); 
    
    
    }
}


Measured memory_bytes: 42360
/*
 * ----------------------------------------------------------------------------
 (: Bismillahir Rahmanir Rahim :) 
 * File: /root/Programming/Atcoder/B_Popular_Vote.cpp
 * Project: /root/Programming/Atcoder
 * Created Date: Saturday, April 4th 2020, 6:06:14 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Sat Apr 04 2020
 * Modified By: Grim Firefly :)
 * -----
 * ----------------------------------------------------------------------------
 */

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

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;

//defined for loop

// defined for taking input
#define gl(x) getline(cin, x)
#define sf scanf
#define sfi(x) sf("%d", &x)
#define sfc(x) sf("%c", &x)
#define sfl(x) sf("%lld", &x)
#define sflu(x) sf("%llu", &x)
#define sfii(x, y) sf("%d %d", &x, &y)
#define sfll(x, y) sf("%lld %lld", &x, &y)
#define sfiii(x, y, z) sf("%d %d %d", &x, &y, &z)
#define sflll(x, y, z) sf("%lld %lld %lld", &x, &y, &z)

//defined for printing
#define pf printf
#define pfn pf("\n")
#define pfcas pf("Case %d: ", cas)
#define pfyes pf("YES")
#define pfno pf("NO")
#define pfi(x) pf("%d", x)
#define pfl(x) pf("%lld", x)

//Defined for loop
//increament
#define loopi(i, j, k) for (int i = j; i < k; i++)
#define loopl(i, j, k) for (ll i = j; i < k; i++)
#define loopc(i, j, k) for (char i = j; i < k; i++)
#define looplu(i, j, k) for (ull i = j; i < k; i++)
//decreament
#define loopri(i, j, k) for (int i = j; i > k; i--)
#define looprl(i, j, k) for (ll i = j; i > k; i--)
#define looprlu(i, j, k) for (ull i = j; i > k; i--)
#define looprc(i, j, k) for (char i = j; i > k; i--)
#define wa(t) while (t--)

//testcases
#define testc(t) for (char cas = 1; cas <= t; cas++)
#define testi(t) for (int cas = 1; cas <= t; cas++)
#define testl(t) for (ll cas = 1; cas <= t; cas++)

//some cmd
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define SZ 10000

//Main Function Start

int main()
{
    int n, m;
    sfii(n, m);
    int ara[n];
    int sum = 0;
    loopi(i, 0, n)
    {
        sfi(ara[i]);
        sum += ara[i];
    }
    sort(ara, ara + n, greater<int>());
    sum = ceil((double)sum / (4.0 * m));
    loopi(i, 0, n)
    {
        if (ara[i] >= sum)
        {
            m--;
        }
    }
    pf(m <= 0 ? "Yes\n" : "No\n");

    return 0;
}

Measured memory_bytes: 256
#include<unordered_map>
#include<iostream>
#include<algorithm>
#include<utility>
#include<climits>
#include<fstream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<list>
#include<map>
#include<set>
#define inf 0x7f7f7f
#define p(x) (x)*(x)
using namespace std;

typedef vector<vector<int> > vtype;
typedef long long ll;
ll *a = nullptr;

int main()
{
	//ios::sync_with_stdio(false);
	ll h = 0, sum = 0, num = 1;
	cin >> h;
	while(h != 1){
		sum += num;
		num *= 2;
		h /= 2;
	}
	sum = sum + num;
	cout << sum << endl;
    return 0;
}















Measured memory_bytes: 256
import sys

if __name__ == '__main__':
    N, K = map(int, sys.stdin.readline().split())
    S = input()
    ans = 0
    for i in range(N-1):
        if S[i] == S[i+1]:
            ans += 1
    ans = min(N-1, ans+K*2)
    print(ans)


Measured memory_bytes: 39408
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll cost[MAX];
vector< pair <ll,int> >graph[MAX];
void dijkstra(int src)
{
    priority_queue< pair<int,int> >q;
    q.push(make_pair(0,src));
    cost[src]=0;
    while(!q.empty())
    {
        ll parents_money=q.top().first*-1;
        int parent=q.top().second;
        q.pop();
        for(int i=0; i<graph[parent].size(); i++)
        {
            ll childs_money=graph[parent][i].first;
            int child=graph[parent][i].second;
            if(cost[child]==-1 || cost[child]>childs_money+cost[parent])
            {
                cost[child]=childs_money+cost[parent];
                q.push(make_pair(-1*cost[child],child));
            }
        }
    }
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    memset(cost,-1,sizeof(cost));
    int n;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v,c;
        cin>>u>>v>>c;
        graph[u].push_back({c,v});
        graph[v].push_back({c,u});
    }
    int q,k;
    cin>>q>>k;
    dijkstra(k);
    while(q--)
 {
     int x,y;
     cin>>x>>y;
     cout<<cost[x]+cost[y]<<endl;
 }
    return 0;
}


Measured memory_bytes: 40728
#include <stdio.h>
int main(){
	int A, B, C, restin;
	scanf("%d %d", &A, &B);
	if((A == 1 && B == 3) || (A == 3 && B == 1) || (A == 1 && B == 1) || (A == 3 && B == 3))
		printf("Yes\n");
	else
		printf("No\n");
	
return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i < (int)(n); i++)
typedef long long ll;
#define NP next_permutation
#define MP make_pair

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  string s;
  cin >> s;
  int l = s.size();

  int a = 0;
  rep(i,l){
    if(i % 2 == 0){
      if(s[i] == '0') a++;
    }
    else{
      if(s[i] == '1') a++;
    }
  }

  int b = 0;
  rep(i, l){
    if(i % 2 == 1){
      if(s[i] == '0') b++;
    }
    else{
      if(s[i] == '1') b++;
    }
  }
  int ans = min(a, b);
  cout << ans << endl;
}




Measured memory_bytes: 512
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = INT()
B = INT()
C = INT()
X = INT()

ans = 0
for i in range(min(X//500 + 1, A+1)):
	for j in range(min((X - 500*i )//100 + 1 , B+1)):
		if (X - 500*i - 100*j)//50 <= C:
			ans += 1

print(ans)

Measured memory_bytes: 5396
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int MAX_N = 200000;
int Par[MAX_N],Rank[MAX_N] = {},Amount[MAX_N];
int N;
void init(){
  int i;
  for(i=0;i<N;i++){
    Par[i] = i;
    Amount[i] = 1;
  }
}
int find(int x){//根元探し
  if(Par[x] == x) return x;
  else{
    Par[x] = find(Par[x]);
    Amount[x] = Amount[Par[x]];
    return Par[x];
  }
}
int amount(int x){//xが含まれる木の頂点の数
  find(x);
  return Amount[x];
}
bool unite(int x,int y){//結合
  x = find(x);y = find(y);
  if(x == y) return false;//すでに同じ木ならばfalse
  if(Rank[x] < Rank[y]) swap(x,y);
  Par[y] = x;
  Amount[x] += Amount[y];
  if(Rank[x] == Rank[y]) Rank[x]++;
  return true;
}
bool same(int x,int y){//同じ木に含まれているか
  return find(x) == find(y);
}
int main(){
  int M,i,a,b;scanf("%d%d",&N,&M);
  init();
  for(i=0;i<M;i++){
    scanf("%d%d",&a,&b);a--;b--;
    unite(a,b);
  }
  int ans = 0;
  for(i=0;i<N;i++){
    if(find(i) != i) continue;
    ans = max(ans,amount(i));
  }
  printf("%d\n",ans);
}

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

  // auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  
  // 3 2
  // 1 1 1
  // 0 2 1
  // 0 3 0
  // → 0 と 0以外の組み合わせは
  // 0 0 X ... 1
  // 0 X 0 ... 1
  // X 0 0 ... 1
  // 0 X X ... 2
  // X 0 X ... 2
  // X X 0 ... 2
  // X X X ... 1
  
  // 0の個数を i とすると
  // → nCi x ???

  // 0 0 (111)
  // 0 (111) 0 ... 1
  // (111) 0 0 ... 1
  // 0 (11) (1) ... 2
  // 0 (1) (11) ... 2
  // (11) 0 (1) ... 2
  // (1) 0 (11) ... 2
  // (11) (1) 0 ... 2
  // (1) (11) 0 ... 2
  // (1) (1) (1) ... 1
  // → 0の個数が i のとき、0以外の個数は (n-i)
  // → (n-i) 個の部屋に 1以上を割り当てて、和が n になるようにしたい
  // 0 () () ← 3こいれたい
  // () には必ず 1 が一個以上ははいるので
  // 0 (1) (1) ← 1個いれたい
  //           ← n-(n-i) 個入れたい
  // ということになる。
  // 0 (1) (1) に n-(n-i) 個入れる comb は、
  // 2つの箱に 1 を 1個入れる組み合わせなので、 2 になる。
  // もし、4つの箱に、2個入れる場合
  // 11|||1       1 の個数=n-(n-i), 仕切りの個数=0以外の個数-1= (n-i)-1
  // n-(n-i)+(n-i)-1 C n-(n-i) という組み合わせを求めれば良い
  

  k = min(n-1,k);
  combination c(n);
  mint ans;
  rep(i, 0, k+1) {
    ans += c(n,i) * c(n-1, i);
  }
  
  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int main() {
    int a, b;
    string c;
    while(true) {
        cin >> a >> c >> b;
        if(c == "+")        cout << a+b << endl;
        else if(c == "-")   cout << a-b << endl;
        else if(c == "*")   cout << a*b << endl;
        else if(c == "/")   cout << a/b << endl;
        else if(c == "?")   break;
    }

    return 0;
}


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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n;
  cin >> n;
  vector<int> a(n+1);
  vector<int> b(n);
  
  ll a_total = 0;
  rep(i, n+1) {
    int at;
    cin >> at;
    a[i] = at;
    a_total += at;
  }
    
  rep(i, n) cin >> b[i];
  
  rep(i, n) {
    if(a[i] + a[i+1] <= b[i]) {
      a[i] = 0;
      a[i+1] = 0;
    }
    else {
      if(a[i] <= b[i]) {
        a[i+1] -= (b[i]-a[i]);
        a[i] = 0;
      }
      else {
        a[i] = a[i]-b[i];
      }
    }
  }
  ll a_remain = 0;
  rep(i, n+1) a_remain += a[i];
  ll ans = a_total - a_remain;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    int A[3]; for (int i = 0; i < 3; ++i) cin >> A[i];
    sort(A, A+3, greater<int>());
    cout << (A[0] - A[1] + A[1] - A[2]) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

struct Edge{
    int from, to, cost;
};

long long d[100005];
vector<vector<Edge>> G;

int dfs(int crt) {
    for (int i = 0; i < G[crt].size(); i++) {
        Edge e = G[crt][i];
        if (d[crt] + e.cost < d[e.to]) {
            d[e.to] = d[crt] + e.cost;
            dfs(e.to);
        }
    }
    return 0;
}

int main(void) {
    int N; cin >> N;
    G = vector<vector<Edge>> (N+5);
    long long INF = 10000000000000000;
    for (int i = 0; i <= N; i++) {
        d[i] = INF;
    }
    for (int i = 0; i < N-1; i++) {
        int a, b, c; cin >> a >> b >> c;
        Edge e1 = {a, b, c};
        Edge e2 = {b, a, c};
        G[a].push_back(e1);
        G[b].push_back(e2);
    }

    d[1] = 0;
    dfs(1);
    vector<int> ans(N+1);
    for (int i = 1; i <= N; i++) {
        if (d[i] % 2 == 0) {
            ans[i] = 1;
        }
    }
    for (int i = 1; i <= N; i++) {
        cout << ans[i] << endl;
    }
}   




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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n+1,0);
    for(int i=1;i<=n;i++) for(int j=i;j<=n;j+=i) v[j]++;
    ll res=0;
    for(ll i=1;i<=n;i++) res+=(i*v[i]);
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 42268
#include <iostream>
using namespace std;
int main() {
	char x[3];
  	char y[3];
 	int ok = 0;
    cin >> x[0] >> x[1] >> x[2];
 	cin >> y[0] >> y[1] >> y[2];
  	for(int i = 0; i<3; i++){    	
		if(x[i] == y[i]) ok++;
    }
	cout << ok << endl;
}

Measured memory_bytes: 256
import java.awt.geom.Point2D;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;

public class Main {
    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        int inp_num = Integer.parseInt(sc.next());
        HashMap<String, Integer> m = new HashMap<String, Integer>();
        for (int i = 0; i < inp_num; i++) {
            String s = sc.next();
            if (m.containsKey(s)) {
                m.put(s, m.get(s) + 1);
            } else {
                m.put(s, 1);
            }
        }
        int ma = -1;
        ArrayList<String> candidates = new ArrayList<>();
        for (Entry<String, Integer> ent : m.entrySet()) {
            if(ma == ent.getValue()){
                candidates.add(ent.getKey());
            }else if(ma < ent.getValue()){
                candidates.clear();
                ma = ent.getValue();
                candidates.add(ent.getKey());
            }
      }
      Collections.sort(candidates);
      for(String can : candidates){
        System.out.println(can);
      }
  }
}

Measured memory_bytes: 82676
# union findでの実装
class UnionFind:
    # 親要素のノード番号を格納。par[x] == xの時そのノードは根
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
    
    # 検索
    def find(self, x):
        # 根ならその番号を返す
        if self.par[x]==x:
            return x
        # 根でないなら親の要素で再検索、走査していく過程で親を書き換える
        else:
            self.par[x] =  self.find(self.par[x])
            return self.par[x]
    
    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x)==self.find(y)
    
    #  併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        # 木の高さを比較し、低い方から高い方へ辺を貼る
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
        # 木の高さが同じなら片方を1増やす
            if self.rank[x]==self.rank[y]:
                self.rank[x] += 1

                
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
ans = 0
for i in range(M):
    graph = UnionFind(N)
    for edge in edges:
        if edge==edges[i]:
            continue
        else:
            graph.union(*edge)
    par = [graph.par[i+1]==i+1 for i in range(N)]
    if par.count(True)==1:
        continue
    else:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyg"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYG";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,K,Q;
  cin>>N>>K>>Q;
  vl a(Q);
  rep(i,Q) cin>>a[i];
  vl score(N,0);
  string ans[N];
  for(int i=0;i<Q;i++){
    score[a[i]-1]++;
  }
  for(int i=0;i<N;i++){
    if(K+score[i]-Q>0){
      ans[i]="Yes";
    }
    else{
      ans[i]="No";
    }
  }
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 7988
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#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 = 998244353;
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;
	ll k = 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 a[2000];
signed main() {
	int n;
	cin >> n;
	int a[2000], b[2000];
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	ld ans1 = 0, ans2 = 0, ans3 = 0, ans4 = 0;
	for (int i = 0; i < n; i++) {
		ans1 += pow(abs(a[i] - b[i]), 1);
		ans2 += pow(abs(a[i] - b[i]), 2);
		ans3 += pow(abs(a[i] - b[i]), 3);
		ans4 = max(ans4, (ld)abs(a[i] - b[i]));
	}
	ans1 = pow(ans1, 1);
	ans2 = pow(ans2, (1.0 / 2));
	ans3 = pow(ans3, (1.0 / 3));
	printf("%.20LF\n%.20LF\n", ans1, ans2);
	printf("%.20LF\n%.20LF\n", ans3, ans4);
}


Measured memory_bytes: 3472
# coding: utf-8
# Your code here!
n,m = list(map(int,input().split()))

k = []
for _ in range(m):
    k.append(list(map(int,input().split())))

k.sort(key=lambda x:x[1])

#print(k)
l=0
ans = 0
for i in range(m):
#    print(l,k[i][0])
    if l <= k[i][0]:
        ans += 1
        l = k[i][1]
    
    
print(ans)


Measured memory_bytes: 29732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second

ll mod = 1e9+7;

ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		string s; cin>>s;
		ll ans = 0;
		if(s.compare("RRR")==0) ans = 3;
		else if(s.compare("RRS")==0) ans = 2;
		else if(s.compare("RSR")==0) ans = 1;
		else if(s.compare("SRR")==0) ans = 2;
		else if(s.compare("RSS")==0) ans = 1;
		else if(s.compare("SRS")==0) ans = 1;
		else if(s.compare("SSR")==0) ans = 1;
		else if(s.compare("SSS")==0) ans = 0;

		cout<<ans;
 	}	
	return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k;
  cin >> s;
  if (s.at(k-1)=='A') s.at(k-1)='a';
  if (s.at(k-1)=='B') s.at(k-1)='b';
  if (s.at(k-1)=='C') s.at(k-1)='c';
  cout << s << endl;
}

Measured memory_bytes: 256
N = list(map(int, input().split()))
ans = [1, 4, 7, 9]
N.sort()
flag = True
for i in range(4):
    if(ans[i] == N[i]):
        continue
    else:
        flag = False
        break

if(flag):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli n;
    string s;
    cin >> n >> s;
    if(n%2!=0){
        cout << "No" << endl;
        return 0;
    }
    else{
        rep(i,n/2){
            if(s[i]!=s[i+n/2]){
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void read(int &x){
	scanf("%d",&x);
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0'); 
}
int n,a[200004],sub[200004];
vector<int>g[200004],v[200004];
ll ans[200004];
int ans1[200004],res[200004];
void dfs(int x,int par){
	sub[x]=1;
	for (int i=0;i<g[x].size();i++)if(g[x][i]!=par)
		dfs(g[x][i],x),sub[x]+=sub[g[x][i]];
}
void dfs1(int x,int par){
	if (v[a[x]].empty()) ans1[a[x]]-=sub[x];
	else res[v[a[x]][v[a[x]].size()-1]]-=sub[x];
	for (int i=0;i<g[x].size();i++) if (g[x][i]!=par){
		v[a[x]].push_back(g[x][i]);
		dfs1(g[x][i],x);
		ans[a[x]]+=1ll*res[g[x][i]]*(res[g[x][i]]+1)/2;
		v[a[x]].pop_back(); 
	}
}
int x,y;
ll A;
int main(){
	read(n),A=1ll*n*(n+1)/2;
	for (int i=1;i<=n;i++) read(a[i]),ans1[i]=n;
	for (int i=1;i<n;i++)read(x),read(y),g[x].push_back(y),g[y].push_back(x); 
	dfs(1,-1);
	for (int i=1;i<=n;i++) res[i]=sub[i];
	dfs1(1,-1);
	for (int i=1;i<=n;i++){
		ll res=A-ans[i]-1ll*ans1[i]*(ans1[i]+1)/2;
		write(res),puts("");
	}
}

Measured memory_bytes: 43448
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <functional>
#include <stdio.h>
#include <string.h>
using namespace std;

struct Graph {
    struct Edge {
        int d, i;
    };
    Graph(int n) : n(n), e(n), d(n, vector<int>(n, 1 << 29)) {
        for (int i = 0; i < n; i++) d[i][i] = 0;
    }
    void add_edge(int i, int j, int l) {
        e[i].push_back({ l, j });
        d[i][j] = l;
    }
    void warshall_floyd() {
        for (int k = 0; k < n; k++)
            for (int i = 0; i < n; i++)
                for (int j = 0; j < n; j++)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    }
    int abc051_d() {
        int k = 0;
        warshall_floyd();
        for (int i = 1; i < n; i++) {
            for (auto o : e[i]) {
                if (o.i < i && d[i][o.i] < o.d) k++;
            }
        }
        return k;
    }
    vector<vector<Edge>> e;
    vector<vector<int>> d;
    int n;
};

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

    int n, m;
    cin >> n >> m;
    Graph g(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        g.add_edge(a, b, c);
        g.add_edge(b, a, c);
    }

    cout << g.abc051_d() << endl;

    return 0;
}

Measured memory_bytes: 384
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function solve(N, M, A)

MOD = 1000000007
steps = fill(true, N)


for a in A
    steps[a] = false
end


dp = zeros(Int, N)

if steps[1]
    dp[1] = 1
    if steps[2]
        dp[2] = 2
    end
else
    if steps[2]
        dp[2] = 1
    end
end


for i in 3:N
    if (steps[i]) 
        dp[i] = (dp[i-2] + dp[i-1]) % MOD
    end
end

println(dp[N])

end

N, M = parseMap(split(readline()))
A = [parseInt(readline()) for _ in 1:M]

if N == 1
    println(1)
else
    solve(N, M, A)
end

Measured memory_bytes: 172136
using Microsoft.CSharp.RuntimeBinder;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.C
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var (N, M, K) = Read3Longs();

            var A = ReadLongs();
            var ruisekiA = new long[N + 1];
            for (int i = 0; i <= N; i++)
            {
                // 0冊の場合も考慮
                ruisekiA[i] = i == 0 ? 0 : (ruisekiA[i - 1] + A[i - 1]);
            }

            var B = ReadLongs();
            var ruisekiB = new long[M + 1];
            for (int i = 0; i <= M; i++)
            {
                // 0冊の場合も考慮
                ruisekiB[i] = i == 0 ? 0 : (ruisekiB[i - 1] + B[i - 1]);
            }

            var maxCount = 0L;
            for (int aCount = 0; aCount <= N; aCount++)
            {
                // はなから読み切れない場合
                if (ruisekiA[aCount] > K) continue;

                // 二分探索
                var l = 0;
                var r = (int)M;
                int bCount;
                while (true)
                {
                    bCount = (r + l) / 2;

                    if (ruisekiA[aCount] + ruisekiB[bCount] <= K)
                    {
                        l = bCount;
                    }
                    else
                    {
                        r = bCount;
                    }

                    if (r - l == 1)
                    {
                        if (ruisekiA[aCount] + ruisekiB[r] <= K)
                        {
                            bCount = r;
                            break;
                        }
                        else
                        {
                            bCount = l;
                            break;
                        }
                    }
                }

                maxCount = Math.Max(maxCount, aCount + bCount);
            }

            return maxCount;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 73284
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a,c;
  string b;
  cin>>a>>b>>c;
  for(int i=0;i<a;i++){
    if(b.at(i)!=b.at(c-1))
      b.at(i)='*';
  }
  cout<<b<<endl;
}


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

int main(){
  int n;
  std::cin >> n;
  std::vector<int> d;
  int temp;
  while(std::cin >> temp)
    d.push_back(temp);
  long rec = 0;
  for(int i=0; i<n; ++i){
    for(int j=i+1; j<n; ++j)
      rec += d[i]*d[j];
  }
  std::cout << rec << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int x,i;
 
    i = 0;
 
while(i < 10000)
{
    i = i + 1;
    scanf("%d",&x);
    if(x == 0)break;
    printf("Case %d: %d\n",i,x);
}
 
return 0;
 
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    int n;cin>>n;
    vector<int> a(n);rep(i,n)cin>>a[i];
    ll sum=1000;
    for(int i =0;i<n-1;i++){
        int dif =a[i+1]-a[i];
        if(dif>0){
            ll x = sum/a[i];
            sum+=dif*x;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3556
def waru(a):
    ans = 0
    for _ in range(a):
        if a %2 ==0:
            a = a//2
            ans+=1
        else:
            break
    return ans
n=int(input())
A =list(map(int,input().split()))
B = [waru(A[i]) for i in range(n)]
print(sum(B))



Measured memory_bytes: 4148
#include <stdio.h>

int main(void) {
  int i, a, max = 0, sum = 0;
  for(i = 0; i < 3; ++i) {
    scanf("%d", &a);
    sum += a;
    if(max < a) max = a;
  }
  printf("%s", sum == max * 2 ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

struct UnionFind {
    vector<int> rnk, par, df_dist;

    UnionFind(int N) : rnk(N), par(N), df_dist(N) {
        for (int i = 0; i < N; ++i)
            par[i] = i;
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            int r = root(par[x]);
            df_dist[x] += df_dist[par[x]];
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    // dist(x) + dist(x, y) = dist(y)
    ll dist(int x, int y) {
        root(x), root(y);
        return df_dist[y] - df_dist[x];
    }

    // dist(x, y) = d
    void unite(int x, int y, int d) {
        int bx = x, by = y;
        x = root(x), y = root(y);
        d += df_dist[bx] - df_dist[by];
        if (x == y)
            return;
        if (rnk[x] < rnk[y])
            swap(x, y), d = -d;
        if (rnk[x] == rnk[y])
            rnk[x]++;
        par[y] = x;
        df_dist[y] = d;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;

    UnionFind uf(N);
    bool isok = true;
    for (int i = 0; i < M; ++i) {
        int L, R, D;
        cin >> L >> R >> D;
        L--, R--;
        if (isok) {
            if (uf.issame(L, R)) {
                isok &= (uf.dist(L, R) == D);
                continue;
            }
            uf.unite(L, R, D);
        }
    }

    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <stdio.h>
#include <string>
#include <cctype>
using namespace std;

int main() {
    string number;
    int num;
    int result;
    while(1) {
        cin >> number;
        if (number == "0") break;

        result = 0;
        for (int i = 0; i < number.size(); i++) {
            num = number[i] - '0';
            result += num;
        }
        cout << result << endl;
    }
    return 0;
}

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

int n, a, ans;

int main() {
  cin >> n;
  ans = 1;
  rep (i, n) {
    cin >> a;
    ans *= 2 - a%2;
  }
  ans = pow(3, n) - ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3944