akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>

using namespace std;

int main()
{
        unsigned int n;
        char s;
        map<char, int> mp;
        cin >> n;

        for (unsigned int i=0; i<n; i++) {
                cin >> s;
                mp[s] = 1;
        }

        switch (mp.size()) {
        case 3:
                cout << "Three" << endl;
                break;
        case 4:
                cout << "Four" << endl;
                break;
        }



        return 0;
}

Measured memory_bytes: 256
n = int(input())
s = input()
rl = s.count('R')
gl = s.count('G')
bl = s.count('B')
rr = 0
gr = 0
br = 0
if s[0] == 'R':
    rl -= 1
    rr += 1
elif s[0] == 'G':
    gl -= 1
    gr += 1
else:
    bl -= 1
    br += 1

ans = 0
for i in range(1, n-1):
    for j in range(1, n//2+1):
        if i-j < 0 or i+j > n-1:
            break
        if s[i+j] != s[i-j] and s[i+j] != s[i] and s[i-j] != s[i]:
            ans -= 1
    if s[i] == 'R':
        ans += bl*gr + br*gl
        rl -= 1
        rr += 1
    elif s[i] == 'G':
        ans += rr*bl + rl*br
        gl -= 1
        gr += 1
    else:
        ans += gr*rl + gl*rr
        bl -= 1
        br += 1
print(ans)


Measured memory_bytes: 9252
n = int(input())
a = list(map(int,input().split()))
d = {}
for num,i in enumerate(a):
  if num%2==0:
    if i in d:
      d[i][0] += 1
    else:
      d[i] = [1,0]
  else:
    if i in d:
      d[i][1] += 1
    else:
      d[i] = [0,1]
b = [i for i in d.values()]
c = [i for i in d.values()]
b.append([0,0])
c.append([0,0])
b.sort(key=lambda x:x[0],reverse=True)
c.sort(key=lambda x:x[1],reverse=True)
if b[0][1] == c[0][0] and b[0][1] != 0:
  print(n-max(b[0][0]+c[1][1],b[1][0]+c[0][1]))
else:
  print(n-b[0][0]-c[0][1])

Measured memory_bytes: 25244
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int main(){
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if(e-a <= k){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }
}

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

int N, K, Q, A, i;
int C[100000];

int main(void){
	scanf("%d%d%d", &N, &K, &Q);
	K-=Q;
	for(i=0; i<Q; i++){
		scanf("%d", &A);
		C[A-1]++;
	}
	for(i=0; i<N; i++){
		if(C[i]+K>0){
			puts("Yes");
		}else{
			puts("No");
		}
	}
}



Measured memory_bytes: 896
#include<stdio.h>
int p[100010]={0};
int d[100010]={0};
int Find(int a,int b){
  int r,n;
  for(r=++a;p[r];r=p[r]);
  for(;n=p[a];a=n)p[a]=r;
  for(r=++b;p[r];r=p[r]);
  for(;n=p[b];b=n)p[b]=r;
  return a-b?1:0;
}
void Union(int a,int b){
  if(Find(a,b)){
    for(++a;p[a];a=p[a]);
    for(++b;p[b];b=p[b]);
    d[a]<d[b]?(p[a]=b):(p[b]=a);
    if(d[a]==d[b])d[a]++;
  }
}
int main(){
  int n,m,t[100010],l,k,i;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d %d",&k,&t[i]);
    while(--k){
      scanf("%d",&l);
      Union(t[i],l);
    }
  }
  //for(i=1;i<=m;i++)printf("%d %d\n",i,p[i]);
  for(i=1;i<n;i++){
    if(Find(t[0],t[i]))break;
  }
  printf("%s\n",i==n?"YES":"NO");
  return 0;
}
    
      


Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int h,w,i,j;
  while(scanf("%d %d",&h,&w)){
    if(h==0 && w==0)break;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return(0);
}
    

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	long long a[90],n;
	cin >> n;
	a[0]=2;
	a[1]=1;
	for (int i=0;i<=n-2;i++)
	{
		a[i+2]=a[i]+a[i+1];
	}
	cout << a[n] << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int N;
    cin >> N;
    int Ans=0;
    OREP(i,N){
        if(i%3!=0 && i%5!=0){
            Ans+=i;
        }
    }
    cout << Ans << endl;
    return 0;
}



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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<int> z(4,0);
	int ans = 0;
	repp(i,0,N){
		string S; cin >> S;
		int a = 0;
		for(auto c : S){
			if(c == 'B' && a == 1) ++ans;
			if(c == 'A') a = 1;
			else a = 0;
		}
		++z[(S[0]=='B'?2:0)+a];
	}
	ans += min(z[1],z[2])+max(0,z[3]-1);
	if((z[1] > 0 || z[2] > 0) && z[3] > 0) ++ans;
	cout << ans << endl;
	return 0;
}


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

