akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int X,Y,Z,K;
long long A[1123];
long long B[1123];
long long C[1123];

set<array<long long,4>> memo;
set<array<int,3>> used;

void ins(int i,int j,int k){
  if(used.count(array<int,3>{i,j,k})==0){
	memo.insert(array<long long,4>{A[i]+B[j]+C[k],i,j,k});
	used.insert(array<int,3>{i,j,k});
  }
}

long long pop(){
  auto el = *(memo.rbegin());
  memo.erase(el);
  ins(el[1]+1,el[2],el[3]);
  ins(el[1],el[2]+1,el[3]);
  ins(el[1],el[2],el[3]+1);

  return el[0];
}

int main(){
  cin >> X;
  cin >> Y;
  cin >> Z;
  cin >> K;
  for(int i=0;i<X;i++){
	cin>>A[i];
  }
  for(int i=0;i<Y;i++){
	cin>>B[i];
  }
  for(int i=0;i<Z;i++){
	cin>>C[i];
  }

  sort(A,A+X);
  sort(B,B+Y);
  sort(C,C+Z);

  reverse(A,A+X);
  reverse(B,B+Y);
  reverse(C,C+Z);

  A[X]=B[Y]=C[Z]=-1e15;

  ins(0,0,0);

  for(int i=0;i<K;i++){
	cout << pop() << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
n,y = map(int,input().split())

for i in range (n+1):
  for j in range(n-i+1):
    if i*10000 + j*5000+(n-i-j)*1000 ==y:
      print(i,j,n-i-j)
      exit()

      
print("-1 -1 -1")



Measured memory_bytes: 2940
X,N = map(int,input().split())
p_li = set(map(int,input().split()))
p = set(range(-200,200))
kouho = p - p_li
ans = 10000
sa_min = 1000000
for i in sorted(list(kouho)):
    sa = abs(X-i)
    if sa_min > sa:
        ans = i
        sa_min = sa
print(ans)


Measured memory_bytes: 9168
#include<stdio.h>
int main(void)
{
	int h,s,n,k,i,flg;
	while(1){
		flg=0;
		scanf("%d",&n);
		if(n==0)break;
		s=n;
		for(i=0;i<n;i++){
			scanf("%d",&k);
//			printf("%d\n",k);
			if(k==0){
				s=s-1;
			}
			if(k>=2){
				flg=1;
			}
		}
		if(flg==1){
			printf("%d\n",s+1);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;


using namespace std;

typedef long long ll;
typedef unsigned long long llu;

int main() {
	FIO;
	ll n;
	cin>>n;
	ll total = (n*(n+1))/2;
	ll lst3 = (n/3)*3; ll lst5 = (n/5)*5; ll lst15 = (n/15)*15;
	ll tot3 = (lst3-3)/3 + 1;
	ll tot5 = (lst5-5)/5 + 1;
	ll tot15 = (lst15-15)/15+ 1;
	total = (total - (tot3*(3+lst3))/2 - (tot5*(5+lst5))/2 + (tot15*(15+lst15))/2);
	cout<<total;
	return 0;
}


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

vector<int> get_divisors(int n){
    vector<int> collect;
    for (int i=1; i<=sqrt(n); i++){
        if (n%i==0){
            collect.push_back(i);
            if (i!=n/i){
                collect.push_back(n/i);
            }
        }
    }
    return collect;
}

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

    int n;
    cin>>n;
    int a[n];
    map<int, int> m;
    for (int i=0; i<n; i++){
        cin>>a[i];
        m[a[i]]++;
    }
    int cnt = 0;
    for (int i=0; i<n; i++){
        vector<int> d = get_divisors(a[i]);
        m[a[i]]--;
        int ok = 1;
        for (int j=0; j<(int)d.size(); j++){
            if (m[d[j]]>0){
                ok = 0;
                break;
            }
        }
        if (ok) cnt++;
        m[a[i]]++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 33208
# ARC078C - Splitting Pile (ABC067C)
from itertools import accumulate


def main():
    n = int(input())
    lst = tuple(accumulate(map(int, input().rstrip().split())))
    total = lst[-1]
    ans = min(abs(total - i * 2) for i in lst[:-1])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26092
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll x; cin >> x;
    if(x < 1200){
        cout << "ABC" << endl;
    }else{
        cout << "ARC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//const int mod = 1000000007;
int main() {
    int n,x;
    cin >> n >> x;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    int total = 0;
    int ans = 1;
    rep(i, n) {
        total += l[i];
        if(total <= x) ans += 1;
        else break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
(defun sum (list)
  (reduce #'+ list :initial-value 0))

(defun take-first (list)
  (let ((result 0))
    (dolist (i list)
      (if (not (= 0 (mod i 10)))
          (progn (setf result i)
                 (return))))
    result))

(defun search-min (list)
  (let ((result (take-first list)))
    (dolist (i list)
      (if (and (< i result) (not (= 0 (mod i 10))))
          (setf result i)))
    (if (= 0 (mod result 10))
        (sum list)
        result)))

(defun main ()
  (let ((times (read))
        (list nil))
    (dotimes (i times)
      (setf list (cons (read) list)))
    (format t "~A~%"
            (if (= 0 (mod (sum list) 10))
                (- (sum list) (search-min list))
                (sum list)))))

(main)


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

int main(){

  int n;
  cin >> n;
  int arr[n];
  int count_odd = 0;
  int count_even = 0;

  for(int i=0; i<n; i++) {
    cin >> arr[i];
    arr[i] % 2 == 0 ? count_even++ : count_odd++;
  }

  if(count_odd % 2 == 0) 
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}



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

const long long MAXN = 1e5 + 5, MAXA = 1e6 + 6, SQRT = 447;
long long n, m, ans;
pair <long long, long long> Arr[MAXN];

bool cmp(pair <long long, long long> a, pair <long long, long long> b) {
    return a.second < b.second;
}

int main() {
    scanf("%lld%lld", &n, &m);
    for (long long i = 0; i < m; i++) {
        scanf("%lld%lld", &Arr[i].first, &Arr[i].second);
    }
    sort(Arr, Arr + m, cmp);
    long long e = -1;
    for (long long i = 0; i < m; i++)
        if (e <= Arr[i].first) {
            ans++;
            e = Arr[i].second;
        }
    printf("%lld", ans);
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(true){
            int h=sc.nextInt();
            int w=sc.nextInt();
            if(h==0&&w==0) break;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    System.out.print('#');
                }
                System.out.printf("\n");
            }
            System.out.printf("\n");
        }
        
    }
}


Measured memory_bytes: 39152
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);

//深さ優先探索
vector<bool> seen;
int num;
int ans[100010];
int C[100010];
void dfs(const Graph &G, int v){
    seen[v] = true; // v を訪問済みにする
	ans[v] = C[num];
	++num;

    // vから行ける各頂点 next_v について
    for(auto nv : G[v]){
        if (seen[nv]) continue; // next_v が探索済みだったらスルー
        dfs(G, nv); // 再帰的に探索
    } 
}
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	Graph G(N);
	rep(i,N-1){
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	rep(i,N){
		cin >> C[i];
	}
	sort(C, C+N);
	reverse(C, C+N);
	seen.assign(N, false); // 全頂点を「未訪問」にして初期化
	dfs(G, 0);
	int sum = 0;
	rep(i,N-1){
		sum += C[i+1];
	}
	cout << sum << endl;
	rep(i,N){
		cout << ans[i] << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 1536
#include <stdio.h>

int main(void){
  int i,j;
  int n;
  int numbers[1000000]={1,1};
  int temp=0;
  
  while(scanf("%d",&n)!=EOF){
      for(i=2;i<=n/2;i++){
          for(j=2;j<=n/i;j++){
              numbers[i*j]+=1;
          }
      }
      for(i=0;i<=n;i++){
          if(numbers[i]==0) temp+=1;
      }
      printf("%d\n",temp);
      temp=0;
  }
  
  return 0;
}





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

int main()
{
	int n,t;
	while(cin >> n, n)
	{
		int k[10] = {0};
		while(n--)
		{
			cin >> t;
			k[t]++;
		}

		for(int i=0; i<10; i++)
		{
			if(k[i])
			{
				for(int j=0; j<k[i]; j++)
				{
					cout << '*';
				}
				cout << endl;
			}
			else
			{
				cout << '-' << endl;
			}
		}
	}
}

Measured memory_bytes: 0
N = gets.to_i
neighbors = Array.new(N+1){Array.new}
(N-1).times do |i|
    a, b = gets.split.map(&:to_i)
    neighbors[a].push(b)
    neighbors[b].push(a)
end

prev = Array.new(N+1)
prev[1] = 0
updated = [1]
while updated.length > 0 do
    nup = []
    updated.each do |u|
        neighbors[u].each do |v|
            next if prev[v]
            prev[v] = u
            nup.push(v)
        end
    end
    updated = nup
end

route = [N]
loop do
    pr = prev[route[-1]]
    route.push(pr)
    break if pr == 1
end
route.reverse!
length = route.length
w_bound = route[(length+1)/2]

prev = Array.new(N+1)
prev[1] = 0
updated = [1]
while updated.length > 0 do
    nup = []
    updated.each do |u|
        neighbors[u].each do |v|
            next if prev[v]
            next if v == w_bound
            prev[v] = u
            nup.push(v)
        end
    end
    updated = nup
end

bn = prev.count{|a| a}
wn = N - bn

puts bn > wn ? 'Fennec' : 'Snuke'

Measured memory_bytes: 14332
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int ans = 0;
    rep(i, N - 1) {
        if (p[i] == i + 1) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    if (p[N - 1] == N) ans++;
    cout << ans << endl;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string N;
  IN(N);
  reverse(ALL(N));
  ll ans = 0;
  ll kuriagari = 0;
  REP(i,N.size()){
    ll tmp = N[i]-'0';
    if(tmp+kuriagari==5){
      bool flag = true;
      if(i<N.size()-1){
        if(N[i+1]-'0'>=5){
          ans += 10-(tmp+kuriagari);
          kuriagari = 1;
          flag = false;
        }
      }
      if(flag){
      ans += (tmp+kuriagari);
      kuriagari = 0;
      }
    }else if(tmp+kuriagari>5){
      ans += 10-(tmp+kuriagari);
      kuriagari = 1;
    }else{
      ans += tmp+kuriagari;
      kuriagari = 0;
    }
  }
  if(kuriagari>0) ans += kuriagari;

  OUT(ans);

  return 0;
}

Measured memory_bytes: 1948
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}

module Main where

import qualified Data.ByteString.Char8 as B8
import Data.Maybe (fromJust)
import Data.Char (toUpper,isDigit)
import Data.List
import qualified Data.Map as M
import Data.Array.IO
import Data.IORef
import Data.Ix (range)
import Control.Monad
import Control.Applicative
import Text.Printf
import Data.Time.Calendar
import Debug.Trace

readDigits = map read <$> words <$> getLine :: IO [Int]
readDigits' = map read <$> lines <$> getContents :: IO [Int]

--
main :: IO ()
main = do
    [a,b,c] <- readDigits
    putStrLn . show . length . filter id . map (fn c) $ [a..b]
    where
    fn c x = (c `mod` x == 0)                                                  

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1e9

typedef long long ll;

int dp[41][401][401];
int pos[41][401][401];
int n, m_a, m_b;
int a[41], b[41], c[41];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m_a >> m_b;
    for(int i = 1; i <= n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    pos[0][0][0] = 1;
    dp[0][0][0] = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= 400; j++){
            for(int k = 0; k <= 400; k++){
                dp[i][j][k] = INF;
                if(pos[i-1][j][k]){
                    pos[i][j][k] = 1;
                    dp[i][j][k] = dp[i-1][j][k];
                }
                if(j - a[i] >= 0 && k - b[i] >= 0){
                    if(pos[i-1][j-a[i]][k-b[i]]){
                        pos[i][j][k] = 1;
                        dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-a[i]][k-b[i]] + c[i]);
                    }
                }
            }
        }
    }
    int ans = INF;
    int i = 1;
    while(i*m_a <= 400 && i*m_b <= 400){
        ans = min(ans, dp[n][i*m_a][i*m_b]);
        i++;
    }
    if(ans >= INF){
        cout << -1;
    }
    else{
        cout << ans;
    }
}


Measured memory_bytes: 49792
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function unionFind(n){this.a=Array(n+1).fill(-1);this.w=Array(n+1).fill(0);}
unionFind.prototype={
  root:function(i){if(this.a[i]<0)return i;var r=this.root(this.a[i]);this.w[i]+=this.w[this.a[i]];return this.a[i]=r;},
  same:function(x,y){return this.root(x)===this.root(y);},
  unite:function(x,y,w){w+=this.weight(x);w-=this.weight(y);x=this.root(x);y=this.root(y);if(x===y)return false;if(this.a[x]>this.a[y]){this.a[y]+=this.a[x];this.a[x]=y;return this.w[x]=-w;}this.a[x]+=this.a[y];this.a[y]=x;return this.w[y]=w;},
  size:function(i){return -this.a[this.root(i)];},
  weight:function(i){this.root(i);return this.w[i];},
  diff:function(x,y){return this.weight(x)-this.weight(y);},
}

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var uf = new unionFind(n);
  for(var i = 0; i < m; i++){
    var t = o.l();
    if(uf.unite(t[0],t[1],t[2]) === false){
      if(uf.diff(t[1],t[0]) !== t[2])return "No";
    }
  }
  return "Yes";
}

Measured memory_bytes: 56532
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}

int main() {
  ll X;
  cin >> X;

  ll ansfact = 1;

  for (ll i = 2; pow(i, 5) <= X; i++) {
    if (X % (ll)(pow(i, 5)) == 0) {
      ansfact *= i;
      X /= pow(i, 5);
    }
  }

  ll ansA = 1;
  ll ansB = 0;
  while (true) {
    ll Bcand = 0;
    if (pow(ansA, 5) - X >= 0)
      Bcand = pow(pow(ansA, 5) - X, 0.2);
    else
      Bcand = -1 * pow(X - pow(ansA, 5), 0.2);
    // if ()
    if (pow(ansA, 5) - pow(Bcand, 5) == X) {
      ansB = Bcand;
      // debug(ansB);
      break;
    }
    //  else if (ansA > 4)
    //   break;
    ansA++;
    // cout << ansA << endl;
  }

  ansA *= ansfact;
  ansB *= ansfact;
  cout << ansA << " " << ansB << endl;
  return 0;
}

Measured memory_bytes: 4104
#include<stdio.h>

int main()
{
	char s1[100][201],s2[100][201],a1[201],a2[201];
	int c,count,i,t,str,count_s1,count_s2;
	int br=0,judge=0,j,k;
	
	while(1)
	{
		j=0;
		k=0;
		count=0;
		count_s1=0;
		count_s2=0;
		
		while((c=getchar())!='\n')
		{
			if(c=='.')
			{
				br=1;
				break;
			}
			if(c=='"')
			{
				judge=1-judge;
				if(judge)
				{
					count_s1++;
					str=0;
				}
				else s1[count_s1-1][str]='\0';
			}
			if(judge)
			{
				s1[count_s1-1][str]=c;
				str++;
			}
			else
			{
				a1[j]=c;
				j++;
			}
		}
		a1[j]='\0';
		if(br) break;
		
		while((c=getchar())!='\n')
		{
			if(c=='"')
			{
				judge=1-judge;
				if(judge)
				{
					count_s2++;
					str=0;
				}
				else s2[count_s2-1][str]='\0';
			}
			if(judge)
			{
				s2[count_s2-1][str]=c;
				str++;
			}
			else
			{
				a2[k]=c;
				k++;
			}
		}
		a2[k]='\0';
		for(int i=0;;i++)
		{
			if(a1[i]=='\0' && a2[i]=='\0') break;
			if(a1[i]!=a2[i])
			{
				count=2;
				break;
			}
		}
		if(count_s1==count_s2 && count==0)
		{
			for(int i=0;i<count_s1;i++)
			{
				//printf("%s\n",s1[i]);
				//printf("%s\n\n",s2[i]);
				for(int t=0;;t++)
				{
					if(s1[i][t]=='\0'&&s2[i][t]=='\0') break;
					if(s1[i][t]!=s2[i][t])
					{
						count++;
						break;
					}
					
				}
			}
		}
		else count=2;
		if(count==0) printf("IDENTICAL\n");
		else if(count==1) printf("CLOSE\n");
		else printf("DIFFERENT\n");
	}
	return 0;
}


Measured memory_bytes: 2540
L, R = map(int, input().split())
x, y = L % 2019, R % 2019
if (R-L) > 2017 or x>=y:
    print(0)
else:
    m = 2019
    for i in range(x, y + 1):
        for j in range(i + 1, y + 1):
           x = (i * j) % 2019
           m = min(m, x)
    print(m)

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

using namespace std;
typedef long long ll;

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    for (int i = k; i > 0; i--) {
        if (a >= b) {
            b *= 2;
            continue;
        }
        if (b >= c) {
            c *= 2;
            continue;
        }
        break;
    }
    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cstdlib>

int numOfIndices(int i, int rows)
{
	if (i <= rows/2) return i+1;
	else return rows - i;
}

int max(int x, int y)
{
	return x>y ? x : y;
}

int main()
{
	int board[100][50];
	
	
	int rows = 0;
	// read the board
	bool first_row = false;
	bool last_row = false;
	while (!last_row) {
		std::string buf;
		std::cin >> buf;
		if (buf == "\n") break;
		
		int offset = 0;
		int index = 0;
		while(true) {
			int pos = buf.find(',', offset);
			if ( pos == std::string::npos ) {
				std::string str_num = buf.substr(offset);
				board[rows][index] = std::atoi(str_num.c_str());
				break;
			}
			else {
				std::string str_num = buf.substr(offset, pos - offset);
				board[rows][index] = std::atoi(str_num.c_str());
				offset = pos + 1;
				index++;
			}
		}
		if (index == 0) {
			if (!first_row) {
				first_row = true;
			} else if (!last_row) {
				last_row = true;
			}
		}
		rows++;
	}
	
	// DP
	int DP[100][50];
	for (int i=0; i<100; i++) {
		for (int j=0; j<50; j++) DP[i][j] = -1;
	}
	
	DP[0][0] = board[0][0];
	for (int i=1; i<rows; i++) {
		for (int j=0; j<numOfIndices(i,rows); j++) {
			if (i<=rows/2) {
				if (i>0) DP[i][j] = max(DP[i-1][j-1], DP[i-1][j]) + board[i][j];
				else DP[i][j] = DP[i-1][j] + board[i][j];
			}
			else {
				DP[i][j] = max(DP[i-1][j], DP[i-1][j+1]) + board[i][j];
			}
		}
	}
	
	//std::cout << std::endl;
	//for (int i=0; i<rows; i++) {
	//	for (int j=0; j<numOfIndices(i,rows); j++) {
	//		std::cout << DP[i][j] << " ";
	//	}
	//	std::cout << std::endl;
	//}
	
	std::cout << DP[rows-1][0] << std::endl;
	
	return 0;
}



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

using namespace std;

int main(){
    int n;
    cin >> n;
    
    vector<int> d;
    ll sum = 0;
    rep(i, n) {
        int x;
        cin >> x;
        
        for(int j = 0; j < i; j++) {
            sum += d[j] * x;
        }
        
        d.push_back(x);
    }
    
    
    cout << sum;
    
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int n;
ll arr[100100];

int main() {
    int i;

    scanf("%d",&n);
    for (i=0;i<n;i++) scanf("%lld",&arr[i]);
    sort(arr,arr+n);
    ll mini = min(arr[n/2]-arr[n/2-1], arr[(n+1)/2]-arr[(n+1)/2-1]);
    ll sum = 0;
    for (i=0;i+1<n;i++) sum += (arr[i+1]-arr[i])*2*min(i+1,n-i-1);
    printf("%lld\n",sum-mini);

    return 0;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

"""
(1+x+...+x^a) をたくさんかける
(1-x^{a+1}) をかけて、(1-x)^{-1}をかける
"""

import numpy as np
MOD = 10 ** 9 + 7
N,K = map(int,input().split())
dp = np.zeros(K+1, dtype=np.int64)
dp[0] = 1

for a in map(int,input().split()):
    # numpyのバージョン違いにより
    prev = dp.copy()
    dp[a+1:] -= prev[:-(a+1)]
    np.cumsum(dp, out=dp)
    dp %= MOD

answer = dp[K]
print(answer)

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

int dp[5005][5005];

int main() {
  int n;
  string s;
  cin >> n >> s;
  for(int i=n-1; i>=0; --i){
    for(int j=n-1; j>=0; --j){
      if(s[i] != s[j]) dp[i][j] = 0;
      else dp[i][j] = dp[i+1][j+1] + 1;
    }
  }
  int ans = 0;
  rep(i, n) rep(j, n){
    if(i>=j) continue;
    int now =  min(dp[i][j], j-i);
    ans = max(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 101304
#include <cstdio>
#include <map>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const int MX = 1300500;
const int SZ = 3500;

#define pii pair<int,int>
long long res[MX];


int main(int argc, char** argv)
{
//    freopen("/Users/melnykroman/CLionProjects/cf/in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> masks;
    int t = 0;
    int can_add = 1;
    for(int i = 0; i < 32; i++){
        if(can_add) {
            masks.push_back((k << i) + t);
        }
        can_add = k & 1;
        k >>= 1;
        if(i) t = (1 << i) - 1;
    }

    while(n--){
        int a, b;
        cin >> a >> b;
        for(int i = 0; i < masks.size(); i++){
            if((masks[i] & a) == a) res[i] += b;
        }
    }
    for(int i = 0; i < masks.size(); i++){
        if(res[i] > res[0]) res[0] = res[i];
    }
    cout << res[0] << endl;
    return 0;
}

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

using namespace std;

int main(){
	int N;
	cin >> N;
	
	vector<double> x(N);
	vector<string> u(N);
	
	for(int i = 0; i < N; i++){
		cin >> x.at(i) >> u.at(i);
	}
	
	double ans = 0;
	
	for(int i = 0; i < N; i++){
		if(u.at(i) == "JPY"){
			ans += x.at(i);
		}else{
			ans += 380000.0 * x.at(i);
		}
	}
	
	cout << ans << endl;
	
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 200005

int n;
ii a[MAXN];
vi low,high;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n){
		cin>>a[i].F>>a[i].S;
		low.pb(a[i].F);
		high.pb(a[i].S);
	}
	sort(low.begin(),low.end());
	sort(high.begin(),high.end());
	
	if(n%2==1){
		cout<<high[n/2]-low[n/2]+1<<'\n';
	}
	else cout<<high[n/2]+high[n/2-1]-low[n/2]-low[n/2-1]+1<<'\n';
	
	return 0;
}


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

const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> H(N);
    for (int i=0; i<N; ++i) cin >> H[i];
    
    vector<vector<int>> to(N);
    for (int i=0; i<M; ++i) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        to[A].push_back(B);
        to[B].push_back(A);
    }
    
    int cnt = 0;
    for (int i=0; i<N; ++i) {
        bool good = true;
        for (int v: to[i]) {
            if (H[i] <= H[v]) {
                good = false;
                break;
            }
        }
        if (good) cnt ++;
    }
    cout << cnt << endl;

    return 0;
}

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

const int MAXN = 3e2 + 3;
double dp[MAXN][MAXN][MAXN];
int cnt[3];
int n;

void input();
void solve();

int main(){
	ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0);
	input();
	solve();
	return 0;
}

void input() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (a == 1)
			cnt[0]++;
		else if (a == 2)
			cnt[1]++;
		else
			cnt[2]++;
	}
}

void solve() {
	for (int i = 0; i <= 300; i++)
		for (int j = 0; i + j <= 300; j++)
			for (int k = 0; i + j + k <= 300; k++) {
				if (i)
					dp[i][j][k] = 1ll * i * dp[i - 1][j + 1][k];
				if (j)
					dp[i][j][k] += 1ll * j * dp[i][j - 1][k + 1];
				if (k)
					dp[i][j][k] += 1ll * k * dp[i][j][k - 1];
				if (i + j + k) {
					dp[i][j][k] += n;
					dp[i][j][k] /= i + j + k;
				}
			}
	cout.precision(10);
	cout << fixed << dp[cnt[2]][cnt[1]][cnt[0]] << endl;
}


Measured memory_bytes: 111888
#include "bits/stdc++.h"

using namespace std;
#define FOR(i,s,t) for (int i = s; i < t; i++)
#define SZ(x) (int)x.size()
using LL = long long; using ll = LL;
using VI = vector<int>; using VL = vector<LL>;
const LL INF = 1e9; const LL LINF = 1e18;
#define debug(x) cout<<#x<<":="<<x<<endl
typedef pair<ll, ll> pll;

struct FF {
#define MS  1005
	struct edge {
		int to, cap, rev;
		edge() {}
		edge(int to, int cap, int rev) :to(to), cap(cap), rev(rev) {}
	};
	vector<edge>G[MS];
	bool used[MS];

	void add_edge(int from, int to, int cap) {
		G[from].emplace_back(edge(to, cap, (int)G[to].size()));
		G[to].emplace_back(edge(from, cap, (int)G[from].size()-1));
	}
	int dfs(int v, int t, int f) {
		if (v == t)return f;
		used[v] = 1;
		FOR(i, 0, SZ(G[v])) {
			edge &e = G[v][i];
			if (!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	int max_flow(int s, int t) {
		const int inf = INT_MAX;
		int flow = 0;
		for (;;) {
			memset(used, 0, sizeof(used));
			int f = dfs(s, t, inf);
			if (f == 0)return flow;
			flow += f;
		}
		return -1;
	}
#undef MS
};

int main() {

	int N, M; int s, t;
	// 1-index
	cin >> N >> M;
	vector<VI> G(N);
	map<pll, int>Map;
	FF F;
	vector<pll>inedge(M);
	FOR(i, 0, M) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		
		inedge[i] = pll(x, y);
		F.add_edge(x, y, 1);
		G[x].push_back(y);
		Map[pll(x, y)] = i+1;
	}
	cin >> s >> t;
	s--, t--;
	cout << F.max_flow(s, t) << endl;
	set<int> ans;
	FOR(i, 0, M) {
		int x, y; tie(x, y) = inedge[i];
		FOR(j, 0, SZ(F.G[x])) {
			int nv = F.G[x][j].to;
			if (nv == y) { // 本来の有向辺
				if (F.G[x][j].cap==2) {
					ans.insert(i);
				}
			}
		}
	}

	cout << SZ(ans) << endl;
	for (auto it : ans) {
		cout << it+1 << endl;
	}

	return 0;
}



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

int main() {
	
	char S[100];
	char T[100];
	int SN;
	int TN;

	scanf("%s %s", S, T);
	SN = strlen(S);
	TN = strlen(T);
	
	for (int i = 0; i < TN; i++) {
		putchar(T[i]);
	}

	for (int i = 0; i < SN; i++) {
		putchar(S[i]);
	}

	putchar('\n');

	return 0;
}



Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

MOD = 998244353

N = int(readline())
m = map(int,read().split())
Y = [y for x,y in sorted(zip(m,m))] # Y座標昇順

# 座圧
Y_rank = {y:i for i,y in enumerate(sorted(Y),1)}
Y = [Y_rank[y] for y in Y]

class BIT():
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        
    def get_sum(self,i):
        s = 0
        while i:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i < self.size:
            self.tree[i] += x
            i += i & -i

LD = [0] * N
bit = BIT(N)
for i,y in enumerate(Y):
    LD[i] = bit.get_sum(y)
    bit.add(y,1)

def cumprod(arr,MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr,Lsq**2).reshape(Lsq,Lsq)
    for n in range(1,Lsq):
        arr[:,n] *= arr[:,n-1]; arr[:,n] %= MOD
    for n in range(1,Lsq):
        arr[n] *= arr[n-1,-1]; arr[n] %= MOD
    return arr.ravel()[:L]

x = np.full(N+10,2,np.int64); x[0] = 1
pow2 = cumprod(x,MOD)

LD = np.array(LD,dtype=np.int32)
D = np.array(Y)-1
L = np.arange(N)
R = N-1-L
U = N-1-D
LU = L-LD
RU = U-LU
RD = D-LD

x = pow2[N] - 1 + pow2[LD] + pow2[RD] + pow2[RU] + pow2[LU]
x -= pow2[U] + pow2[D] + pow2[R] + pow2[L]

answer = x.sum() % MOD
print(answer)

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

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    string s; cin>>s;
    int n = s.size();
    loop(n) cout<<"x";
    cout<<"\n";

    return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mem(ara,x) memset((ara),x,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define bb begin()
#define ee end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);
#define eps 1e-9



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];
int ara[2*n_size],ara2[2*n_size];


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

	int n,m,T,res;

	int maxi=-mx,mini=mx,count=0,sum2;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];



	cin>>n;
	f(i,1,n) cin>>ara[i];

	f(i,1,n){
        ara[i]=ara[i]-i;
	}

    sort(ara+1,ara+n+1);



    int b=ara[(n/2)+1];

    ll int sum=0;

    for(i=1;i<=n;i++) {
        sum+=abs(ara[i]-b);
    }

	cout<<sum<<endl;

}


Measured memory_bytes: 4372
import java.util.*;
 class Main{

     public static void main(String []args){
        
        Scanner scan = new Scanner(System.in) ;
        
        int x = scan.nextInt();
        int y = scan.nextInt();
        int n =scan.nextInt();
        ArrayList<Integer> s = new ArrayList<>() ;
        for(int i = x ; i<x+n ; i++){
          if(!s.contains(i) && (i>=x && i<=y) ){
            s.add(i);   
          }
        }
        for(int i = y-n+1 ; i<=y ; i++){
          if(!s.contains(i) && (i>=x && i<=y)){
            s.add(i); 
          }
        }
       for(Integer k : s){
        System.out.println(k) ; 
       }
        
        
     }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;
/*
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    std::map<int, int> mp;
    std::vector<int> a(3);
    for(int i = 0; i <=2; i++) {
        cin>>a[i];
        mp[a[i]]++;
    }
    for(int i = 0; i <=2; i++) {
        if(mp[a[i]] == 2){
            cout<<"Yes\n";
            return 0;
        }
    }

        cout<<"No\n";
    return 0;
}
*/

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    std::vector<int> v(n);
    for (size_t i = 0; i < n; i++) {
        cin>>v[i];

    }
    for (size_t i = 0; i < n; i++) {
        if(v[i] % 2 == 0 ){
            if(v[i] % 3 != 0 && v[i] % 5 != 0 ){
                  cout<<"DENIED\n";
                  return 0;
            }
        }

    }
    cout<<"APPROVED\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
#include<cassert>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long long dp[310][310][310];
vector<pair<int,int> >g[310];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int s,t,u;
		scanf("%d%d%d",&s,&t,&u);
		g[t].push_back(make_pair(s,u));
	}
	dp[0][0][0]=1;
	long long ret=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<=j;k++){
				if(!dp[i][j][k])continue;
				bool ok=true;
				for(int l=0;l<g[i].size();l++){
					int col=1;
					if(g[i][l].first<=j)col++;
					if(g[i][l].first<=k)col++;
					if(col!=g[i][l].second)ok=false;
				}
				if(!ok)continue;
		//		printf("%d %d %d: %lld\n",i,j,k,dp[i][j][k]);
				if(i==a){
					ret=(ret+dp[i][j][k])%mod;continue;
				}
				dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
				dp[i+1][i][k]=(dp[i+1][i][k]+dp[i][j][k])%mod;
				dp[i+1][i][j]=(dp[i+1][i][j]+dp[i][j][k])%mod;
			}
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 225536
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        var hs = new HashSet<int>(ReadInts());
        Console.WriteLine(hs.Count);
    }
}

