akhauriyash/Code-Regression huggingface dataset:
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0;
    string y;
    cin >> N;

    vector<vector<string>> S(N,vector<string>(2));
    REP(i,N) cin >> S[i][0] >> S[i][1];
    cin >> y;

    //本文
    ll ans = 0;
    ll place = 0;
    REP(i,N){
      if(S[i][0]==y) place = i;
    }
    if(place==N){cout << 0 << endl; return 0;}
    for(int i = place+1; i < N; i++){
      ans += stoi(S[i][1]);
    }
    
    //出力
    cout << ans << endl;
    //REP(i,N) cout << ans.at(i) <<endl;
  return 0;
}

Measured memory_bytes: 3672
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {
	
	int n;
	cin >> n;
	vector<int>a, b, c;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;

		a.push_back(t);

	}
	for (int i = 0; i < n; i++) {
		int t; cin >> t;

		b.push_back(t);

	}
	for (int i = 0; i < n; i++) {
		int t; cin >> t;

		c.push_back(t);

	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	long long int ans = 0, x = 0, y = 0;
	for (int i = 0; i < n; i++) {
	//	if (a[x] >= b[i])break;
		while (x<n&&a[x] <b[i]) {
			if (x ==n)break;
			x++;
			
		}
		
		while (y<n&&c[y] <= b[i]) {
			if (y == n)break;
			y++;
		}
	ans += ((x)*(n-y));
//		cout << x << " " << y <<" "<<ans<< endl;
		//cout << ans;

	}
	cout << ans << endl;


	return 0;
}

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

p = 0
d = abs(n * a[0] - sum(a))

for i in range(1, n):
  if abs(n * a[i] - sum(a)) < d:
    d = abs(n * a[i] - sum(a))
    p = i

print(p)

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

int main(){
  int n,m,c;
  scanf("%d%d%d",&n,&m,&c);
  
  ll sum = 0;
  vector< vector<pll> > g(n);
  for(int i=0;i<m;i++){
    int a,b,d;
    scanf("%d%d%d",&a,&b,&d);
    a--; b--;
    g[a].push_back(pll(d,b));
    g[b].push_back(pll(d,a));
    sum += d;
  }

  vector<ll> d(n,1e18); d[0] = 0;
  priority_queue< pll, vector<pll>, greater<pll> > q; 
  q.push(pll(0,0));

  while(q.size()){
    pll p = q.top(); q.pop();
    ll c = p.first, v = p.second;
    if(d[v] < c)continue;

    for(pll e : g[v]){
      ll nc = c + e.first, u = e.second;
      if(d[u] > nc){
	d[u] = nc;
	q.push(pll(nc,u));
      }
    }
  }

  vector<pll> ord(n);
  for(int i=0;i<n;i++)ord[i] = pll(d[i],i);
  sort(ord.begin(),ord.end());

  vector<int> used(n,0);
  ll res = 1e18;
  for(int i=0;i<n;i++){
    int v = ord[i].second;
    for(pll e : g[v]){
      if(used[e.second])sum -= e.first;
    }
    res = min(res, sum + ord[i].first*c);
    used[v] = 1;
  }
  printf("%lld\n",res);
}

Measured memory_bytes: 17152
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    char ch; cin>>ch;
    if(ch == 'A') cout<<'T';
    else if (ch == 'G') cout<<'C';
    else if (ch == 'C') cout<<'G';
    else cout<<'A';
    
    return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
#define ll long long
signed main()
{
  ll n;
  cin>>n;
  ll s=0, a;
  unordered_map<ll, ll> mp;
  for(int i=0; i<n; i++)
  {
    cin>>a;
    mp[a]++;
    s+=a;
  }
  ll q;
  cin>>q;
  while(q--)
  {
    ll x, y;
    cin>>x>>y;
    s = s-x*mp[x]+y*mp[x];
    cout<<s<<endl;
    ll p = mp[x];
    mp.erase(x);
    mp[y]+=p;
  }
  return 0;
}

Measured memory_bytes: 6688
import java.util.*;
import java.math.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();

    if (n == m) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }

}


Measured memory_bytes: 23508
n = int(input())
s = []

for i in range(n):
    x = [x for x in input()]
    x.sort()
    s.append(''.join(x))

s.sort()
count = 0
i = 0
while True:
    ren = 0
    if i >= n:
        break
    for j in range(i + 1, n):
        if s[i] == s[j]:
            ren += 1
        else:
            break

    if ren != 0:
        for k in range(ren):
            count += k + 1
        i += ren - 1
    i += 1

print(count)


Measured memory_bytes: 10640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
int main()
{
	int d,n,ans;
	cin>>d>>n;
	if(n==100)
	ans=(n+1)*pow(100,d);
	else ans=n*pow(100,d);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            string S = Console.ReadLine();

            int c1 = 0;
            int c2 = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0 && S[i] == '0') c1++;
                if (i % 2 == 0 && S[i] == '1') c2++;
                if (i % 2 == 1 && S[i] == '1') c1++;
                if (i % 2 == 1 && S[i] == '0') c2++;
            }

            Console.WriteLine(Math.Min(c1, c2));

        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11232
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long D = sc.nextLong();
    int counts = 0;
    for (int i = 0; i < N; i++) {
      long X = sc.nextLong();
      long Y = sc.nextLong();
      long A = X * X + Y * Y;
      if (A <= D * D) {
        counts++;
      }
    }
    System.out.println(counts);
  }
}


