akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        Console.WriteLine((double)(n - n / 2) / n);
    }

    static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0;
            int next = Console.In.Read();
            int sign = 1;
            while (45 > next || next > 57) next = Console.In.Read();
            if (next == 45) { next = Console.In.Read(); sign = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = Console.In.Read();
            }
            return res * sign;
        }
    }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll n;
 cin>>n;
 string t;
 ll ans=0,b=0,a=0,ab=0;
 rep(i,0,n){
  cin>>t;
  ll l=t.length();
  rep(j,0,l-1){
   if(t[j]=='A'&&t[j+1]=='B')ans++;
  }
  if(t[0]=='B'&&t[l-1]=='A')ab++;
  else if(t[0]=='B')b++;
  else if(t[l-1]=='A')a++;
 }
// cout<<a<<" "<<b<<" "<<ab<<" "<<ans<<endl;
 if(ab==0)ans+=min(a,b);
 else if(a+b>0)ans+=ab+min(a,b);
 else if(a+b==0)ans+=ab-1;
 pr(ans);
return 0;}

Measured memory_bytes: 3656
/// In The Name Of God

#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)

#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = (int)5e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

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

using namespace std;

ll n;
int a[N], df[N];
int main() {
	#ifdef IOI2018
		freopen ("in.txt", "r", stdin);
	#endif
	Kazakhstan
	cin >> n;
	ll sum = 0;
	rep(i, 1, n) {
		cin >> a[i];
		sum += a[i];
	}
	rep(i, 1, n) {
		if (i < n) df[i] = a[i + 1] - a[i];
		else df[i] = a[1] - a[n];
	}
	if (sum % (n * (n + 1) / 2)) cout << "NO", ioi
	ll k = sum / (n * (n + 1) / 2);
	ll cur = 0, cnt = 0;
	rep(i, 1, n) {
		df[i] -= k;
		cur += df[i];
		if (df[i] > 0 || df[i] % n) cout << "NO", ioi
		if (df[i] < 0) ++cnt;
	}
	//cout << "DA";
	if (cur % n || abs(cur) / n != k) cout << "NO", ioi
	cout << "YES";
	ioi
}


Measured memory_bytes: 1024
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define MOD  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
#define all(x) x.begin(),x.end()
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int n;cin>>n;
    int suma=0,sumb=0;
    int a[114514],b[114514];
    rep(i,0,n){
        cin>>a[i];suma+=a[i];
    }
    rep(i,0,n){
        cin>>b[i];sumb+=b[i];
    }
    if(suma<sumb){
        cout<<-1<<endl;return 0;
    }
    vector<int>v;
    int k=0;
    int ans=0;
    rep(i,0,n){
        if(a[i]<b[i]){
            k+=b[i]-a[i];ans++;
        }
        else v.ps(a[i]-b[i]);
    }
    sort(all(v));
    reverse(all(v));
    int i=0;
    while(k>0){
        ans++;
        k-=v[i++];
    }
    cout<<ans<<endl;return 0;
}

Measured memory_bytes: 2936
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#define INF (long)1e9
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	set<ll> st;
	ll x;
	for(int i = 0; i < n; i++)
	{
		cin >> x;
		if(st.find(x) != st.end())
			st.erase(x);
		else
			st.insert(x);
	}
	cout << st.size() << endl;
	return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=~(1<<31),MAXN=1e6+10;
const int MOD=1e9+7;

map<ll,ll> mp;

ll dfs(ll now)
{
    ll ans=0;
    if(mp[now])return mp[now];
    if(now==1)return 2;
    if(now==0)return 1;
    if(now&1)
    {
        ans+=2*dfs(now/2);
        ans+=dfs(now/2-1);
    }
    else
    {
        ans+=dfs(now/2);
        ans+=2*dfs(now/2-1);
    }
    mp[now]=ans%MOD;
    return ans%MOD;
}

