akhauriyash/Code-Regression huggingface dataset:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


inf = 10 ** 18
mod = 10 ** 9 + 7

x = ir()
if x >= 30:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 77376
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
 
int main(){
    ll a,b,c;
    ll x,y;
    cin>>a>>b>>c>>x>>y;
    ll n = 2*max(x,y);
    ll ans = (ll)INF;
    for(ll i=0;i<=n;i+=2){
        ll num = c*i;
        ll A = i/2;
        ll B = i/2;
        num+=a*max(x-A,0LL);
        num+=b*max(y-B,0LL);
        ans = min(ans,num);
    }
    cout<<ans<<endl;
}


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

int main() {
  
  	int N,l,r;
  	cin >> N;

  	int sum=0;
  	for(int i=0;i<N;i++){
    	cin >> l >> r;
      	sum +=r-(l-1);
    }
	
  	cout << sum << endl;
}

Measured memory_bytes: 256
r,i,f,N[11];C(n){int*p=N+9;for(r+=!n;p-->N;++*p,++p[1],++p[2])(*p-=3)<0||C(n-1),(*p+=2)<0|!p[1]--|!p[2]--||C(n-1);}main(j){for(;j=getchar()+1;)if(++i==14||!++N[j-50]){for(i=-1;++i<9;N[i]--)if(++N[i]<5){for(r=0,j=9;j--;N[j]+=2)(N[j]-=2)<0||C(4);f=r?printf(" %d"+!f,1+i):f;}puts("0"+!!f);memset(N,f=i=0,36);}exit(0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  string tmp;
  int N;
  bool yn = false;
  cin >> S;
  cin >> T;
  N = S.size();
  tmp = S;
  for(int i=0;i<N;i++){
    tmp.at(0) = S.at(N-1);
    for(int j=1;j<N;j++){
      tmp.at(j) = S.at(j-1);
    }
    S = tmp;
    if(tmp == T){
      yn = true;
      break;
    }
  }
  if(yn){
  cout << "Yes" << endl;  
  }
  else{
  cout << "No" << endl;
  
  }
  
  
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	while(cin>>n){
		int arr[n];
		for(int i=0; i<n; i++){
			cin>>arr[i];
		}
		sort(arr, arr+n);
		int ans;
		for(int p = 0; p<=100; p++){
			int cnt = 0;
			for(int i=0; i<n; i++){
				cnt += (arr[i]-p) * (arr[i]-p);
			}
			ans = p==0?cnt:min(ans, cnt);
		}
		cout << ans << endl;
		
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,a) for(int i=lst[a];i;i=nxt[i])
using namespace std;

typedef long long ll;

const int N=1e5+5;

int t[N<<1],v[N<<1],nxt[N<<1],lst[N],l;
void add(int x,int y,int z) {
	t[++l]=y;v[l]=z;nxt[l]=lst[x];lst[x]=l;
}

int n,x,y,z,rt,size[N];
ll dist[N];

void get_size(int x,int y) {
	size[x]=1;
	rep(i,x) if (t[i]!=y) get_size(t[i],x),size[x]+=size[t[i]];
}

void find_root(int x,int y) {
	bool pd=1;
	rep(i,x) 
		if (t[i]!=y) {
			find_root(t[i],x);
			if (size[t[i]]>n/2) pd=0;
		}
	if (n-size[x]>n/2) pd=0;
	if (pd) rt=x;
}

void dfs(int x,int y) {
	rep(i,x)
		if (t[i]!=y) {
			dist[t[i]]=dist[x]+v[i];
			dfs(t[i],x);
		}
}

int main() {
	scanf("%d",&n);
	fo(i,1,n-1) {
		scanf("%d%d%d",&x,&y,&z);
		add(x,y,z);add(y,x,z); 
	}
	if (n==2) {
		printf("%d\n",z);
		return 0;
	}
	get_size(1,0);find_root(1,0);dfs(rt,0);
	ll ans=0;
	fo(i,1,n) ans+=dist[i];
	ans=ans*2;
	int mn=0x7fffffff;
	rep(i,rt) {
		if (size[t[i]]==(n+1)/2) {mn=v[i];break;}
		mn=min(mn,v[i]);
	}
	printf("%lld\n",ans-mn);
}

Measured memory_bytes: 9344
def euclid(x, y):
    if x == 0:
        return y
    if y == 0:
        return x
    while x % y != 0:
        temp = x
        x = y
        y = temp % y
    return y

n = int(input())
data = list(map(int, input().split()))
array = data
L = []
L.append(0)
R = []
R.append(0)
m = []
for i in range(n):
    L.append(euclid(L[i], data[i]))
data.reverse()
for i in range(n):
    R.append(euclid(R[i], data[i]))
R.reverse()
for i in range(0,n):
    m.append(euclid(L[i] , R[i + 1]))
print(max(m))


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

int main(void)
{
    vector<char> S(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> S[i];
    }
    sort(S.begin(), S.end());

    if (S[0] == 'a' && S[1] == 'b' && S[2] == 'c')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define FAST ios_base::sync_with_stdio(false);
#define INPT cin.tie(NULL);
#define OUTPT cout.tie(NULL);
#define fori(i,a,b) for(i=a;i<b;i++)
#define forireverse(i,a,b) for(i=a;i>=b;i--)
#define full(x) x.begin(),x.end()
#define sortV(x) sort(full(x))
#define sortVgr(x) sort(full(x),greater<LL>()) // x -> vector
#define reverse(x) reverse(full(x)) // x -> string
#define go(t) while(t--)
#define endl cout<<"\n"
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define M 1e9+7

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

int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("inputAtC.txt","r",stdin);
	freopen("outputAtC.txt","w",stdout);
	#endif*/
	FAST INPT OUTPT
	LL t=1;
	//cin>>t;
	go(t)
	{
		LL n,p,sum=0;
		cin>>n;
		LL A[n],i;
        fori(i,0,n) cin>>A[i];
        LL maxm=A[0];
        fori(i,1,n)
        {
        	if(A[i]<maxm) sum+=(maxm-A[i]);
        	else maxm=max(maxm,A[i]);
        	//cout<<sum<<" ";
        }
        cout<<sum;
	}
	return 0;
}

Measured memory_bytes: 5228
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int, int>
//#define int ll
#define pll pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;

void dfs(vector<int> adj[], int sv, vector<bool> &vis){
	vis[sv] = true;
	for(int i = 0; i < adj[sv].size(); i++){
		if(!vis[adj[sv][i]]){
			dfs(adj, adj[sv][i], vis);
		}
	}
}
ll power(ll x, ll y){  
	if(x == 1 || y == 0)
		return 1;
    ll res = 1;   
    x = x % mod; 
    if (x == 0) 
		return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res * x) % mod;  
        y = y >> 1; 
        x = (x * x) % mod;  
    }  
    return res;  
}  
ll nCr(ll n, ll r) {
    ll x = 1, y = 1;
    rep(i, 0, r) {
        x = x * (n - i) % mod;
        y = y * (i + 1) % mod;
    }
    return x * power(y, mod - 2) % mod;
}