Measured memory_bytes: 59708
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	cin >> a >> b >> c;
	int x; cin >> x;
	int cnt = 0;
	rep(i, a + 1)
	{
		rep(j, b + 1)
		{
			rep(k, c + 1)
				if (i * 500 + j * 100 + k * 50 == x)
					cnt++; 
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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 ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class DHandstand2 {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      ll n; cin >> n;
      if (n < 10) {
        cout << n << endl;
        return;
      }

      vector<vector<ll>> dp(10, vector<ll>(10));

      vector<ll> d;
      int tmp = n;
      int base = 1;
      while(tmp > 0) {
        d.push_back(tmp%10);
        tmp /= 10;
        base *= 10;
      }
      reverse(all(d));

      // equal
      vector<vector<ll>> dp1(d.size()+1, vector<ll>(10));
      // smaller
      vector<vector<ll>> dp2(d.size()+1, vector<ll>(10));
      //debug(d[0]);
      for(int i=1; i<=9; i++) {
        if (i == d[0]) {
          dp1[0][i] = 1;
        } else if (i < d[0]) {
          dp2[0][i] = 1;
          //debug(i, dp2[0][i]);
        }
      }

      for(int i=1; i<d.size()-1; i++) {
        for(int j=1; j<=9; j++) {
          dp2[i][j] += dp2[i-1][j] * 10;
          dp2[i][j]++;
        }
        for(int j=1; j<=9; j++) {
          dp1[i][j] += dp1[i-1][j];
          dp2[i][j] += dp1[i-1][j]*d[i];
          //debug(i, j, dp1[i][j], dp2[i][j]);
        }
      }

      for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
          dp[i][j] += dp2[d.size()-2][i];
          if (j <= d.back()) dp[i][j] += dp1[d.size()-2][i];
          //debug(i, j, dp[i][j]);
        }
      }

      for(int i=1; i<=9; i++) {
        dp[i][i]++;
      }

      ll ret = 0;
      for(int i=1; i<=9; i++) {
        for(int j=1; j<=9; j++) {
          ret += dp[i][j] * dp[j][i];
        }
      }
      cout << ret << endl;

    }
};