# define C continue;
# define R return

#define int long long
# define D double
# define I insert
# define ld long double
# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

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

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

#define PQ(type) priority_queue<type>
#define PQD(type) priority_queue<type, vector<type>, greater<type>>

#define mii map<int, int>
#define mll map<ll, ll>
#define mci map<char, int>
#define msi map<string, int>
#define mis map<int, string>
#define mib map<int, bool>
#define mcb map<char,bool>

#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>
#define umci unordered_map<char, int>
#define umsi unordered_map<string, int>
#define umis unordered_map<int, string>

#define init(arr,val) memset(arr,val,sizeof(arr))
#define REP(i,a,b) for(int i=a; i<b; i++)
#define distance(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define nl "\n"
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = { -2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const int mod = 1e9 + 7 ;
#define test int t; cin>>t;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .
void a_b_c()
{
    #ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
}

void solve()
{
 int n,ans=0; cin>>n;
 int a[n];
 REP(i,0,n) cin>>a[i];
 REP(i,1,n)
 {
     if(a[i]<a[i-1])
     {
         ans+=a[i-1]-a[i];
         a[i]=a[i-1];
     }
 }
 cout<<ans;
}
int32_t main()
{	fast
    int t=1;
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
    //int t;  cin>>t;
    for(int i=1; i<=t; i++) solve();

}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	ll n;cin >> n;
	string str;cin >> str;
	ll k;cin >> k;
	REP(i, n)if(str[i] != str[k-1])str[i] = '*';
	cout << str << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int x = 2e5+5;
int n, a[x];
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for(int i = n - 1 ; i >= 0; i-=2){
        if(i!=n-1) printf(" ");
        printf("%d",a[i]);
    }
    int i = 0;
    if(n%2)i = 1;
    for(;i<n; i+=2){
       printf(" %d",a[i]);
    }
    printf("\n");
    return 0;
}

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

using namespace std;
//vector<long long> factors;
#define ll long long

#define pii pair<int,int>
#define pll pair<ll,ll>
#define _ <<'\n'
#define __ << ' '
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
int IT_MAX = 1 << 17;
int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x0f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
#define szz(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(false); cout.tie(0);cin.tie(0);
#define flush fflush(stdout)

ll mod(ll a, ll m) { return (a + (abs(a) / m) * m + m) % m; }

struct node {
    vector<ll> childs;
};

vector<node> tree(101010);
map<pll, ll> setik;

ll mx = 0;

void dfs(ll n, ll par) {
    ll a = n;
    ll b = par;
    if (a > b) {
        swap(a, b);
    }
    ll skip_color = setik[{a, b}];
    ll color = 1;
    for (auto child : tree[n].childs) {
        if (child != par) {
            if (color == skip_color)
                ++color;
            mx = max(mx, color);
            a = child;
            b = n;
            if (a > b) {
                swap(a, b);
            }
            setik[{a, b}] = color;
            ++color;
        }
    }

    for (auto child : tree[n].childs) {
        if (child != par) {
            dfs(child, n);
        }
    }

}


int main() {
    IOS

    ll n;
    cin >> n;

    vector<pll > ed;
    for (int i = 0; i < n - 1; ++i) {
        ll a, b;
        cin >> a >> b;
        tree[a].childs.push_back(b);
        tree[b].childs.push_back(a);
        if (a > b) {
            swap(a, b);
        }
        setik[{a, b}] = 0;
        ed.push_back({a, b});
    }
    dfs(1, -1);
    cout << mx << '\n';
    for (auto i : ed) {
        cout << setik[i] << '\n';
    }

    return 0;
}

Measured memory_bytes: 16372
a,b=map(int, input().split())
res = 0
if a > b:
    res+=a
    a-=1
    if a>b:
        print(res+a)
    else:
        print(res+b)
else:
    res+=b
    b-=1
    if a>b:
        print(res+a)
    else:
        print(res+b)


Measured memory_bytes: 2940
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

static vector<bool> check;
void dfs(vector<vector<int>>& graph, int node, vector<int>& out) {
    check[node] = true;
    for(int elem: graph[node]) {
        if(check[elem]) continue;
        dfs(graph, elem, out);
    }
    out.push_back(node);
}

int main(void) {
    int vs, es;
    cin >> vs >> es;
    vector<vector<int>> graph(vs);
    check.resize(vs);
    fill(check.begin(), check.end(), false);
    for(int i = 0; i < es; i++) {
        int src, dst;
        cin >> src >> dst;
        graph[src].push_back(dst);
    }

    vector<int> ans;
    for(int i = 0; i < vs; i++) {
        if(!check[i]) dfs(graph, i, ans);
    }

    reverse(ans.begin(), ans.end());
    for(int elem: ans) {
        cout << elem << endl;
    }
    return 0;
}


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