signed main(){
	FASTIO
	int n;
	cin >> n;
	int a[n];
	unordered_map<int, int> add;
	rep(i, 0, n){
		cin >> a[i];
//		sub[i-a[i]]++;
	}
	
	ll ans = 0;
	rep(i, 0, n){
		if(add.count(i-a[i]) > 0)
			ans += add[i-a[i]];
		add[a[i] + i]++;
	}
	cout << ans;
    return 0;
}


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

int main() {
  int n;cin>>n;
  ll ans=1;
  int x=1e9+7;
  for(int i=1;i<=n;i++){
    ans=ans*i%x;
  }
  cout<<ans<<endl;
}

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

using namespace std;

int main(void)
{
	int h,w;
	cin >> h >> w;

	string s[h];
	for(int i=1;i<=h;i++)
		cin >> s[i-1];
	
	int dx[4]={-1,0,1,0};
	int dy[4]={0,1,0,-1};

	bool isolate = false;

	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(s[i-1][j-1]=='.')
			{
				isolate=false;
				continue;
			}

			isolate = true;
			
			for(int k=1;k<=4;k++)
			{
				int sx=i+dx[k-1];
				int sy=j+dy[k-1];

				if(!(sx<1 || sx>h || sy<1 || sy>w))
				{
					if(s[sx-1][sy-1]=='#')
						isolate = false;
				}
			}
			if(isolate == true)
				break;
		}
		if(isolate == true)
			break;
	}

	cout << (isolate? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <cctype>
#include <algorithm>
using namespace std;

int main() {
	for (;;) {
		string s;
		cin >> s;
		if (s == "-") {
			break;
		}
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int h;
			cin >> h;
			s = s.substr(h) + s.substr(0, h);
		}
		cout << s << endl;
	}

	return 0;
}



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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for(int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowerCnt(const vector<int>& cnrvnSeq)
{
  vector<int> vnRevSeq(cnrvnSeq);
  reverse(begin(vnRevSeq), end(vnRevSeq));

  int nMaxSeqCnt = 0;
  int nFoward = 0;

  while (nFoward < vnRevSeq.size())
  {
    int nSeqCnt = 0;
    int n;

    for (n = nFoward; n < vnRevSeq.size() - 1; n++)
      if (vnRevSeq[n] <= vnRevSeq[n + 1])
        nSeqCnt++;
      else
        break;

    nFoward = n + 1;
    nMaxSeqCnt = max(nMaxSeqCnt, nSeqCnt);
  }
  return nMaxSeqCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowerCnt(vnSeq) << endl;

  return 0;
}

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

int main() {
    int n;
    char s[10010];
    scanf("%d %s",&n,s);
    int len=strlen(s);
    rep(i,len) {
        int x=s[i]-'A';
        x=(x+n)%26;
        putchar('A'+x);
    }
    printf("\n");
}   


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

int main()
{
  int a;
  cin >> a;
  int b;
  if ( a % 2) {
    b = a / 2 +1;
  }
else {
  b = a / 2;
}
  cout << a / 2*b << endl;   
  return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
int main()
{
    char s[11];
    char t[12];
    scanf("%s%s",&s,&t);
    int l=strlen(s);
    int c=0;
    for(int i=0;i<l;i++)
    {
        if(s[i]==t[i]){c++;}
    }
    if(c==l){printf("Yes");}
    else printf("No");
    return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
  int D,S,T;
  cin>>D>>S>>T;
  float s = (float)D/T;
  if(s<=S)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }

}


Measured memory_bytes: 3604
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	vector<long long> B(N);
	vector<long long> C(N);

	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	sort(A.begin(), A.end());
	
	for (int i = 0; i < N; i++) {
		cin >> B.at(i);
	}
	sort(B.begin(), B.end());
	
	for (int i = 0; i < N; i++) {
		cin >> C.at(i);
	}
	sort(C.begin(), C.end());

	long long ans = 0;
	for (int i = 0; i < N; i++) {
		long long numA, numC;
		auto IterA = lower_bound(A.begin(), A.end(), B.at(i));
		auto IterC = upper_bound(C.begin(), C.end(), B.at(i));
		numA = IterA - A.begin();
		numC = IterC - C.begin();
		ans += numA * (N - numC);
	}
	cout << ans << endl;
}

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

