akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
template<class T> T count_bit(T p){
  if(typeid(p)==typeid(int))return __builtin_popcount(p);
  else if(typeid(p)==typeid(long))return __builtin_popcountl(p);
  else return __builtin_popcountll(p);
}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  long N;
  in(N);
  vector<long>A(N);
  ins(A);
  vector<long>X(N);
  rep(i,N){
    if(i%2) X[0]-=A[i];
    else X[0]+=A[i];
  }
  up(i,1,N-1)X[i]=2*A[i-1]-X[i-1];
  cout<<X[0];
  up(i,1,N-1){
    if(i%2==0)cout<<" "<<X[i];
    else cout<<" "<<X[i];
  }
  cout<<endl;

}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define mod 998244353

using namespace std;

llint n;
vector<llint> G[3][100005];
llint base, beki[300005];
llint grundy[3][100005];
llint a[3][1<<9];


llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

void get(vector<llint> G[], llint grundy[])
{
	for(int i = n; i >= 1; i--){
		set<llint> S;
		for(int j = 0; j < G[i].size(); j++){
			S.insert(grundy[G[i][j]]);
		}
		while(S.count(grundy[i])) grundy[i]++;
	}
}


int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint m;
	for(int i = 0; i < 3; i++){
		cin >> m;
		llint u, v;
		for(int j = 0; j < m; j++){
			cin >> u >> v;
			if(u > v) swap(u, v);
			G[i][u].push_back(v);
		}
	}
	
	base = modpow(10, 18);
	beki[0] = 1;
	for(int i = 1; i < 300005; i++) beki[i] = beki[i-1] * base % mod;
	
	for(int i = 0; i < 3; i++){
		get(G[i], grundy[i]);
		for(int j = 1; j <= n; j++){
			a[i][grundy[i][j]] += beki[j];
			a[i][grundy[i][j]] %= mod;
		}
	}
	
	llint N = 1<<9, ans = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			ans += a[0][i] * a[1][j] % mod * a[2][i^j] % mod;
			ans %= mod;
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 17920
x = list(map(int, input().split()))
a = x[0]
b = x[1]
c = x[2]
k = x[3]
count = 0
ka = k-a
if ka >= 0:
  count += a*1
else:
  count += k*1
if ka > 0:
  kb = ka-b
  kc = kb-c
  if kb > 0:
    count += kb*-1
print(count)

Measured memory_bytes: 9196
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  p, q, r = map(int, readline().split())
  print(p+q+r-max(p,q,r))
  
  
  
  
if __name__ == '__main__':
  main()

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

int main(){
  int n,k;
  std::vector<long long> v;
  cin >> n >> k;
  long long mini = 100000000000000;
  for(int i = 0 ; i < n ; i++){
    long long  h;
    cin >> h;
    v.push_back(h);
  }
  sort(v.begin(), v.end());
  int st = 0;
  int fi = k-1;
  for(st = 0 ; st+k-1 < n ; st++){
    if(mini > (v[fi]-v[st])) mini = v[fi] - v[st];
    fi++;
  }
  cout << mini << endl;
}


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

