akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>

using namespace std;
 
int main(){
	
	int N, M;
    cin >> N >> M;
    
    int sum = 0;
    int maxs = 0;
    
    for(int i=0;i<M;i++){
    int a, b;
    cin >> a >> b;
    
    if(a >= N)
	continue;
	
    sum += (N-a);
    maxs = max(maxs, N-a);  
	  
  }
  cout << sum - maxs << "\n";
  return 0;
}


Measured memory_bytes: 3076
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int W = stdIn.nextInt();
		int H = stdIn.nextInt();
		int N = stdIn.nextInt();
		boolean[][] P = new boolean[W][H];
		
		for(int i = 0; i < N; i++) {
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			int a = stdIn.nextInt();
			if(a == 1) {
				for(int j = 0; j < x; j++) {
					Arrays.fill(P[j], true);
				}
			}
			else if(a == 2) {
				for(int j = x; j < W; j++) {
					Arrays.fill(P[j], true);
				}
			}
			else if(a == 3) {
				for(int j = 0; j < y; j++) {
					for(int k = 0; k < W; k++) {
						P[k][j] = true;
					}
				}
			}
			else if(a == 4) {
				for(int j = y; j < H; j++) {
					for(int k = 0; k < W; k++) {
						P[k][j] = true;
					}
				}
			}
		}
		
		int ans = 0;
		for(int i = 0; i < W; i++) {
			for(int j = 0; j < H; j++) {
				if(!P[i][j]) {
					ans++;
				}
			}
		}
		System.out.println(ans);

	}

}

Measured memory_bytes: 23252
with Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;
 use Ada.Text_IO, Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure main is
   A: Integer;
   B: Integer;
   C: Integer;
begin
   get(A);
   get(B);
   get(C);
   if (A = B and then B /= C) then put_line("Yes");
   elsif (B = C and then C /= A) then put_line("Yes");
   elsif (A = C and then C /= B) then put_line("Yes");
   else put_line("No");
   end if;
end main;

Measured memory_bytes: 3672
// header {{{
using namespace std;

// C++
#include <algorithm>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>

#pragma GCC optimization_level 3

// util {{{
#define print(x)	        cout << (x)
#define printvec(x)       for(int i = 0;i < (x).size();i++)cout << (x).at(i) << " ";cout << endl
#define println(x)	        cout << (x) << endl
#define printn		        cout << endl
#define read(x)	            cin >> (x)
#define readvec(x)        for(int i = 0; i < (x).size();i++)cin >> (x).at(i)

#define rep(i, n)	        for(int i = 0; i < (int)(n); i++)
#define rep_1(i, n) 	    for(int i = 1; i <=(int)(n); i++)

#define all(x) 		        (x).begin(),(x).end()
#define vint                vector<int>
#define outif(x,y,z)        if(x) cout<<(y)<<endl; else cout<<(z)<<endl
#define loop 		        while(true)

// }}}

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

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

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

void solve() {
    int W,H,x,y,r;
    read(W);
    read(H);
    read(x);
    read(y);
    read(r);
    outif(x-r >= 0 && x+r <= W && y-r >= 0 && y + r <= H,"Yes","No");
}

signed main() {
    solve();
    return 0;
}


Measured memory_bytes: 3180
#include <cstdio>
#include <utility>
#include <cmath>
#define MAX 100

int main(void)
{

    int n;
    std::pair<double, double> point[MAX];

    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i)
    {
        scanf("%lf %lf", &point[i].first, &point[i].second);
    }

    double ans = 0;
    for(int i = 0 ; i < n ; ++i)
    {
        if(i + 1 == n)
        {
            ans += (point[i].first - point[0].first) * (point[i].second + point[0].second);
        }else
        {
            ans += (point[i].first - point[i + 1].first) * (point[i].second + point[i + 1].second);
        }
    }
    printf("%.1lf\n", ans / 2);

    return 0;
}

Measured memory_bytes: 1092
a = int(input())
b = int(input())

if a == 1 and b == 2:
    print(3)
elif a == 1 and b == 3:
    print(2)
elif a == 2 and b == 1:
    print(3)
elif a == 2 and b == 3:
    print(1)
elif a == 3 and b == 1:
    print(2)
elif a == 3 and b == 2:
    print(1)


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
struct Element{
    long long v;
    int p;
};
Element b[300005];
long long bitCl[300005], bitCr[300005];
long long bitVl[300005], bitVr[300005];
long long a[300005];
int smallP[300005], bigP[300005];

void preWork(int n){
    std::sort(b+1,b+1+n,[&](Element& u,Element& v){
        return u.v<v.v;
    });
    for(int i = 1; i <= n; i++){
        smallP[b[i].p] = i;
        bigP[b[i].p] = n-i+1;
    }
}

void change(int p,long long v,int n,long long bit[]){
    while(p<=n){
        bit[p] += v;
        p += p&-p;
    }
}

long long ask(int p,long long bit[]){
    long long res = 0;
    while(p!=0){
        res += bit[p];
        p -= p&-p;
    }
    return res;
}

long long getFirstK(int k,int n,long long bitC[],long long bitV[]){
    int L = 0, R = n;
    int res = -1;
    while(L<=R){
        int M = (L+R)/2;
        if(ask(M,bitC)>=k){
            res = M;
            R = M-1;
        }
        else L = M+1;
    }
    return ask(res,bitV);
}