int main(){

	string a;
	getline(cin,a);
	for(int i=0;a[i]!='\0';i++){
		if(a[i]>='a' && a[i]<='z'){
			a[i]-=32;
		}
	}
	
	cout<<a<<endl;
	
	return 0;
}

Measured memory_bytes: 3144
#include <stdio.h>
#define N 101

int A[N][N],color[N],f[N],d[N];
int n, time,k,a;

void visit(int u)
{
  int i;
  color[u] = 2;
  d[u] = ++time;
  for( i=1 ; i<=n ; i++ ){
    if(A[u][i]!=0){
      if(color[i]==0) visit(i);
    }
  }
  color[u] = 3;
  f[u] = ++time;
}

void dfs(void)
{
  int i;
  for( i=1 ; i<=n ; i++)
    color[i] = 0;
  time = 0;
  for( i=1 ; i<=n ; i++ )
    if(color[i]==0) visit(i);
}


int main()
{
  int i, j, u, k;
  scanf("%d",&n);
  for(i=0 ; i<=n ; i++ )
    for(j=0 ; j<=n ; j++ )
      A[i][j] = 0;
  
  for(i=1 ; i<=n ; i++ ){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1 ; j<=k ; j++ ){
      scanf("%d",&a);
      A[u][a] = 1;
    }
  }
  dfs();

  for( i=1 ; i<=n ;i++)
    printf("%d %d %d\n",i,d[i],f[i]);

  return 0;
}

Measured memory_bytes: 640
from collections import defaultdict


def main():
    n, w = map(int, input().split())
    items = [list(map(int, input().split())) for _ in range(n)]
    DP = defaultdict(int)
    DP[0] = 0
    for weight, value in items:
        exists = list(DP.items())
        for key, total in exists:
            new_key = key + weight
            new_total = total + value
            if DP[new_key] < new_total:
                DP[new_key] = new_total

    candidates = [0]
    for weight, value in sorted(DP.items()):
        if weight > w:
            break
        candidates.append(value)

    print(max(candidates))


