akhauriyash/Code-Regression huggingface dataset:
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN = (int) 1e3 + 10;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int N;
int arr[MAXN],b[MAXN];
int p[MAXN];
int siz[MAXN],mi[MAXN],sum[MAXN];

int Find(int x){
    return x==p[x] ? x : p[x]=Find(p[x]);
}

void work(){
    scanf("%d",&N);
    for(int i=1;i<=N;i++) scanf("%d",&arr[i]);
    for(int i=1;i<=N;i++) b[i]=arr[i];
    sort(b+1,b+1+N);
//    for(int i=1;i<=N;i++) printf("%d ",b[i]);
//    printf("\n");
    for(int i=1;i<=N;i++) p[i]=i,siz[i]=1,mi[i]=sum[i]=arr[i];
    for(int i=1;i<=N;i++){
        int x=Find(i);
        int id=lower_bound(b+1,b+1+N,arr[i])-b;
        int y=Find(id);
        if(x!=y){
            p[x]=y;
            mi[y]=min(mi[y],mi[x]);
            siz[y]+=siz[x];
            sum[y]+=sum[x];
        }
    }
    int ans=0;
    for(int i=1;i<=N;i++)if(p[i]==i){
        if(siz[i]==2) ans+=sum[i];
        else if(siz[i]>2){
            int tmpmi=min(mi[i]+sum[i]+(siz[i]+1)*b[1],sum[i]+(siz[i]-2)*mi[i]);
            ans+=tmpmi;
        }
    }
    printf("%d\n",ans);
}

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



Measured memory_bytes: 3272
from collections import deque
sa=list(input())
sb=list(input())
sc=list(input())
a=deque(sa)
b=deque(sb)
c=deque(sc)
k=a.popleft()
while True:
    if k=="a":
        if not a:
            print("A")
            exit()
        else:
            k=a.popleft()
    if k=="b":
        if not b:
            print("B")
            exit()
        else:
            k=b.popleft()
    if k=="c":
        if not c:
            print("C")
            exit()
        else:
            k=c.popleft()