int main(){
    int n;
    scanf("%d",&n);
    for(int i = 1; i <= 3*n; i++){
        scanf("%lld",&a[i]);
        b[i].v = a[i], b[i].p = i;
    }
    preWork(3*n);
    long long sumL = 0, sumR = 0;
    for(int i = 1; i <= n-1; i++){
        change(smallP[i],1,3*n,bitCl);
        change(smallP[i],a[i],3*n,bitVl);
        sumL += a[i];
    }
    for(int i = n; i <= 3*n; i++){
        change(bigP[i],1,3*n,bitCr);
        change(bigP[i],a[i],3*n,bitVr);
        sumR += a[i];
    }
    //printf("done\n");
    //update first
    long long inf = 1e18+7;
    long long answer = -inf;
    for(int i = n; 3*n-i>=n; i++){
        change(smallP[i],1,3*n,bitCl);
        change(smallP[i],a[i],3*n,bitVl);
        sumL += a[i];
        change(bigP[i],-1,3*n,bitCr);
        change(bigP[i],-a[i],3*n,bitVr);
        sumR -= a[i];
        long long minusL = getFirstK(i-n,3*n,bitCl,bitVl);
        long long minusR = getFirstK(2*n-i,3*n,bitCr,bitVr);
        long long offer = sumL-minusL-(sumR-minusR);
        if(answer<offer) answer = offer;
    }
    printf("%lld\n",answer);
    return 0;
}