int main()
{
    ll n;
    scanf("%lld",&n);
    cout<<dfs(n);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <deque>
#include <vector>
#define MAX 10010
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
using namespace std;
int n,hoge,foo;
int graph[MAX][MAX] = {0};
int main(){
  cin >> n;
  rep(i,n) {
    cin >> hoge >> foo;
    rep(j,foo) {
      cin >> hoge;
      graph[i][hoge-1] = 1;
    }
  }
  rep(i,n) {
    cout << graph[i][0];
    for(int j=1;j<n;j++) cout << " " << graph[i][j];
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3420
#include <iostream>
using namespace std;
int main(){
  int N,Y;
  cin >> N >> Y;
  for(int n1 = 0;n1<=N;n1++){
    for(int n2 = 0;n2<=N;n2++){
      int n3 = N-n1-n2;
      if(n3>=0 && n3<=N && Y==(n1*10000+n2*5000+n3*1000)){
        cout << n1  << "  " << n2 << "  " << N-n1-n2 << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
  return 0;
}

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

int main(){
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << "#";

			}
			cout<<endl;
		}
cout<<endl;
	}
	
}



Measured memory_bytes: 3080
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 2000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n;
  ll x;
  map<ll,int> m;
  cin>>n;
  rep(i,n){
    cin>>x;
    m[x]++;
  }
  int ans=0;

  for(auto itr = m.begin(); itr != m.end(); ++itr) {
    if(itr->second%2==1)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

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



//解説読めば余裕なのでやり直し
//---main---------------------------------------------
int main(){
    //main
    int N;
    cin >> N;

    vector<int> count(100010);
    ll Asum = 0;
    int A;
    rep(i,N){
        cin >> A;
        count[A]++;
        Asum += A;
    }

    int Q,B,C,Bnum;
    cin >> Q;
    rep(qi,Q){
        cin >> B >> C;
        Bnum = count[B];
        count[B] = 0;
        count[C] += Bnum;
        Asum += (C-B)*Bnum;
        cout << Asum <<  endl;
    }

    return 0;
}

Measured memory_bytes: 3768
from sys import stdin 
a,b,c,d,e,f = map(int,stdin.readline().split())
fir = [0] * (f+1)
sec = [0] * (f+1)
# first check what water and sugar amounts are possible
fir[0] = sec[0] = 1 
for i in xrange(f+1):
    nex = i + a*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i + c 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
    nex = i + b*100 
    if nex<=f and fir[i]:
        fir[nex] = 1 
    nex = i +  d 
    if  nex<=f and sec[i]:
        sec[nex] = 1 
valid = []
for i in xrange(1,f+1):
    for j in xrange(0,f+1):
        # taking i water and j sugar
        if fir[i] and sec[j]:
            if i +  j<=f:
                if e*i >= 100*j:
                    valid.append((i,j))
num = -1
den = 1*100
for y,x in valid:
    if x*den > y*num:
        num = x
        den = y
print num+den,num

Measured memory_bytes: 3460
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<climits>
#define ll long long int
using namespace std;

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int n, m, x;
	cin >> n >> m >> x;
	vector<int> cost(n);
	vector<vector<int>> skill(n, vector<int> (m));
	for (int i = 0; i < n; i++)
	{
		cin >> cost[i];
		for (int j = 0; j < m; j++)
		{
			cin >> skill[i][j];
		}
	}


	int ways = pow(2, n);
	int min_cost = INT_MAX;

	for (int i = 1; i < ways; i++)
	{
		int t = i;
		int ct = 0;
		vector<int> tmp(m, 0);
		int k = 0;
		while (t)
		{
			int flag = 0;
			if (t % 2)
			{
				ct += cost[k];
				for (int j = 0; j < m; j++ )
				{
					tmp[j] += skill[k][j];
					if (tmp[j] >= x)
						flag++;
				}
			}
			t /= 2;
			k++;
			if (flag == m)
			{
				if (ct < min_cost)
					min_cost = ct;
				break;
			}
		}

	}
	if (min_cost == INT_MAX)
		min_cost = -1;
	cout << min_cost;

	return 0;

}

Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{
int n ,m;
cin>>n>>m;
cin.ignore();
char s[n][m];
for(int index = 0 ;index <n ;index++)
    for(int j = 0 ; j< m ;j++)
    cin>>s[index][j];


    for(int  i= 0 ; i< n ; i++)
    {
        for(int j= 0; j<m;j++)
        {
            if(s[i][j]=='.')
            {
                int ans = 0;
                if(j+1<m&&s[i][j+1]=='#')ans++;
                if(j-1>=0&&s[i][j-1]=='#')ans++;

                if(i-1>=0)
                {
                    if(s[i-1][j]=='#')ans++;
                    if(j+1<m&&s[i-1][j+1]=='#')ans++;
                    if(j-1>=0&&s[i-1][j-1]=='#')ans++;
                }

                if(i+1<n)
                {
                    if(s[i+1][j]=='#')ans++;
                    if(j+1<m&&s[i+1][j+1]=='#')ans++;
                    if(j-1>=0&&s[i+1][j-1]=='#')ans++;
                }
                cout<<ans;
            }
            else
                cout<<"#";
        }
        cout<<endl;
    }
 return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  ll n, m;
  cin >> n >> m;
  
  vector<pair<ll, ll> > ab(n);
  REP(i,n){
    cin >> ab[i].first >> ab[i].second;
  }
  sort(all(ab));
  // cout << "ab " << endl;
  // REP(i, n){
  //   cout << ab[i].first << " " << ab[i].second << endl;
  // }
  ll num = 0;
  ll price = 0;
  ll ind = -1;
  // cout << "ind, num = "<< ind << " "<< num <<" " << m <<  endl;
  // cout <<" loop" << endl;
  while(m >= num){
    ind ++;
    price += (ll)(ab[ind].first*ab[ind].second);
    num += ab[ind].second;
    // cout << "ind, num = "<< ind << " "<< num << endl;
  }
  // cout <<" loop" << endl;
  // cout << "ind, num = "<< ind << " "<< num << endl;
  if(num == m){
    cout << price << endl;
  }else{
    price -= (ll)(ab[ind].first*(num - m));
    cout << price << endl;
  }

}



Measured memory_bytes: 1792
#残り1種類のグループとそうでないグループに分けておく，残り1種類になったら移動
#判定のため，各tごとにdのリスト（ソート済み）と，dのリストを参照する番号を持っておく

import heapq

N,K=map(int,input().split())
dt=[[0,0] for _ in range(N)]
gr=[[] for _ in range(N+1)]#tの種類ごとにまとめる
x=0#種類数
ans=0#先に全部食べたことにして，いらないものを除く

for i in range(N):
    dt[i][1],dt[i][0]=map(int,input().split())
    dt[i][1]-=1
    ans+=dt[i][0]
    if gr[dt[i][1]]==[]:
        x+=1
    gr[dt[i][1]].append(dt[i])
ans+=x*x

single=[]
multi=[]
heapq.heapify(single)
heapq.heapify(multi)

num_i=[0]*N#各tに対してどこを見るか

for i in range(N):
    gr[i].sort()
    if gr[i]!=[]:
        if len(gr[i])==1:
            heapq.heappush(single,gr[i][0])
        else:
            heapq.heappush(multi,gr[i][0])
    
inf=10**19
heapq.heappush(single,[inf,N])#絶対に選ばないものを入れておく
heapq.heappush(multi,[inf,N])
    
    
    
for i in range(N-K):
    a=heapq.heappop(single)
    b=heapq.heappop(multi)
    if a[0]+(2*x-1)<=b[0]:#種類ボーナスも含めて小さい方を取り除く
        ans-=a[0]+(2*x-1)
        x-=1
        heapq.heappush(multi,b)
    else:
        ans-=b[0]
        heapq.heappush(single,a)
        tt=b[1]
        num_i[tt]+=1
        if num_i[tt]==len(gr[tt])-1:
            heapq.heappush(single,gr[tt][-1])
        else:
            heapq.heappush(multi,gr[tt][num_i[tt]])
                                       
print(ans)

    

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

int main() {
	int n;
	cin >> n;
	vector<int> l(2 * n);
	for (auto& e : l) {
		cin >> e;
	}
	sort(begin(l), end(l));
	int m = 0;
	for (int i = 0; i < n; i++) {
		m += l[2 * i];
	}
	cout << m << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(var):
	print(var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
# from collections import defaultdict as dd, Counter
# from bisect import bisect_left as bl, bisect_right as br

a = []
a.append(I()[0])
a.append(I()[0])
for i in range(1, 4):
	if i not in a:
		print(i)
		break


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b;
  while(true){
    cin>>a>>b;
    if(a+b==0){
      break;
    }
    for(int i=0;i<a;i++){
      for(int j=i;j<b+i;j++){
	if(j%2==0){
	  cout<<"#";
	}
	if(j%2==1){
	  cout<<".";
	}
      }
      cout<<"\n";
    }
    cout<<"\n";
  }
  return(0);
}



Measured memory_bytes: 3084
D,N=map(int,input().split())

if D==0:
  if N!=100:
    print(N)
  else:
    print(101)
elif D==1:
  if N!=100:
    print(N*100)
  else:
    print(10100)
else:
  if N!=100:
    print(N*10000)
  else:
    print(1010000)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		int[] a = new int[100000];
		int[] b = new int[100000];
		int[] x = new int[100000];
		int[] y = new int[100000];
		int[] c = new int[100000];

		Scanner scan = new Scanner(System.in);
		int aa = scan.nextInt();
		int bb = scan.nextInt();
		int mm = scan.nextInt();

		for (int i=0; i<aa; i++) {
			a[i] = scan.nextInt();
		}

		for (int i=0; i<bb; i++) {
			b[i] = scan.nextInt();
		}

		for (int i=0; i<mm; i++) {
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
			c[i] = scan.nextInt();
		}
		scan.close();
		int ans = 1000000;
		int minA = 100001;
		int minB = 100001;

		for (int i=0; i<aa; i++) {
			if (a[i] < minA) {
				minA = a[i];
			}
		}
		for (int i=0; i<bb; i++) {
			if (b[i] < minB) {
				minB = b[i];
			}
		}
		ans = minA + minB;

		for (int i=0; i<mm; i++) {
			if (a[x[i]-1] +b[y[i]-1] - c[i] < ans) {
				ans = a[x[i]-1] + b[y[i]-1] - c[i];
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 155080
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;
    long long A, B;
    while(cin >> N >> A >> B){
        vector<int> p(N);
        for(auto& t : p) cin >> t;
        vector<long long> dp(2*N+1, 0);
        bool find1 = false;
        for(int i=0;i<=2*N;i++){
            if(i%2 == 1 && p[i/2] == 1){
                find1 = true;
            } else {
                dp[i] = (find1 ? A : B);
            }
        }
        for(int i=2;i<=N;i++){
            vector<long long> next(2*N+1, 0);
            long long m = dp[0];
            bool find = false;
            for(int j=0;j<=2*N;j++){
                if(j%2 == 1){
                    if(p[j/2] == i){
                        next[j] = m;
                        find = true;
                    } else {
                        next[j] = m + (find ? A : B);
                    }
                } else {
                    next[j] = min(m, dp[j]) + (find ? A : B);
                }
                m = min(m, dp[j]);
            }
            dp = next;
        }
        cout << *min_element(dp.begin(), dp.end()) << endl;
    }
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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; }


const string YES = "Yes";
const string NO = "No";

void func(long long X){

    if(X>=30){
        cout<<YES<<endl;
    }
    else{
        cout<<NO<<endl;
    }

}

int main(){
    // cout << fixed << setprecision(5);

    long long X;
    scanf("%lld",&X);
    func(X);
    return 0;
}


Measured memory_bytes: 3764
package main

import (
	"fmt"
	"strconv"
)

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

	n := len(s) - 1
	sum := 0
	for bit := 0; bit < (1 << uint(n)); bit++ {
		last := 0
		for i := 0; i < n; i++ {
			if bit&(1<<uint(i)) != 0 {
				term, _ := strconv.Atoi(s[last : i+1])
				sum += term
				last = i + 1
			}
		}
		term, _ := strconv.Atoi(s[last:])
		sum += term
	}
	fmt.Println(sum)
}


Measured memory_bytes: 512
import numpy as np

N, D = map(int,input().split())
X = []
cnt = 0
for i in range(N):
    X.append(list(map(int,input().split())))

X = np.array(X)
for k in range(N):
    for l in range(k+1, N):
        Xd = X[k] - X[l]
        dis = np.linalg.norm(Xd, ord=2)

        if dis.is_integer():
            cnt += 1

print(cnt)

Measured memory_bytes: 27296
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	int N = 8;
	int[] row = new int[N];
	boolean[] col = new boolean[N];
	boolean[] dpos = new boolean[2 * N - 1];
	boolean[] dneg = new boolean[2 * N - 1];
	boolean[][] map = new boolean[N][N];

	void initialize() {
		Arrays.fill(row, -1);
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		Arrays.fill(row, -1);
		while (n-- > 0) {
			int i = scanner.nextInt();
			int j = scanner.nextInt();
			row[i] = j;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = true;
		}
		slove(0);
	}

	boolean flag = false;

	private void slove(int i) {
		if (i == N) {
			flag = true;
			print();
			return;
		}
		if (row[i] != -1)
			slove(i + 1);

		for (int j = 0; j < N; j++) {
			if (flag)
				return;
			if (row[i] != -1)
				return;
			if (col[j] || dpos[i + j] || dneg[i - j + N - 1])
				continue;
			row[i] = j;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = true;
			slove(i + 1);
			row[i] = -1;
			col[j] = dpos[i + j] = dneg[i - j + N - 1] = false;

		}
	}

	private void print() {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				System.out.print(row[i] == j ? 'Q' : '.');
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17368
t1, t2 = map(int, input().split())
a1, a2 = map(int, input().split())
b1, b2 = map(int, input().split())

sa = a1 * t1 + a2 * t2
sb = b1 * t1 + b2 * t2

if sa == sb:
	print("infinity")
	exit()

# a is faster
if sa < sb:
	a1, a2, b1, b2 = b1, b2, a1, a2
	sa, sb = sb, sa
delta = sa - sb

# no meeting
if a1 > b1:
	print(0)
	exit()

# count the meeting in T1 period
cnt = (b1 - a1) * t1 // delta

# count the meeting in T2 period
cnt += (b1 - a1) * t1 // delta + 1

# common one
if (b1 - a1) * t1 % delta == 0:
	cnt -= 1

print(cnt)

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define REP(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define INF 10000000
#define ll long long

using namespace std;

typedef pair<int, int> P;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int K;
int d[100000];

int main(){
    scanf("%d", &K);

    REP(i, K) d[i] = INF;
    d[1] = 1;

    deque<int> que;
    que.push_back(1);

    while(!que.empty()){
        int t = que.front(); que.pop_front();
        if(t == K) continue;

        int a = (t + 1) % K;
        int b = (t * 10) % K;

        if(d[t] + 1 < d[a]){
            d[a] = d[t] + 1;
            que.push_back(a);
        }
        if(d[t] < d[b]){
            d[b] = d[t];
            que.push_front(b);
        }
    }

    printf("%d", d[0]);

	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main()
{int a,b,c;
 int d;cin>>a>>b>>c;
 d=max(max(a,b),c);
 if(d==a)cout<<d*10+b+c;
 else if(d==b)cout<<d*10+a+c;
 else cout<<d*10+a+b;
}



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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

struct segtree {
    int N, dat[int(1e6+5)];

    segtree(int n) {
        N = 1;
        while(N < n) N *= 2;
//        for(int i = 0; i < 2*N-1; i++) dat[i] = 0;
    }
    // update k th element
    void update(int k, int a) {
        k += N-1; // leaf
        dat[k] = a;
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = max(dat[k*2+1], dat[k*2+2]);
        }
    }
    // min [a, b)
    int query(int a, int b) { return query(a, b, 0, 0, N); }
    int query(int a, int b, int k, int l, int r) {
        if(r <= a or b <= l) return 0;
        if(a <= l and r <= b) return dat[k];
        int m = (l + r) / 2;
        return max(query(a, b, k*2+1, l, m), query(a, b, k*2+2, m, r));
    }
};

int main(){
  int n, k; cin >> n >> k;

  segtree S(300005);

  for (int i = 0; i < n; i++){
    int A; cin >> A;
    int val = S.query(max(0, A - k), min(int(3e5), A + k) + 1);
    S.update(A, val + 1);
  }


  cout << S.query(0, int(3e5+1)) << endl;

  return 0;
}

Measured memory_bytes: 6048
#include<iostream>
using namespace std;
int main(){
  string b;
  cin >> b;
  
  if(b=="A") cout << "T" << endl;
  if(b=="T") cout << "A" << endl;
  if(b=="G") cout << "C" << endl;
  if(b=="C") cout << "G" << endl;
  
  return 0;
}

Measured memory_bytes: 256
icase=46    
if icase==46:
    a=list(map(int,input().split()))
    icnt=1
    if a[0]!=a[1]:
        icnt=icnt+1
    if a[0]!=a[2] and  a[1]!=a[2]:
        icnt=icnt+1
    print(icnt)

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


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<int>> a(h+1, vector<int>(w+1, 0));
    vector<string> s(h);
    int id = 1;
    rep(i,h) {
        cin >> s[i];
        int cnt = 0;
        rep(j,w) if(s[i][j]=='#') cnt++;
        if(cnt==0){
            if(i)rep(x, w) a[i][x]=a[i-1][x];
        }
        else{
            int next = id;
            rep(j,w){
                if(s[i][j]=='#') next=id++;
                a[i][j]=next;
            }
        }
    }
    for(int i = h-1; i >= 0; --i) {
        if(a[i][0]==0){
            rep(j,w) a[i][j] = a[i+1][j];
        }
    }
    rep(i,h) {
        rep(j,w) cout << a[i][j] <<" ";
        cout << endl;
    }

    return 0;
} 

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

using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n, 0);
  a[0] = 1;
  vector<int> count(n, 1);
  for (int i = 0; i < m; i++) {
    int x1, x2;
    cin >> x1 >> x2;
    x1--; x2--;
    count[x1]--;
    count[x2]++;
    if (count[x2] == 0) {
      a[x2] = a[x1];
    } else {
      a[x2] = std::max(a[x2], a[x1]);
    }
    if (count[x1] == 0) {
      a[x1] = 0;
    }
  }  
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 0) {
      res++;
    }
  }  
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 1024
N = int(input())
mozi = input()
mozi2 = list(mozi)
num_w = mozi2.count("W"); num_r = mozi2.count("R")
list_w2 = mozi2[(N-num_w):]; list_w1 = mozi2[:(N-num_w)]
list_r2 = mozi2[num_r:]; list_r1 = mozi2[:num_r]
if num_w <= num_r:
    if "W" in list_w2:
        print(list_w1.count("W"))
    else:
        print(num_w)
else:
    if "R" in list_r1:
        print(list_r2.count("R"))
    else:
        print(num_r)

Measured memory_bytes: 13896
#include <iostream>

using namespace std;
int main() {
  string s;
  cin >> s;
  int k = s.size();
  string ans = "Good";
  for (int i=0; i<k-1; i=i+1){
    if (s[i+1] == s[i]) {
      ans = "Bad";
      break;
    }
  }
  cout << ans << endl;
}

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

int main(){
  vector<int> n(101, 0);
  for(int i=0; i<3; ++i){
    int x;
    cin >> x;
    n.at(x)++;
  }
  for(int i=1; i<=100; ++i){
    if(n.at(i) == 2){
      cout << 2 << endl;
      return 0;
    }else if(n.at(i) == 3){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 3 << endl;
  return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

calc :: (Int, Int) -> (Int, Int) -> Int -> Int
calc (pc2, pc1) (ph2, ph1) h = min c2 c1 
  where c2 = pc2 + abs (ph2 - h)
        c1 = pc1 + abs (ph1 - h)

solve :: [Int] -> (Int, Int) -> (Int, Int) -> [Int]
solve [] _ _ = []
solve (h:hs) pcs@(pc2, pc1) phs@(ph2, ph1) = cost : next
  where cost = calc pcs phs h
        next = solve hs (pc1, cost) (ph1, h)

main :: IO ()
main = do
  getLine
  (h:hs) <- readIntsLine
  print . last $ solve hs (0, 0) (h, h)


Measured memory_bytes: 23164
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string s; cin >> s;
    string ans;
    ll len = 0;
    REP(l, s.size()){
        FOR(r, l, s.size()){
            bool ok = true;
            FOR(i, l, r+1){
                if(!(s[i] == 'A'|| s[i] == 'C' || s[i] == 'G' || s[i] == 'T')){
                    ok = false; break;
                }
            }
            if(ok){
                if(r-l+1 >= len){
                    len = r-l+1;
                }
            }
        }
    }
    cout << len << endstr;
    return 0;
}


Measured memory_bytes: 256
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int> > G;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Ans[2] = {"No", "Yes"};
string ANS[2] = {"NO", "YES"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

void bfs(int v, vi &dist, vector<vi> &graph)
{
    fill(all(dist), -1);
    dist[v] = 0;
    vi q = {v};
    for (int i = 0; i < q.size(); i++)
    {
        for (auto u : graph[q[i]])
        {
            if (dist[u] == -1)
            {
                dist[u] = dist[q[i]] + 1;
                q.push_back(u);
            }
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a, b;
    cin >> a >> b;
    cout << (a + b) % 24;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


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

double cost[101][101];
double mincost[101];
bool used[101];
double x[101], y[101], z[101], r[101];
double INF = numeric_limits<double>::max();
int main(void){
    int n;
    while(cin >> n && n) {
        rep(i, n) {
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }
        rep(i, n) rep(j, n) {
            cost[i][j] = max(sqrt(pow(x[i]-x[j], 2.0) + pow(y[i]-y[j], 2.0) + pow(z[i]-z[j], 2.0)) - r[i] - r[j], 0.0);
        }
        // prim
        rep(i, n) {
            mincost[i] = INF;
            used[i] = false;
        }
        mincost[0] = 0;
        double res = 0;

        while(true) {
            int v = -1;
            rep(u, n) {
                if(!used[u] && (v==-1 || mincost[u] < mincost[v])) v = u;
            }
            if(v == -1) break;
            used[v] = true;
            res += mincost[v];

            rep(u, n) {
                mincost[u] = min(mincost[u], cost[v][u]);
            }
        }
        printf("%.3lf\n", res);
    }
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;

vector<int> v;

int mod(ll x){
    return x % MOD;
}
int modm(ll x,ll m){
    return x * m % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

ll conv(int n,int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return modd(v[n],modm(v[k],v[n-k]));
}

int main(void)
{
    IOS
    int n,k; cin >> n >> k;

    v.resize(n+1);
    v[0] = 1;
    v[1] = 1;
    FOR(i,2,n+1) {
        v[i] = modm(v[i-1],i);
    }

    FOR(i,1,k+1) {
        ll x = modm(conv(n-k+1,i) ,conv(k-1,i-1));
        cout << x << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

map<string,int>mp;
vector<string>vec;

int main(){

	int K;

	string s;

	cin>>s;
	cin>>K;

	int i;

	int len=s.length();

	int num=1;

	while(1){

		if(num>len || num>=6){break;}

		for(i=0;i<len;i++){

			if(i+num>len){continue;}

			string substring=s.substr(i,num);
			if(mp[substring]!=1){
				mp[substring]=1;
				vec.push_back(substring);
			}

		}

		num++;

	}

	sort(vec.begin(),vec.end());

	cout<<vec[K-1]<<endl;

	return 0;
}

Measured memory_bytes: 2048
f=->n,k{
  n<0 ? 0 : k==0 ? 1 : n==0 ? 0 : n%10*f[n/10,k-1]+(9-n%10)*f[n/10-1,k-1]+f[n/10,k]
}
p eval"f[%d,%d]"%[*$<]

Measured memory_bytes: 4220
#include <stdio.h>

int main(void){
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if(a == b){
		printf("a == b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a > b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int a,b,h; cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double EPS = 1e-9;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int n;
int s[100];

int main() {
	// cin.tie(0); // tie
	// ios::sync_with_stdio(false); // sync
	while (cin >> n, n) {
		int mini = 10000, maxi = -1;
		int sum = 0;
		rep(i, n) {
			int s; cin >> s;
			mini = min(mini, s);
			maxi = max(maxi, s);
			sum += s;
		}
		int av = (sum - mini - maxi) / (n - 2);
		cout << av << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void add(int &x, int v) { x += v; if (x >= MOD) x -= MOD; }
inline long long mul(int x, int y) { return (1LL*x*y) % MOD; }
const int B = 10001;

int N, K;
int pK[101];
int dp[2][B];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N >> K;
  pK[0] = 1;
  for (int i=1; i<=N; i++) pK[i] = (1LL*(K+1)*pK[i-1]) % MOD;
  int ans = 0;
  dp[0][0] = 1;
  for (int i=N; i>=1; i--) {
    rep(j, B) dp[1][j] = 0;
    for (int s=B-1; s>=0; s--) {
      if (dp[0][s] == 0) continue;
      for (int t=0; t<=K; t++) {
        if (t > i) {
          add(dp[1][s], dp[0][s]);
          add(ans, mul(pK[i-1], mul(dp[0][s], t+s)));
        }
        else {
          add(dp[1][s+(t+s)/i], dp[0][s]);
          add(ans, mul(pK[i-1], mul(dp[0][s], (t+s)%i)));
        }
      }
    }
    swap(dp[0], dp[1]);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 384
import Data.List

import Control.Monad
main = do
  s <- getLine
  putStrLn . show $ solve s

solve :: String -> Int
solve xs = (inSolve xs (reverse xs)) `div` 2

inSolve [] [] = 0
inSolve (x:xs) (y:ys) = (if x /= y then 1 else 0) + (inSolve xs ys)


Measured memory_bytes: 508
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws IOException {

    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    double debt = 100_000;
    while (input.ready()) {
      int weeks = Integer.valueOf(input.readLine());
      for (int i = 0; i < weeks; i++) {
        debt += debt * 0.05;
        double hasuu = debt % 1000;
        if (hasuu > 0) {
          debt += 1000 - hasuu;
        }
      }
      System.out.println((int) debt);
    }
  }

}

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

int main() {
    int n;
    vector<int> L;
    int i, j, k;
    int a, b;

    int sum = 0;
    int tmp;

    cin >> n;
    for(i = 0; i < n; i++) {
        cin >> tmp;
        L.push_back(tmp);
    }
    sort(L.begin(), L.end());

    for(j = 0; j <n; j++) {
        b = L[j];
        for(i = 0; i < j; i++) {
            a = L[i];
            int ab = a+b;
            int r = lower_bound(L.begin(), L.end(), ab) - L.begin();
            int l = j + 1;
            sum += r-l;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    double a, b;
    cin >> a >> b;
    double x = (a + b) / 2.0;
    cout << ceil(x) << endl;
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i=0; i<N; i++){
		cin >> a[i];
		a[i] = N*a[i];
	}
	int ave = 0;
	for(int i=0; i<N; i++){
		ave = ave + a[i];
	}
	ave = ave/N;
	int min = 0;
	for(int i=1; i<N; i++){
		if(abs(ave - a[min]) > abs(ave - a[i])){
			min = i;
		}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
MOD=10**9+7

def main():
    N,K=map(int,input().split())
    ans=0
    for k in range(K,N+2):
        small=k*(k-1)//2
        big=k*(2*N-k+1)//2
        ans+=(big-small+1)%MOD
        ans%=MOD
    print(ans)

main()


Measured memory_bytes: 9152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

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

using ll = long long;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	cout << c << " " << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S,T;
  cin >> S >> T;
  int answer=0;
  
  for(int i=0; i<3 ; i++){
 
    if(S[i]==T[i]){
      answer++;
    }
    
  }
  
  cout << answer <<endl;
  
  
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	REP(i, 3) {
		char c;
		cin >> c;
		cout << c;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3564
#include<stdio.h>

long long int kaijo(long long int);


int main()
{
	long long int n;
	scanf("%lld", &n);
	printf("%lld\n", kaijo(n));
}

long long int kaijo(long long int n)
{
	if (n == 0)return 1;
	return n*kaijo(n - 1);
}

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

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  for (int i = a; i <= b; i++)
  {
    if (c % i == 0)
    {
      ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
    long long int n;
    cin>>n;
    long long int counter=0;
    for(long long int i=1;i<=n;i++){
        if(i%3==0||i%5==0){
        }else{
            counter+=i;
        }
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 3628