akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>

int max(int x, int y);


int main()
{
    int a, b, c;
    int x, y;
    int minSum;
    int maxNumberOfAb;

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

    maxNumberOfAb = max(x, y) * 2;
    minSum = a * x + b * y + c * (x + y); // dummy
    for (int i = 0; i <= maxNumberOfAb; i++)
    {
	int needA = x - (int)floor(i / 2);
	int needB = y - (int)floor(i / 2);

	if (needA < 0)
	{
	    needA = 0;
	}
	if (needB < 0)
	{
	    needB = 0;
	}
	
	int sum = a * needA + b * needB + c * i;

	if (sum < minSum)
	{
	    minSum = sum;
	}
    }

    printf("%d\n", minSum);
    
    return 0;
}

int max(int x, int y)
{
    if (x > y)
    {
	return x;
    }
    else
    {
	return y;
    }
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A;
    string B;
    
    cin >> A >> B;
    ll lB = 0;
    for(auto c:B){
        if(c != '.'){
            lB = 10*lB + (c-'0');
        }
    }
    res = A*lB/100;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<stdio.h>
int main()
{
  double n,m,sum=0,count=0;
  int i;
  scanf("%lf %lf",&n,&m);
  double a[100];
  for(i=0;i<n;i++)
  {
    scanf("%lf",&a[i]);
    sum+=a[i];
  }
  for(i=0;i<n;i++)
  {
    if(a[i] >= (double)sum/(4*m))
    {
      count++;
      if(count==m)
      {
        printf("Yes");
        return 0;
      }
    }
  }
  if(count==m)
  {
      printf("Yes");
  }
  printf("No");
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int k, x;
    cin >> k >> x;
    for (int i=x-k+1; i<x+k; ++i) {
        cout << i << (i<x+k-1?' ':'\n');
    }
    return 0;
}


Measured memory_bytes: 256
from copy import copy
def solve():
    ans = 0
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for j in range(K):
        check = [0]*(N+1)
        for i in range(N):
            check[max(0,i-A[i])] += 1
            check[min(N,i+A[i]+1)] -= 1
        B = [check[0]]*N
        for i in range(1,N):
            B[i] = B[i-1]+check[i]
        A = copy(B)
        if A==[N]*N:
            break
    return A
print(*solve())

Measured memory_bytes: 170872
#include<bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout << a.at(n-1) - a.at(0) << endl;
  
}

Measured memory_bytes: 256
read n
n=$((n-2))
read b
declare -a z=($b)
a=0
for i in $(seq 1 $n); do
	if [ $((z[$i])) -gt $((z[i-1])) ]; then
		a=$((a+z[i-1]))
	else
		a=$((a+z[i]))
	fi
done
echo $((a+z[0]+z[n]))

Measured memory_bytes: 540
x,y=map(int,input().split())
ans=0
if x==1:
  ans=ans+300000
if y==1:
  ans=ans+300000
if x==2:
  ans=ans+200000
if y==2:
  ans=ans+200000
if x==3:
  ans=ans+100000
if y==3:
  ans=ans+100000
if x==1 and y==1:
  ans=ans+400000
print(ans)

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

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int main() {
  
  int X, Y;
  int const dx[] = {0,-1,1};
  
  while(cin >> X >> Y, X||Y) {
    int ba[X][Y];
    REP(y,Y) {
      REP(x,X) {
        cin >> ba[x][y];
      }
    }
    int dp[X][Y];
    memset(dp,0,sizeof(dp));
    REP(i,X)
      if (ba[i][0] == 0)
        dp[i][0] = 1;
    REP(y, Y-1) {
      REP(x,X) {
        if (ba[x][y] == 0) {
          REP(i,3) {
            int xx = x + dx[i];
            int yy = y + 1;
            if (xx < 0 || X <= xx) continue;
            
            if (ba[xx][yy] == 0 || ba[xx][yy] == 2 && i == 0) {
              dp[xx][yy] += dp[x][y];
            }
          }
        } else if (ba[x][y] == 2) {
          if (y+2 < Y && ba[x][y+2] != 1)
            dp[x][y+2] = dp[x][y];
        }
      }
    }
    // REP(y,Y) {
    //   REP(x,X) {
    //     cout << dp[x][y] << " ";
    //   }
    //   cout << endl;
    // }
  
    int ans = 0;
    REP(x,X) {
      ans += dp[x][Y-1];
      if (ba[x][Y-2] == 2)
        ans += dp[x][Y-2];
    }
    cout << ans << endl;
  }
}

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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = (y); x <= (z); x++)
#define REPP(x, y, z) for(int x = (y); x >= (z); x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn 200000+5
#define IOS ios::sync_with_stdio(false); cin.tie(0);