Measured memory_bytes: 64692
#include<iostream>
#include<algorithm>
using namespace std;
int  main(){
	long n,minv=9999999999,maxv=-9999999999;
	cin>>n;
	for(long i=0;i<n;i++) {
		long r;
		cin>>r;
		maxv=max(maxv,r-minv);
		minv=min(minv,r);
	
		
	}
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int main() {
    int N; cin >> N;
    vector<ll> AB(N);
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll a, b; cin >> a >> b;
        ans -= b;
        AB[i] = a + b;
    }
    sort(AB.begin(), AB.end(), greater<ll>());
    for (int i = 0; i < N; i+=2) {
        ans += AB[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N,K=map(int,input().split())
t=[list(map(int,input().split())) for _ in range(N)]
t.sort(key=lambda x:-x[1])
ans=0
dp=set()
p=[]
for i in range(K):
  ans+=t[i][1]
  if t[i][0] in dp:
    p.append(t[i][1])
  dp.add(t[i][0])
ans+=len(dp)**2
wer=ans
while K<N and p:
  if t[K][0] not in dp:
    wer=wer+t[K][1]-p.pop()-len(dp)**2+(len(dp)+1)**2
    ans=max(ans,wer)
    dp.add(t[K][0])
  K+=1
print(ans)

Measured memory_bytes: 32256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#define sp system("pause");
using namespace std;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
int main(){
	int n,m;
	cin>>n>>m;
	char a[n+5][m+5];
	for(int i=0;i<=n+1;i++)
		for(int j=0;j<=m+1;j++)
			a[i][j]='.';
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(a[i][j]=='#')
			{
				bool ok=false;
				for(int d=0;d<4;d++)
				{
					int x=i+dx[d],y=j+dy[d];
					if(a[x][y]=='#')
						ok=true;
				}
				if(!ok)
				{
					cout<<"No";
					return 0;
				}
			}
		}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pii pair<int,int> 
#define pb push_back
#define INF INT_MAX 
#define mod 1000000007ll
#define fi first
#define se second
#define f(i,p,q) for(int i=p;i<q;i++)
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define psi(a) printf(" %d",a)
#define poi(a) printf("%d",a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld\n",a)
#define Nline() printf("\n")
#define sstr(str) scanf("%s",str)
#define pstr(str) printf("%s\n",str)
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vvi vector<vi>
#define all(v) (v).begin(),(v).end()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i];
#define sq(n) (n)*(n)
#define iso ios::sync_with_stdio(false); cin.tie(0);cout.tie(NULL);
#define cases int t;cin>>t;while(t--)
int main()
{
    iso;
    /* #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
   int n;cin>>n;
   string s;
   cin>>s;
     int ans=1;
    for(int i=1;i<n;i++)
    { 
        if(s[i-1]!=s[i])ans++;  
    }
    cout<<ans;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
    #define REP(i, n) for(int i = 0;i < n;i++)
    #define REPR(i, n) for(int i = n;i >= 0;i--)
    #define FOR(i, m, n) for(int i = m;i < n;i++)
    #define FORR(i, m, n) for(int i = m;i >= n;i--)
    #define SORT(v, n) sort(v, v+n);
    #define VSORT(v) sort(v.begin(), v.end());
    #define llong long long
    #define pb(a) push_back(a)
    #define INF 300300
    using namespace std;
    typedef pair<int, int> P;
    typedef pair<llong, llong> LP;
    typedef pair<int, P> PP;
    typedef pair<llong, LP> LPP;
    //vector<tuple<long long, long long, long long>>vec;

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


    int main()
    {
        int N,K;
        cin>>N>>K;
        string S;
        cin>>S;
        vector<int> dist;
        // 01001001001001
        // 1回ひっくり返せるとき、1箇所の1-0-1区間がつなげられる
        // 2回ひっくり返せるとき、２か所の1-0-1-0-1区間がつなげられる
        // 3回ひっくり返せるとき、３か所の1-0-1-0-1-0-1区間がつなげられる
        // 1-0-1-0-1-0-1の数を求めてやる
        // 1から2K+1この数の和が最大になるような区間を求めればよい
        if (S[0] == '0') dist.push_back(0);
        int len = 1;
        for (int i=0;i<N;i++){
            if (i == N -1) {
                dist.push_back(len);
                break;
            }
            if (S[i] != S[i+1]){
                dist.push_back(len);
                len = 1;
            } else {
                len++;
            }
        }
        if (S[N-1] == '0') dist.push_back(0);

        int ans = 0;
        if (2*K+1 <= dist.size()){
            int initial = 0;
            for (int i=0;i<2*K+1;i++){
                initial += dist[i];
            }
            ans = initial;
            int d = initial;
            for (int i=2;i<dist.size() - 2*K + 1;i=i+2){
                d = d - dist[i-2] - dist[i-1] + dist[i+2*K-1] + dist[i+2*K];
                ans = max(ans, d);
            }
        } else {
            for (int i=0;i<dist.size();i++){
                ans += dist[i];
            }
        }
        cout << ans << endl;
    }

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

int main(){
  int a,b,c,i=0,k=0;
  cin>>a;
  cin>>b>>c;
  i=b;
  while(i<=c){
    if(i%a==0){
      k=1;
      cout<<"OK";
      break;
    }
    i+=1;
  }
  if(k==0)cout<<"NG";
}

Measured memory_bytes: 3532
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] DN = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();
            int D = DN[0];
            int N = DN[1];
            if(N == 100)
            {
               N += 1;
            }
            if(D == 0)
            {
                Console.WriteLine(N);
                return;
            }
            if(D == 1)
            {
                Console.WriteLine(100 * N);
                return;
            }
            if(D == 2)
            {
                Console.WriteLine(10000 * N);
                return;
            }
        }
    }
}
//int[] N = Console.ReadLine().Split(" ").Select(x => int.Parse(x)).ToArray();

Measured memory_bytes: 28208
#include<bits/stdc++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <fstream>

using namespace std;

const long long N = 1e5 + 5;

long long mini = 1e9 + 7;
long long dp[N];
bool mark[N];
bool check = false;
vector<pair<long long, long long>> graph[N];
long long n, m;
long long ans;
long long ctr;
long long sz;

void dfs(long long v)
{
	mark[v] = true;
	dp[v] = 1;
	for (long long i = 0; i < graph[v].size(); i++)
	{
		long long u = graph[v][i].first;
		if (!mark[u])
		{
			dfs(u);
			dp[v] += dp[u];
		}
	}
}

void dfs2(long long v)
{
	mark[v] = true;
	for (long long i = 0; i < graph[v].size(); i++)
	{
		long long u = graph[v][i].first;
		long long w = graph[v][i].second;
		if (!mark[u])
		{
			long long cnt1 = dp[u];
			long long cnt2 = n - dp[u];
			if (cnt1 == cnt2)
			{
				check = true;
				cnt1 = 2 * cnt1 - 1;
			}
			else
			{
				cnt1 = 2 * min(cnt1, cnt2);
			}
			ans += cnt1 * w;
			dfs2(u);
		}
	}
}
 
void dfs3(long long v)
{
	mark[v] = true;
	long long maxi = 0;
	long long s = 0;
	for (long long i = 0; i < graph[v].size(); i++)
	{
		long long u = graph[v][i].first;
		if (!mark[u] && !mark[u])
		{
			dfs3(u);
			s += dp[u];
			maxi = max(maxi, dp[u]);
		}
	}
	maxi = max(maxi, sz - s - 1);
	if (maxi <= sz / 2)
	{
		ctr = v;
	}
}
 
long long findCentroid(long long v)
{
	ctr = -1;
	sz = dp[v];
	dfs3(v);
	return ctr;
}


int main() 
{
	cin >> n;
	for (long long i = 0; i < n - 1; i++)
	{
		long long u, v, w;
		cin >> u >> v >> w;
		graph[u - 1].push_back({v - 1, w});
		graph[v - 1].push_back({u - 1, w});
		mini = min(mini, w);
	}
	dfs(0);
	memset(mark, 0, sizeof mark);
	dfs2(0);
	if (!check)
	{
		mini = 1e9 + 7;
		memset(mark, 0, sizeof mark);
		ctr = findCentroid(0);
		for (long long i = 0; i < graph[ctr].size(); i++)
		{
			mini = min(mini, graph[ctr][i].second);
		}
		ans -= mini;
	}
	cout << ans << endl;


	
}





Measured memory_bytes: 12800
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using static Reader;

public static class P
{
    public static void Main()
    {
        var a = NextInt;
        var b = NextInt;
        var k = NextInt;
        Console.WriteLine(Enumerable.Range(1, 100).Where(x => a % x == 0 && b % x == 0).Reverse().Skip(k - 1).First());
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (int)(Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}


Measured memory_bytes: 13396
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>

#pragma warning(disable: 4996)

using namespace std;

struct point
{
	int x;
	int y;
	int n;
};

struct sortkey : public binary_function<point, point, bool>
{
	bool operator()(point x, point y)
	{
		return x.x < y.x;
	}
};

int n, q, sx, tx, sy, ty;

vector<point> p;

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

	for (int i = 0; i < n; i++)
	{
		point p1;

		scanf("%d", &p1.x);
		scanf("%d", &p1.y);

		p1.n = i;

		p.push_back(p1);
	}

	sort(p.begin(), p.end(), sortkey());

	vector<int> x, y, m;

	for (int i = 0; i < n; i++)
	{
		x.push_back(p[i].x);
		y.push_back(p[i].y);
		m.push_back(p[i].n);
	}

	scanf("%d", &q);

	vector<int> points;

	for (int i = 0; i < q; i++)
	{
		points.clear();

		scanf("%d", &sx);
		scanf("%d", &tx);
		scanf("%d", &sy);
		scanf("%d", &ty);

		int ptr1 = distance(x.begin(), lower_bound(x.begin(), x.end(), sx));
		int ptr2 = distance(x.begin(), upper_bound(x.begin(), x.end(), tx));

		for (int j = ptr1; j < ptr2; j++)
		{
			if (sy <= y[j] && y[j] <= ty)
			{
				points.push_back(m[j]);
			}
		}

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

		for (int i = 0; i < points.size(); i++)
		{
			printf("%d\n", points[i]);
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 15980
import itertools
u=[1,2,3,4,5,6,7,8,9]
a=0
n=list(map(int,input().split()))
for x in itertools.permutations(u):
    f=0
    for i in range(9):
        if n[i]!=-1 and n[i]!=x[i]:f=1
    if f:continue
    if x[0]+x[2]+x[5]-x[8]+(x[1]+x[4]-x[7])*10+(x[3]-x[6])*100==0:a+=1
print(a)

Measured memory_bytes: 7728
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;vector<ll>a(n);for(int i=0;i<n;i++)cin>>a[i];
    map<ll,ll>m;
    set<ll>s;
    ll ans=0;
    for(int i=0;i<n;i++){
        m[a[i]]++;
        s.insert(a[i]);
    }
    for(auto it=s.begin();it!=s.end();it++){
          if(m[*it]>=*it)
              ans+=m[*it]-*it;
        else
            ans+=m[*it];
    }
    cout<<ans<<endl;
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 11520
#include<bits/stdc++.h> 
const int maxn=202020;
struct Edge{
	int to;
	int last;
}a[maxn<<1];
int n,m;
int tot;
int d[maxn];
int head[maxn];
inline void HA(int x,int y)
{
	a[++tot]={y,head[x]};
	head[x]=tot;
	a[++tot]={x,head[y]};
	head[y]=tot;
}
#define y a[i].to
inline void Dfs(int x,int prt){
	for(int i=head[x];i;i=a[i].last)
		if(y!=prt)d[y]=d[x]+1,Dfs(y,x);
	if(d[x]>d[m])m=x;
}
#undef y
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y;i<n;++i)
	{
		scanf("%d%d",&x,&y);
		HA(x,y);
	}
	m=0,Dfs(1,0);
	int temp=m;d[m]=0;
	m=0,Dfs(temp,0);
	puts(d[m]%3==1 ? "Second" : "First");
	return 0;
}

Measured memory_bytes: 20704
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX 100005

ll n, capacity;
ll price[105], weight[105];
ll dp[105][MAX];

ll solve(){
    memset(dp, 0, sizeof(dp));

    for(int item=0; item<=n; item++){
        for(int w=0; w<=capacity; w++){
            if(item == 0|| w==0){
                dp[item][w]=0;
            }
            else if(w>=weight[item-1]){
                dp[item][w] = max(price[item-1]+dp[item-1][w-weight[item-1]], dp[item-1][w]);
            }
            else dp[item][w] = dp[item-1][w];
        }
    }
    return dp[n][capacity];
}

int main(){
    cin>>n>>capacity;
    for(int i=0; i<n; i++){
        cin>>weight[i]>>price[i];
    }
    cout<<solve()<<endl;
    return 0;
}


Measured memory_bytes: 82304
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N;
  cin >> N;
  vector<int> S(N);
  int sum = 0;
  for(int i=0; i<N; i++){
    cin >> S[i];
    sum += S[i];
  }
  sort(S.begin(), S.end());
  int tmp = 0;
  for(int i=0; i<N; i++)
    if(S[i] % 10 != 0){
      tmp = S[i];
      break;
    }
  if(sum % 10 == 0)
    if(tmp == 0)
      cout << 0 << endl;
    else
      cout << sum - tmp << endl;
  else
    cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
program Project1;
             
{$APPTYPE CONSOLE}
             
uses
  SysUtils;
var
  a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,min:Integer;
  l:array of string;
  s,s123,s1,s2,s3:string;
  al:string = 'abcdefghijklmnopqrstuvwxyz';
  tf,tfl,tfr:Boolean;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Read  (a);
    Readln(c);
    count:=0;
    max  :=0;
    min  :=100;

    if (a=2)or(c=2) then
      Writeln('No')
    else
      Writeln('Yes');

    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


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

using namespace std;
typedef long long ll;

int main() {
    int a,b;
    scanf("%d %d",&a,&b);
    printf("%d\n", max(a + b, max(a - b, a * b)));
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,double> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const vi emp;
const int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
const int DX[8]={-1,-1,-1,0,0,1,1,1},DY[8]={1,0,-1,1,-1,1,0,-1};

string a,s,c;

int main(){
	cin>>a>>s>>c;
	cout<<a[0]<<s[0]<<c[0]<<endl;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1e9+7;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
#define ok cout<<"Yes"<<endl;continue
#define ng cout<<"No"<<endl;continue
int main(void){
	int T;cin>>T;
	while(T--){
		llint a,b,c,d;cin>>a>>b>>c>>d;
		if(a<b){ng;}//ぎゃくに最初さえ乗り切れれば問題ない
		if(d<b){ng;}//供給できてない
		llint e=gcd(b,d);//本数%e==a%eが成り立つ
		llint f=c+1+((a%e-(c+1)%e+e)%e);//f=a(mode)かつ、c<fをみたす最小の数
		if(f<b){ng;}
		ok;
	}
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  map<string,int> mp;
  string w;
  cin >> w;
  mp[w]++;
  bool ok = true;
  char end_char = w.at(w.size()-1);
  for (int i = 1; i<N; i++) {
    string w;
    cin >> w;
    if (w.at(0) != end_char) {
      ok = false;

      break;
    }
    mp[w]++;
    if (mp[w] >=2) {
      ok = false;
      break;
    }
    end_char = w.at(w.size()-1);
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}
  
    
  



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		//long count=0;

		/*for(int i=0;i<3;i++) {
			if(s.substring(i,i+1).equals(s.substring(i+1,i+2))) {
				count++;
			}else if(i!=2){
				count=0;
			}
		}*/
		if(n*m<=k) {
			System.out.println(n*m);
		}else{
			System.out.println(k);
		}
		//System.out.println(count);
	}
}




Measured memory_bytes: 22732
#include <iostream>
#include <vector>

using namespace std;
typedef pair<int, int> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector< vector<int> > Vec(n, vector<int>(n));
		P p;
		p.first = n / 2;
		p.second = n / 2;
		p.second++;
		int count = 1;
		Vec[p.second][p.first] = count;
		int step = n * n - 1;
		while(step)
		{
			count++;
			p.first = (p.first + 1) % n;
			p.second = (p.second + 1) % n;
			if(Vec[p.second][p.first] == 0)
			{
				Vec[p.second][p.first] = count;
			}
			else
			{
				--p.first;
				if(p.first == -1)
				{
					p.first += n;
				}
				p.second = (p.second + 1) % n;
				while(Vec[p.second][p.first] != 0)
				{
					--p.first;
					if(p.first == -1)
					{
						p.first += n;
					}
					p.second = (p.second + 1) % n;
				}
				Vec[p.second][p.first] = count;
			}
			step--;
		}
		for(int i = 0; i < n; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				printf("%4d", Vec[i][j]);
			}
			cout << endl;
		}
	}
}

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