Measured memory_bytes: 20416
function Main(input) {
  var line = input.split(' ');
  var a = line[0];
  var b = line[1];
  var c = a * b;
  if (c % 2 === 1) {
    console.log('Odd');
  } else {
    console.log('Even');
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7496
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a%mod; a = a * a%mod; }return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
// head

int N, T;
vector<ll> a, b;
vi idx;
vector<ll> dp[2];
vector<ll> sum;

bool cmp(const int i, const int j)
{
	if (a[i] == 0 && a[j] == 0) return b[i] < b[j];
	return ((double)(a[i]) / (b[i] + 1)) > ((double)(a[j]) / (b[j] + 1));
}

//#define DDD
int main()
{
	cin >> N >> T;
	a.resize(N);
	b.resize(N);
	rep(i, 0, N)
	{
		cin >> a[i] >> b[i];
	}

	idx.resize(N);
	iota(all(idx), 0);
	sort(all(idx), cmp);

	dp[0].resize(N + 1);
	dp[1].resize(N + 1);
	fill(all(dp[0]), LLONG_MAX);
	fill(all(dp[1]), LLONG_MAX);
	dp[0][0] = 0;
	dp[1][0] = 0;
	int maxcnt = 1;

	sum.push_back(0);
	rep(ii, 1, N + 1)
	{
		int i = idx[ii - 1];
		if (a[i] == 0) {
			int sz = sum.size() - 1;
			sum.push_back(b[i]+1 + sum[sz]);
		}
		else {
			rep(cnt, 1, N + 1)
			{
 				if (dp[0][cnt - 1] == LLONG_MAX) break;
				dp[1][cnt] = min(dp[0][cnt - 1] + 1 + a[i] * (dp[0][cnt - 1] + 1) + b[i], dp[0][cnt]);
				if (dp[1][cnt] > T) break;
			}
			dp[0].swap(dp[1]);                       
		}
	}

	int ans = 0;
	rep(cnt, 0, N + 1)
	{
		if (dp[0][cnt] <= T) {
			int TT = T - dp[0][cnt];
			int it = upper_bound(all(sum), TT) - sum.begin() - 1;
			if (cnt + it > ans) ans = cnt + it;
		}
		else {
			break;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9460
fun main(args:Array<String>) {
    val (a,b,k) = readLine()!!.split(" ").map { it.toLong() }
    val lastA = Math.max(a-k, 0)
    val remain = if(lastA > 0) 0 else k - a
    val lastB = Math.max(b - remain, 0)
    println("%s %s".format(lastA, lastB))
}



Measured memory_bytes: 37424
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    rep(i, 10){
        x = r*x-d;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,a,b,cnt = 0;
    int x[2020]={0};
    scanf("%d",&n);
    for(int i=1;i<n+1;i++){
        scanf("%d",&b);
        x[b]=i;
    }
    scanf("%d",&m);
    for(int i=0;i<m;i++){
        scanf("%d",&a);
        for(int i=0;i<2020;i++){
        if(x[i]==a){
                if(x[i+1]==0 || x[i+1]=='\0'){
//                    printf("切替　count=%d\n",i);
                    x[i]=0;
                    x[i+1]=a;
                    break;
                }
            }
        }
    }
//    for(int i=1;i<2020;i++){
//        printf("%d ",x[i]);
//        if(i%20==0){
//            printf("\n");
//        }
//    }
    for(int i=1;i<n+1;i++){
        for(int t=0;t<2020;t++)
            if(x[t]==i){
                printf("%d\n",t);
                break;
            }
        }
    return 0;
}


Measured memory_bytes: 2120
#include <stdio.h>

const long long mod = 1000000007;
const long long inv2 = (mod + 1) / 2;

int N,Q,A[3030],C[3030][3030];

int main()
{
	scanf ("%d %d",&N,&Q);

	for (int i=1;i<=N;i++) scanf ("%d",&A[i]);
	for (int i=1;i<=N;i++) for (int j=1;j<=N;j++) C[i][j] = A[i] > A[j];

	long long mul = 1;
	for (int q=1;q<=Q;q++){
		int x,y; scanf ("%d %d",&x,&y);
		for (int i=1;i<=N;i++) if (i != x && i != y){
			int p = C[x][i] + C[y][i];
			int q = C[i][x] + C[i][y];
			C[x][i] = C[y][i] = p * inv2 % mod;
			C[i][x] = C[i][y] = q * inv2 % mod;
		}
		int r = C[x][y] + C[y][x];
		C[x][y] = C[y][x] = r * inv2 % mod;
		mul = mul * 2 % mod;
	}

	long long ans = 0;
	for (int i=1;i<=N;i++) for (int j=i+1;j<=N;j++) ans = (ans + C[i][j] * mul) % mod;
	printf ("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 35712
N=int(input())
v=list(map(int,input().split()))

def mix(v):
  l1 = min(v)
  v.remove(l1)
  l2 = min(v)
  v.remove(l2)
  v.append((l1+l2)/2)
  
for i in range(N-1):
  mix(v)
  
print(*v)
  

Measured memory_bytes: 3060
a,b=map(int,input().split())

if b == 1:
    print('0')
elif b <= a :
    print('1')
else:
    b -= a
    a -= 1
    y = b % a
    if y==0:
        print(1 + b//a)
    else:
        print(2 + b//a)



Measured memory_bytes: 9164
s, _, *queries = readlines.map(&:chomp)
#s = s * (10 ** 5)
#queries = queries * (10 ** 5)
reverse = false
s = s.each_char.to_a
queries.each do |q|
  t, f, c = q.split
  if t == '1'
    #s = s.reverse
    reverse = !reverse
  else
    #s = f == '1' && !reverse || f == '2' && reverse ? c + s : s + c
    if f == '1' && !reverse || f == '2' && reverse
      s.unshift(c)
    else
      s << c
    end
  end
end
#puts s
puts reverse ? s.reverse.join : s.join

Measured memory_bytes: 54780
import java.util.*; 
import java.lang.*; 


public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                
                long[] L = new long[N];
                
                for(int i=0; i<N; i++){
                    L[i] = scan.nextLong();
                }
                
                int ans = 0;
                
                if(N<=2){
                    System.out.println(0);
                }else{
                    for(int i=0; i<N-2; i++){
                        for(int j=i; j<N-1; j++){
                            for(int k=j; k<N; k++){
                                if(L[i]!=L[j] && L[k]!=L[j] && L[k]!=L[i]){
                                    long a = L[i]+L[j];
                                    long b = L[j]+L[k];
                                    long c = L[k]+L[i];
                                    if(a>L[k] && b>L[i] && c>L[j]){
                                        ans++;
                                    }
                                }
                            }
                        }
                    }
                    
                    System.out.println(ans);
                }
                
                
   
        }
}

Measured memory_bytes: 36232
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, int K, long[] X)
        {
            long min = long.MaxValue;
            for (int i = 0; i + K - 1 < N; ++i)
            {
                long l = X[i];
                long r = X[i + K - 1];
                long L = Math.Abs(l);
                long R = Math.Abs(r);
                if (l * r < 0)
                {
                    long a = Math.Min(L, R);
                    long b = Math.Max(L, R);
                    min = Math.Min(a * 2 + b, min);
                }
                else
                {
                    min = Math.Min(Math.Max(L, R), min);
                }
            }
            return min;
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            long[] X = ReadLongs();
            Console.WriteLine(Solve(V[0], V[1], X));
        }
    }
}


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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

class UnionFind{
public:

    vector<int> root;
    vector<int> rank;
    vector<int> sizev;

    UnionFind();

    //1-indexでアクセスすること想定
    UnionFind(int n){

        for(int i = 0; i <= n; i++){
            root.push_back(i);
            rank.push_back(1);
            sizev.push_back(1);
        }
    }

    int find(int n){

        vector<int> update;
        int count = 0;

        while(n != root[n]){
            
            update.push_back(n);
            n = root[n];
            count++;
        }

        for(int i = 0; i < count; i++){
            root[update[i]] = n;
        }

        return n;
    }

    int size(int n){
        return sizev[find(n)];
    }

    void merge(int a, int b){

        a = find(a);
        b = find(b);

        if(a != b){

            if(rank[a] < rank[b]){
                root[a] = b;
                sizev[b] += sizev[a];
            }else{
                root[b] = a;
                sizev[a] += sizev[b];

                if(rank[a] == rank[b]){
                    rank[a]++;
                }
            }
        
        }
    }
};

int main(){

    ll n;
    int m;
    cin >> n >> m;

    vector<ll> inconv;

    inconv.push_back(n * (n - 1) / 2);

    UnionFind uf(n);

    vector<pair<int,int>> v;

    rep(i, m){
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }

    rep(i, m){
        int a, b;
        a = v[m - 1 - i].first;
        b = v[m - 1 - i].second;

        ll sizea = uf.size(a);
        ll sizeb = uf.size(b);

        //cerr << sizea << " " << sizeb << endl;

        if(uf.find(a) != uf.find(b)){
            inconv.push_back(inconv[i] - sizea * sizeb);
            uf.merge(a, b);
        }else{
            inconv.push_back(inconv[i]);
        }
    }

    reverse(ALL(inconv));

    rep(i, m){
        cout << inconv[i + 1] << endl; 
    }
    return 0;
}


Measured memory_bytes: 6784
n = int(input())
l = list(map(int, input().split()))
a, b, c = 0, 0, 0

for i in l:
  if i % 4 == 0:
    c += 1
  elif i % 2 == 0:
    b += 1
  elif not i % 2 == 0:
    a += 1

if b >= 1:
  if c >= a:
    print('Yes')
  else:
    print('No')
else:
  if c+1 >= a:
    print('Yes')
  else:
    print('No')

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


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int K, A, B;
    cin >> K >> A >> B;
    int start = A / K * K;
    if (A % K != 0) start += K;
    if (start <= B) {
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int N ,M;
    
    cin >> N >> M;
    vector<int> a(N), b(N), c(M), d(M);
    
    rep(i, N) cin >> a[i] >> b[i];
    rep(i, M) cin >> c[i] >> d[i];

    rep(i, N){
        int min_value = 1e9;
        int checkpoint_num;
        rep(j, M){
            int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min_value > dist) {
                checkpoint_num = j;
                min_value = dist;
            }
        }
        cout << checkpoint_num+1 << endl;
    }


    return 0;
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.Scanner;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a < c && c < b) {
			pr.println("Yes");
		} else if (a > c && c > b) {
			pr.println("Yes");
		} else {
			pr.println("No");
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}


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

int main(){
    int cnt[26];
    char c;
    for(int i=0;i<26;i++){
        cnt[i]=0;
    }
    while(scanf("%c",&c)!=EOF){
        if(isupper(c)){
            cnt[static_cast<int>(c)-65]+=1;
        }else if(islower(c)){
            cnt[static_cast<int>(c)-97]+=1;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",static_cast<char>(i+97),cnt[i]);
    }
    return 0;
}


Measured memory_bytes: 3140
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	string s;
	
	cin >> s;
	if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]) cout << "Bad\n";
	else cout << "Good\n";
	
	
	
	
	return 0;
}

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