signed main() {
  DHandstand2 solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
eval'N,K,*A='+`dd`.split*?,
l=[]
N.times{|i|s=0;(i...N).map{|j|l<<s+=A[j]}}
60.times{|k|t=l.select{|e|e>>59-k&1>0};t.size<K||l=t}
p l.inject:&

Measured memory_bytes: 20728
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define fgx cerr<<" ---------------------------------------------- "<<endl
#define uint unsigned int 
#define ULL unsigned long long
#define LDB long double
#define DB double
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
inline LL read(){
	LL nm=0; bool fh=true; char cw=getchar();
	for(;!isdigit(cw);cw=getchar()) fh^=(cw=='-');
	for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
	return fh?nm:-nm;
}

#define mod 1000000007
namespace  CALC{
	inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
	inline int mns(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
	inline int mul(int x,int y){return (LL)x*(LL)y%mod;}
	inline void upd(int &x,int y){x+=y;(x>=mod)?(x-=mod):0;}
	inline void dec(int &x,int y){x-=y;(x<0)?(x+=mod):0;}
	inline int qpow(int x,int sq){int res=1;for(;sq;sq>>=1,x=mul(x,x))if(sq&1)res=mul(res,x);return res;}
}using namespace CALC;

#define M 102000
int n,X[M],ans;
int fac[M],ifac[M],iv[M],pre[M];
int main(){
	n=read(),fac[0]=ifac[0]=1;
	for(int i=1;i<=n;i++) X[i]=read(),fac[i]=mul(fac[i-1],i); ifac[n]=qpow(fac[n],mod-2);
	for(int i=n;i>=1;--i) ifac[i-1]=mul(ifac[i],i),iv[i]=mul(ifac[i],fac[i-1]);
	for(int i=1;i<=n;i++) pre[i]=add(pre[i-1],iv[i]);
	for(int i=1;i<n;i++){
		int bas=mul(fac[n-1],pre[i]);
		upd(ans,mul(bas,X[i+1]-X[i]));
	}
	printf("%d\n",ans);	return 0;

}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define Rep(i,n) for(int i = 1 ; i < n ; i++)
#define MAX 101

int main(){
  double dp[MAX][MAX],nae[MAX][MAX];
  int n,m;
  
  while(cin >> n >> m, n+m){
    fill(dp[0],dp[MAX-1],0);
    rep(i,n) rep(j,n) cin >> nae[i][j]; 
   
    rep(i,n) dp[0][i] = 1.0;
    Rep(i,m) rep(j,n){ dp[i][j] = -1; rep(k,n)
      dp[i][j] = max(dp[i][j],dp[i-1][k]*nae[k][j]);
    }
    double ans = -1;
    rep(j,n)
      ans = max(ans,dp[m-1][j]);

    printf("%.2f\n" , ans);
  }

  return 0;
}

Measured memory_bytes: 1404
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[]){
  int a=0,b=0,ans=0;
  char  t[100],s[100],c[100];
  scanf("%s",s);
  a = strlen(s);
  for (int i = 0; i < a; i++) {
    s[i]='x';
  }
  s[a+1]='\0';
  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,now,ans;
char u;
int main()
{
    cin>>a;
    for(int s=0;s<a;s++)
    {
        cin>>u;
        if(u=='I')now++;
        else
        now--;
        ans=max(ans,now);
    }
    cout<<ans<<endl;//输出
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>

using namespace std;

int main() {
   
   int D, N;
   cin >> D >> N;
  
   int tmp;
   if (N == 100) tmp = 101;
   else tmp = N;
   
   int ans = tmp * pow(100, D);
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

const int N = 105, M = 2020, K = 22;
const long long INF = 0x3f3f3f3f3f3f3f3f;
struct Edge
{
	int v, w;
};
string s[N];
int n, w[N], id[N][K], idx;
long long d[M];
bool st[M];
vector<Edge> g[M];

bool palin(const string& x)
{
	int n = x.size();
	for(int i = 0, j = n - 1; i < j; ++i, --j)
		if(x[i] != x[j]) return false;
	return true;
}

void dijkstra()
{
	typedef pair<long long, int> PII;
	priority_queue<PII, vector<PII>, greater<PII>> h;
	memset(d, 0x3f, sizeof d);
	for(int i = 0; i < n; ++i)
	{
		int u = id[i][s[i].size()];
		d[u] = w[i];
		h.push({d[u], u});
	}
	while(h.size())
	{
		int u = h.top().second;
//		printf("%d\n", u);
		h.pop();
		if(!u) break;
		if(st[u]) continue;
		st[u] = true;
		for(auto& e: g[u])
		{
			int v = e.v, w = e.w;
			if(d[v] > d[u] + w)
			{
				d[v] = d[u] + w;
				h.push({d[v], v});
			}
		}
	}
	return;
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; ++i)
	{
		cin >> s[i] >> w[i];
		s[i + n] = s[i];
		reverse(s[i + n].begin(), s[i + n].end());
		w[i + n] = w[i];
	}
	idx = 1;
	for(int i = 0; i < 2 * n; ++i)
		for(int j = 1; j <= s[i].size(); ++j) id[i][j] = idx++;
	for(int i = 0; i < 2 * n; ++i)
	{
		int l = s[i].size();
		for(int x = 1; x <= l; ++x)
		{
			int u = id[i][x];
			if(palin(s[i].substr(0, x)))
				g[u].push_back({0, 0});
			for(int j = 0; j < 2 * n; ++j) if(i/n != j/n)
			{
				int y = s[j].size(), t = min(x, y);
				if(s[i].substr(x - t, t) != s[j].substr(y - t)) continue;
				if(x < y)
					g[u].push_back({id[j][y - x], w[j]});
				else if(x > y)
					g[u].push_back({id[i][x - y], w[j]});
				else g[u].push_back({0, w[j]});
			}
		}
	}
//	for(int i = 1; i < idx; ++i)
//	{
//		printf("%d:", i);
//		for(int j = 0; j < g[i].size(); ++j)
//			printf("%d ", g[i][j].v);
//		puts("");
//	}

	dijkstra();
	if(d[0] == INF) d[0] = -1;
	cout << d[0] << endl;
	return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
signed main(){
	int n,k;
	cin>>n>>k;
	vector<int> v;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		v.pb(x);
	}
	ll ans = 0;
	for(int i = 1; i <= min(k,n) ; i++ ){
		int throw_away = k - i ;
		for( int j = 0; j <= i; j++){
			ll tmp = 0;
			priority_queue< ll, vector<ll>, greater<ll> > que;
			for(int p = 0; p < j ; p++ ){
				que.push(v[p]);
				//cout<<v[p]<<" ";
			}
			for(int p = 0; p < i-j; p++){
				que.push(v[v.size()-1-p]);
				//cout<<v[v.size()-1-p]<<" ";
			}
			//cout<<endl;
			for(int p = 0; p < throw_away; p++){
				if( !que.empty() && que.top() < 0) que.pop();
			}
			while(!que.empty()){
				tmp += que.top();
				que.pop();
			}
			//cout<<i<<" "<<j<<" "<<tmp<<endl;
			if(ans < tmp){
				ans = tmp;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
    int n; cin >> n;
    int sum = 0;
    vector<int> d(n);
    for(int i = 0;i < n;i++) cin >> d.at(i);

    for(int i = 0;i < n;i++){
        for(int j = i + 1;j < n;j++){
            sum += d.at(i) * d.at(j);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<map>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<list>
#include<string>
#include<climits>
#define ll long long
#define mem(x) memset(x,0,sizeof(x)) 
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pi 3.14159265358979323846
const double eps=1e-6;
using namespace std;
typedef pair<int,int> pii;
const ll mod=1e9+7;
int main()
{
	int a[5];
	for(int i=0;i<3;i++)
	cin>>a[i];
	sort(a,a+3);
	if(a[0]!=a[2]&&(a[1]==a[0]||a[1]==a[2]))
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	bool flg = false;
	if (S[0] == 'k') {
		if (S[1] == 'e') {
			if (S[2] == 'y') {
				if (S[3] == 'e') {
					if (S[4] == 'n') {
						if (S[5] == 'c') {
							if (S[6] == 'e') {
								flg = true;
							}
							else {
								char T = S[S.size() - 1];
								if (T == 'e') flg = true;
							}
						}
						else {
							string U = S.substr(S.size() - 2);
							if (U == "ce") flg = true;
						}
					}
					else {
						string V = S.substr(S.size() - 3);
						if (V == "nce") flg = true;
					}
				}
				else {
					string W = S.substr(S.size() - 4);
					if (W == "ence") flg = true;
				}
			}
			else {
				string X = S.substr(S.size() - 5);
				if (X == "yence") flg = true;
			}
		}
		else {
			string Y = S.substr(S.size() - 6);
			if (Y == "eyence") flg = true;
		}
	}
	else {
		string Z = S.substr(S.size() - 7);
		if (Z == "keyence") flg = true;
	}
	if (flg) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n;
  vector<int> v1(n);

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

  cin >> m;
  vector<int> v2(m);
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    v2[i] = tmp;
  }

  vector<int> r;
  set_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), inserter(r, r.end()));

  for (int i = 0; i < r.size(); i++) {
    cout << r[i] << endl;
  }
}




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

int main()
{
    long long N, C;
    cin >> N >> C;

    long long ans = 0;
    long long positive[N + 1][2] = {};
    long long positive_max[N + 1] = {};
    for (int i = 1; i <= N; i++)
    {
        long long x, v;
        cin >> x >> v;

        positive[i][0] = x;
        positive[i][1] = positive[i - 1][1] + v;

        positive_max[i] = max(positive_max[i - 1], positive[i][1] - positive[i][0]);
        ans = max(ans, positive_max[i]);
    }

    long long negative[N + 1][2] = {};
    long long negative_max[N + 1] = {};
    for (int i = 1; i <= N; i++)
    {
        negative[i][0] = C - positive[N - i + 1][0];
        negative[i][1] = positive[N][1] - positive[N - i][1];

        negative_max[i] = max(negative_max[i - 1], negative[i][1] - negative[i][0]);
        ans = max(ans, negative_max[i]);
    }

    for (int i = 1; i < N; i++)
    {
        long long value = positive[i][1] - 2 * positive[i][0];
        value += negative_max[N - i];
        ans = max(ans, value);
    }

    for (int i = 1; i < N; i++)
    {
        long long value = negative[i][1] - 2 * negative[i][0];
        value += positive_max[N - i];
        ans = max(ans, value);
    }

    cout << ans << endl;
}


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

int main() {
  int N, M; cin >> N;
  vector<string> s(N);
  rep(i, N){cin >> s.at(i);}
  cin >> M;
  vector<string> t(M);
  rep(i, M){cin >> t.at(i);}

  map<string, int> data;

  rep(i, s.size()){
    data[s.at(i)] += 1;
  }
  rep(i, t.size()){
    data[t.at(i)] -= 1;
  }

  int ans = 0;

  for(auto itr = data.begin(); itr != data.end(); ++itr){
    int y = itr->second;
    ans = max(ans, y);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
using namespace std;
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    ll r[a],g[b],cl[c];
    vector<ll> v;
    for(int i=0;i<a;i++) cin>>r[i];
    for(int i=0;i<b;i++) cin>>g[i];
    for(int i=0;i<c;i++){
        cin>>cl[i];
        v.pb(cl[i]);
    }
    sort(r,r+a,greater<int>());
    sort(g,g+b,greater<int>());
    for(int i=0;i<x;i++) v.pb(r[i]);
    for(int i=0;i<y;i++) v.pb(g[i]);
    sort(v.begin(),v.end(),greater<int>());
    ll sum=0;
    for(int i=0;i<(x+y);i++){
        sum+=v[i];
    }
    cout<<sum;
}


Measured memory_bytes: 8816
#include<iostream>
using namespace std;
int w[1500010]={};
int main()
{
	while(1){
		int N,M,N1[2000]={},M1[2000]={};
		int sum1[2000]={}, sum2[2000]={}, ans=0, a,b,c=0;
		for(a=0;a<1500010;a++){
			w[a]=0;
		}
		cin>>N;
		cin>>M;
		if(N==0&&M==0) break;
		for(a=0;a<N;a++){
			cin>>N1[a];
			if(a==0) sum1[a]=N1[a];
			else sum1[a]=N1[a]+sum1[a-1];
		}
		for(a=0;a<M;a++){
			cin>>M1[a];
			if(a==0) sum2[a]=M1[a];
			else sum2[a]=M1[a]+sum2[a-1];
		}
		for(a=0;a<M;a++){
			for(b=0;b<M;b++){
				if(a>b) continue;
				if(a==0) {
					c=sum2[b];
				}
				else c=sum2[b]-sum2[a-1];
				w[c]++;
			}
		}
		for(a=0;a<N;a++){
			for(b=0;b<N;b++){
				if(a>b) continue;
				if(a==0) {
					c=sum1[b];
				}
				else c=sum1[b]-sum1[a-1];
				ans+=w[c];
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7048
#include<iostream>
using namespace std;
int main(){
	long long a,b,n;
	cin>>a>>b>>n;
	long long f=0;
	if(n<b) f= (a*n)/b-a*(n/b);
	if(n==b) f= (a*(n-1))/b-a*((n-1)/b);
	if(n>b) f= (a*(n-1-n%b))/b-a*((n-1-n%b)/b);
		
	cout<<f<<endl;
}

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

using namespace std;

int N, K;
vector<int> v;
vector<vector<int>> s;

int solution(int sum, int x, int y)
{ 
  sum -= x; 
  if (sum < 0)
  { 
    return (y+1) % 2;
  }
  int& res = s[sum][(y+1) % 2];
  if (res != -1)
  { 
    return res;
  }
  for (int i = 0; i < v.size(); ++i)
  { 
    if (solution(sum, v[i], (y+1) % 2) == (y+1) % 2)
    { 
      res = (y+1) % 2;
      return res;
    }
  }
  res = y % 2;
  return res;
}

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

  std::cin >> N >> K;
  v.resize(N);
  s = vector<vector<int>>(K+1, vector<int>(2, -1));

  for (int i = 0; i < N; ++i)
  {
    cin >> v[i];
  }
  
  for (int i = 0; i < v.size(); ++i)
  { 
    if (solution(K, v[i], 0) == 0)
    {
      std::cout << "First";
      return 0;
    }
  } 
  std::cout << "Second";

  return 0;
}


Measured memory_bytes: 10368
a,b= list(map(int,input().split()))
if 0 < a:
    print("Positive")
    exit()
elif 0<=b and a<=0:
    print("Zero")
    exit()
elif b < 0:
    if abs(a-b)%2==0:
        print("Negative")
        exit()
    else:
        print("Positive")
        exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  REP(i, n) mp[i] = -1;
  bool f = false;
  REP(i, m){
    int a , b;
    cin >> a >> b;
    a--;
    if(mp[a] == -1) mp[a] = b;
    if(mp[a] != b) f = true;
  }
  if(f || (n > 1 && mp[0] == 0)){
    cout << -1 << endl;
    return 0;
  }
  int ans = 0;
  REP(i, n){
    if(mp[i] != -1) ans += mp[i] * pow(10, n-i-1);
  }
  string s = to_string(ans);
  if(s.size() != n) ans += pow(10, n-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}

//INSERT ABOVE HERE
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> c(n),v(n);
  for(Int i=0;i<n;i++) cin>>c[i]>>v[i],c[i]--;

  vector<vector<Int> > G(k);
  for(Int i=0;i<n;i++) G[c[i]].emplace_back(v[i]);
  
  vector<Int> ans(n+1,-1);
  struct T{
    Int w,v,c;
    T(Int w,Int v,Int c):w(w),v(v),c(c){}
    bool operator<(const T &a)const{
      //return v/w > a.v/a.w;
      if(v*a.w==a.v*w) return w>a.w;
      return v*a.w > a.v*w;
    }
  };
  
  using P = pair<Int, Int>;
  vector<priority_queue<P> > pq(k);
  priority_queue<P> bs;
  priority_queue<P> ts;
  priority_queue<P, vector<P>, greater<P> > tt;
  vector<T> vt;
  
  for(Int i=0;i<k;i++){
    sort(G[i].rbegin(),G[i].rend());
    vt.emplace_back(2,G[i][0]+G[i][1],i);
    if(G[i].size()>2u){
      ts.emplace(G[i][0]+G[i][1]+G[i][2],i);
    }    
    for(Int j=2;j<(Int)G[i].size();j++){
      vt.emplace_back(1,G[i][j],i);
      pq[i].emplace(G[i][j],(i<<30)|j);
    }
  }
  sort(vt.begin(),vt.end());
  
  Int l=0,s=0,p1=1e17;
  set<P> used;
  set<Int> used2,used3;
  vector<Int> cnt(k,0);
  for(T t:vt){
    //cout<<l<<" "<<s<<":"<<t.w<<" "<<t.v<<" "<<t.c<<endl;
    l+=t.w;
    s+=t.v;
    while(!bs.empty()){
      if(used.count(bs.top())) bs.pop();      
      else break;
    }
    used2.emplace(t.c);
    while(!ts.empty()){
      if(used2.count(ts.top().second)) ts.pop();
      else break;
    }
    while(!tt.empty()){
      if(used3.count(tt.top().second)) tt.pop();
      else break;
    }
    if(t.w==2){
      // remove 1
      chmax(ans[l-1],s-p1);
      
      //remove cur, put 1
      if(!bs.empty()){
        chmax(ans[l-1],s-t.v+bs.top().first);
      }
      if(!tt.empty()){
        Int p2=tt.top().first;

        //remove cur and 2, put 3
        if(!ts.empty()){
          chmax(ans[l-1],s-t.v-p2+ts.top().first);
        }
        //remove 2, put nxt
        if(!pq[t.c].empty()){        
          chmax(ans[l-1],s-p2+pq[t.c].top().first);          
        }
      }
      if(!pq[t.c].empty()) bs.emplace(pq[t.c].top());
      tt.emplace(t.v,t.c);
    }else{
      chmin(p1,t.v);

      used.emplace(pq[t.c].top());pq[t.c].pop();
      if(!pq[t.c].empty()) bs.emplace(pq[t.c].top());
      
      used3.emplace(t.c);
    }
    chmax(ans[l],s);
  }  
  for(Int i=1;i<=n;i++) cout<<ans[i]<<"\n";
  cout<<flush;
  return 0;
}


Measured memory_bytes: 34348
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

vi p;
vi q;

int pv=-1,qv=-1;
int c=0;

void solve(const vector<int>& vec) {
  bool ok_p=true,ok_q=true;
  rep(i,(int)vec.size()) {
    if(vec[i] != p[i]) ok_p = false;
    if(vec[i] != q[i]) ok_q = false;
  }
  if(ok_p) pv = c;
  if(ok_q) qv = c;
  c++;
}

int main() {
    int n;
    cin >> n;
    p.assign(n,0);
    q.assign(n,0);
    rep(i,n){
      cin >> p[i];
    }

    rep(i,n){
      cin >> q[i];
    }

    vi nums(n);
    rep(i,n) nums[i] = i+1;
    do {
        solve(nums);
    } while (next_permutation(nums.begin(), nums.end()));
    cout<<abs(pv-qv)<<endl;
    return 0;
}





















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

using ll = long long;
using ull = unsigned long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
    cin >> t1;
    if(t1 == 0){
        t1 = 1;
    }else{
        t1 = 0;
    }
    cout << t1 << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D,E,F;
  cin >>A>>B>>C>>D>>E>>F;
  vector<double> W,S;
  for(int i=0; i<=F/A; i++){
    for(int j=0; j<=(F-i*A)/B; j++){
      int x=(i*A+j*B)*100;
      if(x>F) break;
      W.push_back(x);
    }
  }
  int z=F*E/(100+E);
  for(int i=0; i<=z/C; i++){
    for(int j=0; j<=(z-i*C)/D; j++){
      int x=i*C+j*D;
      if(x>z) break;
      S.push_back(x);
    }
  }
  sort(W.begin(), W.end());
  sort(S.begin(), S.end());
  for(int i=0; i<W.size()-1; i++){
    if(W[i]==W[i+1]){
      W.erase(W.begin()+i);
      i--;
    }
  }
  for(int i=0; i<S.size()-1; i++){
//    cout<<"i:"<<i<<" S[i]:"<<S[i]<<" S[i+1]:"<<S[i+1]<<endl;
    if(S[i]==S[i+1]){
      S.erase(S.begin()+i);
      i--;
    }
  }
  double per=0;
  int ans1=W[1], ans2=0;
  for(int i=0; i<W.size(); i++){
    int a=W[i]*E/100+1;//許容砂糖量+1
    auto IT=lower_bound(S.begin(), S.end(), a);
    int b=IT-S.begin()-1;
    if(b<0) continue;
    if(W[i]+S[b]==0) continue;
//    cout<<"i:"<<i<<" W[i]:"<<W[i]<<" b:"<<b<<" S[b]:"<<S[b]<<endl;
    if(W[i]+S[b]>F){
      a=F-W[i]+1;
      auto IT=lower_bound(S.begin(), S.end(), a);
      b=IT-S.begin()-1;
    }
    double c=S[b]*100/(W[i]+S[b]);
    if(per<c) per=c, ans1=W[i]+S[b], ans2=S[b];      
  }
  cout <<ans1 <<" " <<ans2 <<endl;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int A,B,C,D;
    cin>>A>>B>>C>>D;
    int lb=A,ub=B;
    chmax(lb,C);
    chmin(ub,D);
    cout<<max(0,ub-lb)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const int mo=1e9+7,N=6e5+5;
int n,m,L,R,fac[N],vf[N],inv[N],i;
inline int C(int x,int y){
	return 1ll*vf[y]*vf[x-y]%mo*fac[x]%mo;
}
inline int calc(int s){
	int i,j,ans=C(s+n,n),ss=0,x;
	for(i=0;i<=s;++i){
		int z=0;
		for(j=0;1ll*(i+1)*(j+n-m)<=s && j<=m;++j){
			x=1ll*C(s-(j+n-m)*(i+1)+n,n)*C(m,j)%mo;
			if(j&1)z=(z+mo-x)%mo;else z=(z+x)%mo;
		}
		for(j=0;1ll*(i+1)*(n-m)+i*j<=s && j<=m;++j){
			x=1ll*C(s-j*i-(n-m)*(i+1)+n,n)*C(m,j)%mo;
			if(j&1)z=(z+x)%mo;else z=(z+mo-x)%mo;
		}
		ss=(ss+z)%mo;
	}
	ans=(ans+mo-1ll*ss*C(n,m)%mo)%mo;
	return ans;
}
int main(){
	for(i=*fac=*vf=1;i<N;++i)
		fac[i]=1ll*fac[i-1]*i%mo,
		inv[i]=i==1?1:1ll*(mo-mo/i)*inv[mo%i]%mo,
		vf[i]=1ll*vf[i-1]*inv[i]%mo;
	scanf("%d%d%d%d",&n,&m,&L,&R);m=n-m;
	printf("%d\n",(calc(R)+mo-calc(L-1))%mo);
	return 0;
}

Measured memory_bytes: 7296
def sol(n, S):
    if S is None or len(S) == 0: return 0
    S.sort() # sort in place
    #print(S)
    diffs = []
    pre = S[0]
    for i in range(1, len(S)):
        diffs.append(S[i] - pre)
        pre = S[i]
    diffs.sort(reverse=True)
    #print(diffs)
    for x in range(n-1):
        if len(diffs) > 0:
            del diffs[0]
    return sum(diffs)



test = False
if test:
    n, m = 2, 5
    S =list( map(int, "10 12 1 2 14".split()))
    print(sol(n, S))

    n, m = 3, 7
    S =list( map(int, "-10 -3 0 9 -100 2 17".split()))
    print(sol(n, S))

    n, m = 100, 1
    S =list( map(int, "-100000".split()))
    print(sol(n, S))


else:
    n, m = map(int, input().split())
    S =list( map(int, input().split()))
    #print(n, S)
    print(sol(n, S))


Measured memory_bytes: 13968
import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in)
							.useDelimiter("[ ,\n]");

	public static void main(String[] args){
		int[][] paper = new int[10][10];
		int count = 0;
		int max = 0;
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				paper[i][j] = 0;
			}
		}
		
		while(scan.hasNext()){
			String xs = scan.next();
			String ys = scan.next();
			String sizes = scan.next();
			int x = Integer.parseInt(xs);
			int y = Integer.parseInt(ys);
			int size = Integer.parseInt(sizes);
			if(size == 1){
				if(x-1 < 0){ 
				} else{
					paper[x-1][y] += 1;
				}
				if(x < 0 || x >= 10){
				} else{
					if(y-1 < 0){
					} else{
						paper[x][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x][y+1] += 1;
					}
				}
				if(x+1 >= 10){
				} else{
					paper[x+1][y] += 1;
				}
			}
			if(size == 2){
				if(x-1 < 0){
				} else{
					if(y-1 < 0){
					} else{
						paper[x-1][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x-1][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x-1][y+1] += 1;
					}
				}
				if(x < 0 || x >= 10){
				} else{
					if(y-1 < 0){
					} else{
						paper[x][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x][y+1] += 1;
					}
				}
				if(x+1 >= 10){
				} else{
					if(y-1 < 0){
					} else{
						paper[x+1][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x+1][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x+1][y+1] += 1;
					}
				}
			}
			if(size == 3){
				if(x-2 < 0){
				} else{
					if(y < 0 || y >= 10){
					} else{
						paper[x-2][y] += 1;
					}
				}
				if(x-1 < 0){
				} else{
					if(y-1 < 0){
					} else{
						paper[x-1][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x-1][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x-1][y+1] += 1;
					}
				}
				if(x < 0 || x >= 10){
				} else{
					if(y-2 < 0){
					} else{
						paper[x][y-2] += 1;
					}
					if(y-1 < 0){
					} else{
						paper[x][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x][y+1] += 1;
					}
					if(y+2 >= 10){
					} else{
						paper[x][y+2] += 1;
					}
				}
				if(x+1 >= 10){
				} else{
					if(y-1 < 0){
					} else{
						paper[x+1][y-1] += 1;
					}
					if(y < 0 || y >= 10){
					} else{
						paper[x+1][y] += 1;
					}
					if(y+1 >= 10){
					} else{
						paper[x+1][y+1] += 1;
					}
				}
				if(x+2 >= 10){
				} else{
					if(y < 0 || y >= 10){
					} else{
						paper[x+2][y] += 1;
					}
				}
			}
		}
		for(int i = 0; i < 10; i++){
			for(int j = 0; j < 10; j++){
				if(paper[i][j] == 0){
					count++;
				}
				if(paper[i][j] > max){
					max = paper[i][j];
				}
			}
		}
		System.out.printf("%d\n", count);
		System.out.printf("%d\n", max);
	}
}

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

int main(){
  int n,q;
  cin>>n>>q;
  queue<int>s[n];
  while(q--){
    int a,b,c;
    cin>>a>>b;
    if(!a){
      cin>>c;
      s[b].push(c);
    }
    else if(a==1){
      if(!s[b].empty())cout<<s[b].front()<<endl;
    }
    else if(!s[b].empty())s[b].pop();
  }
}


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

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

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int r = 0;
    rep(i, n){
        if(s[i] == 'R') r++;
    }
    int ans = 0;
    rep(i, r){
        if(s[i] == 'W') ans++;
    }
    cout << ans << endl; 
    return 0; 
}


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end());
  
  int slen = s.size();
  int tlen = t.size();
  int frag = 0;
  if (slen < tlen) frag = 1;
  
  bool b = false;
  for (int i = 0; i < tlen; i++) {
    if (s.at(0) < t.at(i)) {
      b = true;
      break;
    } 
  }
  
  int count_s = 1,
  	  count_t = 1;
  for (int i = 1; i < slen; i++) {
    if (s.at(0) == s.at(i)) count_s++;
  }
  for (int i = 1; i < tlen; i++) {
    if (t.at(0) == t.at(i)) count_t++;
  }
  if ((count_s == slen) && (count_t == tlen) && frag) b = true;
  
  //cout << slen << endl;
  //cout << tlen << ',' << count << ',' << frag << endl;
  
  if (b) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
L = input()

MOD = 10**9 + 7

d = [0] * len(L)
in_d = [0] * len(L)

for i in range(len(L)):
    if i == 0:
        d[i] = 1
        in_d[i] = 2
        continue

    # (0, 0), (0, 1), (1, 0)
    if L[i] == '1':
        d[i] = (d[i-1]*3 + in_d[i-1]*1) % MOD
        in_d[i] = in_d[i-1]*2 % MOD
    else:
        d[i] = d[i-1]*3 % MOD
        in_d[i] = in_d[i-1]*1 % MOD

d[-1] = (d[-1] + in_d[-1]) % MOD
print(d[-1])


Measured memory_bytes: 11076
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int c=0;
		for(int i=1;i<=n;i++)
		{
			String str=String.valueOf(i);
			if(str.length()%2!=0)
			{
				c++;
			}
		}
		System.out.println(c);
	}
}


Measured memory_bytes: 41204
import scala.io.StdIn.readLine
object Main {
    def main(args: Array[String]): Unit = {
        readLine.split(" ").map(_.toInt) match {
            case Array(a, b, c) =>  if (b <= a) {
                println("No")
            } else if (b >= c) {
                println("No")
            } else {
                println("Yes")
            }
        }
    }
}


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

int main(){
    int n,k;
    cin>>n>>k;
    double dist=0.0;
    double su=0;
    for(int i=1; i<=n; i++){
        int co=i;
        dist=1.0/double(n);
        while(co<k){
            dist*=double(1.0/2.0);
            co*=2;
        }
        su+=double(dist);
    }
    cout << std::fixed;
    cout << std::setprecision(12)<<su<<endl;

} 

Measured memory_bytes: 256
#include<stdio.h>

int house[5][4][11];

int main(void) {

  int n,i,j,k;
  int b,f,r,v;

  scanf("%d",&n);

  for(i = 0; i < n;i++) {
      scanf("%d %d %d %d",&b,&f,&r,&v);
      house[b][f][r] += v;
  }
  for(i = 1; i < 5;i++) {
      for(j = 1; j < 4;j++) {
	  for(k = 1; k < 11;k++) {
	      printf(" %d",house[i][j][k]);
	  }
	  putchar('\n');
      }
      if(i != 4)printf("####################\n");
  }
      return 0;
}

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

int collision_detection(double x1, double y1, double x2, double y2, double r1, double r2){
	double d = ((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
	double sr = ((r1+r2)*(r1+r2));
	double dr = ((r1-r2)*(r1-r2));
	if( d > sr ){
		return 0;
	}else if( d < sr && dr < d){
		return 1;
	}else if(dr > d){
		return (r1>r2)? 2 : -2;
	}else{
		return 1;
	}
}

int main(){
	int n, ans;
	double xa, ya, ra, xb, yb, rb;

	cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		ans = collision_detection( xa, ya, xb, yb, ra, rb);
		cout << ans << endl;
	}
	return 0;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


struct dat {
    int w,s; ll val;
    void read() {
	cin>>w>>s>>val;
    }
    bool operator<(dat o) {
	return w+s<o.w+o.s;
    }
};


int n;
vector<dat> v;

ll dp[1001][10001];



ll solve(int i, int have) {
    assert(have>=0);
    if (i==n) {
	return 0;
    }

    if (~dp[i][have]) return dp[i][have];

    ll &res = dp[i][have] = 0;

    res = solve(i+1, have);

    if (have >= v[i].w) {
	res = max(res, v[i].val + solve(i+1, min(have-v[i].w, v[i].s)));
    }

    return res;
}

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

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

    cin>>n;
    v.resize(n);
    for (int i=0; i<n; i++) {
	v[i].read();
    }

    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());


    // for (auto p: v) {
    // 	cout<<p.w<<" "<<p.s<<" "<<p.val<<endl;
    // }
    // cout<<endl;



    ll res = 0;
    for (int i=0; i<n; i++) {
	dp[i][v[i].s] = v[i].val+solve(i+1, v[i].s);
	res = max(res, dp[i][v[i].s]);
    }


    cout<<res<<endl;
    
    
    return 0;
}


Measured memory_bytes: 78592
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var [n,m]=arr.shift().split(" ").map(Number);
   if(n==0 && m==0)break;
   var x=m/n;
   var sum=0;
   var a=arr.shift().split(" ").map(Number);
   a.forEach(v=>{
      if(v>=x)sum+=x;
      else sum+=v;
   });
   console.log(sum);
}