int main(){
    ll N;cin>>N;
    ll info[N];
    rep(i,N){
        cin>>info[i];
        info[i]-=i;
    }
    sort(info,info+N);
    if(N%2){
        ll a=info[N/2],ans=0;
        rep(i,N)ans+=abs(a-info[i]);
        cout<<ans<<endl;
    }
    else{
        ll b=info[N/2]-1,c=info[N/2];
        ll ans1=0,ans2=0;
        rep(i,N){
            ans1+=abs(b-info[i]);
            ans2+=abs(c-info[i]);
        }
        cout<<min(ans1,ans2)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1920
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    StringBuilder ans = new StringBuilder();
    
    for(int i=0;i<n;i++){
      a[i] = sc.nextInt();
    }
    for(int j = n-1;j>=0;j--){
      ans.append(a[j]+ " ");
      j--;
    }
    for(int k = n%2;k<n;k++){
      ans.append(a[k]+ " ");
      k++;
    }
    System.out.println(new String(ans));
  }
}

Measured memory_bytes: 97892
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

int N;
std::vector<int> a;
std::priority_queue<int, std::vector<int>, std::greater<int>> a_prime_former;
std::priority_queue<int, std::vector<int>, std::less<int>> a_prime_latter;
long max_score = 0;
long sum_a_prime_former = 0;
long sum_a_prime_latter = 0;
std::vector<long> score;

int main() {
  std::cin >> N;
  a.assign(3*N, 0);
  score.assign(N+1, 0);
  int counter = 0;
  for (auto& x: a) {
    std::cin >> x;
    if (counter < N) {
      a_prime_former.push(x);
      sum_a_prime_former += x;
    } else if (counter >= 2*N) {
      a_prime_latter.push(x);
      sum_a_prime_latter += x;
    }
    ++counter;
  }
  score[0] += sum_a_prime_former;
  score[N] -= sum_a_prime_latter;
  for (int k = N; k < 2*N; ++k) {
    // As for maximizeing the former, ...
    int min_element, push_element;
    min_element = a_prime_former.top();
    a_prime_former.pop();
    sum_a_prime_former -= min_element;
    push_element = std::max(min_element, a[k]);
    a_prime_former.push(push_element);
    sum_a_prime_former += push_element;
    // Records
    score[k - N + 1] += sum_a_prime_former;
  }
  for (int k = 2*N -1; k >= N; --k) {
    // As for minimizing latter, ...
    int max_element, push_element;
    max_element = a_prime_latter.top();
    a_prime_latter.pop();
    sum_a_prime_latter -= max_element;
    push_element = std::min(max_element, a[k]);
    a_prime_latter.push(push_element);
    sum_a_prime_latter += push_element;
    // Records
    score[k - N] -= sum_a_prime_latter;
  }
  max_score = *std::max_element(score.begin(), score.end());
  std::cout << max_score << std::endl;
}

Measured memory_bytes: 3320
#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 pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int N = 1e5 + 5;
int dp[N];
int a[N];
int n;

int dynamic(int pos)
{
    if (pos > n)
        return INT_MAX;
    if (pos == n)
        return 0;
    if (dp[pos] != -1)
        return dp[pos];
    int ans;
    ans = min(dynamic(pos + 1) + abs(a[pos + 1] - a[pos]), dynamic(pos + 2) + abs(a[pos + 2] - a[pos]));
    dp[pos] = ans;
    return ans;
}