int main() {
  int N,M;
  cin>>N>>M;
  int Z=0;
  vector<int> p(N);
for (int i = 0; i < N; i++) {
  cin >> p.at(i);
  Z+=p.at(i);
}
  sort(p.begin(), p.end());
reverse(p.begin(), p.end());
  int m=4*M;
  if(p.at(M-1)>(Z-1)/m){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

const int MAX_N = 1000;
lint a[MAX_N+5];
vector<lint> sum;

int main(){
    int n, k; cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a[i+1];
        a[i+1] += a[i];
    }

    for(int i=1;i<=n;i++)
        for(int j=i;j<=n;j++) sum.push_back(a[j]-a[i-1]);

    lint ans = 0;
    for(int i=40;0<=i;i--){
        int cnt = 0; ans += 1LL << i;
        for(int j=0;j<sum.size();j++)
            if((ans & sum[j]) == ans) cnt++;

        if(cnt<k) ans -= 1LL << i;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};



int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int count = 0;
    const string t = "ATGC";
    int n = s.length();
    for (int i=0; i<n; ++i){
        bool check = false;
        for (int j=0; j<4; ++j){
            if(s[i] == t[j]){
                count++;
                check = true;
                break;
            }
        }
        if(!check){
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> tenbou(n);
    for (ll i = 0; i < n; i++) {
        ll h;
        cin >> h;
        tenbou[i] = h;
    }

    bool isTakai[n];
    for (ll i = 0; i < n; i++) {
        isTakai[i] = true;
    }
    for (ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        --a;
        --b;
        if (tenbou[a] > tenbou[b]) {
            isTakai[b] = false;
        }
        if (tenbou[a] == tenbou[b]) {
            isTakai[a] = false;
            isTakai[b] = false;
        }
        if (tenbou[a] < tenbou[b]) {
            isTakai[a] = false;
        }
    }

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        if (isTakai[i]) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3976
#include<iostream>

using namespace std;

long a[2'000'000];

long h = 0;
long INF = 999'999'999;

void maxHeapify(long i) {

	long l, r, max, sw;
	l = 2 * i;
	r = 2 * i + 1;

	if (l <= h and a[l] > a[i]) {
		max = l;
	}
	else {
		max = i;
	}

	if (r <= h and a[r] > a[max])
		max = r;

	if (max != i) {
		sw = a[i];
		a[i] = a[max];
		a[max] = sw;

		maxHeapify(max);
	}
}

void insertHeap(long i, long k) {


	long sw;
	if (k < a[i]) {
		return;
	}

	a[i] = k;

	while (i > 1 && a[i / 2] < a[i]) {
		sw = a[i];
		a[i] = a[i / 2];
		a[i / 2] = sw;

		i = i / 2;
	}
}

long extractHeap() {
	if (h < 1) {
		return -1;
	}

	long max = a[1];
	a[1] = a[h];
	h--;
	maxHeapify(1);

	return max;
}

int main() {


	long  key;
	key = 0;
	char inp[10];

	while (true)
	{
		scanf( "%s", inp);

		if (inp[0] == 'e' && inp[1] == 'n') break;

		if (inp[0] == 'i') {
			h++;
			a[h] = INF * -1;

			scanf( "%d", &key);

			insertHeap(h, key);

		}
		else {

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

	}


	return 0;
}




Measured memory_bytes: 11048
// Aizu 2242: Era Name
// 2017.9.23 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define MAX 1001
typedef struct { char nm[17]; int e, w; } ERA;	// ??´???, ??????????????´????????????????\????????????´
ERA era[MAX]; int n;	// ??´?????????????????????????????????
 
int cmp(ERA *a, ERA *b) { return a->w - b->w; }

// ?????????????????????
int bsch(int x)
{
	int m, l = 0, r = n;

    while (l < r) {
        m = (l + r) >> 1;
        if (era[m].w < x) l = m + 1; else r = m;
    }
	return l;
}

int main()
{
	int q, i, y;

	while (scanf("%d%d", &n, &q) && n > 0) {
		// ?????±?????????????????¨??´????????????????????????
		for (i = 0; i < n; i++) scanf("%s%d%d", era[i].nm, &era[i].e, &era[i].w);
		qsort(era, n, sizeof(ERA), cmp);

		while (q-- > 0) {
			scanf("%d", &y);
			i = bsch(y);		// ?????????????????????
			if (i >= 0 && i < n && era[i].w-era[i].e+1 <= y && y <= era[i].w)
				printf("%s %d\n", era[i].nm, y-era[i].w+era[i].e);
			else puts("Unknown");
		}
	}
	return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] num = Input.ScanIntArray();
          Console.WriteLine(Math.Min(num[0]*num[1],num[2]));
            
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int k[11];
int s[11][11];
int p[11];

bool check(int b) {
    for (int i = 0; i < m; i++) {
        int cnt = 0;
        for (int j = 0; j < k[i]; j++) {
            if ((b>>s[i][j])&1)
                cnt++;
        }
        if (cnt % 2 != p[i]) return false;
    }
    return true;
}

int solve() {
    int res = 0;
    for (int i = 0; i < (1<<n); i++) {
        res += check(i);
    }
    return res;
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> k[i];
        for (int j = 0; j < k[i]; j++) {
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    for (int i = 0; i < m; i++) {
        cin >> p[i];
    }
}

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

    input();
    cout << solve() << endl;
}


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

int main(){
	int i,n,m,a,price[1000],count,out;
	while(cin >> n >> m && (n != 0 && m != 0)){
		count = out = 0;
		for(i = 0;i < n;i++){
			cin >> a;
			price[i] = a;
		}
		sort(price,price+n,greater<int>());
		for(i = 0;i < n;i++){
			out += price[i];
			count++;
			if(count == m) {
				out -= price[i];
				count = 0;
			}
		}
		cout << out << endl;
	}
	return 0;
}

Measured memory_bytes: 0
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N, M; scanf("%d%d", &N, &M);
    int S = 0;
    for(int i=0; i<M; i++) {
        int v; scanf("%d", &v);
        S += v;
    }
    cout << max(N-S, -1) << endl;
    return 0;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
string s,t,a;
bool c=true,h=true;
int g;
int main()
{
  cin>>s;
  cin>>t;
  if(s.size()<t.size())
   {
     cout<<"UNRESTORABLE"<<endl;
     return 0;
   }
  for(int i=0;i<=s.size()-t.size();i++)
     {
       h=true;
       for(int j=0;j<t.size();j++)
         if(s[i+j]!=t[j])
          {
            if(s[i+j]=='?')
             continue;
            h=false;
            break;
          }
       if(h)
        {
          c=false;
          g=i;
        }
     }
  if(c)
   {
     cout<<"UNRESTORABLE"<<endl;
     return 0;
   }
  for(int i=0;i<s.size();i++)
    {
      if(i==g)
       {
         cout<<t;
         i+=t.size()-1;
       }
      else if(s[i]=='?')
            cout<<"a";
      else
         cout<<s[i];
    }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3644
n, h = gets.split.map(&:to_i)
a, b = Array.new(n) { gets.split.map(&:to_i) }.transpose
max = a.max
q = b.select { |e| e > max }.sort.reverse
count = 0

while h > 0
  if (tmp = q.shift)
    h -= tmp
    count += 1
  else
    count += (h.to_f / max).ceil
    break
  end
end

puts count

Measured memory_bytes: 24712
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if (B % A == 0){
            System.out.println(B + A);
        }else{
            System.out.println(B - A);
        }
        sc.close();
    }
}


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

int main()
{
    string s;
    cin >> s;
    if(s[0] == 'S') cout << "Cloudy" << endl;
    else if(s[0] == 'C') cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	int N;
	int gomi = 0;
	int ans = 0;
	cin >> N;
	vector<int> A(100010,0);

	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A[tmp]++;
	}

	for (int i = 0; i < 100010; i++) {
		if(A[i]>=1){
			ans++;
		}
	}

	if(ans%2==0){
		ans--;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
const int N = 2e5+5;
int n,mx;
string s[N];
map<string,int> mp;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i){
		cin>>s[i];
		++mp[s[i]];
		mx=max(mx,mp[s[i]]);
	}
	sort(s+1,s+1+n);
	if(mp[s[1]]==mx) cout<<s[1]<<endl;
	for(ri i=2;i<=n;++i){
		if(s[i]==s[i-1]) continue;
		if(mp[s[i]]==mx) cout<<s[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 26752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(
				new InputStreamReader(System.in))) {

			String in = br.readLine();
			char[] a = in.toCharArray();
			 System.out.println(a[0]==a[1] && a[1]==a[2] ? "No" : "Yes");
		}
	}
}

Measured memory_bytes: 25392
N=int(input())
K=int(input())
x=list(map(int,input().split()))

ans=0
for i in range(N):
  if abs(x[i]) < abs(K-x[i]):
    ans += abs(x[i])*2
  else:
    ans += abs(K-x[i])*2
    
print(ans)

Measured memory_bytes: 9112
using System;


public class A{
	
	public static void Main(){
	
		string[] args;
		
		args = Console.ReadLine().Split(' ');
		int n = Int32.Parse(args[0]);
		int x = Int32.Parse(args[1]);
		
		int[] a = new int[n];
		args = Console.ReadLine().Split(' ');
		for( int i = 0; i < n; i++ ){
			a[i] = Int32.Parse(args[i]);
		}
		
		Array.Sort(a);
		int sum = 0;
		int num = n;
		for( int i = 0; i < n; i++ ){
			sum += a[i];
			if( sum >= x ){
				num = i + 1;
				break;
			}				
		}
		Console.WriteLine( (sum == x) ? num : num - 1 );
				
	}
	
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007 
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
typedef long long int ll;
using namespace __gnu_pbds;
using namespace std;
//using namespace boost::multiprecision;

#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>

ll fact[MAX],inv_fact[MAX];

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

void fun()
{
	fact[0] = 1;
	for(ll i=1;i<MAX;i++)
	fact[i] = (fact[i-1] * i)%MOD;
	inv_fact[MAX-1] = modular_expo(fact[MAX-1],MOD-2);
	for(ll i=MAX-2;i>=0;i--)
	inv_fact[i] = (inv_fact[i+1] * (i+1))%MOD;
}

ll prime[MAX];
vector<ll> v;
void sieve()
{
	for(ll i=2;i*i<MAX;i++)
	if(prime[i]==0)
	for(ll j = i*i;j<MAX;j+=i)
	prime[j]=1;
	
	loop(i,2,MAX)
	if(prime[i]==0)
	v.pb(i);
}

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

//fun();
sieve();

ll t=1;
//cin>>t;

while(t--)
{
	ll n;
	cin>>n;
	
	map<ll,ll> m;
	for(auto it: v)
	{
		while(n%it==0)
		{
			m[it]++;
			n /= it;
		}
		
		if(n==1)
		break;
	}
	
	if(n!=1)
	m[n]++;
	ll ans=0;
	for(auto it: m)
	{
		ll temp = ((ll)sqrt(it.second*8+1) - 1)/2;
		if((temp+1)*(temp+2)<=2*it.second)
		temp++;
		ans += temp;
	}
	
	cout<<ans<<"\n";
}



return 0;
}

Measured memory_bytes: 12088
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
                         **/
#include<bits/stdc++.h>
using namespace std;
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz size
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 2*1e5+1;
const int mod = 1000000009;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 10000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b;
    int pwur = qpow(b,e>>1);
    return pwur * pwur;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    ///freopen("a.in","r",stdin);
    ///freopen("a.out","w",stdout);

    string s;
    int k;
    cin>>s>>k;
    int n=s.size();
    vector<string>ans(0);
    rep(i,n){
        for(int j=1;(i+j)<=n;j++){
            if(j>k)continue;
            ans.pb(s.substr(i,j));
        }
    }
    sort(all(ans));
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    cout<<ans[k-1]<<enl;

    return 0;
}


Measured memory_bytes: 4220
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int a,b,n;
  cin>>a>>b>>n;
  if(a>0){
   if(a>=n){a-=n;n=0;}
    else{n-=a;a=0;}
  }
  if(n>0){
  if(b>0){
  if(b>=n){b-=n;}
    else b=0;
  }
  }
  cout<<a<<' '<<b;
  return 0;
}

Measured memory_bytes: 256
use proconio::input;

// use std::cmp::*;
// use std::collections::*;
// use proconio::marker::Chars;

fn main() {
    input! {
        // s: String
        // n: isize
        a:char,
        b:char
    }
    let mut ans = 'H';
    if a == 'H' {
        ans = b;
    } else {
        ans = if b == 'H' { 'D' } else { 'H' }
    }
    println!("{}", ans);
}


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

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    
    int cnt_RL = 0;
    int cnt_facing = 0;
    for (int i = 1; i < n; i++) {
        if (s.at(i - 1) == 'R' && s.at(i) == 'L') cnt_RL++;
        if (s.at(i - 1) == s.at(i)) cnt_facing++;
    }
    int ans = cnt_facing;
    if (s.at(0) == 'L' && s.at(n - 1) == 'R') {
        if (cnt_RL + 1 <= k) ans += cnt_RL * 2 + 1;
        else ans += min(k, cnt_RL) * 2;
    }
    else if (s.at(0) == 'R' && s.at(n - 1) == 'L') {
        if (cnt_RL <= k) ans += (cnt_RL - 1) * 2 + 1;
        else ans += min(k, cnt_RL) * 2; 
    }
    else ans += min(k, cnt_RL) * 2;
    
    cout << ans << endl;
}