Measured memory_bytes: 16596
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=10+10;
const int a[11]={0,1,2,4,7,12,20,29,38,53,73};

int n,p[N]; ll M,G[N][N];

void update(int n) {
	for (int i=1;i<=n;++i) p[i]=i;
	do {
		ll l=0;
		for (int i=2;i<=n;++i) l+=G[p[i-1]][p[i]];
		M=max(M,l);
	} while (next_permutation(p+1,p+n+1));
}

int main() {
	n=read();
	for (int i=2;i<=n;++i) {
		for (int j=1;j<i;++j) G[i][j]=G[j][i]=(M+1)*a[j];
		update(n);
	}
	for (int i=1;i<=n;++i)
		for (int j=1;j<=n;++j)
			printf("%lld%c",G[i][j]," \n"[j==n]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll NumOfSequenceSum(vector<ll>& sequence, ll K){
    ll N = sequence.size();
    vector<ll> sum(N);
    map<ll,ll> ct;
    ll ans = 0;
    
    sum[0] = sequence[0];
    ct[sum[0]]++;
    if(sum[0] == K) ans++;
    
    for(int i = 1; i < N; i++){
        sum[i] = sum[i-1] + sequence[i];
        if(sum[i] == K) ans++;
        ans += ct[sum[i] - K];
        ct[sum[i]]++;
    }
    
    return ans;
}

int main(){
    ll N; cin >> N;
    vector<ll> A(N); rep(i,N) cin >> A[i];
    pr(NumOfSequenceSum(A,0));
    return 0;
}


Measured memory_bytes: 15872
n,k = map(int, input().split())


ans = 0.0
for i in range(1, n + 1):
  #print(i)
  point = i
  tmp = 0.5
  while (point <  k):
    tmp = tmp * 0.5
    point = point * 2
  tmp = tmp / 0.5
  #print(str(ans) + '=' + str(float(i)) + ' / ' + str(float(n)) + ' * ' + str(float(tmp)) )
  ans += 1.0 / float(n) * tmp
print(ans)

Measured memory_bytes: 39792