//structure

//declaration

//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	int n, k;
	cin >> n >> k;
	double num;
	double arr[maxn];
	arr[0] = 0.0;

	REP(i, 1, n)
	{
		cin >> num;
		arr[i] = arr[i-1]+((1+num)/2);
	}

	double maxx = -1e9;

	for(int i = 0; i+k-1 <= n; i++)
	{
		maxx = max(maxx, arr[i+k]-arr[i]);
	}

	printf("%.12lf\n", maxx);


	

	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int fast = -1;
        int fastIndex = -1;
        int second = -1;

        for (int i = 0; i < N; i++) {
            int n = sc.nextInt();
            if (fast <=  n) {
                second = fast;
                fast = n;
                fastIndex = i;
            } else if (second < n) {
                second = n;
            }
        }

        for (int i = 0; i < N; i++) {
            if (i == fastIndex) {
                System.out.println(second);
            } else {
                System.out.println(fast);
            }
        }

    }
}

Measured memory_bytes: 82892
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = (1LL << 50);

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}



ll dp[100005];
char A[55][55];
ll d[55][55];
ll vis[55][55];

pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };


void bfs(int startx, int starty) {
	queue<pair<int, int>> Q;
	pair<int, int> u;
	ll nextx, nexty;
	Q.push({ startx, starty });

	while (!Q.empty()) {
		u = Q.front();
		Q.pop();


		rep(i, 4) {
			nextx = u.first + dx[i].first;
			nexty = u.second + dx[i].second;

			if (A[nextx][nexty] == '.' && d[nextx][nexty] == inf) {
				Q.push({ nextx, nexty });
				d[nextx][nexty] = d[u.first][u.second] + 1;

			}

		}


	}

	


}



int main() {
	ll H, W;

	cin >> H >> W;


	rep(i, 55) {
		rep(j, 55) {

			d[i][j] = inf;
			A[i][j] = '#';
		}
	}


	d[1][1] = 0;



	ll sum_dot = 0;

	rep(i, H) {
		rep(j, W) {


			cin >> A[i+1][j+1];

			if (A[i + 1][j + 1] == '.')
				sum_dot += 1;


		}

	}





	bfs(1, 1);

	if (d[H][W] == inf) {
		cout << -1 << endl;
		return 0;
	}

	cout << sum_dot - d[H][W] - 1 << endl;

	return 0;
}

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


int main() {
    int n ;
    cin >> n  ;
    int a[n+2] ;
    a[0] = 0 ;
    a[n+1] = 0 ;

    int sum = 0 ;
    for(int i=1;i<=n;i++){
       cin >> a[i] ;
       sum+= abs(a[i]-a[i-1]) ;
    } 

    sum+=abs(a[n]-a[0]) ;

    for(int i=1;i<=n;i++){
        cout << sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1]) << endl ;
    }
    

	return 0;
}



