akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t a, b;
    cin >> a >> b;
    auto max = a + b;
    auto tmp = a - b;
    if (max < tmp) {
	max = tmp;
    }
    tmp = a * b;
    if (max < tmp) {
	max = tmp;
    }
    cout << max << endl;
    return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
using namespace std;
int main(void){
   char o[52],e[52];
   cin>>o>>e;
   int no,ne;
   no=strlen(o);
   ne=strlen(e);
   for(int i=0;i<ne;i++){
      cout<<o[i]<<e[i];
   }
   if(no>ne) cout<<o[no-1];
   return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int n_open = 0;
    int n_close = 0;
    for(auto c: S) {
        if(c == '(') {
            ++n_close;
        }
        else {
            if(n_close>0) {
                --n_close;
            } else {
                ++n_open;
            }
        }
    }
    string ret;
    rep(i, n_open) {
        ret += '(';
    }
    ret += S;
    rep(i, n_close) {
        ret += ')';
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 3136
#include <stdio.h>

typedef struct {
	int key, id;
} data;

void merge_sort(data x[], int n)
{
	static data y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p].key < x[q].key)? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N, C, s[100001], t[100001], c[100001];
	scanf("%d %d", &N, &C);
	for (i = 1; i <= N; i++) scanf("%d %d %d", &(s[i]), &(t[i]), &(c[i]));
	
	data d[100001];
	for (i = 0; i < N; i++) {
		d[i].key = s[i+1];
		d[i].id = i + 1;
	}
	merge_sort(d, N);
	
	int j, tmp, max, count[31][100001] = {};
	for (i = 0; i < N; i++) {
		j = d[i].id;
		if (count[c[j]][s[j]] == 0) count[c[j]][s[j]-1]++;
		else count[c[j]][s[j]]++;
		if (count[c[j]][t[j]-1] == 0) count[c[j]][t[j]]--;
		else count[c[j]][t[j]-1]--;
	}
	for (i = 0, tmp = 0, max = 0; i <= 100000; i++) {
		for (j = 1; j <= C; j++) tmp += count[j][i];
		if (tmp > max) max = tmp;
	}
	
	printf("%d\n", max);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,h;
        cin>>n>>h;
        ll maxa=0;
        vl B(n);
        rep(i,n){
            ll a,b;
            cin>>a>>b;
            chmax(maxa,a);
            B[i]=b;
        }
        sort(rall(B));
        ll now=0;
        ll count=0;
        while (B[now]>maxa&&h>0)
        {
            h-=B[now];
            now++;
            count++;
        }
        if(h>0)count+=(h+maxa-1)/maxa;
        cout<<count<<endl;
    }

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  double n,m,d;
  double ans;
  scanf("%lf %lf %lf", &n, &m, &d);

  if(d == 0){
    ans = (m-1)/n;
    printf("%lf", ans);
  } else {
    ans = (m-1)*2*(n-d)/n/n;
    printf("%lf", ans);
  }
  return 0;
}


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