Measured memory_bytes: 3416
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>



	int main() {
		int a, b, c, d;
		int YN = 0;

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

		if (abs(c - a) <= d){
			YN = 1;
		}
		else if ((abs(c - b) <= d) && (abs(b - a) <= d)) {
			YN = 1;
		}

		if (YN == 1) {
			printf("Yes\n");
		}
		else if (YN == 0) {
			printf("No\n");
		}




		return 0;
	}



Measured memory_bytes: 128
#include <cstdio>

char s[555][555];
int n,m;

#define empty for(int j=1;j<=m;++j)putchar('.');putchar('\n')

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",s[i]+1);
	empty;
	for(int i=2;i<n;++i,putchar('\n'))
	for(int j=1;j<=m;++j)
		putchar((!(i&1)&&s[i][j]!='#'&&j!=m)||j==1?'.':'#');
	empty;putchar('\n');empty;
	for(int i=2;i<n;++i,putchar('\n'))
	for(int j=1;j<=m;++j)
		putchar(((i&1)&&s[i][j]!='#'&&j!=1)||j==m?'.':'#');
	empty;
	return 0;
}

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

using namespace std;
typedef long long LL;
LL a[100005];
int main()
{
    LL n,k,sx,ex,sum=0x3f3f3f3f;
    cin >> n>>k;
    for(LL i = 0;i < n;i++)
        cin >> a[i];
    for(LL i = 0;i <= n-k;i++)
    {
        sx = a[i];
        ex = a[i+k-1];
        if(sx*ex>0)
        {
            sum = min(sum,max(abs(sx),abs(ex)));
        }
        else
            sum = min(sum,ex-sx+min(abs(sx),abs(ex)));
    }
    cout << sum <<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
    int i=0,y[200];
    char x[200];
    while((scanf("%s",x)) != EOF){
        if(*x=='+'){
            y[i-2]=y[i-2]+y[i-1];
            i--;
        }
        else if(*x=='-'){
            y[i-2]=y[i-2]-y[i-1];
            i--;
        }
        else if(*x=='*'){
            y[i-2]=y[i-2]*y[i-1];
            i--;

        }
        else{
            y[i]=atoi(x);
            i++;
        }
    }
    printf("%d\n",y[0]);
    return 0;
}

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

