akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<long long, long long> ii;
int N;
long long D, A;
ii XH[200000];
struct Fenwick {
	int size;
	vector<long long> f;
	Fenwick(int s) {
		size = s;
		f = vector<long long>(s + 1, 0);
	}
	void update(int a, int b, long long v) {
		for (; a <= size; a += a & -a) f[a] += v;
		for (++b; b <= size; b += b & -b) f[b] -= v;
	}
	long long query(int i) {
		long long ans = 0;
		for (; i > 0; i -= i & -i) ans += f[i];
		return ans;
	}
};
int main() {
	long long ans = 0;
	scanf("%d %lld %lld", &N, &D, &A);
	for (int i = 0; i < N; ++i) scanf("%lld %lld", &XH[i].first, &XH[i].second);
	sort(XH, XH + N);
	Fenwick ft(N);
	for (int i = 0; i < N; ++i) ft.update(i + 1, i + 1, XH[i].second);
	for (int i = 0; i < N; ++i) {
		long long temp = ft.query(i + 1);
		if (temp <= 0) continue;
		temp = (temp + A - 1) / A;
		int e = upper_bound(XH, XH + N, ii(XH[i].first + 2 * D, 1000000001)) - XH;
		ans += temp;
		ft.update(i + 1, e, -temp * A);
	}
	printf("%lld", ans);
	return 0;
}

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

int main(){
	int n,m;
	int num_n = 0;
	int num_m = 0;
	cin >> n >> m;
	if(n >= 2){
		num_n = n * (n-1) /2;
	}
	if(m >= 2){
		num_m = m * (m-1)/2;
	}
	cout << num_m + num_n;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main() {
	std::string s;
	while (std::cin >> s){
		int sum = 0;
		for (int i = 0; i != s.size(); i++){
			if (s[i] == 'I'){
				if (s[i + 1] == 'V') {
					sum += 4;i++;
				}
				else if (s[i + 1] == 'X'){
					sum += 9; i++;
				}
				else sum++;
			}
			else if (s[i] == 'V')sum += 5;
			else if (s[i] == 'X'){
				if (s[i + 1] == 'L'){
					sum += 40;i++;
				}
				else if (s[i + 1] == 'C'){
					sum += 90;i++;
				}
				else sum += 10;
			}
			else if (s[i] == 'L')sum += 50;
			else if (s[i] == 'C') {
				if (s[i + 1] == 'D'){
					sum += 400; i++;
				}
				else if (s[i + 1] == 'M'){
					sum += 900; i++;
				}
				else sum += 100;
			}
			else if (s[i] == 'D')sum += 500;
			else if (s[i] == 'M')sum += 1000;
		}
		std::cout << sum << std::endl;
	}
}

Measured memory_bytes: 3024
#include<stdio.h>
int main(){
  int x,y,ans1;
  scanf("%d%d",&x,&y);
  if(x<=0||y<=0||x>1000000001||y>1000000001){
    return 0;
  }
  int a,b;
  a=x;
  b=y;
  if(y>x){
    a=y;
    b=x;
  }
  while(1){
    ans1=a%b;
    if(ans1==0)break;
    else{
      a=b;
      b=ans1;
    }}
  printf("%d\n",b);
  return 0;
}



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

int main(){
    long long n, m;
    cin >> n >> m;

    vector<vector<long long> > s(m);
    for(long long i = 0; i < m; i++){
        long long k;
        cin >> k;
        for(long long j = 0; j < k; j++){
            long long a;
            cin >> a;
            s[i].push_back(a);
        }
    }

    long long p[m];
    for(long long i = 0; i < m; i++) cin >> p[i];


    vector<bool> switch_on(n);
    long long ans = 0;
    for(long long bit = 0; bit < (1 << n); bit++){
        for(long long mask = 0; mask < n; mask++){
            if(bit & (1 << mask)) switch_on[mask] = true;
            else switch_on[mask] = false;
        }

        long long light = 0;
        for(long long i = 0; i < m; i++){
            long long cnt_on = 0;
            for(long long j = 0; j < s[i].size(); j++){
                if(switch_on[s[i][j]-1] == true) cnt_on++;
            }
            if(p[i] == cnt_on % 2)light++;
        }
        if(light == m) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var r = input[0];
            var D = input[1];
            var x = input[2];

            for (int _ = 0; _ < 10; _++)
            {
                x = r * x - D;
                Console.WriteLine(x);
            }
        }
    }
}


Measured memory_bytes: 28000
import java.util.Scanner;

class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		int X = scanner.nextInt();
		int max = 1;

		for (int i = 1; i <= X; i++) {
			for (int j = 2; j <= X; j++) {
				double expo = Math.pow(i,  j);
				if (expo > X) {
					break;
				}

				if (max < expo) {
					max = (int)expo;
				}
				//System.out.println(i + "^" + j + "=" + (int)expo);
			}
		}
		System.out.println(max);
	}
}


Measured memory_bytes: 23124
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()
  val d = sc.nextInt()

  println(abc164b(a, b, c, d))
}