int main(){
  int d,n;
  cin>>d>>n;
  if(n==100) n++;
  if(d==0) {
    cout<<n;
    return 0;
  }
  int rui = pow(100,d);
  cout<<rui*n;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict as de


readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

s = ns()
digit = 1
ans = 0
num = 0
amari = de(int)
amari[0] = 1
"""
大筋のやり方は
https://drken1215.hatenablog.com/entry/2020/04/29/171300
を参照。

「この下のfor文について」
1211400を考える。
1万の桁を考えるとき
digit = 10000
digit = 1924 mod 2019
11400 = 10000 + 1400 = 1924 + 1400 = ans mod 2019
つまり、ある桁までの2019のあまりはその一つ下の桁までのあまりと
その桁の数*桁のあまりを足したもののあまりである
"""

for i in s[::-1]:
    num = num + int(i) * digit
    num %= 2019
    digit *= 10
    digit %= 2019
    amari[num] += 1

for j in amari.values():
    ans += j*(j-1)//2

print(ans)

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

# 以下がとてもわかりやすい
# https://drken1215.hatenablog.com/entry/2020/06/20/231600

for i in range(-200, 200, 1):
    for j in range(-200, 200, 1):
        if i ** 5 - j ** 5 == N:
            print(f'{i} {j}')
            exit(0)

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

using namespace std;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

const int N = 200010;
int n;
ll arr[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> arr[i];
  sort(arr + 1, arr + 1 + n, greater<ll>());
  ll ans = arr[1];
  n -= 2;
  int cur = 2;
  while (n) {
    if (n == 1) {
      ans += arr[cur];
      n--;
    }
    else {
      ans += 2LL*arr[cur++];
      n -= 2;
    }
  }
  cout << ans << '\n';
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll N, W;
map<pair<int, ll>, ll> dp;
vector<pair<ll, ll>> V;

ll dfs(int idx, ll w) {
    if (idx == V.size()) return 0;
    if (dp.find({idx, w}) != dp.end()) {
        return dp[{idx, w}];
    }
    if (V[idx].first <= w) {
        ll res = max(V[idx].second + dfs(idx+1, w - V[idx].first), dfs(idx+1, w));
        dp[{idx, w}] = res;
        return res;
    } else {
        ll res = dfs(idx + 1, w);
        dp[{idx, w}] = res;
        return res;
    }

}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> N >> W;
    REP(i, N) {
        ll w, v;
        cin >> w >> v;
        V.pb({w, v});
    }
    cout << dfs(0, W) << '\n';
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    string s; cin >> s;

    for (auto & i : divide) reverse(i.begin(),i.end());
    reverse(s.begin(),s.end());
    
    bool can_1 = true;
    for (int i = 0; i < s.size();) {
        bool can_2= false;
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if(s.substr(i,d.size()) == d){
                can_2 = true;
                i += d.size();
            }
        }
        if(!can_2){
            can_1 = false;
            break;
        }
    }
    if(can_1)print("YES");
    else print("NO");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> pii;

int x, y;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> x >> y;
	cout << x + y/2 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int s[10] = {};
int ok(int t){
  while (t > 0){
    if (s[t % 10] == 1)
      return false;
    t /= 10;
  }

  return true;
}

int main(void){
  ll n, k;
  cin >> n >> k;
  
  for (int i = 0; i < k; i++){
    int d;
    cin >> d;
    s[d]++;
  }

  int res = n;
  while (!ok(res)){
    res++;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
fun main() {
    val (a, b, c, k) = readLine()!!.split(" ").map { it.toInt() }
    var result = 0
    result += if (k - a > 0) {
        a
    } else {
        k
    }

    if (k - a - b > 0) {
        result -= k - a - b
    }

    println(result)
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;

    vector<int> L(N);
    rep(i,N) cin >> L[i];
    
    //-----------------------------------
    bool is;
    int max=0,index;
    int elsum=0;
    rep(i,N){
        if(chmax(max,L[i])) index=i;
    }
    rep(i,N){
        if(i!=index)elsum+=L[i];
    }
    cout << ((max<elsum) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void a_iai(void) {
	char c;
	cin >> c;
	string judge = "vowel";
	if ((c != 'a') && (c != 'e') && (c != 'i') && (c != 'o') && (c != 'u')) judge = "consonant";
	cout << judge << endl;
}

int main()
{
	a_iai();
    return 0;
}

Measured memory_bytes: 3612
import sys
from math import sqrt
input = sys.stdin.readline
N = int(input())
ps = [tuple(map(int, input().split())) for _ in range(N)]
rang = 0
for t in ps:
  rang = max(rang, abs(t[0]), abs(t[1]))
def calc(x, y):
  res = 0
  for t in ps:
    u, v = t
    res = max(res, sqrt((x - u) ** 2 + (y - v) ** 2))
  return res

x0 = -1000
x3 = 1000
x1 = (x0 * 2 + x3) / 3
x2 = (x0 + x3 * 2) / 3
res = float("inf")
xl = 0
yl = 0
for i in range(0, rang * 2 + 1, 10):
  u = i - rang
  for j in range(0, rang * 2 + 1, 10):
    v = j - rang
    if calc(xl, yl) > calc(u, v):
      xl = u
      yl = v
x0 = xl - 10
x3 = xl + 10
while x3 - x0 > 0.1 ** 12:
  x1 = (x0 * 2 + x3) / 3
  x2 = (x0 + x3 * 2) / 3

  cc1 = 0
  cc2 = 0

  y0 = yl - 10
  y3 = yl + 10
  y1 = (y0 * 2 + y3) / 3
  y2 = (y0 + y3 * 2) / 3

  while y3 - y0 > 0.1 ** 12:
    y1 = (y0 * 2 + y3) / 3
    y2 = (y0 + y3 * 2) / 3
    c1 = calc(x1, y1)
    c2 = calc(x1, y2)
    if c1 < c2: y3 = y2
    else: y0 = y1

  cy1 = y1 + 0

  y0 = yl - 10
  y3 = yl + 10
  y1 = (y0 * 2 + y3) / 3
  y2 = (y0 + y3 * 2) / 3

  while y3 - y0 > 0.1 ** 12:
    y1 = (y0 * 2 + y3) / 3
    y2 = (y0 + y3 * 2) / 3
    c1 = calc(x2, y1)
    c2 = calc(x2, y2)
    if c1 < c2: y3 = y2
    else: y0 = y1

  cy2 = y1 + 0

  cc1 = calc(x1, cy1)
  cc2 = calc(x2, cy2)
  if cc1 < cc2: x3 = x2
  else: x0 = x1
  res = min(cc1, cc2)

print(res)

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

int main() {
	// your code goes here
	int INF=1e9+5;
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++){
	    cin>>arr[i];
	}
	int dp[n];
	for(int i=0;i<n;i++)
	    dp[i]=INF;
	dp[0]=0;
	for(int i=0;i<n;i++){
        for(int j=i;j<i+k+1;j++)
            if(j<n)
	            dp[j]=min(dp[i]+abs(arr[j]-arr[i]),dp[j]);
	}
	cout<<dp[n-1];
	return 0;
}


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

using namespace std;
using ll = long long;

int N;
ll C;

ll x[100000];
ll v[100000];
ll rval[100001];
ll rd[100001];
ll lval[100001];
ll ld[100001];

void rot(ll val[], ll d[], bool left) {
    val[0] = 0;
    d[0] = 0;
    ll valsum = 0;
    for (int i = 0; i < N; ++i) {
        int ii = left ? N - i - 1 : i;
        ll dist = left ? C - x[ii] : x[ii];
        valsum += v[ii];
        if (val[i] < valsum - dist) {
            val[i + 1] = valsum - dist;
            d[i + 1] = dist;
        } else {
            val[i + 1] = val[i];
            d[i + 1] = d[i];
        }
    }
}

int main(){
    cin >> N >> C;

    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> v[i];
    }

    rot(rval, rd, false);
    rot(lval, ld, true);

    // cout << "right" << endl;
    // for (int i = 0; i <= N; ++ i) {
    //     cout << rval[i] << ", ";
    // }
    // cout << endl;

    // cout << "left "<< endl;
    // for (int i = 0; i <= N; ++ i) {
    //     cout << lval[i] << ", ";
    // }
    // cout << endl;

    ll ans = max(rval[N], lval[N]);

    for (int i = 1; i < N; ++i) {
        ll val = rval[i] + lval[N - i];
        val -= min(rd[i], ld[N - i]);
        ans = max(ans, val);
        // cout << i << "th -> right" << endl;
        // cout << rval[i] << "(" << rd[i] << ")" << endl;
        // cout << lval[i] << "(" << ld[i] << ")" << endl;
    }

    cout << ans << endl;
}

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

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

  ll K; cin >> K;
  ll r = 7;
  ll ans = -1;
  for (ll i = 1; i < 1e7; i++) {
    if (r % K == 0) {
      ans = i;
      break;
    }
    r = (r % K) * 10 + 7;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
int main(){
	int N,A,B;
	std::cin>>N>>A>>B;
	int m,s,h,j,i;
	int count = 0;

	for(int k=1;k<=N;k++){
		int num = k;
		m = num/10000;
		num %=10000;
		s = num/1000;
		num %= 1000;
		h = num/100;
		num %=100;
		j = num/10;
		num %=10;
		i = num;
		int sum = m+s+h+j+i;
		if(A <= sum && sum <= B){
			count += k;
		}
	}
	std::cout<<count;
	return 0;
}


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

int main() {
    int n; cin >>n;
    vector<int> at(n), au(n);
    for (int i = 0; i < n; i++) cin >> at.at(i);
    for (int i = 0; i < n; i++) cin >> au.at(i);

    int ret = 0;
    for (int i = 0; i < n; i++) {
        int t = 0;
        for (int k = 0; k <= i; k++) t += at.at(k);
        for (int j = i; j < n;  j++) t += au.at(j);
        ret = max(ret, t);
    }

    cout << ret << endl;
    return 0;
}

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

long long n;
vector<long long> a;

int main() {
  cin >> n;
  a.resize(3 * n);
  for (int i = 0; i < 3 * n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  long long res = 0;
  for (int i = 0; i < n; ++i) res += a[3 * n - 2 * (i + 1)];
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int mod=1e9+7;

int n,x,y,par[N];
struct dot{
	int x,y,id;
	bool operator < (dot other) const{
		return x < other.x;
	}
};
vector<dot> vx,vy;
struct edge{
	int u,v,w;
	bool operator < (edge other) const{
		return w < other.w;
	}
};
vector<edge> e;

int find(int p){
	if (p==par[p]){
		return p;
	}
	return par[p]=find(par[p]);
}

void merge(int p, int q){
	p=find(p);
	q=find(q);
	par[p]=q;
}

bool cmp(dot p, dot q){
	return p.y < q.y;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> x >> y;
		vx.push_back({x,y,i});
		vy.push_back({x,y,i});
	}
	sort(vx.begin(),vx.end());
	sort(vy.begin(),vy.end(),cmp);
	for (int i=1;i<n;i++){
		e.push_back({vx[i].id,vx[i-1].id,
		vx[i].x-vx[i-1].x});
	}
	for (int i=1;i<n;i++){
		e.push_back({vy[i].id,vy[i-1].id,
		vy[i].y-vy[i-1].y});
	}
	sort(e.begin(),e.end());
	for (int i=1;i<=n;i++){
		par[i]=i;
	}
	long long ans=0;
	for (auto &now : e){
		if (find(now.u)!=find(now.v)){
			merge(now.u,now.v);
			ans+=now.w;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 7212
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'
ll M = 1e9 + 7;
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; ++i)
  {
    string x;
    cin >> x;
    s.insert(x);
  }
  cout << s.size();
}

Measured memory_bytes: 19228
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class BIT:
    def __init__(self, li):
        self.n, self.data = len(li) + 1, [0] + li
        for i in range(1, self.n):
            if i + (i & -i) < self.n: self.data[i + (i & -i)] += self.data[i]

    def add(self, i, a):
        i += 1
        while i < self.n:
            self.data[i] += a
            i += i & -i

    # sum of [0, i)
    def acc(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            i -= i & -i
        return res

    # sum of [l, r)
    def get(self, l, r = None):
        if r is None: r = l+1
        return self.acc(r) - self.acc(l)


def main():
    N, Q = LI()
    A = LI()
    query = LIR(Q)
    bit = BIT(A)

    for a, b, c in query:
        if a == 0:
            bit.add(b, c)
        else:
            print(bit.get(b, c))




if __name__ == '__main__':
    main()

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

int main(){
  
    int n, i, h[25];
    cin >> n;
    
    for( i=0; i<n; i++){
    cin >> h[i];
    }

    int count=0, max=h[0];
  
    for(i=1; i<n; i++){
    if(h[i] >= max){
    count++;
    max=h[i];
    }
    }

    cout << count+1 <<endl;

}

    

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

for x in range(1000):
    ok = True
    s = str(x)
    if len(s) != n:
        continue
    if not all([int(s[a[i][0] - 1]) == a[i][1] for i in range(m)]):
        continue
    print(x)
    exit(0)

print(-1)


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

int main(){
	string a,b;
  	cin>>a>>b;
	a+=b;
  	int n=stoi(a);
  	for(int i=4;i<=330;++i){
      if(i*i==n){cout<<"Yes"<<endl;return 0;}
    }cout<<"No"<<endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,v,b,n,m,i,j,k,l;
    while(cin>>n>>m>>a>>b)
    {
        ll c=0;
        for(i=0; i<=n; i++)
        {
            if((i)*500==b)
                c++;
            else
            {
                for(j=0; j<=m; j++)
                {
                    if((i)*500+(j)*100==b)
                        c++;
                    else
                    {
                        for(k=0; k<=a; k++)
                        {
                            if((i)*500+(j)*100+(k*50)==b)
                                c++;

                        }
                    }
                }
            }
        }
        cout<<c<<endl;
    }
}



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

int main(){
  char s;
  string st = "";
  for (int i = 0; i < 10; i++)
  {
    if (i == 4 | i == 7)
    {
      cin >> s;
    }
    else
    {
      cin >> s;
      st += s;
    }
  }
  int date = 0;

  date = stoi(st);
  if (date <= 20190430)
  {
    cout << "Heisei" << endl;
  }
  else
  {
    cout << "TBD" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_B() {}


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    const int N = 5;
    vi A(N); REP(i, N) cin >> A[i];

    vi w(N); // wait time for the next order
    REP(i,N) {
        w[i] = (A[i] + 9) / 10 * 10 - A[i];
    }

    int sum = 0; REP(i, N) sum += A[i] + w[i];
    
    int ans=INF;
    REP(i,N) { // the last order has no wait time
        ans = min(ans, sum - w[i]);
    }

    cout << ans << endl;  

    return 0;
}

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

/*
code credits : ਜ਼ੈਲਦਾਰ
dashan jot singh
*/
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL)
#define pb push_back
#define mp make_pair
#define inf LLONG_MAX
#define p pair<ll,ll>
int n;
int arr[100010];
int dp[100010];
int solve(int i){
	// if(i==n){
		// return 0;
	// }
	if(i>=n){
		return INT_MAX;
	}
	if(i==n-1){
		return 0;
	}
	if(dp[i]!=-1){
		return dp[i];
	}
	int ans=INT_MAX;
	if(i+1<n){
		ans=min(ans,abs(arr[i+1]-arr[i])+solve(i+1));
	}
	if(i+2<n){
		ans=min(ans,abs(arr[i+2]-arr[i])+solve(i+2));
	}
	dp[i]=ans;
	return dp[i];
}
int main(){
	fast;
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	cout<<solve(0)<<endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) cin >> vec.at(i);
  int answer = 0;
  while (true) {
    int count = 0;
    for (int i = 0; i < n; i++) {
      if (vec.at(i) % 2 == 0) {
        count++;
        vec.at(i) /= 2;
      }else {
        break;
      }
    }
    if (count == n) {
      answer++;
    }else {
      break;
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
import itertools

L, R = map(int, input().split())

R = min(R, L+2019)

minimum = 2018

for c in list(itertools.combinations(list(range(L, R+1)),2)):
    mod = (c[0]*c[1]) % 2019
    if mod < minimum:
        minimum = mod
        
print(minimum)

Measured memory_bytes: 148668
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200
int n;
int L[MAXN+5],ans=0;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n*2;i++)
		scanf("%d",&L[i]);
	sort(L+1,L+n*2+1);
	for(int i=1;i<=2*n;i+=2)ans+=L[i];
	printf("%d",ans);//
}

Measured memory_bytes: 256
while True:
   a,op,b=input().split()
   if op=='?': break
   elif op=='+': print( int(a) +  int(b) )
   elif op=='-': print( int(a) -  int(b) )
   elif op=='*': print( int(a) *  int(b) )
   elif op=='/': print( int(a) // int(b) )


Measured memory_bytes: 5592
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class D
{	
	public static void Main()
	{
		string S = Console.ReadLine();
		int[,] dp = new int[S.Length + 1, 4];
		dp[0,0] = 1;
		//dp[0,1] = dp[0,2] = dp[0,3] = 0;
		for(int i = 0; i < S.Length; i++)
		{
			switch (S[i])
			{
				case 'A':
					dp[i+1,0] += dp[i,0];
					dp[i+1,1] += mod(dp[i,1] + dp[i,0]);
					dp[i+1,2] += dp[i,2];
					dp[i+1,3] += dp[i,3];
					for(int j = 0; j < 4; j++)
						dp[i+1,j] = mod(dp[i+1,j]);
					break;

				case 'B':
					dp[i+1,0] += dp[i,0];
					dp[i+1,1] += dp[i,1];
					dp[i+1,2] += mod(dp[i,2] + dp[i,1]);
					dp[i+1,3] += dp[i,3];
					for(int j = 0; j < 4; j++)
						dp[i+1,j] = mod(dp[i+1,j]);
					break;

				case 'C':
					dp[i+1,0] += dp[i,0];
					dp[i+1,1] += dp[i,1];
					dp[i+1,2] += dp[i,2];
					dp[i+1,3] += mod(dp[i,3] + dp[i,2]);
					for(int j = 0; j < 4; j++)
						dp[i+1,j] = mod(dp[i+1,j]);
					break;

				case '?':
					//? -> A
					dp[i+1,0] += dp[i,0];
					dp[i+1,1] += mod(dp[i,1] + dp[i,0]);
					dp[i+1,2] += dp[i,2];
					dp[i+1,3] += dp[i,3];
					for(int j = 0; j < 4; j++)
						dp[i+1,j] = mod(dp[i+1,j]);

					//? -> B
					dp[i+1,0] += dp[i,0];
					dp[i+1,1] += dp[i,1];
					dp[i+1,2] += mod(dp[i,2] + dp[i,1]);
					dp[i+1,3] += dp[i,3];
					for(int j = 0; j < 4; j++)
						dp[i+1,j] = mod(dp[i+1,j]);

					//? -> C
					dp[i+1,0] += dp[i,0];
					dp[i+1,1] += dp[i,1];
					dp[i+1,2] += dp[i,2];
					dp[i+1,3] += mod(dp[i,3] + dp[i,2]);
					for(int j = 0; j < 4; j++)
						dp[i+1,j] = mod(dp[i+1,j]);
					break;
				
				default:
					break;
			}
		}

		Console.WriteLine(dp[S.Length,3]);		
	}

	private static int mod(int x)
	{
		return x % 1000000007;
	}
}

Measured memory_bytes: 13268
import sys
from collections import defaultdict


def main():
    n = int(input())
    lines = sys.stdin.readlines()
    vertex_weights = defaultdict(list)
    for i in range(n):
        u, k, *vtx_wght = map(int, lines[i].split())
        for v_i in range(k):
            vertex_weights[u].append((vtx_wght[2*v_i], vtx_wght[2*v_i+1]))

    dist_from_0 = {}
    vertices = [(0, 0)]
    while len(dist_from_0) != n:
        vertices.sort(key=lambda x: x[1], reverse=True)
        vtx, vtx_dist = vertices.pop()
        dist_from_0[vtx] = vtx_dist

        neighbor_vtx = vertex_weights[vtx]

        for n_vtx, n_dist in neighbor_vtx:
            if n_vtx not in dist_from_0.keys():
                vertices.append((n_vtx, vtx_dist + n_dist))

        [vertices.remove(x) for x in vertices[:] if x[0] in dist_from_0]


    answers = [None] * n
    sorted_dist = sorted(dist_from_0.items(), key=lambda x: x[0])
    for i in range(n):
        answers[i] = f"{sorted_dist[i][0]} {sorted_dist[i][1]}"
    [print(ans) for ans in answers]
    return


main()


Measured memory_bytes: 6516
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def binary_search(list,item):
    low = 0
    high = len(list)-1
    while low <= high:
        mid = (low+high)//2
        guess = list[mid]
        if guess == item:
            return True
        if guess > item:
            high = mid - 1
        else:
            low = mid + 1
    return False

ans = 0
for i in T:
    if binary_search(S,i):
        ans+=1
print(ans)


Measured memory_bytes: 16716
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#include <tuple>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (n); i < (m); i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<double> p(N);
    // dp[i][j] := i番目までのコインを投げた後表がj枚になる確率
    vector<vector<double>> dp(N + 1, vector<double>(N + 1, 0));
    dp[0][0] = 1;
    REP(i, N) {
        cin >> p[i];
        REP(j, N + 1) {
            dp[i + 1][j] = dp[i][j] * (1 - p[i]);
            if (j > 0) dp[i + 1][j] += dp[i][j - 1] * p[i];
        }
    }
    double ans = 0;
    FOR(i,(N+1)/2,N+1) {
        ans += dp[N][i];
    }
    printf("%.10f", ans);
    getchar(); getchar();
}

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

using namespace std;

typedef long long ll;

const int MAX_N = 1e5 + 10;
const ll MOD = 1e9 + 7;

int N, S[MAX_N], pref_sum[MAX_N], next_sum[MAX_N][3];
ll F[MAX_N];

void init() {
    char _S[MAX_N]; scanf("%s", _S + 1); N = strlen(_S + 1);
    for (int i = 1; i <= N; i++) S[i] = _S[i] - 'a' + 1;

    bool flag = true;
    for (int i = 2; i <= N; i++) flag &= S[i] != S[i - 1];
    if (flag) {
        printf("1\n");
        exit(0);
    }

    for (int i = 1; i <= N; i++) pref_sum[i] = (pref_sum[i - 1] + S[i]) % 3;
    for (int i = 0; i < 3; i++) next_sum[N + 1][i] = N + 1;
    for (int i = N; i; i--) {
        for (int j = 0; j < 3; j++) next_sum[i][j] = next_sum[i + 1][j];
        next_sum[i][pref_sum[i]] = i;
    }
}

void solve() {
    ll ans = 0;
    F[0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= 2; j++) {
            int t = next_sum[i][(pref_sum[i - 1] + j) % 3];
            if (t <= N) (F[t] += F[i - 1]) %= MOD;
        }
        if (pref_sum[N] != pref_sum[i - 1]) (ans += F[i - 1]) %= MOD;
    }
    printf("%lld\n", ans);
}

int main() {
    init();
    solve();
}

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

int main(int argc, char *argv[]){
  int n, m;
  cin >> n >> m;
  int target[m], point[n];
  memset(point, 0, sizeof(point));
  for (int i = 0; i < m; i++) {
    cin >> target[i];
    target[i]--;
  }
  for (int i = 0; i < m; i++) {
    int exp[n];
    for (int j = 0; j < n; j++) {
      cin >> exp[j];
      exp[j]--;
      if(exp[j] == target[i]){
        point[j]++;
      }else{
        point[target[i]]++;
      }
    }
  }
    for (int j = 0; j < n; j++) {
      std::cout << point[j] << std::endl;
    }
  return 0;
}

Measured memory_bytes: 1168