akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int dp[50];

int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}


int main(){
  int n, i;
  for(i = 0 ; i < 50 ; i++) dp[i] = -1;

  scanf("%d", &n);
  printf("%d\n", fib(n));

  return 0;
}


Measured memory_bytes: 2100
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int main(void){
	          int i;

	      	  cin.tie(0);  ios_base::sync_with_stdio(false);
	      	  
	      	  string s;
	      	  cin >> s;
	      	  int n=s.size();
	      	  
	      	  for(i=0;i<=n-2;i++){
	      		  if(s[i]=='A' && s[i+1]=='C'){
	      			  cout << "Yes" << endl;
	      			  return 0;
	      		  }
	      	  }
	      	  
	      	  cout << "No" << endl;

	          return 0;
}


Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.random;
     
void main() {
  while (1) {
  	auto x = readln.chomp.split;
  	if (x[1] == "?") break;
  	if (x[1] == "+") writeln(x[0].to!int+x[2].to!int);
  	if (x[1] == "-") writeln(x[0].to!int-x[2].to!int);
  	if (x[1] == "*") writeln(x[0].to!int*x[2].to!int);
  	if (x[1] == "/") writeln(x[0].to!int/x[2].to!int);
  }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int INF = int(1e9);

//BEGIN Dinic

struct Edge {
    int to, rev, cap, f = 0;
    Edge(int to, int rev, int cap) : to(to), rev(rev), cap(cap) {}
};

vector<Edge> g[100000];
int q[100000], dist[100000], pos[100000];
int nodes, src, dest;

void addEdge(int from, int to, int cap) {
    g[from].pb(Edge(to, (int)g[to].size(), cap));
    g[to].pb(Edge(from, (int)g[from].size() - 1, 0));
}

bool bfs() {
    forn(i, nodes) dist[i] = -1;
    dist[src] = 0;
    q[0] = src;
    for (int qh = 0, qt = 1; qh != qt; ++qh) {
        int v = q[qh];
        for (Edge e : g[v]) if (e.f < e.cap && dist[e.to] == -1) {
            dist[e.to] = dist[v] + 1;
            q[qt++] = e.to;
        }
    }
    return dist[dest] != -1;
}

int dfs(int v, int flow) {
    if (v == dest) return flow;
    for (int &i = pos[v]; i < (int)g[v].size(); ++i) {
        Edge &e = g[v][i];
        if (e.f < e.cap && dist[e.to] == dist[v] + 1) {
            int df = dfs(e.to, min(flow, e.cap - e.f));
            if (df > 0) {
                e.f += df;
                g[e.to][e.rev].f -= df;
                return df;
            }
        }
    }
    return 0;
}

int maxFlow() {
    int flow = 0;
    while (bfs()) {
        forn(i, nodes) pos[i] = 0;
        while (int df = dfs(src, INF)) {
            flow += df;
        }
    }
    return flow;
}

//END Dinic

int h, w;
char s[100][105];

int main() {
    scanf("%d%d", &h, &w);
    forn(i, h) {
        scanf("%s", s[i]);
    }
    int field = 2 * h * w;
    src = field + h + w;
    dest = src + 1;
    nodes = dest + 1;
    forn(i, h) forn(j, w) if (s[i][j] == 'o' || s[i][j] == 'S' || s[i][j] == 'T') {
        int beg = i * w + j;
        int ed = h * w + i * w + j;
        if (s[i][j] == 'o') {
            addEdge(beg, ed, 1);
        } else if (s[i][j] == 'S') {
            addEdge(src, ed, INF);
        } else if (s[i][j] == 'T') {
            addEdge(beg, dest, INF);
        }
        addEdge(ed, field + i, INF);
        addEdge(field + i, beg, INF);
        addEdge(ed, field + h + j, INF);
        addEdge(field + h + j, beg, INF);
    }
    int ans = maxFlow();
    if (ans > h * w) {
        ans = -1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5248
(defn input []
  (->> (clojure.string/split (read-line) #"\s")
    (map #(Integer/parseInt %))))

(defn PooisonousCookies [[A B C]]
  (if (< (+ A B) C)
    (+ A B B 1)
    (+ B C)))


(->> (input)
  PooisonousCookies
  println)

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

int main(){
    int n, q;
    cin >> n;
    long long sum = 0;
    vector<long long> num(100001, 0);
    vector<long long> ans(0);
    for (int i = 0; i < n; ++i){
        long long a;
        cin >> a;
        sum += a;
        ++num[a];
    }
    cin >> q;
    for (int i = 0; i < q; ++i){
        int b, c;
        cin >> b >> c;
        sum += (c - b) * num[b];
        num[c] += num[b];
        num[b] = 0;
        ans.push_back(sum);
    }
    for (int i = 0; i < ans.size(); ++ i){
        cout << ans[i] << endl;
    }
    return 0;
}

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

char buf[101];

int main (void)
{
    int len, i, count = 0;

    gets(buf);
    len = strlen(buf);

    for (i = 0; i < len / 2; i++) {
        if (buf[i] != buf[len - i - 1]) {
            count++;
        }
    }

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


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  vector<ll> x = {a*c, a*d, b*c, b*d};
  cout << *max_element(x.begin(), x.end()) << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>
#include <map>

using namespace std;

bool check(map<int, int> reportsMap, int noses) {
   int maxReport = noses - 1;
   if (noses % 2 == 0) {
      for (int i = 1; i <= maxReport; i+=2) {
         if (reportsMap[i] != 2) { return false; }
      }

   } else {
      if (reportsMap[0] != 1) { return false; }
      for (int i = 2; i <= maxReport; i+=2) {
         if (reportsMap[i] != 2) { return false; }
      }
   }
   return true;
}

int main() {

   int noses;
   cin >> noses;

   map<int, int> reportsMap;
   for (int i = 0; i < noses; i++) {
      int report;
      cin >> report;
      if (reportsMap.count(report)) {
         reportsMap[report] += 1;
      } else {
         reportsMap[report] = 1;
      }
   }

   int pattern = 1;
   for (int j = 0; j < (noses / 2); j++) {
      pattern = pattern * 2 % 1000000007;
   }
   // = (int)pow(2, (int)(noses / 2));
   //int answer = pattern % 1000000007;
   int answer = pattern;

   if (check(reportsMap, noses) == false) {
      answer = 0;
   }

   cout << answer << endl;
}

Measured memory_bytes: 6144
n = list(input())
if n[0] == "1":
    n[0] = "9"
else:
    n[0] = "1"
if n[1] == "1":
    n[1] = "9"
else:
    n[1] = "1"
if n[2] == "1":
    n[2] = "9"
else:
    n[2] = "1"
print(n[0] + n[1] + n[2])



Measured memory_bytes: 2940
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    int a, b = 0;
    
    cin >> a >> b;
    
    if (a < b)  cout << "a < b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define ld long double
#define endl "\n"
using namespace std;

int32_t main() {
  int n,x,t;
  cin>>n>>x>>t;
  int p = ceil((double)n/x);
  // int a[n];
  // for(int i = 0;i < n;i++) cin>>a[i];
  cout<<p*t;
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
#define int long long
#define N 300004
#define LL long long
#define ULL unsigned long long
#define pp pair<int,int>
#define mp make_pair
#define pb push_back
#define ff first
#define dd second
#define REP(i,n) for(int i=0;i<(n);++i)
#define FWD(i,a,b) for (int i=(a); i<(b); ++i)
#define BCK(i,a,b) for (int i=(a); i>(b); --i)
#define SIZE(c) ((int)((c).size()))
#define ALL(u) (u).begin(),(u).end()
#define K 41
LL fpw(LL a, ULL b, LL p){
    LL r = 1; while(b){if(b&1) r=r*a%p; a=a*a%p; b/=2;} return (LL)r;
}

using namespace std;
int n, m;


bool present[5][5];

int32_t main() {
    ios_base::sync_with_stdio(false);
    for(int i = 0; i < 5; ++i) for(int j = 0; j < 5; ++j) present[i][j] = 0;
    for(int i = 0; i < 3; ++i) {
        int a,b; cin >> a >> b; present[a][b] = present[b][a] = 1;
    }

    vector<int> nums = {1, 2, 3, 4};

    do{
        bool done = true;
        for(int i = 1; i < 4; ++i) {
            if (!present[nums[i]][nums[i-1]]) {
                done = false; break;
            }
        }
        if (done) {
            cout << "YES\n"; exit(0);
        }
    }while(next_permutation(nums.begin(), nums.end()));
    cout << "NO\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi pair < int, int>
#define ff first
#define ss second
#define int long long
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

const int N = 1e6 + 5;
int32_t main(){
	boost;
	int n;
	cin >> n;
	int a[n];
	int g;
	int fr[N] = {0};
	for(int i = 0, x; i < n; i++) {
		cin >> a[i];
		fr[a[i]]++;
		if(i == 0)
			g = a[i];
		else
			g = __gcd(a[i], g);
	}
	if(g != 1)
		cout << "not coprime" << endl;
	else {
		int f = 0;
		for(int i = 2; i < N; i++) {
			int cnt = 0;
			for(int j = i; j < N; j += i)
				cnt += fr[j];
			if(cnt > 1) {
				f = 1;
				break;
			}
		}
		if(f)
			cout << "setwise coprime" << endl;
		else
			cout << "pairwise coprime" << endl;
	}
}

Measured memory_bytes: 19204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
#define MAX 101

int main() {
	int h, w;
	char a[MAX][MAX];
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	for (int i = 0; i < h+2; i++) {
		if (i == 0 || i == h+1) {
			for (int j = 0; j < w+2; j++) {
				cout << "#";
			}
		} else {
			for (int j = 0; j < w+2; j++) {
				if (j == 0 || j == w+1) {
					cout << "#";
				} else {
					cout << a[i-1][j-1];
				}
			}
		}
		cout << endl;
	}
	return 0;
}


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

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    long[] beauty = new long[N];
    long[] lusciousness = new long[N];
    long[] popularity = new long[N];

    for(int i = 0; i<N; i++){
      beauty[i] = sc.nextLong();
      lusciousness[i] = sc.nextLong();
      popularity[i] = sc.nextLong();
    }

    long[][] value = new long[8][N];
    long score = 0;

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

      for(int j = 0; j<N; j++){
        value[i][j] += (i&4) == 0?beauty[j]:-beauty[j];
        value[i][j] += (i&2) == 0?lusciousness[j]:-lusciousness[j];
        value[i][j] += (i&1) == 0?popularity[j]:-popularity[j];
      }

      Arrays.sort(value[i]);
      //配列の昇順ソート
      long sum = 0;
      for(int j = 0; j<M; j++){
        sum += value[i][N-1-j];
      }
      score = Math.max(score, sum);
    }

    System.out.println(score);
  }
}


Measured memory_bytes: 25892
#include <string>
#include <queue>
#include <iostream>
using namespace std;
struct process
{
	string name;
	int t;
};
int main() 
{
	int n,q;
	int time=0;
	queue<process> rrs;
	cin>>n>>q;
	for(int i=0;i<n;i++)
	{
		process temp;
		cin>>temp.name>>temp.t;
		rrs.push(temp);
	}

	while(!rrs.empty())
	{

		process temp;
		temp=rrs.front();
		rrs.pop();
		if(temp.t>q)
		{
			temp.t=temp.t-q;
			rrs.push(temp);
			time+=q;
		}
		else
		{
			time+=temp.t;
			cout<<temp.name<<" "<<time<<endl;
		}
	}
}

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

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

using namespace std;
typedef long long unsigned int ll;


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

	REP(i, s.size()) {
		REP(j, n) {
			if (s[i] == 'Z')s[i] = 'A';
			else s[i]++;
		}
	}

	cout << s;
}

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
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var (N, M) = Slice2<long>();
            var prms = new long[N].Select(_ => new long[3]).ToArray();
            for (var i = 0; i < N; ++i)
                prms[i] = Sarray();
            var ptrn = 1 << 3;
            var max = long.MinValue;
            for (var i = 0; i < ptrn; ++i)
            {
                var sgs = new long[] { 1, 1, 1 };
                var t = i;
                for (var j = 0; j < 3; ++j, t >>= 1)
                    if (t % 2 == 1) sgs[j] = -1;
                max = Max(max, prms.Select(p => sgs[0] * p[0] + sgs[1] * p[1] + sgs[2] * p[2]).OrderByDescending(p => p).Take((int)M).Sum());
            }
            WriteLine(max);
        }
 
        static long Mod = 998244353;
        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 public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

Measured memory_bytes: 28884
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	cin >> N;
	map<string, int> mp;
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		sort(S.begin(), S.end());
		mp[S]++;
		ans += mp[S] - 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<x<<endl
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
typedef vector<int> vi;

int a,b,c;
int main(void){
    cin>>a>>b>>c;
    cout<<min(c,b/a)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

int main()
{
    ll x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    cout
        << (x2 + y1 - y2) << " " << (y2 + (x2 - x1)) << " "
        << (x1 + y1 - y2) << " " << (y1 + (x2 - x1)) << endl;
}

Measured memory_bytes: 256
a,b,c = map(int, input().split())

A_B = (a+b)
A_C = (a+c)
B_C = (b+c)

if (A_B == c):
    print("Yes")
elif (A_C == b):
    print("Yes")
elif (B_C == a ):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printde(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    unordered_map<int, int> um;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        um[a]++;
    }
    vector<int> as2;
    for(auto p : um){
        if(p.second >= 4){
            as2.push_back(p.first);
        }
        if(p.second >= 2){
            as2.push_back(p.first);
        }
    }
    sort(as2.rbegin(), as2.rend());
    cout << (as2.size() < 2 ? 0 : 1ll * as2[0] * as2[1]) << '\n';
    return 0;
}


Measured memory_bytes: 4128
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
// const int mod = 1000000007;
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint operator-() const { return mint(-x);}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
	mint operator+(const mint a) const { return mint(*this) += a;}
	mint operator-(const mint a) const { return mint(*this) -= a;}
	mint operator*(const mint a) const { return mint(*this) *= a;}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	
	// for prime mod
	mint inv() const { return pow(mod-2);}
	mint& operator/=(const mint a) { return *this *= a.inv();}
	mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
	int N, S;
	int A[3001];
	cin >> N >> S;
	for(int i = 1; i <= N; i++){
		cin >>A[i];
	}
	A[0] = 0;
	
	static mint DP[3001][3001];
	for(int i = 1; i <= N; i++){
		DP[0][i] = 0;
	}
	DP[0][0] = mint(2).pow(N);
	
	for(int i = 1; i <= N; i++){
		for(int j = 0; j <= S; j++){
			DP[i][j] = DP[i-1][j];
			if(j - A[i] >= 0){
				DP[i][j] += DP[i-1][j-A[i]] / 2;
			}
		}
	}
	
	cout << DP[N][S] << endl;
	
	return 0;
}

Measured memory_bytes: 73980
#include <stdio.h>

int main()
{
	char S[5];
	scanf("%s", S);
	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) printf("Yes\n");
	else if (S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) printf("Yes\n");
	else if (S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) printf("Yes\n");
	else printf("No\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1628
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll a, v, b, w, t;

int main() {
	cin >> a >> v >> b >> w >> t;
	if ((v - w) * t >= abs(a - b)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

int n, L;
int x[100055];
int l[17][100055], r[17][100055];

inline int go(int x, int y) {
	int res = 0;

	for (int i = 16; i >= 0; i--) {
		if (r[i][x] < y) {
			res += (1 << i);
			x = r[i][x];
		}
	}

	return res + 1;
}
inline int go2(int x, int y) {
	int res = 0;

	for (int i = 16; i >= 0; i--) {
		if (l[i][x] > y) {
			res += (1 << i);
			x = l[i][x];
		}
	}

	return res + 1;
}
int main() {
	scanf("%d", &n);

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

	scanf("%d", &L);

	{
		int pt = 0;

		for (int i = 0; i < n; i++) {
			while (pt < n && x[pt] - x[i] <= L) pt++;
			r[0][i] = pt - 1;
		}
	}

	{
		int pt = n - 1;

		for (int i = n - 1; i >= 0; i--) {
			while (pt >= 0 && x[i] - x[pt] <= L) pt--;
			l[0][i] = pt + 1;
		}
	}

	for (int i = 0; i < 16; i++) {
		for (int v = 0; v < n; v++) {
			l[i + 1][v] = l[i][l[i][v]];
			r[i + 1][v] = r[i][r[i][v]];
		}
	}

	int q;
	int x, y;

	scanf("%d", &q);

	while (q--) {
		scanf("%d %d", &x, &y);
		x--, y--;

		int res = 0;

		if (x < y) res = go(x, y);
		else res = go2(x, y);

		printf("%d\n", res);
	}

	return 0;
}

Measured memory_bytes: 14464
X, K, D = map(int, input().split())
n = (K-X//D)//2
#print(n)
if X - K*D > 0:
    ans = X-K*D
elif X + D*K < 0:
    ans = abs(X+D*K)
else:
    ans = float('inf')
    for i in range(-1, 2):
        res = X + D*(K-2*(n+i))
        ans = min(ans, abs(res))
    for i in range(-1, 2):
        res = X + D*(2*(n+i)-K)
        ans = min(ans, abs(res))
        #print(res)

print(ans)

Measured memory_bytes: 9212
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int n, m;
	cin >> n >> m;
	if (n == m)puts("Yes");
	else puts("No");*/


	int a, b;
	cin >> a >> b;
	int ma = max(a, b);
	int mi = min(a, b);
	rep(i, ma) {
		cout << mi;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int x,a,b; cin >> x >> a >> b;

  if (b <= a) {
    cout << "delicious" << endl;
  } else if (b <= x + a) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  return 0;
}


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

int main(void){
  double a,b,t;
  scanf("%lf %lf %lf",&a,&b,&t);
  double x = fmod(t+0.5,a);
  double n = ((t+0.5-x)/a)*b;
  int d = n;
  printf("%d",d);
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int i,count;
  char S[3];
  
  scanf("%s",S);
  
  if(S[0]=='R'&&S[1]=='R'&&S[2]=='R')
    count=3;
  else if(S[0]=='R'&&S[1]=='R'||S[1]=='R'&&S[2]=='R')
    count=2;
  else if(S[0]=='R'||S[1]=='R'||S[2]=='R')
    count=1;
  else
    count=0;
  
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 1728
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] balance={512,256,128,64,32,16,8,4,2,1};
		while(sc.hasNext()){
			String strW=Integer.toBinaryString(sc.nextInt());
			int length=strW.length();
			for(int i=0;i<balance.length-length;i++){
				strW="0"+strW;
			}
			char[] cW=strW.toCharArray();
			boolean flag=false;
			for(int i=cW.length-1;i>=0;i--){
				if(Character.toString(cW[i]).equals("1")){
					if(flag){
						System.out.print(" "+balance[i]);
					}else{
						System.out.print(balance[i]);
						flag=true;
					}
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17244
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

struct Seg{
    vec dat;
    //要素数
    int n;

    Seg(int n_){
        n=1;
        while(n<n_)n*=2;
        dat.resize(2*n);

        for(int i=0;i<2*n-1;i++)
            dat[i]=INF;
    }

    //k番目の値をaに変更
    void update(int k,ll a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }

    //[a,b)の最小値を求める
    //kは節点の番号、[l,r)はその区間
    ll query(int a,int b,int k,int l,int r){
        if(r<=a || b<=l)return INF;
        if(a<=l && r<=b)return dat[k];
        else{
            ll vl=query(a,b,2*k+1,l,(l+r)/2);
            ll vr=query(a,b,2*k+2,(l+r)/2,r);
            return min(vl,vr);
        }
    }
};

int main(){
    int N,K; scanf("%d %d",&N,&K);
    int M=(int)sqrt(N);
    vec MA,n;
    FOR(i,1,M+1){
        MA.pb(i); n.pb(1);
    }
    int m=M;
    if(M*M==N) m--;
    rep(i,m){
        MA.pb(N/(m-i)); n.pb(MA[M+i]-MA[M+i-1]);
    }
    int j=SZ(MA);
    vec dp(j),S(j,1);
    rep(k,K){
        rep(i,j){
            dp[i]=(n[i]*S[j-i-1])%mod;
        }
        S[0]=dp[0];
        FOR(i,1,j) S[i]=(S[i-1]+dp[i])%mod;
    }
    printf("%lld\n",S[j-1]);
    return 0;
}

Measured memory_bytes: 2420
//感谢Factorio 

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
using namespace std;
int n;
vector<int> G[1005];
pair<int,long long> ans;
int c[1005];
int x[1005],y[1005];
void dfs(int x,int fa,int dep){
    int cnt=0;
    for (int i=0;i<G[x].size();i++){
        if (G[x][i]==fa){
            continue;
        }
        dfs(G[x][i],x,dep+1);
        cnt++;
    }
    c[dep]=max(c[dep],cnt);
}
void update(){
    int u=0;
    long long v=1;
    while (c[u]){
        v*=c[u];
        u++;
    }
    ans=min(ans,make_pair(u,v));
}
int main() {
    cin>>n;
    for (int i=1;i<n;i++){
        
        cin>>x[i]>>y[i];
        G[x[i]].push_back(y[i]);
        G[y[i]].push_back(x[i]);
    }
    ans=make_pair(n,0);
    //node
    for (int i=1;i<=n;i++){
        memset(c,0,sizeof(c));
        c[0]=1;
        dfs(i,0,1);
        update();
    }
    //edge
    for (int i=1;i<n;i++){
        memset(c,0,sizeof(c));
        c[0]=2;
        dfs(x[i],y[i],1);
        dfs(y[i],x[i],1);
        update();
    }
    cout<<ans.first<<" "<<ans.second<<endl;
    return 0;
}


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




char cakes[330][330];
int  nums[330][330];

int main() {
    int H, W, K;
    cin >> H >> W >> K;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cin >> cakes[i][j];
        }
    }
    int now = 1;
    int flag = 0;
    int sp_flag = 0;
    int ps_flag = 0;
    int backline = -1;
    
    for (int i = 0; i < H; ++i) {
        if (flag == 1 && K >= 0){
            now += 1;
        }
        if (flag == 0 && now != 1) {
            for (int k = 0; k < W; ++k) {
                nums[i-1][k] = nums[i-2][k];
            }
        }
        if (K == 0){
            sp_flag = 1;
        }

        if (now >= 2 && ps_flag == 0) {
            backline = i-1;
            ps_flag = 1;
        }


        flag = 0;
        for (int j = 0; j < W; ++j) {
            if (flag && cakes[i][j] == '#'){
                K -= 1;
                now += 1;
                nums[i][j] = now;
            }
            else if (flag == 0 && cakes[i][j] == '#'){
                K -= 1;
                nums[i][j] = now;
                flag = 1;
            }
            else if (sp_flag) {
                nums[i][j] = nums[i-1][j];
            }
            else{
                nums[i][j] = now;
            }
            
            
        }
    }
    //gyaku
    for (int i = backline; i >= 1; --i){
        for (int j = 0; j < W; ++j) {
            nums[i-1][j] = nums[i][j];
        }
    }


    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            cout << nums[i][j];
            
            if (j != W-1) cout << " ";
            else cout << endl;
        }
    }

}

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x-I .)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s;
    cin >> s;
    if(s[s.size()-1] == 's')s += "es";
    else s += 's';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3628
from bisect import bisect_left, insort_left
n = int(input())
ab = []
for _ in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
cd = []
for _ in range(n):
    c, d = map(int, input().split())
    cd.append((c, d))
ab.sort()
cd.sort()
ans = 0
q = []
ind = 0
for i in range(n):
    for j in range(ind, n):
        if ab[j][0]>cd[i][0]:
            ind = j
            break
        insort_left(q, ab[j][1])
    else:
        ind = n
    tmp = bisect_left(q, cd[i][1])
    if tmp>0:
        q.pop(tmp-1)
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;

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

  int maxv = -2000000000;  // 十分小さい値を初期値に設定
  int minv = R[0];

  for ( int i = 1; i < n; i++ ) {  // ここで毎回 R[i] を読み込めば、配列は不要
    maxv = max(maxv, R[i] - minv);  // 最大値を更新
    minv = min(minv, R[i]);  // ここまでの最小値を保持しておく
  }

  cout << maxv << endl;

  return 0;
}


Measured memory_bytes: 3876
/*
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/10/ITP1_10_C
*/
#include <bits/stdc++.h>
using namespace std;

double _average(vector<int> &vi) {
    int sum = 0;
    for (auto num : vi)
        sum += num;
    return (double)sum / vi.size();
}

double standard_deviation(vector<int> &vi, double average) {
    double sum = 0;
    for (size_t i = 0; i < vi.size(); i++)
        sum += pow((vi.at(i) - average), 2);
    return sqrt(sum / (double)vi.size());
}

void solve(vector<int> vi) {
    double average = _average(vi);
    double sd = standard_deviation(vi, average);
    cout << setprecision(10) << sd << endl;
}

void trace(vector<int> &vi) {
    for (auto i : vi)
        cout << i << endl;
}

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

    while (true) {
        int student;
        cin >> student;
        if (student == 0)
            return 0;

        vector<int> points(student);
        for (int i = 0; i < student; i++) {
            cin >> points[i];
        }
        // trace(points);
        solve(points);
    }
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n + 2);
	a[0] = 0;
	a[n + 1] = 0;
	int sum = 0;
	rep (i, 1, n + 1)
		cin >> a[i];

	rep (i, 1, n + 2)
		sum += abs(a[i] - a[i - 1]);

	rep (i, 1, n + 1) {
		int res = sum;
		if (a[i] < a[i - 1] && a[i] <  a[i + 1]) {
			res -= abs(a[i] - min(a[i - 1], a[i + 1])) * 2;
		} else if (a[i] > a[i - 1] && a[i] > a[i + 1]) {
			res -= abs(a[i] - max(a[i - 1], a[i + 1])) * 2;
		}

		cout << res << endl;
	}

	return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef ll Weight;
void add_edge(vector<vector<Weight>>& g, Weight from, Weight to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

int d = 365;

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

  cin >> d;
	int c[26];
	rep(i,26) cin >> c[i];
	// int s[365][26];
	vector<vector<int>> s(d, vector<int>(26));
	// int t[365];
	vector<int> t(d);
	set<int> last[26];
	rep(i,26) last[i].insert(-1);
	auto prevday = [&last, &t](int day,int contest) {
	  auto it = last[contest].lower_bound(day);
	  if (it == last[contest].end() || *it != day) return *prev(it);
	  else /*(*it == day)*/ return day;
	};

	rep(i,d) { 
	  int maxt = -1, maxcontest = -1;
	  rep(j,26) { 
		  cin >> s[i][j];
			if (chmax(maxt, s[i][j])) maxcontest = j;
		}
		t[i] = maxcontest;
	}

	rep(i,d) { cerr << t[i] << " ";} cerr << en;

	rep(i,d) { 
	  last[t[i]].insert(i);
	}

	//cerr << "t : ";
	//for(auto ti : t) cerr << ti << " " ; cerr << endl;
	//rep(i,26) { for(auto day : last[i])  cerr << day << " "; cerr << endl;}

	auto score = [&last, &c, &s, &t, prevday]() {
		ll ret = 0;
		rep(i, d) {
		  ret += s[i][t[i]];
			rep(j,26) ret -= (ll) c[j]*(i - prevday(i,j));
			//cout << ret << endl;
		}
		return ret;
	};

	ll ans = score();

	auto modify = [&](int day, int q) {
	  ll ans0 = 0;
	  ans0 -= s[day][t[day]];
		ans0 += c[t[day]]*(day - prevday(day,t[day]));
		last[t[day]].erase(day);
		last[q].insert(day);
		ans0 += s[day][q];
		ans0 -= c[q] * (day - prevday(day, q));

		if (ans0 >= 0) { ans += ans0;
		t[day] = q;
		}
		//cout << ans << endl;
	};

	int cnt = 0;
	while (cnt < 1) {
	  rep(i,d) rep(j,26) modify(i,j);
	  cnt++;
		//cout << ans << endl;
	}

	for(auto ti : t) cout << ti+1 << endl;
}


Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(ll i=0,i##_len=(n);i<i##_len;i++)
#define rep2(i,a,b) for(ll i=(a),i##_len=(b);i<=i##_len;i++)
#define rrep(i,n) ll i=(n);ll now=-1;while(i--&&(now++||1))
#define Yes(n) cout<<((n)?Yes:No)
#define vll vector<ll>
#define pb push_back
using namespace std;
using ll = long long;

static inline void ignore_ret(int x) {x++;}
template<class T> inline bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T> inline bool chmin(T&a,const T&b){if(a>b){a=b;return true;}return false;}
template<class T> inline T gcd_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=gcd(r,v.at(i));return r;}
template<class T> inline T lcm_vec(vector<T>v){T r=v.at(0);for(T i=1;i<v.size();i++)r=lcm(r,v.at(i));return r;}
template<class T> inline T factorial(T n){if(n==0)return 1;T r=1;for(T i=2;i<=n;i++)r*=i;return r;}
template<class T> inline T nCr(T n,T k){if(n<k||n<0||k<0)return 0;T r=1;k=min(k,n-k);for(T i=n-k+1;i<=n;i++)r*=i;return r/factorial(k);}
template<class T> inline T dot_product(vector<T>u,vector<T>v){T r=0;for(T i=0;i<u.size();i++)r+=u.at(i)*v.at(i);return r;}
template<class T> inline T sum(vector<T>v){return reduce(all(v),0LL);}

// Template ends here

void solve(ll N, vector<ll> H){
    ll cnt = 0, tmp = 0;
    rep(i, N - 1) {
        if (H.at(i) < H.at(i + 1)) {
            chmax(cnt, tmp);
            tmp = 0;
        }
        else tmp++;
    }
    chmax(cnt, tmp);
    cout << cnt << "\n";
}

int main() {
    ll N;
    ignore_ret(scanf("%lld",&N));
    vector<ll> H(N);
    for(int i = 0 ; i < N ; i++){
        ignore_ret(scanf("%lld",&H[i]));
    }
    solve(N, move(H));
    return 0;
}

Measured memory_bytes: 1024
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modPow(ll x,ll n,ll mod){if(n==0)return 1; if(n%2==0)return modPow(x*x,n/2,mod)%mod; return x%mod*modPow(x,n-1,mod)%mod;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll x; cin >> x;
    if(x == 1) cout << 0 << endl;
    else cout << 1 << endl;
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int cnt[100005];
int main(){
    int n, a;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d", &a);
        cnt[a]++;
    }
    vector<pii> v;
    for(int i=1;i<=100000;i++) if(cnt[i] > 1) v.emplace_back(pii(i, cnt[i]));
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i=0;i<v.size();i++){
        int cnt = v[i].second;
        if(cnt == 1) continue;
        cnt--;
        ans += cnt/2;
        cnt %= 2;
        if(cnt == 1){
            ans++;
            if(i+1 < v.size()) v[i+1].second--;
        }
    }
    printf("%d\n", n-ans*2);
}

Measured memory_bytes: 820
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.{Comparator, StringTokenizer}

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val Q = sc.nextInt()

    val N = 100000
    val p = Array.ofDim[Int](N + 1)
    val d = Array.ofDim[Int](N + 1)

    (2 to math.sqrt(N).toInt) foreach { i =>
      if (p(i) == 0) {
        (2 to N / i) foreach { j =>
          p(j * i) = 1
        }
      }
    }

    (3 to N).reverse foreach { i =>
      if (p(i) == 0 && p((i + 1) / 2) == 0) d(i) = 1
    }

    (0 until N) foreach { i =>
      d(i + 1) += d(i)
    }

    (0 until Q) foreach { _ =>
      val l, r = sc.nextInt()
      out.println(d(r) - d(l - 1))
    }
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 39252
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

int n, a, b, c;

vector<int> l;
vector<int> x;

int ans = 10000000;

void dfs(int i) {
    if (i == n) {
        int a_sum = 0, b_sum = 0, c_sum = 0;
        int a_cnt = 0, b_cnt = 0, c_cnt = 0;
        for (int j = 0; j < n; j++) {
            if (x[j] == 1) {
                a_sum += l[j];   
                a_cnt++;
            } else if (x[j] == 2) {
                b_sum += l[j];
                b_cnt++;
            } else if (x[j] == 3) {
                c_sum += l[j];
                c_cnt++;
            }
        }
        
        if (a_cnt == 0 || b_cnt == 0 || c_cnt == 0) {
            return;
        }
        
        int cost = ((a_cnt - 1) + (b_cnt - 1) + (c_cnt - 1)) * 10;
        
        cost += abs(a_sum - a);
        cost += abs(b_sum - b);
        cost += abs(c_sum - c);
        
        ans = min(ans, cost);
        
        return;
    }
    
    for (int j = 0; j < 4; j++) {
        x[i] = j;
        
        dfs(i + 1);
    }
}

int main()
{    
    cin >> n >> a >> b >> c;
    
    l.resize(n);
    
    for (int i = 0; i < n; i++) {
        cin >> l[i];   
    }
    
    x.resize(n);
    
    dfs(0);
    
    cout << ans << endl;
}


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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

string s,t = "Yes";
ll n,m,a,b,result;
char c;

int main () {
  cin >> n >> m;
  cout << (n-1)/m + 1 << endl;
}


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

int main()
{
    int a[5]={0},k,i,j,t=0;
    for(i=0;i<5;i++)
    {
        scanf("%d",&a[i]);
    }
    scanf("%d",&k);
    for(i=0;i<5;i++)
    {
        for(j=i+1;j<5;j++)
            if(a[j]-a[i]<k||a[j]-a[i]==k)
           {
               t=0;
           }
        else
           {
              t=1;
              break;
           }
           if(t==1)
              break;
    }
    if(t==0)
        printf("Yay!\n");
    else if(t==1)
        printf(":(\n");
    return 0;
}

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

int main(void)
{
    int k = 0;
    int a,b,i = 0;

    int judge = 1;

    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    for(i=a;i<=b;i++)
    {
        
        if((i % k) == 0){
            judge = 0;
            break;
        }else{
            judge = 1;
        }
        
    }

    if(judge == 0)
    {    
        printf("OK\n");

    }else{

        printf("NG\n");
    }
}

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

int main() {
  string S;
  cin >> S;
  set<char> U;
  for (int i = 0; i < S.size(); i++) U.insert(S.at(i));
  for (int i = 0; i <= 26; i++) {
    if (i == 26) cout << "None" << endl;
    else if (!(U.count('a' + i))) {
      cout << (char)('a' + i) << endl;
      break;
    }
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <tuple>
#include <complex>
#include <cassert>
#include <exception>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << "\n"
static const int INF = 1e+9+7;
static const ll INFL = 1e+18+7;
int n,m,l;
int p;
string s,t;
ll d[200010],dp[300][300];
char field[200][200];

int main(){
  cin >> n >> m;
  if(n > 0 && m > 0){
    puts("Positive");
  }else if(n < 0 && m < 0){
    n = abs(n);
    m = abs(m);
    if(n < m)swap(n,m);
    // cout << n << " " << m << endl;
    if((n - m) % 2 == 1 || n == m)puts("Positive");
    else puts("Negative");
  }else{
    print("Zero");
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void display()
{
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    puts(abs(a-c) <= d || abs(a-b) <= d && abs(b-c) <=d ? "Yes": "No");
}
int main(void)
{
    display();
}

Measured memory_bytes: 3540
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

A = list(range(1, n+1))

from itertools import permutations

li=[]
for i in permutations(A, n):
    li.extend([list(i)])
    
for i, v in enumerate(li):
    if li[i] == p:
        s = i
    if li[i] == q:
        t = i
print(abs(s-t))

Measured memory_bytes: 10228