akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

const int MAX = 2e6+1;

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if(n >= MAX){
    ll tmp = 1;
    rep(i,k){
      tmp *= (n-i);
      tmp %= MOD;
    }
    return tmp*finv[k]%MOD;
  }

  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll POW(ll x, ll n){
  ll ret = 1;

  if(n < 0){// n < 0 にも対応
    n *= -1;
    x = inv[x];
  }

  while(0 < n){
    if(n%2 == 0){
      x = x*x%MOD;
      n /= 2;
    }
    else{
      ret = ret*x%MOD;
      n--;
    }
  }

  return ret;
}

vi MP(string s){
  vi A(s.size()+1);
  A[0] = -1;
  int j = -1;
  rep(i,s.size()) {
    while(j >= 0 && s[i] != s[j]) j = A[j];
    j++;
    A[i+1] = j;
  }
  return A;
}

vi Manacher(string s){
  vi R(s.size());
  int i = 0, j = 0;
  while(i < s.size()){
    while(i-j >= 0 && i+j < s.size() && s[i-j] == s[i+j]) ++j;
    R[i] = j;
    int k = 1;
    while(i-k >= 0 && i+k < s.size() && k+R[i-k] < j) R[i+k] = R[i-k], k++;
    i += k; j -= k;
  }
  return R;
}

vi Z_algorithm(string &s){
  vi Z(s.size());
  Z[0] = s.size();
  int i = 1, j = 0;
  while(i < s.size()){
    while(i+j < s.size() && s[j] == s[i+j]) j++;
    Z[i] = j;
    if(j == 0){++i; continue;}
    int k = 1;
    while(i+k < s.size() && k+Z[k] < j) Z[i+k] = Z[k], ++k;
    i += k; j -= k;
  }
  return Z;
}

ll f(int r,int c){
  return COM(r+c,r);
}

ll F(int r,int c){
  ll res = 0;
  for(int x = 1; x <= r+1; x++) {
    res += f(x,c);
    res %= MOD;
  }
  return res;
}

int main(){
  int r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;
  COMinit();
  ll ans = (F(r2,c2)-F(r2,c1-1)-F(r1-1,c2)+F(r1-1,c1-1))%MOD;
  while(ans < 0) ans += MOD;
  cout << ans << endl;
}


Measured memory_bytes: 47104
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}
int main()
{
    size_t N;
    std::cin >> N;

    int64_t sumA, sumB;
    sumA = sumB = 0;

    std::vector<int64_t> A, B;
    for (size_t i = 0; i < N; ++i) {
        int64_t a;
        std::cin >> a;
        sumA += a;
        A.push_back(a);
    }
    for (size_t i = 0; i < N; ++i) {
        int64_t b;
        std::cin >> b;
        sumB += b;
        B.push_back(b);
    }

    const auto opsCount = sumB - sumA;

    int64_t opsA2, opsB1;
    opsA2 = opsB1 = 0;
    for (size_t i = 0; i < N; ++i) {
        if (A[i] < B[i]) {
            // Aに2を足す操作必要
            opsA2 += ceil<int64_t>(B[i] - A[i], 2LL);
            if (B[i] < ceil<int64_t>(B[i] - A[i], 2LL)) {
                // 行き過ぎるのでBiも1回足す必要あり
                opsB1++;
            }
        }
        else if (A[i] > B[i]) {
            // Bに1足す操作必要
            opsB1 += A[i] - B[i];
        }
    }

    if (opsA2 <= opsCount && opsB1 <= opsCount) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }

    return 0;
}


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

int main(){
  int H, N;
  int A[110000];
  cin >> H >> N;
  for (int i = 0; i < N; i++){
   cin >> A[i];
   H -= A[i];
  }

  if (H <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" <<endl;
  }
 }


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var answer float64 = 0.0
	for i := 0; i < n; i++ {
		var a float64
		fmt.Scan(&a)
		answer += 1.0 / a
	}
	answer = 1.0 / answer
	fmt.Println(answer)
}


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

#define ll long long
using namespace std;

int main() {
	ll sm = 0;
	int n; cin >> n;
	for (int i=1; i<=n; i++) {
		int start = i;
		int end = n-(n%i);
		int cnt = (end-start)/i+1;
		sm += (ll)(start+end)*(ll)cnt/2;
	}
	cout << sm;
}


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

int main() {
	int N,M;
	cin >> N >> M;
	vector<string> A(N),B(M);

	rep(i,N)
		cin >> A.at(i);
	rep(i,M)
		cin >> B.at(i);
	
	rep(i,N-M+1)
		rep(j,N-M+1) {
			rep(k,M)
				rep(l,M)
					if(B.at(k).at(l) != A.at(i+k).at(j+l))
						goto NO;

			cout << "Yes" << endl;
			return 0;

			NO:
			;
		}

	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#include <bitset>
#define M 1000000007
#define M1 998244353

#define tr(container, it) \
for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define fast                        \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL);

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

