akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue
#define    nl           "\n"
#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mpi map<int,int>
#define mpl map<ll,ll>
#define umpi unordered_map<int,int>
#define umpl unordered_map<ll,ll>
#define si set<int>
#define sl set<ll>
#define msi multi_set<int>
#define msl multi_set<ll>

#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define repab(i,a,b) for(int i=(a);i<=(b);i++)
#define reprab(i,a,b) for(int i=(a);i>=(b);i--)
#define repll(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,n) for(int i=(0);i<(n);i++)
#define repr(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)
#define tc int t;cin>>t;while(t--)
template<typename T> void TIME(T start, T end)
{
#ifndef ONLINE_JUDGE
    double time_taken =  chrono::duration_cast<chrono::nanoseconds>(end - start).count();
    time_taken *= 1e-9;
    cout << "\nExecuted in: " << fixed
         << time_taken << setprecision(9);
    cout << " sec";
#endif
}

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

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................


int main()
{   
     auto start = chrono::high_resolution_clock::now();
    fast
    int n;
    cin>>n;
    string s;
    map<string,int>mp;
    rep(i,n){
        cin>>s;
        mp[s]++;
    }
    cout<<"AC x "<<mp["AC"]<<nl; 
    cout<<"WA x "<<mp["WA"]<<nl; 
    cout<<"TLE x "<<mp["TLE"]<<nl; 
    cout<<"RE x "<<mp["RE"]<<nl; 
    auto end = chrono::high_resolution_clock::now();
    TIME(start, end);
    return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C_Prison
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str1 = Console.ReadLine().Split(' ');
            int N = int.Parse(str1[0]);
            int M = int.Parse(str1[1]);

            int[] L = new int[M];
            int[] R = new int[M];
            for(int i = 0; i < M; i++)
            {
                string[] str2 = Console.ReadLine().Split(' ');
                L[i] = int.Parse(str2[0]);
                R[i] = int.Parse(str2[1]);
            }

            int min = 1;
            int max = N ;

            for(int i = 0; i < M; i++)
            {
                if (min < L[i])
                {
                    min = L[i];
                }

                if (R[i] < max)
                {
                    max = R[i];
                }
            }

            if (max < min)
            {
                Console.Write("0");
            }
            else
            {
                Console.Write(max - min + 1);
            }
            
        }
    }
}


Measured memory_bytes: 15712
n = int(input())
a = [int(i) for i in input().split()]
s = sum(a)
x = [0] * n

x[0] = (s - 2 * sum((a[i] for i in range(1,n,2))))
for i in range(n-1):
    x[i+1] = (2 * a[i] - x[i])

print(*x)

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

bool is_prime(int x){
    if(x<=1)return false;
    for(int i = 2; i*i<=x;i++){
        if(x%i==0)return false;
    }
    return true;
    
}




int main(){
    
    int X;
    cin >> X;
    while(!is_prime(X))X++;
    cout<<X<<endl;
    
    
    
}
    
    



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (var s in from x in Enumerable.Range(1, 9)
                              from y in Enumerable.Range(1, 9)
                              select string.Format("{0}x{1}={2}", x, y, x * y))
            {
                Console.WriteLine(s);
            }
        }
    }
}

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

