akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const long double eps=1e-9;
int main(){
	long double d;	scanf("%Lf",&d);
	if(1.0-d>eps){
		printf("%.15Lf\n",d*sqrtl(2.0L));
	}
	else{
		printf("%.15Lf\n",max(d*sqrtl(2.0L),floorl(d)+1.0L));
	}
	return 0;
}

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

int main() {
    int A, B;
    cin >> A >> B;
    if (A == 1) A = 14;
    if (B == 1) B = 14;
    if (A > B) {
        cout << "Alice" << endl;
    } else if (A < B) {
        cout << "Bob" << endl;
    } else {
        cout << "Draw" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

typedef string::const_iterator State;
class ParseError {};

struct Parser {
    // エラー検出
    void consume(State &begin, char expected) {
        if(*begin == expected) begin++;
        else {
            cerr << "Expected '" << expected << "' but got '" << *begin << "'" << endl;
            cerr << "Rest string is '";
            while(*begin) {
                cerr << *begin++;
            }
            cerr << "'" << endl;
            throw ParseError();
        }
    }

    // 数字の列をパースして、その数を返す
    int number(State &begin) {
        int ret = 0;
        while(isdigit(*begin)) {
            ret *= 10;
            ret += (*begin - '0');
            begin++;
        }
        return ret;
    }

    // 括弧か数をパースして、その評価結果を返す
    int factor(State &begin) {
        if(*begin == '(') {
            consume(begin, '(');    // '('を飛ばす
            int ret = expression(begin);
            consume(begin, ')');    // ')'を飛ばす
            return ret;
        }else return number(begin);
    }

    // 乗算除算の式をパースして、その評価結果を返す
    int term(State &begin) {
        int ret = factor(begin);
        while(1) {
            if(*begin == '*') {
                consume(begin, '*');
                ret *= factor(begin);
            }else if(*begin == '/') {
                consume(begin, '/');
                ret /= factor(begin);
            }else break;
        }
        return ret;
    }

    // 四則演算の式をパースして、その評価結果を返す
    int expression(State &begin) {
        int ret = term(begin);
        while(1) {
            if(*begin == '+') {
                consume(begin, '+');
                ret += term(begin);
            }else if(*begin == '-') {
                consume(begin, '-');
                ret -= term(begin);
            }else break;
        }
        return ret;
    }
};

int main() {
    int n; cin >> n;
    cin.ignore();
    for(int i = 0; i < n; ++i) {
        Parser ps;
        string s;
        getline(cin, s);

        State begin = s.begin();
        int ans = ps.expression(begin);
        ps.consume(begin, '=');
        cout << ans << endl;
    }
}


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

using namespace std;

#define rep(i, n) REP(i, 0, n)
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
	string s, t;
	cin >> s >> t;
	
	map<char, int> ms, mt;
	rep(i, s.size()) {
        if(ms[s[i]] != mt[t[i]]) {
            cout << "No" << endl;
            return 0;
        }
        if(!ms[s[i]]) ms[s[i]] = ms.size();
        if(!mt[t[i]]) mt[t[i]] = mt.size();
	}
	cout << "Yes" << endl;
}


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

class Progaram
{
    static long Choose2(long v)
    {
        return v * (v - 1) / 2;
    }

    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var line = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToArray();
        line = line.Select(x => x - 1).ToArray();
        var cnt = new int[n];
        //Console.WriteLine(line[0]);
        foreach (var i in line) cnt[i]++;
        //Console.WriteLine("time1");
        long tot = cnt.Select(x => Choose2(x)).Sum();
        foreach (var i in line)
        {
            //Console.WriteLine("time1");
            var ans = tot;
            ans -= Choose2(cnt[i]);
            ans += Choose2(cnt[i] - 1);
            Console.WriteLine(ans);
        }

    }
}



Measured memory_bytes: 36160
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;

bool coverd[5000][5000];

int main() {
	vector<int> xl,yl,xs, xe, ys, ye;
	xl.reserve(5000);
	yl.reserve(5000);
	xs.reserve(3000);
	xe.reserve(3000);
	ys.reserve(3000);
	ye.reserve(3000);

	int N;
	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		int x1, x2, y1, y2;
		scanf("%d %d %d %d", &x1, &y1, &x2, &y2);

		xl.push_back(x1 + 1000000000);
		xl.push_back(x2 + 1000000000);
		yl.push_back(y1 + 1000000000);
		yl.push_back(y2 + 1000000000);
		xs.push_back(x1 + 1000000000);
		xe.push_back(x2 + 1000000000);
		ys.push_back(y1 + 1000000000);
		ye.push_back(y2 + 1000000000);
	}

	sort(xl.begin(), xl.end());
	sort(yl.begin(), yl.end());
	xl.erase(unique(xl.begin(), xl.end()), xl.end());
	yl.erase(unique(yl.begin(), yl.end()), yl.end());

	for (int i = 0; i < N; i++)
	{
		xs[i] = lower_bound(xl.begin(), xl.end(), xs[i]) - xl.begin();
		xe[i] = lower_bound(xl.begin(), xl.end(), xe[i]) - xl.begin();
		ys[i] = lower_bound(yl.begin(), yl.end(), ys[i]) - yl.begin();
		ye[i] = lower_bound(yl.begin(), yl.end(), ye[i]) - yl.begin();
	}

	for (int k = 0; k < N; k++)
	{
		for (int i = xs[k]; i < xe[k]; i++)
		{
			for (int j = ys[k]; j < ye[k]; j++)
			{
				coverd[i][j] = true;
			}
		}
	}

	ll area = 0;
	for (int i = 0; i != (xl.size() - 1); i++)
	{
		for (int j = 0; j != (yl.size() - 1); j++)
		{
			if (coverd[i][j])
			{
				ll x1, x2, y1, y2;
				x1 = xl[i + 1]; x2 = xl[i];
				y1 = yl[j + 1]; y2 = yl[j];
				area += (x1 - x2)*(y1 - y2);
			}
		}
	}

	cout << area << endl;

	return 0;
}