Measured memory_bytes: 1664
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n;
	scanf("%d", &n);
	V a(n); scan(a);
	rep(i, 1, n) a[n-i] -= a[n-i-1];
	int ans = 0;
	rep(i, 0, n) ans += std::max(0l, a[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
using namespace std;
int main()
{

	string N;
	cin >> N;

	if (N == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if(N == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else
	{
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

type Sord struct {
	a int64
	b int64
}

type Sords []Sord

func (a Sords) Len() int {
	return len(a)
}

func (a Sords) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Sords) Less(i, j int) bool {
	return a[i].b > a[j].b
}

func main() {
	var N int
	var H int64

	fmt.Scanf("%d %d", &N, &H)

	sords := make(Sords, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d", &sords[i].a, &sords[i].b)
	}

	sort.Sort(sords)

	max := sords[0].a
	for i := 0; i < N; i++ {
		if sords[i].a > max {
			max = sords[i].a
		}
	}

	attack := 0
	damage := int64(0)
	for i := 0; i < N; i++ {
		if damage >= H || sords[i].b < max {
			break
		}

		damage += sords[i].b
		attack++
	}

	if damage < H {
		more := int((H - damage + (max - 1)) / max)
		attack += more
		damage += max * int64(more)
	}

	fmt.Println(attack)
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;

const int MAXN = 16;
const int H = 4;
const int W = 4;
const char C[3] = {'R','G','B'};
const int INF = 1<<28;

int n;
char goal[H][W];
int h[MAXN], w[MAXN];
bool vis[1<<(W*H)];

inline int getId(const int &x, const int &y) {
  return x + y * W;
}

int stamp(int state, int x, int y, int w, int h, char c) {
  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      int nx = x + j;
      int ny = y + i;
      if(nx < 0 || nx >= W) continue;
      if(ny < 0 || ny >= H) continue;
      int id = getId(nx,ny);
      state = (state & ~(1<<id));
      if(goal[ny][nx] == c) state |= (1<<id);
    }
  }
  return state;
}

int bfs() {
  queue<int> que;
  int vis[1<<(W*H)];
  que.push(0);
  fill(vis,vis+(1<<(W*H)), INF);
  vis[0] = 0;
  while(!que.empty()) {
    int s = que.front();
    que.pop();
    for(int k = 0; k < n; ++k) {
      for(int m = 0; m < 3; ++m) {
	for(int x = 1-w[k]; x < W; ++x) {
	  for(int y = 1-h[k]; y < H; ++y) {
	    int ns = stamp(s,x,y,w[k],h[k],C[m]);
	    if(vis[ns] != INF) continue;
	    vis[ns] = vis[s] + 1;
	    que.push(ns);
	    if(ns == (1<<(W*H))-1) return vis[ns];
	  }
	}
      }
    }
  }
  return INF;
}

int main() {
  while(cin >> n) { 
    for(int i = 0; i < n; ++i) {
      cin >> h[i] >> w[i];
    }
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
	cin >> goal[i][j];
      }
    }
    cout << bfs() << endl;
  }
  return 0;
}

Measured memory_bytes: 1608
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    for (int i = 0; i < m; i++) cin >> x.at(i);
    sort(x.begin(), x.end());
    vector<int> dist(m - 1);
    for (int i = 0; i < m - 1; i++) dist.at(i) = x.at(i + 1) - x.at(i);
    sort(dist.begin(), dist.end(), greater<int>());
    int ans = 0;
    for (int i = n - 1; i < m - 1; i++) ans += dist.at(i);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

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


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

int main(){
    int n;
    scanf("%d", &n);
    char previous_color;
    char s[n];
    scanf("%s", s);

    int cnt = 0;
    cnt++;
    previous_color = s[0];
    for(int i = 1; i < n; i++){
        if(s[i] != previous_color){
            cnt++;
        }
        previous_color = s[i];
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 384
from pprint import pprint
import sys
import copy

n = int(sys.stdin.readline().strip())

events = []
for _ in range(n):
    a, b, c = map(int, sys.stdin.readline().strip().split(" "))
    events.append((a, b, c))
# pprint(events)

pre_states = events[0]
for day in range(1, n):
    states = [0] * 3
    for i in range(3):
        tmp = []
        for j in range(3):
            if i == j:
                continue

            tmp.append(pre_states[j] + events[day][i])
        states[i] = max(tmp)
    # pprint(states)
    pre_states = copy.deepcopy(states)

pprint(max(pre_states))

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

int n;
vector<vector<int>> g;

int solve(int now, int par);

int main() {
  cin >> n;
  g.resize(n);
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].push_back(--b);
    g[b].push_back(a);
  }
  if (solve(0, -1))
    cout << "Alice" << endl;
  else
    cout << "Bob" << endl;
  return 0;
}

int solve(int now, int par) {
  int res = 0;
  for (auto to : g[now])
    if (to != par) res ^= solve(to, now) + 1;
  return res;
}

Measured memory_bytes: 13448
#include <bits/stdc++.h>
//#define int long long
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[n];
  int b1 = 0, b2 = 0, b4 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] % 4 == 0) b4++;
    else if (a[i] % 2 == 0) b2++;
    else b1++;
  }

  if (b2 == 0) {
    if (b1 <= b4 + 1) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if (b1 <= b4) cout << "Yes" << endl;
    else cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main() {

	int d = 0, n = 0, p = 0;
	cin >> d >> n;

	p = powf(100, d);

	if (n == 100) {

		cout << p * 101 << endl;

	}else if(d == 0){

		cout << n << endl;

	}else {

		cout << p * n << endl;

	}
	

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;
//RRRLL RLL RRRLLLLL
//RLRLR RLR RLRLRLRL

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    VL ans(s.size(), 0);

    LL r_count = 0;
    LL l_count = 0;
    LL r_index = -1;
    LL l_index = 0;
    REP(i,s.size()){
        if(r_count > 0 && s[i] == 'L' && r_index == -1){
            r_index = i - 1;
            l_index = i;
        }
        if(l_count > 0 && s[i] == 'R'){
            for(int j = r_index - r_count + 1; j <= r_index; j++){
                if((r_index - j) % 2 == 0)ans[r_index]++;
                else ans[l_index]++;
            }
            for(int j = l_index; j < l_index + l_count; j++){
                if((j - l_index) % 2 == 0)ans[l_index]++;
                else ans[r_index]++;
            }
            r_index = -1;
            r_count = 0;
            l_count = 0;
        }
        if(s[i] == 'R')r_count++;
        if(s[i] == 'L')l_count++;
    }
    if(l_count > 0){
        for(int i = r_index - r_count + 1; i <= r_index; i++){
            if((r_index - i) % 2 == 0)ans[r_index]++;
            else ans[l_index]++;
        }
        for(int i = l_index; i < l_index + l_count; i++){
            if((l_index - i) % 2 == 0)ans[l_index]++;
            else ans[r_index]++;
        }
    }
    REP(i,s.size()){
        cout<<ans[i]<<" ";
    }
}

Measured memory_bytes: 1488
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>

using namespace std;

#define int long long

const int N = 3e5 + 5 , mod = 1e9 + 7;

//void add(int &x , int y){
//	x += y;
//	if(x >= mod)
//		x -= mod;
//}

char s[N];

long long n , ans;

long long f[N][3][3];

void add(long long &a, long long b) {
	a += b, ((a > mod) ? (a -= mod) : 0);
}

main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	f[0][0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(s[i + 1] != '0') {
					if(k)
						add(f[i + 1][j][k - 1], f[i][j][k]);
					else add(f[i + 1][min(j + 1, (long long)2)][k], f[i][j][k]);
				}
				if(s[i + 1] != '1') {
					if(k == 2)
						add(f[i + 1][j][1], f[i][j][k]);
					else add(f[i + 1][j][k + 1], f[i][j][k]);
				}
			}
		}
	}
	for(int i = 0; i < 3; i++)
		for(int j = 0; j <= i; j++)
			add(ans, f[n][i][j]);
	cout << ans;
	return 0;
}