Measured memory_bytes: 0
import java.util.*;
     
    public class Main {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    		// 整数の入力
    		int n = sc.nextInt();
    		// スペース区切りの整数の入力
    		int a = sc.nextInt();
    		int b = sc.nextInt();
     
    		int m;
     
    		if (a * n < b) {
    			m = a * n;
     
    		} else {
    			m = b;
    		}
     
    		// 出力
    		System.out.println(m);
    	}
    }

Measured memory_bytes: 23508
N, M = map(int, input().split())
P = [0] * N
C = [1] * N
P[0] = 1
for _ in range(M):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  P[y] = P[x] | P[y]
  C[x] -= 1
  C[y] += 1
  P[x] = P[x] if C[x] else 0
print(sum(P))

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod = 1000000007;		

VI v[100005];
VI d(100005, 0);
VI a;


void dfs(int n) {
	for (int i : v[n]) {
		dfs(i);
	}
	a.push_back(n);
}


int main() {

	int n, m;
	cin >> n >> m;
	REP(i, n + m - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		d[b]++;
	}

	queue<int> q;
	REP(i, n)if (d[i] == 0)q.push(i);

	VI pa(100005,0);
	while (!q.empty()) {
		int i = q.front();
		q.pop();
		for (int j : v[i]) {
			d[j]--;
			if (d[j] == 0) {
				pa[j] = i + 1;
				q.push(j);
			}
		}
	}
	REP(i, n)cout << pa[i] << endl;

	return 0;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k;	cin >> n >> k;
  vector<long long >	h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  sort(h.begin(),h.end());
  long long sum=0;
  for(int i=0;i<n-k;i++){
    sum+=h.at(i);
  }
  cout << sum;
}

