akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
#include <bitset>
#include <cstring>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using Graph = vector<vector<ll>>;
using P = pair<ll, ll>;

/* 4 方向への隣接頂点への移動を表すベクトル */
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int MAX_A = 100000;
const int MAX_B = 0;
ll H, W;
ll sX, sY, gX, gY;
ll N, M;
vector<int> graph;
ll X[MAX_A];
ll L[MAX_A];
P ps[MAX_A];

int vector_finder(std::vector<int> vec, int number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
int main() {
	cin >> N >> M;
	Graph armWidth = Graph(N,vector<ll>(2));
	rep(i,M) {
		cin >> X[i] >> L[i];
		ps[i] = P(L[i],X[i]);
	}
	sort(ps, ps + M);
	int cur = -MAX_B;
	int ans = 0;
	rep(i,M) {
		if (cur<=ps[i].second) {
			ans++;
			cur = ps[i].first;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11972
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	rep(i, n) a[i] -= (i + 1);
	sort(a.begin(), a.end());
	if (n % 2 == 1) {
		ll d = a[n / 2];
		ll ans = 0;
		rep(i, n) ans += abs(a[i] - d);
		cout << ans << endl;
	}
	else {
		ll d = (a[n / 2] + a[n / 2 - 1]) / 2;
		ll ans = 0;
		rep(i, n) ans += abs(a[i] - d);
		cout << ans << endl;
	}
}

Measured memory_bytes: 1024
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

struct List{
    long A;
    long B;
}

void main()
{
    int[] input = readln().split.to!(int[]);
    int N = input[0];
    int M = input[1];
    List[] list = [];
    foreach(int i; 0..N)
    {
        auto a = readln().split.to!(int[]);
        auto l = List();
        l.A = a[0];
        l.B = a[1];
        list~=l;
    }
    list.sort!((a,b)=>a.A<b.A)();
    long res = 0;
    long count = 0;
    foreach(i; 0..N)
    {
        auto a = list[i];
        auto need = M - count;
        if(need <= a.B)
        {
            res += need * a.A;
            break;
        }else{
            res += a.B * a.A;
            count += a.B;
        }
    }
    writeln(res);
}

Measured memory_bytes: 4860
fun main(args: Array<String>) {
  var X = readInt()
  while (true) {
    if (isPrime(X)) break
    X++
  }
  println(X)
}

fun isPrime(x: Int): Boolean {
  for (i in 2 until x) {
    if (x % i == 0) return false
  }
  return true
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

long long dp[3100][3100];

// dp[i][j]dp[i][j] 
// 元の数列から連続する区間 ai,ai+1,…,aj−1ai,ai+1,…,aj−1 を抜き出した状態の局面から出発して
// 双方最善を尽くしたときの X−YX−Y の値


int main(){
    
    int N;
    cin >> N;
    
    vector<int> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    
    for (int i = 0; i < N; i++) dp[i][i] = 0;
    
    for (int len = 1; len <= N; len++){
        
        for (int i = 0; i + len <= N; i++){
            
            int j = i + len;
            
            //  先手番
            if ((N-len) % 2 == 0) dp[i][j] = max(dp[i+1][j] + a[i], dp[i][j-1] + a[j-1]);
            
            // 後手
            else{
                dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1] - a[j-1]);
            }
        }
    }
    
    cout << dp[0][N] << endl;
}


Measured memory_bytes: 73984
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    int a,b;
    cin >> a >> b;
    if(a <= b){
        cout << a  << endl;
    }else{
        cout << a - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

    vector<int> t(n + 1);
    for (int i = 0; i < m; i++)
    {
        int a;
        cin >> a;
        t[a]++;
    }

    int right = 0;

    for (int i = x; i < n; i++)
    {
        right += t[i];
    }

    int left = 0;
    for (int i = x; i > 0; i--)
    {
        left += t[i];
    }

    cout << min(left, right) << endl;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[8888];
#include<bitset>
std::bitset<16666>f[2][2],z;
int ab(int x)
{
	return x>0?x:-x;
}
int main()
{
	scanf("%s",s+1);
	int now=0,tp=1;
	int n=strlen(s+1);
	int x=io::F(),y=io::F();
	int X=0,Y=1;
	int C=8000;
	f[0][0][8000]=1;
	f[1][0][8000]=1;
	for(register int i=1;i<=n;++i,std::swap(X,Y))
	{
		int cnt=0;
		while(s[i]=='F')++cnt,++i;
		f[now^1][Y]=f[now^1][X];
		if(!tp)f[now][Y]=f[now][X]<<cnt|f[now][X]>>cnt;
			else f[now][Y]=f[now][X]<<cnt;
		if(s[i]=='T')tp=0,now^=1;
	}
	if(f[0][X][x+C]&&f[1][X][y+C])puts("Yes"),exit(0);
	puts("No");
	return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define vs vector<string>
#define all(A) A.begin(), A.end()

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

    bool ans = false;
    rep(i,s.size()-1){
        if(s[i] == 'A' && s[i+1] == 'C'){
            ans = true;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int mod=1000000007;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n,k;
	cin>>n>>k;
	int dp[n][k+1];
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	memset(dp,0,sizeof(dp));
	for(int i=0;i<n;i++){
		dp[i][0]=1;
	}
	for(int i=0;i<=a[0];i++){
		dp[0][i]=1;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<=k;j++){
			dp[i][j]=(dp[i][j-1]%mod+dp[i-1][j]%mod)%mod;
			if(a[i]<j){
				dp[i][j]=(dp[i][j]%mod-dp[i-1][j-a[i]-1]%mod);
			}
			if(dp[i][j]<0){
				dp[i][j]+=mod;
			}
			//cout<<dp[i][j]<<" "<<i<<" "<<j<<" ";
		}
		
	}
	cout<<dp[n-1][k];
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
const int INF = 1<<28;
struct Edge {
  int v;
};
typedef vector<vector<Edge> > Graph;

const int MAXN = 555;

int N, E, Q;
Graph G;
int vis[MAXN];
int cap[MAXN][MAXN];

void addEdge(int from, int to) {
  G[from].push_back((Edge){to});
  G[to].push_back((Edge){from});
  cap[from][to] = cap[to][from] = 1;
}

void eraseEdge(int from, int to) {
  for (int i = 0; i < G[from].size(); ++i) {
    if (G[from][i].v == to) {
      G[from].erase(G[from].begin() + i);
      break;
    }
  }
  for (int i = 0; i < G[to].size(); ++i) {
    if (G[to][i].v == from) {
      G[to].erase(G[to].begin() + i);
      break;
    }
  }
}

int dfs(int v, int t, int f) {
  vis[v] = true;
  if (v == t) return f;
  for (int i = 0; i < G[v].size(); ++i) {
    Edge &e = G[v][i];
    if (vis[e.v]) continue;
    if (cap[v][e.v] == 0) continue;
    int d = dfs(e.v, t, min(f, cap[v][e.v]));
    if (d) {
      cap[v][e.v] -= d;
      cap[e.v][v] += d;
      return d;
    }
  }
  return 0;
}

int oneFlow(int s, int t) {
  memset(vis, 0, sizeof(vis));
  return dfs(s, t, 1);
}

int maxFlow(int s, int t) {
  int f = 0;
  while (1) {
    memset(vis, 0, sizeof(vis));
    int d = dfs(s, t, INF);
    if (d == 0) return f;
    f += d;
  }
}

int main() {
  while (cin >> N >> E >> Q) {
    G = Graph(N);
    while (E--) {
      int F, T;
      cin >> F >> T;
      --F; --T;
      addEdge(F, T);
    }
    int f = maxFlow(0, N-1);
    while (Q--) {
      int M, A, B;
      cin >> M >> A >> B;
      --A; --B;
      if (M == 1) {
        addEdge(A, B);
        f += oneFlow(0, N-1);
      } else {
        int s, t;
        if (cap[A][B] == 0) {
          s = A; t = B;
        } else if (cap[B][A] == 0) {
          s = B; t = A;
        } else {
          s = t = -1;
        }
        eraseEdge(A, B);
        if (s != -1) {
          if (oneFlow(s, t) == 0) {
            --f;
            if (f) {
              oneFlow(N-1, 0);
              oneFlow(s, t);
            } else {
              for (int i = 0; i < N; ++i) {
                for (int j = 0; j < G[i].size(); ++j) {
                  cap[i][G[i][j].v] = 1;
                }
              }
            }
          }
        }
      }
      cout << f << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2564
from bisect import bisect_left
N=int(input())
y=list(map(int, input().split()))
y.sort()
ans=0
for i in range(N-2):
  for j in range(i+1, N-1):
    tmp=y[i]+y[j]
    ans+=bisect_left(y,tmp)-j-1
print(ans)


Measured memory_bytes: 9324
ranks = list(map(int,input().split()))
x, y = ranks[0], ranks[1]
total = 0

if x == 1 :
    total += 300000
elif x == 2 :
    total += 200000
elif x == 3 :
    total += 100000

if y == 1 :
    total += 300000
elif y == 2 :
    total += 200000
elif y == 3 :
    total += 100000

if x == y == 1 :
    total += 400000

print(total)

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i, n) cin >> a[i];

    int ans = INF;

    REPN(i, -100, 101) {
        int tmp = 0;
        REP(j, n) {
            tmp += (a[j] - i) * (a[j] - i);
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

vector<int> vi;

int main(){
    int N, M;
    cin >> N >> M;
    vi.resize(N);
    rep(i, N) vi[i] = -1;

    rep(i, M){
        int s, c, idx;
        cin >> s >> c;
        s--;
        if (vi[s] != -1 && vi[s] != c){
            cout << "-1" << endl;
            return 0;
        }
        vi[s] = c;
    }

    if (vi[0] == 0 && N != 1){
        cout << -1 << endl;
        return 0;
    }

    rep(i, N){
        if (i == 0 && N != 1) {
            if (vi[0] == -1){
                cout << 1;
            }
            else {
                cout << vi[0];
            }
        }
        else{
            if (vi[i] == -1){
                cout << 0;
            }
            else{
                cout << vi[i];
            }
        }
    }
    cout << endl;
    
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            (int H, int W) = Slice<int, int>();
            var Aij = new long[H][];
            for (var h = 0; h < H; ++h)
                Aij[h] = Sarray();
            var Bij = new long[H][];
            for (var h = 0; h < H; ++h)
                Bij[h] = Sarray();
            var diff = new long[H, W];
            for (var h = 0; h < H; ++h)
                for (var w = 0; w < W; ++w)
                    diff[h, w] = Abs(Aij[h][w] - Bij[h][w]);
            var hs = Enumerable.Range(0, W).Select(_ => new HashSet<long>()).ToArray();
            hs[0].Add(diff[0, 0]);
            for (var h = 0; h < H; ++h)
                for (var w = 0; w < W; ++w)
                {
                    var hst = new HashSet<long>();
                    var max = (H - h + W - w) * 80;
                    if (h == 0 && w == 0) continue;
                    if (w != 0)
                        foreach (var t in hs[w - 1])
                        {
                            var v = Abs(t + diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                            v = Abs(t - diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                        }
                    if (0 != h)
                        foreach (var t in hs[w])
                        {
                            var v = Abs(t + diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                            v = Abs(t - diff[h, w]);
                            if (v <= max)
                                hst.Add(v);
                        }
                    hs[w] = hst;
                }
            WriteLine(hs[W - 1].Min(e => Abs(e)));
        }
    }
}

Measured memory_bytes: 63352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;



int main(){
	ll N;
	cin >> N;
	vector<ll> A(N+1,0);
	vector<ll> ans(N+1,0);
	for(ll i=1;i<=N;i++){
		cin>>A[i]
	;}
	for(ll i=1;i<=N;i++){
		ans[A[i]]=i
	;}
	for(ll i=1;i<N+1;i++){
		cout<<ans[i]<<" "
	;}
	cout<<endl;

return 0;
}  



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

int main(){
    string S;
    cin >> S;
    int N = S.length();
    vector<int> A(N, 0);
    int L = 0, R = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'R')R++;
        else{
            A[i - 1] += (R + 1) / 2;
            A[i] += R / 2;
            R = 0;
        }
    }
    
    for(int i = N - 1; i >= 0; i--){
        if(S[i] == 'L')L++;
        else{
            A[i + 1] += (L + 1) / 2;
            A[i] += L / 2;
            L = 0;
        }
    }
    
    for(auto a : A)cout << a << endl;
    return 0;
}

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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    if(h > w) cout << (n+h-1)/h;
    else cout << (n+w-1)/w;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    std::string s, t;
    int n = 0;
    std::cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            n++;
        }
    }
    std::cout << n << std::endl;
    return 0;
}

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

long long n, W, w[101], v[101], dp[101][100010], ans;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> W;
	for(int i=1; i<=n; ++i) cin >> w[i] >> v[i];
	for(int i=1; i<=n; ++i)
		for(int j=0; j<=W; ++j){
			dp[i][j] = dp[i-1][j];
			if(j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i-1][j-w[i]] + v[i]);
		}
	for(int i=0; i<=W; ++i) ans = max(ans, dp[n][i]);
	cout << ans << "\n";
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define base 1000000007LL
#define ll long long
#define X first
#define Y second
#define ld double
#define pb push_back
#define EPS 1e-9
#define all(a) a.begin(),a.end()
#define sz(a) int((a).size())
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
using namespace std;
typedef pair<int, int> II;
typedef pair<ll, II> III;

int n, k, a[100010];

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    //freopen("inp.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    cin >> n >> k;
    FOR(i,1,n) cin >> a[i];
    int vt = 0;
    FOR(i,1,n)
        if (a[i] >= 0) {
            vt = i;
            break;
        }
    if (vt == 0) {
        cout << abs(a[n-k+1]);
        return 0;
    }
    if (a[vt] == 0) {
        if (k == 1) {
            cout << 0;
            return 0;
        }
    }
    int res = 2000000000;
    FOR(i,vt,n) {
        int remain = k-(i-vt+1);
        if (remain < 0) break;
        if (vt-remain > 0) {
            int h = a[i];
            int g = a[vt-remain];
            res = min(res, min(abs(g) + h-g, h-g+h));
        }
    }
    if (vt-k > 0) {
        int h = 0;
        int g = a[vt-k];
        res = min(res, min(abs(g) + h-g, h-g+h));
    }
    cout << res;
    return 0;
}


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

int main() {
    int k,x;
    cin>>k>>x;
    for (int i=x-k+1; i<x+k; i++) {
        cout<<i<< " ";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int M=1e9+7;
long long n,x,y,z,k;
int main()
{
    cin >> n;
    x=y=z=1;
    for(int i=0; i<n; i++) x*=10,x%=M;
    for(int i=0; i<n; i++) y*=9,y%=M;
    for(int i=0; i<n; i++) z*=8,z%=M;
    k = (x-2*y+z)%M;
    if(k<0) k+=M;
    cout << k;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char s[4],p[4];
int main(){
	scanf("%s%s",s,p);
	if(s[0]==p[2]&&s[1]==p[1]&&s[2]==p[0])
		printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        System.out.println(main.solve());
    }
    long solve(){
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt(), r = sc.nextInt();
        int mod = 2019;
        boolean[] vis = new boolean[mod];
        for(int i=0;i<mod&&i+l<=r;i++){
            vis[(l+i)%mod] = true;
        }
        long ans = mod-1;
        for(int i=0;i<mod;i++){
            if(!vis[i]) continue;
            for(int j=0;j<mod;j++){
                if(j==i) continue;
                if(vis[j]) ans = Math.min(ans, i*j%mod);
            }
        }
        return ans;
    }
}

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

int main() {
  int n, f = 1;
  cin >> n;
  int x[n], y[n], p[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    p[i] = i;
    f *= i + 1;
  }
  int o[n];
  double l = 0.0;
  do {
    for (int i = 0; i < n; i++) {
      o[i] = p[i];
    }
    for (int i = 1; i < n; i++) {
      l += sqrt((x[o[i - 1]] - x[o[i]]) * (x[o[i - 1]] - x[o[i]]) + (y[o[i - 1]] - y[o[i]]) * (y[o[i - 1]] - y[o[i]]));
    }
  } while (next_permutation(p, p + n));
  cout << fixed << setprecision(10) << l / f << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> transform(int N, vector<int> A, vector<int> perm) {
	vector<int> ans(N);
	for (int i = 0; i < N; ++i) {
		ans[i] = A[perm[i]];
	}
	return ans;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, D, A;
	cin >> N >> D >> A;
	vector<int> X(N), H(N), perm(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> H[i];
		perm[i] = i;
	}
	sort(perm.begin(), perm.end(), [&](int i, int j) { return X[i] < X[j]; });
	X = transform(N, X, perm);
	H = transform(N, H, perm);
	vector<long long> diff(N + 1);
	long long cursum = 0, ans = 0;
	int ptr = 0;
	for (int i = 0; i < N; ++i) {
		cursum += diff[i];
		if (cursum < H[i]) {
			long long req = (H[i] - cursum + A - 1) / A;
			cursum += req * A;
			diff[i] += req * A;
			ans += req;
			while (ptr != N && X[ptr] <= X[i] + 2 * D) ++ptr;
			diff[ptr] -= req * A;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define P 1000000007

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0);

	ll x;
	cin >> x;
	for(ll a = -1001; a < 1001; a++) {
		for(ll b = -1001; b < 1001; b++) {
			if(pow(a, 5) - pow(b, 5) == x) {
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 4072
//2019.7.27 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=1e5+10;
namespace MAIN{
    int n;
    int a[N],b[N];
    LL ret;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n+1;i++)a[i]=read();
        for(res i=1;i<=n;i++)b[i]=read();
        for(res i=1;i<=n;i++){
            res mn=min(b[i],a[i]);
            ret+=mn,b[i]-=mn,a[i]-=mn;
            mn=min(b[i],a[i+1]),ret+=mn,b[i]-=mn,a[i+1]-=mn;
        }
        printf("%lld\n",ret);
    }
}
int main(){
//    freopen("compound1.in","r",stdin);
//    freopen("compound.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
typedef pair<int,int> P;
const int MAX_N = 200000;
struct UnionFind{
    int par[MAX_N];
    void init(int n){
        for(int i = 0;i < n;i++){
            par[i] = i;
        }
    }
    int root(int x){
        if(par[x] == x)return x;
        else return par[x] = root(par[x]);
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    void unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y)return;
        par[y] = x;
    }
};
main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N,K,L;
    cin >> N >> K >> L;
    UnionFind r,t;
    r.init(N);
    t.init(N);
    for(int i = 0;i < K;i++){
        int a,b;
        cin >> a >> b;
        r.unite(a-1,b-1);
    }
    for(int i = 0;i < L;i++){
        int a,b;
        cin >> a >> b;
        t.unite(a-1,b-1);
    }
    map<P,int> mp;
    for(int i = 0;i < N;i++){
        mp[P(r.root(i),t.root(i))]++;
    }
    for(int i = 0;i < N;i++){
        cout << mp[P(r.root(i),t.root(i))] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 13568
n = int(input())
c = 1
s = []
for i in range(n):
  ss = input()
  s.append(ss)
s.sort()  
for j in range(1,n):
  #print(s[i],s[i-1])
  if s[j] !=s[j-1]:
    c+=1 
print(c)    



Measured memory_bytes: 24028
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        System.out.println(Math.min((n + a - 1) / a * b, (n + c - 1) / c * d));
    }
}


Measured memory_bytes: 26392
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b, c,d; cin >> a >> b >> c>>d;
	cout << min(a, b) + min(c, d);


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

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

	long long power = 1;
	for (int i = 1; i <= n; ++i) {
		power = power * i % 1000000007;
	}

	cout << power << endl;

	return 0;
}

Measured memory_bytes: 3636
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 \
   /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/input.txt"
exit $?
'''
import sys
import math


def _i(): return int(sys.stdin.readline().strip())


def main():
    return 2 * _i() * math.pi


if __name__ == "__main__":
    print(main())


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

using namespace std;
#define INF 1000000001

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    
    if((a == b && a != c) || (a == c && a != b) || (b == c && b != a)) cout << "Yes" << "\n";
    else cout << "No" << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  llong N;
  cin >> N;
  if(N%2==0) cout << N << endl;
  else cout << 2 * N << endl;
}

Measured memory_bytes: 256
import itertools

n = int(input())

p_list = tuple(map(int, input().split()))
q_list = tuple(map(int, input().split()))

# print(p_list, q_list)

p_i, q_i = -1, -1
for i, series in enumerate(itertools.permutations(range(1, n + 1))):
    # print(series)
    if p_list == series:
        # print('p')
        p_i = i
    if q_list == series:
        # print('q')
        q_i = i
    if p_i != -1 and q_i  != -1:
        break

# print(p_i, q_i)
print(abs(p_i - q_i))


Measured memory_bytes: 3060
import java.util.*;
import java.lang.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer a = sc.nextInt();
        Integer b = sc.nextInt();
        Integer c = sc.nextInt();
        Triangle triangle = new Triangle();
 
        System.out.printf("%f",triangle.triangleArea(a,b,c));
        System.out.println();
        System.out.printf("%f", triangle.triangleCircumference(a,b,c));
        System.out.println();
        System.out.printf("%f", triangle.triangleHeight(a,b,c));
    }
}
class Triangle{
    private int a;
    private int b;
    private int angle;
    
    public Triangle(){
        this.a = a;
        this.b = b;
        this.angle = angle;
    }
    public static double triangleArea(int a, int b,int angle){
        return (double)a * b * Math.sin(Math.toRadians(angle))/ 2;
    }
    public static double triangleCircumference(int a, int b, int angle){
        return(double)(a + b + Math.sqrt(Math.pow(a,2) + Math.pow(b,2) - 2 * a * b * Math.cos(Math.toRadians(angle))));
    }
    public static double triangleHeight(int a, int b,int angle){
        return (double) b * Math.sin(Math.toRadians(angle));
    }
}


Measured memory_bytes: 26276
import java.util.*;

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

      int n = sc.nextInt();

      String[] s = new String[n];

      for(int i=0;i<n;i++){
        s[i] = sc.next();
      }

      char[][] c = new char[n][10];
      for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
          c[i][j] = s[i].charAt(j);
        }
      }

      for(int i=0;i<n;i++){
        Arrays.sort(c[i]);
      }

      String[] fin = new String[n];

      for(int i=0;i<n;i++){
        fin[i] = "";
        for(int j=0;j<10;j++){
            fin[i] += c[i][j];
        }
      }

      Arrays.sort(fin);

      String[] ffin = new String[n+1];
      for(int i=0;i<n;i++){
        ffin[i] = fin[i];
      }
      ffin[n] = "tarako";

//////////////////////////////////////////////

      long cnt = 1;
      long ans = 0;

      for(int i=0;i<n;i++){
      ///////////////////////////////////
      if(ffin[i].equals(ffin[i+1])){
        cnt++;
      }
      else{
        ans += cnt*(cnt-1)/2;
        cnt = 1;
      }

      ///////////////////////////////////
      }

      System.out.println(ans);

      /*for(int i=0;i<n;i++){
        System.out.println("fin[i]="+fin[i]);
      }*/

    }
}


Measured memory_bytes: 105276
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  /*
  for(int i=0; i<N; i++){
    cout<<"d.at("<<i<<") : "  << d.at(i) << endl;
  }
  */
  int loop = N*(N-1)/2;
  int ans = 0;
  
  for(int i=0; i < N; i++){   
  	for(int j=i+1; j < N; j++){
      ans += d.at(i) * d.at(j);
          
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
c = [[int(i) for i in input().split()] for i in range(n)]
length = []
for i in range(n):
    for j in range(i+1,n):
        length.append(((c[i][0]-c[j][0])**2 + (c[i][1]-c[j][1])**2)**0.5)

print(sum(length)*2/n)


Measured memory_bytes: 3060
//AUTHOR - NIMISH UPADHYAY
//FROM IIIT ALLAHABAD
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define NIMISH ios_base::sync_with_stdio(false);cin.tie(NULL);
#define UPADHYAY int t;cin>>t;while(t--)
ll p=1e9+7;
ll power(ll n,ll m){
    if(m==0)return 1;
    ll k=power(n,m/2);
    k=(k*k)%p;
    if(m&1)
    return (k*n)%p;
    return k;
    
}
int main(){
    ll c[2001],i,j,n,ans=0,k,a,b,x;
    c[0]=1;
    for(i=1;i<=2000;i++)
    c[i]=(c[i-1]*i)%p;
    cin>>n;
    for(i=1;i<=n;i++){
        j=n-2*i-1;
        k=i-1;
        if(j<0)
        break;
        if(j<k)
        break;
        a=c[j];
        b=c[k];
        x=c[j-k];
        b=(b*x)%p;
        b=power(b,p-2);
        a=(a*b)%p;
        ans=(ans+a)%p;
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = ReadLine().Split().Select(int.Parse).ToArray();
        string[] field = new string[n[0] << 1];
        for(int i = 0; i < n[0] << 1; i += 2)
        {
            var s = ReadLine();
            field[i] = s;
            field[i + 1] = s;
        }
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < n[0] << 1; i++)
            sb.Append($"{field[i]}\r\n");
        WriteLine($"{sb.ToString().Trim()}");
    }
}


Measured memory_bytes: 13396
function main(input) {
  input = input.split('\n');
  const n = parseInt(input[0]);
  const a = input[1]
    .trim()
    .split(' ')
    .map((i) => BigInt(i));
  let ans = 1n;
  if (!a.includes(0n)) {
    for (let i = 0; i < n; ++i) {
      if (ans > 10 ** 18) {
        break;
      }
      ans = ans * a[i];
    }
    console.log(ans > 10 ** 18 ? -1 : ans + '');
  } else {
    console.log(0);
  }
}

 main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
	int n;
	while(cin >> n && n){
		int m = 0, henkan[10000] = {};
		char in, iin;
		for(int i = 0; i < n; i++){
			cin >> in >> iin;
			int ctoi = in, ctoii = iin;
			henkan[ctoi] = ctoii;
		}
		cin >> m;
		for(int i = 0; i < m; i++){
			cin >> in;
			int ctoi = in;
			if(henkan[ctoi])
				ctoi = henkan[ctoi];
			cout << (char)ctoi;
		}
		cout << endl;
	}
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    map<int,int> vmp;
    for(int i = 0; i < n; i++) {
        int tmp=a[i];
        vmp[tmp]++;
    }
    vector<pair<int,int>> vp;
    for(auto itr = vmp.begin(); itr != vmp.end(); itr++) {
        vp.emplace_back(itr->second,itr->first);
    }
    sort(vp.begin(),vp.end());
    int count=0;
    int il=max(vp.size()-k,(unsigned long)0);
    for(int i = 0; i < il; i++) {
        count+=vp[i].first;
    }
    cout << count << "\n";
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i * j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
  int main(){
   int a,b,n,m,i,j,k;
   int c,d[100];
   for(i=0;i<100;i++){
       d[i] = 0;
   }
   scanf("%d",&n);
   scanf("%d %d",&a,&b);
   scanf("%d",&c);
   for(i=0;i<n;i++){
       scanf("%d",&d[i]);
        
   }
   for(j=0;j<n;j++){
       for(k=0;k<n-1;k++){
           if(d[k]<d[k+1]){
              m = d[k+1];
              d[k+1] =d[k];
              d[k] = m;
           }
       }
   }
   for(i=0;i<n;i++){
       if(c/(a+i*b)<d[i]/b){
         c += d[i];
       }else{
           int y = c/(a+i*b);
           printf("%d\n",y);
           break;
       }
   }
   return 0;
  }

Measured memory_bytes: 596
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;cin>>n;
  ll a[n], sum = 0,ans = 0;
  F(i,0,n) cin>>a[i];
  for(int i = n-2;i>=0;i--){
  	sum  = (sum +a[i+1])%MOD;
  	ans  = (ans+ (sum*(a[i]))%MOD)%MOD;
  }

  cout<<ans;
  return 0;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    map<int, int> m;
    int a;
    REP(i, n) {
        cin >> a;
        m[a]++;
    }
    int ans = 0;
    int ans2 = 0;
    for (auto x : m) {
        if (x.second % 2 == 0) ans2++; else ans++;
    }
    cout << ans + (ans2 % 2 == 0 ? ans2 : ans2 - 1) << endl;

}


Measured memory_bytes: 4992
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second
#define int long long

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=1e9+7;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
int n,m,k,f[MAXN];
struct enode{int u,v,c; } e[MAXN];
int quick_pow(int x,int y)
{
	int ret=1;
	for (;y;y>>=1)
	{
		if (y&1) ret=ret*x%mods;
		x=x*x%mods;
	}
	return ret;
}
int find(int x) { return f[x]==x?f[x]:f[x]=find(f[x]); }
int getans(int id)
{
	int ans=0;
	for (int i=1;i<=n;i++) f[i]=i;
	f[e[id].u]=f[e[id].v],ans+=e[id].c;
	for (int i=1;i<=m;i++)
	{
		int x=find(e[i].u),y=find(e[i].v);
		if (x!=y) f[x]=y,ans+=e[i].c;
	}
	return ans;
}
int compare(enode x,enode y){ return x.c<y.c; }
signed main()
{
	n=read(),m=read(),k=read();
	for (int i=1;i<=m;i++)
	{
		int u=read(),v=read(),c=read();
		e[i]=(enode){u,v,c};
	}
	sort(e+1,e+m+1,compare);
	int fst=getans(0),cnt1=0,cnt2=0;
	if (fst>k) { puts("0"); return 0; } 
	for (int i=1;i<=m;i++)
	{
		int t=getans(i);
		if (t==k) cnt1++;
		if (t>k) cnt2++;
	}
	if (fst==k) printf("%lld\n",(quick_pow(2,cnt1)-2)*quick_pow(2,cnt2)%mods);
	else printf("%lld\n",(quick_pow(2,cnt1+1)-2)*quick_pow(2,cnt2)%mods);
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T& a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T& a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

template <typename T>
class SegTree {
  int n;
  vector<T> data;
  T initial_value;
  function<T(T, T)> operation;
  function<T(T, T)> _update;

  // [a,b)
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return initial_value;
    }

    if (a <= l && r <= b) {
      return data[k];
    } else {
      T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
      T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
      return operation(c1, c2);
    }
  }

 public:
  SegTree(size_t _n, T _initial_value, function<T(T, T)> _operation, function<T(T, T)> update_function)
    : initial_value(_initial_value), operation(_operation), _update(update_function) {
    n = 1;
    while (n <= _n) {
      n <<= 1;
    }
    data = vector<T>(2 * n - 1, initial_value);
  }

  // update i-th number (0-indexed)
  void update(int i, T x) {
    i += n - 1;
    data[i] = _update(data[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  T query(int a, int b) {
    return _query(a, b, 0, 0, n);
  }

  T operator[](int i) {
    return data[i + n - 1];
  }
};

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

  ll n;
  cin >> n;

  string s;
  cin >> s;

  ll q;
  cin >> q;

  SegTree<bitset<26>> st(
    n + 1, bitset<26>(0), [](bitset<26> a, bitset<26> b) { return a | b; },
    [](bitset<26> a, bitset<26> b) { return b; });

  rep(i, n) {
    bitset<26> v;
    v[s[i] - 'a'] = 1;
    st.update(i + 1, v);
  }

  rep(i, q) {
    ll type;
    cin >> type;
    if (type == 1) {
      ll a;
      char b;
      cin >> a >> b;
      bitset<26> v;
      v[b - 'a'] = 1;
      st.update(a, v);
    } else {
      ll l, r;
      cin >> l >> r;
      auto res = st.query(l, r + 1);
      cout << res.count() << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 9116
H,W = map(int,input().split())
s = H*W
def func(h,w):
    tmp = float("inf")
    for x in range(1,w):
        s1 = h*x
        s2 = (w-x)*(h//2)
        s3 = s - s1 - s2
        d = max(s1,s2,s3) - min(s1,s2,s3)
        if d < tmp:
            tmp = d
    return tmp
ans = min(func(H,W),func(W,H),min(W%3,1)*H,(min(H%3,1)*W))
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
int A[100005],N;

ll ch(int p)
{
	ll t=0,r=0;
	for(int i=0;i<N;i++,p*=-1)
	{
		t+=A[i];
		if(t*p<=0)
		{
			if(p==-1){r+=abs(-1-t);t=-1;}
			else {r+=abs(1-t);t=1;}
		}
	}
	return r;
}

int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&A[i]);
	printf("%lld\n",min(ch(1),ch(-1)));
	return 0;
}

Measured memory_bytes: 640
import Control.Applicative
import Data.Fixed

data E5 = E5
instance HasResolution E5 where
    resolution _ =
	100000
type Precise5 = Fixed E5

main = do
  [a, b] <- map (\x -> read x :: Int) . words <$> getLine
  putStr $ show $ a `div` b
  putStr " "
  putStr $ show $ a `mod` b
  putStr " "
  putStr $ show $ (fromIntegral a :: Precise5) / (fromIntegral b :: Precise5)

Measured memory_bytes: 4016