akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

inline int xor128() {
    static int x = 123456789;
    static int y = 362436069;
    static int z = 521288629;
    static int w = 88675123;
    int t;
    t = x ^ (x << 11);
    x = y;
    y = z;
    z = w;
    return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}


const int D = 365;
const int M = 26;
vec<int> C(M);
vvec<int> S(D,vec<int>(M));

using arr = array<int,M>;

struct state{
    vec<int> res;
    int day;
    arr last;
    int score;
    state(){
        last = {};
        score = 0;
        day = 0;
    }
    void add(int type){
        day++;
        score += S[(int) res.size()][type];
        res.push_back(type);
        last[type] = day;
        for(int i=0;i<M;i++) if(i!=type) score -= C[i]*(day-last[i]);
    }

    bool operator<(const state& R)const{
        return score>R.score;
    }
};

const int width = 100;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d;
    cin >> d;
    for(auto& x:C) cin >> x;
    for(auto& v:S) for(auto& x:v) cin >> x;
    state init;
    vec<state> S;
    S.push_back(init);
    for(int d=0;d<D;d++){
        vec<state> neS;
        for(auto& now:S){
            for(int i=0;i<M;i++){
                state ne = now;
                ne.add(i);
                neS.push_back(ne);
            }
        }
        sort(neS.begin(),neS.end());
        if(neS.size()>width) neS.resize(width);
        S.swap(neS);
    }
    auto ans = S[0].res;
//    cerr << S[0].score << "\n";
    for(int i=0;i<D;i++) cout << ans[i]+1 << "\n";
}

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

int main() 
{
	while (1) 
	{
		int a;
		cin >> a;
		if (a == 0)break;
		if (a == 1 || a == 2 || a == 3) { cout << 1 << endl; continue; }
		vector<int>s(4);
		s[0] = 1; s[1] = 2; s[2] = 4;
		for (int c = 0; c < a - 3; c++) {
			s[3] = s[2] + s[1] + s[0];
			s[0] = s[1];
			s[1] = s[2];
			s[2] = s[3];
		}
		cout << s[2] /3650+1 << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i=0; i< N; i++){
    cin >> A.at(i);
  }
 
  double sum=0;
  for(int i = 0; i< N; i++){
    sum += 1/(double)A.at(i);
  }
  
  sum = 1/sum;
  cout << fixed << setprecision(7);
  cout << sum  << endl;
}

Measured memory_bytes: 256
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x) memset(x,0,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9+7;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=3e5+10;

    vc<pii> a[N];
    void main()
    {
        int n=qread(),ans=0;
        fo(i,1,n)
        {
            int m=qread();
            while(m--){int x=qread(),y=qread();a[i-1].PB({x-1,y});}
        }
        fo(s,0,bin(n)-1)
        {
            int siz=__builtin_popcount(s);
            bool ok=1;
            fo(x,0,n-1) if(s&bin(x)) for(auto t:a[x]) if( ((s&bin(t.FR))>0)!=t.SE ) ok=0;
            if(ok) chmax(ans,siz);

        }write(ans);
    }
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  int n,x,t;
  cin >> n >> x >> t;

  if(n%x==0){
    ANS(n / x * t);
  }else{
    ANS((n / x + 1) * t);
  }
  return 0;
}


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