int main()
{
	int H, W, i, j;
	
	while(1)
	{
		cin >> H >> W;
		if(H == 0 && W == 0) break;
	
		for(i = 0; i < H; i++)
		{
			for(j = 0; j < W; j++)
			{
				cout << "#";
			}
			cout <<endl;
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3072
import math
H,W=map(int,input().split())
d=[H,W],[W,H]
ans=10**15
for x,y in d:
    for i in range(1,x):
        A=(x-i)*y;B=i*y
        if(i%2==0 or y%2==0):
            ans=min(ans,max(A,B//2)-min(A,B//2))
        else:
            e=[y,i],[i,y]
            for c,d in e:
                C=math.floor(c/2)*d;D=math.ceil(c/2)*d
                ans=min(ans,max(A,C,D)-min(A,C,D))
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char a;
    cin >> a;
    a++;
    cout << a << "\n";
    return 0;
}

Measured memory_bytes: 256
<?php

$count = explode(" ",trim(fgets(STDIN)));
$cnt = $count[0];
$n = $count[1];
// var_dump($cnt,$n)
$input = explode(" ",trim(fgets(STDIN)));
rsort($input);
// var_dump($input);//大きい順に並び替える

for($i=0; $i<=$n-1; $i++){//3回ループする
    $total[] = $input[$i]; 
}
echo array_sum($total);












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


int main(){
  int n;
  cin >>n;
  vector<int> x(n);
  vector<int> y(n);
  rep(i,n)cin>>x.at(i)>>y.at(i);
  vector<int> vec;
  for(int i =0;i<n;++i){
    vec.push_back(i);
  //  cout<<i<<endl;
  }

  double result = 0;
  double counter = 0;
  do{
    counter += 1.0;
    double sum = 0;
      for(int j=1; j<n; j++){
//        cout<<j<<endl;
        double dist =hypot(x.at(vec.at(j))-x.at(vec.at(j-1)),y.at(vec.at(j))-y.at(vec.at(j-1)));
//        cout<<vec.at(j);
        sum+=dist;
      }
//      cout<<endl;
//      cout<<sum<<endl;
      result += sum;
//      cout<<endl;
  }while(next_permutation(vec.begin(),vec.end()));

  result/=counter;
  cout<<setprecision(11)<<result<<endl;




}


Measured memory_bytes: 256
// Author : MohamedSameh
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <sstream>
#include <string.h>

typedef long long ll ;
// random in each run --> srand(time(NULL));

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;

int main ()
{
  int n , l ;
  scanf ("%d%d" ,&n , &l );
  int sum =0 ;
  for (int i =1 ; i <= n ;i++)
  {
    sum += l + i - 1 ;
  }
  int ans = 0 ;
  for (int i =1 ; i <= n ;i++)
  {
    int ans1 = sum ;
    ans1 -= (l + i -1 );
    if (abs (sum - ans1 ) < abs (sum - ans ))
    {
      ans = ans1 ;
    }
  }
  printf ("%d\n" ,ans ); 
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
	long long int n,m,i,j,k,l;
	cin>>n>>m;
	if(n==0) cout<<n<<endl;
	else
	{
		if(n%m==0) cout<<0<<endl;
		else
		{
			l=n/m;
			n-=m*l;
			j=abs(n-m);
			if(j<n)
			{
			k=1;
			while(k)
			{
				k=abs(j-m);
				if(k<j)
				{
					j=k;
				}
				else
				break;
			}
			cout<<j<<endl;	
			}
			else
			{
				cout<<n<<endl;
			}
		}
	
	}
}

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

using namespace std;
int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int r = 0;
	for(char& c : s)
		if(c == 'R') r++;
		else r --;
	if(r > 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

int main(void) {
  int n;cin >> n;
  int t[n];rep(i,n) cin >> t[i];
  int m;cin >> m;
  int p[m], x[m];rep(i,m) cin >> p[i] >> x[i];
  ll cnt = 0;
  rep(i,m) {
    cnt = 0;
    rep(j,n) {
      if(j == (p[i]-1)) cnt+=x[i];
      else cnt+= t[j];
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(){
	int N;
	int i, j, k, w, minj, cnt = 0;
	int A[100];
	
	scanf("%d\n", &N);
	for(i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	
	for(i = 0; i < N-1; i++){
		minj = i;
		for(j = i; j < N; j++){
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if(i != minj){
			w = A[i];
		    A[i] = A[minj];
		    A[minj] = w;
	    	cnt++;
		}
	}
		
	for(k = 0; k < N - 1; k++){
		printf("%d ", A[k]);
	}
    printf("%d\n", A[N - 1]);
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 600
import sys
from itertools import product
import numpy as np
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, M, X = map(int, readline().split())
    CA = list(list(map(int, readline().split())) for _ in range(N))
    CA = np.array(CA)
    target = [0] + [X]*M
    target = np.array(target)
    ans = INF
    for i in range(2**N):
        tmp = 0
        for j in range(N):
            if (i>>j)&1:
               tmp += CA[j]
        if np.all(tmp>=target):
            ans = min(ans, tmp[0])
    print(-1 if ans==INF else ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27308
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int N;
vector<int> d(100005);

int main(){
	cin>>N;

	for(int i=0;i<N;i++)
		cin>>d.at(i);

	d.resize(N);
	sort(d.begin(),d.end());

	cout<<d.at(N/2)-d.at((N-2)/2)<<endl;

}

Measured memory_bytes: 768
#include <iostream>

using namespace std;
int p[200010];
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> p[i];
	}
	int mn = 1000000000,cnt = 0;
	for(i=0;i<n;i++){
		if(p[i]<=mn) cnt++;
		mn = min(p[i],mn);
	}
	cout << cnt << endl;
}
		

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    int a, b, c, x, y;

    x = 0;
    scanf("%d %d %d", &a, &b, &c);
    for (y = a; y <= b; y++)

    {

        if (c % y == 0)
            x++;
    }
    printf("%d\n", x);

    return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int h[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> h[i];

    for(int i = 1; i <= n; i++) {
        if(i == 1 || h[i - 1] < h[i])
            h[i]--;
        if(i > 1 && h[i - 1] > h[i]) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
}

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

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

  string S; cin >> S;
  string T; cin >> T;
  ll A; cin >> A;
  ll B; cin >> B;
  string U; cin >> U;

  if (S == U) {
    A--;
  } else {
    B--;
  }
  cout << A << ' ' << B << '\n';
  return 0;
}

Measured memory_bytes: 256
from itertools import groupby

def main():
    N = int(input())
    a = list(map(int,input().split()))
    gp = []
    for key,value in groupby(a):
        gp.append(list(value))
    ans = 0
    for i in range(len(gp)):
        ans += len(gp[i])//2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
	int n;
  cin >> n;
  string s = "ACL";
  for(int i=0;i<n;i++){
    cout<<s;
  }
  cout<<endl;


return 0;
}
///....


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

int main() {

    string s;
    cin >> s;
    int nb = 0;
    for (int i=0,j=s.size()-1; i<s.size()/2; j--,i++)
    {
        if (s[i] != s[j]) nb++;
    }
    cout << nb;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K,S;
	while(cin>>N>>K>>S) {
		VI ans(N);
		if(K==N) {
			ans = VI(N, S);
		} else {
			ll ub = 1000000000ll;
			ans = VI(N, S==ub ? ub-1 : ub);
			REP(i, K) {
				ans[i] = S;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2160
def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    n_root = int(n**(1/2)) + 100

    c = 10 ** 18

    for i in range(1,n_root):
        if n % i == 0:
            c_new = (n // i) + i
            c = min(c_new,c)
    
    print(c - 2)



if __name__ == "__main__":
    main()

Measured memory_bytes: 38768
n, h = map(int, input().split())
a = []
b = []
for _ in range(n):
    a_i, b_i = map(int, input().split())
    a.append(a_i)
    b.append(b_i)

r = max(a)
key_b = 10**10

attack = []
for i in range(n):
    if a[i] == r:
        if b[i] < key_b:
            if key_b != 10**10:
                attack.append(key_b)
            key_b = b[i]
        else:
            attack.append(b[i])
    elif r < b[i]:
        attack.append(b[i])

ans = 0
attack.sort(reverse=True)
for bi in attack:
    if bi > key_b:
        h -= bi
        ans += 1
    elif h <= key_b:
        h -= key_b
        ans += 1
    else:
        h -= bi
        ans += 1

    if h <= 0:
        break

if 0 < h <= key_b:
    ans += 1
elif key_b < h:
    h -= key_b
    ans += 1

    if h % r == 0:
        ans += h // r
    else:
        ans += 1 + h // r

print(ans)

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

int N;
int X[110];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> X[i];

    ll ans = 1.0e15;
    for (int i = 1; i <= 100; i++) {
        ll tmp = 0;
        for (int j = 0; j < N; j++) {
            tmp += (X[j] - i) * (X[j] - i);
        }
        ans = min(tmp, ans);
    }
    cout << ans << endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[5*100000+1];
int main(){
    string s;cin>>s;
    string t,u,v;
    ll k;cin>>k;
    int n = s.size();
    vector<bool>f(n,false);
    char c = s[0];
    set<char>set;
    rep(i,n){
        set.insert(s[i]);
    }
    if(set.size()==1){
        ll r = s.size()*k/2;
        cout<<r;
        return 0;
    }
    rep(i,n){
        if(c != s[i])break;
        t.push_back(c);
        f[i] = true;
    }
    reverse(ALL(s));
    c = s[0];
    rep(i,n){
        if(f[n-i-1])break;
        if(c != s[i])break;
        v.push_back(c);
        f[n-i-1] = true;
    }
    reverse(ALL(s));
    reverse(ALL(v));
    rep(i,n){
        if(f[i])continue;
        u.push_back(s[i]);
    }
    int ts = t.size()/2;
    int us = 0;
    c = u[0];
    int cnt = 1;
    rep(i,u.size()){
        if(i==0)continue;
        if(c != u[i]){
            us += cnt/2;
            c = u[i];
            cnt = 1;
            continue;
        }
        cnt++;
    }
    us += cnt/2;
    cnt = 1;
    c = v[0];
    int vs = 0;
    rep(i,v.size()){
        if(i==0)continue;
        if(c != v[i]){
            vs += cnt/2;
            c = v[i];
            cnt = 1;
            continue;
        }
        cnt++;
    }
    vs += cnt/2;
    string vt = v+t;
    cnt = 1;
    c = vt[0];
    int vts = 0;
    rep(i,vt.size()){
        if(i==0)continue;
        if(c != vt[i]){
            vts += cnt/2;
            c = vt[i];
            cnt = 1;
            continue;
        }
        cnt++;
    }
    vts += cnt/2;
    ll res = ts+us*k+vts*(k-1)+vs;
    cout<<res;
}



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




int main() {
  int v[5];
  for (int i = 0; i < 5; i++) {
    cin >> v[i];
  }

  int minIdx = -1;
  int minRest = 10;
  for (int i = 0; i < 5; i++) {
    if(v[i]%10!=0 && v[i]%10<minRest) {
      minIdx = i;
      minRest = v[i]%10;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < 5; i++) {
    if(i==minIdx) {
      ans += v[i];
      continue;
    }
    ans += ((v[i]+10-1)/10)*10;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<algorithm>
#include<functional>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<iostream>
#include<string>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define REP(i,x) for (int i=0;i<x;i++)
#define REPP(i,x,y) for (int i=x;i<=y;i++)
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define MX3(x,y,z) max({x,y,z})
#define MX4(x,y,z,p) max({x,y,z,p})
#define MX5(x,y,z,p,q) max({x,y,z,p,q})
#define MN3(x,y,z) min({x,y,z})
#define MN4(x,y,z,p) min({x,y,z,p})
#define MN5(x,y,z,p,q) min({x,y,z,p,q})
#define amax(x,y) x=max(x,y)
#define amin(x,y) x=min(x,y)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef tuple<int,int,int> ti;
typedef tuple<ll,ll,ll> tl;
// #####################################################################

const int MAX = 100000 + 10;

vector<pair<int,int>> v[MAX];
bool vis[MAX];
int ans[MAX];
int kk = 0;

void dfs(int x, int last) {

    vis[x] = true;
    int now = 1;
    for(int i = 0 ; i < v[x].size() ; i++) {
        if(vis[v[x][i].first]) continue;
        if(now == last) now++;
        ans[v[x][i].second] = now;
        amax(kk, now);
        dfs(v[x][i].first, now);
        now++;
    }

}

void solve() {

    int n;
    SI(n);
    REP(i, n-1) {
        int x, y;
        SI(x); SI(y);
        v[x].push_back(make_pair(y, i));
        v[y].push_back(make_pair(x, i));
    }

    dfs(1, -1);

    printf("%d\n", kk);
    REP(i, n-1) {
        printf("%d\n", ans[i]);
    }

}

void init() {
    


}

int main () {
    init();
    solve();
    return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>


int solve(int,int);
int A[2000],n;

int main(){
  int q,M[2000],i,j,k;
  
  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0 ; i<q ; i++){
    scanf("%d",&M[i]);
  }
  
  for(i=0 ; i<q ; i++){
    if(solve(0,M[i]) == 1){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
}

int solve(int i,int m){
  int res;
  if(m==0) return 1;
  if(i>=n) return 0;
  res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;
}



Measured memory_bytes: 2108
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    auto S = sread();
    writeln(S[0 .. 4], " ", S[4 .. $]);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD =  1000000007;
const int INF = 1e11;
using Graph = vector<vector<int>>;

signed main(){
  int N, X, M;
  cin >> N >> X >> M;

  vector<int> kou;
  set<int> num;
  kou.push_back(X);
  num.insert(X);
  int ans = 0;

  for( int i = 1; i < N; i++ ){
    int A = kou[i-1]*kou[i-1];
    A %= M;
    int ichi = 0;
    if( num.count(A) ){
      //繰り返しの前
      for( int j = 0; j < kou.size(); j++ ){
        if( kou[j] == A ){
          ichi = j;
          break;
        }
        ans += kou[j];
      }

      //繰り返し部分の合計
      int roop = 0;
      for( int j = ichi; j < kou.size(); j++ ){
        roop += kou[j];
      }
      ans += (N-ichi)/(kou.size()-ichi)*roop;
      //余り
      int amari = (N-ichi)%(kou.size()-ichi);
      for( int j = ichi; j < ichi+amari; j++ ) ans += kou[j];
      cout << ans << endl;
      return 0;
    }else{
      num.insert(A);
      kou.push_back(A);
    }
  }

  for( int i = 0; i < kou.size(); i++ ) ans += kou[i];
  cout << ans << endl;
}

Measured memory_bytes: 5868
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(1, n - 1):
    if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i+1] < p[i] and p[i] < p[i-1]):
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
int W,H,N,p,q,r,s,a[500][501],b[501][500],d[501][501],inf=1e9;//W,H
int main(){
	cin>>W>>H>>N;
	cin>>p>>q>>r>>s;
	rep(i,N){
		int x,y,T;
		cin>>x>>y>>T;
		string st;
		cin>>st;
		rep(tt,T){
			rep(j,st.size()){
				if(st[j]=='R'){
					if(x+1>=W) continue;
					b[x+1][y]++;
					x++;
				}else if(st[j]=='D'){
					if(y+1>=H) continue;
					a[x][y+1]++;
					y++;
				}else if(st[j]=='L'){
					if(x-1<0) continue;
					b[x][y]++;
					x--;
				}else{
					if(y-1<0) continue;
					a[x][y]++;
					y--;
				}
			}
		}
	}
	priority_queue<PP,vector<PP>,greater<PP> > que;
	rep(i,W+1) rep(j,H+1) d[i][j]=inf;
	que.push(PP(0,P(p,q)));
	d[p][q]=0;
	while(!que.empty()){
		PP pp=que.top();
		que.pop();
		int x=pp.sc.fs,y=pp.sc.sc;
		if(d[x][y]!=pp.fs) continue;
		if(x+1<=W&&d[x+1][y]>d[x][y]+a[x][y]){//R
			d[x+1][y]=d[x][y]+a[x][y];
			que.push(PP(d[x+1][y],P(x+1,y)));
		}
		if(x-1>=0&&d[x-1][y]>d[x][y]+a[x-1][y]){//L
			d[x-1][y]=d[x][y]+a[x-1][y];
			que.push(PP(d[x-1][y],P(x-1,y)));
		}
		if(y+1<=H&&d[x][y+1]>d[x][y]+b[x][y]){//D
			d[x][y+1]=d[x][y]+b[x][y];
			que.push(PP(d[x][y+1],P(x,y+1)));
		}
		if(y-1>=0&&d[x][y-1]>d[x][y]+b[x][y-1]){//U
			d[x][y-1]=d[x][y]+b[x][y-1];
			que.push(PP(d[x][y-1],P(x,y-1)));
		}
	}
	cout<<d[r][s]<<endl;
/*	rep(x,W) rep(y,H){
		cout<<"("<<x<<","<<y<<")\n";
		cout<<"R:"<<b[x+1][y]<<endl;
		cout<<"L:"<<b[x][y]<<endl;
		cout<<"D:"<<a[x][y+1]<<endl;
		cout<<"U:"<<b[x][y]<<endl;
	}*/
}

Measured memory_bytes: 8360
N = int(input())
pre_t = 0
pre_x = 0
pre_y = 0
for i in range(N):
    t,x,y = map(int, input().split())
    if (t%2)+(x+y)%2 == 1 or x+y > t or abs(pre_x-x)+abs(pre_y-y) > (t-pre_t):
        print("No")
        exit()
    pre_t = t
    pre_x = x
    pre_y = y
print("Yes")

Measured memory_bytes: 45672
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define REP1(i,n) for(long long i=1;i<=(n);i++)
#define REP2D(i,j,h,w) for(long long i=0;i<(h);i++) for(long long j=0;j<(w);j++)
#define REP2D1(i,j,h,w) for(long long i=1;i<=(h);i++) for(long long j=1;j<=(w);j++)
#define PER(i,n) for(long long i=((n)-1);i>=0;i--)
#define PER1(i,n) for(long long i=(n);i>0;i--)
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define FORE(i,a,b) for(long long i=(a);i<=(b);i++)
#define ITE(arr) for(auto ite=(arr).begin();ite!=(arr).end();++ite)
#define ALL(a) ((a).begin()),((a).end())
#define RANGE(a) (a),((a)+sizeof(a))
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define YNPRT(b) cout<<((b)?"Yes":"No")<<endl
#define ENTER printf("\n")
#define REV(arr) reverse(ALL(arr))
#define PRT(a) cout<<(a)<<endl

#ifdef DEBUG
#define DBPRT(a) cout << "[Debug] - " << #a << " : " << (a) << endl
#define DBSTART if(1){
#define DBEND }
#define PRTLST(arr,num) REP(_i,num) cout<<_i<<" - "<<arr[_i]<<endl;
#define PRTLST2(arr2,d1,d2) REP(_i,d1) REP(_j,d2) cout<<_i<<","<<_j<<" : "<<arr2[_i][_j]<<endl;
#define PRTLST2D(arr2,d1,d2) do{cout<<"L\t";REP(_i,d2) cout<<_i<<"\t"; cout<<endl; REP(_i,d1){cout<<_i<<"\t";REP(_j,d2){cout<<arr2[_i][_j]<<"\t";}cout<<endl;}}while(0);
#else
#define DBPRT(a) if(0){}
#define DBSTART if(0){
#define DBEND }
#define PRTLST(arr,num) if(0){}
#define PRTLST2(arr2,d1,d2) if(0){}
#define PRTLST2D(arr2,d1,d2) if(0){}
#endif

#define TOSUM(arr,sum,n) {sum[0]=arr[0];REP1(i,n-1) sum[i]=sum[i-1]+arr[i];}

#define MIN(target,v1) (target)=min(target,v1)
#define MAX(target,v1) (target)=max(target,v1) 
#define P1 first
#define P2 second
#define PB push_back
#define UB upper_bound
#define LB lower_bound
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ull INF_ULL = 18446744073709551615Ull;
const ll P = 92540646808111039LL;
const int Move[4][2] = {-1,0,0,1,1,0,0,-1};
const int Move_[8][2] = {-1,0,-1,-1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p) {os<<"( "<<p.P1<<" , "<<p.P2<<" )";return os;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {ITE(v) os << (ite-v.begin()) << " : " << *ite <<endl;return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v) {os<<" { ";ITE(v) {os<<*ite;if(ite!=--v.end()){os<<" , ";}} os<<" } ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& m) {ITE(m) {os<<ite->P1<<"\t\t|->\t\t"<<ite->P2<<endl;} return os;}

//---------------------
#define MAXN 100000
//---------------------

ll n,m;


int main(){
	cin >> n >> m;
	YNPRT(n==m);
	return 0;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
  
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double


#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
  
typedef long long int ll;
  
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll MAXN=1000001;
const ll MAX_LOG=30;
ll power(ll x, ll n) {
      ll res = 1;
      for (; n > 0; n >>= 1) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
      }
      return res;
}

int main()
{
    
  IOS
  ll n;
  cin>>n;
  pll a[15][15];
  ll s[n];
  for(ll i=0;i<n;i++)
  {
    cin>>s[i];
    for(ll j=0;j<s[i];j++)
    {
      cin>>a[i][j].ff>>a[i][j].ss;
      a[i][j].ff--;
    }
  }
  // for(ll i=0;i<n;i++,cout<<endl)
  //   for(ll j=0;j<s[i];j++)
  //     cout<<a[i][j]<<" ";
  ll ans=0;
  for(ll mask=0;mask<(1ll<<n);mask++)
  {
    bool check=true;
    for(ll i=0;i<n;i++)
    {
      if(mask>>i&1ll)
      {
        for(ll j=0;j<s[i];j++)
          if((1ll&(mask>>(a[i][j].ff)))!=a[i][j].ss)
            { 
              check=false;}
      }
    }
    if(check)
      ans=max(ans,ll(__builtin_popcount(mask)));
  }
  cout<<ans<<endl;
  

    
  
  
} 
    


  
	

 

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

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

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll a,b,c,k; cin >> a >> b >> c >> k;
  
  rep(i,k){
    if(a >= b){
      b *= 2;
      continue;
    }
    
    if(b >= c){
      c *= 2;
      continue;
    }
  }
  
  if(a < b and b < c) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

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

		String str[] = br.readLine().split(" ");

		long a = Long.parseLong(str[0]);
		long b = Long.parseLong(str[1]);
		long c = Long.parseLong(str[2]);
		long d = Long.parseLong(str[3]);

		if (b < 0 && d < 0) {
			System.out.println(a * c);
		} else if (a > 0 && c > 0) {
			System.out.println(b * d);
		} else {
			long A = a * c;
			long B = b * d;
			long C = a * d;
			long D = b * c;

			long max = Long.MIN_VALUE;
			max = Math.max(max, A);
			max = Math.max(max, B);
			max = Math.max(max, C);
			max = Math.max(max, D);
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 32620
#include <iostream>
#include <vector>
using namespace std;
int main(){
  string a,b,c;
  cin >> a >> b >> c;
  char card = 'a';
  string* now = &a;
  while(true){
    if(card == 'a')
      now = &a;
    else if (card == 'b')
      now = &b;
    else
      now = &c;
    if(now->empty()) break;
    card = now->front();
    now->erase(now->begin());
  }
  char v;
  if(card == 'a')
    v = 'A';
  else if (card == 'b')
    v = 'B';
  else
    v = 'C';
  cout << v << endl;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = []

for i in range(N):
    if i == 0:
        A.append(B[i])
    elif i == N - 1:
        A.append(B[i-1])
    else:
        A.append(min(B[i-1], B[i]))

print(sum(A))

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

int main() {
    int n, m;
    cin >> n >> m;
    auto a = vector<int>(m);
    for (auto &a_i : a)
        cin >> a_i;
    auto tot = accumulate(a.begin(), a.end(), 0LL);
    if (tot > n)
        cout << -1;
    else
        cout << (n - tot);

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
using namespace std;

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

const long long INF = 1LL << 60;
const int dp_max = 100100;

// 入力
int n, m;
vector<vector<int>> G;

int dp[dp_max];
int rec(int v){
  if(dp[v] != -1) return dp[v];

  int res = 0;
  for(auto nv : G[v]){
    chmax(res,rec(nv) + 1);
  }
  return dp[v] = res;
}

int main() {
  cin >> n >> m;
  G.assign(n, vector<int>());
  for (int i = 0; i < m; i++){
    int x, y;
    cin >> x >> y;
    x--, y--;
    G[x].push_back(y);
  }

  for (int v = 0; v < n; v++) dp[v] = -1;

  int res = 0;

  for (int v = 0; v < n; v++) chmax(res, rec(v));

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 8192
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}

int main(void) {
    int N;
    vector<int> p;
    
    cin>>N;
    
    for(int i = 0;i < N;i++) {
        int temp;
        cin>>temp;
        p.push_back(temp);
    }

    sort(p.begin(),p.end(),greater<int>());

    Int sum = 0;
    sum = p[0]/2;
    for(int i = 1;i < N;i++) {
        sum += p[i];
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>
#include <numeric>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<30)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  ll A[1001000];
  ll t;
  for(int i=0;i<N;i++){
    cin >> t;
    A[i]=t;
  }
  sort(A,A+N);
  ll ans=A[0];
  for(int i=1;i<N;i++){
    ans=gcd(ans,A[i]);
    if(ans==1LL)break;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <list>
#include <map>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    ll N;
    cin >> N;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    map<ll, ll> mp_even;
    map<ll, ll> mp_odd;

    for(int i = 0; i < N; i++){
        if(i % 2 ){
            mp_odd[v[i]] ++;
        }
        else{
            mp_even[v[i]] ++;
        }
    }

    sort(all(v));
    ll ans = 0;
    for(int i = 0; i < N; i++){
        if(i % 2){
            if( mp_even[v[i]] ) ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 10368
#pragma GCC optimize "Ofast"
#pragma GCC optimize "unroll-loops"
#pragma GCC target "sse,sse2,sse3,sse4,abm,avx,mmx,popcnt,tune=native"
#include <bits/stdc++.h>
#define scan(x) do{while((x=getchar_unlocked())<'0'); for(x-='0'; '0'<=(_=getchar_unlocked()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
#define ll long long
#define MAXM 1010
#define MAXN 5010
#define INF 0x3f3f3f3f
#define min(a, b) (a) < (b) ? (a) : (b)
#define max(a, b) (a) < (b) ? (b) : (a)
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
#define mii map<int, int>
#define umii unordered_map<int, int>
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
using namespace std;

int A, B;

int main (int argc, char const *argv[]) {
	#ifdef NOT_DMOJ
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif // NOT_DMOJ
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
cin >> A >> B;
cout << (A * B - (B + A - 1)) << "\n";
	return 0;
}

/* 
 * Look for:
 * the exact constraints (multiple sets are too slow for n=10^6 :( ) 
 * special cases (n=1?)
 * overflow (ll vs int?)
 * array bounds
 */

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void c_write_and_erase(void) {
	int n;
	cin >> n;
	map<long long, int>a;
	long long ain;
	for (int i = 0; i < n; i++) {
		cin >> ain;
		if (a.count(ain)) {
			a[ain]++;
		}
		else {
			a.insert(make_pair(ain, 1));
		}
	}

	int cnt = 0;
	map<long long, int>::iterator aptr = a.begin();
	for (aptr; aptr!=a.end(); aptr++) {
		if ((aptr->second) % 2 == 1) cnt++;
	}

	cout << cnt << endl;
}

int main()
{
    c_write_and_erase();
    return 0;
}

Measured memory_bytes: 9736
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<=n;i++)
int main(){
    int a,b,c,x;cin>>a>>b>>c>>x;
    int ans = 0;
    fol(i,a){
        fol(j,b){
            fol(k,c){
                if (500*i+100*j+50*k==x) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	string S;
	cin >> S;
	if (S.length() == 2) {
		cout << S;
	}
	else {
		for (int i = 2; i >= 0; i--) {
			cout << S[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
constexpr int64_t MOD = 1e9 + 7;

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

  string S;
  int K;
  cin >> K;
  cin >> S;
  int len = S.size();
  if (len <= K) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3640
/*
 *      ┌─┐       ┌─┐ + +
 *   ┌──┘ ┴───────┘ ┴──┐++
 *   │                 │
 *   │       ───       │++ + + +
 *   ███████───███████ │+
 *   │                 │+
 *   │       ─┴─       │
 *   │                 │
 *   └───┐         ┌───┘
 *       │         │
 *       │         │   + +
 *       │         │       Code is far away from bug with the animal protecting
 *       │         └──────────────┐
 *       │                        │
 *       │                        ├─┐
 *       │                        ┌─┘
 *       │                        │
 *       └─┐  ┐  ┌───────┬──┐  ┌──┘  + + + +
 *         │ ─┤ ─┤       │ ─┤ ─┤
 *         └──┴──┘       └──┴──┘  + + + +
 *                神兽保佑
 *               代码无BUG!
 */

#include<bits/stdc++.h>
using namespace std;
class IN{
public:
    template<typename T>
    IN& operator >>(T &x){read(x);return *this;}
    IN& operator >>(double &x){scanf("%lf",&x);return *this;}
    IN& operator >>(char *s){scanf("%s",s);return *this;}
    IN& operator >>(char &c){c=getchar();return *this;}
private:
    template<typename T>
    void read(T &x){
        T f=1;int c=getchar();x=0;
        while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
        while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
        x*=f;
    }
}in;
class NL{}nl;
class BK{}bk;
class OUT{
public:
    template<typename T>
    OUT& operator <<(T x){write(x);return *this;}
    OUT& operator <<(const char *s){printf("%s",s);return *this;}
    OUT& operator <<(char c){putchar(c);return *this;}
    OUT& operator <<(BK x){putchar(' ');return *this;}
    OUT& operator <<(NL x){putchar('\n');return *this;}
private:
    template<typename T>
    void write(T x){
        if(x<0)putchar('-'),x=-x;
        if(x>=10)write(x/10);
        putchar(x%10+48);
    }
}out;

#define pb(x) push_back(x)
#define fi first
#define se second
#define rep(i,a,n) for(int i=a;i<=n;++i)
#define per(i,n,a) for(int i=n;i>=a;--i)
#define mem(a,x) memset(a,x,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;
/*****************************************************************************************************/
ll Pow(ll a,ll b,ll mod){ll res=1;a%=mod;while(b){if(b&1)(res*=a)%=mod;(a*=a)%=mod;b>>=1;}return res%mod;}
ll inv(ll a,ll p){if(a==1)return 1;return (p-p/a)*inv(p%a,p)%p;}//p为素数,a<p
ll C(ll n,ll m,ll p){ll res=1;for(ll i=1,j=n-m+1;i<=m;++i,++j){res=res*inv(i,p)%p*j%p;}return res;}
/*****************************************************************************************************/
/*ll ask(int x){ll res=0;while(x)res+=c[x],x-=x&-x;return res;}
void add(ll v,int x){while(x<=n)c[x]+=v,x+=x&-x;}*/
const int p=1e9+7;
const int N=2e5+10;

int main(){
    int x;in>>x;
    if(x>=30)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3612
//QWsin
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

int cal(ll x){
	int ret=0;
	while(x) ++ret,x/=10;
	return ret;
}
int main()
{
	ll n;cin>>n;
	for(ll k=sqrt(n);;--k)
		if(n%k==0){
			printf("%d\n",cal(n/k));return 0;	
		}
	return 0;
}


Measured memory_bytes: 256