akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    while(true) {
        int a,b;
        cin >> a >> b;
        if(a == 0 && b == 0) break;
        int ans = 0;
        for(int i = 1; i <= a; i++) {
            for(int j = 1; j < i; j++) {
                for(int k = 1; k < j; k++) {
                    if(i+j+k==b) ans++;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  char I;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> I;
    if(I == 'Y'){
      cout << "Four" << endl;
      N = -1;
      break;}
  }
  if(N != -1) cout << "Three" << endl;
}
    
    

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

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

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

int main() {
    vector<int> A(5);
    for (int i = 0; i < 5; i++) cin >> A[i];
    for (int i = 0; i < 5; i++) {
        if (A[i] == 0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0;
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	REP(i, s.size() + 2) {
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
		else {
			s = s.substr(1, s.size() - 1) + s[0];
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int g[21][21];
int dy[4] = {1,0,-1,0};
int dx[4] = {0,1,0,-1};

int main()
{
	while(1) {
		int n, m;
		cin >> n;
		if (!n) break;
		memset(g, 0, sizeof(g));
		rep(i,0,n) {
			int a, b; cin >> a >> b;
			g[a][b]++;
		}

		cin >> m;
		int tx = 10, ty = 10;
		int cnt = 0;
		rep(i,0,m) {
			char a;
			int b; 
			cin >> a >> b;
			int d;
			if (a == 'N') d = 0;
			else if (a == 'E') d = 1;
			else if (a == 'S') d = 2;
			else if (a == 'W') d = 3;
			rep(j,0,b) {
				tx += dx[d];
				ty += dy[d];
				if (g[tx][ty]) {
					cnt++;
					g[tx][ty]--;
				}
			}
		}
		if (cnt == n) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
n, m = map(int, input().split())
inf = 10**8+1
dp = [inf]*(2**n)
dp[-1] = 0
for _ in range(m):
    a, b = map(int, input().split())
    c = sum(2**(i-1) for i in map(int, input().split()))
    for j in range(len(dp)):
        dp[j] = min(dp[j], a+dp[j|c])
if dp[0] == inf:
    print(-1)
else:
    print(dp[0])

Measured memory_bytes: 48984
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

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


using namespace std;



int main()
{
    
    double a;
    cin >> a;
    double b = a / 3;
    cout << setprecision(20);
    cout << b * b * b << endl;
    
    return 0;

}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io;

fn min2(x: i32, y: i32) -> i32 {
    if x <= y {
        x
    } else {
        y
    }
}

fn max2(x: i32, y: i32) -> i32 {
    if x >= y {
        x
    } else {
        y
    }
}

fn main() {
    let stdin = io::stdin();
    let mut stdin = io::BufReader::new(stdin.lock());

    let mut tmp = String::new();
    stdin.read_line(&mut tmp).unwrap();
    let _: i32 = tmp.trim().parse().unwrap();

    tmp.clear();
    stdin.read_line(&mut tmp).unwrap();
    let data: Vec<i32> = tmp.split_whitespace()
                            .map(|x| x.parse::<i32>().unwrap())
                            .collect();

    let mut dt = [0; 13];
    for v in data {
        dt[v as usize] += 1;
    }
    if dt[0] >= 1 || dt[12] >= 2 {
        println!("0");
        return;
    }
    for &x in &dt {
        if x >= 3 {
            println!("0");
            return;
        }
    }

    let mut ans = 0;
    for i in 0..(1 << 11) {
        let mut dd = [false; 24];
        dd[0] = true;
        for (x, &y) in dt.iter().enumerate() {
            if y == 1 && (x == 0 || x == 12) {
                dd[x] = true;
            } else if y == 2 {
                dd[x] = true;
                dd[24 - x] = true;
            } else if y == 1 {
                if (i >> (x - 1)) & 1 != 0 {
                    dd[x] = true;
                } else {
                    dd[24 - x] = true;
                }
            }
        }

        let mut start: i32 = -1;
        let mut last: i32 = -1;
        let mut min_gap: i32 = 24;
        for (x, &y) in dd.iter().enumerate() {
            if !y {
                continue;
            }
            if start == -1 {
                start = x as i32;
            } else {
                min_gap = min2(min_gap, x as i32 - last);
            }
            last = x as i32;
        }
        min_gap = min2(min_gap, (start + 24) - last);
        ans = max2(ans, min_gap);
    }

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


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

int main()
{
    int n;
    cin>>n;
    vector<int> x(n),y(n),h(n);
    int i,j,k;
    int height;
    bool s;
    int ansx,ansy,ansh;
    int check;
    for(i = 0; i < n; i++)cin>>x.at(i)>>y.at(i)>>h.at(i);
    for(i = 0; i < n; i++)
    {
        if(h.at(i)>0)
        {
            check = i;
            break;
        }
    }
    for(i = 0; i <= 100; i++)
    {
        for(j = 0; j <= 100; j++)
        {
            height = abs(x.at(check)-i)+abs(y.at(check)-j)+h.at(check);
            s = true;
            for(k = 0; k < n; k++)
            {
                if(h.at(k) != max(height-abs(x.at(k)-i)-abs(y.at(k)-j),0))
                {
                    s = false;
                    break;
                }    
            }
            if(s)
            {
                ansx = i;
                ansy = j;
                ansh = height;
                break;
            }
        }
        if(s)break;
    }
    cout << ansx << ' ' << ansy << ' ' << ansh << endl;
}

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

int main()
{
  int n,max_sum=INT_MAX;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  int min=arr[0];
  int max=arr[n-1];
  //cout<<min<< " "<<max<<endl;
  for(int i=min;i<=max;i++)
  {
      int sum=0;
    for(int j=0;j<n;j++){
    sum+=(arr[j] - i)*(arr[j] - i);
    }
   // cout<<sum<<endl;
      if(sum<max_sum)
        max_sum=sum;
  }
  cout<<max_sum<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repf(i, j, n) for (int i = (j); i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)

signed main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  rep(i, n) cin >> a[i + 1];
  for (int i = n; i >= 1; i--) {
    int s = 0;
    for (int j = 1; j <= n / i; j++) {
      s += a[i * j];
    }
    a[i] = s % 2;
  }
  int t = 0;
  for (int i = 1; i <= n; i++) t += a[i];
  cout << t << endl;
  if (t == 0) exit(0);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (a[i] == 1) {
      cout << i;
      cnt++;
      if (cnt < t) cout << " ";
    }
  cout << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
int main(void)
{
  int a[3][3];
  for(int i = 0; i != 3; i++)
    for(int j = 0; j != 3; j++)
      std::cin >> a[i][j];
  if(a[1][0] - a[0][0] == a[1][1] - a[0][1] && a[1][1] - a[0][1] == a[1][2] - a[0][2]
     && a[2][0] - a[1][0] == a[2][1] - a[1][1] && a[2][1] - a[1][1] == a[2][2] - a[1][2]
     && a[0][1] - a[0][0] == a[1][1] - a[1][0] && a[1][1] - a[1][0] == a[2][1] - a[2][0]
     && a[0][2] - a[0][1] == a[1][2] - a[1][1] && a[1][2] - a[1][1] == a[2][2] - a[2][1])
    std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
e = [int(input()) for _ in range(m)]
b = [1] * (n+1)
for v in e[::-1]:
    if b[v]:
        b[v] = 0
        print(v)
for i in range(1, n+1):
    if b[i]:
        print(i)

Measured memory_bytes: 14164
N, K = map(int, input().split())
ABs = []
for i in range(N):
  A, B = map(int, input().split())
  ABs.append((A, B))
fs = [K]
for i in range(32):
  if K&(1<<i) != 0:
    f = (K^(1<<i))|((1<<i)-1)
    fs.append(f)
rs = []
for f in fs:
  r = 0
  for A, B in ABs:
    if f|A == f:
      r += B
  rs.append(r)
r = max(rs)
print(r)


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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  vi a(n);
  vi b(m);
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  vl ca(n + 1);
  vl cb(m + 1);
  rep(i, n) ca[i + 1] = ca[i] + a[i];
  rep(i, m) cb[i + 1] = cb[i] + b[i];
  dump(ca);
  dump(cb);
  int mx = 0;
  rep(i, n + 1) {
    if (k < ca[i]) continue;
    int rm = k - ca[i];
    int j = upper_bound(cb.begin(), cb.end(), rm) - cb.begin();
    if (j == 0) continue;
    dump(i, ca[i], rm, j - 1);
    mx = max(mx, i + j - 1);
  }
  cout << mx << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 7940
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
bool a[100][100];
int main() {
	int n;
	while (cin >> n&&n != 0) {
		int h, w, x, y, s, t;
		cin >> w >> h;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) a[i][j] = false;
		}
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			x--;y--;
			a[y][x] = true;
		}
		cin >> s >> t;
		int sum2 = 0;
		for (int i = 0; i < h - t+1; i++) {
			for (int j = 0; j < w - s+1; j++) {
				int sum = 0;
				for (int x = 0; x < t; x++) {
					for (int y = 0; y < s; y++) {
						if (a[i + x][j + y]) sum++;
					}
				}
				sum2 = max(sum, sum2);
			}
		}
		cout << sum2 << endl;
	}
}

Measured memory_bytes: 3036
import random as rng
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)


def dump_impl(*objects):
    print(*objects, file=sys.stderr)


def dump_dummy(*objects):
    pass


dump = dump_impl if "DEBUG" in sys.argv else dump_dummy

a, b, c = map(int, input().split())
# dump(S)
cab = c-a-b
ab4 = 4*a*b
print("Yes" if (cab >= 0 and ab4 < cab*cab) else "No")


Measured memory_bytes: 4592
/*
 * atcoder/abc117_2nd/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 * f(x) = (x xor a_1) + (x xor a_2) + ... + (x xor a_N)
 *
 * a_1 = 0000011111110000
 * a_2 = 0101010101010010
 * a_N = 0001000010101001
 *
 * ① x<=Kという制約がなければ各桁ごとの0と1を数えて、1が多ければ0、0が多ければ1（最大値を求めたいので0より1にしたい）.
 *
 * x<=Kという制約は、通常の桁DPと同じように取り扱えば良い.
 * つまり、各桁を見る際にすでにx<=Kが確定しているかのフラグを持っておく.
 * i)  x<=K 確定済みの場合: 0 or 1 どちらもOK. ① で決める.
 * ii) x<=K 未確定で、かつKのn桁目が0の場合: 0のみ
 * iii) x<=K 未確定で、かつKのn桁目が1の場合:
 *    iii.i) 1を取って未確定.
 *    iii.ii) 0を取ってx<=K確定
 */
const int MAX = 41;
ll N, K;
vector<ll> A;
ll dp[MAX][2];

void solve() {
  cin >> N >> K;
  A.resize(N);
  loop(n,0,N) cin >> A[n];

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

  dp[40][0] = 0;
  for (int n=39; n>=0; n--) {
    ll D = (1LL<<n);
    ll num1 = 0;
    for (auto&&a: A) {
      num1 += (a>>n)&1;
    }
    ll num0 = N-num1;

    // i)
    if (dp[n+1][1] >= 0) {
      chmax(dp[n][1], dp[n+1][1] + D * max(num1, num0));
    }

    if (dp[n+1][0] < 0) continue;

    ll k = (K>>n)&1;
    if (k==1) {
      // iii.i)
      chmax(dp[n][1], dp[n+1][0] + D * num1);
      // iii.ii)
      chmax(dp[n][0], dp[n+1][0] + D * num0);
    }
    else {
      // ii)
      chmax(dp[n][0], dp[n+1][0] + D * num1);
    }
  }
  cout << max(dp[0][0], dp[0][1]) << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct{int p, l, r;}; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u){
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if(T[u].p == NIL) printf("root, ");
  else if(T[u].l == NIL) printf("leaf, ");
  else printf("internal node, ");
  
  printf("[");
  for (i=0, c = T[u].l; c != NIL; i++, c = T[c].r){
    if(i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
  
}

void calcDepth(int u, int p){
  D[u] = p;
  if(T[u].l != NIL) calcDepth(T[u].l,p+1);
  if(T[u].r != NIL) calcDepth(T[u].r,p);
}

int main(){
  int i, j, k;
  int n;
  int id, sib, child;
  int root = NIL;
  scanf("%d", &n);
  for(i=0; i<n; i++) T[i].p = T[i].l = T[i].r = NIL;
  
  for(i=0; i<n; i++){
    scanf("%d %d", &id, &k);
    for(j = 0, sib = NIL; j<k; j++){ //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if(j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for(i=0; i<n; i++){
    if(T[i].p == -1) root = i;
  }
  
  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for(i=0; i<n; i++) print(i);
  
  return 0;
}



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

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

  for (int i = 0; i < n; i++) {
    int tmp1, tmp2; cin >> tmp1 >> tmp2;
    if (tmp1 % tmp2 == 0) {
      cout << tmp2 << endl;
    } else {
      cout << tmp1 % tmp2 << endl;
    }
  }
}

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

int gcd(int x, int y){
    if (y == 0) return x;
    return gcd(y, x % y);
}

int main(){
    int n;
    cin >> n;
    int ans = 0;
    int x;
    for (int i = 0; i < n; i++){
        cin >> x;
        ans = gcd(x, ans);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

int n;

struct point {
    ld x, y;
};

vector<point> p;

ld dis(point a, point b) {
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

// f(x, y) := 中心を(x, y)としたときの最大距離
ld f(ld x, ld y) {
    ld res = 0;
    rep(i, n) {
        chmax(res, dis(p[i], point{x, y}));
    }
    return res;
}

// g(x) := xを固定した時の最適解
ld g(ld x) {
    ld l = 0, r = 1000;
    int cnt = 100;
    while(cnt--) {
        ld c1 = (l*2+r)/3;
        ld c2 = (l+2*r)/3;
        if(f(x, c1) > f(x, c2)) l = c1;
        else r = c2;
    }
    return f(x, l);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    p = vector<point>(n);
    rep(i, n) cin >> p[i].x >> p[i].y;
    ld l = 0, r = 1000;
    int cnt = 100;
    while(cnt--) {
        ld c1 = (l*2+r)/3;
        ld c2 = (l+2*r)/3;
        if(g(c1) > g(c2)) l = c1;
        else r = c2;
    }
    cout << fixed << setprecision(20) << g(l) << endl;
}

Measured memory_bytes: 3864
#include <iostream>

int main(){
    int n, d, x;
    std::cin >> n >> d >> x;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int tmp;
        std::cin >> tmp;
        ans += ((d-1)/tmp + 1);
    }
    std::cout << ans + x << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
int main(void){
  int n,l;
  cin>>n>>l;
  vector<string> s(n);
  rep(i,n)cin>>s[i];
  sort(s.begin(),s.end());
  rep(i,n)cout<<s[i];
  cout<<endl;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let k: u128 = sc.cin();
    let mut md = k;
    for i in 1..10000000 {
        md = (10 * md + 7) % k;
        if md == 0 {
            put!(i);
            return;
        }
    }
    put!(-1);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            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));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  int a[n + 5];
  rep(i, n){
    cin >> a[i];
  }
  lol money = 1000, memo, kabu = 0;
  rep(i, n - 1){
    if(a[i] < a[i + 1]){
      kabu += money / a[i];
      money %= a[i];
    }
    if(a[i] > a[i + 1]){
      money += kabu * a[i];
      kabu = 0;
    }
  }
  money += a[n - 1] * kabu;
  cout << money << '\n';
  return 0;
}


Measured memory_bytes: 3564
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	bool N = false, W = false, S = false, E = false;
	string s; cin >> s;
	for (char c: s) {
		if (c == 'N') N = true;
		if (c == 'W') W = true;
		if (c == 'S') S = true;
		if (c == 'E') E = true;
	}
	if (N + S == 1 || W + E == 1) cout << "No" << endl;
	else cout << "Yes" << endl;
}


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

using namespace std;

//typedef long long ll;
typedef __int128_t ll;

bool isPrime(ll n) {
	if (n == 1) return false;
	if (n == 2) return true;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i == 0) return false;
	}
	return true;
}

ll p(int n) {
	ll a = 1 << n;
	for (int i = a+1;; ++i) {
		if ( isPrime(i) ) {
			return i;
		}
	}
	return -1;
}

ll solve(int n) {
	ll k = p(n)-1;
	ll j = 0;
	for (int i = 0; i < k; ++i) {
		j *= 10;
		++j;
	}
	return j % (k+1);
}

int main() {
	int n; cin >> n;
	if (n == 0) cout << 1 << endl;
	else if (n == 1) cout << 2 << endl;
	else if (n == 2) cout << 1 << endl;
	else cout << 0 << endl;
//	for (int i = 0; i < 10; ++i) {
//		cout << (long long)solve(i) << endl;
//	}
}

Measured memory_bytes: 1164
import sys
from collections import deque
input = sys.stdin.readline        

def main():

    def loopfind():
        for i in range(N):
            if USE[i]==1:
                break
        else:
            return []
        
        Q=deque()
        Q.append(i)
        USESET={i}
        ANS=[i]

        while True:
            for to in EOUTLIST[ANS[-1]]:
                if USE[to]==1:
                    nextv=to
                    break

            if nextv in USESET:
                break
            else:
                ANS.append(nextv)
                USESET.add(nextv)

        x=ANS.index(nextv)
        return ANS[x:]

    def shortcut(ANS):
        #print(ANS)

        ANSSET=set(ANS)
        LEN=len(ANS)
        flag=0

        for i in range(LEN):
            for to in EOUTLIST[ANS[i]]:
                if to in ANSSET and ANS[(i+1)%LEN]!=to:
                    flag=1
                    x=ANS.index(to)

                    #print(ANS,i,x)

                    break
            if flag:
                break
        #print(flag)

        if flag:
            if x<i:
                return shortcut(ANS[x:i+1])
            else:
                return shortcut(ANS[x:]+ANS[:i+1])

        else:
            return ANS
    
    N,M=map(int,input().split())

    EIN=[0]*N
    EOUT=[0]*N

    EINLIST=[[] for i in range(N)]
    EOUTLIST=[[] for i in range(N)]

    for i in range(M):
        x,y=map(int,input().split())
        x-=1
        y-=1

        EOUT[x]+=1
        EIN[y]+=1

        EOUTLIST[x].append(y)
        EINLIST[y].append(x)

    Q=deque()
    USE=[1]*N

    for i in range(N):
        if EIN[i]==0 or EOUT[i]==0:
            Q.append(i)
            USE[i]=0

    while Q:
        x=Q.pop()

        for to in EOUTLIST[x]:
            if USE[to]==0:
                continue
            EIN[to]-=1
            if EIN[to]==0:
                Q.append(to)
                USE[to]=0

        for fr in EINLIST[x]:
            if USE[fr]==0:
                continue
            EOUT[fr]-=1
            if EOUT[fr]==0:
                Q.append(fr)
                USE[fr]=0

    ANS=shortcut(loopfind())
    if len(ANS)==0:
        print(-1)
    else:
        print(len(ANS))
        for ans in ANS:
            print(ans+1)

main()

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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int i,j,k,count,maxcount;
  maxcount = count = 0;
  string s;
  cin >> s;
  
  for(i=0;i<s.size();i++){
  	for(j=s.size();j>0;j--){
      count = 0;
      for(k=i;k<j;k++){
      	if(s.at(k) == 'A' || s.at(k) == 'C' || s.at(k) == 'G' || s.at(k) == 'T'){
      	  count++;
          if(maxcount < count) maxcount = count;
        }else break;
      }
    }
  }
  cout << maxcount << endl;
}

Measured memory_bytes: 256
N = int(raw_input())
A = map(int, raw_input().split(' '))
B = map(int, raw_input().split(' '))
C = map(int, raw_input().split(' '))

satisfied = 0
for i in range(0, N):
    i_food = A[i]
    satisfied += B[i_food - 1]
    if i > 0:
        i_food_prev = A[i - 1]
        if i_food - i_food_prev == 1:
            satisfied += C[i_food_prev - 1]

print satisfied


Measured memory_bytes: 2568
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.container;
import std.array;
import std.math;
import std.range;
import std.typecons;
import std.ascii;
import std.format;

void main()
{
  auto a = readln.chomp.split.map!(to!int);
  auto h = a[0];
  auto w = a[1];
  char[][] map = new char[][](h + 2, w + 2);
  foreach (ref arr; map) {
    arr[] = '.';
  }
  foreach (i; 0..h) {
    auto s = readln;
    foreach (j; 0..w) {
      map[i + 1][j + 1] = s[j];
    }
  }
  for (int i = 1; i <= h; ++i) {
    for (int j = 1; j <= w; ++j) {
      if (map[i][j] == '#') {
        write = '#';
        continue;
      }
      int cnt = 0;
      for (int dx = -1; dx <= 1; ++dx) {
        for (int dy = -1; dy <= 1; ++dy) {
          cnt += map[i + dy][j + dx] == '#';
        }
      }
      cnt.write;
    }
    writeln;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    string str;
    int n;
    cin>>n;
    getline(cin,str);
    for(int i=0;i<n;i++){
        getline(cin,str);
        for(int j=0;j<str.size();j++){
            if(str[j]=='o'){
                if(str[j-1]=='n'){
                    if(str[j-2]=='i'){
                        if(str[j-3]=='h'){
                            if(str[j-4]=='s'){
                                if(str[j-5]=='o'){
                                    if(str[j-6]=='H'){
                                        str[j]='a';
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        for(int i=0;i<str.size();i++){
            if(i==str.size()-1){
                cout<<str[i]<<endl;
            }else cout<<str[i];
        }
    }
    return 0;
}

Measured memory_bytes: 3180
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s=in.next();
		for(int i=0;i<s.length();i++)
		{
			if((i+1)%2!=0)
			{
				if(s.charAt(i)!='R' && s.charAt(i)!='U' && s.charAt(i)!='D')
				{
					System.out.println("No");
					System.exit(0);
				}
			}
			else if((i+1)%2==0)
			{
				if(s.charAt(i)!='L' && s.charAt(i)!='U' && s.charAt(i)!='D')
				{
					System.out.println("No");
					System.exit(0);
				}
			}
		}
		System.out.println("Yes");
	}
}


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

int main() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> xv(n);
  vector<int> yv(m);
  for (int i = 0; i < n; i++) cin >> xv[i];
  for (int i = 0; i < m; i++) cin >> yv[i];
  sort(xv.begin(), xv.end());
  sort(yv.begin(), yv.end());

  if (x < xv[n - 1] && xv[n - 1] < yv[0] && yv[0] <= y)
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
	const int N = 100000;

	int n;
	long long a[N];
	long long x[N] = { 0LL };

	scanf("%d", &n);

	for(int i = 0; i < n; ++i)
	{
		scanf("%lld", &a[i]);
	}

	int sign = 1;
	for(int i = 0; i < n; ++i)
	{
		x[0] += a[i] * sign;
		sign *= -1;
	}

	for(int i = n - 1; i > 0; --i)
	{
		x[i] = 2 * a[i] - x[(i + 1) % n];
	}

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

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

chk = False
chk1 = True
bis = 5
ans = 0
if (n % 2 ==1) or (n<10):
    print(0)

else:
    #while chk == False:
    #    if list(str(n))[-1] == "0":
    #        chk = True
    #    else:
    #        n -=2
            
    while n > bis:
        
        ans += n // (bis*2)
        bis = bis *5

        
        
    print(ans)

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	string s; cin >> s;
	int K; cin >> K;
	set<string> solve;
	repp(i,0,s.size()) repp(j,1,6) solve.insert(s.substr(i,j));
	auto ans = solve.begin();
	repp(i,1,K) ++ans;
	cout << *ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define It set<node>::iterator
#define endl '\n'
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=3e6+10;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;

int r1,c1,r2,c2,ans;
int val[maxn],inv[maxn];

inline int qpow(int a,int x){
	int res=1;
	while(x){
		if(x&1) res=a*res%mod;
		a=a*a%mod;
		x>>=1;
	}
	return res;
}

inline int Inv(int dat){
	return qpow(dat,mod-2);
}

inline int calc(int a,int b){
	if(b==0) return 1;
	return (val[a]*inv[b]%mod)*inv[a-b]%mod;
}

signed main(){
	cin>>r1>>c1>>r2>>c2;
	val[1]=1;
	for(int i=2;i<=r2+c2+5;++i) val[i]=val[i-1]*i%mod;
	for(int i=1;i<=r2+c2+5;++i) inv[i]=Inv(val[i]);
//	for(int i=1;i<=r2+c2+5;++i) cout<<inv[i]<<" ";
//	cout<<endl;
	for(int i=r1+1;i<=r2+1;++i){
		ans=(ans+calc(i+c2,c2)%mod)%mod;
//		cout<<i+c2<<" "<<c2<<" "<<calc(i+c2,c2)<<endl;
	}
	for(int i=r1+1;i<=r2+1;++i){
		ans=(ans-calc(i+c1-1,c1-1)%mod+mod)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }

const long long INF = 1LL << 60;
long long dp[101][21];

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

    vector<int> num(N);
    rep(i, N) cin >> num[i];

    dp[1][num[0]] = 1;

    rep(i, N-1) {
        rep(j, 21) {
            if (dp[i][j] > 0) {
                int plus = j + num[i];
                int minus = j - num[i];

                if (plus >= 0 && plus <= 20) dp[i+1][plus] += dp[i][j];
                if (minus >= 0 && minus <= 20) dp[i+1][minus] += dp[i][j];
            }
        }
    }

    cout << dp[N-1][num[N-1]] << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> h(n);
    rep(i, n) cin>>h[i];
    int count =0;
    int ans = 0;
    rep(i, n-1){
        if (h[i]>=h[i+1]) {
            count++;
        }else{
            
            count=0;
        }
        ans = max(ans, count);

    }
    
    cout <<ans<<endl;
    
    
    

}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    static int A;
    static int B;
    static int[] a;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        A = scanner.nextInt();
        B = scanner.nextInt();
        scanner.close();
    }


    public static void main(String args[]) {
        init();
        System.out.println((A + B + 1) / 2);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define Maxn 5007
int n,modp;
int f[Maxn];
int calc(int x)
{
    int a=x,b=x+1;
    if (a%2==0) a/=2; else b/=2;
    return (1LL*a*b)%modp;
}
int main()
{
    scanf("%d%d",&n,&modp);
    if (n%2==1)
    {
        int k=n/2;
        memset(f,0,sizeof(f));
        f[0]=1;
        for (int i=2;i<=k+1;i++)
            for (int j=i;j<=n;j++)
                f[j]=(f[j]+f[j-i])%modp;
        for (int i=k;i>1;i--)
            for (int j=i;j<=n;j++)
                f[j]=(f[j]+f[j-i])%modp;
        int ans=0;
        for (int i=0;i<n;i++)
            ans=(ans+1LL*f[i]*calc(n-i))%modp;
        printf("%d\n",ans);
    } else
    {
        int k=n/2;
        memset(f,0,sizeof(f));
        f[0]=1;
        for (int i=2;i<=k;i++)
            for (int j=i;j<=n;j++)
                f[j]=(f[j]+f[j-i])%modp;
        for (int i=k;i>1;i--)
            for (int j=i;j<=n;j++)
                f[j]=(f[j]+f[j-i])%modp;
        int ans=0;
        for (int i=0;i<n;i++)
            ans=(ans+1LL*f[i]*calc(n-i))%modp;
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 256
Row,Col,Ichigo=map(int,input().split())

List=[[j for j in input().split()] for i in range(Row)]

cnt = 1
add = 0

ans = []

for i in range(Row):
  
  arr = list(List[i][0])
  ans_arr = []
  
  if "#" in arr:
    for j in range(Col):
      str = arr[j]
      if str == "#":
        cnt = cnt + add
        ans_arr.append(cnt)
        add = 1
      else :
        ans_arr.append(cnt)
  
  else:
    cnt = cnt - 1
    ans_arr.append(-1)
    
  cnt = cnt + 1
  ans.append(ans_arr)
  add = 0 
  
for i in range(Row):
  
  arr = ans[Row - i - 1][0]
  if arr == - 1 and Row - i != Row:
    
    ans_arr = ans[Row - i ]
    ans[Row - i - 1] = ans_arr
    
  elif i == 0 and ans[Row-1][0] == -1:
    ans_arr = ans[Row - 2 ]
    ans[Row - 1] = ans_arr
    
for i in range(Row):
  
  arr = ans[i][0]
  if arr == - 1:
    ans_arr = ans[i-1]
    ans[i] = ans_arr
    
for List in ans:
    print(*List)

Measured memory_bytes: 7504
from itertools import accumulate
from bisect import bisect_right

N, K = map(int, input().split())
A = [int(input()) for i in range(N)]

diff = [a - K for a in A]
diff = [0] + list(accumulate(diff))


class BinaryIndexedTree:
    def __init__(self, n):
        self.size = n
        self.bit = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= (i & -i)
        return s

    def add(self, i, x):
        while i <= self.size:
            self.bit[i] += x
            i += (i & -i)

    def reset(self):
        self.bit = [0] * (self.size + 1)


BIT = BinaryIndexedTree(N + 1)

temp = sorted(diff)
order = [bisect_right(temp, d) for d in diff]
ans = 0

for x in order:
    ans += BIT.sum(x)
    BIT.add(x, 1)

print(ans)


Measured memory_bytes: 32768
import numpy as np
N,Q = map(int,input().split())
S = input()
T = (N+1)*[0]

for n in range(N):
  if S[n:n+2]=="AC":
    T[n+1]+=1

T = np.cumsum(T)

for q in range(Q):
  l,r = map(int,input().split())
  print(T[r-1]-T[l-1])

Measured memory_bytes: 29096
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";


int main(){
    cin>>A>>B;
    cout<<(B%A ? B-A : A+B)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>){
  val scn = Scanner(System.`in`) //Scannerのインスタンスを作成
  
  var s: String = scn.next()
  val q: Int = scn.nextInt()
  var rev: Boolean = false
  var sb: Array<String?> = arrayOfNulls(q)
  var ib = 0
  var sa: Array<String?> = arrayOfNulls(q)
  var ia = 0
  for(i in 1..q) {
    val t: Int = scn.nextInt()
    if (t == 1) {
      rev = !rev
    } else {
      val f: Int = scn.nextInt()
      val c: String = scn.next()
      if (f == 1) {
        if (rev) {
          sa[ia] = c
          ia++
        } else {
          sb[ib] = c
          ib++
        }
      } else {
        if (rev) {
          sb[ib] = c
          ib++
        } else {
          sa[ia] = c
          ia++
        }
      }
    }
  }

  if (rev) {
    for(i in ia-1 downTo 0) print(sa[i])
    print(s.reversed())
    for(i in 0..ib-1) print(sb[i])
  } else {
    for(i in ib-1 downTo 0) print(sb[i])
    print(s)
    for(i in 0..ia-1) print(sa[i])
  }
  println("")
}

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

int main(){
    long N;
    int K,count=0;
    cin>>N>>K;
    vector<int> h(N);
    for(int i=0;i<N;i++){
        cin>>h.at(i);
    }

    for(int i=0;i<N;i++){
        if(h.at(i)>=K) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
typedef pair<ll, int> P;

ll INF = 1LL << 50;

struct edge{
    int to;
    ll cost;
};

/////////////////////////////////////////////////////////////////////////

class GraphD{
public:
    int N;
    vector<ll> d;
    vector<vector<edge>> G;

    GraphD(int n){
        N = n;
        d.resize(N, INF);
        G.resize(N, vector<edge>(0));
    }

    void makeEdge(int s, int t, ll c){
        G[s].push_back(edge{t, c});
    }

    void dijkstra(int s){
        fill(d.begin(), d.end(), INF);
        priority_queue<P, vector<P>, greater<P>> que;
        d[s] = 0;
        que.push(P(0, s));

        while(!que.empty()){
            P p = que.top();
            que.pop();
            int v = p.second;
            if(d[v] < p.first) continue;

            for(int i = 0; i < (int)G[v].size(); i++){
                edge e = G[v][i];
                if(d[e.to] > d[v] + e.cost){
                    d[e.to] = d[v] + e.cost;
                    que.push(P(d[e.to], e.to));
                }
            }
        }
    }

    ll getCost(int t){
        return d[t];
    }
};

///////////////////////////////////////////////////////////////////////////

int main(){
    int N, M, s;
    cin >> N >> M >> s;

    GraphD g = GraphD(N);
    for(int i = 0; i < M; i++){
        int a, b;
        ll c;
        cin >> a >> b >> c;
        g.makeEdge(a, b, c);
    }

    g.dijkstra(s);

    for(int i = 0; i < N; i++){
        ll x = g.getCost(i);
        if(x == INF){
            cout << "INF" << endl;
        } else {
            cout << x << endl;
        }
    }

    return 0;
    /*
    How to use
    インスタンスを作成
    P, edge, INFを定義する
    辺を入力してmakeEdge
    始点sを入力してdijkstra
    d[i]にsからiへの最小コストが入っています
    */
}


Measured memory_bytes: 19496
def main():
    from builtins import int, map, list, print, len
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = (lambda: (sys.stdin.readline()).rstrip())
    input_list = (lambda: input().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N = input_number()
    A = input_number_list()
    cnt = 0
    is_ng = False
    while True:
        for i in range(len(A)):
            if A[i] % 2 == 1:
                is_ng = True
                break
            else:
                A[i] /= 2
        if is_ng:
            break
        cnt += 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=5005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=2;i<M;i+=2) F[i]=F[i-2]*(i-1)%mod;
}
 
int n;
vvi g;
vvl dp;

int dfs(int v,int p){
	int S=1,B=0;
	vl DP;
	for(auto u:g[v]) if(u!=p){
		int N=dfs(u,v);
		S+=N;
		vl DP_(S+1);
		if(!B){
			for(int i=1;i<=N;i++){
				DP_[i+1]=dp[u][i]%mod;
				if(i%2==0) (DP_[1]+=dp[u][i]*F[i]%mod*(mod-1))%=mod;
			}
			B=1;
		}
		else{
			for(int i=1;i<=S-N;i++) for(int j=1;j<=N;j++){
				(DP_[i+j]+=DP[i]*dp[u][j])%=mod;
				if(j%2==0) (DP_[i]+=DP[i]*dp[u][j]%mod*F[j]%mod*(mod-1))%=mod;
			}
		}
		DP=DP_;
	}
	if(S==1){
		DP=vl(2);
		DP[1]++;
	}
	dp[v]=DP;
	return S;
}

int main(){
	Init();
	cin>>n;
	g=vvi(n);
	dp=vvl(n,vl(n+1));
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	ll res=0;
	for(int i=2;i<=n;i+=2) (res+=dp[0][i]*F[i])%=mod;
	cout<<res<<endl;
}

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

#define ull unsigned long long
#define endl '\n'
#define ll long long
const int N = 2e5 + 5;
ll mod = 1e9 + 7;
vector<ll> node[N];
ll sz[N], dp[N], fact[N], ans[N], n;
ll inv(ll u, ll p){
        if (p == 0) return 1;
        if (p == 1) return u;
        ll t = inv(u, p / 2) % mod;
        if (p & 1) return t * t % mod * u % mod;
        return t * t % mod;
}
void dfs(ll u, ll p){
        sz[u] = 1;
        for (auto j : node[u]){
                if (j != p){
                        dfs(j, u);
                        sz[u] += sz[j];
                }
        }
}
ll tot = 1;
void reroot(ll u, ll v){
        tot = tot * inv(sz[u], mod - 2) % mod * inv(sz[v], mod - 2) % mod;
        sz[u] = n - sz[v];
        sz[v] = n;
        tot = tot * sz[u] % mod * sz[v] % mod;
}
void dfs1(ll u, ll p){
        ans[u] = fact[n] * inv(tot, mod - 2) % mod;
        for (auto j : node[u]){
                if (j != p){
                        reroot(u, j);
                        dfs1(j, u);
                        reroot(j, u);
                }
        }
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (fopen(".INP", "r")){
                freopen(".INP", "r", stdin);
                freopen(".OUT", "w", stdout);
        }
        cin >> n;
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
        for (int i = 1; i < n; i++){
                ll u, v;
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        dfs(1, 0);
        for (int i = 1; i <= n; i++){
                tot = (tot * sz[i]) % mod;
        }
        dfs1(1, 0);
        for (int i = 1; i <= n; i++){
                cout << ans[i] << endl;
        }
}


Measured memory_bytes: 20976