Measured memory_bytes: 22796
#include <iostream>
#include <algorithm>

using namespace std;

int w, h;
char input[50][50];
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, 1, 0, -1};
bool touched[2][50][50];

bool isOver(int y, int x){
  if(y<0 || y>=h) return true;
  if(x<0 || x>=w) return true;
  return false;
}

void dfs(int y, int x, int p){
  touched[p][y][x] = true;
  for(int i=0;i<4;i++){
    int ny = y + dy[i];
    int nx = x + dx[i];
    if(isOver(ny, nx)) continue;
    if(input[ny][nx] != '.') continue;
    if(touched[p][ny][nx]) continue;
    dfs(ny, nx, p);
  }
}

main(){
  while(cin >> w >> h && (w|h)){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        cin >> input[i][j];
      }
    }
    fill(touched[0][0], touched[2][0], false);
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(input[i][j] == '.'){
          for(int k=0;k<4;k++){
            int ny = i + dy[k];
            int nx = j + dx[k];
            if(isOver(ny, nx)) continue;
            if(input[ny][nx] == 'B' && !touched[0][i][j]) dfs(i, j, 0);
            if(input[ny][nx] == 'W' && !touched[1][i][j]) dfs(i, j, 1);
          }
        }
      }
    }
    int ans1 = 0, ans2 = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(touched[0][i][j] && !touched[1][i][j]) ans1++;
        if(!touched[0][i][j] && touched[1][i][j]) ans2++;
      }
    }
    cout << ans1 << ' ' << ans2 << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    vector<int> P(N);
    vector<int> Q(N);
    vector<int> ar(N);
    rep(i,N)cin >> P[i];
    rep(i,N)cin >> Q[i];
    rep(i,N)ar[i] = i+1;

    int pn = 0;
    int qn = 0;
    int ct1 = 0;
    int ct2 = 0;
    do{
        int tmp = 0;
        int p = 0;
        for(int i=N-1; i>=0; i--){
            tmp += ar[i] * pow(10,i);
            p += P[i] * pow(10,i);
        }
 //       cout << tmp << " " << p << endl;
        if(tmp == p)pn = ct1;
        ct1++;
    }while(next_permutation(all(ar)));

    do{
        int tmp = 0;
        int q = 0;
        for(int i=N-1; i>=0; i--){
            tmp += ar[i] * pow(10,i);
            q += Q[i] * pow(10,i);
        }
        if(tmp == q)qn = ct2;
        ct2++;
    }while(next_permutation(all(ar)));

 //   cout << pn << " " << qn << endl;
    cout << abs(pn-qn) << endl;
}


Measured memory_bytes: 512
x,k,d=map(int,input().split())

x=abs(x)
kai=x//d
if kai==k:
    print(x%d)
elif kai>k:
    print(x-k*d)
else:
  right=x%d
  left=abs(x%d-d)

  if (kai+k)%2==0:
      print(right)
  else:
      print(left)

Measured memory_bytes: 9044
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,m,x,y; cin >> n >> m >> x >> y;
    VI xx(n) , yy(m);
    REP(i,n) cin >> xx[i]; xx.push_back(x);
    REP(i,m) cin >> yy[i]; yy.push_back(y);
    if(MAX(xx)<MIN(yy)){out("No War");}
    else out("War");

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(),v.end()