if __name__ == "__main__":
    main()


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

int main() {
	int r, c, i,j,k,box[101][101] = {};
	cin >> r >> c;
	for (i = 0; i < r; i++) {
		for (j = 0; j < c; j++) {
			cin >> box[i][j];
			box[i][c] += box[i][j];
			box[r][j] += box[i][j];
		}
	}
	for (k = 0; k < c; k++) {
		box[r][c] += box[r][k];
	}
	for (i = 0; i <= r; i++) {
		for (j = 0; j <= c; j++) {
			if (j == c) {
				cout << box[i][j];
			}
			else {
				cout << box[i][j] << " ";
			}
		}
		cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3148
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;

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



int main(){
    int q; cin >> q;
    VI a;
    REP(i, q){
        int op, val; cin >> op;
        switch(op){
            case 0:
                cin >> val;
                a.PB(val);
                break;
            case 1:
                cin >> val;
                cout << a[val] << "\n";
                break;
            case 2:
                a.pop_back();
        }
    }
    return 0;
}



Measured memory_bytes: 3888
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
int main(){
  int N;
  scanf("%d\n", &N);
  int *X = calloc(N, sizeof(int));
  char buff[401]={0};
  scanf("%[^\n]", buff);
  X[0]=atoi(strtok(buff, " "));
  for(int i = 1; i < N; ++i)
    X[i] = atoi(strtok(NULL, " "));
  int answer = INT_MAX;
  int kouho;
  for(int i = 0; i < 100; ++i){
    kouho = 0;
    for(int j =0; j < N; ++j){
      kouho += abs(X[j]-i) * abs(X[j]-i);
    }
    if(answer > kouho)
      answer = kouho;
  }
  printf("%d", answer);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
ll N,M;
ll sum = 0;
cin >> N >> M;
vector<int> v(M);
for(int i = 0; i<M ; i++){
  cin >> v[i];
}
for(int i = 0; i<M ; i++){
  sum+=v[i];
}
if(N<sum){
  cout << "-1" << endl;
}else{
  cout << N-sum << endl;
}
}



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


void solve(long long N, std::vector<long long> C, std::vector<long long> S, std::vector<long long> F){
    for(int i=0; i<N-1; i++){
        auto t=0l;
        for(int j=i; j<N-1; j++){
            if(t <= S[j])t=S[j]+C[j];
            else t = S[j]+C[j]+F[j]*((t-S[j])/F[j] + ((t-S[j])%F[j] == 0 ?  0: 1));
        }
        cout << t << endl;
    }
    cout << 0 << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> C(N-1);
    std::vector<long long> S(N-1);
    std::vector<long long> F(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&S[i]);
        scanf("%lld",&F[i]);
    }
    solve(N, std::move(C), std::move(S), std::move(F));
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

inline int lbit(int x) {return x & -x;}
inline void put(int x, int y) {printf("%d %d\n", x, y);}

int main() {
	int n;
	scanf("%d", &n);
	
	if(n == lbit(n)) return puts("No"), 0;
	
	puts("Yes");
	put(3, n+1);
	
	for(int i = 2; i < n - (~n&1); i += 2) {
		put(i, i+1);
		put(i, 1);
		put(i+n+1, 1);
		put(i+n, i+n+1);
	}
	
	if(~n&1) {
		int x = lbit(n), y = n ^ x;
		put(n, x);
		put(n+n, y+n+1);
	}
	return 0;
}

Measured memory_bytes: 2304
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
map<int,set<int>>mp;
int main(){
ll  n,k;
cin>>n>>k;
vector<ll> a(n),sum(n+1,0);
for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]%=k;
    sum[i+1]=sum[i]+a[i];
}
ll ans=0;
for(int i=0;i<=n;i++){
   int now=(sum[i]-i)%k;
   int b=i-k+1;
   auto ite=mp[now].lower_bound(b);
   if(ite!=mp[now].begin())mp[now].erase(mp[now].begin(),ite);
   ans+=(int)mp[now].size();
   mp[now].insert(i);
}
cout<<ans<<endl;
}