Measured memory_bytes: 21760
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  vector<long long> a(5);
  for(int i=0;i<5;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  long long ans=4+(n+a[0]-1)/a[0];
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int* x, int* y){
    int temp;
    if(*x>*y)
    {
        temp=*x;
        *x=*y;
        *y=temp;
    }
}

int main(){
    int a,b,c; scanf("%d%d%d",&a,&b,&c);
    swap(&a,&b);
    swap(&b,&c);
    swap(&a,&b);
    printf("%d %d %d\n",a,b,c);
    
}




Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b;
    cin >> a >> b;
    
    cout << (a-1)*(b-1) << endl;
    

    return 0;
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
const long double eps = 1e-12;
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144*2
#define REP(a,b) for(long long a = 0;a < b;++a)
long long dp[300000] = {};
int main() {
	iostream::sync_with_stdio(false);
	cin.tie(0);
	long long n, w;
	cin >> n >> w;
	REP(i, n) {
		long long a, b;
		cin >> a >> b;
		for (int i = w; i >= 0; --i) {
			dp[i + a] = max(dp[i + a], dp[i] + b);
		}
	}
	long long ans = 0;
	REP(i, w + 1) {
		ans = max(ans, dp[i]);
	}
	cout << ans << endl;
}

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

#define rep(i, n) for (ll i=0;i<(n); i++)

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;



int main(){
  ll a,b,x;
  ll ans = 0;
  cin >> a >> b>>x;

  if (a%x==0) ans += 1;
  
  a = a / x;
  b = b / x;

  ans += b-a;

  
 
  
  
  cout << ans << endl;  
  
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int result = 0;
		for(int i = 0; i < n; i++) {
			int r = sc.nextInt(), l = sc.nextInt();
			result += (l-r+1);
		}
		System.out.print(result);
	}

}