int main() {
  double d, t, s;
  cin >> d >> t >> s;
  double a;
  a=d/s;
  if(a<=t){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}



Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main()
{
    int m, n;
    while( cin >> m >> n ) {
        if ( m > n )
            swap( m, n );
        while( n != 0 ) {
            int const nn = n;
            n = m % n;
            m = nn;
        }
        cout << m << endl;
    }
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#define N 100005
long long fun(long long [],long long );
int cmp(const void *,const void *);
int cmp(const void *a,const void *b)
{
    return *(int *)a-*(int *)b;
}
long long fun(long long a[],long long n)
{
    long long i;
    long long cnt[3]={0},t=0;
    qsort(a,n,sizeof(a[i]),cmp);
    for(i=n-1;i>=1;i--)
    {
        if(a[i]==a[i-1])
        {
            cnt[t++]=a[i];
            i--;
            if(t==2)
            {
                break;
            }
        }
    }
    return cnt[0]*cnt[1];
}
int main()
{
    long long n,i;
    long long a[N];
    scanf("%lld",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    printf("%lld\n",fun(a,n));
    return 0;
}

Measured memory_bytes: 1788
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
const ll mod = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()


const int MOD = 998244353;

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

	vector<int> d(n + 1);
	reple(i, 1, n)
	{
		cin >> d[i];
	}

	//1と1の距離は0
	if (d[1] != 0)
	{
		cout << 0 << endl;
		return 0;
	}

	map<int, int> counts;
	reple(i, 1, n)
	{
		counts[d[i]]++;
	}

	//1以外に距離0のノードがある場合はおかしい
	if(counts[0] != 1)
	{
		cout << 0 << endl;
		return 0;
	}
	

	//場合の数の計算
	ll totalCount = 1;
	int prevCount = 1;
	int prevD = -1;

	for (auto itr = counts.begin()++; itr != counts.end(); ++itr)
	{
		if (itr->first != prevD + 1)
		{
			totalCount = 0;
			break;
		}

		rep(i, itr->second)
		{
			totalCount *= prevCount;
			totalCount %= MOD;
		}

		prevD = itr->first;
		prevCount = itr->second;
	}

	
	cout << totalCount << endl;

	return 0;
}

Measured memory_bytes: 5376
// ------------------------------------
// Date:2018/ 3/10
// Problem:ABC 072 Together c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int N;
  cin >> N;
  map< int, int > m;
  REP(i, N) {
    int a;
    cin >> a;
    if (a > 0) m[a - 1]++;
    m[a]++;
    m[a + 1]++;
  }

  int ans = 0;
  REP(mi, m.size()) {
    ans = max(ans, m[mi]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)

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

struct edge {
	int to,cost;
	edge(int t,int c):to(t),cost(c) {}
};

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

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

int n,a,x[51];
ll dp[51][51][2501];

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

	cin>>n>>a;
	REP(i,n) cin>>x[i];

	dp[0][0][0]=1;
	REP(i,n) {
		REP(j,n) {
			REP(k,2501) {
				dp[i+1][j][k]+=dp[i][j][k];
				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
			}
		}
	}

	ll ans=0;
	FOR(i,1,n+1) ans+=dp[n][i][i*a];

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 50048
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> score(N);
  int t;
  for (int i = 0; i < Q; i++){
    cin >> t;
    score.at(t-1) += 1;
  }
  for (int i = 0; i < N; i++){
    if (score.at(i) - Q + K >= 1){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

int main(){
	int h,n,a;
	int sum = 0;

	cin >> h >> n;
	for(int i = 0; i<n; i++){
		cin >> a;
		sum += a;
	}
	if(sum >= h)cout << "Yes\n";
	else cout << "No\n";


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,k;
	char a;
	scanf("%d%d",&n,&k);
	if(n==0){
		if(k>1988){
			k=k-1988;
			a='H';
		}
		else if(k>1925){
			k=k-1925;
			a='S';
		}
		else if(k>1911){
			k=k-1911;
			a='T';
		}
		else{
			k=k-1867;
			a='M';
		}
	}
	else{
		if(n==1)k=k+1867;
		else if(n==2)k=k+1911;
		else if(n==3)k=k+1925;
		else k=k+1988;
	}
	if(n==0)printf("%c",a);
	printf("%d\n",k);
	return 0;
}


Measured memory_bytes: 2120
n = int(input())
x = list(map(int, input().split()))
ave = sum(x)/len(x)
MIN = abs(x[0]-ave)
MIN_index = 0
for i,j in enumerate(x):
  if abs(j-ave) < MIN:
    MIN_index = i
    MIN = abs(j-ave)
print(MIN_index)
  
  

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

int main() {
  int N;
  vector<int> num(110);

  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> num.at(i);
  }
  sort(num.begin(),num.end());
  reverse(num.begin(),num.end());
  int num_diff = num.at(0) - num.at(N - 1);
  
  cout << num_diff << endl;
}

Measured memory_bytes: 256
use proconio::*;
use std::cmp::min;

fn main() {
    input! {s: String}
    let mut ans = s.len()-1;
    for c in b'a'..=b'z' {
        ans = min(ans, s.split(c as char).map(|s| s.len()).max().unwrap());
    }
    println!("{}", ans);
}

Measured memory_bytes: 2120
import Control.Monad

main = do
  [a,b] <- map read . words <$> getLine :: IO [Int]
  print . sum $ map isParindrome [min a b .. max a b]

isParindrome n = let
 [a,b,_,d,e] = show n
 in if a==e && b==d then 1 else 0

Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	int a[55], b[55], c[55], d[55];
	for (int i = 1; i <= N; i++) {
		cin >> a[i]>>b[i];
	}
	for (int i = 1; i <= M; i++) {
		cin >>c[i]>>d[i];
	}
	
	for (int i = 1; i <= N; i++) {
		int point = 1;
		int dist1 = abs(a[i] - c[1]) + abs(b[i] - d[1]);
		for (int j = 1; j <= M; j++) {
			int kyori= abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (kyori < dist1) {
				dist1 = kyori;
				point = j;
			}
		}
		cout << point << endl;
	}

	return 0;
}




Measured memory_bytes: 256
def main():
    BK = '#'
    WH = '.'

    A, B = map(int, input().split())

    g = []
    for _ in range(50):
        g.append([BK] * 100)  # 100にし忘れていた
    for _ in range(50):
        g.append([WH] * 100)

    r, c = 1, 1
    for _ in range(A - 1):
        g[r][c] = WH
        c += 2
        if c > 99:
            c = 1
            r += 2

    r, c = 51, 1
    for _ in range(B - 1):
        g[r][c] = BK
        c += 2
        if c > 99:
            c = 1
            r += 2

    print(100, 100)
    for row in g:
        print(*row, sep='')


if __name__ == '__main__':
    main()


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

#define ll long long
#define ld long double
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<

int main(){
  ll n;
  cin >> n;
  vector<ll> l(n);
  ll i;
  for(i = 0; i < n; i++)
    cin >> l[i];
  sort(ALL(l));
  ll sum = 0;
  for(i = 0; i < n - 1; i++)
    sum += l[i];
  if(sum > l[n - 1])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
using namespace std;
long long power5(long long n) {
	return n * n * n * n * n;
}
int main() {
	long long x; cin >> x;
	for (long long i = -1000; i < 1000; i++) {
		for (long long j = -1000; j < 1000; j++) {
			if (power5(i) - power5(j) == x) {
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    if(n%2){
        cout << "No" << endl;
        return 0;
    }
    for(int i = 0; i < n/2; i++){
        if(s[i] != s[n/2+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N, K;
    cin >> N >> K;
    //
    vector<int> x(N);
    for(int i=0;i<N;i++){
        cin >>x[i] ;
    }
    //
    long long distance = 0;
    for(int i=0;i<N;i++){
        int shortest ;
        if( abs(x[i]-0) < abs(x[i] -K)){
            shortest = abs(x[i]- 0);
        }
        else {
            shortest = abs(x[i]- K);
        }
        distance = distance + shortest*2 ;
    }
    cout << distance << endl;

}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int ll
#define all int i=0; i<n; i++
#define pb push_back
#define pf push_front
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int> >
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define mod 1000000007
#define INF 0x3f3f3f3f3f
#define mp make_pair
#define pii pair<int,int>
#define T int t;cin>>t;while(t--)
#define I 
#define think 
#define we 
#define should 

bool sortinrev(const pair<ll,ll> &a,  
               const pair<ll,ll> &b) 
{ 
       return (a.first > b.first); 
}
int abso(int k){
	if(k==0)return 0;
	else if(k<0) return -1*k;
	else return k;
}
map<int, int>c;
int g[1000005];
int32_t main() 
{ 
	int n,W;
	cin>>n>>W;
	int weight[n+1];
	int val[n+1];
	int dp[W+1][n+1];
	for(int i=1; i<=n; i++){
		cin>>weight[i]>>val[i];
	}
	for(int j=0; j<=n; j++){
			dp[0][j] = 0;
	}
	for(int j=0; j<=W; j++){
			dp[j][0] = 0;
	}
	for(int j=1; j<=n; j++){
		for(int i=1; i<=W; i++){
			if(weight[j] > i){
				dp[i][j] = dp[i][j-1];
			}
			else{
				dp[i][j] = max(dp[i][j-1], dp[i - weight[j]][j-1] + val[j]);
			}
		}
	}
	cout<<dp[W][n]<<endl;
}



Measured memory_bytes: 79104
#include <cstdio>
#include <cstring>

#define max(a, b) (a > b ? a : b)
using namespace std;

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

    int candies[2 + 1][no_of_columns + 1];
    memset(candies, 0, sizeof(candies));

    for(int i = 1; i <= 2; i++)
        for(int j = 1; j <= no_of_columns; j++)
            scanf("%d", &candies[i][j]);

    int max_candies_till[2 + 1][no_of_columns + 1];
    memset(max_candies_till, 0, sizeof(max_candies_till));

    for(int i = 1; i <= 2; i++)
    {
        for(int j = 1; j <= no_of_columns; j++)
        {
            max_candies_till[i][j] = candies[i][j] + max(max_candies_till[i - 1][j], max_candies_till[i][j - 1]);
        }
    }

    printf("%d\n", max_candies_till[2][no_of_columns]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	string a,b,c,wa,wb,wc;
	cin>>a>>b>>c;
	wa=a.substr(0,1);
	wb=b.substr(0,1);
	wc=c.substr(0,1);
	transform(wa.begin(), wa.end(), wa.begin(), ::toupper);
	transform(wb.begin(), wb.end(), wb.begin(), ::toupper);
	transform(wc.begin(), wc.end(), wc.begin(), ::toupper);
	cout<<wa+wb+wc<<endl;

	return 0;
}


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

void bubbleSort( int* a, string* b, int n )
{
    for( int i = 0; i < n; i++ )
        for( int j = n - 1; j >= i + 1; j-- )
        {
            if( a[j-1] < a[j] )
            {
                int temp = a[j-1];
                a[j-1] = a[j];
                a[j] = temp;

                string temp2 = b[j-1];
                b[j-1] = b[j];
                b[j] = temp2;
            }
        }

}

int main()
{   
    int n, a[10], b, c, cnt = 0;
    string s[10];

    while( cin >> n )
    {
        if( n == 0 )
            break;
        if( cnt != 0 )
            cout << endl;
        cnt++;
        for( int i = 0; i < n; i++ )
        {
            cin >> s[i] >> a[i] >> b >> c;
            a[i] = a[i] * 3 + c;
        }
        bubbleSort( a, s, n );
        for( int i = 0; i < n; i++ )
            cout << s[i] << ',' << a[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 3160
N = int(raw_input())
likes = map(int, raw_input().split())
pairs = 0
counter = 0
rabbit = 1
while counter < N:
    if likes[(likes[counter] - 1)] == rabbit:
        pairs += 1
        rabbit += 1
        counter += 1
    else:
        rabbit += 1
        counter += 1
pairs = pairs / 2
print pairs

Measured memory_bytes: 11328
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <functional>
//#include "bits/stdc++.h"
using namespace std;
//using namespace std::vector;
#define rep(i,a,b) for(int i=(a);i<(b);++i)

#define huge 1000000007
typedef long long ll;
ll gcd(ll a, ll b);

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll C = 0;
	ll D = 0;
	ll M = 0;
	//ll M = 0;
	ll a[200] = {};
	ll b[200] = {};
	ll v[3] = {};
	//ll *a, *b, *x;
	string S, T, U[52];
	ll count = 0;
	ll sum = 0;
	ll min = 100000;
	ll max = 0;
	int flag = 0;
	char temp, head;
	//int is = 0;

	vector<int> c(3);
	//char p;






	//cin >> S;

	//a = (ll *)malloc(M * sizeof(ll));
	//b = (ll *)malloc(M * sizeof(ll));
	//vector<pair<int,int>> ch(50);

	//vector<bool> flag(N);

	cin >> N;
	/*rep(i, 0, M) {
	cin >> ch[i].first >> ch[i].second;
	}*/
	//x = (ll *)malloc((N+1) * sizeof(ll));
	//c = (ll *)malloc((N) * sizeof(ll));
	//cin >> D >> G;
	//vector<pair<int,int>> tr(M);
	//vector<pair<int,int>> qes(Q);
	//sort(c.begin(), c.end());

	//cout << c[2] - c[1] << endl;


	/*A = N / 1000;
	N %= 1000;
	B = N / 100;
	N %= 100;
	C = N / 10;
	N %= 10;
	D = N;*/



	if (N == 1)
		cout << "Hello World" << endl;
	else if (N == 2) {
		cin >> A >> B;
		cout << A + B << endl;
	}
	

	
	return 0;

}

ll gcd(ll a, ll b) {
	ll c;
	c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	return b;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 string X;
   cin>>X;
  char a = X[X.size()-1];
 
  if(a=='s'){
    cout<<X<<"es"<<endl;
  }
    else{
      cout<<X<<"s"<<endl;
    }
    
  }

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<unordered_map>
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main(void) {

    ll N, K;
    cin >> N >> K;

    ll a, b;
    unordered_map<ll, ll> m;
    for (ll i = 0; i < N; ++i) {
        cin >> a >> b;
        m[a] += b;
    }

    // pq?
    vector<ll> keys;
    for (const auto& p : m) {
        keys.push_back(p.first);
    }

    sort(keys.begin(), keys.end(), less<ll>());

    // ll cnt = 0;
    // for (auto key : keys) {
    //     cnt += m[key];
    //     if (cnt >= K) {
    //         cout << key << endl;
    //         return 0;
    //     } 
    // }

   ll cnt = 0;
   for (auto &v: keys) {
      if (cnt < K && K <= cnt + m[v]) {
         cout << v << endl;
         return 0;
      }
      cnt += m[v];
   }

    // for (int i = 0; i < N; ++i) {
    //     if (K <= m[keys[i]]) {
    //         cout << keys[i] << endl;
    //         break;
    //     }
    //     K -= m[keys[i]];
    // }

    return 0;
}

Measured memory_bytes: 4260
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define MOD 1000000007

using namespace std;
typedef long long ll;

int N, K;
ll cnt[100001];
ll sum_div[100001];
int div_cnt[100001];
ll cnt1[100001];
bool sq[100001];

template <typename T>
T pow(T a, ll n) {
	T ans = 1;
	T tmp = a;
	for (int i = 0; i <= 30; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans *= tmp;
		ans %= MOD;
		}
		tmp *= tmp;
		tmp %= MOD;
	}
	return ans;
}


template <typename T>
vector<T> divs(T N) {
	vector<T> ans;
	for (int i = 1; i * i <= N; i++) {
		if (N % i == 0) {
		ans.push_back(i);
		if (i * i != N) ans.push_back(N / i);
		}
	}
	return ans;
}

template <typename T>
vector<T> prime_facs(T N) {
	vector<T> ans;
    int N_ = N;
	for (int i = 2; i * i <= N; i++) {
		if (N % i == 0) {
            ans.push_back(i);
            int cnt = 0;
            while (N % i == 0) {
                N /= i;
                cnt++;
            }
            if(cnt >= 2) {
                sq[N_] = true;
            }
		}
	}
	if (N != 1) ans.push_back(N);
	return ans;
}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(ll i = 1; i <= K; i++){
        div_cnt[i] = prime_facs<int>(i).size();
    }
    for(ll i = 1; i <= K; i++){
        int m = K/i;
        cnt1[m] = pow<ll>(m, N);
        for(int j = 2; j <= m; j++){
            if(sq[j]) continue;
            if(div_cnt[j]%2 == 0){
                cnt1[m] += pow<ll>(m/j, N);
            }else{
                cnt1[m] -= pow<ll>(m/j, N);
            }
            cnt1[m] %= MOD;
            cnt1[m] += MOD;
            cnt1[m] %= MOD;
        }
        // cout << m << ' ' << cnt1[m] << endl;
    }
    ll ans = 0;
    for(int i = 1; i <= K; i++){
        int m = K/i;
        ans += i*cnt1[m];
        // cout << cnt1[m] << endl;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 4252
#include <iostream>

using namespace std;

class Dice {
private:
	int number[6];
public:
	void setNumber(int index, int num);
	void move(string d);
	int getTop();
};

void Dice::setNumber(int index, int num) {
	number[index] = num;
}

void Dice::move(string d) {
	for (int i = 0; i < d.size(); i++) {
		int newNumber[6] = {0};
		char c = d[i];
		if (c == 'N') {
			newNumber[0] = number[1];
			newNumber[1] = number[5];
			newNumber[2] = number[2];
			newNumber[3] = number[3];
			newNumber[4] = number[0];
			newNumber[5] = number[4];
		}
		else if (c == 'E') {
			newNumber[0] = number[3];
			newNumber[1] = number[1];
			newNumber[2] = number[0];
			newNumber[3] = number[5];
			newNumber[4] = number[4];
			newNumber[5] = number[2];
		}
		else if (c == 'W') {
			newNumber[0] = number[2];
			newNumber[1] = number[1];
			newNumber[2] = number[5];
			newNumber[3] = number[0];
			newNumber[4] = number[4];
			newNumber[5] = number[3];
		}
		else if (c == 'S') {
			newNumber[0] = number[4];
			newNumber[1] = number[0];
			newNumber[2] = number[2];
			newNumber[3] = number[3];
			newNumber[4] = number[5];
			newNumber[5] = number[1];
		}
		for (int i = 0; i < 6; i++)
			number[i] = newNumber[i];
	}
}

int Dice::getTop() {
	return number[0];
}

int main() {
	Dice dice;
	int n;
	for (int i = 0; i < 6; i++) {
		cin >> n;
		dice.setNumber(i, n);
	}
	string s;
	cin >> s;
	dice.move(s);
	cout << dice.getTop() << endl;
	return 0;
}

Measured memory_bytes: 1212
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    vector<int> v(26);
    string ans="No",s;
    in s;
    bool flag=false;
    rep(i,s.size())v[s[i]-'a']++;
    rep(i,26)
        if(v[i]%2==1)
        {
            pn;
            flag = true;
            break;
        }
    if(!flag)py;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
	int32_t A, B, C, D;
	cin >> A >> B >> C >> D;

	cout << max(A * B, C * D) << endl;

	return 0;
}


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

int main(){
    int64_t h,w;
    cin>>h>>w;
    if(h == 1 or w == 1) cout<<1<<endl;
    else{if(h*w%2==1)cout<<h*w/2+1<<endl;
    else cout<<h*w/2<<endl;
    }
}

Measured memory_bytes: 256
n = int(input())

def divisior(n):
    a = []
    i = 1
    while (i*i <= n):
        if n%i == 0:
            a.append(i)
            if (i*i != n): a.append(n//i)
        i += 1
    return a

ans = 0
a = divisior(n)

for x in a[1:]:
    tmp = n
    while (tmp%x == 0): tmp = tmp//x
    if (tmp%x == 1) : ans += 1

b = divisior(n-1)

ans = ans + len(b) -1

print(ans)




Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cmath>
using namespace std; 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define int long long int
#define rep(i,a,b) for(int i=a;i<b;i++)
#define reprev(i,a,b) for(int i=b-1;i>=a;i--)
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mapp map<int,int>
#define pb push_back
#define mp  make_pair
#define mod 1000000007
#define mod2 998244353
#define tr(container, it) \
for(auto it = container.begin(); it != container.end(); it++)
 
bool comps(const pair<int,int> &a, const pair<int,int> &b) {return (a.second<b.second);} 
 
int power(int x, unsigned int y)
{ 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
}
 
int binomialCoeff(int n, int k)
{  
    // Base Cases  
    if (k == 0 || k == n)  
        return 1;  
  
    // Recur  
    return binomialCoeff(n - 1, k - 1) +  
                binomialCoeff(n - 1, k);  
}
 
signed main(){
    
    IOS
    int n,m,sum=0;
    cin>>n>>m;
    int a[n];
    rep(i,0,n) {cin>>a[i];sum+=a[i];}
    sort(a,a+n);
    if(a[n-m]<((float)sum/(4*m))) cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X=sc.nextInt();
		int Y=sc.nextInt();
		sc.close();
		boolean result=false;
		int legs=0;
		for(int i=0;i<=X;i++) {
			legs=(i*2)+((X-i)*4);
			if(legs==Y)
				result=true;
		}
		if(result==true)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 35788
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,a) for(int i=0;i<(int)(a);i++)
#define rrep(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define ci(a) cin>>(a)
#define co(a) cout<<(a)<<endl
typedef vector<int> vi;
typedef long long ll;
const ll D = 1000000000000000000;
int main(){
    ll A, B, C, K;
    cin>>A>>B>>C>>K;
    if(K&1){
        if(abs(B-A)>D)co("Unfair");
        else co(B-A);
    }
    else{
        if(abs(A-B)>D)co("Unfair");
        else co(A-B);
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
v=list(map(int,input().split()))
from collections import Counter
even=[]
odd=[]
for i in range(n):
    if i%2==0:
        even.append(v[i])
    else:
        odd.append(v[i])
E=Counter(even).most_common()
O=Counter(odd).most_common()
E.append([0,0])
O.append([0,0])
if E[0][0]!=O[0][0]:
    print(n-(E[0][1]+O[0][1]))
else:
    print(min(n-(E[1][1]+O[0][1]),n-(E[0][1]+O[1][1])))

Measured memory_bytes: 20956
//  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;
typedef long long int ll;
typedef pair<ll,ll>P;
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,k,x,y;cin>>n>>k>>x>>y;
    ll s=0;
    if(n<=k)
        s=n*x;
    else{
        s=k*x;
        s+=(n-k)*y;
    }
    cout<<s<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> as(N);
  ll res_final = LONG_LONG_MAX;
  for (auto i = 0; i < N; i++) cin >> as[i];
  for (auto k = 0; k < 2; k++) {
    ll sum = as[0];
    ll res = 0;
    if (k == 0 && as[0] <= 0) {
      // change as[0] to positive
      res = abs(as[0]) + 1;
      sum = 1;
    } else if (k == 1 && as[0] >= 0) {
      res = abs(as[0]) + 1;
      sum = -1;
    }
    for (auto i = 1; i < N; i++) {
      ll a = as[i];
      if (sum == 0) {
        sum = a;
        continue;
      }
      if (sum * (sum + a) >= 0) {
        res += abs(sum + a) + 1;
        if (sum > 0) sum = -1;
        else sum = 1;
      } else {
        sum += a;
      }
//      cout << "a=" << a << " sum=" << sum << " res=" << res << endl;
    }
    res_final = min(res_final, res);
  }

  cout << res_final << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <list>

std::string getFizzBuzzString(int n)
{
    std::string fizzBuzzString;
    
    if(n % 15 == 0)
    {
        fizzBuzzString = "FizzBuzz";
    }
    else if(n % 5 == 0)
    {
        fizzBuzzString = "Buzz";
    }
    else if(n % 3 == 0)
    {
        fizzBuzzString = "Fizz";
    }
    else
    {
        fizzBuzzString = std::to_string(n);
    }
    
    return fizzBuzzString;
}

void fizzBuzzGame(int num_of_players, int num_of_remarks)
{
    std::list<int> player_list;

	/* ?????¬???????????????????????¨???????????¬?????????????????????push?????? */
    for(int i = 1; i <= num_of_players; i++ )
    {
        player_list.push_back(i);
    }

	/* fizz buzz ?????????????§? */
    for(int i = 1; i <= num_of_remarks; i++)
    {
        /* ??\??????????????? */
        std::string remarks;
        std::cin >> remarks;

        /* ?????¬??????????????????????????£?????????????£???°??? */
        if(player_list.size() <= 1)
        {
            continue;
        }

        /* ?????¬?????????????????? */
        int player = *(player_list.begin());
        player_list.pop_front();

        /* ?????????????????? */
        std::string expect_remarks = getFizzBuzzString(i);
        
        /* ??£??????????¨??????????????????°????????????push???????????? */
        /* ????????£????????????????????????push??????????????¨??§??¢??±???????????¨????????? */
        if(remarks == expect_remarks)
        {
            player_list.push_back(player);
        }
    }
    
    /* ???????????????????????£??????????????¬????????????????????????????????? */
    player_list.sort();
	auto itr = player_list.begin();
	for(itr = player_list.begin(); itr != player_list.end(); ++itr)
	{
		if(itr != player_list.begin())
		{
			std::cout << " ";
		}
		std::cout << *itr;
	}
    std::cout << std::endl;
	
	return;
}

void volume2_0221()
{
    int num_of_players;
    int num_of_remarks;
    
    for(;;)
    {
        /* ?????¬???????????°??¨????¨??????°??????????????? */
        std::cin >> num_of_players >> num_of_remarks;
        
        /* ?????¬???????????°???????¨??????°??±??? 0 ????????\????????? */
        if( num_of_players == 0 && num_of_remarks == 0 )
        {
            break;
        }
        
    	/* FizzBuzzGame ?????? */
    	fizzBuzzGame(num_of_players, num_of_remarks);
    }

    return;
}

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

Measured memory_bytes: 3140
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vvl children(114514);
ll dp[114514][2];
ll flag[114514];
void f(ll i,ll from){
  if(flag[i])return;
  flag[i]=1;
  dp[i][0]=1;
  dp[i][1]=1;
  for(auto j:children[i]){
    if(from==j)continue;
    f(j,i);
    dp[i][0]=dp[i][0]*(dp[j][0]+dp[j][1])%MOD;
    dp[i][1]=dp[i][1]*dp[j][0]%MOD;
  }
}
  
int main(){
  ll n;cin>>n;
  rep(i,n-1){
    ll a,b;cin>>a>>b;
    a--;b--;
    children[a].push_back(b);
    children[b].push_back(a);
  }
  f(0,-1);
  cout<<(dp[0][0]+dp[0][1])%MOD<<endl;
}

Measured memory_bytes: 15360
mo=10**9+7
s=input()
n=len(s)
dp=[[0]*(1+n) for i in range(3)]
cc=0
for i in range(n):
    c=s[i]
    if c=='A':
        da,db,dc,dd=1,0,0,1
    elif c=='B':
        da,db,dc,dd=0,1,0,1
    elif c=='C':
        da,db,dc,dd=0,0,1,1
    elif c=='?':
        da,db,dc,dd=1,1,1,3
        
    dp[0][i+1]=dp[0][i]*dd+da*pow(3,cc,mo)
    dp[1][i+1]=dp[1][i]*dd+dp[0][i]*db
    dp[2][i+1]=dp[2][i]*dd+dp[1][i]*dc
    dp[0][i+1]%=mo
    dp[1][i+1]%=mo
    dp[2][i+1]%=mo
    if c=='?':
        cc+=1

print(dp[2][n]%mo)

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

using namespace std;
#define int long long
#define MOD 1000000007
#define pb push_back
int N;
int call(int idx, int parent,int color, vector<vector<int> >&GRAPH,vector<vector<int> >&dp)
{
    if(dp[idx][color]!=-1)
    {
        return dp[idx][color];
    }
    dp[idx][color]=1;
    bool flag =true;
    
    for(int i=0;i<GRAPH[idx].size();i++)
    {
        if(GRAPH[idx][i]==parent)
        {
            continue;
        }
        flag=false;
        if(color==1)
        dp[idx][color]*=(call(GRAPH[idx][i],idx,0,GRAPH,dp));
        else
        {
            dp[idx][color]*=((call(GRAPH[idx][i],idx,0,GRAPH,dp)+call(GRAPH[idx][i],idx,1,GRAPH,dp))%MOD);
            
        }
        dp[idx][color]%=MOD;
    }
   // if(flag)dp[idx][color]=1;
   // cout<<idx<<" "<<mask<<" "<<dp[idx][mask]<<endl;
    return dp[idx][color];
    
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // int N;
    cin>>N;
    vector<vector<int> >GRAPH(N+1);
    for(int i=0;i<N-1;i++)
    {
        int x,y;
        cin>>x>>y;
        GRAPH[x].pb(y);
        GRAPH[y].pb(x);
    }
    vector<vector<int> > dp(N+1,vector<int>(2,-1));
    cout<<(call(1,-1,0,GRAPH,dp)+call(1,-1,1,GRAPH,dp))%MOD;
    return 0;
}

Measured memory_bytes: 19584
import math

a,b,c,d = map(int,input().split())
x = ((c * (1/12)  * 360)+(d*(1/60)*30)) % 360
y = d * (1/60) * 360 % 360
Z = math.radians(abs(x-y))
zz = a**2 + b**2 - 2*a*b*math.cos(Z)
print(zz **(0.5))



Measured memory_bytes: 9504
from collections import deque
W, H, N = map(int, input().split())
X = deque()
Y = deque()
A = deque()
for _ in range(N):
    x, y, a = map(int, input().split())
    X.append(x)
    Y.append(y)
    A.append(a)
a1 = 0
a2 = W
a3 = 0
a4 = H
for i in range(N):
    Ai = A.popleft()
    if Ai == 1:
        a1 = max(a1, X[i])
    elif Ai == 2:
        a2 = min(a2, X[i])
    elif Ai == 3:
        a3 = max(a3, Y[i])
    elif Ai == 4:
        a4 = min(a4, Y[i])
if a1 >= a2 or a3 >= a4:
    print(0)
else:
    print((a2 - a1) * (a4 - a3))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define INF 0x3f3f3f3f
using namespace std;
int a,b,c,ans=INF;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>a>>b>>c;
	ans=min(ans,a+b);
	ans=min(ans,a+c);
	ans=min(ans,b+c);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    string s;
    cin >> s;
    int  k;
    cin >> k;
    set<string> st;
    int n = s.size();
    vector<vector<int>> num(26);
    for(int i = 0; i < n; i++) num[s[i]-'a'].push_back(i);
    for(int i = 0; i < 26; i++){
            for(auto p:num[i]){
                for(int k = 1; k <= 5; k++){
                    string t = s.substr(p,k);
                    st.insert(t);
                }
            }
            if(st.size() >= k) break;
    }
    //cout << st.size() << endl;
    int i = 0;
    for(auto p:st){
        if(i == k-1){
            cout << p << endl;
            break;
        }
        i++;
    }
    return 0;
}


Measured memory_bytes: 3720
//#include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iterator>
#include <tuple>
#include <utility>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
using namespace std;

#define V             vector
#define PQ            priority_queue

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

#define mod           (1e9+7)

typedef long long ll;
typedef unsigned long long ull;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n,k,q,ip,a[100003]={0};
    cin>>n>>k>>q;
    ip=k-q;

    int A;
    while (q--) {
        cin>>A;
        ++a[A];
    }

    for (int i=1; i<=n; ++i)
        cout<<(ip+a[i]>0?"Yes":"No")<<endl;
}


Measured memory_bytes: 1024