akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<vector<vector<int>>> f(n, vector<vector<int>>(5, vector<int>(2, 0)));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 2; k++) {
				cin >> f[i][j][k];
			}
		}
	}

	vector<vector<int>> p(n, vector<int>(11, 0));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> p[i][j];
		}
	}

	vector<vector<int>> joif(5, vector<int>(2, 0));
	int maxtotal = -2000000000;
	for (int i =1; i < 1024; i++) {
		for (int j = 0; j < 5; j++) {
			for (int k = 0; k < 2; k++) {
				if ((i & (1 << (k * 5 + j)))) {
					joif[j][k] = 1;
				}
				else { joif[j][k] = 0; }
			}
		}
		int totalcount = 0;
		for (int ii = 0; ii < n; ii++) {
			int counter = 0;
			for (int j = 0; j < 5; j++) {
				for (int k = 0; k < 2; k++) {
					if (joif[j][k] == f[ii][j][k] && joif[j][k]==1) {
						counter++;
					}
				}
			}
			totalcount += p[ii][counter];
		}

		maxtotal = max(maxtotal, totalcount);

	}
	cout << maxtotal << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int[][] dp = new int[11][10];
        Arrays.fill(dp[1], 1);
        long ans=0;
        if(k<10){
           ans = k;
        }else{
            int sum = 9;
            int dij=0 , num=0;
            OUTER:for (int i = 2; i < 11; i++) {
                dij = i;
                for (int j = 0; j < 10; j++) {
                    if(j==0){
                        dp[i][j] = dp[i-1][0] + dp[i-1][1];
                        continue;
                    }
                    num = j;
                    int pre1 = j - 1, pre2 = j +1;
                    if(-1<pre1) {dp[i][j] += dp[i-1][pre1]; sum+=dp[i-1][pre1];}
                    dp[i][j] += dp[i-1][j]; sum+= dp[i-1][j];
                    if(pre2<10){dp[i][j] += dp[i-1][pre2]; sum+=dp[i-1][pre2];}
                    if(k <= sum)break OUTER;
                }
            }
            sum -= dp[dij][num];
            int[] a = new int[dij+1];
            a[dij] = num;
            for (int i = dij-1; i > 0; i--) {
                int f = a[i+1];
                int pre1 = f - 1, pre2 = f +1;
                int t = sum;
                if(-1<pre1) {
                    t += dp[i][pre1];
                    if(k <= t){
                        a[i] = pre1; continue;
                    }
                }
                sum =t;
                t += dp[i][f];
                if(k <= t){
                    a[i] = f; continue;
                }
                sum =t;
                if(pre2<10){
                    t += dp[i][pre2];
                    if(k <= t){
                        a[i] = pre2; continue;
                    }
                }
                sum =t;
            }
            long b = 1;
            for (int i = 1; i < dij+1; i++) {
                ans += a[i] * b;
                b *= 10;
            }
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23124
n=int(input())
# 降順のリストで二分探索
# 自分より小さい数字で最も大きいものを自分でアップデート
# 該当がなければ最後に追加
d=[]
d.append(int(input()))
for i in range(n-1):
  a=int(input())
  ok=len(d)
  ng=-1
  while abs(ok-ng)>1:
    mid=abs(ok+ng)//2
    if d[mid]<a:
      ok=mid
    else:
      ng=mid
  if ok==len(d):
    d.append(a)
  else:
    d[ok]=a
print(len(d))

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

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

int main() {
    int n;
    cin >> n;
    vector<int> W(n);
    for(int i=0; i<n; i++) cin >> W[i];
    vector<int> S;

    int sum = 0;
    for(int i=0; i<n; i++) {
        sum += W[i];
        S.push_back(sum);
    }

    int a = sum;
    int min_div = sum;

    for(int i=0; i<n-1; i++) {
        a -= W[i];
        min_div = min(min_div,abs(a - S[i]));
    }
    cout << min_div << endl;
}



Measured memory_bytes: 3648
//A
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {
	int A, B;
	cin >> A >> B;
	cout << A * B - A - B + 1 << endl;
	return 0;
}


/*
//B
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {

return 0;
}
*/

/*
//C
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {

return 0;
}
*/

/*
//D
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int main() {

return 0;
}
*/


Measured memory_bytes: 256
from  numpy  import *

N=int(input())
a=list(map(int,input().split(" ")))
s=0
while True :
  curr=""
  pos=0
  for index,item in enumerate(a):  
    if item==0:
      curr+='-'
    else:
      pos+=1
      curr+=str(item)
      a[index]=item-1
  if pos==0:
    break
  s+=count_nonzero([len(x) for x in curr.split("-")])
  
print(s)


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

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
	int n;
	cin >> n;
	int a[100010];

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

	int wari = 2;
	int ans = a[0]-1;

	for(int i = 1;i < n;i++){
		if(wari == a[i]){
			wari++;
		}else{
			int tmp = a[i] - (wari-1);
			ans += tmp / wari;
			a[i] -= tmp / wari * wari;
			if(a[i] > wari) ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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

ll MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    ll count = 0;
    for (ll i = 0; i < 1 << S.length()-1; i++) {
        string tmp = "";
        for (ll j = 0; j < S.length()-1; j++) {
            tmp += S[j];
            if (i >> j & 1 == 1) {
                count += stoll(tmp);
                tmp = "";
            }
        }
        tmp += S[S.length()-1];
        count += stoll(tmp);
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{

    int N; cin>>N;
    int arr[N]{};
    int Brr[N]{};
    for(int i = 0 ; i<N ; i ++)
    {
        cin>>arr[i];
        Brr[i] = arr[i]-(i+1);
    }
    sort(Brr , Brr+N);
    int b = Brr[N/2];
    ll ans = 0 ;
    for(int i = 0 ; i<N ; i++)
    {

        ans += abs(arr[i] - (b+i+1));
    }

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


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
vector<int> G[N];
int vis[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n-1;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        G[x].push_back(y);
        G[y].push_back(x);
    }

    queue<int> Q;
    Q.push(1);
    Q.push(n);
    vis[1]=1;
    vis[n]=2;

    int fennec=0,snuke=0;
    while(!Q.empty()){
        int x=Q.front();
        Q.pop();
        for(int i=0;i<G[x].size();i++){
            int y=G[x][i];
            if(vis[y]==0){
                Q.push(y);
                vis[y]=vis[x];
                if(vis[y]==1)
                    fennec++;
                else if(vis[y]==2)
                    snuke++;
            }
        }
    }
    if(fennec>snuke)
        printf("Fennec\n");
    else
        printf("Snuke\n");
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        // var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine();
        var K = int.Parse(Console.ReadLine());

        var value = S[K - 1];

        var ans = "";
        for(var i = 0; i < S.Length; i++)
        {
            var now = S[i];

            if (now != value)
            {
                ans += "*";
            } else
            {
                ans += now;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] nArray = new int[N];
		for (int i = 0; i < N; i++) {
			nArray[i] = scan.nextInt();
		}
		scan.close();
		int count = 0;
		for (int j = 0; j < N; j++) {
			if ((j + 1) % 2 == 1 && nArray[j] % 2 == 1) {
				count += 1;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35660
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int a, b; cin >> a >> b;
  int result = a;
  if (a>b) result--;
  cout << result << endl;
  return 0;
}

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

int main() {
    ll n, h, a, b;
    cin >> n >> h;
    vector<ll> starts, ends;
    for (ll i=0; i<n; i++) {
        cin >> a >> b;
        starts.push_back(a);
        ends.push_back(b);
    }
    sort(starts.rbegin(),starts.rend());
    sort(ends.rbegin(),ends.rend());
    ll ei = 0;
    ll res = 0;
    while (h>0) {
        if (starts[0]>=ends[ei] || ei==n) {
            res+=h/starts[0];
            if (h%starts[0]!=0) res++;
            h = 0;
        }
        else {
            res++;
            h-=ends[ei];
            ei++;
        }
    }
    cout << res;
    return 0;
}

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

using namespace std;

#define umap std::unordered_map
#define uset std::unordered_set
#define _all(container) std::begin(container), std::end(container)
#define _in(container, value) (std::find(_all(container), value) != std::end(container))
#define _in_if(container, predicate) (std::find_if(_all(container), predicate) != std::end(container))
#define _odd(value) (value & 1)
#define _even(value) !(value & 1)
#define _for(i, n) for (int i = 0; i < n; ++i)
#define _FOR(i, k, n) for (int i = k; i <= n; ++i)
#define _FORR(i, k, n) for (int i = n; i >= k; --i)

using Integer = long long;
using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;
using vdouble = vector<double>;
using cint = const int;
using cdouble = const double;

void solve()
{
    int N;

    cin >> N;

    int num_odd = std::ceil(1.0 * N / 2);
    cout << (1.0 * num_odd / N) << "\n";
}

int main(int argc, char**)
{
    if (argc > 1) {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);

    solve();
}


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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    int N;
    ist >> N;

    /* ------- 計算 ------- */

    int N_amari = N % 10;

    if (N_amari == 3)
    {
        ost << "bon" << endl;
        return;
    }

    if (N_amari == 0 || N_amari == 1 || N_amari == 6 || N_amari == 8)
    {
        ost << "pon" << endl;
        return;
    }

    ost << "hon" << endl;
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 3624
N = int(input())
seat = ['?' for _ in range(N+1)]
left = 0
right = N
for i in range(20):
  if i == 0:
    output = 0
  elif i == 1:
    output = (N-1)//2
  else:
    output = (right + left)//2
  print(output)
    
  s = input()
  if s == 'Vacant':
    exit()
  seat[output] = s
  if i == 0:
    seat[N] = s
  #print(seat)
  if ((right + output) % 2 == 0 and seat[right] != seat[output]) or ((right + output) % 2 == 1 and seat[right] == seat[output]):
    left = output
  else:
    right = output


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

#define for_(i,a,b) for(int i=a;i<b;++i)

struct Cake {
	int w, d;
	Cake() {}
	Cake(int _w, int _d) : w(_w), d(_d) {}
	bool operator < (const Cake& a) const { return w * d < a.w * a.d; }
};

int n, w, d;

int main() {
	while (scanf("%d %d %d", &n, &w, &d), w) {
		vector< Cake > cakes;
		cakes.push_back(Cake(w, d));
		
		for_(i,0,n) {
			int p, s; scanf("%d %d", &p, &s); --p;
			
			Cake cp = cakes[p];
			s %= (cp.w + cp.d);
			Cake a, b;
			
			if (s < cp.w) {
				a = Cake(cp.w - s, cp.d);
				b = Cake(s, cp.d);
			} else {
				a = Cake(cp.w, cp.d - s + cp.w);
				b = Cake(cp.w, s - cp.w);
			}
			
			cakes.erase(cakes.begin() + p);
			cakes.push_back(min(a, b));
			cakes.push_back(max(a, b));
		}
		
		sort(cakes.begin(), cakes.end());
		
		for_(i,0,n+1) {
			Cake ci = cakes[i];
			if (i < n) cout << ci.w * ci.d << " ";
			else cout << ci.w * ci.d << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

const int M = 2e5 + 5;

int main(){
    
    ll x , y;
    cin >> x >> y;
    if(x%y == 0){
        cout<<"-1";
        return 0;
    }
    cout<<x<<endl;
	
	
	
	
	
	
    
}





































Measured memory_bytes: 256
use std::cmp::{max, min};

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let a: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let b: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let k: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    for i in a..min(a + k - 1, b) + 1 {
        println!("{}", i);
    }
    for i in max(a + k, b - k + 1)..(b + 1) {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	const m = 1000000007

	N := readInt()
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = readInt()
	}

	result := 0
	for b := 0; b < 60; b++ {
		t := 0
		bs := (A[N-1] >> uint(b)) & 1
		for i := N - 2; i > -1; i-- {
			if (A[i]>>uint(b))&1 == 0 {
				t += bs
			} else {
				t += (N - (i + 1)) - bs
				bs++
			}
		}
		t %= m
		v := (1 << uint(b)) % m
		result += (t * v) % m
		result %= m
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

const ll MAX_V = 200010;

class dijkstra
{
public:
  struct edge
  {
    ll to;
    ll cost;
  };

  vector<edge> E[MAX_V];
  ll d[MAX_V];

  void calc(ll s)
  {
    priority_queue<pll, vector<pll>, greater<pll>> que;
    rep(i, MAX_V) d[i] = LINF;
    que.emplace(0LL, s);
    d[s] = 0LL;
    while (!que.empty())
    {
      pll p = que.top();
      que.pop();
      ll v = p.second;
      if (d[v] < p.first)
        continue;

      for (auto &&e : E[v])
      {
        if (d[e.to] > d[v] + e.cost)
        {
          d[e.to] = d[v] + e.cost;
          que.emplace(d[e.to], e.to);
        }
      }
    }
  }
};

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

  ll v, e, r;
  cin >> v >> e >> r;
  dijkstra ds;
  rep(i, e)
  {
    ll s, t, d;
    cin >> s >> t >> d;
    ds.E[s].push_back({t, d});
  }
  ds.calc(r);
  rep(i, v)
  {
    if (ds.d[i] == LINF)
      cout << "INF\n";
    else
      cout << ds.d[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 22656
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

int main() {
  map<ll, ll> m;

  ll n;
  scanf("%lld", &n);

  bool dup = false;
  for (ll i = 0; i < n; i++) {
    ll v;
    scanf("%lld", &v);
    if (m[v] == 1) {
      dup = true;
      break;
    }

    m[v] = 1;
  }

  if (!dup) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 8520
#include <stdio.h>
#define S 10000
#define T 500

int s[S];
int t[T];

int main(){
  int i,j,n,q;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
  scanf("%d",&q);
 
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
    for(j=0;j<i;j++){
      if(t[j]==t[i]) i--;
    }
  }  
  printf("%d\n",IinearSearch(n,q));
  return 0;
}

int IinearSearch(int n,int q){
  int i,j,key,c=0;
  for(i=0;i<q;i++){
    key=t[i];
    for(j=0;j<n;j++){
      if(key==s[j]){
	c++;
	break;
      }
    }
  }
  return c;
}

Measured memory_bytes: 640
n, m = map(int, input().split())
l_list = []
r_list = []
cnt = 0
for _ in range(m):
    l, r = map(int, input().split())
    l_list.append(l)
    r_list.append(r)

print(min(r_list) - max(l_list) + 1) if min(r_list) >= max(l_list) else print(0)

Measured memory_bytes: 10996
#include <stdio.h>
int area(int a,int b)
{
  int s;
  s = a*b;
  return(s);
}
int circuit(int a,int b)
{
  int c;
  c = 2*a + 2*b;
  return(c);
}
int main(void)
{
  int a,b;
  int S,C;

  scanf("%d",&a); scanf("%d",&b);
  S = area(a,b);
  C = circuit(a,b);

  printf("%d %d\n",S,C);
  return(0);
}

Measured memory_bytes: 2720
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
int bk[1000000],fr[1000000];
int32_t main()
{
	fastio();
	int n,m;
	cin>>n>>m;
	int a[m];
	f(i,0,m)
	{
		cin>>a[i];
		bk[a[i]]=1;
	}
	int fg=0;
	f(i,1,m)
	{
		if(a[i]==a[i-1]+1)
			fg=1;
	}
	if(fg==1)
	{
		cout<<0;
		return 0;
	}
	fr[0]=1;
	for(int i=0;i<=n-1;i++)
	{
		if(bk[i]==1)
			continue;
		if(bk[i+1]==0)
			fr[i+1]=(fr[i+1]+fr[i])%mod;
		if(bk[i+2]==0)
			fr[i+2]=(fr[i+2]+fr[i])%mod;
	}
	cout<<fr[n];
}

Measured memory_bytes: 5504
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;


int main()
{
	int n;
	while (cin >> n, n) {
		int a[4], b[4],x[4];
		for (int i = 0; i < n; i++) {
			cin >> a[0] >> a[1] >> a[2] >> a[3];
			cin >> b[0] >> b[1] >> b[2] >> b[3];
			x[0] = a[0] * b[0] + (-1)*a[1] * b[1] + (-1)*a[2] * b[2] + (-1)*a[3] * b[3];
			x[1] = a[0] * b[1] + a[1] * b[0] + a[2] * b[3] + (-1)*a[3] * b[2];
			x[2] = a[0] * b[2] + a[2] * b[0] + (-1)*a[1] * b[3] + a[3] * b[1];
			x[3] = a[0] * b[3] + a[3] * b[0] + a[1] * b[2] + (-1)*a[2] * b[1];
			printf("%d %d %d %d\n",x[0],x[1],x[2],x[3]);
		}
	}
	return 0;
}

Measured memory_bytes: 3164
s = list(input().split())
stack = []

for i in range(len(s)):
    if s[i] == '+':
        stack.append(stack.pop() + stack.pop())
    elif s[i] == '-':
        stack.append(-(stack.pop() - stack.pop()))
    elif s[i] == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(s[i]))

print(stack[-1])


Measured memory_bytes: 5604
#include<iostream>
using namespace std;
int main(){
  string input = "";
  cin >> input;
  int max_length, current_length;
  max_length =0;
  current_length=0;
  for(int i=0; input[i]; i++){
    if(input[i]=='A'||input[i]=='G'||input[i]=='C'||input[i]=='T')
      current_length++;
    else{
      if(max_length < current_length)
        max_length = current_length;
      current_length =0;
    }
  }
  if(max_length < current_length)
    max_length = current_length;
  cout << max_length << endl;
  return 0;
}

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

typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define Rep(n) for (ll _ = 0; _ < (ll)(n); _++)

template <class S>S sum(vector<S>& a) {return accumulate(all(a), S());}
template <class S>S max(vector<S>& a) {return *max_element(all(a));}
template <class S>S min(vector<S>& a) {return *min_element(all(a));}
ll max(int a, ll b) { return max((ll)a, b); } ll max(ll a, int b) { return max(a, (ll)b); }
ll min(int a, ll b) { return min((ll)a, b); } ll min(ll a, int b) { return min(a, (ll)b); }

void eprint() { cerr << endl; }
template <class First, class... Rest>
void eprint(First& f, Rest&... r) {
  cerr << f << ' ';
  eprint(r...);
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  size_t output_num = v.size();
  bool is_emitted = false;
#ifdef OUTPUT_VECTOR_MAX
  if (OUTPUT_VECTOR_MAX < output_num) {
    output_num = OUTPUT_VECTOR_MAX;
    is_emitted = true;
  }
#endif
  os << "[";
  for (size_t i = 0; i < output_num - 1; i++) os << v[i] << ", ";
  os << v[output_num - 1];
  if (is_emitted) os << ", ...";
  return os << "]";
}

void Main();
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}

using T = tuple<int,int,int>;

void Main() {
  int n; cin >> n;
  vector<T> xy(n);
  rep(i,n){
    int a,b; cin>>a>>b;
    xy[i] = T(a,b,i);
  }
  sort(all(xy));
  dsu d(n);
  int m = get<1>(xy[0]);
  rep(i,n-1){
    if(m < n-i){
      d.merge(get<2>(xy[i]), get<2>(xy[i+1]));
    }
    m = min(m, get<1>(xy[i+1]));
  }
  rep(i,n){
    cout << d.size(i) << endl;
  }
}


Measured memory_bytes: 6352
#include <iostream>

int main(void){
  	char tmp;
  	std::cin >> tmp;
	if(tmp == 'A' || tmp == 'T'){
        std::cout << (char)('T' - (int)tmp + 'A') <<std::endl;
    }
    else{
        std::cout << (char)('G' - (int)tmp + 'C') <<std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int r, c;
    scanf("%d %d", &r, &c);

    int table[101][101] = {0};

    int i, j;
    for(i = 0; i < r; ++i)
    {
        for(j = 0; j < c; ++j)
        {
            scanf("%d", &table[i][j]);
            table[i][100]   += table[i][j];
            table[100][j]   += table[i][j]; 
            table[100][100] += table[i][j];
        }
    }

    for(i = 0; i < r; ++i)
    {
        for(j = 0; j < c; ++j)
        {
            printf("%d ", table[i][j]);
        }

        printf("%d\n", table[i][100]);
    }

    for(i = 0; i < c; ++i)
    {
        printf("%d ", table[100][i]);
    }

    printf("%d\n", table[100][100]);

    return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <vector>
#include <cstring>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <map>
#include <stack>
#include <cmath>
#define LL long long 
using namespace std;

int main()
{
	int m,d,ans=0;
	scanf("%d%d",&m,&d);
	for(int i=4;i<=m;i++)
	{
		for(int j=2;j<=(d/10);j++)
		{
			for(int k=2;k<=9;k++)
			{
				if((j*10+k)>d)
					break;
				if(j*k==i)
					ans++;
			}
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
n, m, k = map(int, input().split())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))

a_sum = [0]
b_sum = [0]
for i in range(1, n+1):
  a_sum.append(a_sum[i-1] + an[i-1])
for j in range(1, m+1):
  b_sum.append(b_sum[j-1] + bn[j-1])

idx = len(bn)
ans = 0
for i in range(n+1):
  while a_sum[i] + b_sum[idx] > k:
    idx -= 1
    if idx == -1:
      break
  if idx == -1:
    break
  ans = max(ans, i + idx)

print(ans)



Measured memory_bytes: 48752
#include<bits/stdc++.h>
using namespace std;
string s,t;
long long x[100],ans,a;
vector<int> v[100];
int main(){
	cin>>s>>t;a=s.size();
	for (int i=0;i<s.size();i++) x[s[i]-'a']++;
	for (int i=0;i<t.size();i++)
		if (x[t[i]-'a']==0){
			cout<<-1<<endl;
			return 0;
		}
	for (int i=0;i<s.size();i++) v[s[i]-'a'].push_back(i);
	int n=-1;
	for (int i=0;i<t.size();i++){
		int lbound=upper_bound(v[t[i]-'a'].begin(),v[t[i]-'a'].end(),n)-v[t[i]-'a'].begin();
		if (lbound>=v[t[i]-'a'].size()||v[t[i]-'a'][lbound]<=n){
			ans++;
			n=v[t[i]-'a'][0];
		}
		else
			n=v[t[i]-'a'][lbound];
	}
	cout<<ans*a+(long long)n+1<<endl;
	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 9223372036854775807
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0;
string s;
bool flag;
#pragma endregion
#define MAX 111111

ll c[55][55];

void comb() {
  FOR(i, 0, 54) {
	FOR(j, 0, i+1) {
	  if (i == j || j == 0) {
		c[i][j] = 1;
	  }
	  else {
		c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]);
	  }
	}
  }
}

ld mx[55];
ll ans2[55];
int main(void) {
  ld tmpd = -INF;
  vll v;
  map<ll, ll> mp, mp2;
  ll a, b;
  cin >> n >> a >> b;
  comb();
  FOR(i, 0, n) {
	cin >> tmp;
	v.pb(tmp);
	mp[tmp]++;
  }
  sort(RALL(v));
  FOR(i, 0, n) {
	mx[i + 1] += mx[i] + v[i];
  }
  FOR(i, 1, n + 1) {
	mx[i] /= i;
  }
  FOR(i, a, b + 1) {
	tmpd = max(tmpd, mx[i]);
  }
  FOR(i, 0, n) {
	mp2[v[i]]++;
	if (tmpd != mx[i + 1]) continue;
	ans2[i + 1] = 1;
	for (auto it : mp2) {
	  ans2[i + 1] *= c[mp[it.F]][it.S];
	}
  }
  FOR(i, a, b + 1) {
	ans += ans2[i];
  }
  cout.precision(20);
  cout << fixed << tmpd << endl;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll modp(ll a, ll b)
{
	if(b==0)return 1;
	ll u=modp(a,b/2);
	u=(u*u)%mod;
	if(b&1) return (a*(u))%mod;
	return u;
}
ll inv(ll a)
{
	return modp(a, mod-2);
}
int main()
{
  ll n,a,b;
  cin>>n>>a>>b;
  
  ll base=modp(2,n);
  base=(base-1+mod)%mod;
  ll nca=1;ll ncb=1;
  ll tn=n;
  for(ll i=a;i>=1;i--)
  {
  	nca=(nca*tn)%mod;
  	tn--;
  	nca=(nca*inv(i))%mod;
  }
  //if(base<0)cout<<"Yes base";
  
  tn=n;
   for(ll i=b;i>=1;i--)
  {
  	ncb=(ncb*tn)%mod;
  	tn--;
  	ncb=(ncb*inv(i))%mod;
  }
  
  //if(nca<0)cout<<"Yes nca";
  //if(ncb<0)cout<<"yes ncb";
  
  cout<<(base-(nca+ncb)+2*mod)%mod;
}

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


int main(){
    int a,b;
    cin >> a >> b;
    int ans =0;
    for(int i=a;i<=b;i++){
        if(i / 10000 == i % 10 && i / 1000 % 10 == i /10 % 10 )ans++;
    }
    cout << ans << endl;
 }

Measured memory_bytes: 256
//package hiougyf;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner sc =new Scanner(System.in);
		 String s=sc.next();
		 int nas=0;
		 String a=sc.next();
		 for(int i=0;i<s.length();i++) {
			 if(s.charAt(i)!=a.charAt(i)) nas++;
		 }
		 System.out.println(nas);
		}
}


Measured memory_bytes: 41164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int allSum = 0;
		int sum = 0;
		for (int i = 1; i <= n; i++) {
			sum = 0;
			for (int j = 1; j <= getDigit(i); j++) {
				sum += getNumOfKeta(i, j);
			}
			if (a <= sum && sum <= b) {
				allSum += i;
			}
		}
		System.out.println(allSum);
	}

	public static int getDigit(int x) {
		int count = 1;
		int temp = x;
		while(true) {
			temp /= 10;
			if (temp >= 1) {
				count++;
			} else {
				return count;
			}
		}
	}

	public static int getNumOfKeta(int x, int keta) {
		int num = 0;
		int ten = 1;
		for (int i = 0; i < keta; i++) {
			ten *= 10;
		}
		int temp = x % ten;
		num = temp / (ten / 10);
		return num;
	}

}


Measured memory_bytes: 23252
while True:
    try:
        l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,v1,v2=map(int,input().split(","))
        kyo=0
        for i in l1,l2,l3,l4,l5,l6,l7,l8,l9,l10:
            kyo +=i
        v=v1+v2
        x=kyo/v
        ans=v1*x
        flag=0
        for j in l1,l2,l3,l4,l5,l6,l7,l8,l9,l10,0:
            if ans>0:
                ans -=j
                flag +=1
            else:
                print(flag)
                break
    except:break


Measured memory_bytes: 5600
//@HelloElwin20190819
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int n, m, ghd, hd[200005], tag[200005], ans[200005];
bool bk[200005];

struct Edge {
	int u, v, nxt;
}g[400005];

void AddEdge (int u, int v) {
	g[ghd] = (Edge){u, v, hd[u]};
	hd[u] = ghd++;
}

void Dfs (int u, int sum) {
	bk[u] = true;
	sum += tag[u];
	ans[u] += sum;
	for (int i = hd[u]; ~i; i = g[i].nxt) {
		int v = g[i].v;
		if (bk[v]) continue;
		Dfs(v, sum);
	}
}

int main() {
	
	scanf("%d %d", &n, &m);
	memset(hd, -1, sizeof(hd));

	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		AddEdge(a, b);
		AddEdge(b, a);
	}

	for (int i = 0; i < m; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		tag[a] += b;
	}

	Dfs(1, 0);

	for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);

	return 0;
}

Measured memory_bytes: 15616
(n,m),*t=[map(int,t.split())for t in open(0)]
e=[[]for _ in range(n+1)]
for a,b in t:
  e[a]+=b,
  e[b]+=a,
q=[1]
d=[0]*-~n
for v in q:
  for w in e[v]:
    if d[w]<1:
      d[w]=v
      q+=w,
print('Yes',*d[2:])

Measured memory_bytes: 107860
read a b

if [ $a -eq 1 ]
then
	a=$((a+13))
fi
if [ $b -eq 1 ]
then
	b=$((b+13))
fi

if [ $a -eq $b ]
then
	echo Draw
	exit
fi

if [ $a -gt $b ]
then
	echo Alice
else
	echo Bob
fi


Measured memory_bytes: 1396
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int modpow(int n,int m,int p){
    if(m == 0) return 1;
    if(m%2==0){
        int a=modpow(n,m/2,p);
        return ((long long int)a*a)%p;
    }
    return ((long long int)n*modpow(n,m-1,p))%p;
}

int modkai(int n,int m,int p){
    if(n == m) return 1;
    return ((long long int)modkai(n-1,m,p)*n)%p;
}

    

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int p  = 1000000007;
    int nCa = ((long long int)modkai(n,n-a,p)*modpow(modkai(a,0,p),p-2,p))%p;
    int nCb = ((long long int)modkai(n,n-b,p)*modpow(modkai(b,0,p),p-2,p))%p;
    int kai = ((long long int)(modpow(2,n,p) - nCa - nCb - 1))%p;
    if (kai >=0)cout << kai <<endl;
    else cout << kai + p <<endl;
    
    
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const int N = 2e5+5;
const ll mod = 998244353 ;
typedef pair<int,int> pii;


void TEST_CASES(int cas)
{
    ll n,m;
    cin>>n>>m;
    vector<ll>a(n);
    vector<ll>p(n+1);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        a[i]%=m;
    }
    for(ll i=1;i<=n;i++)
    {
        p[i] = p[i-1] + a[i-1];
        p[i]%=m;
    }
    map<ll,ll>cnt;
    ll ans = 0;
    for(ll i=0;i<=n;i++)
    {
        ans+= cnt[p[i]];
        cnt[p[i]]++;
    }
    cout<<ans<<"\n";

}



/*

*/

int main()
{
#ifndef APURBA
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt","r",stdin);
    //freopen("out1.txt","w",stdout);

    int t=1,cas=0;
    //cin>>t;
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 8548
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int a;
	cin>>a;
	
	cout<<a+a*a+a*a*a<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int n,k,ans,tmp,ok,cnt,ra,tot;
string s;
vector<int>v,vv;
int main(void){
    cin>>n>>k>>s;
    if(s[0]=='1'){ok=1;cnt++;tmp=1;}
    else {cnt++;tmp=0;ra++;}
    for(int i=1;i<n;i++){
        if(s[i]=='0'&&tmp==0)cnt++;
        else if(s[i]=='1'&&tmp==1)cnt++;
        else if(s[i]=='0'){
            ra++;
            v.push_back(cnt);
            cnt=1;
            tmp=0;
        }
        else if(s[i]=='1'){
            v.push_back(cnt);
            cnt=1;
            tmp=1;
        }
    }
    v.push_back(cnt);
    if(ra-k+1<=1){
        cout<<n<<endl;
        return 0;
    }
    vv.push_back(0);
    if(ok==0)vv.push_back(0);
    for(int i=0;i<v.size();i++){
        tot+=v[i];
        vv.push_back(tot);
    }
    vv.push_back(tot);
    for(int i=0;i<ra-k+1;i++){
        //cout<<vv[i*2+2*k+1]<<vv[i*2]<<endl;
        ans=max(ans,vv[i*2+2*k+1]-vv[i*2]);
    }
    //cout<<ra<<endl;
    cout<<ans<<endl;
}



Measured memory_bytes: 1528
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;



int main()
{
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if (s == u){
        cout << a-1 << " " << b << endl;
    }
    else if (t == u){
        cout << a << " " << b-1 << endl;
        
    }
    else {
        cout << "ERROR" << endl;
    }
    
}




Measured memory_bytes: 256
def main():
    import sys,heapq
    input = sys.stdin.readline

    n,m = map(int,input().split())
    a = tuple(map(int,input().split()))


    #Union Find
    par = [-1]*n
    #xの根を求める
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]
    #xとyの属する集合の併合
    def unite(x,y):
        x = find(x)
        y = find(y)

        if x == y:
            return False
        else:
            #sizeの大きいほうがx
            if par[x] > par[y]:
                x,y = y,x
            par[x] += par[y]
            par[y] = x
            return True

    #xとyが同じ集合に属するかの判定
    def same(x,y):
        return find(x) == find(y)

    #xが属する集合の個数
    def size(x):
        return -par[find(x)]


    for _ in [0]*m:
        x,y = map(int,input().split())
        unite(x,y)
    
    if m < (n-1)//2:
        print('Impossible')
        return
    
    h = [[] for _ in [0]*n]
    for i,e in enumerate(a):
        heapq.heappush(h[find(i)],e)
    
    root = []
    for i,e in enumerate(par):
        if e < 0:
            root.append(i)
    
    if len(root) == 1:
        print(0)
        return

    must = 0
    opt = []
    for i in root:
        must += heapq.heappop(h[i])
        for e in h[i]:
            opt.append(e)
    opt.sort()

    print(must+sum(opt[:len(root)-2]))



if __name__ =='__main__':
    main()

Measured memory_bytes: 99640
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
  int i;
  int j[8];
  int n,a,a2,a3,b,b2,b3,c,c2,c3;
  int l[8];
  int ans=2997;
  int ans2;
  scanf("%d %d %d %d",&n,&a,&b,&c);
  for(i=0;i<n;i++)scanf("%d",&l[i]);
  for(j[0]=0;j[0]<4;j[0]++)for(j[1]=0;j[1]<4;j[1]++)for(j[2]=0;j[2]<4;j[2]++)for(j[3]=0;j[3]<4;j[3]++)for(j[4]=0;j[4]<4;j[4]++)for(j[5]=0;j[5]<4;j[5]++)for(j[6]=0;j[6]<4;j[6]++)for(j[7]=0;j[7]<4;j[7]++){
    a2=0;
    b2=0;
    c2=0;
    a3=0;
    b3=0;
    c3=0;
    ans2=0;
    for(i=0;i<n;i++){
      switch(j[i]){
      case 0:
        a2+=l[i];
        a3++;
        break;
      case 1:
        b2+=l[i];
        b3++;
        break;
      case 2:
        c2+=l[i];
        c3++;
        break;
      case 3:
        break;
      }
    }
    if(a3!=0 && b3!=0 && c3!=0){
      ans2=abs(a-a2)+abs(b-b2)+abs(c-c2)+10*(a3+b3+c3-3);
      if(ans>ans2)ans=ans2;
    }
  }
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#include <deque>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long K, std::vector<long long> V){
  ll ans = 0;
  for(ll i=0; i<=K; i++) {
    for(ll j=0; j<=K-i; j++) {
      if(i+j > N) break;
      ll d = K-i-j;
      ll now = 0;
      vector<ll> v;
      for(ll k=0; k<i; k++) {
	now += V[k];
	v.push_back(V[k]);
      }
      for(ll k=N-j; k<N; k++) {
	now += V[k];
	v.push_back(V[k]);
      }
      sort(v.begin(), v.end());
      for(ll k=0; k<d; k++) {
	if(k >= v.size()) break;
	if(v[k] > 0) break;
	now -= v[k];
      }
      ans = max(ans, now);
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long K;
  scanf("%lld",&K);
  std::vector<long long> V(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&V[i]);
  }
  solve(N, K, std::move(V));
  return 0;
}



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

cd.sort()
remain = set(range(n))

ans = 0
for c,d in cd:
    cand = [-1, -1]
    for i in remain:
        a,b = ab[i]
        if((a<c) & (b<d)):
            if(cand[1] < b):
                cand = [i,b]

    if(cand[0] == -1):
        continue

    remain.remove(cand[0])
    ans += 1


print(ans)

Measured memory_bytes: 39280
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	bool flag=true;

	cin>>n;

	vs w(n);

	rep(i, n){
		cin>>w[i];
		rep(j, i){
			if(w[i]==w[j]){
				flag=false;
			}
		}
		if(i!=0){
			if(w[i][0]!=w[i-1][w[i-1].size()-1]) flag=false;
		}
	}

	cout<<yn(flag)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<long>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    long nn = a[n-1];
    long rr = a[0];
    for(int i=1;i<n-1;i++){
      if(abs((nn+1)/2-a[i]) < abs((nn+1)/2-rr))rr = a[i];
    }
    cout << nn << " " << rr<<endl;
}


Measured memory_bytes: 1024
/* *>>>>>Anshit_Bhardwaj<<<<<* */
#include <bits/stdc++.h>
#define ll long long
#define f(i, x, n) for(int i = x; i < n; i++)
#define dbg(x) cout << x << endl
#define dbg2(x, y) cout << x << ' ' << y << endl
#define dbg3(x, y, z) cout << x << ' ' << y << ' ' << z << endl
#define mod 1000000007
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n);
    f(i, 0, n){
        cin >> arr[i];
    }
    sort(arr.begin(), arr.end());
    vector<char> sieve(1000001, 1);
    int ans = 0;
    f(i, 0, n){
        if(sieve[arr[i]]){
            if(i < n-1){
                if(arr[i] != arr[i+1]){
                    ans++;
                }
            }else{
                ans++;
            }
            for(int j = arr[i]; j <= arr[n-1]; j += arr[i]){
                sieve[j] = false;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5044
def main():
    n = int(input())
    d = {}
    ans = 0
    
    for _ in range(n):
        ss = ''.join(sorted(input()))
        d[ss] = d.get(ss, 0) + 1
        
    for v in d.values():
            ans += (v*(v-1)) // 2
         
    print(ans)
       
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 17852