Measured memory_bytes: 512
//author: zekigurbuz (Zeki Gurbuz) 2020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;

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

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

const int N = 1e5 + 10;
const int M = 1e9 + 7;

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

template<class T>void ckmin(T&a,T b){a=min(a,b);}
template<class T>void ckmax(T&a,T b){a=max(a,b);}

bool works(int a, int b, int c) {
	return abs(a-b) <= 1 && abs(b-c) <= 1;
}

void increment(vector<int>& digits) {
	bool all9 = true;
	for (int x : digits) all9 &= x == 9;
	if (all9) {
		int digs = digits.size() + 1;
		digits.clear(); digits.resize(digs);
		digits[0] = 1;
	}
	else {
		if (digits.size() == 1) digits[0]++;
		else {
			for (int i = digits.size() - 1; i >= 0; i--) {
				if (digits[i] == 9) continue;
				if (i == digits.size() - 1) {
					if (abs(digits[i-1]-(digits[i]+1)) <= 1) {
						digits[i]++;
						return;
					}
				}
				else if (i == 0) {
					if (abs(digits[i+1]-(digits[i]+1)) <= 1) {
						digits[i]++;
						for (int j = i + 1; j < digits.size(); j++) {
							digits[j] = max(0, digits[j-1]-1);
						}
						return;
					}
				}
				else {
					if (works(digits[i-1], digits[i]+1,digits[i+1])) {
						digits[i]++;
						for (int j = i + 1; j < digits.size(); j++) {
							digits[j] = max(0, digits[j-1]-1);
						}
						return;
					}
				}
			}
		}
	}
}