private fun abc164b(a: Int, b: Int, c: Int, d: Int): String {
  val ad = a.toDouble() / d.toDouble()
  val cb = c.toDouble() / b.toDouble()
  if (Math.ceil(ad) >= Math.ceil(cb)) return "Yes"

  return "No"
}


Measured memory_bytes: 36448
#include <stdio.h>

int main(){
    int n = 0, a[20], q, m[200],cnt=0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++){
        scanf("%d", &m[i]);
    }
    for (int i = 1; i < 1 << n; i++){
        int sum=0;
        for (int j = 0; j < n; j++){
            if(i >> j & 1){
                sum += a[j];
            }
        }
        for (int k = 0; k < q; k++){
            if (m[k] == sum){
                m[k] = 0;
            }
        }
    }
    for (int k = 0; k < q; k++){
        if (m[k]){
            printf("no\n");
        }
        else{
            printf("yes\n");
        }
    }
 
    return 0;
}

Measured memory_bytes: 1012
#include<bits/stdc++.h>
#define ll long long int
#define MM 1000005
#define MOD 1000000007
#define sync ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

bool comp(const pair<ll,ll> &p1,const pair<ll,ll> &p2)
{
    if(p1.first!=p2.first)
        return p1.first>p2.first;
    else
        return p1.second<p2.second;
}
ll check(ll n)
{
    ll hh=n/60,p=0;
    ll mm=n%60;
    while(hh>0){
        if(hh%10==7){
            p=1;break;
        }
        hh/=10;
    }
    while(mm>0){
        if(mm%10==7){
            p=1;break;
        }
        mm/=10;
    }
    return p;
}
int  main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    sync
    ll t=1;
    //cin>>t;
    ll tt=t;
    while(t--)
    {
        ll i,j,k,n,m,q,x=0,y=0,z=0,p=0,mx=0,sum=0;
        cin>>n>>m;
        if((n*m)%2==0) mx=1;
        if(mx)cout<<"Even"<<endl;
        else cout<<"Odd"<<endl;
    }
    return 0;
}


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

bool yaku(int m)
{
	int k = 0;
	for(int i = 1; i <= m; i++){
		if(m % i == 0) k += 1;
		if(k == 9) return 1;
	}
	if(k == 8) return 0;
	else return 1;
}

int main()
{
	int n;
	cin >> n;
	int k = 0;
	for(int i = 1; i <= n; i += 2){
		if(yaku(i) == 0) k += 1;
	}
	cout << k << endl;
	return 0;
}

Measured memory_bytes: 256
x = int(input())
y = [int(i) for i in input().split()]
y.sort(reverse=True)
a = 0
b = 0
for i in range(1, x+1):
    if (i % 2) != 0:
        a += y[i-1]
    else:
        b += y[i-1]
print(a-b)

Measured memory_bytes: 3064
import collections

n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=[0]+[collections.deque(arr[i]) for i in range(n)]
ans=0
cand=set(range(1,n+1))
while 1:
  check=set()
  for i in cand:
    if not arr[i]:
      continue
    pair=arr[i][0]
    if arr[pair][0]==i:
      check.add(i)
      check.add(pair)
  if not check:
    break
  cand=set()
  for i in check:
    cand.add(i)
    arr[i].popleft()
    if arr[i]:
      cand.add(arr[i][0])
  ans+=1
for i in range(1,n+1):
  if arr[i]:
    print(-1)
    break
else:
  print(ans)

Measured memory_bytes: 44196
#include <iostream>
using namespace std;
#include<set>
int z(int a){
if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12)return 100;
if (a == 2)return 1000;
if (a == 4 || a == 6 || a == 9 || a == 11)return 10000;
}
int main(){
	int a, b;
	cin >> a >> b;
	if (z(a) == z(b))cout << "Yes";
	else cout << "No";
}

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int n, m;

priority_queue<int> que;