Measured memory_bytes: 31488
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef double D;
typedef long double LD;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef tuple<int,int,int> tiii;
typedef tuple<LL,LL,LL> tlll;
#define mod9 1000000009LL
#define mod7 1000000007LL
#define INF  1023456789LL
#define INF16 10000000000000000LL
#define eps 1e-9
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()
#ifndef ONLINE_JUDGE
#define debug(...) printf(__VA_ARGS__)
#else 
#define debug(...)
#endif
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add( LL _x , LL _y , LL _mod = mod7 ){
  _x += _y;
  return _x >= _mod ? _x - _mod : _x;
}
inline LL sub( LL _x , LL _y , LL _mod = mod7 ){
  _x -= _y;
  return _x < 0 ? _x + _mod : _x;
}
inline LL mul( LL _x , LL _y , LL _mod = mod7 ){
  _x *= _y;
  return _x >= _mod ? _x % _mod : _x;
}
LL mypow( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 1LL;
  LL _ret = mypow( mul( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = mul( _ret , _a , _mod );
  return _ret;
}
LL mymul( LL _a , LL _x , LL _mod ){
  if( _x == 0 ) return 0LL;
  LL _ret = mymul( add( _a , _a , _mod ) , _x >> 1 , _mod );
  if( _x & 1 ) _ret = add( _ret , _a , _mod );
  return _ret;
}
inline bool equal( D _x ,  D _y ){
  return _x > _y - eps && _x < _y + eps;
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/

void build(){

}
LL x , y;
void init(){
  x = getint();
  y = getint();
}
inline LL cal( LL a , LL b ){
  return a > b ? INF16 : b - a;
}
void solve(){
  LL ans = INF16;
  ans = min( ans , cal( x , y ) );
  ans = min( ans , cal( -x , y ) + 1 );
  ans = min( ans , cal( x , -y ) + 1 );
  ans = min( ans , cal( -x , -y ) + 2 );
  cout << ans << endl;
}
int main(){
  build();
  //__ = getint();
  while( __ -- ){
    init();
    solve();
  }
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int n,k;
int main()
{
    cin>>k;
    if(k<=500)
	{
	    n=k;
	    cout<<n<<'\n';
	    for(int i=0;i<n;i++)
		{
		    for(int j=0;j<n;j++) cout<<i+1<<' ';
		    cout<<'\n';
		}
	}
    else
	{
	    n=(k+3)/4*2;
	    cout<<n<<'\n';
	    for(int i=0;i<n;i++)
		{
		    if((i+1)&1) for(int j=0;j<n;j++) cout<<((i+j)%n+1)<<' ';
		    else
			{
			    for(int j=0;j<n;j++)
				if((i+j)%n+n+1>k) cout<<((i+j)%n+1)<<' ';
				else cout<<((i+j)%n+n+1)<<' ';
			}
		    cout<<'\n';
		}
	}
    return 0;
}

Measured memory_bytes: 1152
<?php

$stdin = trim(fgets(STDIN));  
list($a, $b, $c, $k) = explode(' ', $stdin);

if ($a >= $k) {
  echo $k;
} else if ($a + $b >= $k) {
  echo $a;
} else {
  echo $a - ($k - $a - $b);
}


Measured memory_bytes: 16088
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     ld           long double
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     (__gcd((a),(b)))
#define     lcm(a,b)     (((a)*(b))/gcd((a),(b)))
#define     pb           push_back
#define     ins          insert
#define     pii          pair<int,int>
#define     F            first
#define     S            second
#define     makep        make_pair
#define     maket        make_tuple
#define     show(x)      for(auto c:x)cout<<c<<" ";cout<<"\n";
#define     show2(x)     for(auto c:x)cout<<c.F<<" "<<c.S<<"\n";

const int inf=1e18,M=1e9+7;
const int N=21;

int dp[N][1<<N];
int val[N];

int mat[N][N];

int n;

void compute()
{
    val[0]=1;
    for(int i=1;i<N;++i)
        val[i]=2*val[i-1];
}

int go(int ind,int mask)
{
    if(ind==n)
        return 1;

    if(dp[ind][mask]!=-1)
        return dp[ind][mask];

    int res=0;
    for(int i=0;i<n;++i)
    {
        if(mat[ind][i] && !(mask&val[i]))
            res=(res+go(ind+1,mask|val[i]))%M;
    }

    return (dp[ind][mask]=res);
}

void solve()
{
    mem(dp,-1);

    compute();

    cin>>n;

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

    int ans=go(0,0);
    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}




Measured memory_bytes: 344320
using System;
using System.Linq;

class B
{
	static void Main() { Console.WriteLine(string.Join("\n", new int[int.Parse(Console.ReadLine())].Select((_, i) => new { i = i + 1, r = Console.ReadLine().Split() }).OrderBy(_ => _.r[0]).ThenBy(_ => -int.Parse(_.r[1])).Select(_ => _.i))); }
}


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

bool compare(const string& lStr, const string& rStr) {
	if(lStr.size()==rStr.size()) return lStr < rStr;
	else return lStr.size() < rStr.size();
}

int main(void){
	int n;
	cin>>n;
	vector<string> p_name;
	map<string,int> c;
	for(int i=0;i<n;++i){
		string p;int s;
		cin>>p>>s;
		if(c.find(p)!=c.end()){
			c[p]+=s;
		}else{
			p_name.push_back(p);
			c[p]=s;
		}
	}
	sort(p_name.begin(),p_name.end(),compare);
	for(int i=0;i<p_name.size();++i){
		cout<<p_name[i]<<" "<<c[p_name[i]]<<endl;
	}
	return 0;
}

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

int main(void){
    int a,b,c,x,y;
    long int sum = 0;
    cin >> a >> b >> c >> x >> y;
    int max,min,max2;
    if(x>y){
        max=x;
        if(a > 2*c)max2 = 2*c;
        else max2 = a;
        min=y;
    } else {
        max=y;
        if(b > 2*c)max2 = 2*c;
        else max2 = b;
        min=x;
    }
    if((2*c) > (a+b))sum = min*(a+b);
    else sum = min*2*c;
    sum += (max-min)*max2;
    cout << sum;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long X = sc.nextLong();
    long a = 100;
    long b = 0;
    //long b = 1;
    //long max = (int)Math.pow(10,18);
    long cnt = 0;

    for(int i=0; i<X; i++) {
      a+=a/100;
      b=a;
      cnt++;
      if(b>=X){
        break;
      }
      if(X<100){
        continue;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 35792
#include <bits/stdc++.h>
using namespace std;
#define MOD %1000000007
int main()
{
    long long int n,k;
    vector<long long int> arr(n);
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<pair<long long int ,int> > brr (n,{0,0});
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<i;j++)
        {
            if(arr[j]<arr[i])
            {
                brr[i].first++;
            }
        }
        for(int j=i+1;j<n;j++)
        {
            if(arr[j]<arr[i])
            {
                brr[i].second++;
            }
        }
    }
    long long int ans=0, earlier=0, later=0;
    for(int i=0;i<n;i++)
    {
        earlier=(earlier+(brr[i].first MOD))MOD;
        later=(later+(brr[i].second MOD))MOD;
    }
    ans=((((((k*(k+1))/2)MOD)*later)MOD)+(((((k*(k-1))/2)MOD)*earlier)MOD))MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 33024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

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

	ll A, B, C, K;
	cin >> A >> B >> C >> K;

	while (K && B <= A) {
		B <<= 1;
		K--;
	}
	while (K && C <= B) {
		C <<= 1;
		K--;
	}

	if (A < B && B < C) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll A, B, C; std::cin >> A >> B >> C;
  ll v = gcd(A, B);
  if ( C % v == 0 ) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)

ans = sum(A)

Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    ans += (C - B) * c[B]
    c[C] += c[B]
    c[B] = 0
    print(ans)


Measured memory_bytes: 24120
from heapq import heappush, heappushpop

def main():
    INF = float("inf")

    sum_B = 0
    L, R = [INF], [INF]
    sum_L = sum_R = 0

    A = map(int, open(0).read().split())

    Q = next(A)
    for _ in range(Q):
        q = next(A)
        if q == 1:
            a, b = next(A), next(A)

            sum_B += b

            if len(L) > len(R):
                l = -L[0]
                if a >= l:
                    heappush(R, a)
                    sum_R += a
                else:
                    heappushpop(L, -a)
                    sum_L += a - l
                    heappush(R, l)
                    sum_R += l
            elif not L:
                heappush(R, a)
                sum_L += a
            else:
                r = R[0]
                if a <= r:
                    heappush(L, -a)
                    sum_L += a
                else:
                    heappushpop(R, a)
                    sum_R += a - r
                    heappush(L, -r)
                    sum_L += r

        else:
            median = -L[0]
            res = (median * len(L) - sum_L) + (sum_R - median * len(R)) + sum_B
            print(median, res)

if __name__ == '__main__':
    main()


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

string s;
long long int ans = 0; 
long long int side_white = 1;

int main(){
    cin >> s;

    if(s.length() == 1){
        ans = 0;
    }else{
        for(int i = 0;i < s.length();i++){
            if(s[i] == 'W'){
                ans += (i+1) - side_white;
                side_white++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const ll longinf = 1LL << 60;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

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




long double a;

int main() {

	cin >> a;

	cout << a * PI * 2 << endl;

	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
const int maxn = 4e3 + 10;
char str[maxn] = {0};
long long sum = 0;
int n;

void ppp(char A, char B, char C){
	long long b = 0;
	for(int i = 0; i < n; i++){
		if(str[i] == C){
			b++;
		}
	}
	for(int i = 0; i < n; i++){
		if(str[i] == C) b--;
		if(str[i] == B){
			for(int j = 0; j < i; j++){
				if(str[j] == A){
					if(i + (i - j) < n && str[i + (i - j)] == C){
						sum += b - 1;
					}else{
						sum += b;
					}
				}
			}
		}
	}
}
int main(){
	scanf("%d", &n);
	getchar();
	scanf("%s", str);

	ppp('R','G','B');
	ppp('R','B','G');
	ppp('G','R','B');
	ppp('G','B','R');
	ppp('B','G','R');
	ppp('B','R','G');

	printf("%lld", sum);
	return 0;
}


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


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

    int n;
    cin >> n;

    map< long long, int > M;

    long long sum = 0;

    long long res = 0;

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

    cout << res << '\n';
}



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

int main() {
  string s; cin>>s;
  s = '0' + s;
  int n = s.size();

  // 0でちょうど払う、1で1多く払う
  vector<vector<int>> dp(n, vector<int>(2, 1e9));
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (int i = 1; i < n; i++) {
    dp[i][0] = min(dp[i-1][0] + (s[i] - '0'), dp[i-1][1] + (10 - (s[i] - '0')));
    dp[i][1] = min(dp[i-1][0] + (s[i] - '0' + 1), dp[i-1][1] + (10 - (s[i] - '0') - 1));
  }
  cout << dp[n-1][0] << endl;

  return 0;
}

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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << max(a * b, c * d) << '\n';

  return (0);
}


Measured memory_bytes: 3628
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, Q;
    cin >> N >> Q;

    struct Stop {
        ll S, T, X;
    };
    vector<Stop> stops(N);
    for (ll i = 0; i < N; i++) {
        cin >> stops[i].S >> stops[i].T >> stops[i].X;
    }

    enum Type {
        STOP_END, STOP_START, WALK_START
    };
    struct Query {
        Type type;
        ll time, pos;
        bool operator<(const Query& rhs) const {
            return (time != rhs.time ? time > rhs.time : type > rhs.type);
        }
    };
    priority_queue<Query> pq;
    for (ll i = 0; i < N; i++) {
        pq.push({ STOP_START, stops[i].S - stops[i].X, stops[i].X });
        pq.push({ STOP_END, stops[i].T - stops[i].X, stops[i].X });
    }

    struct Walker {
        ll D, index, ans;
        bool start;
    };
    vector<Walker> walkers(Q);
    for (ll i = 0; i < Q; i++) {
        cin >> walkers[i].D;
        walkers[i].index = i;
        walkers[i].ans = -1;
        pq.push({ WALK_START, walkers[i].D, -1 });
    }

    map<ll, bool> mp;
    priority_queue<ll, vector<ll>, greater<>> min_pq;
    while (!pq.empty()) {
        auto top = pq.top();
        pq.pop();

        if (top.type == STOP_START) {
            min_pq.push(top.pos);
            mp[top.pos] = true;
        } else if (top.type == STOP_END) {
            mp[top.pos] = false;
        } else {
            if (min_pq.empty()) {
                cout << -1 << endl;
                continue;
            }

            while (!mp[min_pq.top()]) {
                min_pq.pop();
                if (min_pq.empty()) {
                    break;
                }
            }

            if (min_pq.empty()) {
                cout << -1 << endl;
                continue;
            }

            cout << min_pq.top() << endl;
        }
    }
}

Measured memory_bytes: 41828
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
int64_t ans = 1;
cin >> N;
for (int i = 1;i <= N;i++) {
    ans *= i;
    if (ans >= 1000000007) {
        ans %= 1000000007;
    }
}
cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>n;
  ll dp[87] = {0};
  dp[0] = 2;
  dp[1] = 1;

  repl(i,2,n+1) dp[i] = dp[i-1] + dp[i-2];

  cout<<dp[n]<<endl;

}

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


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

using namespace std;

signed main() {
	int n;
	cin >> n;
	map<long, int> m;
	vector<long> v = {};
	for (int i = 0; i < n; i++) {
		long t;
		cin >> t;
		if (!m.count(t)) {
			m[t] = 0;
		}
		m[t] = m[t] + 1;
		if (m[t] % 2 == 0) {
			vector<long>::iterator it = lower_bound( v.begin(), v.end(), t);
			v.insert(it, t);
		}
	}
	for (size_t i = 0; i < v.size(); i++) {
		// cout << "v:" << v.at(i) << endl;
	}
	if (v.size() < 2) {
		cout << 0 << endl;
		return 0;
	}
	long h = v.at(v.size() - 1);
	long w = v.at(v.size() - 2);

	// cout << h << " " << w << endl;
	cout << h * w << endl;
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<lint, lint> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	string S;
	cin >> S;
	int Z = S.size();
	int c0 = 0;
	int c1 = 0;
	rep(i, Z) {
		if (S[i] == '0')c0++;
		if (S[i] == '1')c1++;
	}
	cout << 2 * min(c0, c1) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
int main()
{
    ios;
    ll deg[5];
    memset(deg , 0 , sizeof deg);
    for(ll i = 1; i<=3;++i){
        ll x, y;
        cin >> x>> y;
        deg[x]++;
        deg[y]++;
    }
    ll deg1 = 0 ;
    ll deg2  = 0;
    for(ll i =1 ;i<=4;++i){
        if(deg[i]==1){
            ++deg1;
        }
        else if(deg[i]==2){
            ++deg2;
        }
    }
    if(deg1 == 2 and deg2 == 2){
        cout <<"YES\n";
        return 0;
    }
    else {
        cout <<"NO\n";
        return 0;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

int main(){
  ll N,M,X;cin>>N>>M>>X;
  vector<ll> c(N);
  vector<vector<ll>> a(N,vector<ll>(M,0));
  for(int i=0;i<N;i++){
    cin>>c[i];
    for(int j=0;j<M;j++){
      cin>>a[i][j];
    }
  }
  ll min=1000000000;
  ll bit=0;
  for(ll i=0;i<(1<<N);i++){
    vector<ll > score(M,0);
    ll sum=0;
    for(int j=0;j<N;j++){
      ll tmp=pow(2,j);
      if((tmp&i)==tmp){
        sum+=c[j];
        for(int r=0;r<M;r++){
          score[r]+=a[j][r];
        }
      }
    }
    int count=0;
    for(int r=0;r<M;r++){
      if(score[r]>=X){
        count++;
      }
    }
    if(count==M){
      if(min>sum){
        min=sum;
      }
    }
  }
  if(min!=1000000000){
    cout<<min<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3148
#!/usr/bin/env runghc
import Control.Applicative

run n
		| n>0 = do
			[y,m,d] <- map read . words <$> getLine
			putStrLn (show (196471-((y-1)*195)-(div (y-1) 3)*5-(m-1)*20+(if ((mod y 3)==0) then 0 else (div (m-1) 2))-d))
			run (n-1)
		| otherwise = return ()

main = readLn >>= run

Measured memory_bytes: 4216
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    vector<vector<int>> arr(3,vector<int>(3)),vis(3,vector<int>(3,0));
    F0R(i,3)
    {
        F0R(j,3)
            cin >> arr[i][j];
    }
    int n;
    cin >> n;
    F0R(i,n)
    {
        int e;
        cin >> e;
        F0R(i,3)
        {
            F0R(j,3)
            {
                if(arr[i][j]==e)
                    vis[i][j]=1;
            }
        }
    }
    F0R(i,3)
    {
        int tot=0;
        F0R(j,3)
            tot+=vis[i][j];
        if(tot==3)
        {
            cout << "Yes";
            return 0;
        }
    }
    F0R(j,3)
    {
        int tot=0;
            F0R(i,3)
            tot+=vis[i][j];
        if(tot==3)
        {
            cout << "Yes";
            return 0;
        }
    }
    if(vis[0][0]+vis[1][1]+vis[2][2]==3 || vis[0][2]+vis[1][1]+vis[2][0]==3)
    {
        cout << "Yes";
        return 0;
    }
    cout << "No";

    return 0;
}


Measured memory_bytes: 256