void solve() {
	int k; cin >> k;
	vector<int> digits(1); digits[0] = 1;
	int cnt = 1;
	while (cnt++ < k) {
		increment(digits);
	}
	string s = ""; s.resize(digits.size());
	for (int i = 0; i < digits.size(); i++) {
		s[i] = (char) (digits[i] + '0');
	}
	cout << s << endl;
}

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

	int t = 1;
    //cin >> t;
	for (int i = 1; i <= t; ++i) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct p
{
    char s;
    int num;
} b[500009];
int mini=1e9,n,k=0,num[500009],num2[500009],ans=0,ans1=0;
char a[500009];
int main()
{
    scanf("%d%s",&n,a);
    for(int i=0; i<n;)
    {
        char tmp=a[i];
        int cnt=0;
        while(a[i]==tmp&&i<n)
        {
            cnt++;
            i++;
        }
        b[k].s=tmp;
        b[k].num=cnt;
        k++;
    }
    for(int i=0; i<k; i++)
    {
        //printf("%c %d\n",b[i].s,b[i].num);
        if(b[i].s=='.')
        {
            ans+=b[i].num;
            num[i]=ans;
        }
        else
        {
            ans1+=b[i].num;
            num2[i]=ans1;
        }
    }
    for(int i=0; i<k; i++)
    {
        if(b[i].s=='.')
        {
            if(i-1>=0)
            {
                if(b[k-1].s=='.')
                    mini=min(mini,num2[i-1]+num[k-1]-num[i]);
                else
                    mini=min(mini,num2[i-1]+num[k-2]-num[i]);
            }
            else
            {
                if(b[k-1].s=='.')
                    mini=min(mini,num[k-1]-num[i]);
                else
                    mini=min(mini,num[k-2]-num[i]);
            }
        }
        else
        {
            if(i-1>=0)
            {
                if(b[k-1].s=='.')
                    mini=min(mini,num2[i]+num[k-1]-num[i-1]);
                else
                    mini=min(mini,num2[i]+num[k-2]-num[i-1]);
            }
            else
            {
                if(b[k-1].s=='.')
                    mini=min(mini,num2[i]+num[k-1]);
                else
                    mini=min(mini,num2[i]+num[k-2]);
            }
        }
    }
    if(b[k-1].s=='.')
        mini=min(mini,num[k-1]);
    else
        mini=min(mini,num[k-2]);
    printf("%d",mini);
    return 0;
}


