akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> g(h);
  int sx, sy;
  for (int i = 0; i < h; i++) {
    cin >> g[i];
    for (int j = 0; j < w; j++) {
      if (g[i][j] == 'S') sx = i, sy = j;
    }
  }
  vector<vector<int>> dist(h, vector<int>(w, -1));
  dist[sx][sy] = 0;
  queue<pair<int, int>> que;
  que.emplace(sx, sy);
  int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
  while (que.size()) {
    auto cur = que.front();
    que.pop();
    if (dist[cur.first][cur.second] == k) continue;
    for (int i = 0; i < 4; i++) {
      int x = cur.first + dx[i];
      int y = cur.second + dy[i];
      if (x < 0 || x >= h || y < 0 || y >= w) continue;
      if (g[x][y] == '#') continue;
      if (dist[x][y] != -1) continue;
      dist[x][y] = dist[cur.first][cur.second] + 1;
      que.emplace(x, y);
    } 
  }
  // for (int i = 0; i < h; i++) {
  //   for (int j = 0; j < w; j++) {
  //     cerr << g[i][j];
  //   }
  //   cerr << endl;
  // }
  // cerr << endl;
  // for (int i = 0; i < h; i++) {
  //   for (int j = 0; j < w; j++) {
  //     cerr << setw(3) << dist[i][j];
  //   }
  //   cerr << endl;
  // }
  for (int i = 0; i < h; i++) {
    if (dist[i][0] == -1 && dist[i][w - 1] == -1) continue;
    cout << 1 << '\n';
    return 0;
  }
  for (int j = 0; j < w; j++) {
    if (dist[0][j] == -1 && dist[h - 1][j] == -1) continue;
    cout << 1 << '\n';
    return 0;
  }
  for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
    if (dist[i][j] >= 0) {
      que.emplace(i, j);
      dist[i][j] = 0;
    }
  }
  while (que.size()) {
    auto cur = que.front();
    que.pop();
    for (int i = 0; i < 4; i++){ 
      int x = cur.first + dx[i];
      int y = cur.second + dy[i];
      if (x < 0 || x >= h || y < 0 || y >= w) continue;
      if (dist[x][y] != -1) continue;
      dist[x][y] = dist[cur.first][cur.second] + 1;
      que.emplace(x, y);
      if (x == 0 || x == h - 1 || y == 0 || y == w - 1) {
        cout << 1 + (dist[x][y] + k - 1) / k << '\n';
        return 0;
      }
    }
  }
  // cerr << endl;
  // for (int i = 0; i < h; i++) {
  //   for (int j = 0; j < w; j++) {
  //     cerr << setw(3) << dist[i][j];
  //   }
  //   cerr << endl;
  // }
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <cmath>
typedef long long ll;
using namespace std; 
int main() {
	ios::sync_with_stdio(false); cin.tie(0);
    int n,x,t;
    cin>>n>>x>>t;
    cout<<ll((n+x-1)/x*t);
    
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int K, T;
priority_queue<int> a;

void init()
{
	cin >> K >> T;
	rep(i, T) {
		int t;
		cin >> t;
		a.push(t);
	}
}

void solve()
{
	int pre = a.top() - 1;
	a.pop();
	while (!a.empty()) {
		int t = a.top() - 1;
		a.pop();
		if (pre) a.push(pre);
		pre = t;
	}
	cout << pre << endl;
}



Measured memory_bytes: 256
s = [i for i in input()]
B_pos_ls = []
for i, x in enumerate(s):
    if x == 'B':
        B_pos_ls.append(i)
res = 0
B_pos_ls.sort(reverse=True)
last_B_pos = len(s) - 1
for B_pos in B_pos_ls:
    res += last_B_pos - B_pos
    last_B_pos -= 1
print(res)

Measured memory_bytes: 12708
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>

using namespace std;


int main() {
	int i, j, k;
	int n;

	map<int, int>mp;

	cin >> n;

	int num;
	for (i = 0; i < n; i++) {
		cin >> num;
		if (mp.count(num) == 0) {
			mp.insert(pair<int, int>(num, 1));
		}
		else {
			mp[num]++;
		}
	}

	int cnt = 0;
	map<int, int> ::iterator it;
	for (it = mp.begin(); it != mp.end(); it++) {
		if ((*it).first > (*it).second) {
			cnt += (*it).second;
		}
	}

	for (it = mp.begin(); it != mp.end(); it++) {
		if ((*it).first <= (*it).second) {
			cnt += (*it).second - (*it).first;
		}
	}

	cout << cnt << endl;




	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 4736
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(void){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans_solt = 0;
  	int ans_al = 100*a;
    for(int i =0;i<=30;i++){
        for(int j=0;j<=30;j++){
            for(int k=0;k<=100;k++){
                for(int l=0;l<=100;l++){
                    int solt = (c*k+d*l);
                    int water = 100*a*i+100*b*j;
                    if(water+solt <= f && water> 0){
              			if((double) solt /water <= (double) e/100){
                          if((double) ans_solt / ans_al < (double) solt / (water + solt)){
                            ans_solt = solt;
                            ans_al = solt + water;
                           }
                        }
                    }
                }
            }
        }
    }
    cout << ans_al << ' ' << ans_solt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int A,B,C;
    cin >> A >> B >> C;

    LL ans = B + min(A+B+1,C);
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

#define NMAX 100

int selectionSort(int *A, int n);

int main(){
   int j, n, A[NMAX];
   int nswitch;
   scanf("%d",&n);
   for(j=0;j<n;j++) scanf("%d",A+j);
   nswitch=selectionSort(A,n);
   printf("%d",A[0]);
   for(j=1;j<n;j++) printf(" %d",A[j]);
   printf("\n");
   printf("%d\n",nswitch);
   return 0;
}

int selectionSort(int *A, int n){
   int nswitch, i, j, minj, tmp;
   nswitch=0;
   for(i=0;i<n;i++){
      minj=i;
      for(j=i;j<n;j++){
         if(A[j]<A[minj]) minj=j;
      }
      if(minj!=i){
         tmp=A[i]; A[i]=A[minj]; A[minj]=tmp;
         ++nswitch;
      }
   }
   return nswitch;
}

Measured memory_bytes: 604
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long 
#define mod 1000000007
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int t;
        int a,b,c,d;
        cin>>a>>b;
        if(b>=a)cout<<"unsafe";
        else cout<<"safe";
        return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
long long int mod = (long long int)1000000007;
using namespace std;

void solve()
{
    ll i,j,k,n;
    std::cout.precision(10);
    int yes=0;
    cin>>n;
    n=n%10;
    if(n==2 || n==4 || n==5 || n==7 || n==9)
    {
        cout<<"hon";
    }
    else if(n==3)
    {
        cout<<"bon";
    }
    else 
    {
        cout<<"pon";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
    int i,j,k;
    int t;
    std::cout.precision(10);
    t=1;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
ll int large=(ll int)1e13+7;
ll int mod=(ll int)1e9+7;
ll int const N=(ll int)1e6+10;

ll int mod_exp(ll int x,ll int n)
{
    ll int result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n=n/2;
    }
    return result;
}

ll int mod_inverse(ll int a)
{
    return mod_exp(a,mod-2);
}



int main()
{
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
ll int T,i,j,ij;
T=1;
//cin>>T;
while(T--)
{
   ll n;
   cin>>n;
   string ans="";

   while(n!=0)
   {
       if(n%26==0)
       {
        ans+=char('a'+25);
        n-=26;
       }
       else
       ans+=('a'+n%26-1);
       n/=26;
   }
    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;



}
return 0;
}
















Measured memory_bytes: 3652
#include<stdio.h>

int main(void)
 {

 int r1,r2,c1,c2,i,j;
 int rsam = 0;
  
  scanf("%d",&r1);
  scanf("%d",&c1);
  r2 = r1;
  c2 = c1;
  r2++;
  c2++;

  int num[r2][c2];
  int csum[c2];
  

  
    for(i=0;i<r1 ;i++){
        for(j=0;j<c1;j++){
            
            scanf("%d",&num[i][j]);
            printf("%d ",num[i][j]);
            rsam += num[i][j];
            
        }
        num[i][c1] = rsam;
        printf("%d",rsam);
        rsam = 0;
        printf("\n");
    }
    
    for(i=0;i<r1 ;i++){
        for(j=0;j<c2;j++){
            if(i == 0){
                csum[j] = 0;                
            }
            csum[j] += num[i][j]; 
        }
    }
    
    for(i=0;i<c2;i++){
        printf("%d",csum[i]);
        if(i != c1){
            printf(" ");
        }
    }
        printf("\n");
return 0;
 }

 

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

int main(){
  int N, M, a, b, i;
    cin >> N >> M;
  vector<int> road(N);
    for(i=0; i<M; i++){
     cin >> a >> b;
      road.at(a-1)++;
      road.at(b-1)++;
    }
  
  for (i=0; i<N; i++){
    cout << road.at(i) << endl;
  }
    
}
       


Measured memory_bytes: 256
#include<iostream>
int main()
{
	int n;
	std::cin >> n;
	int i = 1;
	while(true)
	{
		static int x;
		static bool is_exe_CN = true, is_exe_I3, is_exe_ECN;
		if(is_exe_CN)
		{
			x = i;
			if(x % 3 == 0)
			{
				std::cout << ' ' << i;
				is_exe_I3 = false;
				is_exe_ECN = true;
			}
			else
			{
				is_exe_I3 = true;
			}
		}
		if(is_exe_I3)
		{
			if(x % 10 == 3)
			{
				std::cout << ' ' << i;
				is_exe_ECN = true;
			}
			else
			{
				x /= 10;
				if(x)
				{
					is_exe_ECN = false;
					is_exe_CN = false;
					is_exe_I3 = true;
				}
				else
				{
					is_exe_ECN = true;
				}
			}
		}
		if(is_exe_ECN)
		{
			if(++i <= n)
			{
				is_exe_CN = true;
			}
			else
			{
				std::cout << std::endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3080
#include<iostream>
#define rep(i,n) for(int i=0; i<n; ++i)
using namespace std;

int coin[] = {10,50,100,500};
int main(){
  int a[4],b[4],k,c,s=1;
  while(cin >> c,c){
    if(s!=1)cout << endl;
    s =-c;
    rep(i,4)cin >> b[i],s+=b[i]*coin[i],a[i]=0;
    rep(i,4)while(s>=coin[3-i])s-=coin[3-i],++a[3-i];
    rep(i,4){
      k=b[i]-a[i];if(k>0)cout << coin[i] << " " << k << endl;
    }
  }
  return 0;
}



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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int left = min(A, B);
    int right = max(A, B);
    if ((left < C) && (right > C)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#-------------
N = int(input())
A = list(map(int, input().split()))
#-------------

kabu = 0
money = 1000
for i in range(N-1):
  if A[i] < A[i+1]:
    mod,money = divmod(money , A[i])
    kabu += mod
  if A[i] > A[i+1]:
    money = money + A[i] * kabu
    kabu = 0

money = money + A[N-1]*kabu
print(money)

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

int main(){
    int a,b;
    char op;
    
    while(1){
        cin >> a >> op >> b;
        if(op=='?')break;
        
        if(op=='+')cout << a + b << endl;
        else if(op=='-')cout << a - b << endl;
        else if(op=='*')cout << a * b << endl;
        else if(op=='/')cout << a / b << endl;
    }

    return 0;
}


Measured memory_bytes: 3088
#include<map>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(s...)  fprintf(stderr, s)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }

struct Node {
    int mark;
    map<char, Node*> next;
    Node *cut;
    int cnt, sup, depth;
    Node() {
	mark = -1;
	cut = NULL;
	cnt = 0;
	sup = 0;
	depth = 0;
    }
};

Node node[1000000];
int node_i;
void init_trie() {
    node[0] = Node();
    node_i = 1;
}

Node *leaf[100111];

void insert_trie(const string &s, int mark=-1) {
    Node *x = &node[0];
    for (int i=0; i<(int)s.size(); i++) {
	x->cnt++;
	char c = s[i];
	if (x->next.count(c) == 0) {
	    node[node_i] = Node();
	    x->next[c] = &node[node_i];
	    x->next[c]->depth = x->depth + 1;
	    node_i++;
	}
	x = x->next[c];
    }
    x->mark = mark;
    x->cnt++;
    x->sup++;
    leaf[mark] = x;
}

void bfs() {
    REP (i, node_i) {
	Node *x = node + i;
	if (x->next.size() == 1u) {
	    x->next.begin()->second->cut = x->cut;
	} else if (x->next.size()) {
	    EACH (e, x->next) 
		e->second->cut = x;
	}
	EACH (e, x->next) 
	    e->second->sup += x->sup;
    }
}

bool find_trie(const string &s) {
    Node *x = &node[0];
    for (int i=0; i<(int)s.size(); i++) {
	char c = s[i];
	if (x->next.count(c) == 0) return false; // match s[0..i-1]
	x = x->next[c];
    }
    // match x->mark;
    return true;
}

int N, Q;
string S[100111];
char buf[400111];
int ord[26];


int main() {
    init_trie();

    scanf("%d", &N);
    REP (i, N) {
	scanf("%s", buf);
	S[i] = buf;

	insert_trie(S[i], i);
    }

    bfs();

    scanf("%d", &Q);
    REP ($, Q) {
	int K;
	scanf("%d%s", &K, buf);
	K--;
	REP (i, 26) ord[buf[i] - 'a'] = i;

	Node *cur = leaf[K];
	int ans = cur->sup - 1;

	while (true) {
//	    eprintf("dep %d\n", cur->depth);
	    cur = cur->cut;
	    if (cur == NULL) break;
	    EACH (e, cur->next) {
		if (ord[e->first - 'a'] < ord[S[K][cur->depth] - 'a']) {
		    ans += e->second->cnt;
		}
	    }
	}

	printf("%d\n", ans+1);
    }


    return 0;
}



Measured memory_bytes: 105088
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
using vs = vector<string>; using tll = tuple<ll, ll, ll>; using vtll = vector<tll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define co(i) cout << i << endl;
#define co2(i,j) cout << i << " " << j << endl;
#define co3(i) cout << i << " ";
#define po(i) cout << i.first << " " << i.second << endl;
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop, bitSearch, bitList, nod, digitDP, treeDP//
//gcdlcm, isPrime, eratos, primeFactorize, Npow, combination, divisor, modinv, doubling//
//dfs, bfs, dijkstra, WarshallFloyd, BellmanFord, UnionFind, Kruskal, RMQ, LCA//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007, INF = 1LL << 60, ans = 0, z = 0, o = 1;
vl flag, D; vll path;
//***********//
int main() {
	cin >> N;
	vl A(N);
	for (i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());
	ll P = A[0];
	ll Q = A[1];
	ll R = A[1];
	ans += A[0];
	N -= 2;
	ll num = 1;
	ll count = 0;
	while (N > 0) {
		ans += A[num];
		count++;
		if (count == 2) {
			num++;
			count = 0;
		}
		N--;
	}
	co(ans);
}

Measured memory_bytes: 4828
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	n := oneInt()
	s := oneStr()

	ans := calc(s, n)
	fmt.Println(ans)
}

func calc(s string, n int) int {
	currentDot := 0
	for _, k := range s {
		if string(k) == "." {
			currentDot += 1
		}
	}

	ans := currentDot

	currentSharp := 0
	for _, k := range s {
		if string(k) == "." {
			currentDot -= 1
		} else {
			currentSharp += 1
		}

		//fmt.Printf("dot: %d, sharp: %d\n", currentDot, currentSharp)

		ans = min(ans, currentDot+currentSharp)
	}

	return ans
}

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func cumSum(nums []int) []int {
	sums := []int{0}

	for i := 0; i < len(nums); i++ {
		sums = append(sums, sums[i]+nums[i])
	}
	return sums
}


Measured memory_bytes: 2048
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int n = sc.nextInt();
		int [][] array = new int [n + 1][n + 1];
		int [] kei = new int [n + 1];
		int a,b,c,d;
		int x = n * (n - 1) / 2;
		for (int i = 0; i < x; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			d = sc.nextInt();
			if(c > d){
				array[a][b] = 3;
				array[b][a] = 0;
			}
			else if(c < d){
				array[a][b] = 0;
				array[b][a] = 3;
			}
			else if(c == d){
				array[a][b] = 1;
				array[b][a] = 1;
			}
		}
		
		for(int i = 1; i <= n; i++) {
			kei[i] = 0;
			for(int j = 1; j <= n; j++) {
				kei[i] += array[i][j];
			}
		}
		for(int i = 1; i <= n; i++) {
			int counter = 1;
			for(int j = 1; j <= n; j++) {
				if(kei[i] != kei[j]){
					if(kei[i] < kei[j]){
						counter++;
					}
				}
			}
			System.out.println(counter);
		}
	}

}

Measured memory_bytes: 42112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	int A,B,K;
	cin>>A>>B>>K;
	vector<bool> f(INF);
	rep(i,K)f[A+i]=true;
	rep(i,K){
		if(B-K+1+i>=0)
		f[B-K+1+i]=true;
	}
	for (int i = A; i <= B; ++i){
		if(f[i])cout<<i<<endl;
	}
}

Measured memory_bytes: 122368
N, A = gets.split.map(&:to_i)
x = [0] + gets.split.map(&:to_i)

X = (x + [A]).max

dp = Array.new(N + 1) do
  Array.new(N + 1) do
    Array.new(N * 50 + 1, 0)
  end
end

dp[0][0][0] = 1

(1..N).each do |j|
  (0..j).each do |k|
    (0..(N*X)).each do |s|
      dp[j][k][s] = case
                    when k == 0 && s == 0
                      1
                    when k == 0 || s == 0
                      0
                    when s < x[j]
                      dp[j-1][k][s]
                    when k >= 1 && s >= x[j]
                      dp[j-1][k][s] + dp[j-1][k-1][s-x[j]]
                    end
    end
  end
end

p (1..N).map { |k| dp[N][k][k*A] }.inject(:+)


Measured memory_bytes: 54652
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M;
  cin>>N>>M;
  vector <set<int>> A(N);
  for(int i=0;i<N;i++){
    set<int> a;
    int K;
    cin>>K;
    for(int j=0;j<K;j++){
    int c;
      cin>>c;
      a.insert(c);
      
    }A.at(i)=a;
  
  }int ans=0;
  for(int i=1;i<=M;i++){
  bool x=true;
    for(int j=0;j<N;j++){
     if(!A.at(j).count(i)){
      x=false; break;
     }
    }  if(x) ans++;
  
 } cout<<ans<<endl;
   
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

struct UnionFind{

    vector<ll> par;
    UnionFind(ll n) : par(n, -1){}
    

    int root(int x){
        if(par[x]<0) return x;
        return par[x] = root(par[x]);
    }

    bool same(int a, int b){
        return root(a)==root(b);
    }
    void unite(int a, int b){
        int x=root(a), y=root(b);
        if(same(x, y)) return;
        if(y<x) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
    int size(int x){
        return -par[root(x)];
    }

};

int main(){
    ll n, m;    cin >> n >> m;
    UnionFind tree(n);
    rep(i, m){
        ll a, b;    cin >> a >> b;
        a--, b--;
        tree.unite(a, b);
    }
    set<ll> res;
    rep(i, n) res.insert(tree.root(i));
    cout << res.size()-1 << endl;
}

Measured memory_bytes: 7944
import math,sys
s = list(raw_input())
if len(s) == 0:
    print "Yes"
    sys.exit()
if s.count("N") == s.count("S") == 0:
    if "E" in s and "W" in s:
        print "Yes"
        sys.exit()
if s.count("E") == s.count("W") == 0:
    if "N" in s and "S" in s:
        print "Yes"
        sys.exit()
if "W" in s and "E" in s and "N" in s and "S" in s:
    print "Yes"
    sys.exit()
print "No"

Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int main() { IO;
  int a, b, t;
  cin >> a >> b >> t;

  cout << (t / a) * b << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
const int N = 10;
int x[N], y[N], n;

double dist (int i, int j) {
	return hypot(x[i] - x[j], y[i] - y[j]);
}

double calc (const vi& p) {
	double res = 0;
	Foz(i, sz(p) - 1) {
		res += dist(p[i], p[i + 1]);
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	cin >> n;
	Foz(i, n) cin >> x[i] >> y[i];
	vi p;
	Foz(i, n) p.pb(i);
	int cnt = 0;
	double len = 0;
	do {
		len += calc(p);
		cnt++;
	} while (next_permutation(all(p)));
	cout << fixed << setprecision(17);
	cout << len / cnt << '\n';
}



Measured memory_bytes: 384
L = input()
l = len(L)
mod = 10**9 + 7
ans = 1  # (0,0)

d = dict()


def modpow(x, n, mod):
    if x not in d:
        d[x] = [1]
    l = len(d[x])
    ret = d[x][-1]
    for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
    return(d[x][n])


ans = modpow(3, l, mod)

r = 0
count = 0

for i in range(l):
    if L[i] == '0':
        r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2
        ans -= r
        ans %= mod
    else:
        count += 1
print(ans)


Measured memory_bytes: 9188
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;

int main() {
  ll n, k;
  cin >> n >> k;

  ll sum[200002] = {0};
  sum[0] = 0;
  for (int i = 1; i <= n; i++) {
    sum[i] += i + sum[i-1];
  }


  ll ans = 1;
  for (int i = k; i <= n; i++) {
    ll l = sum[i-1];
    ll r = (sum[n] - sum[n-i]);
    ans = (ans + (r - l + 1)) % mod;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <algorithm>
#define INF 99999999
using namespace std;

int dp[51];

void make() {
  const int weight[6] = {2, 3, 5, 10, 12, 15};
  const int price[6] = {380, 550, 850,
			int(380*5*(1.0-0.2)+0.5),
			int(550*4*(1.0-0.15)+0.5),
			int(850*3*(1.0-0.12)+0.5)};
  dp[0] = 0;
  for(int w = 1; w <= 50; ++w) {
    dp[w] = INF;
    for(int i = 0; i < 6; ++i) {
      int p = w - weight[i];
      if(p < 0) continue;
      dp[w] = min(dp[w], price[i] + dp[p]);
    }
  }
}

main() {
  int W;
  make();
  while((cin >> W) && W) cout << dp[W/100] << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define MAX_N 51
using namespace std;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int m,n;
    cin>>n>>m;
    if(m<n){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;

int main(void) {
	double a, b, x;
	cin >> a >> b >> x;
	double ans;
	if (x <= a * a * b / 2) {
		ans = (double)180.0 / PI * atan((double)a * b * b / (2.0 * x));
	}
	else {
		ans = (double)180.0 / PI * atan((2.0 * b -(double) 2.0 * x / (a * a)) / a);
	}
	printf("%.12f",ans);
	return 0;
}


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

d = []
isheld = [0] * 26
for i in range(n):
    b = list(map(int, input().split()))
    d.append(b)
# print(d)

score = 0
minus = 0
for i in range(1, n + 1):
    s = int(input())
    s -= 1

    isheld[s] = i

    for j in range(26):
        score -= a[j] * (i - isheld[j])

    score += d[i - 1][s]
    print(score)


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

int main() {
  int n,m,x,j;
  cin >> n >> m >> x;
  vector<int> a(m);
  for(int i=0;i<m;i++){
    cin >> a.at(i);
  }
  for(int i=0;i<m;i++){
    if(a.at(i) >= x){
      j = i;
      break;
    }
  }
  
  int ans = min(j,m-j);
  cout << ans << endl;
}


Measured memory_bytes: 256
# A=gets.to_i
# B=gets.split.map(&:to_i)
# C=N.times.map{gets.to_i}
# D=N.times.map{gets.split.map(&:to_i)}
# S=gets.chomp
N=gets.to_i
W=gets.split.map(&:to_i)
sum=W.inject(:+)

l=sum
h=0
min=(l-h).abs
W.each do |i|
  l-=i
  h+=i
  min=[min,(l-h).abs].min
end

puts min

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

int n, a[20];

bool solve(int x, int y){
	if(y==0) return true;
	
	if(x==n) return false;
	
	bool ret = solve(x+1, y) || solve(x+1, y-a[x]);
	return ret;
}

int main(){
	scanf(" %d", &n);
	for(int i=0; i<n; ++i) scanf(" %d", &a[i]);
	
	int q;
	scanf(" %d", &q);
	for(int i=0; i<q; ++i){
		int m;
		scanf(" %d", &m);
	
		if(solve(0, m)) printf("yes\n");
		else printf("no\n");
	}
	
}



Measured memory_bytes: 3168
const main = (input) => {
  var S = input.trim();
  var isAYY=false,isBYY=false,isAMM=false,isBMM=false;

  var A = Number(S[0]+S[1]);
  var B = Number(S[2]+S[3]);

  if(A>=1 && A<=12){
    isAMM = true;
  }
  if(B>=1 && B<=12){
    isBMM = true;
  }
  if(isAMM && isBMM){
    console.log('AMBIGUOUS');
  }else if(isAMM){
    console.log('MMYY');
  }else if(isBMM){
    console.log('YYMM');
  }else{
    console.log('NA');
  }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


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

#define int long long

#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))
#define upp(a,b) upper_bound(all(a),(b))
#define fill(i,n) memset(i,n,sizeof(i)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
int cnt[101];
int ruiseki[101];

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<int> P;
void make_primes(int n)
{
	vector<bool> primes;

	primes.resize(n + 1, true);
	primes[0] = primes[1] = false;
	rep(i, 2, sqrt(n)) if (primes[i]) for (int j = 0; i * (j + 2) < n; j++)
		primes[i * (j + 2)] = false;

	rep(i, 2, n + 1) if (primes[i]) P.push_back(i);
}

signed main() {
    //IOS();
    COMinit();
    /*シフト演算は(1ll<<x)*/
    cin>>N;
    make_primes(N);
    rep(i,0,N){
        int x=(i+1);
    for(auto e:P){
        while(x%e==0){
            cnt[e]++;
            x/=e;
        }
    }
    }
    rep(i,0,N+1){
        //cout<<cnt[i]<<endl;
        if(cnt[i]>=74)ruiseki[75]++;
        if(cnt[i]>=24)ruiseki[25]++;
        if(cnt[i]>=14)ruiseki[15]++;
        if(cnt[i]>=4)ruiseki[5]++;
        if(cnt[i]>=2)ruiseki[3]++;
        
        
        
        
    }
    int ans=0;
    ans+=(ruiseki[3]-2)*COM(ruiseki[5],2);
    ans+=(ruiseki[3]-1)*ruiseki[25];
    ans+=(ruiseki[5]-1)*ruiseki[15];
    ans+=ruiseki[75];
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int n,tmp,ans;
char a[110000];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(a[i]=='I') tmp++;
		if(a[i]=='D') tmp--;
		ans=max(ans,tmp);
	}
	cout<<ans;
    return 0;
}
//开心又快乐

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int A,B,K;
    while(scanf("%d%d%d",&A,&B,&K)!=EOF)
    {
        if((B-A+1)<=K*2)
        {

            for(int i=A;i<=B;i++)
              cout<<i<<endl;
        }
        else
        {
           //if(K%2==0)
           //{
               for(int i=A;i<=A+K-1;i++)
                  cout<<i<<endl;
               for(int i=B-K+1;i<=B;i++)
                  cout<<i<<endl;
          // }
           /*else
           {
               for(int i=A;i<=A+K;i++)
                  cout<<i<<endl;
               for(int i=B-K+1;i<=B;i++)
                  cout<<i<<endl;
           }*/

        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

const int MAX = 300020;
ll fac[MAX], finv[MAX], inv[MAX];
int H, W, A, B;

void init()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; ++i)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll comb(int n, int k)
{
    if (n < k)
    {
        return 0;
    }
    else if (n < 0 || k < 0)
    {
        return 0;
    }
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// void init()
// {
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++)
//     {
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }

// // 二項係数計算
// ll comb(int n, int k)
// {
//     if (n < k)
//         return 0;
//     if (n < 0 || k < 0)
//         return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

int main()
{
    init();
    cin >> H >> W >> A >> B;
    ll ans = 0;
    for (int i = B; i < W; ++i)
    {
        // cout << H - A + i - 1 << " " << H - A - 1 << " " << A + W - i - 2 << " " << A - 1 << endl;
        ans += (comb(H - A + i - 1, H - A - 1) % MOD) * (comb(A + W - i - 2, A - 1) % MOD);
        // ans += comb(i + B - 1, i) * comb(H + W - B - 2, W - B - 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
}


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

int main() {
	long long l[100] = {0}, n; cin >> n;
	l[0] = 2; l[1] = 1;
	for (int i = 2; i <= 92; i ++) {
		if (i == 18)
			l[i] = l[11] + l[10];
		else if (i == 19)
			l[i] = l[18] + l[11];
		else 
			l[i] = l[i-1] + l[i-2]; 
	}
	if (n <= 11)
		cout << l[n] << endl;
	else 
		cout << l[n+6] << endl;
		
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv, std.algorithm.iteration, std.functional;

void main()
{
    auto _x = readln;
    auto s = readln.chomp;
    int x, max;
    foreach (c; s) {
        switch (c) {
            case 'I':
                if (++x > max) max = x;
                break;
            case 'D':
                --x;
                break;
            default:
        }
    }
    writeln(max);
}

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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const int MAXN = 1200;
int n;
int av[5100];
vector<int> eds[MAXN];
int p[MAXN];
int x[MAXN];
vector<int> vv;
pair<int, int> dp[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; ++i) {
		scanf("%d", p + i);
		--p[i];
		eds[p[i]].push_back(i);
	}
	for (int i = 0; i < n; ++i)
		scanf("%d", x + i);
	for (int i = n - 1; i >= 0; --i) {
		int sum = 0;
		vv.clear();
		int nd = x[i];
		for (int u: eds[i]) {
			sum += dp[u].first + dp[u].second;
			nd -= min(dp[u].first, dp[u].second);
			vv.push_back(abs(dp[u].first - dp[u].second));
		}
		if (nd < 0) {
			cout << "IMPOSSIBLE\n";
			return 0;
		}
		memset(av, 0, sizeof(av[0]) * (nd + 1));
		av[0] = 1;
		for (int i: vv) {
			for (int j = nd; j >= i; --j)
				if (av[j - i])
					av[j] = 1;
		}
		for (int j = nd; j >= 0; --j) {
			if (av[j]) {
				sum += nd - j;
				break;
			}
		}
		dp[i] = make_pair(x[i], sum - x[i]);
	}
	cout << "POSSIBLE\n";
	return 0;
}




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

using namespace std;

#define ll long long
int main()
{
	ll n,w,i,j;
	cin>>n>>w;
	ll val[n],weight[n];
	for(i=0;i<n;i++)
	{
		cin>>weight[i]>>val[i];
	}
	ll dp[n+1][w+1];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			if(i==0||j==0)
				dp[i][j]=0;
			else if(j>=weight[i-1])
			dp[i][j]=max(val[i-1]+dp[i-1][j-weight[i-1]],dp[i-1][j]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79104
#include <cstdio>

using namespace std;

bool test(int n)
{
	while ((n & 1) == 0)
		n >>= 1;
	return n > 1;
}

int main()
{
	int N;
	scanf("%d", &N);
	if (test(N) == false)
	{
		puts("No");
		return 0;
	}
	puts("Yes");
	printf("%d %d\n", 1, 2);
	printf("%d %d\n", 2, 3);
	printf("%d %d\n", 3, N + 1);
	printf("%d %d\n", N + 1, N + 2);
	printf("%d %d\n", N + 2, N + 3);
	for (int x = 4;x + 1 <= N;x += 2)
	{
		printf("%d %d\n", 1, x);
		printf("%d %d\n", x, x + 1);
		printf("%d %d\n", 1, (x + 1) + N);
		printf("%d %d\n", (x + 1) + N, x + N);
	}
	if ((N & 1) == 0)
	{
		for (int a = 2, b;a <= N;++a)
		{
			b = (N ^ 1 ^ a);
			if (1 <= b && b < N && a != b)
			{
				printf("%d %d\n", N, (a & 1) ? N + a : a), printf("%d %d\n", N + N, (b & 1) ? N + b : b);
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
    #include <vector>
    #include <set>
     
    using namespace std;
     
    int main(){
        int n, m;
        cin >> n >> m;
        set<int> toN;
        vector<int> fromzero;
     
        for(int i=0;i<m;i++){
            int a, b;
            cin >> a >> b;
            if(a == 1)
                fromzero.push_back(b-1);
            else if(b == n)
                toN.insert(a-1);
        }
        bool flag = false;
        for(auto c: fromzero){
            if(toN.count(c)){
                flag = true;
                break;
            }
        }
        cout << (flag?"POSSIBLE":"IMPOSSIBLE") << endl;
        return 0;
    }

Measured memory_bytes: 5368
# https://atcoder.jp/contests/abc085/tasks/abc085_d
from math import ceil
n, h = map(int, input().split())

cut = []
throw = []
for _ in range(n):
    a, b = map(int, input().split())
    cut.append(a)
    throw.append(b)
throw.sort(reverse=True)
MAX = max(cut)

attack = 0
for i in range(len(throw)):
    if throw[i] > MAX:
        h -= throw[i]
        attack += 1
    else:
        break
    if h <= 0:
        break

attack += max(0, ceil(h / MAX))
print(attack)


Measured memory_bytes: 61528
A,B,C = list(map(int,input().split()))
K = int(input())

ans = 0

for i in range(K):
    if A < B * (2**i) < C * (2**(K-i)):
        ans += 1
    else:
        pass

if ans > 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 79304
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>

using namespace std;

#define sz(X) ((int)(X).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()
#define FOR(i, a, n) for(int i=(a), __ ## i=(n); i<__ ## i; i++)
#define REP(I,N) FOR(I,0,N)
#define PR(X) cout<<#X<<" = "<<(X)<<" "
#define PRL cout<<endl
#define PRV(X) {cout<<#X<<" = {";REP(__prv,sz(X)-1)cout<<(X)[__prv]<<",";if(sz(X))cout<<*(X).end();cout<<"}"<<endl;}

template<class T> ostream &operator<<(ostream &os, const vector<T> &vec)
{
	os << '{';
	REP(i, sz(vec))
	{
		os << vec[i];
		if (i + 1 != sz(vec))
			os << ',';
	}
	os << '}';
	return os;
}

template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &par)
{
	os << '(' << par.X << ',' << par.Y << ')';
	return os;
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<unsigned long long> VULL;
typedef vector<vector<int>> VVI;
typedef queue<int> QI;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : abs(x);
}

template<class T> T sqr(T x)
{
	return x * x;
}

LL matr[500][500];

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

	int H, W, h, w;
	cin >> H >> W >> h >> w;

	if (H % h == 0 && W % w == 0)
		cout << "No";
	else
	{
		cout << "Yes" <<endl;
		for (int i = 0; i < H; i += h)
			for (int j = 0; j < W; j += w)
				matr[i][j] = 1000000000 - 1;

		for (int i = h-1; i < H; i += h)
			for (int j = w-1; j < W; j += w)
				matr[i][j] = -1000000000 ;

		REP(i, H)
		{
			REP(j, W)
				cout << matr[i][j] << ' ';
			cout << endl;
		}
	}

	return 0;
}

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

int main()
{
	int a, b, c;

	cin >> a >> b >> c; 

	if( a == b && a == c ){
		cout << "Yes" << endl; 
	} else {
		cout << "No" << endl; 
	}

	return 0;
}

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

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


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

using namespace std;

#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.length()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>())
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////
	int n;
	cin >> n;
	cout << (n*800)-((n/15)*200) << endl;

	
//////////////////////////////////////////////
}


Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int[] arr = new int[3];
         for(int i=0; i < 3; i++)
            arr[i] = Integer.parseInt(st.nextToken());
         Arrays.sort(arr);
         System.out.println(arr[0]+arr[1]);
      }
   }

Measured memory_bytes: 22484
#include<stdio.h>
#include<string.h>
#define SIZE 1001

int main(void)
{
    char tmp, str[SIZE], cmd[8], p[SIZE];
    int i, j, q, a, b;
    
    scanf("%s", str);
    scanf("%d", &q);
    
    for ( i=0; i<q; ++i) {
        scanf("%s %d %d", cmd, &a, &b);
        
        if ( strcmp(cmd, "replace") == 0) {
            scanf("%s", p);
            for ( j=a; j<=b; ++j)
                str[j] = p[j-a];
        }else if ( strcmp(cmd, "reverse") == 0) {
            for ( j=0; j<(b-a+1)/2; ++j) {
                tmp = str[a+j];
                str[a+j] = str[b-j];
                str[b-j] = tmp;
            }
        }else if ( strcmp(cmd, "print") == 0) {
            for ( j=a; j<=b; ++j)
                printf("%c", str[j]);
            putchar('\n');
        }
    }
    
    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main(){
    // while(true){
        cout<<fixed<<setprecision(10);
        string s;
        cin>>s;
        REP(i,s.size()-1){
            if(s[i]==s[i+1]){
                cout<<"Bad";
                return 0;
            }
        }
        cout<<"Good";
    // }
    return 0;
}

Measured memory_bytes: 256