int main()
{
  char a;
  cin >> a;
  bool ans = false;
  for(int i = 0;i <= ('Z' - 'A');i++){
    if(a == (char)('A' + i)) ans = true;
  }
  if(ans) cout << 'A' << endl;
  else cout << 'a' << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

ll lcm(ll a, ll b) {
	ll g = __gcd(a, b);
	return (a * b) / g;
}

void solve() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	
	ll tot = b - a + 1, l = lcm(c, d);
	ll divb = b / c + b / d - b / l;
	ll diva = (a - 1) / c + (a - 1) / d - (a - 1) / l;
	
	cout << tot - (divb - diva) << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string S; cin >> S;
    if(S.size() == 3)reverse(all(S));
    cout << S << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int K = sc.nextInt();
    int X = sc.nextInt();
    for (int i= X - K + 1; i <= X + K -1; i++) {
      System.out.print(i);
      if(i != X+ K -1) System.out.print(" ");
    }
  }
}

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll cur = 7 % n;
    ll cnt = 1;
    if (cur == 0)
    {
        cout << 1 << endl;
        return 0;
    }
    for (ll i = 2 ; i <= 10000000 ; i++)
    {
        cur *= 10;
        cur %= n;
        cur += 7;
        cur %= n;
        if (cur == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<ctime>
#include<vector>
#include<queue>
#include<map>
#include<deque>
#include<stack>
#include<algorithm>
#define N 100005
using namespace std;
const int INF=0x7fffffff;
const double Pi=acos(-1);
int A[N];
int main()
{
	int i,n,k,Sum=INF;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	if(A[n]<=0)Sum=-A[n-k+1];//Ö±½ÓÍù×ó×ß 
	if(A[1]>=0)Sum=A[k];//Ö±½ÓÍùÓÒ×ß 
	for(i=1;i<=n;i++)if(A[i]>0)break;
	int ID=i;//µÚÒ»¸ö´óÓÚ0µÄ
	for(i=0;i<=k;i++)//Ã¶¾ÙÍù×ó×ß 
	{
		int Pos1=ID-i,Pos2=ID+k-i-1;
		if(Pos1<1||Pos2>n)continue;
		if(A[Pos1]<=0&&A[Pos2]>=0)Sum=min(Sum,A[Pos2]-A[Pos1]+min(A[Pos2],-A[Pos1]));
		else Sum=min(Sum,max(abs(A[Pos1]),abs(A[Pos2])));
	}
	printf("%d\n",Sum);
	return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

buster=0
for i in range(n):
    buster += min(a[i],b[i])
    buster += min(a[i+1],b[i]-min(a[i],b[i]))
    a[i+1] = a[i+1] - (b[i]-min(a[i],b[i]))
    if(a[i+1] < 0): a[i+1] = 0

print(buster)

Measured memory_bytes: 18624
#coding:utf-8

a = []
count = 0
while True:
    n = input()
    a.append(n)
    count+=1
    if count==2:
        break
# print a
if a[0]>a[1]:
    print ("GREATER")
elif a[0]==a[1]:
    print("EQUAL")
else :
    print("LESS")


Measured memory_bytes: 2568
#include <cstdio>
const int Mn(100050);
struct edge
{
	int e,no,nt;
}ed[Mn<<1];
int vs[Mn],ec(0);
void adde(int s,int e,int no)
{
	ed[++ec] = (edge){e,no,vs[s]};
	vs[s] = ec;
}

int color[Mn];
int son[Mn];
void dfs_count(int p)
{
	for(int i(vs[p]);i;i=ed[i].nt)
	{
		edge& e(ed[i]);
		if(!son[e.e])
		{
			++son[p];
			dfs_count(e.e);
		}
	}
}
bool vis[Mn];
void dfs_color(int p,int prcol)
{
	vis[p] = true;
	int col(0);
	for(int i(vs[p]);i;i=ed[i].nt)
	{
		edge& e(ed[i]);
		if(vis[e.e])	continue;
		if(++col==prcol)	++col;
		color[e.no] = col;
		dfs_color(e.e,col);
	}
}

int main()
{
	int n;
	scanf("%d",&n);
	for(int i(1);i<n;++i)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		adde(u,v,i);
		adde(v,u,i);
	}
	dfs_count(1);
	int ans(0);
	for(int i(1);i<=n;++i)
		if(son[i]>=son[ans])	ans = i;
	dfs_color(1,0);
	if(ans==1)	printf("%d\n",son[1]);
	else		printf("%d\n",son[ans]+1);
	for(int i(1);i<n;++i)
		printf("%d\n",color[i]);
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define zero(x) (((x)>0?(x):-(x))<eps)
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int>PII;
const double eps=1e-6;
const double pi=acos(-1.0);
const LL mod=1e18+7;
const int INF=0x3f3f3f3f;
//LL powmod(LL a,LL b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
VI v[3010];
int sg[3010],a[3010];
void dfs(int x){
    sg[x]=0;
    for(auto i:v[x]){
        if(~sg[i]) continue;
        dfs(i);
        if(a[x]>a[i]&&sg[i]==0){
            sg[x]=1;
            break;
        }
    }
}
int main(){
//    freopen("in.in","r",stdin);
//    freopen("out.out",";w",stdout);
    int n,x,y;
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++){
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    for(int i=1;i<=n;i++){
        memset(sg,-1,sizeof sg);
        dfs(i);
        if(sg[i]) cout<<i<<" ";
    }
    puts("");
    return 0;
}
/*

*/


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;


#define ll          long long
#define pb          push_back
#define pii         pair<ll ,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define REP(i,n) for (int i = 1; i <= n; i++)
// mp::cpp_int



int solve( ){
  
 int n,m;
 cin>>n>>m;
 vi a;
 rep(i,0,m)
 {
  int x;
  cin>>x;
  a.pb(x);
 }
 sort(all(a));
 if(n>=m){cout<<0;return 0;}

 vi b;
 rep(i,1,m)
 { 
    b.pb(a[i]-a[i-1]);
 }
 sort(all(b));
 ll ans=0;
 rep(i,0,m-n)
 {
  ans+=b[i];
 }
cout<<ans;
return 0;
}
 

int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
  
  
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
    //cout << "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    vector< tuple<int, int, int> > v;
    tuple<int, int, int> t;
    for( int i = 0; i < n; ++i ) {
        int x, y, h;
        cin >> x >> y >> h;
        if( h > 0 ) {
            get< 0 >(t) = x;
            get< 1 >(t) = y;
            get< 2 >(t) = h;

        }
        v.emplace_back(x, y, h);

    }

    for( int i = 0; i <= 100; ++i ) {
        for( int j = 0; j <= 100; ++j ) {
            bool flg = true;
            int x, y, h;
            x = get< 0 >(t);
            y = get< 1 >(t);
            h = get< 2 >(t);
            int hei = h + abs(x - i) + abs(y - j);
            for( int k = 0; k < v.size(); ++k ) {
                x = get< 0 >(v[k]);
                y = get< 1 >(v[k]);
                h = get< 2 >(v[k]);
                int height = hei - abs(i - x) - abs(j - y);
                height = max(height, 0);
                if( height != h ) {
                    flg = false;
                    break;

                }
            }
            if( flg ) {
                cout << i << " " << j << " " << hei << endl;
                continue;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 256
program main
	implicit none
    integer W, a, b
	read(*, *) W, a, b
	if(b - (a+W) >= 0) then
		write(*, *) b - (a+W)
	else if(a - (b+W) >= 0) then
		write(*, *) a - (b+W)
	else
		write(*, *) 0
	end if
end program main

Measured memory_bytes: 256
#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

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

  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  reverse(t.begin(), t.end());

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


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

using namespace std;
// void fill1(std::vector<int> v,std::vector<int> &fill1,vector<int> &fill2){
// 	int mini=*min_element(v.begin(), v.end());
// 	for(int i=0;i<min;i++){
// 		fill2[i]=1;
// 		fill1[i]=2;
// 	}
// 	for(int i=0;i<v.size();i++){
// 		if(v[i]>(fill1.size()-1))break;
// 		fill2[v[i]]=2;
// 		fill1[v[i]]=1;
// 	}
// 	for

// }
void fill(std::vector<int> &v,std::vector<int> &fill1,vector<int> &fill2,int p,int k){
	int x=v.size();
	if (p==1){
		int pb=0;
		for(int i=0;i<x;i++){
			if(v[i]<=k){
				if(fill2[k-v[i]]==0)fill(v,fill1,fill2,2,k-v[i]);
				if(fill2[k-v[i]]==1){
					fill1[k]=1;

					pb=1;
					break;					
				}
				else if(fill2[k-v[i]]==2)continue;
			}
		}
		if(!pb){
			fill1[k]=2;
			// fill2[k]=2;
		}

		return;
	}
	else {
		int pb=0;
		for(int i=0;i<x;i++){
			if(v[i]<=k){
				if(fill1[k-v[i]]==0)fill(v,fill1,fill2,1,k-v[i]);
				if(fill1[k-v[i]]==2){
					fill2[k]=2;
					pb=1;
					break;					
				}
				else if(fill1[k-v[i]]==1)continue;
			}
		}
		if(!pb){
			fill2[k]=1;
			// fill1[k]=1;
		}
		return ;

	}

} 

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	std::vector<int> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	std::vector<int> v1(k+1,0),v2(k+1,0);
    v1[0]=2;
    v2[0]=1;
	fill(v,v1,v2,1,k);
	
	if(v1[k]==1){
		cout<<"First";
	}

	else if(v1[k]==2) cout<<"Second";


	return 0;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int H,W,M;
// vector<pii> B;
vector<int> cntX, cntY;
map<int, map<int,int>>  Bomb;
void input(){
    fast_io();
    cin >> H >> W >> M;
    cntX.assign(H,0);
    cntY.assign(W,0);
    // Bomb.assign(H,vector<int>(W,0));
    for (int i = 0; i < M; i++)
    {
        int x, y; cin >> x >> y;
        x--, y--;
        // B.emplace_back(x,y);
        cntX[x]++;
        cntY[y]++;
        Bomb[x][y] = 1;
    }
}

void chmax(int &a, int b){if(a<b) a=b;}

int solve(){
    // vector<pii> cx,cy;
    // for(auto [x,c]:cntX) cx.emplace_back(c,x);
    // for(auto [y,c]:cntY) cy.emplace_back(c,y);
    // auto cmp = [](pii a, pii b){return a.first > b.first;};
    // sort(cx.begin(),cx.end(),cmp);
    // sort(cy.begin(),cy.end(),cmp);
    // DBG(cx)
    // DBG(cy)
    int mx = *max_element(cntX.begin(),cntX.end());
    int my = *max_element(cntY.begin(),cntY.end());
    vector<int> idx, idy;
    for (int i = 0; i < H; i++)
    {
        if(cntX[i]==mx) idx.push_back(i);
    }
    for (int i = 0; i < W; i++)
    {
        if(cntY[i]==my) idy.push_back(i);
    }

    int ans = mx + my -1;
    for(int i:idx){
        for(int j:idy){
            if(!Bomb[i][j]){
                ans++;
                cout << ans << endl;
                return 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 51936
from math import factorial
def combination(n, r):
    return factorial(n)//(factorial(n-r) * factorial(r))

def answer(n,k):
    ans = 0
    # nが空の時
    if n=='':
        return 0
    # 先頭が0の時
    if n[0]=='0':
        ans += answer(n[1:],k)
    else:
        # 先頭以外でk個使う
        if len(n) > k:
            ans += combination(len(n)-1,k) * 9**k
        # 先頭でNの先頭より小さい数を1つ使う
        if len(n)>k-1:
            ans += (int(n[0])-1)*combination(len(n)-1,k-1)*9**(k-1)
        # 先頭でNの先頭と同じ数を使う
        if k>1:
            ans += answer(n[1:],k-1)
        else:
            ans += 1
    return ans

n = input()
k = int(input())

print(answer(n,k) if len(n)>=k else 0)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int k, a, b;
    cin >> k >> a >> b;
    if(b/k - (a-1)/k >0){
        cout << "OK" << endl;
    }
    else{
        cout << "NG" << endl;
    }

    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

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

bool* sieve(ll n){
	bool* a=new bool[n+1];
	for(ll i=0;i <n+1;i++) a[i]=true;
	for(ll i=2;i<n/2;i++){
		if(a[i]==false) continue;
		ll k=2;
		while(i*k <=n){
			a[i*k]=false;
			k++;
		}
	}
	
	return a;
}

int main(){
	ll n;
	cin >> n;
	bool* b=sieve(n);
	ll ans=1;
	for(ll i=2; i <n+1;i++){
		if(b[i]){
			ll j=i;
			ll count=0;
			while(j<=n){
				count+=n/j;
				j*=i;
			}
			ans*=count+1;
			ans%=mod;
		}
	} 
	cout << ans;
	return 0;
}

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

int main(){
	set<int> s;
	for (int i = 0; i<3; i++){
		int n;
		cin>>n;
		s.insert(n);
	}
	if (s.size()==2){
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int k, x;
	cin >> k >> x;

	if (500 * k >= x) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}

Measured memory_bytes: 384
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		StringBuilder sb = new StringBuilder(sc.next());
		sb.insert(4, ' ');
		System.out.println(sb);
	}

}

class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	int N, K;
	cin >> N >> K;
	vector<int>h(N);
	for (int i = 0;i < N;++i) {
		cin >> h[i];
	}
	int cnt = 0;
	for (int i = 0;i < N;++i) {
		if (K <= h[i])++cnt;
	}
	cout << cnt << "\n";

	return 0;
}

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

int main() 
{
    string S;
    cin >> S;
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }else if (S == "Rainy") {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;

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

	vector<int> vec = {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 n;
	cin >> n;
	cout << vec[n-1] << '\n';
}


Measured memory_bytes: 384
//09-2 ???????????????
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    int W[10],K[10];
    for(int i=0; i<10; i++){
        cin >> W[i];
    }
    for(int i=0; i<10; i++){
        cin >> K[i];
    }
    sort(W,W+10);
    sort(K,K+10);
    int a = W[7] + W[8] + W[9];
    int b = K[7] + K[8] + K[9];
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,a,b = LI()
    c = a+b
    r = n // c * a
    r += min(a, n % c)

    return r


print(main())





Measured memory_bytes: 7616
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>  
using namespace std;
int main() {
  stack<char>aux;
  string a="0", b="0";
  string c,d;
  cin>>c>>d;
  a+=c;
  b+=d;
  int linha=a.size(), coluna=b.size();
  int M[linha][coluna];
  for(int i=0; i < linha;i++){
    M[i][0]=0;
  }
  for(int i=0; i < coluna;i++){
    M[0][i]=0;
  }
  for(int i=1;i<linha;i++){
    for(int j=1;j<coluna;j++){
      if(a[i]==b[j]){
        M[i][j]=M[i-1][j-1]+1;
      }
      else if(M[i-1][j]>=M[i][j-1]){
        M[i][j]=M[i-1][j];
      }
      else{
        M[i][j]=M[i][j-1];
      }
    }
  }
   /* for(int i=1;i<linha;i++){
      for(int j=1;j<coluna;j++){
        cout<<M[i][j]<<" ";
      }
      cout<<endl;
    }*/
    for(int i=linha-1;i>=1;i--){
      for(int j=coluna-1;j>=1;j--){
        if(a[i] == b[j]){
          aux.push(a[i]);
          coluna--;
          break;
          }
        else if(M[i-1][j]>M[i][j-1]){
          break;
          } 
          coluna--;
     }
  }
  //aux.pop();
  while(aux.size()){
    //if(aux.top()!='0')
    cout<<aux.top();
    aux.pop();
  }
  cout<<endl;
}

Measured memory_bytes: 35456
m, d = map(int, input().split())
day_li = [i for i in range(1, d + 1)]
month_li = [j for j in range(1, m + 1)]

ans = 0
for k in day_li:
    if k >= 10:
        if int(str(k)[0]) * int(str(k)[1]) in month_li and int(str(k)[0]) >= 2 and int(str(k)[1]) >= 2:
            ans += 1
print(ans)

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

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  string s;
  cin>>s;

  deque<char> dc(s.begin(),s.end());

  int flip=0;
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int t;
    cin>>t;
    if(t==1) flip^=1;
    if(t==2){
      int f;
      char c;
      cin>>f>>c;
      if((f==1 and !flip) or (f==2 and flip)){
        dc.emplace_front(c);
      }else{
        dc.emplace_back(c);
      }
    }
  }
  if(flip) reverse(dc.begin(),dc.end());
  cout<<string(dc.begin(),dc.end())<<newl;
  return 0;
}


Measured memory_bytes: 1232
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    A,B,K = map(int, input().split())
    turn = 0
    while K > 0:
        if turn == 0:
            if A%2 == 1:
                A -= 1
            B += A/2
            A /= 2
            turn ^= 1
        else :
            if B%2 == 1:
                B -=1
            A += B/2
            B /= 2
            turn ^= 1
        K -= 1

    A = (int)(A)
    B = (int)(B)
    print(A,B)
            


        

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF = numeric_limits<long long>::max();
#define intf int_fast64_t
int main(){
    intf n,ans=0;
    cin >>n;
    vector<intf> a(n);
    for(auto &e:a)cin >>e;

    sort(a.begin(),a.end(),std::greater<intf>());

    rep(i,n){
        ans += pow(-1,i+2) * a[i];
    }
    cout << ans <<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n; cin >> n;
    vector<int> ans;
    int a;
    while(n--){
        cin >> a;
        ans.push_back(a);
    }
    
    sort(ans.begin(),ans.end());
    
    double ret = ans[0];
    for(int i=1;i<ans.size();i++){
        ret = (ret + ans[i])/2;
    }
    
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    
    size_t n;
    std::cin >> n;

    if(n % 2 == 0){
        std::cout << (n / 2) / static_cast<double>(n) << std::endl;
    }else{
        std::cout << (n - (n / 2)) / static_cast<double>(n) << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int num[100]={0};
int main(){
  int i,j,n,a[3][3],cnt=0,b;
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> a[i][j];
    }
  }
  cin >> n;
  for(i=0; i<n; i++){
    cin >> b;
    num[b]++;
  }
  for(i=0; i<3; i++){
    if(num[a[i][1]]&&num[a[i][2]]&&num[a[i][0]]){
      cnt++;
    }
    else if(num[a[1][i]]&&num[a[2][i]]&&num[a[0][i]]){
      cnt++;
    }
  }
  if(num[a[1][1]]&&num[a[2][2]]&&num[a[0][0]]){
    cnt++;
  }
  else if(num[a[0][2]]&&num[a[1][1]]&&num[a[2][0]]){
    cnt++;
  }
  if(cnt>0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int a,b,c;
	int max,sum=0;

	cin>>a>>b>>c;
	sum=a+b+c;

	if(a == sum/2.0 || b == sum/2.0 || c == sum/2.0 ){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}


	return 0;
}

Measured memory_bytes: 764
#include<cstdio>
#include<algorithm>

using namespace std;
int main(void)
{
	int a,b,n;
	while(scanf("%d%d%d",&a,&b,&n)!= EOF)
	{
		int kari = a % b;
		int sum = 0;
		for(int i = 0;i < n;i++)
		{
			sum += 10 * kari / b;
			kari = 10 * kari % b;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

#define INF 1e9
using namespace std;

int main(){
  int n,k,q,a,b,e;
  long r[101][101];
  while(cin>>n>>k,n||k){
    for(int i=1;i<=n;++i){
      for(int j=1;j<=n;++j) r[i][j]=INF;
    }
    for(int i=0;i<k;++i){
      cin>>q;
      if(q){
	cin>>a>>b>>e;
	if(r[a][b]>e) r[a][b]=r[b][a]=e;
      }
      else{
	bool ud[n+1];
	long d[n+1];
	for(int j=1;j<=n;++j){
	  d[j]=INF;ud[j]=false;
	}
	cin>>a>>b;
	d[a]=0;
	while(1){
	  int v=-1;
	  for(int j=1;j<=n;++j){
	    if(!ud[j]&&(v==-1||d[j]<d[v])) v=j;
	  }
	  if(v==-1) break;
	  ud[v]=true;
	  for(int j=1;j<=n;++j){
	    d[j]=min(d[j],d[v]+r[v][j]);
	  }
	}
	cout<<((d[b]>=INF)?-1:d[b])<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin>>x1>>y1>>x2>>y2;
  x3=x2-(y2-y1);
  y3=y2+(x2-x1);
  x4=x3-(x2-x1);
  y4=y3-(y2-y1);
  cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<" "<<endl;
}


Measured memory_bytes: 256
x, y = map(int, input().split())
a = abs(abs(x) - abs(y))
if y == 0:
    if x < 0:
        print(a)
    else:
        print(a + 1)
elif x == 0:
    if y < 0:
        print(a + 1)
    else:
        print(a)
elif abs(x) < abs(y):
    if x > -1 and y > -1:
        print(a)
    elif x < 0 and y < 0:
        print(a + 2)
    else:
        print(a + 1)
else:
    if x > -1 and y > -1:
        print(a + 2)
    elif x < 0 and y < 0:
        print(a)
    else:
        print(a + 1)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string n;
cin>>n;
string ca = n.substr(0,n.size()-8);
cout <<ca<< endl;
return 0;}



Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;

const int MAXN = 2e5+2;

int nex[MAXN][26];

int f[MAXN][2];
char s[MAXN];

int main() {
#ifdef DEBUG
	freopen("in", "r", stdin);
#endif
	scanf("%s", s);

	f[0][0] = 1;
	f[0][1] = -100;
	f[1][0] = s[0] == s[1] ? -100 : 2;
	f[1][1] = 1;
	int len = strlen(s);
	for (int i=2; i<len; ++i) {
		f[i][0] = f[i-1][1]+1;
		if (s[i-1]!=s[i]) f[i][0] = max(f[i][0], f[i-1][0]+1);
		f[i][1] = f[i-2][0]+1;
		if (s[i-3]!=s[i-1] || s[i-2] != s[i])
			f[i][1] = max(f[i][1], f[i-2][1]+1);
	}
	//for (int i=0; i<len; ++i)
		//printf("%d ", f[i][0]);
	//printf("\n");	
	//for (int i=0; i<len; ++i)
		//printf("%d ", f[i][1]);
	//printf("\n");
	printf("%d\n", max(f[len-1][0], f[len-1][1]));

	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
using namespace std;

void solve()
{
    ll n;
    cin >> n;
    ll arr[n];
    for(ll i=0;i<n;i++)
        cin >> arr[i];
    ll sum=0;
    for(ll i=1;i<n;i++)
    {
        ll p=max(arr[i-1]-arr[i],0ll);
        sum+=p;
        arr[i]+=p;
    }
    cout << sum << endl;
}

int main()
{
    int t=1;
    //cin >> t;
    while(t--)
    solve();

    return 0;
}



Measured memory_bytes: 5104
#include<iostream>
#include<vector>
#include<cmath>
#include<string>
#include<map>
#include<list>
#include<cctype>
#include<utility>
#include<algorithm>
#include<cmath>
#include<cctype>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<double>x(n),y(n);
	for(int i=0;i<n;i++)
		cin >> x[i];
	for (int i = 0; i < n; ++i)
		cin >> y[i];

	for(int i=1;i<=3;i++){
		double ret=0;
		for(int j=0;j<n;j++){
			ret += pow(abs(x[j]-y[j]),i);
		}
		printf("%.10f\n",pow(ret,1./i));
	}

	double ret = 0;
	for(int i=0;i<n;i++)
		ret = max(ret,abs(x[i]-y[i]));
	printf("%.10f\n",ret);


    return 0;
}

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

//Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type / Class / Struct Definitions:
using ll = long long;
using ull = unsigned long long;

//Constants:
const int INF = (1ll << 30) - 1;  //nearly 1.07e9
const ll INFLL = 1ll << 60;       //nearly 1.15e18
const int MOD = 1e9 + 7;
const long double EPS = 1.0e-14;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

//================ Main Loop ================
int main() {
    int n, m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
    return 0;
}
//===========================================

//Functions:
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

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


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

double dp[3001][3001];
double solve(double*arr,int i,int x)
{
	if(x==0)
		return 1;

	if(i==0)
		return 0;

	if(dp[i][x]> -0.9)
		return dp[i][x];

	return dp[i][x]=arr[i]*solve(arr,i-1,x-1)+(1-arr[i])*solve(arr,i-1,x);
}

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

	double*arr=new double[n+1];
	for(int i=1;i<=n;i++)
		cin>>arr[i];

	memset(dp,-1,sizeof(dp));

	cout<<fixed<<setprecision(10)<<solve(arr,n,(n+1)/2);
	return 0;
}

Measured memory_bytes: 74316
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(final String[] args) {
        try (final Scanner sc = new Scanner(System.in)) {
            final int n = sc.nextInt();
            final int k = sc.nextInt();
            final String s = sc.next();

            List<Integer> nums = new ArrayList<Integer>();
            int now = 1; // これにより、numsの最初の要素は必ず1に対応する（文字列の最初の要素が1でないときでも）
            int count = 0;
            for (int i = 0; i < n; i++) {
                if (s.charAt(i) == (char) ('0' + now)) {
                    count += 1;
                } else {
                    nums.add(count);
                    now = 1 - now; // now ^= 1もあり
                    count = 1;
                }
            }
            nums.add(count);
            // numsの末尾も1に対応させたいので、0対応で終わっていたら（数が偶数個なら）1に対応する要素を追加（実際は存在しないので数は0）
            if (nums.size() % 2 == 0) {
                nums.add(0);
            }
            // しゃくとり法
            int ans = 0;
            int add = 2 * k + 1;
            int left = 0;
            int right = 0;
            int temp = 0; // [left, right)
            for (int i = 0; i < nums.size(); i += 2) {
                int nextLeft = i;
                int nextRight = Math.min(nextLeft + add, nums.size());
                while (nextLeft > left) {
                    temp -= nums.get(left);
                    left++;
                }
                while (nextRight > right) {
                    temp += nums.get(right);
                    right++;
                }
                ans = Math.max(ans, temp);
            }
            System.out.println(ans);
        }
    }

}


Measured memory_bytes: 26900
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading;

class Program
{
  
    
    static void Main(string[] args)
    {
        Console.ReadLine();
        int[] arr = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        var a = arr.GroupBy(v => v);
        foreach(var ele in a)
        {
            if(ele.Count() != 1)
            {
                Console.WriteLine("NO");
                return;
            }
        }
        Console.WriteLine("YES");


    }




}

Measured memory_bytes: 67408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,ans=0;
  cin>>n;
  ll i;
  string s[n];
  map<string, ll> mp;
  for(i=0;i<n;i++)
  {
    cin>>s[i];
    sort(s[i].begin(), s[i].end());
    mp[s[i]]++;
  }
  
 for(auto m :mp)
 {
   if(m.second>=2) ans+=((m.second*(m.second-1))/2);
 }
 cout<<ans;
 return 0;
}

Measured memory_bytes: 18176