akhauriyash/Code-Regression huggingface dataset:
####################################### Define
maxN = int(6e5 + 100)
a = [0] * maxN
b = [0] * maxN
ans = [0] * maxN
####################################### Functions
def solve() :
    L = R = 0
    for i in range(2, 3 * n + 1) :
        if i > R :
            L = R = i
            while R + 1 <= 3 * n and (a[i] ^ a[1]) == (a[R + 1] ^ a[R - L + 2]): R += 1
#            print(a[i] ^ a[1], a[R + 1] ^ b[R - L + 2], R, L, "\n")
            ans[i] = R - L + 1
        else :
            k = i - L + 1
            if ans[k] < R - i + 1 : ans[i] = ans[k]
            else :
                L = i
                while R + 1 <= 3 * n and (a[i] ^ a[1]) == (a[R + 1] ^ a[R - L + 2]): R += 1
                ans[i] = R - L + 1
####################################### Main
n = int(input())
inp = input().split()
for i in range(n + 1, 2 * n + 1) : a[i] = int(inp[i - n - 1])
for i in range(2 * n + 1, 3 * n + 1) : a[i] = a[i - n]
inp = input().split()
for i in range(1, n + 1) : a[i] = int(inp[i - 1])

solve()

for i in range(n + 1, 2 * n + 1):
    if ans[i] >= n:
        print(i - n - 1, (a[i] ^ a[1]))


Measured memory_bytes: 70284
N,K = map(int,input().split())
src = list(map(int,input().split()))
MOD = 10**9+7

dp = [[0 for k in range(256)] for i in range(N+1)]
dp[0][0] = 1
for i,a in enumerate(src):
    for j in range(i,-1,-1):
        for k in range(256):
            if dp[j][k] == 0: continue
            dp[j+1][k^a] += dp[j][k]

ans = 0
fact = 1
for i in range(1,N+1):
    ans += (dp[i][K] * fact) % MOD
    fact = (fact * (i+1)) % MOD
print(ans % MOD)

Measured memory_bytes: 4080
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 ? "Yes" : "No");
}


Measured memory_bytes: 256
n=int(input())
v=[int(i) for i in input().split()]

v1 = [v[2*i] for i in range(int(n/2))]
v2 = [v[2*i+1] for i in range(int(n/2))]

v1.sort()
v2.sort()

v1.append(-1)
v2.append(-1)


count1= 1
maxcount1=0
maxcount1sub=0
num1=0
num1sub=0

count2=1
maxcount2=0
maxcount2sub=0
num2=0
num2sub=0

for i in range(int(n/2)):
    if v1[i] == v1[i+1]:
        count1+=1
    else:
        if maxcount1sub<=count1:
            if maxcount1<=count1:
                maxcount1sub=maxcount1
                maxcount1=count1
                num1sub=num1
                num1=v1[i]
                
            else:
                maxcount1sub=count1
                num1sub=v1[i]                       
        count1=1
        
        
for i in range(int(n/2)):
    if v2[i] == v2[i+1]:
        count2+=1
    else:
        if maxcount2sub<=count2:
            if maxcount2<=count2:
                maxcount2sub=maxcount2
                maxcount2=count2
                num2sub=num2
                num2=v2[i]
                
            else:
                maxcount2sub=count2
                num2sub=v2[i]                       
        count2=1        
        
if num1!=num2:
    print(n-maxcount1-maxcount2)
else:
    print(min(n-maxcount1-maxcount2sub, n-maxcount2-maxcount1sub))

#print(v1)
#print(v2)
#print(maxcount1,maxcount1sub)
#print(num1, num1sub)
#print(maxcount2,maxcount2sub)
#print(num2, num2sub)

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

using namespace std;

#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define all(x) x.begin(), x.end()

typedef pair<int, int> pi;
typedef long long ll;
const int MAX_INT = 2000000000;

int dp[100001];
int h[100001];

int cost(int i, int j)
{
    return abs(h[i] - h[j]);
}

