akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
 
#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 1001001001;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define rep(i,n) for (int i = 0; i < (n); ++i)
 
void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}
 
 
void execute()
{
  int a[12][12];
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }
 
  int ans = iINF;
  rep(s,1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == iINF) cout << -1 << endl;
  else cout << ans << endl;
}


Measured memory_bytes: 3636
class BinarySearchTree:
    def __init__(self):
        self.root = None
    def in_order_traversal(self):
        def _in_order_line(node):
            if node:
                _in_order_line(node.left)
                print(' {0}'.format(node.key), end = '')
                _in_order_line(node.right)
        _in_order_line(self.root)
        print('')
    def pre_order_traversal(self):
        def _pre_order_line(node):
            if node:
                print(' {0}'.format(node.key), end = '')
                _pre_order_line(node.left)
                _pre_order_line(node.right)
        _pre_order_line(self.root)
        print('')


class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
        

def insert(T, z):
    y = None
    x = T.root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.left
        else:
            x = x.right
    z.parent = y
    if y == None:
        T.root = z
    elif z.key < y.key:
        y.left = z
    else:
        y.right = z



import sys

t = BinarySearchTree()

m = sys.stdin.readline()

for i in sys.stdin.readlines():
    if i[0] == 'i':
        k = int(i[7:])
        n = Node(k)
        insert(t, n)
    else:
        t.in_order_traversal()
        t.pre_order_traversal()

Measured memory_bytes: 189464
/*

  _____      _____     _____    __    __    _______    _____    _____    ______      _______      __
 |  _  \    |  _  \   |_   _|   \ \  / /   |   ____|  |_   _|  |  ___|  (   ___|    |__   __|    /  \
 | |_)  )   | |_)  )    | |      \ \/ /    |  |____     | |    | |__     \  (__        | |      / /\ \
 | ____/    | ____/     | |      / /\ \    |   ____|    | |    |  __|     \__   \      | |     / /__\ \
 | |        | |\ \     _| |_    / /  \ \   |  |        _| |_   | |___     ____)  )     | |    / /----\ \
 |_|        |_| \_\   |_____|  /_/    \_\  |__|       |_____|  |_____|   |______/      |_|   /_/      \_\
*/

#include<bits/stdc++.h>
using namespace std;
#define ll  long long int
#define M 300005
#define mod 1000000007
#define oo (ll)1e18
#define pii pair<ll,ll>
#define fi first
#define se second
#define debug(x) cout<<" :"<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :"<<x<<"\t"<<#y<<": "<<y<<"\n";
#define f(i,x,y) for(ll i=x;i<y;i++)
#define boost ios::sync_with_stdio(0);cin.tie(0);
#define in_arr0(a,n) f(i,0,n){cin>>a[i];}
#define in_arr1(a,n) f(i,1,n+1){cin>>a[i];}
#define pb(i) push_back(i)
#define mp  (x,y) make_pair(x,y)
ll n,w;
int main(){
  boost;
  cin>>n>>w;
  ll weights[102];
  ll val[102];
  f(i,1,n+1){
    cin>>weights[i]>>val[i];
  }
  ll dp[102][100005];
  f(i,1,102){
    f(j,1,100005){
      dp[i][j] = oo;
    }
  }
  dp[1][0] = 0;
  dp[1][val[1]] = weights[1];
  ll ans = 0;
  if(weights[1]<=w){
  	ans = val[1];
  }
  f(i,2,n+1){
    f(j,0,100005){
      dp[i][j] = min(dp[i][j],dp[i-1][j]);

      if(j>=val[i]){
      dp[i][j] = min(dp[i][j],dp[i-1][j-val[i]]+weights[i]);
      
      	      }
      if(dp[i][j]<=w){
        ans = max(j,ans);
      }
    }
  }
  //f(i,1,n+1){
  //	f(j,0,100)
  //	if(dp[i][j]!=oo){
  //		cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
  //	}
  //}
  cout<<ans;
  return 0;
}


Measured memory_bytes: 79872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back

int n;
vector<int> e[5010];
const ll mod=int(1e9)+7;

int szh[5010][5010];
int sz(int x, int p){
	if(szh[x][p]) return szh[x][p];
	int ret=1;
	for(int y:e[x]) if(p != y) ret += sz(y, x);
	return szh[x][p]=ret;
}

int a[5010], an;