Measured memory_bytes: 5248
n = int(input())
listH = list(map(int, input().split()))

flag = 1
index = 0
bef = ""
while index < n:
    if bef == "":
        bef = listH[index]
    else:
        if bef <= listH[index]:
            bef = listH[index]
        elif bef == listH[index]+1:
            bef = listH[index]+1
        else:
            flag = 0
            break
    index+=1
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<n; i++)
#define pb push_back
#define int long long
const int MOD = 1000000007;

int n, a, b;

int mod_pow(int x, int n) {
    int res = 1;
    while (n>0) {
        if (n&1) res = res*x%MOD;
        x = x*x%MOD;
        n >>= 1;
    }
    return res;
}

const int MAX = 201000;
int fact[MAX], finv[MAX], inv[MAX];

void Cinit() {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i=2; i<MAX; i++) {
        fact[i] = fact[i-1]*i%MOD;
        inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}

int C(int n, int k) {
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    int ans = mod_pow(2, n);
    Cinit();
    int nca = 1;
    for (int i=n; i>=n-a+1; i--) {
        nca *= i;
        nca %= MOD;
    }
    nca *= finv[a];
    nca %= MOD;
    int ncb = 1;
    for (int i=n; i>=n-b+1; i--) {
        ncb *= i;
        ncb %= MOD;
    }
    ncb *= finv[b];
    ncb %= MOD;
    ans = (ans-nca+MOD)%MOD;
    ans = (ans-ncb+MOD)%MOD;
    cout << (ans-1+MOD)%MOD << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const double eps = 1e-8;
const int N = 1000+10;

int main()
{
	int n;
	cin >> n;
	int sum = n % 1000;
	cout <<(1000-sum)%1000 << endl;
    return 0;
}

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

int main() {
  // 入力
  int N, K;
  cin >> N >> K;
  bool num[10] = {false};
  int tmp;
  for (int i=0; i<K; i++) {
    cin >> tmp;
    num[tmp] = true;
  }

  while (1) {
    tmp = N;
    while (tmp > 0) {
      int n1 = tmp % 10;
      if (num[n1]) break;
      tmp /= 10;
    }
    if (tmp <= 0) {
      cout << N << endl;
      break;
    }
    N++;
  }

  return 0;
}


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

from collections import Counter
F = sorted(Counter(A).items(), key=lambda x: x[0], reverse=True)
edge= []

for k, v in F:
  if v >= 4:
    edge.extend([k, k])
  elif v >= 2:
    edge.append(k)
  if len(edge) >= 2: break

if len(edge) < 2:
  ans = 0
else:
  ans = edge[0] * edge[1]
print(ans)

Measured memory_bytes: 22308
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	int N;

	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		N = nextInt();

		int[][] Acnts = new int[10][10];
		int[][] Bcnts = new int[10][10];

		for(int i=1;i<=N;i++) {
			if(i % 10 == 0)continue;

			int digit = stringSize(i);
			int first = i/(int)Math.pow(10, (digit-1));
			int end = i%10;
			Acnts[first][end]++;
			Bcnts[end][first]++;
		}

		long cnt = 0;
		for(int i=0;i<10;i++) {
			for(int j=0;j<10;j++) {
				cnt += Acnts[i][j] * Bcnts[i][j];
			}
		}

		out.println(cnt);
	}

	private final int[] sizeTable = {
	        9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999, Integer.MAX_VALUE
	};

	public int stringSize(int x) {
	    for (int i = 0;; i++)
	        if (x <= sizeTable[i])
	            return i + 1;
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}

	long lcm(long m, long n) {
	        return m * n / gcd(m, n);
	}
}