Measured memory_bytes: 4816
n = int(input())
l0 = list(map(int, input().split()))

l0 = sorted(l0)
m = l0.pop()

mini = m + 1
maxii = 0
ans = 0
for i in range(len(l0)):
    if l0[i] < m/2:
        ipred = l0[i]
        continue
    if abs((m/2 - l0[i-1])) >= abs((m/2 - l0[i])):
        ans = m, l0[i]
    else:
        ans = m, l0[i-1]
    break

if not ans:
    print(m, ipred)
else:
    for i in ans:
        print(i, end=' ')

Measured memory_bytes: 14428
#include <iostream>
using namespace std;
 
int A, B, C;
 
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B >> C;
    int result;
    
    if (C >= A - B) {
      result = C - A + B;
    } else {
      result = 0;
    }
  
    cout << result;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;cin>>N;
    int ans=0;int x;
    for(int i=0;i<N;i++){
        cin>>x;
        while(1){
            if(x%2==0){
                x/=2;
                ans++;
            }
            else break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;	
  ci(n);
  vst A(n);
  FOR(i,0,n){
    ci(A[i])
    SORT(A[i]);
  }
  SORT(A);
  ll ans=0;
  ll count=1;
  
  FOR(i,1,n){
    if(A[i-1]==A[i]){
      ans+=count;
      count++;
    }
    else{
      count=1;
    }
  }
  co(ans)
}

Measured memory_bytes: 8064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);

