akhauriyash/Code-Regression huggingface dataset:
#![allow(unused_imports, unused_variables, dead_code, non_snake_case, unused_macros)]
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

struct ContestPrinter {
    s: String,
}

impl ContestPrinter {
    fn new() -> ContestPrinter {
        ContestPrinter {
        s: String::new(),
        }
    }

    fn print<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}", x).as_str());
    }

    fn println<T>(&mut self, x: T)
        where T: std::fmt::Display {
        self.s.push_str(format!("{}\n", x).as_str());
    }
}

impl std::ops::Drop for ContestPrinter {
    fn drop(&mut self) {
        print!("{}", self.s);
    }
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 { a }
    else { gcd(b, a % b) }
}

fn divisors(n: i64) -> Vec<i64> {
    let mut ret = Vec::new();
    if n == 1 { ret.push(1); return ret; }
    let mut i = 1;
    loop {
        if (n % i) == 0 {
            ret.push(i);
            if (i != 1) & ((i*i) != n) {
                ret.push(n / i);
            }
        }
        i += 1; if n < (i*i) { break; }
    }
    ret.push(n);
    ret
}

fn is_max_i64(num: i64) -> bool { if num == i64::max_value() { true } else { false } }

fn main() {
    let mut pr = ContestPrinter::new();
    
    let n = readl!(i64);
    let g = if n == 2 {
        let (a, b) = readl!(i64, i64);
        gcd(a, b)
    } else {
        let (a, b, c) = readl!(i64, i64, i64);
        gcd(gcd(a, b), gcd(b, c))
    };

    let mut ds = divisors(g);
    ds.sort();
    for d in ds {
        pr.println(d);
    }
}


Measured memory_bytes: 5036
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : d : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let (q, r) = divMod n (2 * d + 1)
  print $ if r == 0 then q else q + 1

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
<?php
// code
fscanf(STDIN, "%d", $n);

$odd_count = 0;
for($i = 1; $i <= $n; $i++){
    if($i % 2 !== 0){
        $odd_count++;
    }
}
echo sprintf('%.10f',($odd_count / $n)).PHP_EOL;

Measured memory_bytes: 4728
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long A, long B) {
    return max(
        A + (A - 1),
        A + B,
        B + (B - 1)
    );
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long A;
    A = input.front.to!long;
    input.popFront;

    long B;
    B = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(A, B);
    else
        solve(A, B).writeln;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
  int N,M;
  scanf("%d%d",&N,&M);
  int A[N];
  int sum=0;
  for(int i=0;i<N;i++){
    scanf("%d",&A[i]);
    sum+=A[i];
  }
  
  
  qsort(A, N, sizeof(int), compare_int);
  
  if(A[M-1] >= (double)sum/(4*M)){
    printf("Yes\n");
  }
  else printf("No\n");
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LL long long
#define Rg register
#define RI register int
#define RC register char
#define ed puts("") 
#define Pair pair<int,int>
#define space putchar(' ')
using namespace std;

template <typename tp> inline void read(tp & x)
{	
    x=0;
    RI f=1;
    RC c=getchar();
    while(c<'0' || c>'9'){if(c=='-') f=-1;c=getchar();}
    while(c>='0' && c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();} 
 	x*=f;
} 	

template <typename Tp> inline void print(Tp x)
{		
    if(x<0) x=-x,putchar('-');
    if(x>9) print(x/10);
    putchar(x%10+'0');
}
#define int long long
int a,b;
int maxx;

signed main()
{
	read(a),read(b);
	int i=a+b;
	int j=a-b;
	int k=a*b;
	print(max(max(i,j),k));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)


int main(){
    int d ;
    string n;
    cin >> d >> n;
    if (n == "100") cout << "101";
    else cout << n;
    rep(i,d) cout << "00";
    cout << endl;
    return 0;
}

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

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

    int ret = 0;
    REP(i, 4)
    {
        if (N[i] == '2') ++ret;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define MAX 1000005


int main()
{
 //O_O ;
 ll c=0;ll sum=0;
   ll t;
   cin>>t;
   for(ll i=1;i<=t;i++)
   {
       if(i%3==0)
        c++;
       else if(i%5==0)
        c++;
        else
            sum+=i;
   }
  cout<<sum<<nn;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	vector<int> a(n), to(n + 1);
	for(int i = 0; i < n; i++) cin >> a[i];
	if(k == 1){
		cout << 0 << endl;
		return 0;
	}
	long long ans = 0, sum = 0;
	map<int, int> cnt;
	cnt[0] = 1;
	to[0] = 0;
	for(int i = 1; i <= n; i++){
		if(i >= k) cnt[to[i - k]]--;
		sum += a[i - 1];
		sum %= k;
		int val = (sum - i) % k;
		val += k; val %= k;
		ans += cnt[val];
		cnt[val]++;
		to[i] = val;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        int[] primes = new int[5133];
        fillPrimes(primes, 50000);
        int[] results = new int[50001];
        for (int i = 0; i < primes.length; i++) {
            int p = primes[i];
            if (p > 25000) {
                break;
            }
            for (int j = i; j < primes.length; j++) {
                int sum = p + primes[j];
                if (sum > 50000) {
                    break;
                }
                results[sum]++;
            }
        }

        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            int n = Integer.parseInt(reader.readLine());
            if (n == 0) {
                break;
            }
            out.println(results[n]);
        }
    }

    private static int fillPrimes(int[] primes, int n) {
        boolean[] sieve = new boolean[n + 1];
        int k = (int) Math.sqrt(n);
        int i = 0;
        for (int p = 2; p <= n; p++) {
            if (sieve[p]) {
                continue;
            }
            primes[i++] = p;
            if (p <= k) {
                for (int q = p * 2; q <= n; q += p) {
                    sieve[q] = true;
                }
            }
        }
        return i;
    }
}

Measured memory_bytes: 11000
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int x;
    cin >> x;
    for (int A = -118; A <= 119; A++) {
        for (int B  = -118; B <= 119; B++) {
            if (A * A * A * A * A - B * B * B * B * B == x) {
                cout << A << " " << B <<endl;
                return 0;
            }
        }
    }


    return 0; 
}


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