int main(){
  string S; cin>>S;
  int ans=1e9;
  rep(i,2){
    int cnt=0;
    rep(j,S.length()){
      if(j%2==i&&S[j]!='0') cnt++;
      if(j%2!=i&&S[j]!='1') cnt++;
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
from collections import defaultdict
import heapq

dct=defaultdict(list)

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

hq=[]
val=0

for i in range(1,m+1):
  if dct[i]:
    for item in dct[i]:
      heapq.heappush(hq,item)
  if hq:
    val+=heapq.heappop(hq)

print(-val)

Measured memory_bytes: 27676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = sc.nextInt();
		int sum = 0;
		
		for (int i = 0; i < M; i++) {
			sum += sc.nextInt();
		}
		
		if (sum > N) {
			System.out.println("-1");
		} else {
			System.out.println(N - sum);
		}
 	}

}


Measured memory_bytes: 46444
#include<stdio.h>
#include<string.h>
int main()
{
    int len,maxsum,flag,i;
    char str[50];
    while(gets(str)!=NULL)
    {
        flag=1;
        len = strlen(str);
        for(i=1;i<len;i++)
        {
            if(str[i]<'9')
            {
                flag=0;
                break;
            }
        }
        if(flag==0)
            maxsum=9*(len-1)-1+str[0]-'0';
            else
                maxsum=9*(len-1)+str[0]-'0';
        printf("%d\n",maxsum);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 1e5+5;

int a[sz];

int main()
{
   int n;
   ll tot = 0;
   scanf("%d", &n);
   for(int i=0; i<=n; i++)
      scanf("%d", &a[i]), tot += a[i];

   ll ans = 0, x = 1;
   for(int i=0; i<=n; i++) {
      if(x < a[i]) {
         puts("-1");
         exit(0);
      }
      ans += x;
      x -= a[i];
      tot -= a[i];
      x = min(x << 1, tot);
   }

   if(!n && !a[0]) ans = 0;
   printf("%lld\n", ans);
}


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

using namespace std;

const int MAX_LENGTH = 3012;
string s, t, dp[2][MAX_LENGTH];

int main() {

    cin >> s >> t;

    int s_length = s.size(), t_length = t.size();

    if (s[0] == t[0])
        dp[0][0] = s[0];

    for (int i = 1; i < t_length; ++i) {

        if (t[i] == s[0] && dp[0][i - 1].empty())
            dp[0][i] = s[0];

        else
            dp[0][i] = dp[0][i - 1];
    }

    int tst = 0;

    for (int i = 1; i < s_length; ++i) {

        if (tst % 2 == 0) {
            if (s[i] == t[0] && dp[0][0].size() == 0)
                dp[1][0] = s[i];

            else
                dp[1][0] = dp[0][0];
        }

        else {
            if (s[i] == t[0] && dp[1][0].size() == 0)
                dp[0][0] = s[i];

            else
                dp[0][0] = dp[1][0];
        }

        for (int j = 1; j < t_length; ++j) {

            if (tst % 2 == 0) {

                if (s[i] == t[j])
                    dp[1][j] = dp[0][j - 1] + s[i];

                else if (dp[1][j - 1].size() > dp[0][j].size())
                    dp[1][j] = dp[1][j - 1];

                else
                    dp[1][j] = dp[0][j];
            }
            else {

                if (s[i] == t[j])
                    dp[0][j] = dp[1][j - 1] + s[i];

                else if (dp[0][j - 1].size() > dp[1][j].size())
                    dp[0][j] = dp[0][j - 1];

                else
                    dp[0][j] = dp[1][j];
            }
        }
        tst++;
    }

    if (dp[0][t_length - 1].size() > dp[1][t_length - 1].size())
        cout << dp[0][t_length - 1] << endl;

    else
        cout << dp[1][t_length - 1] << endl;
    return 0;
}

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

using namespace std;

int main(void) {
	int n;
	cin >> n;
	long long power = 1;
	for (int i = 1; i <= n; i++) {
		power *= i;
		power %= 1000000007;
	}
	cout << power % (1000000000 + 7);
	return 0;
}

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

cnt = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        break
if cnt >= 3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62412
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
bool program[30][100005];
bool watching[30];
int main(){
    int n,c; cin >> n >> c;
    REP(i,n){
        int s,t,c; cin >> s >> t>> c; s--;  c--;
        program[c][s] = !program[c][s];
        program[c][t] = !program[c][t];
    }
    int ans = 0;
    REP(i,30){
        watching[c] = false;
    }


    REP(i,100000){
        int count = 0;
        REP(j,30){
            if(program[j][i]){
                watching[j] = !watching[j];
            }
            if(watching[j]){
                count++;
            }
        }
        ans = max(count , ans);
    }
    cout << ans << endl;

}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define lcm(a,b)            (abs(a)/gcd(a,b))*abs(b)
#define PI      	        2*acos(0.0)
#define INF     	        1e9
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; 

const int N = 1e5+9;
int dp[N][3];


int main ()
{
    #ifdef Lollipop
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    #endif
    
    int n;
    cin >> n;
    for (int i = 0; i<n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dp[i+1][0] = max(dp[i][1] + a, dp[i][2] + a);
        dp[i+1][1] = max(dp[i][0] + b, dp[i][2] + b);
        dp[i+1][2] = max(dp[i][0] + c, dp[i][1] + c);
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
    return 0;
}




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

int main() {
    long long int N, K, sum = 0;
    cin >> N >> K;
    vector <int> v;

    if(K>=N) cout << "0" << endl;
    else {
        for(long long int i=0; i<N; i++) {
            long long int a; 
            cin >> a;
            v.push_back(a);
            sum += a;
        }

        sort(v.begin(), v.end());
        auto it = v.end()-1;
        for(long long int i=0; i<K; it--, i++) {
            sum -= (*it);
        }

        cout << sum << endl;
    }
    return 0;
    
}

Measured memory_bytes: 1400
import java.util.Scanner;
class Main
{
  public static void main(String[]av)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] R=new int[n];
    for(int i=0;i<n;i++)
    {
      R[i]=sc.nextInt();
    }
    int minv=R[0],maxv=(1000000000)*(-1);
    for(int j=1;j<n;j++)
    {
      if(maxv<R[j]-minv)
      {
        maxv=R[j]-minv;
      }
      if(minv>R[j])
      {
        minv=R[j];
      }
    }
    System.out.println(maxv);
  }
}



Measured memory_bytes: 102220
import java.util.*;

class Main {
  public static void main (String[] args) {
    final int NUM = 8;
    Scanner scanner = new Scanner(System.in);
    char[][] in = new char[NUM][NUM];
    char[][] out = new char[NUM][NUM];
    while (scanner.hasNext()) {
      for (int row = 0; row < NUM; row++) {
        String line = scanner.nextLine();
        for (int col = 0; col < NUM; col++) {
          in[row][col] = line.charAt(col);
        }
      }
    }

    for (int ii = 90; ii < 360; ii += 90) {
      System.out.println(ii);
      for (int row = 0; row < NUM; row++) {
        for (int col = 0; col < NUM; col++) {
          out[col][NUM - 1 - row] = in[row][col];
        }
      }
      for (int row = 0; row < NUM; row++) {
        for (int col = 0; col < NUM; col++) {
          System.out.print(out[row][col]);
          in[row][col] = out[row][col];
        }
        System.out.println();
      }
    }
  }
}

Measured memory_bytes: 15312
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<set>
using namespace std;
#define ll long long
const int N=100008;
ll n,nn,a[N],b[N+N];
ll add(ll x,ll y){while(x<=n+n){b[x]+=y;x+=x&(-x);}return 0;}
ll sum(ll x){ll y=0;while(x>0){y+=b[x];x-=x&(-x);}return y;}
ll pan(ll x)
{
	ll i,j,k;
	k=0;
	add(n+1,1);j=0;for(i=1;i<=n;i++){j+=(a[i]<=x);k+=sum(n+j+j-i);add(n+j+j-i+1,1);}
	add(n+1,-1);j=0;for(i=1;i<=n;i++){j+=(a[i]<=x);add(n+j+j-i+1,-1);}
	return k;
}
int main(void)
{
	std::ios::sync_with_stdio(false);
	ll i,left,right,mid;
	cin>>n;for(i=1;i<=n;i++)cin>>a[i];
	nn=(n+n*(n-1)/2)/2;
	left=1;right=1000000000;
	while(left+1<right)
	{
		mid=(left+right)>>1;
		if(pan(mid)>nn)right=mid;else left=mid+1;
	}
	if(pan(left)>nn)right=left;
	cout<<right;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

P hasi(int n){
    int a = log10(n);
    a = pow(10,a);
    return P(n/a,n%10);
}

int naka(int n){
    int a = log10(n);
    a = pow(10,a);
    return ((n%a)-(n%10))/10;
}

int main() {
    int n; cin >> n;
    if (n <= 10){
        cout << min(9,n) << endl;
        return 0;
    }
    if (n < 100){
        int ans = 9;
        repp(i,n+1,11){
            P p = hasi(i);
            if (p.second != 0 && p.first > p.second) ans += 2;
            else if (p.first == p.second) ans += 3;
        }
        cout << ans << endl;
        return 0;
    }
    int ans = 108;
    repp(i,n+1,100){
        P p = hasi(i);
        if (p.second == 0) continue;
        if (p.first == p.second){
            ans += naka(i) * 2 + 1;
            int a = log10(i)-1;
            ans += (pow(10,a)-1) / 9 * 2 + 2;
        }
        else if (p.first > p.second){
            int a = log10(i);
            ans += (pow(10,a)-1) / 9 * 2;
        }
        else if (p.first < p.second){
            int a = log10(i)-1;
            ans += (pow(10,a)-1) / 9 * 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector <int> arr(n);
	for(int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr.begin(), arr.end());
	
	int num = arr[0], ans = 1;
	for(int i = 1; i < n; i++) {
		if(num != arr[i]) {
			ans++;
			num = arr[i];
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main{
	static int a,b;
    
    public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       while(true) {
    	   int m = sc.nextInt();
    	   int nmin = sc.nextInt();
    	   int nmax = sc.nextInt();
    	   if(m+nmin+nmax==0)break;
    	   int[] score = new int[m];
    	   int gap = 0;
    	   int ans = 0;
    	   for(int i=0;i<m;i++) { score[i] = sc.nextInt(); }
    	   for(int i=nmin;i<=nmax;i++) {
    		   if(gap <= score[i-1]-score[i]) {
    			   gap = Math.max(gap, score[i-1]-score[i]);
    			   ans = i;
    		   }
    	   }
    	  System.out.println(ans);
      }
    }
}


Measured memory_bytes: 57240
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
int dp[333][333][333];
int pos1L[333],pos2R[333],pos2L[333],pos3R[333];
#define mod 1000000007
void addto(int&x,int y){
	x+=y;
	if(x>=mod)x-=mod;
}
bool chk(int i,int y,int z){
	if(pos1L[i] <= y)return false;
	if(pos2R[i] != -1){
		if(!(pos2R[i] <= y))return false;
		if(!(pos2L[i] > z))return false;
	}
	if(pos3R[i] != -1){
		if(!(pos3R[i] <= z))return false;
	}
	return true;
}
int main(){
	int m;
	scanf("%d%d",&n,&m);
	for(int i=1; i<=n; i++){
		pos1L[i] = i;
		pos2R[i] = -1;
		pos2L[i] = i-1;
		pos3R[i] = -1;
	}
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		if(z == 1){
			pos1L[y] = min(pos1L[y], x);
		}else
		if(z == 2){
			pos2R[y] = max(pos2R[y], x);
			pos2L[y] = min(pos2L[y], x);
		}else
			pos3R[y] = max(pos3R[y], x);
	}
	dp[1][0][0] = 3;
	int res=0;
	for(int i=1; i<=n; i++)
	for(int j=i-1; j>=0; j--)
	for(int k=max(j-1,0); k>=0; k--){
		if(!chk(i,j,k))
			dp[i][j][k]=0;
		if(i==n)addto(res, dp[i][j][k]);else{
			addto(dp[i+1][j][k], dp[i][j][k]);
			addto(dp[i+1][i][k], dp[i][j][k]);
			addto(dp[i+1][i][j], dp[i][j][k]);
		}
	}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 129280
#include<stdio.h>
#include<string.h>

char s[200010];
int a[2020];
int main(){
	scanf("%s",s);
	int n=strlen(s);
	int cum=0;
	int p10=1;
	a[0]++;
	for(int i=n-1;i>=0;i--){
		cum=(cum+p10*(s[i]-'0'))%2019;
		a[cum]++;
		p10=p10*10%2019;
	}
	long long ans=0;
	for(int i=0;i<2019;i++)ans+=a[i]*(a[i]-1)/2;
	printf("%lld",ans);
}

Measured memory_bytes: 1924
def dfs(s):
    return _dfs(s, set())


def _dfs(v, visited):
    for u in edges[v]:
        if u in visited:
            continue
        visited.add(u)
        if matched[u] == -1 or _dfs(matched[u], visited):
            matched[u] = v
            return True
    return False


xn, yn, e = map(int, input().split())
edges = [set() for _ in range(xn)]
matched = [-1] * yn

for _ in range(e):
    x, y = map(int, input().split())
    edges[x].add(y)

print(sum(map(dfs, range(xn))))

Measured memory_bytes: 8560
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007


int main() {
  int N,T,A;
  cin >> N >> T >> A;
  int j;
  double m=10000.0;

  rep(i,N){
    double h;
    cin >> h;
    if( fabs(T - h * 0.006 - A) < m ){
      m = fabs(T - h * 0.006 - A);
      j = i + 1;
    }
  }

  cout << j << endl;


}


Measured memory_bytes: 256
import sys
from collections import deque
s = list(input())
q = int(input())
h = deque()
h.extend(s)

rev = False
for _ in range(q):
    que = sys.stdin.readline().split()
    if que[0] == '1':
        if rev:
            rev = False
        else:
            rev = True
    elif que[1] == '1':
        if rev:
            h.append(que[2])
        else:
            h.appendleft(que[2])
    else:
        if rev:
            h.appendleft(que[2])
        else:
            h.append(que[2])
if rev:
    print(''.join(list(h)[::-1]))
else:
    print(''.join(list(h)))

Measured memory_bytes: 69240
n,m = map(int,raw_input().split())
switch = []
for i in xrange(m):
	a = map(int,raw_input().split())
	conn = [0]*n
	for x in a[1:]:
		conn[x-1] = 1
	switch.append(conn)
p = map(int,raw_input().split())
res = 0
for i in xrange(2**n):
	temp = i
	lit = [0]*m
	for j in xrange(n):
		if temp%2 == 1:
			for b in xrange(m):
				if switch[b][j]:
					lit[b] += 1
		temp /= 2
	res += 1
	for j in xrange(m):
		if lit[j]%2 != p[j]:
			res -= 1
			break
print res

Measured memory_bytes: 2696
#include<stdio.h>
int main ()
{
    int a,b,k,tal,fr,i;
    scanf ("%d%d%d",&a,&b,&k);
    tal = b+1-a;
    if(tal%2==0){
    tal=tal/2;
    if (k>= tal)
    {
        for (i = a; i<=b;i++)
        printf ("%d\n",i);
    }
    else{
    fr = a+k-1;
        for(i = a; i<=fr;i++)
            printf ("%d\n",i);
        fr = b-k+1;
        for (i = fr; i<=b;i++)
             printf ("%d\n",i);
    }
    }
    else{
    tal = (b-a)/2+1;
    if (k>=tal)
    { for (i = a; i<=b;i++)
        printf ("%d\n",i);}

       else{
    fr = a+k-1;
        for(i = a; i<=fr;i++)
            printf ("%d\n",i);
        fr = b-k+1;
        for (i = fr; i<=b;i++)
             printf ("%d\n",i);
    }
}
    return 0;
    }


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x; cin>>x;
	string x_str=to_string(x);
	if(x<100) {cout<<0<<endl; return 0;}
	for(int i=1;i<=100000;i++){
		if(x >= i*100 && x<=i*105) {cout<<1<<endl; return 0;}
		if(i*105>x) break;
	}
	cout<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

int main()
{
    int r,g;

    while(scanf("%d%d",&r,&g) != EOF)
    {
        printf("%d\n",2*g-r);
    }

    return 0;
}


Measured memory_bytes: 256
from sys import exit, stderr, stdin
input = stdin.readline
# setrecursionlimit(10**7)

def debug(var, name="hoge"):
    print(name +":" + str(type(var)) + " = " + repr(var), file=stderr)
    return


def main():
    K, A = [int(n) for n in input().split()]
    for i in range(-K+1,K):
        print(A+i,end=" ")
    print()



if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n,q; cin >> n >> q;

    vector<int> v(n+1);
    vector<vector<int>> r(n+1,vector<int>());

    REP(i,n-1) {
        int a,b; cin >> a >>b;
        r[a].emplace_back(b);
        r[b].emplace_back(a);
    }
    REP(i,q) {
        int p,x; cin >> p >> x;
        v[p] += x; 
    }

    vector<int> vb = {1};
    vector<bool> visit(n+1,false);

    while(vb.size() != 0) {
        vector<int> tmp;
        for(auto i : vb) {
            if (!visit[i]) {
                for(auto y : r[i]) {
                    if (!visit[y]) {
                        tmp.emplace_back(y);
                        v[y] += v[i];
                    }
                }
                visit[i] = true;
            }
        }
        vb = tmp;
    }

    FOR(i,1,n+1) cout << v[i] << " ";

    
    return 0;
}

Measured memory_bytes: 15716
#include<stdio.h>
#include<math.h>

int main(){
  long long int	N,m;
  int  i;
  scanf("%lld",&N);
  m=sqrt((double)N);
  m=m+5;
  for(i=m;i>0;--i){
    if(N/i*i==N){
       printf("%ld\n",1+(long)floor(log10((double)N/i)));
      return 0;
    }
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	if (a * b <= 0)cout << "Zero" << endl;
	else {
		if (0 < a)cout << "Positive" << endl;
		else {
			cout << ((abs(b-a)+1)%2 == 0 ? "Positive" : "Negative") << endl;
		}
	}
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int a,b,t;cin >> a >> b >> t;
    cout << t/a * b << endl;
    

}

Measured memory_bytes: 256
#coding: utf-8
import math

n = int(raw_input())
y_list = [[]]
cnt = 0
cnt_y = 0

for i in range(1,n+1,2):
    ri = (i>>1) 
    for j in range(3,ri,2):
        if i%j == 0: cnt_y += 1
    if cnt_y + 2 == 8: cnt += 1
    cnt_y = 0

print cnt


Measured memory_bytes: 2568
#include<iostream>
using namespace std;
int main() {
  unsigned int a, b, c;
  cin >> a >> b >> c;
  if(a >= b) cout << "No\n";   // a>=bであれば Noを出力。

  else {
    if(b < c) cout << "Yes\n";    // a<b かつ　b<c であればyesを出力。
    else cout << "No\n";    //　でなければNoを出力。
  }
  return 0;

}



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

int main(){
  int i,j,n;
  while(1){
    cin >> n;
    if(n == 0) break;
    int a[10],b;
    for(i=0;i<10;i++) a[i] = 0;
    for(i=0;i<n;i++){
      cin >> b;
      a[b]++;
    }
    for(i=0;i<10;i++){
      if(a[i] == 0) cout << "-";
      else{
	for(j=0;j<a[i];j++) cout << "*";
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	switch(a){
		case 'A':cout<<"T"<<endl;break;
		case 'T':cout<<"A"<<endl;break;
		case 'C':cout<<"G"<<endl;break;
		case 'G':cout<<"C"<<endl;break;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 228;

int a[N];
vector<int> v[N];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif  
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    vector<int> ans;

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

    for (int i = 0; i < n; ++i) {
        for (int j = n - 1; j >= 0; --j) {
            if (a[j] == i) {
                int c = 0;
                for (int k = 0; k < j; ++k) {
                    c += a[k] < i;
                }

                if (c < i) {
                    cout << "-1\n";
                    return 0;
                }

                ans.insert(ans.end() - (c - i), i + 1);
            }
        }
    }

    for (int x: ans) {
        cout << x << "\n";
    }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      ss: [usize; n],
    }
    let mut ss = ss;
    ss.sort();
    let score: usize = ss.iter().sum();
    if score % 10 != 0 {
        println!("{}", score);
        return;
    }

    for i in 0..n {
        if ss[i] % 10 != 0 {
            println!("{}", score - ss[i]);
            return;
        }
    }
    println!("{}", 0);
}


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

int main()
{
      string s,t;
      cin>>s>>t;
      int freq[26];
      for(int i=0;i<26;i++)
      {
          freq[i]=0;
      }
      int n=t.size();
      for(int i=0;i<n;i++)
      {
          freq[t[i]-'a']++;
      }
      long long sum=0;
      for(int i=0;i<n;i++)
      {
          if(s[i]!=t[i]){
            sum++;
          }
      }
      cout<<sum<<endl;
}



Measured memory_bytes: 3820
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<queue>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
ll dx[4] = {1,0,0,-1};
ll dy[4] = {0,1,-1,0};

#define ARRAY_MAX 55
ll n,k,h,w,d;
ll X1[ARRAY_MAX],X2[ARRAY_MAX],Y1[ARRAY_MAX],Y2[ARRAY_MAX],D1[ARRAY_MAX],D2[ARRAY_MAX];
ll field[ARRAY_MAX*4][ARRAY_MAX*4][ARRAY_MAX*4];
vector<ll> xs,ys,ds,xunzip,yunzip,dunzip;
map<ll,ll> xzip,yzip,dzip;

void compress(vector<ll>& x,map<ll,ll>& zip,vector<ll>& unzip){

    VSORT(x);
    x.erase(unique(x.begin(),x.end()),x.end());
    unzip.resize(x.size());
    REP(i,x.size()){
        zip[x[i]] = i;
        unzip[i] = x[i];
    }
}


int main(){


    cin >> n >> k;
    
    REP(i,n){
        cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
        xs.push_back(X1[i]);
        xs.push_back(X2[i]);
        ys.push_back(Y1[i]);
        ys.push_back(Y2[i]);
        ds.push_back(D1[i]);
        ds.push_back(D2[i]);
    }

    compress(xs,xzip,xunzip);
    compress(ys,yzip,yunzip);
    compress(ds,dzip,dunzip);

    w = xzip.size();
    h = yzip.size();
    d = dzip.size();

    REP(i,n){
        field[yzip[Y1[i]]][xzip[X1[i]]][dzip[D1[i]]]++;
        field[yzip[Y1[i]]][xzip[X2[i]]][dzip[D1[i]]]--;
        field[yzip[Y2[i]]][xzip[X1[i]]][dzip[D1[i]]]--;
        field[yzip[Y2[i]]][xzip[X2[i]]][dzip[D1[i]]]++;
        field[yzip[Y1[i]]][xzip[X1[i]]][dzip[D2[i]]]--;
        field[yzip[Y1[i]]][xzip[X2[i]]][dzip[D2[i]]]++;
        field[yzip[Y2[i]]][xzip[X1[i]]][dzip[D2[i]]]++;
        field[yzip[Y2[i]]][xzip[X2[i]]][dzip[D2[i]]]--;
    }
        
    REP(i,h+1)REP(j,w)REP(m,d){//横
        field[i][j+1][m] += field[i][j][m];
    }


    REP(j,w+1)REP(i,h)REP(m,d){//縦
        field[i+1][j][m] += field[i][j][m];
    }

    REP(m,d+1)REP(i,h)REP(j,w){
        field[i][j][m+1] += field[i][j][m];
    }

    ll ans = 0;
    REP(i,h)REP(j,w)REP(m,d){
        if(field[i][j][m] >= k){
            ans += (yunzip[i+1] - yunzip[i])*(xunzip[j+1] - xunzip[j])*(dunzip[m+1] - dunzip[m]);

        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20916
s=gets.chomp.chars.map(&:to_i)
l=s.size-1
res = 0
(2**l).times do |i|
  p = i.to_s(2).rjust(l,'0').chars.map{|j|j=='1' ? '+' : nil}
  res += eval(s.zip(p).flatten.compact.join(''))
end
puts res

Measured memory_bytes: 1916
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    string s;
    IN s;
    loop(i,0,s.length())
    {
        if(s[i]=='?')
        {
            s[i]='D';
        }
    }
    OUT s<<endl
    return 0;
}

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

class BIT {
private:
    vector<int> dat;
    int n;
public:
    BIT(int size) {
        dat.resize(size + 1);
        n = size;
    }
    int sum(int i) {
        int s = 0;
        while(i > 0) {
            s += dat[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i, int x) {
        while(i <= n) {
            dat[i] += x;
            i += i & -i;
        }
    }
};

template<class T> vector<int> compress(const vector<T> &A) {
    int n = A.size();
    vector<T> B(n);
    vector<int> C(n);
    copy(A.begin(), A.end(), B.begin());
    sort(B.begin(), B.end());
    B.erase(unique(B.begin(), B.end()), B.end());
    for(int i = 0; i < n; ++i) {
        int id = lower_bound(B.begin(), B.end(), A[i]) - B.begin() + 1;
        C[i] = id;
    }
    return C;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, 0, N) {
        cin >> A[i];
        A[i] -= K;
    }
    vector<ll> R(N + 1);
    rep(i, 0, N) R[i+1] = R[i] + A[i];
    vector<int> C = compress(R);
    ll ans = 0;
    BIT bit(N + 1);
    rep(i, 0, N + 1) {
        ans += bit.sum(C[i]);
        bit.add(C[i], 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<int> V(N);
    rep(i,0,M){
        int a,b;
        cin >> a >> b;
        V[a-1]++;
        V[b-1]++;
    }
    rep(i,0,N){
        if(V[i] % 2 == 1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
	int a,i,j,sum=0,M,S;
	
	for(i=0;i<4;i++){
		scanf("%d",&a);
		sum+=a;
	}
	S=sum%60;
	M=0;
	while(1){
		if(sum-S==60*M){
			break;
		}
		M++;
	}
	printf("%d\n%d\n",M,S);
	return 0;
}
	

Measured memory_bytes: 596
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int[] a=new int[3];
	    a[0]=gi();
	    a[1]=gi();
	    a[2]=gi();
        Arrays.parallelSort(a);
	    
        System.out.println(a[2]* 10+a[1]+a[0]);
//        if () {
//        	System.out.print("No");
//        }else {
//        	System.out.print("Yes");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35612
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

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

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

signed solve()
{
	i64 n;
	cin >> n;
	map<i64, i64> mp;
	REP(i, n)
	{
		i64 a;
		cin >> a;
		mp[a]++;
	}

	i64 num = SIZE(mp);
	i64 ans = num % 2 == 0 ? num - 1 : num;

	//i64 ans = 0;
	////REPIT(mp)
	////{
	////	if ((*it).second == 1)
	////	{
	////		ans++;
	////		it = mp.erase(it);
	////	}
	////}

	//vector<i64> v;
	//REPIT(mp)
	//{
	//	if ((*it).second == 1)
	//		ans++;
	//	else
	//		v.push_back((*it).second);
	//}

	//if (SIZE(v) > 0)
	//{

	//	REP(i, SIZE(v) - 1)
	//	{
	//		i64 num = min(v[i], v[i + 1]) - 1;
	//		ans += num;
	//		v[i] -= num;
	//		v[i + 1] -= num;
	//	}
	//}

	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 6528
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>

#define MIN(x, y) (x < y ? x : y)
#define MAX(x, y) (x > y ? x : y)

using namespace std;


int main(){
	int A, B, C, D;
	cin >> A >> B >> C >> D;

	A = MIN(A, B);
	C = MIN(C, D);

	cout << A+C << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a[1000],i;
  
 long double l,j=0,k=0;;
  cin>>n;
  for(i=0;i<n;i++)
  {
    cin>>a[i];
  }
  for(i=0;i<n;i++)
  {
    j=j+(long double)1/a[i];
    
  }
  l=(long double)1/j;
  cout<<l<<endl;
  return 0;
}

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

int main(){
	
	int a, b, c, perm = 0;
	
	cin >> a >> b >> c;
	
	perm = a - b;
	
	if (c - perm < 0){
		cout << "0";
	} else {
		cout << c - perm;
	}
	
}

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


/********************************************************************/
#define M1 1000000007
#define M2 998244353
#define ll long long
#define pll pair<ll,ll>
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define REPR(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define CASE(t) ll t; cin>>t; while(t--)
/********************************************************************/
// const int mx = 1e7 + 5;
const double pi = 3.1415926535;
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}
const int mx = 1e5 + 5;
ll freq[mx] = {};


/********************************************************************/
int main() {
	FAST();
	ll n;
	cin >> n;
	string ans = "";
	while (n > 0) {
		ll val = n % 26;
		if (val == 0)
			val = 26;
		ans += ('a' + val - 1	);
		n -= val;
		n /= 26;
		if (n == 0)
			break;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
N, L = map(int, input().split(' '))
if L >= 0:
  res = (L-1) * N + N * (N+1) / 2 - L
elif L <= 1 - N:
  res = (L-1) * N + N * (N+1) / 2 - (L+N-1)
else:
  res = (L-1) * N + N * (N+1) / 2

print(int(res))

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
#define fr first
#define sc second

const int maxn=2e5+5;

pii node[maxn];
int n,rt,tot,cnt;
int f[20][maxn][2];
int a[maxn],now[maxn],pre[maxn],son[maxn];

int read() {
    int x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}

void add(int a,int b) {
    if(!b)return;
    pre[++tot]=now[a];
    now[a]=tot,son[tot]=b;
}

int cmp(int pos1,int pos2) {
    if(a[pos1]<a[pos2])return pos1;
    return pos2;
}

void make_st() {
    for(int i=1;i<20;i++)
        for(int j=1;j+(1<<i)-1<=n;j++)
            for(int k=0;k<2;k++)
                f[i][j][k]=cmp(f[i-1][j][k],f[i-1][j+(1<<(i-1))][k]);
}

int solve(int l,int r,int opt) {
    if(r<l)return 0;
    if(l+1==r) {
        node[++cnt]=make_pair(a[l],a[r]);
        return cnt;
    }
    int x=log2(r-l+1);
    int pos=cmp(f[x][l][opt],f[x][r-(1<<x)+1][opt]);
    x=log2(r-pos+1);
    int tmp=cmp(f[x][pos][opt^1],f[x][r-(1<<x)+1][opt^1]);
    node[++cnt]=make_pair(a[pos],a[tmp]);x=cnt;
    add(x,solve(l,pos-1,opt));
    add(x,solve(pos+1,tmp-1,opt^1));
    add(x,solve(tmp+1,r,opt));
    return x;
}

struct Heap {
    int len;
    int tree[maxn];

    void ins(int u) {
        tree[++len]=u;
        int pos=len;
        while(pos>1) {
            if(node[tree[pos]]<node[tree[pos>>1]])
                swap(tree[pos],tree[pos>>1]),pos>>=1;
            else break;
        }
    }

    int pop() {
        int res=tree[1];
        tree[1]=tree[len--];
        int pos=1,son=2;
        while(son<=len) {
            if(son<len&&node[tree[son|1]]<node[tree[son]])son|=1;
            if(node[tree[son]]<node[tree[pos]])
                swap(tree[pos],tree[son]),pos=son,son=pos<<1;
            else break;
        }
        return res;
    }
}H;

void make_ans() {
    H.ins(rt);
    while(H.len) {
        int u=H.pop();printf("%d %d ",node[u].fr,node[u].sc);
        for(int p=now[u];p;p=pre[p])
            H.ins(son[p]);
    }
}

int main() {
    n=read();a[0]=2e9;
    for(int i=1;i<=n;i++)
        a[i]=read(),f[0][i][i&1]=i;
    make_st();
    rt=solve(1,n,1);
    make_ans();
    return 0;
}


Measured memory_bytes: 42368
#include <iostream>

int main() {
  char c;
  std::cin >> c;

  const char s[] = "aeiou";
  for (auto e : s) {
    if (c == e) {
      std::cout << "vowel" << std::endl;
      return 0;
    }
  }
  std::cout << "consonant" << std::endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (b+c-a <= 0) cout << 0 << endl;
  else cout << b+c-a << endl;
}


Measured memory_bytes: 3600