Measured memory_bytes: 21844
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;

/*============================ DEBUGGING =============================*/

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)
#define Sort(a) sort(a.begin(),a.end())

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long double ld;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/

int main(){
	FIO
	
	int w,a,b;cin>>w>>a>>b;
	if(b>=a && b<=a+w)cout<<0;
	else if(a>=b && a<=b+w)cout<<0;
	else cout<<min(abs(a-b-w),abs(b-a-w));
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int a[200005],b[200005],c[200005],d[200005];
int main()
{
    int n,t;
    int i,j,k,h;
    scanf("%d%d",&n,&t);
    for(i=0;i<t;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        if(a[i]==1)
        {
            c[b[i]]=b[i];
        }
        if(b[i]==n)
        {
            d[a[i]]=a[i];
        }
    }
    int g=0;
    for(i=0;i<=n;i++)
    {
        if(c[i]==d[i]&&(c[i]!=0&&d[i]!=0))
        {
            printf("POSSIBLE\n");
            return 0;
        }
        else
        {
            g++;
        }
    }
    if(g!=0)
        printf("IMPOSSIBLE\n");
        return 0;
}


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

int main(){
	int i = 0;
	std::cin >> i;

	char type[2];
	int num = 0;
	int c = 0;
	bool card[52] = {};
	for (int n = 0; n<52; n++)card[n] = false;
	for (int n = 0; n < i; n++){
		std::cin >> type >> num;
		int t;
		if (!strcmp(type, "S"))t = 0;
		if (!strcmp(type, "H"))t = 1;
		if (!strcmp(type, "C"))t = 2;
		if (!strcmp(type, "D"))t = 3;

		card[t * 13 + num - 1] = true;

	}
	for (int n = 0; n < 52; n++){

		if (card[n] == false){
			int t = floor(n / 13);
			if (t == 0)std::cout << "S " << (n % 13) + 1 << std::endl;
			if (t == 1)std::cout << "H " << (n % 13) + 1 << std::endl;
			if (t == 2)std::cout << "C " << (n % 13) + 1 << std::endl;
			if (t == 3)std::cout << "D " << (n % 13) + 1 << std::endl;

		}
	}
	return 0;
}

Measured memory_bytes: 3072
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n, ans = INF;
	cin >> n;
	vector<pair<int, int> > p(n);

	for (int i = 0; i < n; ++i) {
		cin >> p[i].first >> p[i].second;
	}

	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if (i == j) {
				continue;
			}

			int pp = p[i].first - p[j].first;
			int qq = p[i].second - p[j].second;
			int cnt = n;

			for (int ii = 0; ii < n; ++ii) {
				int x = p[ii].first - pp;
				int y = p[ii].second - qq;
				bool flag = 0;

				for (int jj = 0; jj < n; ++jj) {
					if (p[jj].first == x && p[jj].second == y) {
						flag = 1;
					}
				}

				if (flag) {
					cnt--;
				}
			}
			ans = min(ans, cnt);
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
from itertools import chain
 
R = lambda: map(int, input().split())
n, k = R()
v = list(R())
a = sorted((x, i) for i, x in enumerate(v) if x < 0)
r = 0
for i in range(1, min(n, k) + 1):
    for j in range(i):
        r1, r2 = i - j, n - j
        s = sum(v[m] for m in chain(range(r1), range(r2, n)))
        j = i
        for x, m in a:
            if j == k:
                break
            if m < r1 or m >= r2:
                s -= x
                j += 1
        r = max(r, s)
print(r)


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
void answer()
{
	int a,five=0,seven=0;
	for(int i=0;i<3;i++){
		cin>>a;
		if(a==5)
			five++;
		else
		if(a==7)
		 seven++;
	}
	if(2==five||1==seven)
		cout<<"YES";
	else
		cout<<"NO";
	}
int main(){
	answer();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

deque<pair<double, double>> Q;
deque<pair<double, double>> R;

int main() {
	UL N; cin >> N;
	rep(i, N) {
		int x, y; cin >> x >> y;
		Q.push_back({ (double)x, (double)y });
	}
	while (Q.back().first < Q.front().first) {
		Q.push_front(Q.back());
		Q.pop_back();
	}
	R.push_back(Q.front());
	while (Q.back().first >= R.back().first) {
		R.push_back(Q.back());
		Q.pop_back();
	}
	Q.push_back(R.back());
	for (auto& p : Q) {
		p.first *= 1000000.0 / 999900.0;
		p.second *= 1000000.0 / 999900.0;
	}
	for (auto& p : R) {
		p.first *= 1000000.0 / 999900.0;
		p.second *= 1000000.0 / 999900.0;
	}

	UL K; cin >> K;
	rep(k, K) {
		double x, y;
		{ int xx, yy; cin >> xx >> yy; x = xx; y = yy; }
		UL lQ, rQ; lQ = 0; rQ = Q.size() + 1;
		while (lQ + 1 < rQ) {
			UL m = (lQ + rQ) >> 1;
			if (Q[m - 1].first < x) lQ = m;
			else rQ = m;
		}
		UL lR, rR; lR = 0; rR = R.size() + 1;
		while (lR + 1 < rR) {
			UL m = (lR + rR) >> 1;
			if (R[m - 1].first < x) lR = m;
			else rR = m;
		}
		if (lQ == 0 || lQ == Q.size()) { cout << "0\n"; continue; }
		auto q1 = Q[lQ - 1];
		auto q2 = Q[lQ];
		double qx = (x - q1.first) / (q2.first - q1.first);
		double qy = q1.second * (1.0 - qx) + q2.second * qx;
		auto r1 = R[lR - 1];
		auto r2 = R[lR];
		double rx = (x - r1.first) / (r2.first - r1.first);
		double ry = r1.second * (1.0 - rx) + r2.second * rx;
		if (qy <= y && y <= ry) cout << "1\n";
		else cout << "0\n";
	}

	cout << flush;
	return 0;
}



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

int main(){
    string S;
    int count = 0;
    cin >> S;

    string S_rev = S;

    reverse(S_rev.begin(),S_rev.end());
    
    for (size_t i = 0; i < S.size(); i++)
    {
        if (S.at(i) != S_rev.at(i)){
            count++;
        }
    }

    cout << count /2 << endl;
    

}

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

int main() {
  int N, A, l = 1, ans = 100000;
  cin >> N;
  for(int i = 0; i < N; i++){
    int sam = 0;
    cin >> A;
    if (A % 2 == 0 && A != 0){
      for (; A % 2 == 0; sam++){
        A /= 2;
      }
    }
    if (ans > sam){
      ans = sam;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
long long a,b,c,d,k;
cin>>a>>b>>c>>d>>k;
    b+=a*60;
    d+=c*60;
    int ans=d-b-k;
    cout<<ans<< endl;
      return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define ui unsigned int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define fi first
#define se second
#define pb push_back
#define pi 3.141592653589793
#define maxn 
#define maxm 
#define maxs 
#define M 
#define Base 
#define Hash 
#define Author Renatus
//#define DEBUG
//#define ONLINE_JUDGE
using namespace std;

ll N, X;

ll cal(ll x, ll y){
	if (x < y) swap(x, y);
	if (!y) return 0;
	if (x == y) return x;
	ll d = x / y;
	if (x % y == 0) d--;
	return d * 2 * y + cal(x - d * y, y);
}

int main(){
	
	scanf("%lld%lld", &N, &X);
	printf("%lld", cal(N - X, X) + N);
	return 0;
}

Measured memory_bytes: 256
# import bisect
from collections import Counter, deque
# import copy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

    N=int(input())
    H=list(map(int,input().split()))

    cluster=deque([H])
    cnt=0
    while cluster:
        i=cluster.popleft()
        if len(i)!=0:
            mini=min(i)
            cnt += mini
            for j in range(len(i)):
                i[j]-=mini

            j = 0

            for k in range(len(i)):
                if i[k]==0:
                    cluster.append(i[j:k])

                    j=k+1
                elif k==len(i)-1:
                    cluster.append(i[j:len(i)])

    print(cnt)
resolve()

Measured memory_bytes: 38640