void solve()
{
    cin >> n;
    for (int i = 1 ; i <= n; i++)
        cin >> a[i];
    // mem1(dp);
    dp[1] = 0;
    dp[2] = abs(a[2] - a[1]);
    for (int i = 3; i <= n; ++i)
        dp[i] = min(dp[i - 2] + abs(a[i] - a[i - 2]), dp[i - 1] + abs(a[i] - a[i - 1]));
    cout << dp[n];
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 1792
object Main {
  def main(args : Array[String]): Unit ={
    val scanner = new java.util.Scanner(System.in)
    val i = scanner.nextInt()
    val lines = List.fill(i)(List.fill(10)(scanner.nextInt()))
    val result = lines.map(check(_ , 0 , 0)).map{if (_) "YES" else "NO"}
    result.foreach(println)

  }

  def check (rest : List[Int], l : Int , r : Int) : Boolean ={
    rest match {
      case Nil => true
      case x :: xs =>
        (x >  l && check(xs ,x , r)) || (x > r && check(xs, l, x))
    }
  }
}

Measured memory_bytes: 44936
N,K = map(int,input().split())
A = []
c = 0

for i in range(N+2):
    A.append(i*(i-1)//2)

for i in range(K,N+2):
    c += A[N+1]-A[N-i+1]-A[i]+1
    
print(c%(10**9+7))

Measured memory_bytes: 16972
[N,K] = list(map(int,input().split()))
S = 0
out = [0]*(K+1)
p = 10**9+7
for i in range(K):
    X = K-i
    out[X] = pow(int(K/X),N,p)
    t=2
    while t*X<=K:
        out[X] = out[X]-out[t*X]
        t+=1
    S = (S + X*out[X])%p
print(S)

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

int main()
{
    int n;
    while(scanf("%d",&n)==1)
    {
        int i;
        int sum,a,b;
        sum=0;
        for(i=0;i<n;i++)
        {
            scanf("%d%d",&a,&b);
            sum=sum+b-a+1;
        }
        printf("%d\n",sum);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

// 2整数の最大公約数を求める関数
ll gcd(ll x, ll y) {
  if (y == 0)
    return (x);
  else
    return (gcd(y, x % y));
}

ll lcm(ll x, ll y) {
  return x * y / gcd(x, y);
}

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

  ll n,m;
  string s,t;
  cin>>n>>m>>s>>t;
  
  ll ans = -1;
  ll i = lcm(n,m);
  ll flag = 1;
  ll l = lcm(i/n,i/m);
  for(ll j = 0; j < i / l; j++)
  {
    if(s[l * n / i * j] != t[l * m / i * j]) {
      flag = 0;
    }
  }
  if(flag) {
    ans = i;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 640
/**
 *   author: r1933
**/
#include "bits/stdc++.h"

using namespace std;

#define all(x) x.begin(), x.end()
using i64 = long long;

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A, B, C;
  cin >> A >> B >> C;
  cout << ((A <= C && C <= B) || (A >= C && C >= B) ? "Yes" : "No") << "\n";
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long sum=0,n,m,k;
    vector<int>v;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>k;
        sum+=k;

    }
    if(sum>n)cout<<"-1"<<endl;
    else cout<<n-sum<<endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    int fib[n+1];
    fib[0] = 1;
    fib[1] = 1;
    REP(i,n - 1){
        fib[i+2] = fib[i+1] + fib[i];
    }
    cout << fib[n] << endl;

}


Measured memory_bytes: 3120
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

vector<int> powerArray(int p, int n) {
	vector<int> power(n + 1); power[0] = 1;
	for (int i = 0; i < n; i++)
		power[i + 1] = power[i] * p;
	return power;
}

using Num = int;
vector<vector<Num>> nCr;
void compute_nCr(int n) {
	vector<Num> a(1, 1), b(2, 1);
	nCr = { a,b };
	for (int i = 3; i <= n + 1; i++) {
		swap(a, b);
		b.resize(i);
		b[0] = 1; b[i - 1] = 1;
		for (int j = 1; j < i - 1; j++)
			b[j] = a[j - 1] + a[j];
		nCr.emplace_back(b);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	int P; cin >> P;
	int cnt[2] = {};
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
		cnt[A[i] % 2]++;
	}
	int ans = 0;
	compute_nCr(N);
	vector<int> pow2 = powerArray(2, N);
	if (P == 1) {
		ans = pow2[cnt[0]];
		int t = 0;
		for (int i = 1; i <= cnt[1]; i += 2) {
			t += nCr[cnt[1]][i];
		}
		ans *= t;
	}
	else {
		ans = pow2[cnt[0]];
		dump(ans);
		int t = 0;
		for (int i = 0; i <= cnt[1]; i += 2) {
			t += nCr[cnt[1]][i];
			dump(t);
		}
		ans *= t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a, b, i, j;
    while(1){
        scanf("%d %d", &a, &b);
        if(a == 0 && b == 0) break;
        
        for(i = 1; i <= a; i++){
            for(j = 1; j <= b; j++){
                if(j % 2 == 1){
                    if(i % 2 == 1)printf("#");
                    else printf(".");
                }
                else{
                    if(i % 2 == 1)printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2104
n=int(input())
if int(input())!=0:
  print(-1)
  exit()
b=0
c=0

for i in range(n-1):
  a=int(input())
  if a>b+1:
    print(-1)
    exit()
  else:
    if a==b+1:
      c+=1
    else:
      c+=a  
  b=a
print(c)

Measured memory_bytes: 9056
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;
int A[200010];


llint solve(){
	llint ans = 0;
	llint sum = 0;
	llint xsum = 0;
	int j = 0;
	rep(i, 0, N){
		while(j < N && sum+A[j] == (xsum^A[j])) sum+=A[j], xsum^=A[j], j++;
		ans += j-i;
		if(i == j) j++;
		else {
			sum -= A[i];
			xsum ^= A[i];
		}
	}
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> A[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>

int main(){
	int N;
	scanf("%d\n", &N);
	bool a[N];
	for (int i = 0; i < N; ++i){
		char tmp;
		scanf("%c", &tmp);
		a[i] = tmp == '(';
	}
	int left_surplus = 0, right_surplus = 0, left_lack = 0, right_lack = 0;
	for (int i = 0; i < N; ++i){
		if(a[i]) left_surplus++;
		else if(left_surplus) left_surplus--;
		else left_lack++;
	}
	for (int i = N-1; i >= 0; --i){
		if(!a[i]) right_surplus++;
		else if(right_surplus) right_surplus--;
		else right_lack++;
	}
	for (int i = 0; i < left_lack; ++i) printf("(");
	for (int i = 0; i < N; ++i) printf("%c", a[i] ? '(' : (')'));
	for (int i = 0; i < right_lack; ++i) printf(")");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
   int n,i,k=1,s=0,a[100001],aux,j;
    cin>>n;
   for(i=0;i<n;i++)
          cin>>a[i];
   sort(a , a + n);
   for(i=1;i<n;i++)
   {
       if(a[i - 1] == a[i])
              k++;
       else{
              if(k%2==1)
                     s++;
              k=1;
       }
   }

       if(k%2==1)
              s++;


       cout<<s;
       return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s1 = sc.next();
    String s2 = sc.next();
    String s3 = sc.next();
    String ans = "";
    ans += s1.charAt(0);
    ans += s2.charAt(1);
    ans += s3.charAt(2);
    System.out.println(ans);
  }

}


Measured memory_bytes: 20564
#include <stdio.h>
#include <numeric>
#include <time.h>
#include <bitset>
#include <string.h>
#include <stack>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <math.h>
#include <queue>
#include <complex>
#include <functional>
#include <limits.h>
using namespace std ;
typedef long long ll ;
typedef long double ld ;
typedef unsigned long long ull ;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define pi (acos(-1.0))
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define lson (o<<1),l,mid
#define rson (o<<1|1),mid+1,r
#define MP make_pair
#define sqr(x) ((x)*(x))
#define ALL(v) (v).begin(),(v).end()
#define showtime fprintf(stderr,"time = %.15f\n",clock() / (double)CLOCKS_PER_SEC)
const double eps = 1e-9 ;
const int MOD=(int)1e9+7,BAS=233;
inline int sign(double x){return x<-eps?-1:x>eps;}
inline int clz(int x){return __builtin_clz(x);}
inline int clz(ll x){return __builtin_clzll(x);}
inline int lg2(int x){return !x ? -1 : 31-clz(x);}
inline int lg2(ll x){return !x ? -1 : 63-clz(x);}
int AP (char *s) {
	unsigned hash=0;
	for(int i=0; s[i]; i++){
		if (i & 1) hash ^= (~((hash<<11)^s[i]^(hash>>5)));
		else hash ^= ((hash<<7)^s[i]^(hash>>3));
   } return hash & 0x7FFFFFFF;
}

const int M = 55;
char s[M][M], t[M][M];
int n, m;

bool judge (int sx,int sy) {
	for (int i=sx; i<sx+m; i++) {
		for (int j=sy; j<sy+m; j++) if (s[i][j]!=t[i-sx][j-sy]) {
			return false;
		}
	}
	return true;
}

int main () {
	scanf ("%d%d", &n, &m);
	for (int i=0; i<n; i++) scanf ("%s", s[i]);
	for (int i=0; i<m; i++) scanf ("%s", t[i]);
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) if (judge(i,j)) {
			puts ("Yes");
			exit(0);
		}
	}
	puts ("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define M 20001
#define N 1001
struct faner {
    int w, s, v;
} a[N];
ll f[M], ans;
bool cmp(faner a, faner b) { return a.s + a.w < b.s + b.w; }
int n;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d%d%d", &a[i].w, &a[i].s, &a[i].v);
    sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; i++)
        for (int j = M - 1; j >= a[i].w; j--)
            if (a[i].s + a[i].w >= j) f[j] = max(f[j], f[j - a[i].w] + a[i].v);
    for (int i = 1; i < M; i++) ans = max(ans, f[i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define for0(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,k;
  ll count=0;
  ll r=0,g=0,b=0;
  char RGB[4004];
	cin >> n;
  cin >>RGB;
  for(ll i=0 ; i< n ; ++i){
    if(RGB[i]=='R')r++;
    else if(RGB[i]=='G')g++;
    else if(RGB[i]=='B')b++;
  }
  count=r*g*b;
  for(ll i=0 ; i<n ; i++){
    for (ll j = i+1; j < n; j++) {
      k = 2*j-i ;
      if(RGB[i]!=RGB[j]){
          if(k<n && RGB[k]!=RGB[j] && RGB[i]!=RGB[k])count--;
      }
    }
  }
  cout<<count;
	return 0;
}


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

using namespace std;

int n,a[100010],nowm[100010];

int main()
{
	scanf("%d%*d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=n;i;i--)
	{
		nowm[i]=max(nowm[i+1],a[i]);
	}
	int nowans=0;
	for(int i=1;i<=n;i++)
		if(nowm[i]-a[i]>=nowans)nowans=nowm[i]-a[i];
	int ans=0;
	for(int i=1;i<=n;i++)
		if(nowm[i]-a[i]==nowans)ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int q;
int main(){
	cin>>q;
	long long a ,b;
	long long tong;
	while(q--){
		cin>>a>>b;
		long long product=a*b;
		long long t=sqrt(product);
		if(t*(t+1)<product){
			cout<<2*t-1<<endl;
		}
	else if(t * t == product)
		{
			if(a != b)
				cout<< (t - 1) * 2-1<<endl;
			else
				cout<<(t - 1) * 2 <<endl;
		}
		else
		 cout<< (t-1)*2<<endl;
}
}

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

const int maxn = 100005;

int n, lst;
int a[maxn];
long long ans;

signed main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) 
		scanf("%d", &a[i]);
	ans = a[1] - 1, a[1] = 1;
	lst = 1;
	for (int i = 2; i <= n; ++i) {
		if (lst != a[i] - 1) {
			ans += (a[i] - 1) / (lst + 1);
			a[i] = 1;
		}
		lst = max(lst, a[i]);
	}
	printf("%lld\n", ans);
}


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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1000000007; // 10000000000000007ll;

const double eps = 1e-8;

const i64 MAXN = 3'000'000 + 6;

i64 T;
i64 k, n;
i64 a[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);


    cin >> k >> n;

    for (i64 i = 1; i <= n; i++) {
        cin >> a[i];
    }

    i64 m = 0;
    for (i64 i = 2; i <= n; i++) {
        m = max(m, a[i] - a[i - 1]);
    }

    m = max(m, k - a[n] + a[1]);


    i64 R = k - m;
    cout << R << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    int N;
    vector<long long> A,B;
    long long ans = 0;
    
    cin >> N;
    
    for ( int i = 0; i < N; i++ ) {
        long long a, b;
        cin >> a;
        cin >> b;
        
        A.push_back(a);
        B.push_back(b);
    }
    
    reverse( A.begin(), A.end() );
    reverse( B.begin(), B.end() );
    
    for ( int i = 0; i < N; i++ ) {
        
        A[i] += ans;
        
        if ( A[i] % B[i] == 0 ) { continue; }
        
        // cout << "A[i]: " << A[i] << endl;
        // cout << "B[i]: " << B[i] << endl;
        
        
        long long dif;
        if ( A[i] <= B[i] ) {
            dif = B[i] - A[i];
        }
        else {
            dif = B[i] - (A[i] % B[i]);
        }
        
        // cout << "dif: " << dif << endl;
        
        ans += dif;
        
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 2036
n=int(input())
x=list(map(int,input().split()))
mi=min(x)
ma=max(x)
ans = sum(x)**2
for i in range (mi,ma+1):
  hp=0
  for j in x:
    hp+= (i-j)**2
  ans = min(hp,ans)
print(ans)


Measured memory_bytes: 63332
N,D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N):
        temp = 0
        for k in range(D):
            temp += (X[i][k] - X[j][k])**2
        temp = temp**(1/2)
        if temp == temp//1:
            ans+=1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int N, A;

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		scanf("%d", &A);
		int t = N % 500;
		if(A >= t) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
import collections
n = int(input())
s = [input() for i in range(n)]
p = collections.Counter(s)
res = sorted(p.items(), key=lambda x: x[1],reverse = True)
 
keys = []
#keys = [i for i,m in p.items() if m == p.values()]
u = max(p.values())
for i,m in res:
  if(m == u):
    keys.append(i)
  else:
    break
keys=sorted(keys)
for i in range(len(keys)):
  print(keys[i])

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> vec(N);
  int count = 0, sum = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    vec.at(i) = A;
    sum += A;
  }
  for (int i = 0; i < N; i++) {
    if ((double) vec.at(i) >= (double) sum / (4*M)) {
      count++;
    }
  }
  if (count >= M) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    char m[N][N];
    for(int yi = 0; yi < N; yi++){
        string s;
        cin >> s;
        for(int xi = 0; xi < N; xi++){
            m[yi][xi] = s[xi];
        }
    }
    int count = 0;
    for(int i = 0; i < N; i++){
        bool judge = true;
        for(int yi = 0; yi < N; yi++){
            for(int xi = 0; xi < N; xi++){
                int X = (xi + i) % N;
                int Y = (yi + i) % N;
                //cout << m[X][yi] << m[Y][xi] << ",";
                if(m[X][yi] != m[Y][xi]){
                    judge = false;
                }
            }
        }
        //cout << endl;
        if(judge){
            count++;
        }
    }
    cout << count * N << endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> g(n);
  rep(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    g[u].push_back(make_pair(v, w));
    g[v].push_back(make_pair(u, w));
  }
  queue<int> q;
  q.push(0);
  vector<int> col(n, -1);
  col[0] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto a : g[v]) {
      if (col[a.first] != -1) continue;
      if (a.second % 2 == 0) {
        col[a.first] = col[v];
      }
      else {
        col[a.first] = 1 - col[v];
      }
      q.push(a.first);
    }
  }
  rep(i, n) cout << col[i] << endl;
  return 0;
}


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

#define int long long

int a[110];
int n, p;
int memo[100][10];

int dp(int i, int j){
    if(i == n){
        if(j == p){
            return 1;
        }else{
            return 0;
        }
    }

    if(memo[i][j] != -1) return memo[i][j];

    return memo[i][j] = dp(i+1, j) + dp(i+1, (j+a[i])%2);
}

signed main(){
    cin >> n >> p;
    for(int i = 0;i < n;i++) cin >> a[i];
    memset(memo, -1, sizeof(memo));

    cout << dp(0, 0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>


long H;
long heap[500001];

long right(long i) { return 2 * i + 1; }
long left(long i) { return 2 * i; }
long parent(long i) { return i / 2 ;}

void maxHeapify(long i) {
	long r = right(i);
	long l = left(i);

	long max;

	if (r<=H && heap[r]>heap[i]) {
		max = r;
	}
	else {
		max = i;
	}

	if (l<=H && heap[l]>heap[max]) {
		max = l;
	}

	if (i != max) {
		long t = heap[i];
		heap[i] = heap[max];
		heap[max] = t;

		maxHeapify(max);
	}

}

int main() {
	scanf("%ld", &H);

	for (long i = 1; i <= H; ++i) {
		scanf("%ld", &heap[i]);
	}

	for (long i = H / 2; i > 0; i--) {
		maxHeapify(i);
	}

	for (long i = 1; i <= H; ++i) {
		printf(" %d", heap[i]);
	}
	printf("\n");
	return 0;
}


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


int main() {
    int N;
    cin >> N;
    int ans = 0;
    rep(i,N + 1) {
        if (i%2 == 1) {
            int count = 0;
            for (int j = 1; j < i + 1; j++) {
                if (i%j == 0) {
                    count++;
                }
            }
            if (count == 8) {
                ans++;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define md 1000000000000000000
int main()
{
  int n;
  cin>>n;
 long long  int a[n];

  for(int i=0;i<n;i++)
     cin>>a[i];
 sort(a,a+n);  int yy=0;
  long long int prd=1;
  for(int i=0;i<n;i++)
  {
  	if(a[i]==0) {yy=-1;cout<<0<<endl;break;}
    if((a[i]<md/prd && md%prd!=0)||(md%prd==0 && a[i]<=md/prd))
    {prd=prd*a[i];}
    else {yy=1;break;}
  } 
  if(yy==1) cout<<-1<<endl;
  else if(yy==0) cout<<prd<<endl;
   return 0;
}

Measured memory_bytes: 4372
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int i;
		int ans=1000000;
		while(true) {
			int n=sc.nextInt();
			if(n==0)
				break;
			int a[]=new int[n];
			for(i=0;i<n;i++) {
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			for(i=0;i<n-1;i++) {
				if(ans>a[i+1]-a[i])
					ans=a[i+1]-a[i];
			}
			System.out.println(ans);
			ans=1000000;
		}

	}
}



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

int main() {
  int N, a[100010];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  
  int ai, b[300010];
  for (int i = 0; i < N; i++) {
    ai = a[i];
    b[0 + i*3] = ai;
    b[1 + i*3] = ai + 1;
    b[2 + i*3] = ai - 1;
  }
  
  map<int, int> mp;
  for (int j = 0; j < N*3; j++)
    mp[b[j]]++;
  
  int ans = 0, num;
  for (auto k: mp) {
    num = k.second;
    ans = max(ans, num);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6272
import math
H,W=map(int,input().split())
sum=0
# for i in range(H):
#     for j in range(W):
#         if (i-j)%2==0:
#             sum+=1
if H==1 or W==1:
    print(1)
else:
    sum=(H*W)/2
    print(math.ceil(sum))

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;

template <typename T, typename E>
struct SegmentTree{
  vector<T> dat;vector<E> laz;
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  typedef function<E(E, int)> P;
  int n;F f;G g;H h;P p;T d1;E d0;

  SegmentTree(int m,F f,G g,H h,T d1,E d0,
  	      vector<T> v=vector<T>(),P p=[](E a,int b){return a;}):
      f(f),g(g),h(h),d1(d1),d0(d0),p(p){
      init(m);
      if(m==(int)v.size()) build(m,v);
  }
  void init(int m){
    n = 1;
    while(n<m) n*=2;
    dat.clear();laz.clear();
    dat.resize(2*n-1);laz.resize(2*n-1);
  }
  void build(int m, vector<T> v){
    for(int i=0;i<m;i++) dat[i+n-1] = v[i];
    for(int i=n-2;i>=0;i--) dat[i] = f(dat[i*2+1], dat[i*2+2]);
  }
  inline void eval(int len, int k){
    if(laz[k]==d0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=h(laz[k*2+1], laz[k]);
      laz[k*2+2]=h(laz[k*2+2], laz[k]);
    }
    dat[k]=g(dat[k], p(laz[k], len));
    laz[k]=d0;
  }
  T update(int a, int b, E x, int k, int l, int r){
    eval(r-l, k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b){
      laz[k] = h(laz[k], x);
      return g(dat[k], p(laz[k], r-l));
    }
    return dat[k] = f(update(a, b, x, k*2+1, l, (l+r)/2),
                      update(a, b, x, k*2+2, (l+r)/2, r));
  }
  T query(int a, int b, int k, int l, int r){
    eval(r-l, k);
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return dat[k];
    T vl = query(a, b, k*2+1, l, (l+r)/2);
    T vr = query(a, b, k*2+2, (l+r)/2, r);
    return f(vl, vr);
  }
  T update(int a,int b,E x){return update(a,b,x,0,0,n);}
  T query(int a,int b){return query(a,b,0,0,n);}
};

int main(int argc, char const *argv[]) {
  ll n, q;
  ll a, b, c, d;
  std::cin >> n >> q;
  SegmentTree<ll,ll> ch(n,
			  plus<ll>(),
			  plus<ll>(),
			  plus<ll>(),
			  0,0,vector<ll>(n,0),
			  multiplies<ll>());
  for(int i=0;i<q;i++){
    std::cin >> a;
    if(a){
      std::cin >> b >> c;
      std::cout << ch.query(b-1, c) << '\n';
    }else{
      std::cin >> b >> c >> d;
      ch.update(b-1, c, d);
    }
  }
  return 0;
}



Measured memory_bytes: 8440
using System;

namespace ITP1_1_A
{
    class Program
    {
        static void Main(string[] args)
        {
            bool flag = false;
            for (int i = 0; ; i++)
            {
                string[] num = Console.ReadLine().Split();

                if (int.Parse(num[0]) == 0 && int.Parse(num[1]) == 0) return;

                for (int j = 1; j <= int.Parse(num[0]); j++)
                {

                    for (int k = 1; k <= int.Parse(num[1]); k++)
                    {
                        if (1 == j % 2 && 1 == k % 2 || 0 == j % 2 && 0 == k % 2)
                        {
                            flag = true;
                        }
                        else
                        {
                            flag = false;
                        }

                        if (flag)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");

                        }
                    }
                    Console.WriteLine("");
                }
                Console.WriteLine("");
            }
        }
    }
}



Measured memory_bytes: 17928
N,x=map(int,input().split(" "))
a=sorted(map(int,input().split(" ")))

s = 0
for j in range(N):
    i = a[j]
    if j == N - 1:
        if x == i:
            s += 1
    else:
        if x >= i:
            x -= i
            s += 1
        else:
            break

print(s)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    string o,e; cin>>o>>e;
    REP(i,o.size()+e.size()){
        if(i%2==0) cout<<o[i/2];
        else cout<<e[i/2];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;
using LL = long long;

LL compx(const vector<LL>& as, const LL a1, const LL i)
{
  return -a1 + as[i - 1] * 2;
}

int main()
{
  LL n;
  vector<LL> as;
  cin >> n;
  for (auto i = 0; i < n; ++i) {
    LL a;
    cin >> a;
    as.push_back(a);
  }

  LL a1{0};
  for (auto i = 0; i < n; ++i) {
    a1 += ((i & 1) == 0 ? +as[i] : -as[i]);
  }
  cout << a1;

  for (auto i = 1; i < n; ++i) {
    a1 = compx(as, a1, i);
    cout << ' ' << a1;
  }
  cout << '\n';
}


Measured memory_bytes: 2292
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int a, b;
  cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }
    vector<int> b;
    for (pair<int, int> i : mp) b.emplace_back(i.first);
    for (int i = 0; i < b.size(); ++i) {
        if (i == 0) cout << b[0];
        else cout << " " << b[i];
    }
    cout << endl;
}



Measured memory_bytes: 8228