#define REP(i,n)	for(int i=0;i<(int)n;++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 FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(int argc, char **argv) {
	int x, y;
	cin >> x >> y;
	int res = 0;
	if (abs(y) >= abs(x)) {
		res = abs(y) - abs(x);
		if (x < 0) ++res;
		if (y < 0) ++res;
	}
	else {
		res = abs(x) - abs(y);
		if (x > 0) ++res;
		if (y > 0) ++res;
	}
	cout << res << endl;
	return 0;
}


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


count = [0] * N
for d in D:
    count[d] += 1

if (D[0] != 0 or count[0] >= 2):
    print(0)
    exit()
ans = 1
for i in range(N):
    if (i > 0):
        ans *= (count[i - 1] ** count[i]) % 998244353
        ans %= 998244353

print(ans)


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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
#define int long long
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n,k;cin >> n >> k;
  int mod=1e9+7;
  vint a(n);vin(a);
  int s=0,t=0;
  rep(i,n){
    rep(j,n){
      s%=mod;t%=mod;
      if(i==j)continue;
      if(a[i]>a[j]){
        s++;
        if(i<j)t++;
      }
    }
  }
  int ka=k*t%mod;
  int sum;
  if(k%2==0)sum=k/2*s%mod*(k-1)%mod;
  else sum=(k-1)/2*s%mod*k%mod;
  int ans=(ka+sum)%mod;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

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