ll fact[5010];
ll finv[5010];
ll comb(ll a, ll b){
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
ll perm(ll a, ll b){
	return fact[a]*finv[a-b]%mod;
}

ll dp[5010];

ll Work(){
	dp[0] = 1;
	fill(dp+1, dp+accumulate(a+1, a+an+1, 0)+1, 0);
	int ps = 0;
	for(int i=1; i<=an; ++i){
		int ai=a[i];
		for(int j=ps; 0<=j; --j){
			for(int use=1; use<=ai; ++use){
				(dp[j+use] += dp[j] * comb(ai, use) % mod * perm(ai, use) % mod) %= mod;
			}
		}
		ps += ai;
	}
	ll ret = fact[ps];
	for(int i=1; i<=ps; ++i){
		if(i&1)
			(ret += (mod - dp[i] * fact[ps-i] % mod)) %= mod;
		else
			(ret += dp[i]*fact[ps-i]) %= mod;
	}
	return ret;
}

int main(){
	scanf("%d", &n);
	
	fact[0]=1; finv[n]=1;
	for(int i=1; i<=n; ++i) fact[i]=i*fact[i-1]%mod;
	for(ll b=fact[n], e=mod-2; e; (b*=b)%=mod, e/=2) if(e&1) (finv[n]*=b)%=mod;
	for(int i=n; 1<=i; --i) finv[i-1]=finv[i]*i%mod;

	for(int a,b,i=1; i<n; ++i){
		scanf("%d%d", &a, &b); e[a].pb(b); e[b].pb(a);
	}
	int p=1;
	while(true){
		bool flg=0;
		for(int q:e[p]){
			int A=sz(p, q), B=sz(q, p);
			if(A < B){
				p = q;
				flg=1;
				break;
			} else if(A == B){
				ll ans = 1;
				for(int i=1; i<=n/2; ++i){
					(ans *= i) %= mod;
				}
				(ans *= ans) %= mod;
				printf("%lld\n", ans);
				return 0;
			}
		}
		if(!flg) break;
	}
	//printf("Centroid %d\n", p);
	for(int x:e[p]) a[++an] = sz(x, p);
	ll ans = Work();
	a[++an] = 1;
	(ans += Work()) %= mod;
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 97536
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;
int N, n, M, K;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

vector<bool> color;
vector<bool> seen;
void dfs(const Graph &G, int v) {
    seen[v] = true; 
    for (auto next_v : G[v]) { 
        if (seen[next_v.to]) continue; 
        if (next_v.weight % 2 == 1 ) {color[next_v.to] = !color[v];}
      	else {color[next_v.to] = color[v]; } 
        dfs(G, next_v.to); 
    }
}

int main(){
    cin >> N;
    Graph G(N);
    for (int i = 0; i < N-1; ++i) {
        int from, to, weight;
        cin >> from >> to >> weight;
        G[from-1].push_back(Edge(to-1, weight));
     	G[to-1].push_back(Edge(from-1, weight));
    }
    color.assign(N, false);
    seen.assign(N, false);
  	color[0] = true;
    dfs(G, 0);
    REP(i,N){
        cout << color[i]<<"\n";
    }
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
 int a, b, c;
 cin>>a>>b>>c;
 if(a%3 == 0 || b%3 == 0 || (a+b)%3==0)
 {
   puts("Possible");
 }
 else puts("Impossible");
}


Measured memory_bytes: 14080
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static double Solve(double n, double m, double d)
        {
            return (d == 0) ? (m - 1.0) / n
                            : (m - 1.0) * (n - d) * 2.0 / (n * n);
        }
        static void Main(string[] args)
        {
            int[] V = ReadInts();
            Console.WriteLine(Solve(V[0], V[1], V[2]));
        }
    }
}


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

int main(){
    int N, X = 0;
    cin >> N;
    int V[50], C[50];
    for(int i = 0;i < N; i++){
        cin >> V[i];
    }
    for (int i = 0; i < N; i++){
        cin >> C[i];
    }
    int count;
    for(int i = 0; i < N; i++){
        count = V[i] - C[i];
        if(count > 0){
            X += count;
        }
    }
    cout << X << endl;
}

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