int main()
{
    int N, K;
    cin >> N >> K;
    FOR(i, 1, N)
    {
        cin >> h[i];
    }

    dp[N] = 0;

    for (int i = N - 1; i >= 1; i--)
    {
        dp[i] = MAX_INT;
        for (int j = i + 1; j <= N && j <= i + K; j++)
            dp[i] = min(dp[i], cost(i, j) + dp[j]);
    }

    cout << dp[1];

    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

int main()
{
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string u;
	cin >> u;
	if (s == u)
		a--;
	if (t == u)
		b--;
	printf("%d %d", a, b);



	//std::printf("%d", r);

	return 0;
}


Measured memory_bytes: 888
#include <stdio.h>

int main(void){
	int n,a,b,an,bn,t;
	while(1){
		an=0;bn=0;
		scanf("%d",&n);
		if(n==0){
			return 0;
		}
		for(t=0;t<n;t++){
			scanf("%d %d",&a,&b);
			if(a>b){
				an = an+a+b;
			}
			if(a<b){
				bn = bn+a+b;
			}
			if(a==b){
				an = an+a;
				bn = bn+b;
			}
		}
		printf("%d %d\n",an,bn);
	}
}
			

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
const double pi = 3.14159265358979323846264;

int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    queue<ll> que;
    ll sum = 0;
    ll xor_sum = 0;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        que.push(a[i]);
        sum += a[i];
        xor_sum = xor_sum ^ a[i];
        while (!(sum == xor_sum))
        {
            sum -= que.front();
            xor_sum = xor_sum ^ que.front();
            que.pop();
            ans += que.size() - 1;
        }
        ans++;
    }
    while (!que.empty())
    {
        sum -= que.front();
        xor_sum = xor_sum ^ que.front();
        que.pop();
        ans += que.size();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6428
a,b,c,x,y = [int(i) for i in input().split()]
if a+b <= 2*c:
    ans = a*x + b*y
else:
    z = min(x,y)
    ans = min(max(x,y)*c*2,z * 2 * c + a*(x-z) + b*(y-z))

print(ans)

Measured memory_bytes: 3060
#!/usr/bin/env pypy3


import collections
import itertools


def solve(names):
    ctr = collections.Counter(name[0] for name in names)
    res = 0
    for x, y, z in itertools.combinations("MARCH", 3):
        res += ctr[x] * ctr[y] * ctr[z]
    return res


def main():
    names = [input() for _ in range(int(input()))]
    print(solve(names))


if __name__ == '__main__':
    main()


Measured memory_bytes: 56664
const lines=readlines()
input()=shift!(lines)
int(x)=parse(Int,x)
function intLine()
    s=input()|>split
    int(s[1]),int(s[2])
end
function main()
    n,m=intLine()
    e=Array{Int,1}[[]for i=1:n]
    for i=1:m
        u,v=intLine()
        push!(e[u],v)
    end
    s,t=intLine()
    f=ones(Int,(n,3))*-3
    f[s,1]=0
    q=Array{Pair{Int,Int}}([s=>1])
    while !isempty(q)
        v,m=shift!(q)
        if v==t&&m==1;break;end
        u=m>2?1:m+1
        for w=e[v]
            if f[w,u]<0
                f[w,u]=f[v,m]+1
                push!(q,w=>u)
            end
        end
    end
    show(f[t,1]÷3)
end
main()

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

int main() {
    int64_t x;
    cin >> x;
    int hund = x / 500;
    int res = x % 500;
    int five = res / 5;
    cout << hund * 1000 + five * 5;
    return 0;
}

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

int main() {
  string s;
  cin >> s;

  for (int i = 0; i < s.size(); i += 2) {
    if (i == s.size() - 1) {
      cout << s.at(i) << endl;
    } else {
      cout << s.at(i);
    }
  }
}


Measured memory_bytes: 512
import sys
def input():
	return sys.stdin.readline()[:-1]

class BIT():#1-indexed
	def __init__(self, size):
		self.table = [0 for _ in range(size+2)]
		self.size = size

	def Sum(self, i):#1からiまでの和
		s = 0
		while i > 0:
			s += self.table[i]
			i -= (i & -i)
		return s

	def PointAdd(self, i, x):#
		while i <= self.size:
			self.table[i] += x
			i += (i & -i)
		return

	def SegAdd(self, l, r, x):#lからrにxを足す
		self.PointAdd(l, x)
		self.PointAdd(r+1, -x)
		return

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
s.sort(key=lambda x: x[1]-x[0])
b = BIT(m)

too_long = n #r-l+1よりも大きい区間（必ず訪れる）
cur = 0
for i in range(1, m+1):
	while cur < n and s[cur][1]-s[cur][0]+1 < i:
		too_long -= 1
		b.SegAdd(s[cur][0], s[cur][1], 1)
		cur += 1
	ans = too_long
	for j in range(i, m+1, i):
		ans += b.Sum(j)
	print(ans)

Measured memory_bytes: 118356
N=int(input())
def fn(N):
  lis=[]
  i=1
  T=-1
  while i**2<=2*N:
    lis.append(i)
    i+=1
  rtn=[0]*N
  for i,a in enumerate(lis):
    for j in range(i,len(lis)):
      b=lis[j]
      for k in range(j,len(lis)):
        c=lis[k]
        tmp=a**2+b**2+c**2
        if tmp%2==0 and tmp<=2*N:
          x,y,z=(a-b+c)/2,(a+b-c)/2,(b+c-a)/2
          if x%1==0 and y%1==0 and z%1==0: 
            if x>0 and y>0 and z>0:
              if x==y and y==z: rtn[int(tmp/2)-1]+=1
              elif x==y or y==z or z==x: rtn[int(tmp/2)-1]+=3
              else: rtn[int(tmp/2)-1]+=6
  return rtn


lis=fn(N)
for i in range(N): print(lis[i])

Measured memory_bytes: 9212
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

int main(){
  int N;
  cin >> N;
  int start, x[N];
  cin >> start;
  REP(i, N){
    cin >> x[i];
  }
  sort(x, x+N);
  int D;
  REP(i, N){
    if(x[i]>start){
      if(i==0) D = x[i]-start;
      else D = min(x[i]-start, start-x[i-1]);
      break;
    }
    if(i == N-1) {
      D = start-x[N-1];
    }
  }

  bool judge;
  while(D){
    judge =true;
    REP(i, N){
      if(abs(start-x[i]) % D) {
        judge = false;
        break;
      }
    }
    if(judge) break;
    else --D;
    //cout << D << endl;
  }

  cout << D <<endl;

  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  int n,b,i,j, w;
  char x;
  int c[13][4];
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      c[j][i]=0;
    }
  }
  scanf("%d\n", &n); for( w = 0; w < n; w++){
    scanf("%c %d\n", &x, &b);
    // C=0 //
    int y = 0;
    if( x == 'S')
      y=0;
    else if( x == 'H')
      y=1;
    else if( x == 'C')
      y=2;
    else
      y=3;
    //   printf("-- %c %d: %d %d\n", x, b, b-1, y);
    c[b-1][y] = 1;
  }
  for(i=0;i<4;i++){
    for(j=0;j<13;j++){
      if( c[j][i] == 0){
	if( i==0 )
	  printf("S %d\n", j+1);
	else if( i == 1 )
	  printf("H %d\n", j+1);
	else if( i == 2)
	  printf("C %d\n", j+1);
	else
	  printf("D %d\n", j+1);
      }
    }
  }
  return 0;
}




Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n,a,b,c,ans;
vector<P> v[15];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a;
        for(int j=0;j<a;j++){
            cin>>b>>c;
            b--;
            v[i].push_back({b,c});
        }
    }
    for(ll i=0;i<(1LL<<n);i++){
        ll ok=1;
        ll cnt=0;
        for(ll j=0;j<n;j++){
            if(((i>>j)&1)==1){
                cnt++;
                for(auto x:v[j]){
                    if(((i>>x.first)&1)!=x.second){
                        ok=0;
                        break;
                    }
                }
            }
        }
        if(ok==1){
            ans=max(ans,cnt);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!
ans=10
a=0
for i in range(5):
    t=int(input())
   
    l=t%10 
    a+=t+(10-l)
    if(l==0):
        a-=10
    if(l!=0 and l<ans):
        ans=l
    #print(ans)
print(a-(10-ans))

Measured memory_bytes: 3060
n=int(input())
s=0
if n>=9:
    s+=9
else:
    s+=n
if n>=100:
    if n>=100 and n<=999:
        s+=n-100+1
    else:
        s+=900
if n>=10000:
    if n>=10000 and n<=99999:
        s+=n-10000+1
    else:
        s+=90000
print(s)

Measured memory_bytes: 2940
N,K = map(int,input().split())
V = list(map(int,input().split()))
cmax = 0
for k in range(1,min(K,N)+1):
    for i in range(k+1):
        A = V[:i]+V[N-(k-i):]
        A = sorted(A,reverse=True)
        a = min(k,K-k)
        for j in range(a):
            if A[-1]<0:
                A.pop()
        cmax = max(cmax,sum(A))
print(cmax)    

Measured memory_bytes: 3064
def ex_euclid(x, y):
	a0, a1 = 1, 0
	b0, b1 = 0, 1
	while y!=0:
		a0, a1 = a1, (a0 - x//y * a1)
		b0, b1 = b1, (b0 - x//y * b1)
		x, y = y, x%y
	return a0, b0

a,b=map(int,input().split())
print(*ex_euclid(a,b))


Measured memory_bytes: 5600
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <queue>
#include <string>

#define REP(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,s,n) for (int i = (s); i < (n); i++)
#define ALLOF(c) c.begin(), c.end()
#define RANGEOF(c,i,n) c.begin() + (i), c.begin() + (i) + (n)
#define EPS 1e-9
#define INF 1000000000
using namespace std;

template <class T> T read() { T t; cin >> t; return t; }
template <class T> vector<T> read(int n) { vector<T> v; REP(i,n) { v.push_back(read<T>()); } return v; }
template <class T> vector<vector<T>> read(int n, int m)
{
	vector<vector<T>> v;
	REP(i,n) { v.push_back(read<T>(m)); }
	return v;
}

template <class T> void write(const T &t) { cout << t << endl; }
template <class T> void write(const T &t, const T &t2) { cout << t << ' ' << t2 << endl; }
template <class T> void write(const vector<T> &v)
{
	ostringstream ss; 
	for (auto x : v) ss << x << ' ';
	auto s = ss.str();
	cout << s.substr(0, s.length() - 1) << endl;
}

struct _Reader { template <class T> _Reader operator ,(T &rhs) { cin >> rhs; return *this; } };
#define READ(t,...) t __VA_ARGS__; _Reader(), __VA_ARGS__

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

/// template end ///



void solve()
{
	while (true)
	{
		READ(int, N);
		if (!N) { break; }
		READ(int, W, H);
		vector<vector<int>> field(W, vector<int>(H));
		REP(i,N) { auto s = read<int>(2); field[s[0] - 1][s[1] - 1]++; }

		READ(int, S, T);
		int maxValue = 0;
		REP(i, W-S+1) REP(j, H-T+1)
		{ 
			int sum = 0;
			REP(k, S) REP(l, T) sum += field[i+k][j+l];
			maxValue = max(maxValue, sum);
		}
		write(maxValue);
	}
}

Measured memory_bytes: 1252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = l[0];
            var B = l[1];
            int ret = 0;
            if (B == 1)
            {
                Console.WriteLine(ret);
                return;
            }
            while (B > 0)
            {
                if (A >= B)
                {
                    B -= A;
                }
                else
                {
                    B -= A - 1;
                }
                ret++;
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<stdio.h>
#include<queue>
#include<math.h>



using namespace std;
typedef long long i64;

int main(){

	i64 lim = 1e18;
	i64 a, b;
	
	scanf("%lld %lld",&a,&b);
	i64 i = 1;
	i64 s = a;
	do{
		s *= i;
		if(s%b && s <= lim && s > 0){printf("%lld\n",s);return 0;}
		++i;
	}while(s <= lim);
	printf("-1\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,l[111],ba=0;
	bool a[111][111][111]={0};
	cin>>n;
	for(int t=0;t<n;t++)
	{
		cin>>l[t];
	}
	for(int t=0;t<n;t++)
	{
		for(int i=t+1;i<n;i++)
		{
			if(l[t]==l[i])
			{
				continue;
			}
			for(int j=i+1;j<n;j++)
			{
				if(l[i]!=l[j]&&l[j]!=l[t]&&(l[t]+l[i]>l[j]&&l[t]+l[j]>l[i]&&l[i]+l[j]>l[t])&&a[t][i][j]==0)
				{
					a[t][i][j]=1;
					ba++;
				} 
			}
		}
	}
	cout<<ba;
	return 0;
}

Measured memory_bytes: 4976
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;

string S;

int main() {
	cin >> S;
	if (S == "Sunny") {
		cout << "Cloudy";
	}
	if (S == "Cloudy") {
		cout << "Rainy";
	}
	if (S == "Rainy") {
		cout << "Sunny";
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace a
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] num = new int[5]; 
            for(int i = 0; i < 5; i++)
            {
                num[i] = int.Parse(Console.ReadLine());
            }
            int k = int.Parse(Console.ReadLine());

            int diff = Max(num) - Min(num);

            if(diff <= k)
            {
                Console.WriteLine("Yay!");
            }
            else
            {
                Console.WriteLine(":(");
            }
        }

        public static int Max(params int[] nums)
        {
            if(nums.Length == 0) return 0;

            int max = nums[0];
            for(int i = 1; i < nums.Length; i++)
            {
                max = max > nums[i] ? max : nums[i];
            }
            return max;
        }

        public static int Min(params int[] nums)
        {
        if(nums.Length == 0) return 0;

        int max = nums[0];
        for(int i = 1; i < nums.Length; i++)
        {
            max = max < nums[i] ? max : nums[i];
        }
        return max;
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
a_l=[]
for i in range(n):
    a_l.append(int(input()))

record = set()
pos = 1
count = 0

while True:
    count += 1
    pos = a_l[pos-1]
    if pos == 2:
        print(count)
        break
    elif pos in record:
        print(-1)
        break
    record.add(pos)

Measured memory_bytes: 13220
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define MOD 1000000007
typedef long long ll;
#include <string.h>

int main(){
	int n;
	char str[105];
	scanf("%s", str);
	n = strlen(str);
	rep(i, n) printf("x");
	return 0;
}



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

namespace AtCoderConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            // 標準入力から1行取得
            string input = Console.ReadLine();
            string input2 = Console.ReadLine();

            // 2で割った数
            int count = 0;

            // 2で割れる数をカウント
            foreach (var item in input2.Split(' '))
            {
                for (int n = int.Parse(item); n % 2 == 0; n /= 2)
                {
                    count++;
                }
            }

            // 標準出力に出力
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int k, x;
		cin >> k >> x;
		if(k * 500 >= x)cout << "Yes" << endl;
		else cout << "No" << endl;
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int n;
char s[4];
int main(){
	scanf("%s",s);

	for(int i = 0; s[i] != '\0'; i++){
        n++;
    }

	for(int i = 0; i < n; i++){
        s[i] -= '0';
    }

	long ans = 0;
	for(int S = 0;S < (1 << n);S++){
		long sum = s[0];
		long a = s[1];
		for(int i = 1;i < n;i++){
			if(S & (1 << i)){
				sum += a;
				a = s[i + 1];
			}else{
				sum -= a;
				a = s[i + 1];
			}
		}

        ans = sum;
        if(ans == 7){
            printf("%d",s[0]);
            for(int i = 1;i < n;i++){
                if(S & (1 << i)){
                    printf("+%d",s[i]);
                }else{
                    printf("-%d",s[i]);
                }
            }
            printf("=%ld\n",ans);
            break;
        }
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

struct Node{
  size_t cnt;
  Node *p,*l,*r;
  Node():cnt(0){p=l=r=nullptr;}
  Node(Node* p):cnt(0),p(p){l=r=nullptr;}
};
  
template<typename T,size_t X>
struct BinaryTrie{
  T acc;
  Node *root;
  Int ptr=0;
  static vector<Node> vs;
  BinaryTrie():acc(0),ptr(0){
    if(vs.empty()) vs.resize(3e6);
    root=emplace(nullptr);
  }
  
  inline Node* emplace(Node* p){
    return &(vs[ptr++]=Node(p));
  }

  inline size_t count(Node* a){
    return a?a->cnt:0;
  }
  
  void add(const T b,size_t k=1){
    const T nb=b^acc;
    Node* a=root;
    for(Int i=X-1;i>=0;i--){
      bool f=(nb>>i)&1;
      if(!f&&!a->l) a->l=emplace(a);
      if( f&&!a->r) a->r=emplace(a);
      a=f?a->r:a->l;
    }
    a->cnt+=k;    
    while((a=a->p)) a->cnt=count(a->l)+count(a->r);    
  }

  inline void update(const T b){acc^=b;}

  size_t order_of_key(const T b){
    Node *a=root;
    size_t res=0;
    for(Int i=X-1;i>=0;i--){      
      Node *l=a->l,*r=a->r;
      if((acc>>i)&1) swap(l,r);
      bool f=(b>>i)&1;
      if(f) res+=count(l); 
      a=f?r:l;
      if(!a) break;
    }
    return res;
  }
};
template<typename T, size_t X>
vector<Node> BinaryTrie<T, X>::vs;

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  scanf("%lld %lld",&n,&k);
  k=n*(n+1)/2-k;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) scanf("%lld",&a[i]);

  auto calc=
    [&](Int x)->Int{
      Int res=0;
      BinaryTrie<Int, 20> bt;
      bt.add(0);
      for(Int i=0;i<n;i++){
        bt.update(a[i]);
        res+=bt.order_of_key(x);
        bt.add(0);
      }
      return res;
    };
  
  Int l=0,r=1<<20;
  while(l+1<r){
    Int m=(l+r)>>1;
    if(calc(m)<=k) l=m;
    else r=m;
  }

  printf("%lld\n",l);
  return 0;
}



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

string f,p;
int l,i;
int main()
{
	cin>>f;
	p=f;
	l=f.size();
	for(i=0;i<l;i++)
	{
		p[i]=f[l-i-1];
	}
	for(i=0;i<l;i++)
	{
		if(p[i]=='b')p[i]='d';
		else if(p[i]=='d')p[i]='b';
		else if(p[i]=='p')p[i]='q';
		else if(p[i]=='q')p[i]='p';
	}
	if(p==f)cout<<"Yes"<<endl;
	  else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 512
<?php
  
$totalN = fgets( STDIN );
$cards = explode( ' ', trim(fgets( STDIN )));

rsort( $cards );
$alice = 0;
$bob = 0;

for( $n = 0; $n < $totalN; $n++ ) {
    if( $n %2 == 0 ) {
        $alice += $cards[ $n ];
    } else {
        $bob += $cards[ $n ];
    }
}
echo( $alice - $bob );

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  vector<int> v = {a,b,c};
  sort(v.begin(),v.end());
  if(v.at(0) == 5 && v.at(1) == 5 && v.at(2) == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
string baka(int x, int y, string z,string a){
	string sakurai;
	string satou;
	string huuta;
	for(int i = 0;i<x;i++){
		sakurai += a.at(i);
	}
	for(int i = y+1;i < a.size();i++){
		satou += a.at(i);
	}
	huuta += sakurai;
	huuta += z;
	huuta += satou;

     return huuta;
}
string aho(int b,int c,string x){
	string eziri;
	string syouma;
	string s;
	string huuta;
	for(int i = 0;i<b;i++){
		eziri += x.at(i);
	}
	for(int i = c +1;i<x.size();i++){
		syouma += x.at(i);
	}
	for(int i = b;i<c+1;i++){
		if(i >=b && i <=c+1) s += x.at(i); 
	}
	reverse(s.begin(),s.end());
	huuta += eziri;
	huuta += s;
	huuta += syouma;
	return huuta;
}
int main(void){
	int a,b = 0,c = 0;
	string x;
	string y;
	cin>>x;
	cin>>a;
	for(int i = 0;i<a;i++){
		cin>>y;
		if(y =="replace"){
			string z;
			cin>>b>>c;
			cin>>z;
			x = baka(b,c,z,x);
			//cout<<x<<endl;
		}
		else if(y == "reverse"){
			cin>>b>>c;
			x = aho(b,c,x);
			//cout<<x<<endl;
		}
		else if(y =="print"){
			cin>>b>>c;
			string s;
			for(int j = 0;j<x.size();j++){
				if(b<= j &&  c>= j) s+=x.at(j);
			}
			cout<<s<<endl;
		}
	}
	return 0;
}


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

int main() {
    ll m,a,r,c,h;
    m = a = r = c = h = 0;
    int n;
    cin >> n;
    rep(i,n) {
        string s;
        cin >> s;
        if(s[0] == 'M') {
            m++;
        } else if(s[0] == 'A') {
            a++;
        } else if(s[0] == 'R') {
            r++;
        } else if(s[0] == 'C') {
            c++;
        } else if(s[0] == 'H') {
            h++;
        }
    }
    ll ans = 0;
    ans += (m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Program{
    public static void Main(){
        string s = Console.ReadLine();
        string[] numbers = new string[2];
        numbers[0] = s.Substring(0,2);
        numbers[1] = s.Substring(2);
        bool[] monthFlag = new bool[2];
        for(var i = 0; i < 2; i++){
            var num = 0;
            if(numbers[i][0] == '0'){
                num = int.Parse(numbers[i].Substring(1));
            }else{
                num = int.Parse(numbers[i]);
            }
            
            if(num > 0 && num < 13){
                monthFlag[i] = true;
            }
        }
        if(monthFlag[0] && monthFlag[1]){
            Console.WriteLine("AMBIGUOUS");
        }else if(!monthFlag[0] && monthFlag[1]){
            Console.WriteLine("YYMM");
        }else if(monthFlag[0] && !monthFlag[1]){
            Console.WriteLine("MMYY");
        }else{
            Console.WriteLine("NA");
        }
    }
}


Measured memory_bytes: 11092
while True:
    n, x = [int(i) for i in input().split()]
 
    if n == x == 0:
        break
 
    count = 0
    for s in range(1, n + 1):
        for m in range(s+1, n):
            for e in range(m+1, n+1):
                if x == s + m + e:
                    count += 1
 
    print(count)

Measured memory_bytes: 7664
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;

const int mx=200010;
const ll mod=1e9+7;

int n;


int main(){
  cin >> n;
  cout << (n+1)/2-1 << endl;
  return 0;
}

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

using namespace std;

#define il inline
#define re register int
#define Rep(i, s, e) for (re i = s; i <= e; ++i)
#define Dep(i, s, e) for (re i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

typedef long long ll;

const int N = 200010;

il int read() {
	int x = 0; bool f = true; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
	while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
	return f ? x : -x;
}

int n, k, h[N]; ll ans;
int main() {
	n = read(), k = read();
	Rep(i, 1, n) h[i] = read();
	sort(h + 1, h + n + 1);
	Rep(i, 1, n - k) ans += h[i];
	return printf("%lld", ans) & 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long int ll;
 ll  p=1e9+7; 

 int  main() {
        ff;
       
       ll n,k;
       cin>>n>>k;
       ll d,x;
        ll cnt[n+1]={0};
       while(k--){
           
           cin>>d;
           while(d--){
             cin>>x;
             cnt[x]=1;
           }
       }
       
       int cc=0;
       for(int i=1;i<(n+1);i++){
           if(cnt[i]==0){
               cc++;
           }
       }
       cout<<cc<<endl;
    
       
      
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
    int a,b,c,s,ans=0;
    cin>>a>>b>>c>>s;
    for(int i=0;i<=a;i++)
    for(int g=0;g<=b;g++)
    for(int j=0;j<=c;j++)
    if(i*500+g*100+j*50==s)ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    vll sum(n+1, 0);
    rep(i, n) sum[i+1] = sum[i] + a[i];
    int idx = lower_bound(sum.begin(), sum.end(), sum[n]/2.0) - sum.begin();
    ll l1 = sum[idx];
    ll l2 = sum[n] - sum[idx];
    ll ans = abs(l1 - l2);
    ll l3 = sum[idx-1];
    ll l4 = sum[n] - sum[idx-1];
    chmin(ans, abs(l3 - l4));
    cout << ans << endl;
}

Measured memory_bytes: 3456
#include<iostream>
using namespace std;
int main() {
	int x, y, max, py, num;
	cin >> x >> y >> max >> py >> num;
	if (max < num) y = py*(num - max) + y;
	if (y < x*num) cout << y << endl;
	else cout << x*num << endl;
	return 0;
}

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

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

  string S; cin >> S;
  bool is_good = true;
  for (ll i = 0; i < 3; ++i)
    if (S[i] == S[i+1]) is_good = false;
  if (is_good) puts("Good");
  else puts("Bad");
  return 0;
}


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

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define deb(x)     cout << #x << " = "<<x<<endl

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)

int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX =  100001;//200005


ll gcd(ll  a , ll b) {
	return (b == 0) ? a : gcd(b, a % b);
}
ll binpow(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}
ll powmod(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
ll modinv(ll n, ll p)
{
	return powmod(n, MOD - 2, MOD);
}

int dp[MX];
int main(int argc, char const *argv[])
{
	// two magical lines to speed up IO
	cin.tie(0);
	ios_base::sync_with_stdio(false);
// #ifndef ONLINE_JUDGE
// 	freopen("in.txt", "r", stdin);
// 	freopen("out.txt", "w", stdout);
// #endif

	int n;
	cin >> n;
	int h[n + 1];
	h[0] = 0;
	FOR(i, 1, n + 1) {
		cin >> h[i];
	}
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(h[2] - h[1]);
	FOR(i, 3, n + 1) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n] << endl;






}










Measured memory_bytes: 4400
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N=5, i ;
    vector<int> x(N);
    for (i=1;i<N;i++){
        cin >> x[i];  
    }
    for (i=1;i<=N;i++){
        if (x[i]==0){
            cout << i << endl;
            break;
        }
    }
}

Measured memory_bytes: 3552
module Main where

import qualified Data.Vector as V 
import qualified Data.Map as M

readint :: IO Int
readint = read <$> getLine

readvec :: IO [Int]
readvec = (fmap read . words) <$> getLine

main :: IO()
main = do
  [a,b,c] <- readvec
  --print a
  --print b
  --print c
  print $ min (floor $ fromIntegral b / fromIntegral a) c


Measured memory_bytes: 508
"use strict";
const main = arg => {
  	const set1 = new Set(arg.trim().split(" "));
  	let ans = "No";
  	if(set1.size == 2){
    	ans = "Yes";
    } 
  	

  	console.log(ans);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

class UnionFind {
public:
  // 親の番号
  // 自分が親の場合は-1とする
  vector<int> Parent;

  // 最初はParentの値をすべて-1にしておく
  // -1は誰ともつながっていないことを示す
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }

  // Aがどのグループに属しているかを調べる
  int root(int A)
  {
    // -1の場合は自分が親
    if (Parent[A] < 0) {
      return A;
    }

    // 自分が属する親を再帰で探す
    return Parent[A] = root(Parent[A]);
  }

  // AとBをつなぐ
  bool connect (int A, int B) {

    // AとBを直接つなぐのではなく、
    // root(A)にroot(B)をつなぐ
    A = root(A);
    B = root(B);

    if (A == B) {
      // すでにつながっているので、必要ない
      return false;
    }

    // 大きい方に小さい方をつなげる
    if (Parent[A] > Parent[B]) {
      swap(A,B);
    }

    // サイズを加える
    Parent[A] += Parent[B];
    
    // つなぐ
    Parent[B] = A;

    return true;
  }

  // A と B が同じグループかを返す
  bool same(int A, int B) {
    return root(A) == root(B);
  }

  // Aが属するグループのサイズを返す
  int size(int A) {
    return -Parent[root(A)];
  }

};

// 友達の数
int AB[100010];

// ブロック関係
vector<int> CD[100010];


int main() {

  int N, M, K;
  cin >> N >> M >> K;

  // 友達関係を管理するために、
  // AとBをつなぐ。
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    AB[A]++;
    AB[B]++;
    uf.connect(A,B);
  }

  // ブロック関係を配列に入れる。
  for (int i = 0; i < K; i++) {
    int C, D;
    cin >> C >> D;
    C--;
    D--;
    CD[C].push_back(D);
    CD[D].push_back(C);
  }

  for (int i = 0; i < N; i++) {
    // 答え（友達候補） = 属するグループのサイズ - 友達の数 - 自分。
    int answer = uf.size(i) - AB[i] - 1;
    for (auto item: CD[i]) {
      // ブロック関係にあって、同じグループに属している場合は、
      // 答えからさらに1引く。
      if (uf.same(i, item)) {
        answer--;
      }
    }
    cout << answer << " ";
  }
  cout << endl;

  return 0;

}

Measured memory_bytes: 6784
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#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 gcd(a,b) __gcd(a,b)
#define ll long long int
#define ld double
#define pi pair<ll,ll>
#define pb push_back
#define pf push_front
#define pu push
#define po pop
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define be begin
#define sz(a) (ll)a.size()
#define INF 1e18
 
typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
 
ll mod=1e9+7;
// ll gcd(ll a, ll b){
//     if(a<b) swap(a,b);
//     if(b==0) return a;
//     return gcd(b,a%b);
// }
 
// ll fun(ll x, ll y){
//     ll rem=1;
//     while(y!=0){
//         if(y%2==1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y/=2;
//     }
//     return rem;
// }


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	ve<ld>ar(n+1);
	lr(n){
		cin>>ar[i+1];
	}
	ld dp[n+1][n+1];
	for(ll i=0;i<=n;i++) dp[i][0]=0;
	for(ll i=0;i<=n;i++) dp[0][i]=0;
	dp[0][0]=1;
	for(ll i=1;i<=n;i++){
		for(ll j=0;j<=n;j++){
			dp[i][j]=dp[i-1][j]*(1-ar[i]);
			if(j!=0) dp[i][j]+=dp[i-1][j-1]*ar[i];
		}
	}
	ld ans=0;
	for(ll i=n/2+1;i<=n;i++){
		ans+=dp[n][i];
	}
	cout << fixed << setprecision(10) << ans << "\n";
	return 0;
}

Measured memory_bytes: 70656
/*2019/10/19 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return -1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return 1;}
//int asc_t(const void *a,const void *b){if(((pair_t*)a)->d < ((pair_t*)b)->d)return 1;else if(((pair_t*)a)->d == ((pair_t*)b)->d)return 0;else return -1;}
double to_deg(double r) {return r * 180.0 / (atan(1.0) * 4.0);}

int main(){
    int n;
    static ull a[300000];
    ull allSum=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%llu",&a[i]);
        allSum+=a[i];
    }
    ull sum=0,min=__LONG_LONG_MAX__,tmp;
    
    for(int i=0;i<n;i++){
        allSum-=a[i];
        sum+=a[i];
        
        if(allSum>sum)tmp=allSum-sum;
        else tmp=-allSum+sum;
        if(min>tmp){
            min=tmp;
        }
    }
    
    printf("%llu\n",min);
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.Run_Length", "r", stdin );
	string str = "";
	while (getline (cin, str ) ){
		int n = str.length();
		string res = "";
		int i = 0;
		while (i < n ){
			if (str[i] != '@' ){
				res += str[i];
			}else{
				i++;
				int cnt = (str[i] - '0');
				i++;
				char c = str[i];
				rep (j, cnt ){
					res += c;
				} // end if
			} // end if
			i++;
		} // end while
		cout << res << endl;
	} // end while

	return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

//Repeated Subsequences
public class Main{

	String lcs(String a, String b){
		int na = a.length(), nb = b.length();
		int dp[][] = new int[na+1][nb+1];
		for(int i=1;i<=na;i++)for(int j=1;j<=nb;j++){
			if(a.charAt(i-1)==b.charAt(j-1))dp[i][j] = dp[i-1][j-1] + 1;
			else dp[i][j] = Math.max(dp[i-1][j], dp[i][j-1]);
		}
		char[] r = new char[dp[na][nb]];
		int i = na, j = nb;
		while(0<i&&0<j){
			if(dp[i][j]==dp[i-1][j])i--;
			else if(dp[i][j]==dp[i][j-1])j--;
			else{
				r[dp[i-1][j-1]] = a.charAt(i-1);
				i--; j--;
			}
		}
		return new String(r);
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			String s = sc.next();
			if("#END".equals(s))break;
			String res = "";
			for(int i=1;i<s.length();i++){
				String l = lcs(s.substring(0, i), s.substring(i));
				if(res.length()<l.length())res = l;
			}
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin>>n;
  ll a[n];
  F(i,0,n) cin>>a[i];
  sort(a,a+n);
  ll cnt = 0;
  F(i,0,n) F(j, i+1, n) F(k, j+1,n) if(!(a[i] == a[j] || a[j] == a[k]) && a[i]+a[j]>a[k]) cnt++;
  cout<<cnt<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

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

    vector<int> v(n);

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

    map<int, int> efs, ofs;

    for(int i=0; i<n; i+=2){
        efs[v[i]]++;
    }
    for(int i=1; i<n; i+=2){
        ofs[v[i]]++;
    }

    pair<int, int> em1({0,0}), em2({0,0}), om1({0,0}), om2({0,0});

    for(pair<int, int> p: efs){
        if(p.second >= em1.second){
            em2 = em1;
            em1 = p;
        }
        else if(p.second>em2.second){
            em2 = p;
        }
    }

    for(pair<int, int> p: ofs){
        if(p.second >= om1.second){
            om2 = om1;
            om1 = p;
        }
        else if(p.second>om2.second){
            om2 = p;
        }
    }

    int ans = 0;

    if(em1.first != om1.first){
        ans = n-em1.second-om1.second;
    }
    else{
        ans = n-max(em1.second+om2.second, em2.second+om1.second);
    }

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

Measured memory_bytes: 8232
#include <iostream>
#include <vector>
using namespace std;
const int INF = 1e9;

int main(){
  int D, N;
  while(cin >> D >> N, D){
    vector<int> A(N), E(N), R(N);
    for(int i = 0; i < N; ++i){
      cin >> A[i] >> E[i] >> R[i];
    }
    vector<vector<int>> dp(D+1,vector<int>(101,INF));
    dp[D][0] = 0;
    for(int i = D; i >= 0; --i){
      for(int j = 0; j <= 100; ++j){
        if(dp[i][j] >= INF) continue;
        for(int k = 0; k < N; ++k){
          if(R[k] > j) continue;
          int i_ = max(0,i-A[k]), j_ = min(100,j+E[k]);
          dp.at(i_).at(j_) = min(dp[i_][j_],dp[i][j]+1);
        }
      }
    }
    int ans = INF;
    for(int j = 0; j <= 100; ++j)
      ans = min(ans,dp[0][j]);
    if(ans >= INF) cout << "NA" << endl;
    else cout << ans << endl;
  }
}



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

int main()
{
	string s;
	cin >> s;

	int len = s.size();
	bool cFlag = false;

	for (int i = 0; i < len; i++)
	{
		if (s[i] == 'C')
		{
			cFlag = true;
		}
		if (s[i] == 'F' && cFlag)
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include  <iostream>
#include  <vector>
#include  <algorithm>
#include  <string>
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; }
#define rep(i, n) for(int i = 0; i < n; i++)

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

const int INF = 1 << 29;
const ll LINF = 1LL << 60;
const int R = 1e9 + 7;

int n;
vector<ll> a(n);
vector<vector<ll> >m;
vector<vector<bool> >seen;
ll ksum(int l, int r)
{
	ll res = 0;
	if (r >= 1)  res += a[r - 1];
	if (l)  res -= a[l - 1];
	return res;
}

ll rec(int l, int r)
{
	if (l == r - 1)  return 0;
	if (seen[l][r])  return m[l][r];
	seen[l][r] = true;
	for (int c = l; c < r; c++) {
		chmin(m[l][r], rec(l, c + 1) + rec(c + 1, r) + ksum(l, r));
	}
	return m[l][r];
}

int main()
{
	cin >> n;
	a.resize(n);
	rep(i, n)  cin >> a[i];
	//累積和
	rep(i, n - 1) {
		a[i + 1] += a[i];
	}

	m.resize(n + 1, vector<ll>(n + 1, LINF));  //区間dp
	seen.resize(n + 1, vector<bool>(n + 1, false));
	
	cout << rec(0, n) << endl;
}

Measured memory_bytes: 1536