int W,H,res;
void dfs(int x,int y,vector<vector<char> >& m){
    if(m[y][x]=='#')return;
    res++;
    m[y][x]='#';
    rep(i,4){
        int nx=x+dx[i],ny=y+dy[i];
        if(nx>=0&&nx<W&&ny>=0&&ny<H){
            dfs(nx,ny,m);
        }
    }
}

int main(){
    while(cin >> W >> H,W|H){
        vector<vector<char> > m(H,vector<char>(W));
        rep(i,H)rep(j,W)cin >> m[i][j];
        res=0;
        rep(i,H)rep(j,W){
            if(m[i][j]=='@')dfs(j,i,m);
        }
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

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

int main(){
    int a, b, c, d;

    scanf("%d %d %d %d", &a, &b, &c, &d);

    int ans = 0;
    if(a < b){
        ans += a;
        if(c < d){
            ans += c;
        }else{
            ans += d;
        }
    }else{
        ans += b;
        if(c < d){
            ans += c;
        }else{
            ans += d;
        }
    }

    printf("%d\n", ans);

    return 0;
}


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

signed main(){
    int a,b,ab,x,y; cin>>a>>b>>ab>>x>>y;
    if(a+b<=ab*2){
        cout<<a*x+b*y<<endl; return 0;
    }
    if(x>=y){
        if(a<=ab*2){
            cout<<ab*y*2+a*(x-y)<<endl;
            return 0;
        }
        else{
            cout<<ab*x*2<<endl;
            return 0;
        }
    }
    if(x<y){
        if(b<=ab*2){
            cout<<ab*x*2+b*(y-x)<<endl;
            return 0;
        }
        else{
            cout<<ab*y*2<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;

int main() {
  int K;
  long long A, B;
  cin >> A >> B >> K;
  for (size_t i = A; i < B+1; i++) {
    if (i - A < K || B - i < K) {
      cout << i << endl;
    }
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
int n, m, x, y, memo[N];
vector<vector<int>>v;
int solve(int node)
{
    if(sz(v[node]) == 0)
        return 0;
    int &ret = memo[node];
    if(~ret)
        return ret;
    ret = 0;
    for(auto i : v[node])
        ret = max(ret, solve(i) + 1);
    return ret;
}
int main()
{
    MuhammedAly
    cin >> n >> m;
    mem(memo, -1);
    v.resize(n + 1);
    for(int i = 0 ; i < m ; i++)
    {
        cin >> x >> y;
        v[x].pb(y);
    }
    int ans = 0;
    for(int i = 1 ; i <= n ; i++)
        ans = max(ans, solve(i));
    cout << ans;
    return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a;
    cin >> a;
    if (a < 1200) cout << "ABC" << endl;
    else if (a < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;


    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
using namespace std;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	int k;
	cin >> k;
	cout << a[k - 1] << endl;
	return 0;
}

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

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

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

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

int main(){
    int n;cin>>n;
    vector<P>p;
    rep(i,n){
        int x,y;cin>>x>>y;
        p.emplace_back(x,y);
    }
    sort(ALL(p));
    double res = 0;
    int cnt = 0;
    do{
        double dist = 0;
        REP(i,1,n-1){
            double d1 = pow(p[i-1].first-p[i].first,2);
            double d2 = pow(p[i-1].second-p[i].second,2);
            dist += pow(d1+d2,0.5);
        }
        res += dist;
        cnt++;
    }while(next_permutation(ALL(p)));
    res /= cnt;
    cout<<fixed<<setprecision(8)<<res<<endl;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int a, b;
    cin >> a >> b;
    if(a+b == 0) puts("0");
    else if(a+b > 0) puts("1");
    else puts("-1");
    return 0;
}


Measured memory_bytes: 3100
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 0, a = 0, b = 0, ba = 0;
	rep(i,n){
		string s;
		cin >> s;
		rep(j,s.size()-1){
			if(s[j] == 'A' && s[j+1] == 'B') ++ans;
		}
		if(s[0] == 'B' && s.back() == 'A') ++ba;
		else if(s[0] == 'B') ++b;
		else if(s.back() == 'A') ++a;
	}
	if(a > 0){
		ans += ba;
		ba = 0;
	}
	else if(ba > 0){
		ans += ba - 1;
		ba = 0;
		++a;
	}
	ans += min(a, b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3540
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   //setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  //sin, cos, tan

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

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

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

ll ans = MAX;

void Main()
{
  ll n, m, k; cin >> n >> m >> k;
  vll c(n);
  vvll a(n, vll (m));
  rep(i, n)
  {
    cin >> c[i];
    rep(j, m)
    {
      cin >> a[i][j];
    }
  }
  ll flag = 1;
  for(ll i = 1;i < n;i++)
  {
    flag += pow(2, i);
  }

  while (flag)
  {
    ll tmp = flag;
    ll Q = 0;
    ll h = 0;
    vll s(m, 0);
    while(tmp)
    {
      if(tmp % 2 == 1)
      {
        Q += c[h];
        rep(i, m)
        {
          s[i] += a[h][i];
        }
      }
      h++;
      tmp /= 2;
    }
    ll J = 0;
    rep(i, m)
    {
      if(s[i] >= k) J++;
    }
    if(J == m) ans = min(ans, Q);
    flag--;
  }
  if(ans == MAX) fin(-1);
  fin(ans);
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); 0埋め４桁
  Main();
  return 0;
}


Measured memory_bytes: 4000
import Control.Monad
import Data.List
import Text.Printf
main=do
  n <- readLn
  [xs, ys] <- transpose <$> map (map (read::String->Double) . words) <$> replicateM n getLine
  let
    ps = permutations [0..n-1]
    a = sum $ map (solve xs ys) ps
    b = fromIntegral $ product [1..n]
  printf "%10f" (a / b :: Double)

solve :: [Double] -> [Double] -> [Int] -> Double
solve _ _ [_] = 0
solve xs ys (i:j:ps) = (sqrt $ (xs!!i - xs!!j)^2 + (ys!!i - ys!!j)^2) + solve xs ys (j:ps)

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}

const int INF = 1e9 + 100;
int main() {

	int n, W;

	cin >> n >> W;

	int w[n+1], v[n+1], sum = 0;

	tik(i,1,n+1) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}

	vi dp(100000 + 100,INF); //dp[i] = minimum weight required to get value exactly i
	dp[0] = 0;

	tik(i,1,n+1) {
		tok(j,sum - v[i],0) {
			if(v[i] + j > sum)
				break;
			dp[v[i] + j] = min(dp[v[i] + j],dp[j] + w[i]); 
		}
	}

	int res = 0;
	tik(i,0, sum + 1) {
		//error(i,dp[i]);
		if(dp[i] <= W)
			res = i;
	}

	cout << res;
}

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

int dig_sum(int a)
{
    int sum=0;
    while(a)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}
int cheak_zero(int a)
{
    int count=0;
    while(a)
    {
        int b=a%10;
        a=a/10;
        if(b!=0)
            break;
        else
            count++;
    }
    return count;
}
void sort(int numbers[], int count)
{
    for(int i = 0; i < count - 1; i++)
    {
        int currentMin = numbers[i];
        int currentMinIndex = i;

        for(int j = i + 1; j < count; j++)
        {
            if(currentMin > numbers[j])
            {
                currentMin = numbers[j];
                currentMinIndex = j;
            }
        }

        if(currentMinIndex != i)
        {
            numbers[currentMinIndex] = numbers[i];
            numbers[i] = currentMin;

        }
    }
}


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

bool cheak1(char fi[],char se[],int n,int m,int x)
{
    for(int i=0;i<x;i++)
    {
        if(fi[i]!=se[i])
        {
            return false;
        }
        se[i]='.';
    }
    for(int i=n-1,j=m-1;i>x;i--,j--)
    {
        if(fi[i]!=se[j])
        {
            return false;
        }
    }
    return true;
}
int faw()
{

    int n,m;
    cin>>n>>m;
    char fi[n];
    char se[m];
    cin>>fi;
    cin>>se;
    int x;
    for(int i=0;i<n;i++)
    {
        if(fi[i]=='*')
        {
            x=i;
            break;
        }
    }
    /*if(x==0)
    {
        if(strcmp(fi,se)==0)
        {
            cout<<"YES"<<endl;
            return 0;
        }
        else
            cout<<"NO"<<endl;
        return 0;
    }*/
    if(cheak1(fi,se,n,m,x)==true)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;

    return 0;
}

int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b-(a+b-1)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3616