Measured memory_bytes: 23536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll x, y;
    cin>>x>>y;
    cout << __gcd(x, y) << endl;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main(){
	int h1, h2, m1, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	int ans = (m2-m1)+((h2-h1)*60)-k;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1700
// In the Name of Allah
// Ya Ali

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define F first
#define S second
#define all( x ) x.begin() , x.end()
#define pb push_back
#define mp make_pair

const int maxn = 1e5 + 10 ;
const int mod = 998244353 ;
const int INF = 1e18 ;

int n , a[ maxn ] , x , y , ans = 1 ;
bool t1 = false , t0 = false ;

signed main()
{
 ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;

 cin >> n ;
 for(int i = 1 ; i <= n ; i ++){

  cin >> a[ i ] ;

  if( !a[ i ] )
   t0 = true ;

  if( a[ i ] && ans > (INF/a[ i ]) )
    t1 = true ;

  if( !t1 )ans *= a[ i ] ;
 }

 if( t0 )
  return cout << 0 , 0 ;

 if( t1 )
  return cout << -1 , 0 ;

 cout << ans ;

    return 0;
}


Measured memory_bytes: 4424
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
struct state{
  int y,x,a,b,c,d,e,f,cost;
  bool operator < (const state&p)const{
    return cost > p.cost;
  }
};

int h,w;
int t[10][10];

int d[10][10][6][6][6][6][6][6];

void solve(){
  int ay,ax,by,bx;
  cin>>ay>>ax>>by>>bx;
  //memset(d,sizeof(d),0);  
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      for(int k=0;k<6;k++)
    for(int l=0;l<6;l++)
      for(int m=0;m<6;m++)
        for(int n=0;n<6;n++)
          for(int o=0;o<6;o++)
        for(int p=0;p<6;p++)
          d[i][j][k][l][m][n][o][p]=0;
  d[ay][ax][0][1][2][3][4][5]=1;
  priority_queue< state > Q;
  Q.push((state){ay,ax,0,1,2,3,4,5,1});
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.y][s.x][s.a][s.b][s.c][s.d][s.e][s.f])continue;
    if(s.y==by&&s.x==bx){cout<<s.cost-1<<endl;return;}
    if(s.y>0){
      int* k=&d[s.y-1][s.x][s.b][s.f][s.c][s.d][s.a][s.e];
      int ncost=s.cost+(s.e+1)*t[s.y-1][s.x];
      if( *k==0 || ncost < *k){
	*k=ncost;
	Q.push((state){s.y-1,s.x,s.b,s.f,s.c,s.d,s.a,s.e,ncost});
      }
    }
    if(s.y+1<h){
      int* k=&d[s.y+1][s.x][s.e][s.a][s.c][s.d][s.f][s.b];
      int ncost=s.cost+(s.b+1)*t[s.y+1][s.x];
      if( *k==0 || ncost < *k){
	*k=ncost;
	Q.push((state){s.y+1,s.x,s.e,s.a,s.c,s.d,s.f,s.b,ncost});
      }
    }
    if(s.x>0){
      int* k=&d[s.y][s.x-1][s.c][s.b][s.f][s.a][s.e][s.d];
      int ncost=s.cost+(s.d+1)*t[s.y][s.x-1];
      if( *k==0 || ncost < *k){
	*k=ncost;
	Q.push((state){s.y,s.x-1,s.c,s.b,s.f,s.a,s.e,s.d,ncost});
      }  
    }
    if(s.x+1<w){
      int* k=&d[s.y][s.x+1][s.d][s.b][s.a][s.f][s.e][s.c];
      int ncost=s.cost+(s.c+1)*t[s.y][s.x+1];
      if( *k==0 || ncost < *k){
	*k=ncost;
	Q.push((state){s.y,s.x+1,s.d,s.b,s.a,s.f,s.e,s.c,ncost});
      }  
    }
  }
  cout<<"NA"<<endl;
}

int main(){
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>t[i][j];
    solve();
  }
  return 0;
}

Measured memory_bytes: 19480
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e6+5;
int a[N];
 
int32_t main(){
   
   speed_cubing
   
   int n;
   cin>>n;
   
   for(int i=0;i<n;i++)
      cin>>a[i];

   int gcd = 0;

   for(int i=0;i<n;i++)
      gcd = __gcd(a[i],gcd);

   if(gcd!=1){
     cout<<"not coprime";
     return 0;
   }      

   um<int,int> m;

   for(int i=0;i<n;i++){
      m[a[i]]++;
      if(m[a[i]]>1 && a[i]!=1){
        cout<<"setwise coprime";
        return 0; 
      }
   }

   if(m.size()==1 && m.begin()->ff==1){
     cout<<"pairwise coprime";
     return 0;
   }

   for(int i=2;i<N;i++){
      
      int cnt = 0;
      
      for(int j=i;j<N;j+=i){
         
         if(m.count(j))
           cnt++;  
      }

      if(cnt>1){
        cout<<"setwise coprime";
        return 0;
      }

   } 

   cout<<"pairwise coprime"; 


   return 0;
}


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