int N;
vector<int> V;

int main(void) {
	cin >> N;
	int cnt = 0;
	for (int i = 1; i <= N; ++i) {
		int p;
		cin >> p;
		if (p == i)
			++cnt;
		else {
			if (cnt == 0)
				continue;
			else {
				V.push_back(cnt);
				cnt = 0;
			}
		}
	}
	if (cnt != 0)
		V.push_back(cnt);

	int ans = 0;
	for (int i = 0; i < (int)V.size(); ++i) {
		if (V[i] == 1)
			++ans;
		else if (V[i] % 2 == 0)
			ans += V[i] / 2;
		else
			ans += V[i] / 2 + 1;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
from sys import stdin
from collections import deque
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    G=[[] for _ in range(n+1)]
    for i in range(m):
        a,b=map(int,readline().split())
        G[a].append(b)
        G[b].append(a)

    ans=[0]*(n+1)
    flags=[False]*(n+1)
    flags[1]=True
    d=deque([1])
    while len(d)>0:
        now=d.popleft()
        v=now
        for u in G[v]:
            if flags[u]==False:
                flags[u]=True
                ans[u]=v
                d.append(u)

    print("Yes")
    for i in range(2,n+1):
        print(ans[i])
        
if __name__=="__main__":
    main()


Measured memory_bytes: 34932
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
/*
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = ((C[i - 1][j - 1] + C[i - 1][j]))%MOD;}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}*/
 
int main(){ //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);
ll n,k;cin>>n>>k;
if(n<=k) {cout<<min(n,k-n);return 0;}
if(n%k==0) {cout<<"0";return 0;}
cout<<min((n-((n/k)*k)),(abs((n-((n/k)*k))-k)));



return 0;}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) { 
   int score, out, B[10], n, i, sum, key;
   char s[10];
   scanf("%d", &n);
   while ( n != 0 ) {
      score = out = sum = 0; key = 3;
      while( key != 0 ) { B[key] = 0; key--;}
      while (out != 3 ) {
         scanf("%s", s);
         if ( s[1] == 'I') {
            if ( B[3] == 1) score++;
            if ( B[2] == 1) B[3] = 1;
            if ( B[1] == 1) B[2] = 1;
            B[1] = 1;
         } else if ( s[1] == 'O' ) {
            score = score + 1 + B[1] + B[2] + B[3];
            key = 3;
            while( key != 0 ) { B[key] = 0; key--;}
         } else if ( s[1] == 'U' ) out++;
      }
      printf("%d\n", score);
      n--;
   }
   return 0;
}

Measured memory_bytes: 1756
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999


int main(){
    bool white;
    bool data[100010];
    int n,k;
    while(cin>>n>>k&&(n||k)){
        rep(i,100010)data[i]=false;
        white=false;
        rep(i,k){
            int a;
            cin>>a;
            if(a==0)white=true;
            else data[a]=true;
        }
        
        
        
        int dp[100010][2];
        rep(i,100010)rep(j,2)dp[i][j] = 0;
        
        for(int i=1;i<=100000;i++){
            if(data[i]){
                dp[i][0] = dp[i-1][0]+1;
                dp[i][1] = dp[i-1][1]+1;
            }
            else{
                dp[i][1] = dp[i-1][0]+1;
                dp[i][0] = 0;
            }
        }
        int maxi[2]={-1,-1};
        
        
        rep(i,100010){
            rep(j,2){
                maxi[j] = max(dp[i][j],maxi[j]);
            }
        }
        if(white)   cout<<max(maxi[0],maxi[1])<<endl;
        else        cout<<maxi[0]<<endl;
    }
}

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

using namespace std;
const int maxn = 1e5 + 10;
int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    if(n & 1){
        cout << 2 * n;
    }
    else{
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <stack>
#include <queue>
#include <iomanip>
#include <cctype>
using namespace std;
typedef long long ll;
int main()
{
    int m,nmin,nmax;
    cin>>m>>nmin>>nmax;
    while(m&&nmin&&nmax)
    {
        vector<int> p(m);
        for(int i=0;i<m;i++)
        {
            cin>>p[i];
            
        }
        int cmax=-1;
        int ci=0;
        for(int i=nmax;i>=nmin;i--)
        {
            int t=p[i-1]-p[i];
            if(cmax<t)
            { cmax=t;
                ci=i;
                }
        }
            cout<<ci<<endl;
        cin>>m>>nmin>>nmax;
    }
    
    
    return 0;
}



Measured memory_bytes: 3092
#include <iostream>
#include <cstdio>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <cmath>
#include <ctime>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<ll> vl;
typedef vector< vector<ll> > vvl;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forv(i, v) forn(i, v.size())
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

int main() {
#ifdef NEREVAR_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n, m;
    cin >> n >> m;
    vi cnt(n, 1);
    vi may(n);
    may[0] = true;
    forn(i, m) {
        int x, y;
        scanf("%d %d", &x, &y);
        x--, y--;
        cnt[x]--;
        cnt[y]++;
        may[y] |= may[x];
        if (cnt[x] == 0) may[x] = false;
    }
    int ans = 0;
    forn(i, n) if (may[i]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
//////////////////////////
//      _        ____   //
//  U  /"\  u U /"___|  //
//   \/ _ \/  \| | u    //
//   / ___ \   | |/__   //
//  /_/   \_\   \____|  //
//   \\    >>  _// \\   //
//  (__)  (__)(__)(__)  //
//  Compro by NULL_CT©  //
//////////////////////////
// STL libs
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

// Boost
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/irange.hpp>

#define ALL(LIST) (LIST.begin()), (LIST.end())

using namespace std;
using boost::irange;
using boost::multiprecision::cpp_int;

constexpr int64_t MOD = 1000000007;

vector<int64_t> divisor(const int64_t &_n) {
  vector<int64_t> head, tail;
  for (int64_t i = 1; i * i <= _n; i++) {
    if (_n % i == 0) {
      head.push_back(i);
      if (i * i != _n)
        tail.push_back(_n / i);
    }
  }
  head.insert(head.end(), tail.rbegin(), tail.rend());
  return head;
}

int64_t kadanes(const vector<int64_t> &_ls) {
  int64_t highestMax = 0, currentMax = 0, length = _ls.size();
  for (int64_t i = 0; i < length; i++) {
    currentMax = max(_ls[i], currentMax + _ls[i]);
    highestMax = max(highestMax, currentMax);
  }
  return highestMax;
}

void execution();

int main() {
#ifndef DEBUG
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
#endif
  // cout<<fixed<<setprecision(20);

  execution();
  return 0;
}

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

void execution() {
  int n,k;
  cin>>n>>k;
  vector<int> h(n);
  for(int i:irange(n)){
    cin>>h[i];
  }
  sort(h.rbegin(),h.rend());

  int64_t ans=0;
  for(int i : irange(h.size())){
    if(0 < k){
      k--;
    }else{
      ans+=h[i];
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

	int n, m;
	int max=0;
	int count=1;
	vector<string> s, t;

	cin>> n;
	s.resize(n);
	for(int i=0;i<n;i++) cin>> s[i];
	cin>> m;
	t.resize(m);
	for(int i=0;i<m;i++) cin>> t[i];

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());

	s.emplace_back("1");

	//for(int i=0;i<n+1;i++) cout<< "  " << s[i] << endl;

	for(int i=0;i<n;i++){
		if(s[i]==s[i+1]){
			count++;
		}else{
			for(int j=0;j<m;j++){
				if(s[i]==t[j]) count--;
			}
			if(max<count) max=count;
			count=1;
		}
	}

	cout<< max << endl;


}

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

using namespace std;

#define N 100000
#define pb push_back

int n, m, tot, d[N + 5], fa[N + 5], sum[N + 5], X, Y, cir[N + 5], a[N + 5];
vector<int> G[N + 5];

int find(int x) {
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

void dfs(int u, int pa) {
    fa[u] = pa;
    sum[u] = (d[u] & 1) ? -1 : 1;
    for (auto v : G[u]) {
        if (v == pa) continue;
        d[v] = d[u] + 1;
        dfs(v, u);
        sum[u] += sum[v];
    }
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i)
        fa[i] = i;
    for (int i = 1, x, y, fx, fy; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        fx = find(x), fy = find(y);
        if (fx == fy) {
            X = x, Y = y;
            continue;
        }
        G[x].pb(y), G[y].pb(x);
        fa[fy] = fx;
    }
    if (X == 0) X = 1;
    // printf("X:%d Y:%d\n", X, Y);
    dfs(X, 0);
    // for (int i = 1; i <= n; ++i)
    //     printf("%d ", sum[i]);
    // printf("\n");
    if (m == n - 1) {
        if (sum[X])
            return puts("-1"), 0;
    }
    else {
        int t = Y;
        cir[++tot] = t;
        while (fa[t]) t = fa[t], cir[++tot] = t;
        // printf("tot:%d\n", tot);
        if (tot & 1) { // 奇环
            if (sum[X] & 1)
                return puts("-1"), 0;
            for (int x = Y; x; x = fa[x])
                sum[x] -= sum[X] >> 1;
        }
        else { // 偶环
            if (sum[X])
                return puts("-1"), 0;
            for (int i = 1; i <= tot; ++i)
                a[i] = sum[cir[i]];
            sort(a + 1, a + tot + 1);
            for (int x = Y; x; x = fa[x])
                sum[x] -= a[tot >> 1];
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans += abs(sum[i]);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 13952
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,W; cin>>n>>W;
  vector<long long> w(n+1),v(n+1);
  vector<vector<long long>> t(n+1,vector<long long>(W+1,0));
  for(int i=1;i<=n;i++){ cin>>w[i]>>v[i];}

  for(int ni=0;ni<n;ni++){
    for(int wi=0;wi<=W;wi++){
      t[ni+1][wi]=max(t[ni+1][wi],t[ni][wi]);
      if(wi+w[ni+1]<=W){
        t[ni+1][wi+w[ni+1]]=max(t[ni+1][wi+w[ni+1]],v[ni+1]+t[ni][wi]);
      }
    }
  }
  cout<<t[n][W]<<endl;
  return 0;
}


Measured memory_bytes: 80256
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
ns = list(map(int, input().split()))
ns = set(ns)
for i in range(n+1):
    if x - i not in ns:
        print(x - i)
        break
    elif x + i not in ns:
        print(x + i)
        break
    
    



Measured memory_bytes: 61636
n = int(input())
d = list(map(int,input().split()))
ans = 1
count1 = 1
count = 0
now = 0
mod = 998244353
if d[0] != 0:
    print(0)
else:
    d.sort()
    for i in range(1,n):
        if d[i] == now+1:
            count += 1
        else:
            if count == 0 or d[i] == 0:
                ans = 0
                break
            elif d[i] > now + 2:
                ans = 0
                break
            else:
                p = 1
                for j in range(count):
                    p *= count1
                    p %= mod
                ans *= p
                ans %= mod
                count1 = count
                count = 1
                now += 1
        #print(count,count1,now)
    p = 1
    for i in range(count):
        p *= count1
        p %= mod
    ans *= p
    ans %= mod
    print(ans)

Measured memory_bytes: 14396
n=int(input())
X=[[] for _ in range(n)]

for i in range(n-1):
    a,b=map(int,input().split())
    X[a-1].append([b-1,i])

ANS=[0]*(n-1)
VC=[0]*n
k=1
for v,c in enumerate(X):
    t=1
    for b, i in c:
        if VC[v]==t:
            t+=1
        VC[b]=t
        ANS[i]=t
        k=max(k,t)
        t+=1
print(k)
for i in range(n-1):
    print(ANS[i])

Measured memory_bytes: 30792
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
using namespace std;



int main(void){
    int n, m, x;
    cin >> n >> m >> x;
    
    int l=0, r=0;
    for(int i=0; i<m; i++) {
        int a;
        cin >> a; 
        if(a<x) l++;
        else r++;
    }
    cout << (l<r ? l : r) << endl;
    return 0;
}


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

using namespace std;

void solve();

int main() {
#ifdef OFFLINE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

struct fenvick_tree {
	fenvick_tree(int size): t(size, INT_MAX) {}

	void dec(int i, int x) {
		i = t.size() - i - 1;
		for (; i<t.size(); i=(i|(i+1)))
			t[i] = std::min(t[i], x);
	}

	int min(int i) {
		i = t.size() - i - 1;
		int ret = INT_MAX;
		for (; i>=0; i=(i&(i+1))-1)
			ret = std::min(ret, t[i]);
		return ret;
	}

private:
	vector<int> t;
};

void solve() {
	string moves;
	cin >> moves;

	int n = moves.size();
	fenvick_tree ft(n);

	vector<int> moves_balance(n+1);
	for (int i=0; i<n; i++) {
		moves_balance[i+1] = moves_balance[i] + (moves[i] == 'g'? 1: -1);
		ft.dec(i, moves_balance[i+1]);
	}

	int result = 0;
	int my_balance = 0;
	for (int i=0; i<n; i++) {
		if (moves[i] == 'p') {
			my_balance--;
		}
		else if (my_balance + ft.min(i) - moves_balance[i+1] > 0) {
			my_balance--;
			result++;
		}
		else {
			my_balance++;
		}
	}

	cout << result << endl;
}

Measured memory_bytes: 1232
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const a = input;
  return a < 1200 ? "ABC" : "ARC";
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29388
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
	#define se second
	#define endl "\n"
	#define pii pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
	#define REP(i,n) for(int i=0;i<n;i++)
	#define FOR(i,a,b) for(int i=a;i<=b;i++)
	#define FORR(i,a,b) for(int i=a;i>=b;i--)
	#define ALL(c) (c).begin(),()c.end() 

	#define PI 3.14159265358979323846
	const int N = 500 + 10;  
   
    vi vp;
   int sum;
   void solve() {
          int n,m;
          cin>>n>>m;
          
          int mini=0,maxi=0,cnt=0,flag=0;
          
          while(m--) {
              int l,r;
              cin>>l>>r;
              if(cnt==0){
                  mini=min(l,r);
                  maxi=max(l,r);
                  cnt++;
              }
              
              else {
                  int yo1=min(l,r);
                  int yo2=max(l,r);
               
               if(yo1>mini)
                 mini=yo1;
                  
               if(yo1<maxi) {
                   if(yo2<maxi)
                     maxi=yo2;
               }
               
              if(yo1>maxi) {
                  flag++;
                  break;
              }
                            
           }
	   }
       
       //cout<<mini<<" "<<maxi<<endl;
       
       if(flag)
         cout<<0;
        else
          cout<<maxi-mini+1;      
       
   }
   
      int32_t main() {
	    cool;
	    int t=1;
	    while(t--)
	       solve();
	       
	       
	       return 0;	   
	   }


Measured memory_bytes: 256
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("failed 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,m,c):(i64,i64,i64)=(read(),read(),read());
    let mut vec:Vec<i64> = Vec::new();
    for i in 0..m{
        vec.push(read());
    }
    let mut res:i64=0;
    for i in 0..n{
        let mut temp:i64=0;
        for j  in &vec{
            let b:i64=read();
            temp+=j*b;
        }
        temp+=c;
        if temp>0{
            res+=1;
        }
    }
    println!("{}",res);
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int integer = 1;
    for(int i = 0; i < N; i++){
        if(min(2 * integer, integer + K) == 2 * integer) integer *= 2;
        else integer += K;
    }
    cout << integer << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c,d;
void solve()
{
    int e=c-a,f=d-b;
    cout<<c-f<<" "<<d+e<<" "<<c-f-e<<" "<<d+e-f<<endl;
}
int main()
{
    while(cin>>a>>b>>c>>d)
        solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main() {
  string S;
  cin >> S;
  vector<string> table = {"dream", "dreamer", "erase", "eraser"};
  for (auto &x : table) reverse(x.begin(), x.end());
  reverse(S.begin(), S.end());

  int l = 0, sz = S.size();
  while (l < sz) {
    bool match = false;
    for (auto &x : table) {
      if (S.substr(l, x.size()) == x) {
        match = true;
        l += x.size();
        break;
      }
    }
    if (!match) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}



Measured memory_bytes: 512
#include<stdio.h>

#define MAX 500000
#define mugen 2000000000

int S[MAX],L[MAX/2+2],R[MAX/2+2],count;

void merge(int * ,int ,int ,int);

void mergeSort(int * ,int ,int);

int main(){
  int n,i;

  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);

  mergeSort(S,0,n);

  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1)printf(" ");
  }

  printf("\n%d\n",count);

  return 0;
}

void merge(int *S,int left,int mid,int right){
  int i,j,k;
  int l,r;

  l=mid-left;
  r=right-mid;

  for(i=0;i<l;i++)
    L[i]=S[left+i];
  for(i=0;i<r;i++)
    R[i]=S[mid+i];

  L[l]=mugen;
  R[r]=mugen;

  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(L[i]<=R[j])S[k]=L[i++];
    else S[k]=R[j++];
  }
}

void mergeSort(int *S,int left,int right){
  int mid;
 
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}

Measured memory_bytes: 4508
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;;
using ll = long long;

int main() {
	int A,B,C;
	cin >> A >> B >> C;
	swap(A , B);
	swap(A, C);
	cout << A << ' ' << B << ' ' << C << endl;

	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int a;
  bool flag1=false, flag2=false, flag3=true;
  if(s.at(0)=='A')flag1=true;
  for(int i = 2; i <= s.length()-2; i++){
    if(s.at(i)=='C'){
      flag2=true; a=i;
    }
  }
  for(int i =1; i<s.length(); i++){
    if(i==a)continue;
    else if(s.at(i)-'a'<0)flag3=false;
  }
  if(flag1&&flag2&&flag3)cout << "AC"<<endl;
  else cout << "WA"<<endl;
}

Measured memory_bytes: 256
N,A=map(int, input().split())
X=list(map(int, input().split()))
dp=[[[0]*(2501) for _ in range(N+1)]for _ in range(N+1)]
dp[0][0][0]=1
#dp[i][j][k]i枚目を検討中、j枚選び、合計kとなるのは何通りか
for i in range(N):
  for j in range(N+1):
    for k in range(2501):
      if not dp[i][j][k]:
        continue
      dp[i+1][j][k]+=dp[i][j][k]
      if j<N:
        dp[i+1][j+1][k+X[i]]+=dp[i][j][k]
ans=0
for i in range(1,N+1):
  ans+=dp[N][i][i*A]
print(ans)

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

int main(){
	string s;
	cin>>s;
	vector<char> v;
	vector<char> t;
	for(int i=0;i<s.size();i++){
		if(i%2==0){
			v.push_back('0');
			t.push_back('1');
		}
		else if(i%2==1){
			v.push_back('1');
			t.push_back('0');
		}
	}
	int res=0;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!=v[i]){
			res++;
		}
		else if(s[i]!=t[i]){
			cnt++;
		}
	}
	cout<<min(res,cnt)<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
    int n;
    int a[109];
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    int s,su,x,MAX=100000;
    for(int i=1; i<n; i++)
    {
        s=0;
        su=0;
        for(int j=i; j>=1; j--)
        {
            s+=a[j];
        }
        for(int h=i+1; h<=n; h++)
        {
            su+=a[h];
        }
        if(s>=su)
        {
            x=s-su;
        }
        else
        {
            x=su-s;
        }
        if(x<=MAX)
        {
            MAX=x;
        }
    }
    printf("%d\n",MAX);
    return 0;
}


Measured memory_bytes: 128
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

H, N = get_ints
A = get_ints

sum = A.sum

puts sum >= H ? 'Yes' : 'No'


Measured memory_bytes: 20360
import sys
N = int(input())
S = list(input().split())
if not ( 1 <= N <= 100 ):
    sys.exit()
for I in range(len(S)):
    if not (S[I] == 'P' or 'W' or 'G' or 'Y'):
        sys.exit()

result = set(S)
if len(result) == 3:
    print('Three')
else:
    print('Four')

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;

int V, E;
vector< vector<int> > dist(22, vector<int>(22, -1));
int dp[(1<<20)+1][22];

int main() {
    cin >> V >> E;
    for(int i = 0; i < E; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        dist[s][t] = d;
    }

    for(int bit = 0; bit < (1<<V); ++bit) {
        for(int v = 0; v < V; ++v) {
            dp[bit][v] = INF;
        }
    }

    dp[0][0] = 0;
    for(int bit = 0; bit < (1<<V); ++bit) {
        for(int now = 0; now < V; ++now) {
            for(int to = 0; to < V; ++to) {
                if((bit & (1<<to)) == 0 && dist[now][to] != -1) {
                    chmin(dp[bit|1<<to][to], dp[bit][now]+dist[now][to]);
                }
            }
        }
    }

    if(dp[(1<<V)-1][0] == INF) {
        cout << -1 << endl;
    }else {
        cout << dp[(1<<V)-1][0] << endl;
    }
}


Measured memory_bytes: 5956
import math

##素数判定を行う関数
def prime(p):
    if p==2 or p==3:
        return True
    else:
        i = int(math.sqrt(p))
        while i>=2:
            if p%i==0:
                return False
                break
            i-=1
        return True
                
            

N = int(input())
count = 0

for i in range(N):
    a = int(input())
    if prime(a)==True:
        count+=1
        
print(count)


Measured memory_bytes: 5676
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
using namespace std;
const int64_t INF = 1e15;
struct edge {
    int to,cost;
};
vector<edge> G[200010];//1~R,R+1~R+Cというindexの頂点


int main(){
    int N,R,C;
    cin>>R>>C>>N;
    int r[100010],c[100010],a[100010];
    for(int i=0;i<N;i++){
        cin>>r[i]>>c[i]>>a[i];
        edge e;
        e.to=c[i]+R;
        e.cost=a[i];
        G[r[i]].push_back(e);
        e.to=r[i];
        G[c[i]+R].push_back(e);
    }
    int64_t val[200010];
    fill(val,val+200010,INF);
    for(int i=1;i<=R+C;i++){
        if(val[i]==INF){
            queue<int> q;
            q.push(i);
            val[i]=0;
            while(!q.empty()){
                int v = q.front(); q.pop();
                for(int j=0;j<G[v].size();j++){
                    edge u = G[v][j];
                    if(val[u.to]==INF){
                        val[u.to] = u.cost - val[v];
                        q.push(u.to);
                    }
                }
            }
        }
    }
    bool flag = true;
    for(int i=1;i<=R+C;i++){
        for(int j=0;j<G[i].size();j++){
            edge e = G[i][j];
            if(e.cost != val[i] + val[e.to]){
                flag=false;
                break;
            }
        }
    }
    if(flag){
        bool used[200010]={};
        for(int i=1;i<=R+C;i++){
            if(!used[i]){
                queue<int> q;
                q.push(i);
                used[i]=true;
                int64_t min_R=INF;
                int64_t min_L=INF;
                if(i<=R){
                    min_R = min(min_R,val[i]);
                }else{
                    min_L = min(min_L,val[i]);
                }
                while(!q.empty()){
                    int v = q.front(); q.pop();
                    for(int j=0;j<G[v].size();j++){
                        edge u = G[v][j];
                        if(!used[u.to]){
                            used[u.to]=true;
                            if(u.to<=R){
                                min_R = min(min_R,val[u.to]);
                            }else{
                                min_L = min(min_L,val[u.to]);
                            }
                            q.push(u.to);
                        }
                    }
                }
                if(min_R+min_L < 0){
                    flag=false;
                    break;
                }
            }
        }
    }
    
    
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 14080
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f

int main()
{
    int a[4];
    while(~scanf("%d%d%d",&a[0],&a[1],&a[2]))
    {
        sort(a,a+3);
        if(a[0]==a[1]&&a[1]!=a[2])
            printf("Yes\n");
        else if(a[1]==a[2]&&a[1]!=a[0])
            printf("Yes\n");
        else
            printf("No\n");
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

    class Program
    {
        static void Main(string[] args)
        {
            long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            while (true)
            {
                a[2] -= a[1];
                if (a[2] <= 0) { Console.WriteLine("Yes"); break; }

                a[0] -= a[3];
                if (a[0] <= 0) { Console.WriteLine("No"); break; }
            }



        }



    }


Measured memory_bytes: 28080
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    # 標準入力を取得
    N = int(input())
    a = list(map(int, input().split()))

    return N, a


def main(N: int, a: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): マスの数
        a (list): 各マスに書かれた整数
    """
    # 求解処理
    ans = 0
    for i in range(0, N, 2):
        ans += (a[i] % 2 == 1)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, a = get_input()

    # メイン処理
    main(N, a)


Measured memory_bytes: 9124
#include <iostream>
#include <tuple>

using namespace std;

int yen(int x, int y, int z){
  return 10000 * x + 5000 * y + 1000 * z;
}

int main(){
  int N, Y;
  cin >> N >> Y;
  
  int x, y, z, flag = 1;
  for(x = 0 ; x <= 2000 ; x++){
    for(y = 0 ; y <= 2000 ; y++){
      z = N - x - y;
      if(10000*x + 5000*y + 1000*z == Y && z >= 0){
        flag = 0;
        break;
      }
    }
    if(flag == 0){
      break;
    }
  }

  if(flag == 0){
    cout << x << " " << y << " " << z << endl;
  }else{
    cout << "-1 -1 -1" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<string.h>
int main(void){
int i,n,m,count[1000001],res;
char s[1000001],ioi[4]="IOI";

while(scanf("%d",&n),n){
scanf("%d %s",&m,s);
for(i=0;i<1000001;count[i]=0,i++);

for(i=0;i<=m;i++)
if(strncmp(s+i,ioi,3)==0)count[i]=count[i-2]+1;

for(i=0,res=0;i<m;i++)if(count[i]>=n)res++;
printf("%d\n",res);
}
return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t,a[100001];
    cin>>t;
    for(int i=0;i<t;i++)
        cin>>a[i];
    ll m,x,y;
    cin>>m;
    while(m--)
    {
        cin>>x>>y;
        x--;
        ll sum=0;
        for(int i=0;i<t;i++)
        {
            sum+=a[i];
        }
        sum=sum+y-a[x];
        cout<<sum<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(lambda:0)

double = 0
for i in range(N):
    d[A[i]] += 1
    if d[A[i]] != 1:
        double += 1

if double%2==0:
    ans = N-double
else:
    ans = N-double-1

print(ans)

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

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

int main(){
    int k; cin >> k;
    int sum = 0;
    for(int a = 1;a <= k;++a){
        for(int b = 1;b <= k; ++b){
            for(int c = 1;c <= k;++c){
                sum += gcd(a,gcd(b,c));
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define _USE_MATH_DEFINES
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const int MOD=1000000007;
const double EPS=1e-9;

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


int main()
{
    int N; cin >> N;
    
    int A;
    priority_queue<pii> Q;
    rep(i,N) {
        cin >> A;
        Q.push(mp(-A,i+1));
    }

    rep(i,N) {
        if(i) cout << " ";
        cout << Q.top().second;
        Q.pop();
    }
    cout << endl;

    return 0;
}


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

int main(){
  int d;
  cin >> d;
  if(d == 22)
    cout << "Christmas Eve Eve Eve" << endl;
  else if(d == 23)
    cout << "Christmas Eve Eve" << endl;
  else if(d == 24)
    cout << "Christmas Eve" << endl;
  else if(d==25)
    cout << "Christmas" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>


using namespace std;


int main()
{
	int n;
	int p[200001];
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i];

	int cnt = 1;
	int i, min = p[0];
	for (i = 1; i < n; i++)
	{
		if (min >= p[i])
		{
			cnt++;
			min = p[i];
		}
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
cum = [0]
for a in A:
    cum.append(cum[-1] + a)
count = Counter(cum)
ans = 0
for v in count.values():
    ans += v * (v - 1) // 2
print(ans)

Measured memory_bytes: 41472
n = input()
op_cnt = len(n) - 1
for i in range(2 ** op_cnt):
    op = ['-'] * op_cnt
    for j in range(op_cnt):
        if((i >> j) & 1):
            op[op_cnt - 1 - j] = '+'
    f = ''
    for j in range(op_cnt):
        f += n[j] + op[j]
    f += n[-1]
    if eval(f) == 7:
        print(f + '=7')
        break

Measured memory_bytes: 3064
//om namah shivaaay//
#include <bits/stdc++.h>
#define input int t;cin>>t;while(t--)
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout.precision(10)
 #define ll long long
 #define vi  vector<int>
 #define pb push_back
 #define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
 #define f(i, a, b) for (int i = 0; i < (b); i++)
 #define w(t) int t;cin>>t;while(t --)
#define fr(i, a, b) for (int i = (a); i >= (b); i--)
 const int N=1e5 +5;
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
    ll d,t,s;
    cin>>d>>t>>s;
    if(t*s>=d)
    cout<<"Yes";
    else
    cout<<"No";
}


Measured memory_bytes: 3616
while True:
	t,d,l = map(int,input().split())
	if t+d+l == 0:break
	lst = []
	for i in range(t):
		x = int(input())
		if x >= l:
			lst.append(1)
		else:
			lst.append(0)
	ans = 0
	sd = 0
	for i,w in enumerate(lst[:-1]):
		if w == 1: 
			ans += 1
			if lst[i+1] != 1:
				sd = d-1
		else:
			if sd != 0:
				ans += 1
				sd -= 1
	
	print(ans)



Measured memory_bytes: 7056
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int A[2][N]; REP(i,2) REP(j,N) cin>>A[i][j];
    int cumsum[2][N];
    cumsum[0][0] = A[0][0];
    cumsum[1][0] = A[1][0];
    REP(i,2) REP(j,N-1) cumsum[i][j+1] = cumsum[i][j]+A[i][j+1];
    int candy = A[0][0]+cumsum[1][N-1];
    REP(i,N) candy = max(candy,cumsum[0][i+1]+cumsum[1][N-1]-cumsum[1][i]);
    cout<<candy<<endl;
}


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

# R = [r1, r2, ..., rn]
# a1 == r1//2 + r2//2
# a2 == r2//2 + r3//2
# ...
# an == rn//2 + r1//2
#
# a1 - a2 + a3 - a4 + ... - a{n-1} + an == r1

sgn = (-1 if i % 2 == 0 else 1 for i in range(1, N + 1))
r1 = sum(a * s for a, s in zip(A, sgn))

R = [r1]
for a in A:
    R.append(2 * a - R[-1])

print(' '.join(map(str, R[:-1])))

Measured memory_bytes: 19912