int main(void)
{
	unsigned long long w;
	unsigned long long h;
	unsigned long long x;
	unsigned long long y;

	cin >> w >> h;
	cin >> x >> y;
	double area = w * h / 2.0;
	cout << fixed << setprecision(9) << area << " ";
	if ((double)(w / 2.0) == (double)x && (double)(h / 2.0) == (double)y)
	{
		cout << 1 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  string S;
  cin >> S;

  ll cnt[26];
  REP(i, 0, 26) cnt[i] = 0;
  REP(i, 0, S.size()) cnt[S[i] - 'a']++;

  ll ans = S.size() * (S.size() - 1) / 2 + 1;
  REP(i, 0, 26) ans -= cnt[i] * (cnt[i] - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define X first
#define Y second
#define mp make_pair
using namespace std;
typedef pair<int,int> PII;
const int N = 300010;
int n,m,c[N];
PII p[N];

bool cmp(PII a,PII b){
	return a.Y-a.X<b.Y-b.X;
}
inline int sum(int x){
	int ret = 0;
	while(x){
		ret+=c[x];
		x-=x&-x;
	}
	return ret;
}
inline void add(int x,int t){
	while(x<=m+1){
		c[x]+=t;
		x+=x&-x;
	}
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%d%d",&p[i].X,&p[i].Y);
	}
	sort(p,p+n,cmp);
	int j = 0;
	//cout<<"----";	for(int i=0;i<n;i++) cout<<p[i].X<<' '<<p[i].Y<<endl;
	for(int i=1;i<=m;i++){
		while(j<n && p[j].Y-p[j].X+1<i){
			add(p[j].X,1);
			add(p[j].Y+1,-1);
			j++;
		}
		int ans = n-j;
		for(int k = i;k<=m;k+=i) ans += sum(k);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
const int lim = 1e6;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    vector <vector<int>> v(lim+1);
    //vector<int> p;
    for(int i = 2; i <= lim; i++) if(v[i].size() == 0) for(int j = i; j <= lim; j+=i) v[j].pb(i);
    //for(int i = 2; i <= lim; i++) if(v[i]) p.pb(i);
    vector <ll> cnt(lim+1, 1);
    for(int i = 2; i <= lim; i++){
        ll c = 1;
        for(auto x: v[i]){
            ll pp = 1, cc = 1, s = i;
            while(s%x == 0){
                s/=x;
                cc++;
                //if(i == 2) cout << pp << " " << i << "\n";
            }
            c*=cc;
        }
        cnt[i] = c;
    }
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i < n; i++) ans+=cnt[i];
    cout << ans << "\n";
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    double p = 1, s;
    REP(i, N)
    {
        p *= A[i];
    }
    REP(i, N)
    {
        s += p / A[i];
    }
    cout << p / s << endl;
} 
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

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

visited = [-1 for i in range(n)]
visited_history = []
machi = 0
before = -1
loop = -1
flag = False
for idx in range(k):
    machi = a[machi] - 1
    if visited[machi] == -1:
        visited[machi] = idx
        visited_history.append(machi)
    else:
        before = visited[machi]
        loop = idx - before
        flag = True
        break

if flag:
    k -= before
    idx = k % loop - 1
    if idx == -1:
        idx = loop - 1
    machi = visited_history[idx + before]

ans = machi + 1
print(ans)


Measured memory_bytes: 32168
#include <bits/stdc++.h>
#define FOR(i,b,e) for (common_type_t<decltype(b),decltype(e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define rep(i,n)   FOR (i, size_t{}, n)
#define ALL(x)     begin (x), end (x)
using namespace std;
using ll = int64_t;
constexpr ll inf = 2e18;
constexpr ll MOD = ll (1e9+7);

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t H, W, K;
  cin >> H >> W >> K;
  -- K; // 1-indexed to 0-indexed

  vector <vector <ll>> dp (H + 1, vector <ll> (W, 0)); // dp[i][k]: 0からスタートして上からi[cm]移動してきた時、kにいる場合の数
  dp [0][0] = 1;

  // 連続した縦線が余っている（0からスタートしたルートの移動に関わっていないという意味）とき、それぞれの間に横線がひかれている可能性がある。
  // possibility[i]: 連続したi本の線が余っているとき、そこに横線があるかないかのパターン（通り）
  vector <ll> possibility (W + 1, 0);
  // 1本以下なら線が引けないので1通り
  possibility [0] = possibility [1] = 1;
  FOR (i, 2, W + 1)
  {
    // 2本以上余っている時は、
    // まず2本を選択する。連続した2本しか選べないので(j,j+1)を選んだとすると、
    rep (j, i - 1)
    {
      // 飛ばしたものは考慮しない！！
      //possibility [i] += possibility [j];
      // (j+1)より右側にのこっている(i-1-(j+1))本で、あああああああああああああああああああああああああああああああああああああああああああああああああああああああああああ！！！！！！！！！！！！！！！！！！
      possibility [i] += possibility [i - 1 - (j + 1)];
    }
    // 全く選択しないパターン（線を引かない）1通り
    possibility [i] += 1;

    possibility [i] %= MOD;

#ifdef LOCAL
    cerr << "p[" << i << "]: " << possibility [i] << endl;
#endif
  }

  rep (i, H)
  {
      rep (k, W)
      {
        // kより左に移動に関わっている線がないとき、kより左にある連続した縦線はk本。
        // kより右に移動に関わっている線がないとき、kより右にある連続した縦線は(W - 1 - k)本。
        dp [i + 1][k] += (((dp [i][k] * possibility [k]) % MOD) * possibility [W - 1 - k]) % MOD;
        dp [i + 1][k] %= MOD;

        if (k + 1 < W)
        {
          dp [i + 1][k + 1] += (((dp [i][k] * possibility [k]) % MOD) * possibility [W - 1 - (k + 1)]) % MOD;
          dp [i + 1][k + 1] %= MOD;
        }

        if (k >= 1)
        {
          dp [i + 1][k - 1] += (((dp [i][k] * possibility [k - 1]) % MOD) * possibility [W - 1 - k]) % MOD;
          dp [i + 1][k - 1] %= MOD;
        }
    }
  }
#ifdef LOCAL
  rep (i, H + 1)
  {
    rep (k, W)
    {
      cerr << dp [i][k] << ' ';
    }
    cerr << endl;
  }
#endif
  cout << dp [H][K] << endl;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
vector<int> A, B;

int main() {
  cin >> N;
  rep(i, 0, N) {
    int a, b;
    cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  if (N % 2 == 1) {
    int mid = (N + 1) / 2 - 1;
    int low = A[mid];
    int high = B[mid];
    cout << high - low + 1 << endl;
    return 0;
  } else {
    int mid = N / 2 - 1;
    double low = double((A[mid] + A[mid + 1])) / 2.0;
    double high = double(B[mid] + B[mid + 1]) / 2.0;
    int ans = round((high - low) / 0.5) + 1;
    cout << ans << endl;
  }
}


Measured memory_bytes: 5024
function main(input) {
    const parsedInput = parser(input);
    if(isAchievement(parsedInput.a, parsedInput.b, parsedInput.k)) {
        console.log('OK');
        return;
    }
    console.log('NG');
}
function parser(inputStr) {
    const splitInput = inputStr.split('\n');
    const splitInputAandB = splitInput[1].split(' ');
    return {
        k: Number(splitInput[0]),
        a: Number(splitInputAandB[0]),
        b: Number(splitInputAandB[1]),
    };
}
function isAchievement(a, b, k) {
    if (a % k === 0) {
        return true;
    }
    if (((b - a) + a % k) / k >= 1) {
        return true;
    }

    return false;
}

// test
// const Q1 = `7
// 500 600`
// const Q2 = `4
// 5 7`
// const Q3 = `1
// 11 11`
// 
// main(Q1);
// main(Q2);
// main(Q3);
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 29624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const float pi = 3.1415926535;
unsigned GetDigit(unsigned num){
    return to_string(num).length();
}

int main() {
  int a,b;
  cin >> a >> b;
  
  if (a<=0 && b>=0) cout << "Zero" << endl;
  else if (b<0) {
    if ((b-a)%2==1) cout << "Positive" << endl;
    else cout << "Negative" << endl;
  }
  else if (a>0) cout << "Positive" << endl;
}

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

typedef long long ll;

int N;
string S;

ll evaluate(int s){
	ll result = 0;
	for(int j = 0; j<N; j++){
		ll tmp = 0;
		while(s>>j & 1){
			tmp += S[j++] - '0';
			tmp *= 10;
		}
		tmp += S[j] - '0';
		result += tmp;
	}
	return result;
}

int main(){
	cin >> S;
	N= S.size();
	ll sum = 0;
	for(int i = 0; (i < 1 << (N-1)); i++){
		sum += evaluate(i);
	}
	cout << sum << endl;

	return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define inf (1<<29)
#define MAX 100
using namespace std;
typedef long long ll;

/*
経路復元用
dp[day][hotel][number] := minimum
 */
int dp[MAX][MAX][MAX];
int path[MAX][MAX][MAX];
int N,D,p[MAX][MAX];

int main()
{
  scanf("%d %d",&N,&D);
  rep(i,N)
    {
      rep(j,D)scanf("%d",&p[i][j]);
      reverse(p[i],p[i]+D);
    }
  
  rep(i,D+1)rep(j,N)rep(k,55)
    {
      dp[i][j][k] = inf;
      path[i][j][k] = inf;
    }

  rep(i,N)dp[0][i][0] = 0;

  rep(day,D)
    {
      rep(hotel,N)
	{
	  rep(number,55)
	    {
	      if(dp[day][hotel][number] == inf)continue;
	      rep(next_hotel,N)
		{
		  int add = (hotel != next_hotel);
		  if(dp[day+1][next_hotel][number+add] > dp[day][hotel][number]+p[next_hotel][day])
		    {
		      dp[day+1][next_hotel][number+add] = dp[day][hotel][number]+p[next_hotel][day];
		      path[day+1][next_hotel][number+add] = hotel;
		    }
		  else if(dp[day+1][next_hotel][number+add] == dp[day][hotel][number]+p[next_hotel][day])
		    {
		      if(path[day+1][next_hotel][number+add] > hotel)path[day+1][next_hotel][number+add] = hotel;
		    }
		}
	    }
	}
    }

  int mincost,minnumber,minN;
  mincost = minnumber = minN = inf;

  rep(i,N)rep(j,55)
    {
      if(mincost >= dp[D][i][j])
	{
	  if(mincost == dp[D][i][j])
	    {
	      if(minnumber >= j)
		{
		  if(minnumber == j)
		    {
		      if(minN > i)
			minN = i;
		    }
		  else
		    {
		      minnumber = j;
		      minN = i;
		    }
		}
	    }
	  else
	    {
	      mincost = dp[D][i][j];
	      minnumber = j;
	      minN = i;
	    }
	}
    }

  cout << mincost << " " << minnumber << endl;
  vector<int> ph;
  int d,h,n;

  d = D,h = minN, n = minnumber;

  int diff = p[h][D-1];
  for(;d >= 0 && n >= 0;)
    {
      ph.push_back(h);

      int next_h = path[d][h][n];
      int next_n = n - (next_h != h);
      h = next_h;
      n = next_n;
      d--;
      diff += p[h][d-1];
      if(path[d][h][n] == inf)break;
    }
  rep(i,ph.size())
    {
      cout << ph[i]+1 << endl;
      assert(ph[i]!=inf);
    }
  return 0;
}

Measured memory_bytes: 6552
#include<bits/stdc++.h>
using namespace std;
struct siswa{
	int idx;
	int num;
};
bool cmp(siswa a,siswa b){
	return a.num<b.num;
}
int main(){
	int n;cin>>n;vector<siswa>v;
	for(int x=0;x<n;x++){
		int a;cin>>a;siswa tmp;tmp.idx=x+1;tmp.num=a;v.push_back(tmp);
	}
	sort(v.begin(),v.end(),cmp);
	cout<<v[0].idx;
	for (int x=1;x<n;x++){
		cout<<" "<<v[x].idx;
	}
	cout<<endl;
}

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

using namespace std;

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < v.size();i++)

#define INF 1000000000
#define pb(a) push_back(a)
#define llong long long

int main(){
	int x,a,b;
	cin>>x>>a>>b;
	if(abs(x-a)>abs(x-b)){
		cout<<"B"<<endl;
	}else{
		cout<<"A"<<endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

#define siz 100001
#define mod 1000000001

int main(){
	// C from 173
	ll n,m,k;
	cin >> n >> m >> k;
	
	char v[7][7];
	
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < m; j++){
			cin >> v[i][j];
		}
	}
	
	// So what are we going to do is, we will start from  0 row and 0 columns, 1 columns, 2 colums ....
	// here considering all cases, so if at a particular column we get that we are not considering that
	// that means, we are not setting that column, so we will check if that cell has black or not
	// if black that means we will not color that cell given our condititons
	// so we will incrementt the black cells and eventually find if they are equal to k or not
	
	ll ans = 0;
	for(ll i = 0; i < (1<<n); i++){
		for(ll j = 0; j < (1<<m); j++){
			ll black = 0;
			// black is inside because, considering 0 row and 0 columns then 1 colums then 2... 1,2 ... 2,3 ... 1,3 ... 1,2,3 ..
			// check for set bits 
			for(ll x = 0; x < n; x++){
				for(ll y = 0; y < m; y++){
					if((i>>x & 1) == 0 && (j>>y & 1) == 0 && v[x][y] == '#'){
						black++;
					}
				}
			}
			
			if(black == k){
				ans++;
			}
		}
	}
	
//	    for(int maskR = 0; maskR < (1<<n); maskR++){  //checking all formation of row
//	        for(int maskC = 0; maskC < (1<<m); maskC++){  //checking all formation for column
//	            ll black = 0;
//	            for(int i=0; i<n; i++){
//	                for(int j=0; j<m; j++){
//	                    if((maskR>>i & 1)==0 && (maskC>>j & 1)==0 && v[i][j] == '#')black++;    //if current cell is not in formation & its black
//	                }
//	            }
//	            if(black == k)ans++;
//	        }
//	    }
	cout << ans << "\n";
}

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


long long n, m, ans;
vector<long long> a;

//判定
bool chk(long long x) {
    long long cnt = 0;
    for(int i=0; i<n; i++) {
        long long pos = lower_bound(a.begin(), a.end(), x - a[i]) - a.begin();
        cnt += (n - pos);
    }
    return cnt < m;//X以上の和がM個未満かどうか
}

int main() {
    cin >> n >> m;
    a.resize(n);
    for(int i=0; i<n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    //二分探索
    long long ng = 0, ok = LLONG_MAX;
    while (abs(ok - ng) > 1) {
        long long mid = (ok + ng) / 2;
        if (chk(mid)) ok = mid;
        else ng = mid;
    }
    //終了時にngにX-1,okにXが入っている。


    vector<long long> wa(n + 1); //Aの累積和
    for(int i=0; i<n; i++) wa[i + 1] = wa[i] + a[i];
    for(int i=0; i<n; i++) {
        long long pos = upper_bound(a.begin(), a.end() , ng - a[i]) - a.begin();
        long long cnt = n - pos;
        ans += cnt * a[i] + (wa[n] - wa[pos]);
        m -= cnt;
    }
    ans += m * ng;
    cout << ans << endl;
}

Measured memory_bytes: 1920
package main

import "fmt"

func main() {
	var a, b, t int
	fmt.Scan(&a, &b, &t)
	cnt := 0
	bis := 0
	for {
		cnt += a
		if cnt > t{
			break
		}
		bis += 1 
	}
	fmt.Println(b * bis)
}

Measured memory_bytes: 512
import sys
from io import StringIO
import unittest
import math


def resolve():
    s = input()

    if s == '<' or s == '>':
        print(1)
        return

    upDownList = []
    count = 1
    before = s[0]
    c = None
    for i in range(1, len(s)):
        c = s[i]

        if c != before:
            if c == '>':
                upDownList.append(count)
            elif c == '<':
                upDownList.append(-1 * count)
            else:
                raise Exception()
            count = 0

        count += 1
        before = c

    if c == '<':
        upDownList.append(count)
    elif c == '>':
        upDownList.append(-count)
    else:
        raise Exception()
    # print(upDownList)

    beforeIsUp = False
    before = 0
    count = 0
    for i in range(len(upDownList)):
        upDown = upDownList[i]

        for i in range(abs(upDown)+1):
            count += i

        if beforeIsUp:
            if before > abs(upDown):
                count -= abs(upDown)
            else:
                count -= before

        if upDown > 0:
            beforeIsUp = True
            before = upDown
        else:
            beforeIsUp = False
        # print(count)

    print(count)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """<>>"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """<>>><<><<<<<>>><"""
        output = """28"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 71836
x,y=map(int,input().split())
grd=[[0 for i in range(y)] for i in range(x)]
for i in range(x):
    s=input()
    for j in range(len(s)):
        if(s[j]=='.'):
            grd[i][j]=0
        else:
            grd[i][j]=-1

            
dp=[[0 for i in range(y)] for i in range(x)]
vi=[[0 for i in range(y)] for i in range(x)]
dp[0][0]=1
def grid(i,j):
    if(i==0 and j==0):
        return 1;
    if(i>=x or j>=y):
        return 0;
    if(grd[i][j]==-1):    
        return 0;
    if(vi[i][j]):
        return dp[i][j]
    vi[i][j]=1
    dp[i][j]=((dp[i-1][j])%(10**9+7)+dp[i][j-1]%(10**9+7))%(10**9+7)
    return dp[i][j];
for i in range(x):
    for j in range(y):
        dp[i][j]=grid(i,j)
print(dp[-1][-1])        
    
            


Measured memory_bytes: 71004
from bisect import bisect_right
from sys import stdin, stdout

int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for _ in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
bool_out = lambda o: out("YES" if o else "NO")
tests = lambda: range(1, int_in() + 1)
case_out = lambda i, o: out("Case #{}: {}".format(i, o))


def solve(n, m, k, a, b):
    prefix_sum_a = [0]
    for i in range(len(a)):
        prefix_sum_a.append(a[i] + prefix_sum_a[-1])
    prefix_sum_b = [b[0]]
    for i in range(1, len(b)):
        prefix_sum_b.append(b[i] + prefix_sum_b[-1])

    pa = bisect_right(prefix_sum_a, k) - 1
    result = 0
    while pa >= 0:
        left = k - prefix_sum_a[pa]
        pb = bisect_right(prefix_sum_b, left)
        result = max(result, pa + pb)
        pa -= 1
    return result


if __name__ == "__main__":
    n, m, k = arr_in()
    a = arr_in()
    b = arr_in()
    out(solve(n, m, k, a, b))

Measured memory_bytes: 133348
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,a,b,x,y;
    cin>>n>>a>>b;
    x=n/(a+b)*a;
    if(n-(n/(a+b)*(a+b))>=a){
        y=a;
    }
    else{
        y=n-(n/(a+b)*(a+b));
    }
    cout<< x+y <<endl;
}


Measured memory_bytes: 256
import math
from itertools import permutations
N = int(input())
xy = [tuple(map(int, input().split())) for i in range(N)]

ans = 0
for x in permutations(range(N)):
    for i in range(N-1):
        ans += ((xy[x[i+1]][0] - xy[x[i]][0])**2 +
                (xy[x[i+1]][1] - xy[x[i]][1])**2) ** (1/2)

print(ans / math.factorial(N))


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

int main ( )  {

	static char buf [234567] ;
	scanf ( "%s", buf ) ;

	int len = strlen ( buf ) ;
	long long ans = ( 1LL * len * ( len + 1 ) >> 1 ) + len ;
	
	ans -= ( len - 1 ) ; // i == j ;

	static int cnt [30] ;
	memset ( cnt, 0, sizeof cnt ) ;

	for ( char* pt = buf ; *pt ; ++ pt )  ++ cnt [*pt - 'a'] ;

	for ( int i = 0 ; i < 26 ; ++ i )  {
		ans -= 1LL * cnt [i] * ( cnt [i] + 1 ) >> 1 ;
	}
	
	return ! printf ( "%lld\n", ans ) ;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
  int n;
  std::cin>>n;
  for(int i=1;i<10;i++){
    for(int j=1;j<=i;j++){
      if(i*j==n){
        std::cout<<"Yes"<<"\n";
        return 0;
      }
    }
  }
  std::cout<<"No"<<"\n";
  return 0;
}

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

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

    vector<vector<int>> F(N, vector<int> (10));
    vector<vector<int>> P(N, vector<int> (11));
    for (auto& x : F) for (auto& y : x) cin >> y;
    for (auto& x : P) for (auto& y : x) cin >> y;

    int ans = -(1 << 30);
    for (int i = 1; i < 1 << 10; i++) {
        vector<int> f(10);
        for (int j = 0; j < 10; j++) {
            f[j] = ((i >> j) & 1);
        }
        int t = 0;
        for (int j = 0; j < N; j++) {
            int cnt = 0;
            for (int k = 0; k < 10; k++) {
                cnt += (F[j][k] && f[k]);
            }
            t += P[j][cnt];
        }
        ans = max(ans, t);
    }
    cout << ans << endl;

    return 0;
}


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

#define MOD		1000000007
#define ll		long long int
#define pll		pair<ll, ll>
#define pb		push_back
#define endl	"\n"
#define f 		first
#define s 		second
#define fastio 	ios_base::sync_with_stdio(false);cin.tie(NULL)

ll power(ll x, ll y) { ll ans = 1; x %= MOD; while (y) {if (y & 1)ans = (x * ans) % MOD; x = (x * x) % MOD; y >>= 1;} return ans;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)

void solve() {

}

int main() {

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

	fastio;
	ll n;
	cin >> n;
	string s;
	cin >> s;

	int w = 0;
	int r = n - 1;
	ll ans = 0;

	while(w < r) {
		if(s[w] != 'W') {
			w++;
		} else if(s[r] != 'R') {
			r--;
		} else {
			ans++;
			w++;
			r--;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3756
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

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

  long long n,m;

  cin >> n >> m;

  n-=2;
  m-=2;

  if(n < 0) n = 1;
  if(m < 0) m = 1;

  cout << n * m << endl;

  return 0;
}


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

int main(){
    int A, B, T;
    int t = 0;
    int ans = 0;

    //input
    cin >> A >> B >> T;

    t += A;
    while(t < T + 1){
        ans += B;
        t += A;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	long a,b,d,r;
	double f;
	
	scanf("%ld %ld",&a,&b);
	
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	printf("%ld %ld %lf\n",d,r,f);

	return 0;
}

Measured memory_bytes: 1860
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    vector<ll> x(5);
    rep(i,5){
        cin>>x[i];
        if(x[i] != i+1){
            cout<<i+1<<endl;
            return 0;
        }
    }
 
    

    return 0;
    

}

Measured memory_bytes: 3604
#include <stdio.h>
#include <algorithm>
#include <deque>
using ll = long long;
using namespace std;

ll n, a, b;
deque<ll> res;
void rec(ll off = 0, ll blocks = 0) {
	if (!(off < n))
		return;
	ll w = max(min(b, (n - off) - (a - blocks - 1)), 1ll);
	rec(off + w, blocks + 1);
	for (ll i = 0; i < w; i++)
		res.emplace_front(off + i + 1);
}

int main() {
	scanf("%lld %lld %lld", &n, &a, &b);
	if (n + 1 < a + b) {
		res.emplace_back(-1);
	} else if (a * b < n) {
		res.emplace_back(-1);
	} else {
		rec();
	}

	printf("%lld", res[0]);
	for (int i = 1; i < res.size(); i++)
		printf(" %lld", res[i]);
	printf("\n");
}

Measured memory_bytes: 12544
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ull N, K, n;
    cin >> N >> K;
    int A[N], i, j;
    int a, b, f, C;
    for(n = 0; n < N; n++)
    {
        cin >> A[n];
        A[n]--;
    }

    a = A[0];
    b = A[A[0]];
    while(a != b)
    {
        a = A[a];
        b = A[A[b]];
    }
    a = 0;
    i = 0;
    while(a != b)
    {
        a = A[a];
        b = A[b];
        i++;
    }
    f = a;
    b = A[a];
    C = 1;
    while(a != b)
    {
        b = A[b];
        C++;
    }

    if(K <= i)
    {
        a = 0;
        for(j = 0; j < K; j++)
        {
            a = A[a];
        }
        cout << a+1 << endl;
    }
    else
    {
        K -= i;
        K %= C;
        a = f;
        for(j = 0; j < K; j++)
        {
            a = A[a];
        }
        cout << a+1 << endl;
    }
}

// Main

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

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


Measured memory_bytes: 4380
from collections import deque


def bfs(sy, sx, gy, gx):
    q = deque([[sy, sx]])
    visited[sy][sx] = 0
    while q:
        y, x = q.popleft()
        if [y, x] == [gy, gx]:
            return visited[y][x]
        for j, k in ([1, 0], [-1, 0], [0, 1], [0, -1]):
            ny, nx = y+j, x+k
            if ny < 0 or ny > h-1 or nx < 0 or nx > w-1 or path[ny][nx] == "#":
                continue
            if path[ny][nx] == "." and visited[ny][nx] == -1:
                visited[ny][nx] = visited[y][x]+1
                q.append([ny, nx])


h, w = map(int, input().split())
path = [input() for _ in range(h)]
visited = [[-1]*w for _ in range(h)]
sy, sx = 0, 0
gy, gx = h-1, w-1
bfs(sy, sx, gy, gx)

count = 0
for i in range(h):
    for j in range(w):
        if path[i][j] == '#':
            count += 1
if visited[gy][gx] != -1:
    print(h*w-count-(visited[gy][gx]+1))
else:
    print(-1)


Measured memory_bytes: 9404
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    vector<int> n(3);
    rep(i, 3) cin >> n.at(i);
    sort(n.begin(), n.end());
    if (n.at(0) == 5 && n.at(1) == 5 && n.at(2) == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), co(N, 0);
    rep(i, N) {
        cin >> A[i];
        co.at(A[i] - 1)++;
    }
    ll ch = 0;
    rep(i, N) ch += co[i] * (co[i] - 1) / 2;
    rep(i, N) cout << ch - co[A[i] - 1] + 1 << endl;
}

Measured memory_bytes: 6388
#include <iostream>
#include <algorithm>
using namespace std;
int n,ans;
char s[110];
int main(){
    cin>>n>>s;
    for(int i=0;i<n;i++){
        int a[26]={},b[26]={},m=0;
        for(int j=0;j<n;j++){
            if(j<i) a[s[j]-'a']=1;
            else b[s[j]-'a']=1;
        }
        for(int j=0;j<26;j++){
            if(a[j]&&b[j]) m++;
        }
        ans=max(ans,m);
    }
    cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,pair<int,int>>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int p, q, r; cin >> p >> q >> r;
	cout << min({ p + q,p + r,q + r }) << endl;
}

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

int main(void)
{
	int N, A, B, C;
	std::cin >> N >> A >> B >> C;

  std::vector<long long> poles;
  for(int i = 0; i < N; i++)
  {
    long long l;
    std::cin >> l;
    poles.push_back(l);
  }
  std::sort(poles.begin(), poles.end());

  int minCost = 10000000;
  for(int i = 0; i < 65536; i++)
  {
    int cost = -30;
    std::vector<int> polesTesting(4,0);
    for(int n=0; n< poles.size(); n++)
    {
      auto id = (i >> (2 * n)) % 4;
      polesTesting[id] += poles[n];
      if( id != 3 ) { cost += 10; }
    }

    if (polesTesting[0] == 0) { continue; }
    if (polesTesting[1] == 0) { continue; }
    if (polesTesting[2] == 0) { continue; }

    cost += std::abs(polesTesting[0] - A);
    cost += std::abs(polesTesting[1] - B);
    cost += std::abs(polesTesting[2] - C);
    minCost = std::min(minCost, cost);
  }
  std::cout << minCost;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
        int n, k; cin >> n >> k;
        for (int q = 0; q <= n; ++q){
            for (int w = 0; w <= n; ++w){
                int e = n - q - w;
                if (e < 0) break;
                if (q * 10000 + w * 5000 + e * 1000 == k){
                    cout << q << " " << w << " " << e << endl;
                    return 0;
                }
            }
        }
        cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, m;
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
char s[52][52];
int main() {
	scanf("%d%d", &n, &m);
	for(int i=1; i<=n; i++) {
		scanf("%s", &s[i][1]);
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=m; j++) {
			if(s[i][j] != '#') continue;
			bool flag = 0;
			for(int k=0; k<4; k++) {
				if(s[i+dy[k]][j+dx[k]] == '#')
					flag = 1;
			}
			if(!flag) { puts("No"); return 0; }
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
N=int(input())
A=list(map(int,input().split()))
A1=sorted(A)
cnt=[0 for _ in range(N+1)] #cnt_table[i]: 数字iの要素の個数

for i in range(N):
    cnt[A[i]]+=1

cmb=[cnt[k]*(cnt[k]-1)//2 for k in range(N+1)]
SUM=sum(cmb)

for j in range(N):
    n=A[j]
    v=cnt[A[j]]
    print(SUM-cmb[n]+(v-1)*(v-2)//2)


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


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

class APayment {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        out << (1000-n%1000)%1000 << endl;
	}
};


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


Measured memory_bytes: 3620