int main()
{
    cin >> n >> m;
    rep(i, n)
    {
        int a;
        cin >> a;
        que.push(a);
    }

    rep(i, m)
    {
        int t = que.top();
        que.pop();
        que.push(t / 2);
    }

    ll ans = 0;
    while (!que.empty())
    {
        int t = que.top();
        ans += t;
        que.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
const int MAX=210000;
const long long MOD=1000000007;

typedef long long ll;

ll fac[MAX],finv[MAX],inv[MAX];

ll mod_pow(ll x, ll n){ //べき乗
    ll ans=1;
    x%=MOD;
    while(n!=0){
        if(n&1) ans=ans*x%MOD;
        x=x*x%MOD;
        n=n>>1;
    }
    return ans%MOD;
}

void com_init(){ //初期化
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        //inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        //finv[i]=finv[i-1]*inv[i]%MOD;
        finv[i]=finv[i-1]*mod_pow(i,MOD-2)%MOD;//フェルマーの小定理より
    }
}

ll comb(ll n, ll k){ //nCk
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
    int S; cin >> S;
    com_init();
    ll ans=0;
    for(int i=1;i<=S/3;i++){
        ans+=comb(S-2*i-1,i-1)%MOD;
        ans%=MOD;
    }
    cout << ans << endl;
}

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

void f(vector<int> &u){
    sort(u.begin(),u.end());
}

int main(){
    while(1){
        int x,y; cin >> x >> y;
        if(x == 0 && y == 0)break;
        else{
            vector<int> u = {x,y};
            f(u);
            cout << u[0] << " " << u[1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3064
# input
n, q = map(int, raw_input().split())
procs = [raw_input().split() for i in xrange(n)]
procs = list(reversed(procs))

# procsessing
cnt, lack = 0, 1
while lack > 0:
    lack = 0
    tprocs = []
    for i in xrange(n):
        proc = procs.pop()
        t = int(proc[1])
        if t <= q:
            cnt += t
            print proc[0], cnt
            n -= 1
        else: # t > q
            cnt += q
            t = t - q
            lack += t
            proc[1] = str(t)
            tprocs.append(proc)
    procs = list(reversed(tprocs))

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

int main(){
    int n;
    cin >>n;
    int digit3=n/100;
    int digit2=n-digit3*100;
    digit2=digit2/10;
    int digit1=n-digit3*100-digit2*10;
    if(digit3==9){
        digit3=1;
    }else if(digit3==1){
        digit3=9;
    }
    if(digit2==9){
        digit2=1;
    }else if(digit2==1){
    digit2=9;
    }
    if(digit1==9){
        digit1=1;
    }else if(digit1==1){
        digit1=9;
    }
    cout <<digit3*100+digit2*10+digit1;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, D, X, res = 0; cin >> N >> D >> X;
    rep (i, 0, N) {
        int in; cin >> in;
        rep (j, 0, D) {
            if (1+in*j <= D) res++;
            else break;
        }
    }
    cout << res + X << endl;
}

Measured memory_bytes: 256
// All Heil Fire Lord Zuko

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

#define F first
#define S second
#define PB push_back
#define debug(x) cerr << #x << " = " << x << endl

#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef long double ld;

const int N = 2 * 100 * 1000 + 19;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < sz(s); i ++)
        if (s[i] == t[i])
            ans ++;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports, non_snake_case, dead_code)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

const MODULO: u64 = 1_000_000_007;

struct Combination {
    MOD: u64,
    size: usize,
    fact: Vec<u64>,
    inv_fact: Vec<u64>,
}
impl Combination {
    fn new(size: usize, MOD: u64) -> Self {
        let mut fact = vec![1; size + 1];
        let mut inv_fact = vec![1; size + 1];
        for i in 1..size + 1 {
            fact[i] = fact[i - 1] * i as u64 % MOD;
        }
        inv_fact[size] = Self::modpow(fact[size], MOD - 2, MOD);
        for i in (1..size + 1).rev() {
            inv_fact[i - 1] = inv_fact[i] * i as u64 % MOD;
        }
        Combination {
            MOD,
            size,
            fact,
            inv_fact,
        }
    }
    fn modpow(mut x: u64, mut y: u64, m: u64) -> u64 {
        let mut res: u64 = 1;
        while y > 0 {
            if y & 1 > 0 {
                res = res * x % m;
            }
            x = x * x % m;
            y >>= 1;
        }
        res
    }
    fn modinv(x: u64, m: u64) -> u64 {
        Self::modpow(x, m - 2, m)
    }
    fn nPr(&self, n: usize, r: usize) -> u64 {
        if n < r {
            return 0;
        };
        self.fact[n] * self.inv_fact[n - r] % self.MOD
    }
    fn nCr(&self, n: usize, r: usize) -> u64 {
        if n < r {
            return 0;
        };
        self.fact[n] * self.inv_fact[r] % self.MOD * self.inv_fact[n - r] % self.MOD
    }
}

#[fastout]
fn main() {
    input!{
        N: usize
    }
    let ncr = Combination::new(N * 2, MODULO);
    let mut ans = 0;
    for i in 1..N/3+1 {
        ans = (ans + ncr.nCr(N-i*3+i-1, i-1)) % MODULO;
    }
    println!("{}", ans);

}


Measured memory_bytes: 2236
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

n, m, d = map(int, input().split())
if d == 0:
    ans = (m - 1) / n
else:
    ans = 2 * (n - d) * (m - 1) / (n * n)
print(ans)


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

int main() {
    int N, K; cin >> N >> K;
    int ans = K;
    for (int i = 0; i < N - 1; i++) {
        ans *= K - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200500],num[200500],n;
long long ans;
int main() {
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i],num[a[i]]++;
    for(int i=1;i<=n;i++)
        ans+=1LL*num[i]*(num[i]-1)/2;
    for(int i=1;i<=n;i++)
	{
        ans-=1LL*num[a[i]]*(num[a[i]]-1)/2;
        num[a[i]]--;
        printf("%lld\n",ans+1LL*num[a[i]]*(num[a[i]]-1)/2);
        num[a[i]]++;
        ans+=1LL*num[a[i]]*(num[a[i]]-1)/2;
    }
    return 0;
}

Measured memory_bytes: 3712
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			//final int W = 100;
			final int W = 100;
			final int H = 100;
			final int half_H = 50;
			ArrayList<ArrayList<Character>> board = new ArrayList<ArrayList<Character>>();
			for(int i = 0; i < H; i++){
				board.add(new ArrayList<Character>());
			}
			
			// A
			for(int i = 0; i < half_H; i++){
				for(int j = 0; j < W; j++){ board.get(i).add('#'); }
			}
			// B
			for(int i = half_H; i < H; i++){
				for(int j = 0; j < W; j++){ board.get(i).add('.'); }
			}
			
			
			
			int curr_A = 1;
			int curr_B = 1;
			
			LOOP_A:
			for(int i = 0; curr_A < A && i < half_H; i += 2){
				for(int j = 1; j < W; j += 2){
					board.get(i).set(j, '.');
					curr_A++;
					
					if(curr_A == A){ break LOOP_A; }
				}
			}
			
			LOOP_B:
			for(int i = H - 1; curr_B < B && i >= half_H; i -= 2){
				for(int j = 1; j < W; j += 2){
					board.get(i).set(j, '#');
					curr_B++;
					
					if(curr_B == B){ break LOOP_B; }
				}
			}
			
			
			try(final PrintWriter pw = new PrintWriter(System.out)){
				pw.println(H + " " + W);
				for(ArrayList<Character> line : board){
					for(int i = 0; i < W; i++){
						pw.print(line.get(i));
					}
					pw.println();
				}				
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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


int main() {
    int N;
    std::cin >> N;

    std::map<long long int, long long int> A;
    for (int i = 0; i < N; i++) {
        int in;
        std::cin >> in;
        if (A.find(in) == A.end()) {
            A[in] = 0;
        }
        A[in]++;
    }
    int Q;
    std::cin >> Q;
    long long int sum = 0;
    for (auto && pair : A) {
        sum += pair.first * pair.second;
    }
    for (int i = 0; i < Q; i++) {
        int B, C;
        std::cin >> B >> C;
        if (A.find(C) == A.end()) {
            A[C] = 0;
        }
        if (A.find(B) != A.end()) {
            sum += (C - B) * A[B];
            A[C] += A[B];
            A.erase(B);
        }
        std::cout << sum << std::endl;
    }
}


Measured memory_bytes: 7592
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll A, B;
    cin >> A >> B;
    if (A <= 5) {
        cout << 0 << endl;
    } else if (A <= 12) {
        cout << B / 2 << endl;
    } else {
        cout << B << endl;
    }
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	cout << (s == "abc" ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
N=int(input())
D = [input().split() for i in range(N)]
cnt=0
for i in range(N):
    if D[i][0]==D[i][1]:
        cnt+=1
        if cnt==3:
            break
    else:
        cnt=0
if cnt==3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <stdio.h>

int main()
{
    int a, b, c, ab, ac, bc;
    scanf("%d %d %d", &a, &b, &c);

    ab = a+b;
    ac = a+c;
    bc = b+c;

    if(ab<ac && ab<bc)
    {
        printf("%d", ab);
    }
    else if(ac<ab && ac<bc)
    {
        printf("%d", ac);
    }
    else
    {
        printf("%d", bc);
    }

    return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

int main(void) {
  while(1){
    int n,m;cin>>n>>m;
    if(!(n||m))break;
    vector<int> t(n),h(m);
    REP(i,n)cin>>t[i];
    REP(i,m)cin>>h[i];
    int ts=0,hs=0;
    REP(i,n)ts+=t[i];
    REP(i,m)hs+=h[i];
    int smin = INF;
    int tmin = INF;
    int hmin = INF;
    REP(i,n){
      REP(j,m){
        if(ts-t[i]+h[j]==hs+t[i]-h[j]){
          if (smin > t[i]+h[j]){
            tmin=t[i];
            hmin=h[j];
            smin=t[i]+h[j];
          }
        }
      }
    }
    if(smin == INF){
      cout<<-1<<endl;
    }else{
      cout<<tmin<<' '<<hmin<<endl;
    }
  }
  return 0;
}

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

int main()
{
	int n;
	do {
		cin >> n;
		int score_a = 0, score_b = 0;
		for (int i = 0; i < n; i++) {
			int inp_a, inp_b;
			cin >> inp_a >> inp_b;
			if (inp_a == inp_b) {
				score_a += inp_a;
				score_b += inp_b;
			}
			else {
				(inp_a>inp_b ? score_a : score_b) += inp_a + inp_b;
			}
		}
		if (n > 0 && n <= 10000) {
			cout << score_a << ' ' << score_b << '\n';
		}
	} while (n > 0 && n <= 10000);

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  string s; 
  cin >> s;
  vector<bool> a(26);
  for(int i=0; i<26; ++i) a[i] = false;

  for(int i=0; s[i]!='\0'; ++i){
    a[s[i] - 'a'] = true;
  }
  for(int i=0; i<26; ++i){
    if(a[i]==false){
      cout << (char)(i+'a') << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}

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

const ll INF = 1ll<<60;

typedef pair<ll,ll> P;

int main() {
  ll n, x, d;
  cin >> n >> x >> d;

  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n+1 << endl;
    }
    return 0;
  }

  map<int,vector<P>> mp;
  rep(i,n+1) {
    ll s = x*i;
    ll l = (ll)i*(i-1)/2;
    ll r = l + (ll)i*(n-i);
    s += l*d;
    r -= l;
    mp[(s+(d<<30))%d].emplace_back(s,r);
  }

  ll ans = 0;
  for (auto p : mp) {
    auto a = p.second;
    int m = a.size();
    rep(i,m) a[i].first = (a[i].first-p.first)/d;
    vector<P> ev;
    rep(i,m) {
      ev.emplace_back(a[i].first, 1);
      ev.emplace_back(a[i].first+a[i].second+1, -1);
    }
    sort(ev.begin(), ev.end());
    ll cnt = 0, pre = -INF;
    for (auto e : ev) {
      ll len = e.first-pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    string a,b;int ans=0;cin>>a>>b;
    for(int i=0; i<3; i++)if(a[i]==b[i])ans++;
    cout<<ans;
    
    
    
    
    
    return 0;
}


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

typedef long long LL;
int main(int argc, char* argv[])
{
	int N,i;
	cin>>N;
	vector<LL> A(N);
	int pNum=0;
	int mNum=0;
	LL MinAbs=10e9;
	for (i=0;i<N;i++){
		cin>>A[i];
		if (A[i]>=0){
			pNum++;
		}else{
			mNum++;
		}
		LL absV=A[i];
		if (absV<0){
			absV=-absV;
		}
		if (MinAbs>absV){
			MinAbs=absV;
		}
	}
	LL MaxV=0;
	if (mNum%2==0){
		for (i=0;i<N-1;i++){
			if (A[i]<0){
				A[i]=-A[i];
				A[i+1]=-A[i+1];
			}
		}
	}else{
		for (i=0;i<N-1;i++){
			if (A[i]<0){
				if (A[i]==-MinAbs){
					continue;
				}
				A[i]=-A[i];
				A[i+1]=-A[i+1];
			}else if (A[i]>0){
				if (A[i]==MinAbs){
					A[i]=-A[i];
					A[i+1]=-A[i+1];
				}
			}
		}
	}
	for (i=0;i<N;i++){
		MaxV+=A[i];
	}
	cout<<MaxV<<endl;
	return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:u32 = read();
    let b:Vec<String> = (0..n).map(|_| read()).collect();
    let m:u32 = read();
    let r:Vec<String> = (0..m).map(|_| read()).collect();

    let mut l = b.clone();
    l.sort();
    l.dedup();
    let mut ans:i32 = 0;
    for i in l {
        let temp:i32 = b.iter().filter(|&j| *j == i).count() as i32 - r.iter().filter(|&k| *k == i).count() as i32;
        if temp > ans {
            ans = temp;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;

int calc_area(int st_ix, int en_ix){
  return (en_ix - st_ix - 1) + 1;
}

int main(){
  string S;
  cin >> S;
  
  int ans = 0;
  int tmp_area = 0;

  typedef pair<int, int> P;
  
  stack<int> s;
  stack<P> s_ix_area;
  stack<P> rev_s_ix_area;
  rep(i, 0, S.length()){
    if(S[i] == '\\'){
      s.push(i);
    }
    else if(S[i] == '/' && !s.empty()){
      int st_ix = s.top(); s.pop();
      int area = calc_area(st_ix, i);
      int tmp_area = area;
      while(!s_ix_area.empty() && st_ix < s_ix_area.top().first){
	tmp_area += s_ix_area.top().second; s_ix_area.pop();
      }
      ans += area;
      s_ix_area.push(make_pair(i, tmp_area));
    }
  }
  while(!s_ix_area.empty()){
    rev_s_ix_area.push(s_ix_area.top());
    s_ix_area.pop();
  }
  
  cout << ans << endl;
  cout << rev_s_ix_area.size();
  while(!rev_s_ix_area.empty()){
    cout << " " << rev_s_ix_area.top().second;
    rev_s_ix_area.pop();
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 3308
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll popcount(ll n){
    ll ret=0;
    while(n>0){
        ret+=n%2;
        n/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll bit[800010];
ll u;
void bitinit(ll n){
    ll y=1;
    rep(i,0,69){
        
        if(y>=n){
            u=y;
            break;
        }
        y*=2;
    }
    fill(bit,bit+u+10,0);
}
void add(ll n,ll x){
    ll i=n;
    bit[i]+=x;
    bit[i]%=mod;
    while(i<u){
        i+=i&(-i);
        bit[i]+=x;
        bit[i]%=mod;
    }
}
ll sum(ll n){
    ll i=n;
    ll ret=0;
    while(i>0){
        ret+=bit[i];
        i-=i&(-i);
        ret%=mod;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[3*n];
    rep(i,0,3*n)cin>>a[i];
    multiset<ll> st;
    ll sum[3*n];
    sum[n-1]=0;
    rep(i,0,n){
        st.insert(a[i]);
        sum[n-1]+=a[i];
    }
    rep(i,n,2*n){
        st.insert(a[i]);
        ll r=*st.begin();
        st.erase(st.begin());
        sum[i]=sum[i-1]+a[i]-r;
    }
    ll su[3*n];
    su[2*n]=0;
    st.clear();
    rrep(i,3*n-1,2*n){
        st.insert(a[i]);
        su[2*n]+=a[i];
    }
    rrep(i,2*n-1,n){
        st.insert(a[i]);
        auto itr=st.end();
        itr--;
        ll r=*itr;
        st.erase(itr);
        su[i]=su[i+1]+a[i]-r;
    }
    
    ll ans=-inf;
    rep(i,n,2*n+1){
        ans=max(sum[i-1]-su[i],ans);
        //cout<<sum[i-1]<<" "<<su[i]<<endl;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 8832
import collections
n=int(input())
a= list(map(int, input().split()))

mod = 10**9+7
c = collections.Counter(a)
c =c.most_common()
c.sort()

if n%2==0:
    for i in range(len(c)):
        if c[i][0]==i*2+1 and c[i][1]==2:
            continue
        else:
            print(0)
            exit()
    ans=pow(2,n//2,mod)
    print(ans)

else:
    for i in range(len(c)):
        if i==0:
            if c[i][0]==0 and c[i][1]==1:
                continue
            else:
                print(0)
                exit()
        else:
            if c[i][0] == i * 2 and c[i][1] == 2:
                continue
            else:
                print(0)
                exit()
    ans=pow(2,n//2,mod)
    print(ans)

Measured memory_bytes: 59244
#include <stdio.h>
int main( )
{
  int a,b,c;
  scanf("%d%d%d",&a, &b, &c);
 
  if(a<=b && b<=c)
    printf("%d %d %d\n",a,b,c);
  if(a<=c && c<=b)
    printf("%d %d %d\n",a,c,b);
  if(b<a && a<c)
    printf("%d %d %d\n",b,a,c);
  if(b<=c && c<=a)
    printf("%d %d %d\n",b,c,a);
  if(c<a && a<b)
    printf("%d %d %d\n",c,a,b);
  if(c<b && b<a)
    printf("%d %d %d\n",c,b,a);

  return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>

using namespace std;

int main() {

	string str;

	cin >> str;

	int sum =0;

	for (int i = 0; i < str.size(); i++) {
		int a = str.at(i) - '0';
		sum += a;
	};

	if (sum % 9 == 0)
		cout << "Yes";
	else
		cout << "No";

}

Measured memory_bytes: 3720
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	ll ans = 0, A = 0, B = 0,BA = 0;
	REP(i, N) {
		string S;
		cin >> S;
		REP(j, SZ(S) - 1) {
			if (S[j] == 'A' && S[j + 1] == 'B') {
				ans++;
			}
			
		}
		if (S[0] == 'B' && S[SZ(S) - 1] == 'A') {
			BA++;
		}
		else if (S[0] == 'B') {
			B++;
		}
		else if (S[SZ(S) - 1] == 'A') {
			A++;
		}
	}
	if (BA == N) {
		cout << N - 1 + ans<< endl;
		return 0;
	}
	if (A == 0) {
		if (BA == 0) {
			cout << ans << endl;
			return 0;
		}
		BA--;
		A++;
	}
	A--;
	ans += BA;
	if (B != 0) {
		B--;
		ans++;
	}
	ans += min(A, B);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

d = {}
for y in range(H):
    for x in range(W):
        d[A[y][x]] = (y, x)

t = [[0] * (H * W // D + 1) for _ in range(D)]
for i in range(D):
    ti = t[i]
    j = 0
    if i == 0:
        j = 1
    while i + (j + 1) * D <= H * W:
        y1, x1 = d[i + j * D]
        y2, x2 = d[i + (j + 1) * D]
        ti[j + 1] = abs(y1 - y2) + abs(x1 - x2)
        j += 1
    for j in range(H * W // D):
        ti[j + 1] += ti[j]

Q = int(input())
result = []
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    result.append(t[i][(R - i) // D] - t[i][(L - i) // D])
print('\n'.join(str(i) for i in result))


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

vector<int> viSort;
int iMaxSize;

void fnTrace()
{
  for (int i = 0; i < iMaxSize; i++)
  {
    if (i) cout << " ";
    cout << viSort[i];
  }
  cout << endl;
}

void insertionSort()
{
  for (int i = 1; i < iMaxSize; i++)
  {
    int iTarget = viSort[i];
    int j = i - 1;
    while (iTarget < viSort[j] &&
           j       >= 0            )
    {
      viSort[j + 1] = viSort[j];
      j--;
    }
    viSort[j + 1] = iTarget;
    fnTrace();
  }
}

int main()
{
  cin >> iMaxSize;
  viSort.resize( iMaxSize );
  for (int i = 0; i < iMaxSize; i++) cin >> viSort[i];

  fnTrace();
  insertionSort();

  return 0;
}

Measured memory_bytes: 1200
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int H = sc.nextInt();

		int W = sc.nextInt();

		int white = 0;

		char[][] maze = new char[H][W];

		for(int i=0;i<H;i++) {

			String s = sc.next();

			for(int j=0;j<W;j++) {

				maze[i][j] = s.charAt(j);

				if(maze[i][j] == '.') white++;
			}
		}

			Queue<Point> q = new LinkedList<Point>();

			q.add(new Point(0,0,0));

			int[] dx = {-1,0,1,0};

			int[] dy = {0,-1,0,1};

			int nstep = 0;

			while(q.size()>0) {

				Point p = q.poll();

				for(int i=0;i<4;i++) {

				int nx = p.x + dx[i];

				int ny = p.y + dy[i];

				nstep = p.step + 1;

				if(ny>=0 && nx>=0 && ny<H && nx<W) {

					if(ny == H-1 && nx == W-1) {


						System.out.println(white-nstep-1);

						return;
					}else if(maze[ny][nx] == '.') {

						q.add(new Point(ny,nx,nstep));

						maze[ny][nx] = '#';
					}

				}
				}

				if(q.size() == 0)	System.out.println(-1);


			}


	}
	public static class Point{

		int y;

		int x;

		int step;

		public Point(int y ,int x, int step) {

			this.y = y;

			this.x = x;

			this.step = step;

		}
	}

}


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

string s;
const int mod = 2019;
int n, ans;

int r[2019] = { 1 };

int main() {
	cin >> s;
	n = s.size();
	for (int i = 0, d = 1, m = 0; i < n; i++, d = d * 10 % mod) {
		m = (m + (s[n - 1 - i] - '0') * d) % mod;
		r[m]++;
	}
	for (int i = 0; i < mod; i++)
		ans += r[i] * (r[i] - 1) / 2;
	cout << ans << endl;

}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int cnt;
void selectionSort(int a[],int n){
  for(int i=0;i<n;++i){
    int min=i;
    for(int j=i;j<n;++j)
      if(a[j]<a[min]) min=j;
    if(min!=i){
      swap(a[i],a[min]);
      cnt++;
    }
  }
}
int main(){
  int n,a[101];
  cin>>n;
  for(int i=0;i<n;++i) cin>>a[i];
  selectionSort(a,n);
  for(int i=0;i<n;++i) cout<<a[i]<<(i==n-1?"\n":" ");
  cout<<cnt<<endl;
  return 0;
}

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

public class Node
{
    public int nno { get; set; }
    public int one { get; set; }
    public int zero { get; set; }
}

public class hello
{
    public static void Main()
    {
        var nodes = new List<Node>();
        NodeSet(nodes);
        while (true)
        {
            var s = Console.ReadLine().Trim();
            if (s == "#") break;
            var wn = nodes[0];
            for (int i = 0; i < s.Length; i++)
            {
                switch(s[i])
                {
                    case '0':
                        if (wn.zero != -1) wn = nodes[wn.zero];
                        else { Console.WriteLine("No");   goto next; }
                        break;
                    case '1':
                        if (wn.one != -1) wn = nodes[wn.one];
                        else { Console.WriteLine("No"); goto next; }
                        break;
                }
            }
            if (wn.nno == 5) Console.WriteLine("Yes");
            else Console.WriteLine("No");
            next:;
        }
    }
    public static void NodeSet (List<Node> n)
    {
        n.Add(new Node { nno = 0,   zero = 1, one = 2 });
        n.Add(new Node { nno = 1, zero = -1, one = 3 });
        n.Add(new Node { nno = 2, zero = 1, one = -1 });
        n.Add(new Node { nno = 3, zero = 4, one = 5 });
        n.Add(new Node { nno = 4, zero = 5, one = 2 });
        n.Add(new Node { nno = 5, zero = 2, one = 1 });
    }
}

Measured memory_bytes: 8828
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

	static class TaskC {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
				sum += a[i];
			}
			boolean[] f = new boolean[sum + 1];
			f[0] = true;
			for (int x : a) {
				for (int i = sum; i >= 0; i--) {
					if (f[i] && i + x <= sum) {
						f[i + x] = true;
					}
				}
			}
			int ans = 0;
			for (int i = 0; i <= sum; i++) {
				if (i % 10 == 0) {
					continue;
				}
				if (f[i]) {
					ans = Math.max(ans, i);
				}
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}



Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int maxn=1e5+10;
int data[maxn],n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",data+i);
    sort(data+1,data+n+1);
    int cnt=0;
    for(int i=1;i<=n;i++) if(i>1&&data[i]==data[i-1]) cnt++;
    if(cnt%2==0) printf("%d\n",n-cnt);else printf("%d\n",n-cnt-1);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10

int main() {
	ll n, m, d; cin >> n >> m >> d;

	double ans = double(m-1) * (double)(2 * (n-d) / (double)(n*n));
	if (d == 0)ans /= 2;

	cout << fixed << setprecision(10) << ans << endl;







	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;

	for (int i = 0; i < 3; i++) {
		if (S[i] == '7') {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

}






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

LL D,N;
LL a[20];
LL Pow[20];

LL chec () {
	LL re = 1;
	for(LL i = 1;i <= N / 2;++i) {
        LL yinzi = (10 - abs(a[i]));
		if(i == 1 && a[i] >= 0)
			yinzi--;
		re = re * yinzi;
	}
	if(N & 1) {
		LL yinzi = 10;
		if(N == 1)
			--yinzi;
		re = re * yinzi;
	}
	return re;
}

LL dfs (LL u,LL lef) {
	if(u > N / 2) {
		if(lef != 0)
			return 0;
		return chec();
	}

	if(9 * (Pow[N - u] - Pow[u - 1]) < lef) {
		a[u] = 9;
		return dfs(u + 1,lef - 9 * (Pow[N - u] - Pow[u - 1]));
	}
	if(-9 * (Pow[N - u] - Pow[u - 1]) > lef) {
		a[u] = -9;
		return dfs(u + 1,lef + 9 * (Pow[N - u] - Pow[u - 1]));
	}
    if(lef % (Pow[N - u] - Pow[u - 1]) == 0) {
		a[u] = lef / (Pow[N - u] - Pow[u - 1]);
		return dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
    }
    LL re = 0;
    a[u] = abs(lef) / (Pow[N - u] - Pow[u - 1]);
    if(lef > 0) {
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
		a[u]++;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
    }
	else {
		a[u] *= -1;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
		a[u]--;
		re += dfs(u + 1,lef - a[u] * (Pow[N - u] - Pow[u - 1]));
	}
	return re;
}

int main () {
	//freopen("1.txt","r",stdin);
	scanf("%lld",&D);
	Pow[0] = 1;
	for(LL i = 1;i <= 17;++i)
		Pow[i] = Pow[i - 1] * 10;

	LL pr = 0;
	for(LL i = 1;i <= 18;++i) {
		N = i;
		pr += dfs(1,D);
	}
	printf("%lld\n",pr);
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, k; cin >> n >> k;
  vi v(n);
  REP(i, n) cin >> v[i];
  sort(ALL(v));
  int ans = 0;
  REP(i, k) {
    ans += v[i];
  }
  cout << ans << endl;

}








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

int main(void) {
    int n, v[55], c[55];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> c[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (v[i] > c[i]) {
            ans += v[i] - c[i];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<iomanip>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
int main(){
  int a, b, c, n;
  cin >> a >> b >> c >> n;
  if(a >= n){
    cout << n << "\n";
    return 0;
  }
  if(a + b >= n){
    cout << a << "\n";
    return 0;
  }
  int d = n - a - b;
  cout << a - d << "\n";
}
  

Measured memory_bytes: 3676
<?php
$input = explode(" ", trim(fgets(STDIN)));
$a = (int)$input[0];
$b = (int)$input[1];
$c = (int)$input[2];

if (($a < $b) && ($b < $c)){
    echo "Yes".PHP_EOL;
} else {
    echo "No".PHP_EOL;
}
?>


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

int main(){
    //変数宣言
    int A,B,C,i;
    int a[2],b[2],c[2];
    cin >> A >> B >>C;
    a[0]=A,b[0]=B,c[0]=C;
    for (i=0;a[0]%2==0&&b[0]%2==0&&c[0]%2==0;i++){
        a[1]=(b[0]/2)+(c[0]/2);
        b[1]=(a[0]/2)+(c[0]/2);
        c[1]=(a[0]/2)+(b[0]/2);
        if (a[0]==a[1]&&b[0]==b[1]&&c[0]==c[1]){
            i = -1;
            break;
        }
        a[0]=a[1],b[0]=b[1],c[0]=c[1];
    }
    cout << i <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {



	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	// 入力
	int n = sca.nextInt();
	String[] s = new String[n];
	int[] t = new int[n];
	for(int i = 0; i < n; i++) {
		s[i] = sca.next();
		t[i] = sca.nextInt();
	}
	int inemuri = 0;
	String x = sca.next();
	for(int i = 0; i < n; i++) {
		if(s[i].equals(x)  == true) {
			inemuri = i;
		}
	}
	int ans = 0;
	for(int i = inemuri + 1; i < n; i++) {
		ans = ans + t[i];
	}

	System.out.println(ans);

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 21844
'use strict';

function Main(input) {
    const tmp = input.trim().split('\n');
    const D = Number(tmp[0]);
    const C = tmp[1].split(' ').map((v) => Number(v));
    const S = tmp
        .slice(2, 2 + D)
        .map((v) => v.split(' ').map((v) => Number(v)));
    const T = tmp.slice(-1 * D).map((v) => Number(v));

    let LastContestDays = Array(26).fill(0); // コンテストの種類ごとの最終開催日
    let currnetContestLebels = Array(26).fill(0); // ある開催日のコンテストごとの満足度
    let lebel = 0; // 満足度の累計

    for (let i = 1; i <= D; i++) {
        LastContestDays[T[i - 1] - 1] = i;
        for (let j = 0; j < C.length; j++) {
            if (LastContestDays[j] === i) {
                currnetContestLebels[j] = S[i - 1][j];
            } else {
                currnetContestLebels[j] = C[j] * (i - LastContestDays[j]) * -1;
            }
        }
        lebel += currnetContestLebels.reduce((acc, cur) => acc + cur);
        console.log(String(lebel));
    }

    return;
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 30912
#include<bits/stdc++.h>
#include<atcoder/all>
#define int long long
using namespace std;
using namespace atcoder;
int mn=10000000000000000;
void a(int x,int y){
  if(gcd(x,y)!=1)return;
  int A=inv_mod(x,y)*x;
  mn=min(mn,(A>1?A:A+x*y)-1);
}
signed main(){
  int N;
  cin>>N;
  N*=2;
  for(int i=1;i*i<=N;i++)
    if(N%i==0){
      a(i,N/i);
      a(N/i,i);
    }
  cout<<mn<<endl;
}

Measured memory_bytes: 3664