int gcd (int x, int y){
    int r;
    if (x < y) swap(x, y);
    
    while (y > 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {
    int N, M;
    cin >> N >> M;
    cout << gcd(N, M) << endl;;
    
    return 0;
}


Measured memory_bytes: 3100
import java.io.*;
  
class Main{
    public static void main(String[] args) throws IOException{
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int i=0;
        StringBuilder str = new StringBuilder();
         
        while(true){
            i++;
            String str2 = br.readLine();
            int x = Integer.parseInt(str2);
            if(x == 0){
                break;
            }
            str.append("Case " + i + ": " + x + "\n");
        }
        System.out.print(str);
 
    }
}

Measured memory_bytes: 31940
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque, HashSet };

macro_rules! trace {
    ($var:expr) => ({
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    })
}
macro_rules! swap { ($a:expr, $b:expr) => ({ let t = $b; $b = $a; $a = t; }) }

fn main() {
    let mut sc = Scanner::new();

    let h: i32 = sc.cin();
    let w: i32 = sc.cin();

    let mut ps = vec![];

    let n: usize = sc.cin();
    for i in 0..n {
        let a: i32 = sc.cin();
        let b: i32 = sc.cin();
        ps.push((a, b));
    }

    let mut qs = HashSet::new();
    let mut bs = HashSet::new();

    for &p in ps.iter() {
        let (a, b) = p;
        bs.insert((a, b));
        for i in (a-1)..(a+2) {
            for j in (b-1)..(b+2) {
                qs.insert((i, j));
            }
        }
    }

    let mut counts = [0 as u64; 10];

    for &p in &qs {
        let (a, b) = p;
        if a <= 1 || a >= h || b <= 1 || b >= w { continue }
        let mut count = 0;
        for i in (a-1)..(a+2) {
            for j in (b-1)..(b+2) {
                if bs.contains(&(i, j)) {
                    count += 1
                }
            }
        }
        // trace!((p, count));
        counts[count] += 1;
    }

    counts[0] = (h - 2) as u64 * (w - 2) as u64;
    for i in 1..10 { counts[0] -= counts[i]; }

    for i in 0..10 {
        println!("{}", counts[i]);
    }
}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
    fn get_char(&mut self) -> char {
        self.reserve();
        let head = self.buffer[0].chars().nth(0).unwrap();
        let tail = String::from( &self.buffer[0][1..] );
        if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); }
        head
    }
}
struct PowerPermutation { n: usize, m: usize, ar: Vec<usize> }
impl PowerPermutation {
    fn new(n: usize, m: usize) -> PowerPermutation {
        let ar = vec![0; m];
        PowerPermutation { n: n, m: m, ar: ar }
    }
}
impl Iterator for PowerPermutation {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Vec<usize>> {
        if self.ar[self.m-1] >= self.n { return None }
        let r = self.ar.clone();
        self.ar[0] += 1;
        for i in 0..self.m-1 {
            if self.ar[i] == self.n {
                self.ar[i] = 0;
                self.ar[i + 1] += 1;
            } else {
                break;
            }
        }
        return Some(r);
    }
}


Measured memory_bytes: 29528
def main():
    from bisect import bisect_left as bl
    a, b, q, *stx = map(int, open(0).read().split())
    s = [-float('Inf')] + stx[:a] + [float('Inf')]
    t = [-float('Inf')] + stx[a:a + b] + [float('Inf')]
    x = stx[a + b:]
    tmp = []
    for i in x:
        f, g = bl(s, i), bl(t, i)

        sl, sr = s[f - 1], s[f]
        tl, tr = t[g - 1], t[g]

        d = float('Inf')
        for j in [sl, sr]:
            for k in [tr, tl]:
                if j <= i and k <= i:
                    d = min(d, i - min(j, k))
                elif j <= i <= k or k <= i <= j:
                    d = min(d, min(abs(i - j), abs(i - k)) * 2 + max(abs(i - j), abs(i - k)))
                else:
                    d = min(d, max(j, k) - i)

        tmp.append(d)

    ans = '\n'.join(map(str, tmp))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 36612
#include <stdio.h>

int main(void)
{
	int n;
	double stu[40];
	int i, j = 0;
	int rank[7];
	
	for (i = 1; i < 7; i++){
		rank[i] = 0;
	}
	
	scanf("%d", &n);
	
	for (i = 1; i <= n; i++){
		scanf("%lf",&stu[i]);
	}
	
	for (i = 1; i <= n; i++){
		if (stu[i] >= 185){
			rank[6]++;
		}
		else if (stu[i] >= 180){
			rank[5]++;
		}
		else if (stu[i] >= 175){
			rank[4]++;
		}
		else if (stu[i] >= 170){
			rank[3]++;
		}
		else if (stu[i] >= 165){
			rank[2]++;
		}
		else if (stu[i] < 165){
			rank[1]++;
		}
	}
	for (i = 1; i <= 6; i++){
		printf("%d:", i);
		for (j = 1; j <= rank[i]; j++){
			printf("*");
		}
		printf("\n");
	}
	
	return (0);
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int[] a = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            a[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        int range = 2 * 100000;

        // -rangeが起点
        int[] diff = new int[range * 10];
        int[] sum = new int[range * 10];
        for (int i = 1; i <= n; i++) {
            if (a[i] > 2 * 100000) {
                continue;
            }
            diff[i - a[i] + range]++;
            sum[i + a[i] + range]++;
        }

        long ans = 0;
        for (int i = 1; i <= n; i++) {
            if (a[i] > 2 * 100000) {
                continue;
            }
            ans += sum[i - a[i] + range];
            ans += diff[i + a[i] + range];
        }

        System.out.println(ans / 2);
    }
}