bool solve() {
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; ++i) {
        if(i % k == 0) return true;
    }
    return false;
}

int main() {
    cout << (solve() ? "OK" : "NG") << '\n';
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <stack>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <cassert>

using namespace std;

typedef long long ll;
typedef ll li;
typedef pair<ll,ll> PI;
#define EPS (1e-10L)
#define rep(i,n) for(ll i=0;i<(int)(n);++i)
#define REP(i,m,n) for(ll i=m; i<=(int)(n); ++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(),a.end()
#define FOR(it,a) for(__typeof(a.begin())it=a.begin();it!=a.end();++it)
ll dx[]={0,1,0,-1,1,1,-1,-1};
ll dy[]={1,0,-1,0,-1,1,1,-1};


vector<int> in;
 
vector<int> G[1000];
int pos=0;
int path[1000];
int ed[1000];
int newn;
 
void dfs(int cv,int depth){
  //cout << cv << ' ' << depth << endl;

  path[depth] = cv;
  ed[cv] = in[pos++];
  bool ok = false;
  if(SZ(G[cv]) == ed[cv]) return;
  while(pos < SZ(in)){
    int t=in[pos];
    //cout << t << endl;
    if(t<0){
      assert(depth+t>=0);
      int nv=path[depth+t];
      G[cv].pb(nv);
      G[nv].pb(cv);
      ++pos;
    }else{
      ++newn;
      G[cv].pb(newn);
      G[newn].pb(cv);
      dfs(newn,depth+1);
      assert(SZ(G[newn]) == ed[newn]);
    }
    if(SZ(G[cv]) == ed[cv]){
      ok = true;
      break;
    }
  }
  assert(ok);
}

vector<int> killedge(vector<int> in){
  rep(i,SZ(in))
    if(in[i]<0){
      --in[i+in[i]];
      --in[i-1];
      in.erase(in.begin()+i);
      break;
    }
  return in;
}
 
void solve(){
  in.clear();
  int t;
  while(cin >> t, t)
    in.pb(t);
  
  while(true){
      int no=0;
      int degsum = 0;
      newn = 0;
      FOR(it,in){
        int t=*it;
        no += t>0;
        degsum += (t>0) * t;
      }

      rep(i,no) G[i].clear();
      pos = 0;
      try{
        dfs(0,0);
      }catch(...){
        in = killedge(in);
        continue;
      }
      rep(i,no) sort(ALL(G[i]));

      rep(i,no){
        cout << i+1;
        FOR(it,G[i]) cout << ' ' << *it+1;
        cout << endl;
      }
      break;
  }
}
 
int main(){
  int n;
  cin >> n;
  rep(i, n) solve();
}

Measured memory_bytes: 1272
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
using namespace std;
int main(void) {
	int N, A, B;
	cin >> N>>A>>B;
	int res = A*N >B?B : A*N;
	cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main() {
int ans=0;
int n;
cin>>n;
int arr[2*n];
n*=2;
rep(i,0,n)
cin>>arr[i];
sort(arr,arr+n);
for(int i=0;i<n;i+=2)
ans+=arr[i];
cout<<ans;
}


Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			n--;
			n %= 39;
			System.out.printf("3C%02d\n", n % 39 + 1);
		}
	}

}

Measured memory_bytes: 17188
#!/usr/bin/env python
# coding: utf-8
#


def main(a, b):
    retval = a * b - a * 1 - b * 1 +  1 * 1
    print(retval)
    
if __name__ == '__main__':
    try:
        a, b = list(map(int,input().strip().split(" ")))
        main(a, b)
    except EOFError:
        pass


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    int cnt[MAX];
    int ans[MAX];
    memset(cnt, 0, sizeof(cnt));
    rep(i, N){
        int a; cin >> a;
        cnt[a]++;
    }
    int kind = 0;
    int kind2 = 0;
    rep(i, MAX){
        if(cnt[i] > 0) {
            kind++;
            if((cnt[i]-1) % 2 == 0){

            }
            else{
                kind2++;
            }
        }
    }

    // print(kind, kind2);
    if(kind2 % 2 != 0){
        print(kind-1);
    }else{
        print(kind);
    }
    
    
    return 0;
}


Measured memory_bytes: 640