ll power(ll x, ll n)
{
    ll result = 1;
    while (n)
    {
        if (n % 2 == 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}

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

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

inline ll mul(ll x, ll y, ll m)
{
    ll z = 1LL * x * y;
    if (z >= m)
    {
        z %= m;
    }
    return z;
}

ll powmod(ll x, ll y, ll m)
{
    ll r = 1;
    while (y)
    {
        if (y & 1)
        {
            r = mul(r, x, m);
        }
        y >>= 1;
        x = mul(x, x, m);
    }
    return r;
}



void start()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
/***********************************************************************************************************/

int main()
{
    start();
    int n, m;
    cin>>n>>m;
    int a[n+1][n+1];
    memset(a, 0, sizeof(a));
    for (int i=0;i<m;i++)
    {
        int x, y;
        cin>>x>>y;
        a[x][y]++;
        a[y][x]++;
    }
    for (int i=1;i<=n;i++)
    {
        int c=0;
        for (int j=1;j<=n;j++)
        {
            if (a[i][j])
            {
                c+=a[i][j];
            }
        }
        cout<<c<<"\n";
    }
    return 0;
}

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

// 小数点以下桁数
// fixed << setprecision(i)

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

int main()
{
  int n, a;
  vector<int> vec(100000);

  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a;
    vec[a - 1] = i + 1;
  }
  for (int i = 0; i < n; i++)
  {
    cout << vec[i];
    if (i != n - 1)
      cout << ' ';
    else
      cout << endl;
  }
}

Measured memory_bytes: 3744
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 100000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;
int N;
int S = 0;
int num[100000];
int mainasu = 0;
int least = 1000000001;
int ans = 0;

signed main(void) {
    cin >> N;
    rep(i,N){
        int a;
        cin >> a;
        if(a>0){
            num[i] = a;
            ans += a;
            if(a < least) {
                least = a;

            }

        }
        if(a <0){
            num[i] = -a;
            ans += -a;
            mainasu++;
            if(-a < least){
                least = -a;

            }

        }

        if(a== 0){
            S=i+1;
            mainasu=0;
            least = 1000000001;
        }
    }

//    cout << mainasu << endl;

    if(mainasu%2==0){
        cout << ans << endl;
    }else{
        cout << ans - 2*least << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
class card:
    def __init__(self, types, value):
        self.types = types
        self.value = value

def bubbleSort(A, N):
    for i in range(0, N):
        for j in range(N - 1, i, -1):
            if A[j].value < A[j - 1].value:
                exchange(A, j - 1, j)
    printCards(A)
    print "Stable"

def selectionSort(A, N):
    origin = A[:]
    for i in range(0, N):
        minj = i
        for j in range(i, N):
            if A[j].value < A[minj].value:
                minj = j
        if i != minj:
            exchange(A, i, minj)
    printCards(A)
    if checkStable(origin, A, N):
        print "Stable"
    else:
        print "Not stable"

def exchange(array, i, j):
    tmp = array[i]
    array[i] = array[j]
    array[j] = tmp

def printCards(cards):
    print " ".join(t.types + str(t.value) for t in cards)

def checkStable(origin, sorted, N):
    for i in range(0, N - 1):
        if sorted[i].value == sorted[i + 1].value:
            if origin.index(sorted[i]) > origin.index(sorted[i + 1]):
                return False
    return True

if __name__ == "__main__":
    N = input()
    A = [card(c[0], int(c[1])) for c in raw_input().split()]
    bubbleSort(A[:], N)
    selectionSort(A[:], N)

Measured memory_bytes: 6364
result = list()
while(True):
    n,x = map(int,input().split())
    count = 0
    if n==x and n==0:
        break
    
    if x /3 > n-1:
        print("0")
        continue
    if x - 2*n+1 >0 :
        start = x-2*n+1
    else :
        start = 1
    flag = 0
    for i in range(start,n):
        for j in range(i+1,n):
            if x - i - j <= j:
                break
            if x-i-j <= n:
                count +=1 
        
    print(count)


Measured memory_bytes: 5596
#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define re register int
#define db double
#define in inline
namespace fast_io
{
	char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0;
	in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
	in int read()
	{
		re x=0,y=1;while(nc=gc(),(nc<48||nc>57)&&nc!=-1)if(nc==45)y=-1;Bi=1;
		x=nc-48;while(nc=gc(),47<nc&&nc<58)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*y;
	}
	in db gf() {re a=read(),b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi):a);}
	in int gs(char *s) {char c,*t=s;while(c=gc(),c<32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
	in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
	in void flush() {if(C>1<<22) ot();}
	template <typename T>
	in void write(T x,char t)
	{
		re y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
		if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
	}
	in void write(char *s) {re l=strlen(s);for(re i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=1e5+5,M=1e6+5;
char s[N];
int n,m,k,p;
ll ans,res;
int main()
{
	n=gs(s+1);k=read();
	for(re i=1;i<=n;i++)
	{
		if(s[i]==p) res++;
		else
		{
			if(res&&!m) m=res;
			ans+=(ll)k*(res>>1);p=s[i];res=1; 
		} 
	}
	if(res==n) ans=(ll)k*n>>1;
	else
	{
		if(s[n]==s[1])
		{
			ans-=(ll)(m>>1)*(k-1);
			ans+=(ll)((m+res)>>1)*(k-1)+(res>>1);
		}
		else ans+=(ll)(res>>1)*k;
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233
//In my dream's scene,I can see the everything that in Cyaegha.

Measured memory_bytes: 256
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

class Main {

    static final int MOD = 1000000007;
    static ArrayList<Node> nodeList = new ArrayList<Node>();

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final int Q = sc.nextInt();
        for (int i = 0; i < N; i++) {
            nodeList.add(new Node(i));
        }

        for (int i = 1; i < N; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            nodeList.get(b - 1).parent = nodeList.get(a - 1);
            // nodeList.get(a - 1).addEdge(nodeList.get(b - 1));
        }

        for (int i = 0; i < Q; i++) {
            int p = sc.nextInt();
            int x = sc.nextInt();
            nodeList.get(p - 1).count += x;
        }

        for (int i = 0; i < N; i++) {
            System.out.print(nodeList.get(i).checkParent() + " ");
        }
        System.out.println();
    }
}

class Node {
    final int number;
    int count = 0;
    long finalCount = -1;
    Node parent;
    boolean isLeaf = true;

    Node(int number) {
        this.number = number;
    }

    long checkParent() {
        long sum = 0;
        Node tmp = this;
        while (tmp != null) {
            if (tmp.finalCount >= 0){
                sum += tmp.finalCount;
                finalCount = sum;
                return sum;
            }
            sum += tmp.count;
            tmp = tmp.parent;
        }
        finalCount = sum;
        return sum;
    }
}

Measured memory_bytes: 175596
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 1000000007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

int n, m;
ll A = 0, B = 0;
vector<int> V[maxn];
int c[maxn];
int have = 0, dem = 0;

void go(int u, int color){
	c[u] = color;
	dem++;
	Rep(i, sz(V[u])){
		int v = V[u][i];
		if(c[v] == -1){
			go(v, 1 - color);
		} else{
			if(c[v] != 1 - color){
				have = 1;
//				return;
			}
		}
	}
}

int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);

	cin >> n >> m;
	Rep(run, m){
		int u, v;
		cin >> u >> v;
		V[u].pb(v);
		V[v].pb(u);
	}

	ms(c, -1);
	ll res = 0, C = 0;
	For(i, 1, n) if(c[i] == -1){
		have = 0; dem = 0;
		go(i, 0);
		if(dem == 1) C++;
		else if(have) B++;
		else A++;
	}
//	cout << A << " " << B << endl;
	res += C * C + C * (n - C) * 2;
	res += A * 2 + B + A * (A - 1) * 2 + 2 * A * B + B * (B - 1);
	cout << res << endl;

    return 0;
}


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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); 
	cout.tie(NULL);
	
	ll n;
	cin>>n;
	ll a[n];
	ll p=0;
	for(int i=0;i<n;i++)
	{cin>>a[i];
	if(i%2==0&&a[i]%2!=0)
	p++;
	}
	cout<<p;
	
	return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>
i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;

//メモリ置き場
int a, b;

//inputします
void input() {
    cin >> a >> b;
}

//ライブラリ置き場



//main
int main() {
    input();
    int ans=0;
    if (a > 5)ans = b / 2;
    if (a > 12)ans = b;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

vector<int> Eratosthenes( const int N )
{
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int A[N];
  rep(i,N)
    cin >> A[i];
  map <int,int> F;
  
  int P[168];
  int count = 0;
  for( const auto &p: Eratosthenes(1000) ){
    P[count] = p;
    count ++;
  }
  
  rep(i,N){
    rep(j,168){
      if (A[i]<P[j])
        break;
      if (A[i]%P[j] != 0)
        continue;
      while (A[i]%P[j] == 0)
        A[i] /= P[j];
      F[P[j]] ++;
    }
    if (A[i] != 1)
      F[A[i]] ++;
  }
  
  int res = 0;
  for (const auto& [key, value] : F){
    res = max(res,value);
  }
  
  
  if (res <= 1)
    cout << "pairwise coprime" << endl;
  else if (res == N)
    cout << "not coprime" << endl;
  else
    cout << "setwise coprime" << endl;
}

Measured memory_bytes: 11096
A,B,C=map(int, input().split())
K=int(input())

s=0

for i in range(100):
    if B <= A:
        B = B*2
        s = s + 1
    else:
        break

for i in range(100):
    if C <= B:
        C = C*2
        s = s + 1
    else:
        break

if s > K:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9192
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &k)

	var ans bool
	for i := 0; i < k; i++ {

		if b >= c {
			c = c * 2
		} else if a >= b {
			b = b * 2
		}

		if a < b && b < c {
			ans = true
			break
		}
	}

	if ans == true {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

Measured memory_bytes: 1832
#include <stdio.h>
int main(void) {
	int n, arr[100], i, sum=0, cnt=0, num, result=0, result1=0;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		scanf("%d", &arr[i]);
		sum += arr[i];
		cnt++;
	}
	if(sum%cnt==0){
		num = sum / cnt;
		for(i=0; i<n; i++)
			result += (arr[i]-num)*(arr[i]-num);
	}
	else{
		num = sum / cnt;
		for(i=0; i<n; i++)
			result += (arr[i]-num)*(arr[i]-num);
		num = num + 1;		
		for(i=0; i<n; i++)
			result1 += (arr[i]-num)*(arr[i]-num);	
		if(result>result1)
			result = result1;
	}
	printf("%d", result);
	return 0;
}

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

int keisann(vector<int>& a_retu, vector<vector<int>>& abcd)
{
	int ret = 0;
	for (auto abcd_ele : abcd) {
		int a = abcd_ele.at(0);
		int b = abcd_ele.at(1);
		int c = abcd_ele.at(2);
		int d = abcd_ele.at(3);
		if (a_retu.at(b - 1) - a_retu.at(a - 1) == c) {
			ret += d;
		}
	}
	return ret;
}

int main()
{
	int n, m, q;
	cin >> n >> m >> q;
	vector<vector<int>> abcd(q);
	for (int i = 0; i < q; i++) {
		int a_in, b_in, c_in, d_in;
		cin >> a_in >> b_in >> c_in >> d_in;
		abcd.at(i) = {a_in, b_in, c_in, d_in};
	}

	int ans = 0;
	vector<int> a(10, 1);
	for (int i0 = 1; i0 <= m; i0++) {
		a.at(0) = i0;
		for (int i1 = i0; i1 <= m; i1++) {
			a.at(1) = i1;
			for (int i2 = i1; i2 <= m; i2++) {
				a.at(2) = i2;
				for (int i3 = i2; i3 <= m; i3++) {
					a.at(3) = i3;
					for (int i4 = i3; i4 <= m; i4++) {
						a.at(4) = i4;
						for (int i5 = i4; i5 <= m; i5++) {
							a.at(5) = i5;
							for (int i6 = i5; i6 <= m; i6++) {
								a.at(6) = i6;
								for (int i7 = i6; i7 <= m; i7++) {
									a.at(7) = i7;
									for (int i8 = i7; i8 <= m; i8++) {
										a.at(8) = i8;
										for (int i9 = i8; i9 <= m; i9++) {
											a.at(9) = i9;
											ans = max(ans, keisann(a, abcd));
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
using ull = unsigned long long;

ull GreatestCommonDivisor(ull a, ull b){
	ull r = b;
	while(a % b != 0){
		r = a % b;
		a = b;
		b = r;
	}
	return r;
}

int main(){
	ull A, B;
	scanf("%llu %llu", &A, &B);
	ull n = GreatestCommonDivisor(A, B);
	ull _n = n;
	unsigned ans = 1;
	for(ull i = 2; i*i <= _n; ++i){
		unsigned count = 0;
		while(n % i == 0){
			count++;
			n /= i;
		}
		if(count) ans++;
	}
	if(n != 1) ans++;
	printf("%u\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#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 ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n,d,x;
	cin >> n >> d >> x;
	int a[n];
	rep(i,0,n)
		cin >> a[i];
	
	int ans=0;
	rep(i,0,n){
		ans += (d-1)/a[i];	
		ans++;
	}
	P(ans+x);
	ret 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define uniq(x) (x).erase(unique(all(x)),(x).end())


void solve(void){
    int N;
    cin >> N;
    vector <int> v;
    rep(N, i) {
        int d;
        cin >> d;
        if (i == 0) {
            v.pb(d);
            continue;
        }
        if (lower_bound(all(v), d) == v.end()) {
            v.pb(d);
        }
        else v[lower_bound(all(v), d) - v.begin()] = d;
    }
    cout << (int)v.size() << endl;
}

int main(void){
  solve();
  //cout << "yui(*-v・)yui" << endl;
  return 0;
}



Measured memory_bytes: 3336
#include<cstdio>
#include<iostream>
using namespace std;
const int maxn=400100;
int dpl[maxn],dpr[maxn];
int val[maxn];
int nex[maxn][20],las[maxn][20];
int a[maxn];
int b[20],k=-1;
int f[maxn];
int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	int n,v;
	scanf("%d%d",&n,&v);
	while(v){
		b[++k]=v;
		v/=2;
	}
	b[++k]=0;
	for(int i=0;i<=k;i++)
		if(i<k-i)
			swap(b[i],b[k-i]);

	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int j=0;j<=k;j++)
	{
		nex[n][j]=n;
		nex[n+1][j]=n;
		las[1][j]=1;
		las[0][j]=1;
	}
	for(int i=n-1;i>=1;i--)
		for(int j=0;j<=k;j++)
		{
			if(a[i+1]-a[i]<=b[j])
				nex[i][j]=nex[i+1][j];
			else
				nex[i][j]=i;
		}
	for(int i=2;i<=n;i++)
		for(int j=0;j<=k;j++)
		{
			if(a[i]-a[i-1]<=b[j])
				las[i][j]=las[i-1][j];
			else
				las[i][j]=i;
		}


	for(int i=0;i<(1<<k);i++){
		for(int j=0;j<k;j++){
			if(i&(1<<j)) continue;
			if(nex[dpl[i]+1][j]>dpl[i|(1<<j)])
				dpl[i|(1<<j)]=nex[dpl[i]+1][j];
		}
	}

	for(int i=0;i<(1<<k);i++)
		dpr[i]=n+1;
	for(int i=0;i<(1<<k);i++){
		for(int j=0;j<k;j++){
			if(i&(1<<j)) continue;
			if(las[dpr[i]-1][j]<dpr[i|(1<<j)])
				dpr[i|(1<<j)]=las[dpr[i]-1][j];
		}
	}

	for(int i=1;i<=n;i++)
		f[i]=n+1;
	for(int i=0;i<(1<<k);i++)
		if(dpr[((1<<k)-1)^i]-1<f[dpl[i]+1])
			f[dpl[i]+1]=dpr[((1<<k)-1)^i]-1;

	int r,mn;
	for(int i=1;i<=n;i=r+1){
		r=nex[i][k],mn=n+1;
		for(int j=i;j<=r;j++)
			if(f[j]<mn) mn=f[j];
		if(mn<=r){
			for(int j=i;j<=r;j++)
				printf("Possible\n");
		}
		else{
			for(int j=i;j<=r;j++)
				printf("Impossible\n");
		}
	}
	return 0;
}


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

#define ll long long

int main() {
	ll n;	cin >> n;
	vector <ll> cn(3);

	ll nc = 0;	
	string a;	cin >> a;
	for (ll i = 0; i < n; i ++) {
		if (a[i] == 'R')	cn[0] += 1;
		if (a[i] == 'G')	cn[1] += 1;
		if (a[i] == 'B')	cn[2] += 1;
	}

	for (ll i = 0; i < n; i ++) {
		for (ll j = i + 1; j < n; j ++) {

			if ((j - i) % 2 == 0) {
				ll k = (i + j) / 2;
				if ( (a[i] != a[j]) && (a[j] != a[k]) && (a[i] != a[k]) )
					nc += 1;
			}
		}
	}

	cout << cn[0] * cn[1] * cn[2] - nc << "\n";
	
		
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<char>>;
using info = vector<vector<int>>;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
info seen;
info dist;
Graph G;
queue<vector<int>> que;
int H, W;

void bfs(Graph &G, info &seen, info &dist, vector<int> v, queue<vector<int>> &que) {
  for (int i = 0; i < 4; ++i) {
    vector<int> nv = {v[0] + dy[i], v[1] + dx[i]};
    if (nv[0] < 0 || nv[0] >= H || nv[1] < 0 || nv[1] >= W) continue;

    if (seen[nv[0]][nv[1]]) continue; 
    
    if (G[nv[0]][nv[1]] == '#') {
      seen[nv[0]][nv[1]] = 1;
      continue;
    }
    
    seen[nv[0]][nv[1]] = 1;
    dist[nv[0]][nv[1]] = dist[v[0]][v[1]] + 1;
    que.push(nv);
  }
}

int main() {
  cin >> H >> W;
  int grid_number = H*W;
  int black_number = 0;
  G.assign(H+1, vector<char>(W+1));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      cin >> G[i][j];
      if (G[i][j] == '#') ++black_number;
    }
  }

  vector<int> start ={0, 0};
  vector<int> goal = {H-1, W-1};

  seen.assign(H+1, vector<int>(W+1, 0));
  dist.assign(H+1, vector<int>(W+1, -1));
  seen[0][0] = 1;
  que.push(start);
  dist[0][0] = 0;
  while(!que.empty()) {
    vector<int> v = que.front(); que.pop();
    bfs(G, seen, dist, v, que);
  }

  if (dist[goal[0]][goal[1]] == -1) {
    cout << -1 << endl;
    return 0;
  }
  
  int ans = grid_number - black_number - dist[goal[0]][goal[1]] - 1;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<tuple>
#include<complex>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
#define EPS (long double) 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

using namespace std;

int main() {
	int n, m;
	cin>>n>>m;
	vector<int> c(m);
	REP(i, m) cin>>c[i];
	int dp[m + 1][n + 1];
	REP(i, n + 1) dp[0][i] = INF;
	dp[0][0] = 0;
	FOR(i, 1, m + 1) {
		REP(j, n + 1) {
			if(j == 0) dp[i][j] = 0;
			else if(j >= c[i - 1]) dp[i][j] = min(dp[i - 1][j], dp[i][j - c[i - 1]] + 1);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	cout<<dp[m][n]<<endl;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main()
{
    int N;
    cin >> N;

    vector<int> p(N);

    REP(i, N){
        cin >> p[i];
    }
    int ans = 0;
    for(int i=1; i<N-1; i++){
        if(p[i-1] < p[i] && p[i] < p[i+1]) ans++;
        if(p[i-1] > p[i] && p[i] > p[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;cin >> S;
  bool f = true;
  int sum = 0;
  for(int i = 0; i < S.size(); ++i)
    sum += S[i]-'0';
  if(S.size() == 1)cout << S << endl;
  else cout << max(sum,9 * int(S.size() - 1) + int(S[0] - '0') - 1) << endl;
  return 0;
}
 


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

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

  vector<vector<int>> G(N, vector<int>(N, 1e9));
  for (int a, b, c; cin >> a >> b >> c;) {
    G.at(--a).at(--b) = c;
    G.at(b).at(a) = c;
  }
  for (int i = 0; i < N; i++) {
    G.at(i).at(i) = 0;
  }

  vector<vector<int>> G2 = G;

  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k < N; k++) {
        G.at(j).at(k) = min(G.at(j).at(k), G.at(j).at(i) + G.at(i).at(k));
      }
    }
  }
  
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (G2.at(i).at(j) == 1e9) continue;
      if (G2.at(i).at(j) != G.at(i).at(j)) cnt++;
    }
  }
  cout << cnt / 2 << "\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
const long long INF = 1e18;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, from, a[MAXN];
long long ans;
int main() {
	read(n);
	for (int i = 1; i <= n; i++)
		read(a[i]);
	ans = -INF;
	for (int i = 1; i <= n; i++) {
		long long now = 0;
		for (int j = i; j <= n; j += 2) 
			if (a[j] > 0 || i == j) now += a[j];
		if (now > ans) {
			ans = now;
			from = i;
		}
	}
	writeln(ans);
	static int tmp[MAXN]; int tot = 0;
	for (int i = from; i <= n; i += 2)
		if (a[i] > 0 || i == from) tmp[++tot] = i;
	writeln(tmp[1] - 1 + n - tmp[tot] + (tmp[tot] - tmp[1]) / 2);
	for (int i = n; i >= tmp[tot] + 1; i--)
		writeln(i);
	for (int i = tot - 1; i >= 1; i--) {
		int pos = (tmp[i] + tmp[i + 1]) / 2;
		for (int j = pos; j > tmp[i]; j--)
			writeln(j);
	}
	for (int i = tmp[1] - 1; i >= 1; i--)
		writeln(1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    double x = abs(x1 - x2);
    double y = abs(y1 - y2);
    double l = sqrt(x * x + y * y);
    cout <<  fixed << setprecision(15) << l << endl;
}



Measured memory_bytes: 3264
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
}


Measured memory_bytes: 3596
#include <map>
#include <iostream>
#include <numeric>

using namespace std;

map<pair<long long, long long>, long long> m;
long long ans[10];

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

int main()
{
    long long H, W, N;

    cin >> H >> W >> N;

    m.clear();

    for (long long i = 0; i < N; i++)
    {
        long long a, b;
        cin >> a >> b;
        for (long long j = 0; j < 9; j++)
        {
            pair<long long, long long> p = make_pair(a + dx[j], b + dy[j]);
            if(p.first < 2 || p.second < 2 || p.first >= H || p.second >= W)
            {
                continue;
            }

            if (m.find(p) == m.end())
            {
                m.emplace(p, 1);
            }
            else
            {
                m[p] = m[p] + 1;
            }
        }
    }
    for (auto iter = m.begin(); iter != m.end();iter++)
    {
        ans[iter->second]++;
    }
    long long all = (H - 2) * (W - 2);
    ans[0] = all - accumulate(ans + 1, ans + 10, 0);
    for (long long i = 0; i < 10; i++)
    {
        cout << ans[i] << endl;
    }

    return 0;
}

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

  int N ;
  ll ans = 0 ;
  cin >> N ;
  vector<ll> A(N) ;
  map<ll,ll> mp ;
  rep(i,N) cin >> A.at(i) ;
  vector<ll> S(N+1) ;
  S.at(0) = 0 ;
  mp[S.at(0)]++ ;
  rep(i,N){
    S.at(i+1) = S.at(i) + A.at(i) ;
    mp[S.at(i+1)]++ ;
  }
  for(auto p : mp ){
    ans += (p.second - 1 )*p.second / 2 ;
  }
  cout << ans << endl ;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b;
  cin>>a>>b;
  for(ll i=b-a+1;i<b+a;i++){
    cout<<i<<' ';
  }
  cout<<endl;
  return 0;
}
    
  
  
    
  


Measured memory_bytes: 3576
// In the name of Allah the Lord of the Worlds.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

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

    double w , h , x , y;
    cin >> w >> h >> x >> y;
    if(w/2==x&&h/2==y){
        cout << w*h/2.00 << " " << 1 << endl;
    }
    else cout << w*h/2.00 << " " << 0 << endl;

    return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int w = 0;
    ll ans = 0;
    rep(i, s.size()) {
        if(s[i] == 'W') {
            w++;
            ans += i;
        }
    }
    ans -= (ll) w * (w - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3760
n,m=map(int,input().split())
if n>=2 and m>=2:
    print((m-2)*(n-2))
elif n==1:
    if m==1:
        print(1)
    else:
        print(m-2)
elif m==1:
    if n==1:
        print(1)
    else:
        print(n-2)


Measured memory_bytes: 61796
def ApplePie():
    N, L = input().split()
    N = int(N)
    L = int(L)
    flavors = []
    for i in range(N):
        flavors.append(L+i)
    
    if 0 in flavors:
        flavors.remove(0)
        result = 0
        for i in flavors:
            result = result + i
        print(result)
        exit()
    elif L >= 0:
        del flavors[0]
        result = 0
        for i in flavors:
            result = result + i
        print(result)
        exit()
    else:
        del flavors[-1]
        result = 0
        for i in flavors:
            result = result + i
        print(result)
        exit()
        
ApplePie()

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int R;
    cin >> R;
    
    if(R<1200){
        cout << "ABC" << endl;
    }else{
        if(R<2800){
            cout << "ARC" <<endl;
        }else{
            cout << "AGC" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N;
	char c[200001];
	scanf("%d", &N);
	scanf("%s", c);
	
	int i, j, count = 0;
	for (i = 0, j = N - 1; i < j; i++) {
		if (c[i] == 'R') continue;
		for (; j > i && c[j] == 'W'; j--);
		if (i == j) break;
		else {
			c[i] = 'R';
			c[j] = 'W';
			count++;
		}
	}
	printf("%d\n", count);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1932
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x) { return __builtin_popcount(x); }
int popcnt(ll x) { return __builtin_popcountll(x); }
int clz(int x) { return 31 - __builtin_clz(x); }
int clz(ll x) { return 63 - __builtin_clzll(x); }
int ctz(int x) { return __builtin_ctz(x); }
int ctz(ll x) { return __builtin_ctzll(x); }

class compare {
public:
	bool operator()(tuple<ll, ll> a, tuple<ll, ll> b) {
		return (get<1>(a) > get<1>(b));
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,in;
	cin>>n;
	bool ok=false;
	rep(i,n){
		cin>>in;
		if(in%2!=0)ok=true;
	}
	cout<<(ok?"first":"second")<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>

using namespace std;

long r,c,a1,a2,b1,b2;
long nCr[1001][1001];

int main() {
	cin>>r>>c>>a1>>a2>>b1>>b2;
	long w = min(abs(a1-b1), r-abs(a1-b1));
	long h = min(abs(a2-b2), c-abs(a2-b2));

	nCr[1][0] = nCr[1][1] = 1;
	for (int i = 2; i <= w+h; i++) {
		nCr[i][0] = 1;
		for (int j = 1; j <= w; j++) {
			if (i == j) { nCr[i][j] = 1; break; }
			nCr[i][j] = (nCr[i-1][j-1] + nCr[i-1][j]) % 100000007;
		}
	}
	long a = nCr[w+h][w];
	if (r == w * 2) a *= 2;
	if (c == h * 2) a *= 2;
	cout<<a % 100000007<<endl;
}

Measured memory_bytes: 9844
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>

using namespace std;

int main() {
  long n;
  long ans = 0;
  cin >> n;
  vector<long> b;

  for (long i=1; i<=n; i++) {
    long a; cin>>a;
    b.push_back(a-i);
  }

  sort(b.begin(), b.end());
  long B = (n%2? b[n/2] : (b[n/2-1]+b[n/2])/2);
  ans = accumulate(b.begin(),b.end(),0L,
    [&](long acc, long i) {return acc + abs(i-B);});
  cout << ans << endl;

}

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

int main(){
  long long int x;
  cin >> x;

  long long int ans = x/500;
  long long int tmp = x%500;

  long long int ans1 = tmp / 5;
  cout << ans*1000 + ans1*5 << endl;


}


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

ll power(ll x, ll n) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,s;
	cin>>n>>s;
	ll a[n+5];
	for(ll i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	ll dp[n+5][s+5][2];
	memset(dp,0,sizeof(dp));

	if (a[1]<=s)
	dp[1][a[1]][1]++;
	
	for(ll i=2;i<=n;i++)
	{
		for(ll j=1;j<=s;j++)
		{
			dp[i][j][0] = dp[i-1][j][0]+dp[i-1][j][1];
			dp[i][j][1] = dp[i-1][j][0]+dp[i-1][j][1];
			if (dp[i][j][0]>=mod)
				dp[i][j][0]%=mod;

			if (dp[i][j][1]>=mod)
				dp[i][j][1]%=mod;
		}

		if (a[i]<=s)
		{
			dp[i][a[i]][1] += power(2,i-1);
			if (dp[i][a[i]][1]>=mod)
				dp[i][a[i]][1]%=mod;
		}
		for(ll j=a[i]+1;j<=s;j++)
		{
			
			dp[i][j][1]+= dp[i-1][j-a[i]][0]+dp[i-1][j-a[i]][1];
			if (dp[i][j][1]>=mod)
				dp[i][j][1]%=mod;
		}

		
	}

	ll ans = 0;
	
	ans+=dp[n][s][0]+dp[n][s][1];
	if (ans>=mod)
		ans%=mod;
	cout<<ans;
}

Measured memory_bytes: 144644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define SIZE 1010


char* reverseString(char* str);
int max(int a, int b);

int main(void) {
    char str1[SIZE], str2[SIZE];
    int str1len, str2len, i, j, k, anscount = 0;
    int dp[SIZE][SIZE];
    char ansstr[SIZE];
    int q;
    scanf("%d\n",&q);
    for (k = 0; k < q; k++) {
        memset(dp,0,sizeof(dp));

        fgets(str1,SIZE,stdin);
        fgets(str2,SIZE,stdin);
        str1len = strlen(str1);
        str2len = strlen(str2);

        if (str1[str1len - 1] == '\n') {
            str1[--str1len] = '\0';
        }
        if (str2[str2len - 1] == '\n') {
            str2[--str2len] = '\0';
        }

        for (i = 0; i < str1len; i++) {
            for (j = 0; j < str2len; j++) {
                if (str1[i] == str2[j]) {
                    dp[i + 1][j + 1] = dp[i][j] + 1;
                } else {
                    dp[i + 1][j + 1] = max(dp[i][j + 1],dp[i + 1][j]);
                }
            }
        }

        printf("%d\n",dp[str1len][str2len]);
    }

    return 0;
}

char* reverseString(char* str) {
    char* ansstr;
    int len, i;

    len = strlen(str);
    ansstr = (char*)malloc(sizeof(char) * len);
    
    for (i = 0; i < len; i++) {
        ansstr[i] = str[len - i - 1];
    }
    return ansstr;
}

int max(int a, int b) {
    return a > b ? a : b;
}


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

#define warn printf("!!!***!\n")
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
const int maxn=2e6+6;
const int mod=1e9+7;
const int oo=0x3fffffff;
int a[maxn];
int main()
{
     int n;scanf("%d",&n);
     for(int i=1;i<=n;i++) scanf("%d",&a[i]);
     sort(a+1,a+1+n);
     for(int i=2;i<=n;i++){
        if(a[i]==a[i-1]){
            printf("NO\n");return 0;
        }
     }
     printf("YES\n");
     


}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

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


Measured memory_bytes: 640
N=int(input())
list=[]
for i in range(N):
  S=input()
  if S:
    list.append(S)
C0=list.count("AC")
C1=list.count("WA")
C2=list.count("TLE")
C3=list.count("RE")
print ("AC x ",C0)
print ("WA x ",C1)
print ("TLE x ",C2)
print ("RE x ",C3) 

Measured memory_bytes: 16092
n = int(input())
h = list(map(int, input().split()))
ans = 0
tmp_ans = 0

for i in range(n-1):
    if h[i] >= h[i+1]:
        ans += 1
    else:
        if ans > tmp_ans:
            tmp_ans = ans
        ans = 0

print(max(ans, tmp_ans))

Measured memory_bytes: 15020
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	flag := 0
	befI := ""
	sliceS := strings.Split(s, "")
	for _, val := range sliceS {
		if val == befI {
			flag = 1
		}
		befI = val
	}

	if flag == 1 {
		fmt.Println("Bad")
	} else {
		fmt.Println("Good")
	}
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 090_arc_b / Link: https://abc087.contest.atcoder.jp/tasks/arc090_b?lang=en  ----- */
/* ------問題------

x 軸上に N 人の人が立っています。 人 i の位置を xi とします。 任意の i に対して、xi は 0 以上 109 以下の整数です。 同じ位置に複数の人が立っていることもありえます。
これらの人の位置に関する情報が M 個与えられます。 このうち i 個めの情報は (Li,Ri,Di) という形をしています。 この情報は、人 Ri は人 Li よりも距離 Di だけ右にいること、 すなわち、xRi−xLi=Di が成り立つことを表します。
これら M 個の情報のうちのいくつかに誤りがある可能性があることがわかりました。 与えられる M 個すべての情報と矛盾しないような値の組 (x1,x2,…,xN) が存在するかどうか判定してください。

-----問題ここまで----- */
/* -----解説等-----

この前やった
相対的な距離は重み付きUFでもできるけどグラフとしては逆辺に負のコストを与えれば良い。

----解説ここまで---- */

LL N, M;

int ans;

void dfs(int v, int p, LL d, VL& dist, VI& visit, vector<vector<PLL>>& G) {
	if (!visit[v])dist[v] = d, visit[v] = 1;
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i].first;
		LL cost = G[v][i].second;
		if (nx != p) {
			if (visit[nx]) {
				if (dist[v] + cost != dist[nx])ans = 0;
			}
			else {
				dfs(nx, v, d + cost, dist, visit, G);
			}

		}
	}
}

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

	cin >> N >> M;
	vector<vector<PLL>> G(N);
	FOR(i, 0, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		G[a].push_back(PLL(b, c));
		G[b].push_back(PLL(a, -c));
	}
	VL dist(N, 0);
	VI visit(N, 0);
	ans = 1;
	FOR(i, 0, N) {
		if (!visit[i])dfs(i, -1, 0, dist, visit, G);
	}

	cout << (ans==1 ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 19712
import java.util.*

fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val tree = mutableMapOf<Int, MutableList<Int>>()
    val visited = Array(n + 1) { false }
    (1..n).forEach { tree[it] = mutableListOf() }
    (1 until n).forEach {
        val (a, b) = readLine()!!.split(' ').map(String::toInt)
        tree[a]!!.add(b)
        tree[b]!!.add(a)
    }
    val d1num = Array(n + 1) { 0 }
    val d2num = Array(n + 1) { 0 }

    val queue = ArrayDeque<Int>()
    queue.add(1)
    val ansList = mutableListOf<Long>()
    while (queue.isNotEmpty()) {
        val i = queue.pollFirst()!!
        visited[i] = true
        val dists = tree[i]!!
        ansList.add((k - d1num[i] - d2num[i]).toLong())
        var count = 0
        for (j in 0 until dists.size) {
            val dist = dists[j]
            if (visited[dist]) continue
            d2num[dist] = count++ + d1num[i]
            d1num[dist] = 1
            queue.add(dist)
        }
    }

    var ans = 1L
    ansList.forEach { ans = (ans * it) % 1000000007 }
    println(ans)
}


Measured memory_bytes: 106156