Measured memory_bytes: 67036
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int mod=1e9+7;
const int N = 1e5+5;

int cnt[30];
string now;

int main(){
  // freopen("input.txt","r",stdin);
  cin>>now;
  for(int i = 0;i < now.size();i++) cnt[now[i]-'a']++;
  for(int i = 0;i < 29;i++){
    if(cnt[i]&1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b&&a>c)
        printf("%d\n",b+c);
   else if(b>a&&b>c)
        printf("%d\n",a+c);
   else if(c>a&&c>b)
        printf("%d\n",a+b);
   else if(a==b)
        printf("%d\n",a+b);
   else if(a==c)
        printf("%d\n",a+c);
   else if(b==c)
        printf("%d\n",b+c);
    else
        printf("%d\n",a+b);


    return 0;


}


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

int main(){
  int r,s;
  cin>>r>>s;
 
  vector<string> vec(r);
  for(int i=0;i<r;i++){
    cin>>vec.at(i);
  }
  string x,y;
  int count=0;
  
  for(int i=0;i<r;i++){
    x=vec.at(i);
    for(int j=0;j<s;j++){
      if(x.at(j)=='#'){
        if(i!=0){
          y=vec.at(i-1);
          if(y.at(j)=='#'){
            count++;
          }
        }
        
        if(i!=r-1){
          y=vec.at(i+1);
          if(y.at(j)=='#'){
            count++;
          }
        }
        
        if(j!=0){
          if(x.at(j-1)=='#'){
            count++;
          }
        }

        if(j!=s-1){
          if(x.at(j+1)=='#'){
            count++;
          }
        }
        
        if(count==0){
          cout<<"No"<<endl;
          return 0;
        }
        count=0;
      }
    }
  }

     cout<<"Yes"<<endl; 
}

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

int main() {
  int n, d, x, p[10][10], dp[200001];

  cin >> n >> d >> x;
  for(int i = 0; i < d; i++) {
    for(int j = 0; j < n; j++) {
      cin >> p[i][j];
    }
  }
  int money = x;
  for(int i = 1; i < d; i++) {
    fill_n( dp, 200001, -1145141919);
    dp[0] = 0;
    for(int j = 0; j < n; j++) {
      for(int k = 0; k <= money; k++) {
        dp[k + p[i - 1][j]] = max(dp[k + p[i - 1][j]], dp[k] + p[i][j]);
      }
    }
    int next = money;
    for(int j = 0; j <= money; j++) {
      next = max(next, dp[j] + money - j);
    }
    money = next;
  }
  cout << money << endl;
}

Measured memory_bytes: 1940
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int k = scanner.nextInt();
		if(a >= b && a>=c) {
			a *= (int)Math.pow(2, k);
		}else if(b > a && b >= c) {
			b *= (int)Math.pow(2, k);
		}else {
			c *= (int)Math.pow(2, k);
		}
		
		System.out.println(a+b+c);		
	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i+=2){
    int num=0;
    for(int j=1;j<=i;j++){
      if(i%j==0){
        num++;
      }
    }
    if(num==8){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
	int a, b, c,s;
	cin >> a >> b >> c;
	s = a + b + c;
	if (s > 21) {
		cout << "bust";
	}
	else {
		cout << "win";
	}
	cout << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		for(;;){
			if(!sc.hasNext())
				break;
			int n=sc.nextInt();
			int r=0;
			for(int d=0; d<=9; d++)
				for(int c=0; c<=9; c++)
					for(int b=0; b<=9; b++)
						for(int a=0; a<=9; a++)
							if(a+b+c+d==n)
								r++;
			println(""+r);
		}
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 12000
import java.util.*;

public class Main {
    public static long gcd(long a, long b) {
        while (b != 0) {
            long tmp = b;
            b = a % b;
            a = tmp;
        }

        return a;
    }

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

        int n = sc.nextInt();

        int[] nums = new int[n];

        HashMap<Integer, Integer> divs = new HashMap<>();

        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }

        int[] prefixGCD = new int[n - 1];

        prefixGCD[0] = nums[0];

        for (int i = 1; i < n - 1; i++) {
            prefixGCD[i] = (int) gcd(prefixGCD[i - 1], nums[i]);
        }

        int best = prefixGCD[n - 2];
        int runningGCDsuffix = nums[n - 1];

        for (int i = n - 2; i > 0; i--) {
            best = Math.max(best, (int) gcd(runningGCDsuffix, prefixGCD[i - 1]));
            runningGCDsuffix = (int) gcd(runningGCDsuffix, nums[i]);
        }

        best = Math.max(best, runningGCDsuffix);

        System.out.println(best);
    }
}


Measured memory_bytes: 50324
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

string cs;

void precalc() {
  cs = "";
  for (char c = 'a'; c <= 'z'; c++) {
    cs += c;
  }
  for (char c = 'A'; c <= 'Z'; c++) {
    cs += c;
  }
  for (char c = '0'; c <= '9'; c++) {
    cs += c;
  }
}

const int l = 128;

int ask(const string &s) {
  printf("? %s\n", s.c_str());
  fflush(stdout);
  int res;
  scanf("%d", &res);
  return res;
}

int n;
vector<int> cnt;

string rec(int l, int r) {
  if (l == r - 1) {
    return string(cnt[l], cs[l]);
  }
  int m = (l + r) / 2;
  string s = rec(l, m), t = rec(m, r);
  int j = 0;
  for (int i = 0; i < sz(s); i++) {
    while (j < sz(t)) {
      string ns = s;
      ns.insert(ns.begin() + i, t[j]);
      if (ask(ns) == n - sz(ns)) {
        s = ns;
        i++;
        j++;
      } else {
        break;
      }
    }
  }
  while (j < sz(t)) {
    s += t[j];
    j++;
  }
  return s;
}

void solve() {
  cnt.resize(sz(cs));
  n = 0;
  for (int i = 0; i < sz(cs); i++) {
    cnt[i] = l - ask(string(l, cs[i]));
    n += cnt[i];
  }
  string ans = rec(0, sz(cs));
  printf("! %s\n", ans.c_str());
  fflush(stdout);
}

int main() {
  precalc();
  solve();
#ifdef DEBUG
  eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 3780
N, M = map(int, input().split())
lst = [int(x) for x in input().split()]

ret = [1] * N
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if lst[a] > lst[b]:
        ret[b] = 0
    elif lst[a] < lst[b]:
        ret[a] = 0
    if lst[a] == lst[b]:
        ret[a] = ret[b] = 0

print(ret.count(1))

Measured memory_bytes: 20112
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.util.ArrayList;
        import java.util.Collections;
        import java.util.List;
        import java.util.Scanner;

public class Main {
    static private Scanner scan = new Scanner(System.in);
    public static void main(String args[]) {
//        int int1 = Integer.parseInt(scan.next());
//        int int2 = Integer.parseInt(scan.next());

        String str1 = scan.next();
        String str2 = scan.next();
//        String str3 = scan.next();
        int ans_int = 0;
        double ans_dob = 0;
        String ans = "";
        BigDecimal bd = new BigDecimal((Double.parseDouble(str1) + Double.parseDouble(str2))/2);
        ans_int = bd.setScale(0, BigDecimal.ROUND_HALF_UP).intValue();

        PrintWriter out = new PrintWriter(System.out);
        out.println(ans_int);
        out.flush();
        scan.close();
    }
}


Measured memory_bytes: 22228
import numpy as np
import sys
input = sys.stdin.readline

N = int(input())
S = input()
keta = 3
count = 0
for i in range(1000):
    s = str(i).zfill(keta)
    pos = -1
    for j in range(keta):
        tmp = S[pos+1:].find(s[j])
        if tmp == -1:
            break
        pos += tmp + 1
    else:
        count += 1
print(count)

Measured memory_bytes: 12508
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
        ab: [(i64, i64); n],
        cd: [(i64, i64); m],
    }
    for &(a, b) in ab.iter() {
        let mut min_idx = 1;
        let mut min_dist = std::i64::MAX;
        for (i, &(c, d)) in cd.iter().enumerate() {
            let dist = (a - c).abs() + (b - d).abs();
            if dist < min_dist {
                min_dist = dist;
                min_idx = i + 1;
            }
        }

        println!("{}", min_idx);
    }
}


Measured memory_bytes: 4352