akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

template <int n>
struct UnionFind{
    UnionFind(){
        for(int i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
        }
    }
    int find(int x){
        if(x == par[x])return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y){return;}
        
        if(rank[x] > rank[y]){
            par[y] = x;
        }else{
            par[x] = y;
            if(rank[x] == rank[y]){rank[y]++;}
        }
    }
    int rank[n], par[n];
};

UnionFind<200100> uf, uf2;
vector<P> groups[200100];
int cnt[200100];

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N, K, L;
    std::cin >> N >> K >> L;

    for(int i=0;i<K;++i){
        int p, q;
        std::cin >> p >> q;

        uf.unite(p, q);
    }

    for(int i=0;i<L;++i){
        P p;
        std::cin >> fst(p) >> snd(p);

        uf2.unite(fst(p), snd(p));
    }

    for(int i=1;i<=N;++i){
        groups[uf.find(i)].emplace_back(uf2.find(i), i);
    }

    for(int i=1;i<=N;++i){
        sort(groups[i].begin(), groups[i].end());

        int n = groups[i].size();
        for(int j=0,k=0;j<n;){
            while(k < n && fst(groups[i][k]) == fst(groups[i][j])){
                ++k;
            }

            int m = k - j;
            // std::cout << "Group " << i << std::endl;
            for(;j<k;++j){
                // std::cout << snd(groups[i][j]) << std::endl;
                cnt[snd(groups[i][j])] = m;
            }
        }
    }

    for(int i=1;i<=N;++i){
        std::cout << cnt[i] << " \n"[i==N];
    }    
}


Measured memory_bytes: 14976
#include<stdio.h>
int main(){
  char s[1027];
  int n;
  int i,j,g;
  scanf("%d\n",&n);
  for(i=0;i<n;i++){
    char t[55]={0};
    g=25;
    fgets(s,1026,stdin);
    for(j=0;1;j+=3){
      t[g]=s[j];
      if     (s[j+1]=='-')g++;
      else if(s[j+1]=='<')g--;
      else    break;
    }
    for(j=0;t[j]==0;j++);
    for(;t[j]!=0;j++)printf("%c",t[j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::input;
use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
use std::cmp::*;

const INF: usize = 1000_000_000_000;
fn main() {
    input! {
        N: usize,
        M: usize,
        S: usize,
        mut UVAB: [(Usize1,Usize1,usize,u64);M],
        CD:[(usize,u64);N]
    }
    // g[i] = (j, a,b)なら、iからjへ、a円 b時間
    let mut g = vec![vec![]; N];
    for &(u, v, a, b) in UVAB.iter() {
        g[u].push((v, a, b));
        g[v].push((u, a, b));
    }
    // 銀貨最大値
    let w = 50 * 49;
    let mut dp = vec![vec![std::u64::MAX; w + 1]; N];
    // 都市0で銀貨S枚持つまでに0分かかる。
    dp[0][min(w, S)] = 0;
    let mut h = std::collections::BinaryHeap::new();
    // 謎。Heapに、逆順を指定したうえでタプルを加えている模様。
    h.push(Reverse((0, 0, min(w, S))));
    // hからpop出来る限り繰り返す。
    while let Some(Reverse((d, v, k))) = h.pop() {
        // heap は既に訪れた場所？
        // 既に訪れたHeapについて、dp[v][k]のより小さいものが見つかったとしたら、無視。
        // 最初は0,0,Sであり、dp[0][S]=0だから、if式はfalse。
        if d > dp[v][k] {
            continue;
        }
        for &(u, a, b) in g[v].iter() {
            // 移動可能な場所uへの運賃aが、所持金より多い場合、移動不可。
            if a > k {
                continue;
            }
            // そうでなければ移動。移動時間を加えたものをdとすると、
            // 所持金をa減らしてuに到着した場合の時刻dとなるので、
            // dが過去に計算されたdp[u][k-a]を更新できるなら、更新し、
            // hに、検査対象の (d,u,k-a)を追加する。
            let next_d = d + b;
            let next_k = k - a;
            if next_d < dp[u][next_k] {
                dp[u][next_k] = next_d;
                //let mut tmp_k = next_k;
                for tmp_k in (0..next_k).rev() {
                    if dp[u][tmp_k] > dp[u][next_k] {
                        dp[u][tmp_k] = dp[u][next_k];
                    } else {
                        break;
                    }
                }
                h.push(Reverse((next_d, u, next_k)));
            }
            // 以上を、vから移動可能な路線(u,a,b)のすべてについてチェックする。。
        }
        // 次に換金時間を足す。dは時刻、kは所持金
        let next_d = d + CD[v].1;
        let next_k = min(k + CD[v].0, w);
        if dp[v][next_k] > next_d {
            dp[v][next_k] = next_d;
            h.push(Reverse((next_d, v, next_k)));
        }
    }

    //println!("dp[0]={:?}", &dp[0][0..10]);
    //println!("dp[1]={:?}", &dp[1][0..10]);
    for v in 1..N {
        println!("{}", dp[v].iter().min().unwrap());
    }
}


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

int main(){
  int n,m;
  cin >> n >> m;
  
  int r[n];
  for(int q=0;q<n;++q){
  r[q] = 0;}
  
  int a,b;
  for(int i = 0;i<m;++i){     
    cin >> a >> b;
    r[a-1] +=1;
    r[b-1] +=1;
  }
  for(int g = 0;g<n;++g){
    cout << r[g] << endl;
  }
}

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

ll MOD = 1e9+7;

int main(){
    string S; cin >> S;
    ll N = S.size();
    ll temp = 0;
    ll SUM = 0;
    ll MIN = 1e9;
    int i = 0;
    while(i < N){
        if(S[i] == '<') {
            temp++;
            SUM += temp;
        }
        else{
            ll cnt = 1;
            while(i < N-1 && S[i+1] == '>'){
                temp--;
                i++;
                cnt++;
                SUM += temp;
            }
            temp--;
            SUM += temp;
            //cout << temp << endl;
            if(temp < 0) SUM -= (cnt+1)*temp;
            else SUM -= (cnt)*temp;
            temp = 0;

            
        }
        //cout << i << " " << SUM << endl;
        i++;
    }

    //ans += abs(MIN)*(S.size()+1);
    cout << SUM << endl;
}

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

int main()
{
    string S; cin >> S;
    for (int i = 0; i < S.size()-1; i++) {
        for (int j = i+1; j < S.size(); j++) {
            if (S[i] != S[j]) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph = vector<vector<ll>>;
int main(){
  ll A;
  cin>>A;
  vector<ll>vec(0);
  for(ll i=0;i<A;i++){
    char a;
    cin>>a;
    if(a=='R'){
      vec.push_back(i+1);
    }
  }
  sort(vec.begin(),vec.end());
  ll f=vec.size();
  ll g=0;
  for(ll i=0;i<f;i++){
    if(vec.at(i)>vec.size()){
      g=i;
      break;
    }
    if(i==f-1){
      g=f;
    }
  }
  cout<<min(f-g,A-f)<<endl;
    
}
    


Measured memory_bytes: 5284
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
typedef pair<int,int> Pair;

const int MAXN = 20004;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,1,0,-1};

namespace std {
  bool operator < (const Pair &a, const Pair &b) {
    if(a.first != b.first) return a.first < b.first;
    return a.second < b.second;
  }
};

int N;
int X[MAXN], Y[MAXN];
char D[MAXN];

map<Pair, Pair> m;
int B[MAXN];

bool dfs(int id, int b) {
  B[id] = b;
  int fx[2], fy[2];
  if(D[id] == 'x') {
    fx[0] = 0; fx[1] = 1;
    fy[0] = 0; fy[1] = 0;
  } else {
    fx[0] = 0; fx[1] = 0;
    fy[0] = 0; fy[1] = 1;
  }
  for(int j = 0; j < 2; ++j) {
    for(int i = 0; i < 4; ++i) {
      int nx = X[id] + fx[j] + dx[i];
      int ny = Y[id] + fy[j] + dy[i];
      Pair p(nx,ny);
      if(m.count(p)) {
        int nid = m[p].first;
        int nb = m[p].second;
        if(nid == id) continue;
        if(B[nid] != -1) {
          if((B[nid]^nb) != (b^j)) {
            return false;
          }
        } else {
          if(!dfs(nid, b^j^nb)) return false;
        }
      }
    }
  }
  return true;
}

int main() {
  while(cin >> N && N) {
    for(int i = 0; i < N; ++i) {
      cin >> X[i] >> Y[i] >> D[i];
    }
    m.clear();
    for(int i = 0; i < N; ++i) {
      if(D[i] == 'x') {
        m[Pair(X[i],Y[i])] = Pair(i, 0);
        m[Pair(X[i]+1,Y[i])] = Pair(i, 1);
      } else {
        m[Pair(X[i],Y[i])] = Pair(i, 0);
        m[Pair(X[i],Y[i]+1)] = Pair(i, 1);
      }
    }

    fill(B, B+MAXN, -1);
    bool ans = true;
    for(int i = 0; i < N; ++i) {
      if(B[i] == -1) {
        if(!dfs(i, 0)) {
          ans = false;
          break;
        }
      }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 7064
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 1e9+7;
struct angka
{
    ll x, y;
};
struct angka node[200200];
bool desc(struct angka a, struct angka b)
{
    return a.x + a.y < b.x + b.y;
}
bool asc(struct angka a, struct angka b)
{
    return a.x - a.y < b.x - b.y;
}
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n;
    vector<pair<ll,ll> > v;
    for(i=1;i<=n;i++) {
        cin >> node[i].x >> node[i].y;
    }
    ll chaeng = 0;
    sort(node+1, node+n+1, desc);
    chaeng = max(chaeng, abs(node[n].x-node[1].x) + abs(node[n].y-node[1].y));
    sort(node+1, node+n+1, asc);
    chaeng = max(chaeng, abs(node[n].x-node[1].x) + abs(node[n].y-node[1].y));
    cout << chaeng << endl;
    return 0;
}


Measured memory_bytes: 6756
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

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

int main(){
    long int const mod = 1000000007;
    long int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    long int ans = 1;
    if (n % 2 == 0){
        int num[n/2];
        rep(i, n / 2) num[i] = 0;
        rep(i, n){
            if (a[i] % 2 == 0){
                cout << 0 << endl;
                return 0;
            }
            long int idx = a[i] / 2;
            if (num[idx] > 1){
                cout << 0 << endl;
                return 0;     
            }
            num[idx]++;
        }
        
        rep(i, n / 2){
            ans *= 2;
            ans %= mod;
        }
    }else{
        int num[n/2+1];
        rep(i, n / 2 + 1) num[i] = 0;
        rep(i, n){
            if (a[i] % 2 == 1){
                cout << 0 << endl;
                return 0;
            }
            long int idx = a[i] / 2;
            if (idx > 0 && num[idx] > 1){
                cout << 0 << endl;
                return 0;     
            }else if (idx == 0 && num[idx] > 0){
                cout << 0 << endl;
                return 0;
            }
            num[idx]++;
        }
        
        rep(i, n / 2){
            ans *= 2;
            ans %= mod;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 768
#include<iostream>
using namespace std;
int main()
{
	int n,a,b,c,x,i;
	int y[100];
	int flame;
	for(;;)
	{
		cin >> n >> a >> b >> c >> x ;
		if(n==0 && a==0 && b==0 && c==0 && x==0)
			break;
		for(i=0;i<n;i++)
		{
			cin >> y[i] ;
		}
		flame=0;
		int f=1;
		for(i=0;;)
		{
			if(flame==10001)
			{
				f=0;
				break;
			}
			if(y[i]==x)
			{
				i++;
				x=(a*x+b)%c;
				if(i==n)
					break;
				flame++;
			}
			else
			{
				flame++;
				x=(a*x+b)%c;
			}
		}
		if(f==1)
			cout << flame << endl;
		else
			cout << "-1" << endl;
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#define MAX 100000
#define NIL -1

struct Node
{
int x, y, z;
};
struct Node A1[MAX];

int num, G, A2[MAX];

int getDepth(int m){
  int b = 0;
  for(; A1[m].x != NIL ;b++) m = A1[m].x;
  return b;
}

void print(int m){
  int i, c;
  printf("node %d: ", m);
  printf("parent = %d, ", A1[m].x);
  printf("depth = %d, ", A2[m]);

  if ( A1[m].x == NIL ) printf("root, ");
  else if ( A1[m].y == NIL ) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i = 0, c = A1[m].y; c != NIL; i++, c = A1[c].z){
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");
}

int main(){
  int i, j, a, b, c, y;
  scanf("%d", &num);
  for ( i = 0; i < num; i++ ) A1[i].x = A1[i].y = A1[i].z = NIL;

  for ( i = 0; i < num; i++ ){
    scanf("%d %d", &a, &b);
    for ( j = 0; j < b; j++ ){
      scanf("%d", &c);
      if ( j == 0 ) A1[a].y = c;
      else A1[y].z = c;
      y = c;
      A1[c].x = a;
    }
  }

  G = 0;
  for ( i = 0; i < num; i++ ){
    A2[i] = getDepth(i);
    if ( A2[i] > G ) G = A2[i];
  }

  for ( i = 0; i < num; i++ )
    {
      print(i);
    }

  return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(void)
{
	int a, b; char op;
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		if 	(op == '?') break;

		if (op == '+') {
			printf("%d\n", a + b);
		} else if (op == '-') {
			printf("%d\n", a - b);
		} else if (op == '*') {
			printf("%d\n", a * b);
		} else if (op == '/') {
			printf("%d\n", a / b);
		}
	}

	return 0;
}

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

int main()
{
	//freopen("modle.in","r",stdin);
	//freopen("modle.out","r",stdout);
	int n;
	cin>>n;
	cout<<n+n*n+n*n*n;
	return 0;
}

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

const long long N = 3e6 + 17;
ll a[N], b[N], cnt = 1, ans, lnt, n, m, r1, r0, l1, l0, sum, mx, h, c[N], t[N], mn = N, x, y, k;
pair<ll,ll>pr[N];
vector<ll>v,v2;
map<ll,ll>mp;
bool used[N];
char ch[N];
ll prime[N] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> m;
    double q;
    q = double(n) / m;
    cout << fixed << setprecision(10) << q;
}


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

constexpr long mod = 1000000007;

priority_queue<long> q1, q2;

long c() {
    if(!q1.size() && !q2.size()) return 0;
    if(!q2.size()) return q1.top();
    if(!q1.size()) return -q2.top();
    long a = q1.top(), b = -q2.top();
    long m = q1.size(), n = q2.size();

    if ((m+n) % 2) return m > n ? a : b;
    return a;
}
long myabs(long a) {
    return a > 0 ? a : -a;
}

int main(void) {
    long bsum = 0;
    long q1s = 0, q2s = 0;
    q1.push(0); q1.pop();
    q2.push(0); q2.pop();

    long q;
    cin >> q;
    for(int i=0; i<q; i++) {
        int type;
        cin >> type;
        if(type == 1) {
            long a, b;
            cin >> a >> b;
            bsum += b;

            long m = c();
            if(m < a) {
                q2.push(-a);
                q2s += a;
            } else {
                q1.push(a);
                q1s += a;
            }

            while(myabs(q1.size() - q2.size()) >= 2) {
                if (q1.size() < q2.size()) {
                    q2s -= -q2.top();
                    q1s += -q2.top();
                    q1.push(-q2.top()), q2.pop();
                }
                if (q1.size() > q2.size()) {
                    q1s -= q1.top();
                    q2s += q1.top();
                    q2.push(-q1.top()), q1.pop();
                }
            }

            /* cout << '!' << q1.top() << ',' << q1.size() << ' ' << q2.top() << ',' << q2.size() << ' ' << endl; */
        } else if (type == 2) {
            long m = c();
            /* cout << q1s << ' ' << q2s << ' ' << bsum << endl; */
            cout << m << ' ' << (m * (signed long)(q1.size() - q2.size()) - q1s + q2s + bsum) << endl;
        }
    }
}


Measured memory_bytes: 3828
n=int(input())
s=list(map(int,input().split()))
list_box=[]

count=0
for i in range(0,n-1):
  if s[i]>=s[i+1]:
    count=count+1
  if s[i]<s[i+1]:
    list_box.append(count)
    count=0
list_box.append(count)
print(max(list_box))

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#include <limits>
using namespace std;
// 素因数分解
typedef pair<long long, long long> P;
vector<P> prime_factorize(long long n)
{
vector<P> res;
for (long long p = 2; p * p <= n; ++p)
{
if (n % p != 0)
continue;
int num = 0;
while (n % p == 0)
{
++num;
n /= p;
}
res.push_back(make_pair(p, num));
}
if (n != 1)
res.push_back(make_pair(n, 1));
return res;
}
// 因数分解
long long gcd(long long x, long long y)
{
  if (y == 0)
  {
    return x;
  }
  else
  {
    return gcd(y, x % y);
  }
}
const int MOD = 1000000007;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)

int main()
{
    int a, b;
    cin >> a >> b;
    int i;
    for (i = 1;;i++){
        if(i*8/100==a&&i/10==b){
            cout << i << endl;
            return 0;
        }
        if(i*8/100>a||i/10>b){
            cout << -1 << endl;
            return 0;
        }
    }
        return 0;
}

Measured memory_bytes: 3536
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int K = int.Parse(str[1]);
		int[]A = new int[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str2[i]);
		}
		if(K>=N){
			for(var i=0;i<N;i++){
				A[i] = N;
			}
		} else {
			for(var i=0;i<K;i++){
				var listA = new List<int>();
				var listB = new List<int>();
				var ct = 0;
				for(var j=0;j<N;j++){
					if(j-A[j]<=0){
						ct++;
					} else {
						listA.Add(j-A[j]);
					}
					if(A[j]+j+1<N){
						listB.Add(A[j]+j+1);
					}
				}
				listA.Sort();
				listB.Sort();
				listA.Add(10000000);
				listB.Add(10000000);
				var a1 = 0;
				var b1 = 0;
				bool flag = true;
				for(var j=0;j<N;j++){
					while(listA[a1]==j){
						ct++;
						a1++;
					}
					while(listB[b1]==j){
						ct--;
						b1++;
					}
					A[j] = ct;
					if(flag && A[j]<N){
						flag = false;
					}
				}
				if(flag){
					break;
				}
			}
		}
		Console.Write(A[0]);
		for(var j=1;j<N;j++){
			Console.Write(" " +A[j]);
        }
	}
}

Measured memory_bytes: 41816
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int n = a * x + b * y;
    int m = 2 * c * max(x, y);

    int p   = x < y ? b : a;
    int l   = 2 * c * min(x, y) + p * abs(x - y);
    int ans = min(n, min(m, l));
    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())

def left(a, i, prev):
  yield 0
  for l, s in enumerate(prev, 1-i):
    yield s+abs(l)*a
    
def right(a, i, prev):
  for r, s in enumerate(prev, N - len(prev) - i + 1):
    yield s+abs(r)*a
  yield 0

pd = [0]
A = map(int, input().split())
for a,i in sorted(((a, i) for i, a in enumerate(A, 1)), reverse=True):
  pd = [*map(max, zip(left(a,i, pd), right(a,i, pd)))]

print(max(pd))


Measured memory_bytes: 9464
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int H, W;
char G[100][100];

void row(int r){
	for(int i = 0; i < W; i++)
		if(G[r][i] == '#') return;
	for(int i = 0; i < W; i++) G[r][i] = 'x';
}

void col(int c){
	for(int i = 0; i < H; i++)
		if(G[i][c] == '#') return;
	for(int i = 0; i < H; i++) G[i][c] = 'x';
}

int main(void){
	//IO("test.in", "test.out");
	scanf("%d%d", &H, &W), cin.get();
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) G[i][j] = cin.get();
		cin.get();
	}
	for(int i = 0; i < H; i++) row(i);
	for(int i = 0; i < W; i++) col(i);
	for(int i = 0; i < H; i++){
		bool s = false;
		for(int j = 0; j < W; j++)
			if(G[i][j] != 'x')
				printf("%c", G[i][j]), s = true;
		if(s) printf("\n");
	}
}

Measured memory_bytes: 256
# Print a Chessboard
loop do
    h, w, = gets.split.map(&:to_i)
    break if h == 0 && w == 0
    h.times do |n|
        if n.even?
            puts ('#.' * w)[0,w]
        else
            puts ('.#' * w)[0,w]
        end
    end
    puts
end

Measured memory_bytes: 8900
#include <iostream>
#include <string>
#include <sstream>

using namespace std;

string lower(const string& s) {
	string out;
	out.reserve(s.size());
	for (size_t i = 0; i < s.size(); ++i) {
		out += static_cast<char>(tolower(s[i]));
	}
	return out;
}

int main() {
	string w, s;
	cin >> w;
	w = lower(w);

	size_t counter = 0;
	while (getline(cin, s)) {
		if (s == "END_OF_TEXT") {
			break;
		}
		istringstream is(s);
		string b;
		while (is >> b) {//??????????????¨????????????
			//cout << "b : " << b << endl;
			if (w == lower(b)) {
				++counter;
			}
		}
	}
	cout << counter << endl;
	return 0;
}

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

using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

bool pallan(string s){
    ll i=0,j=s.size()-1;
    while(i<j){
        if(s[i]!=s[j])
            return false;
        i++;
        j--;
    }
    return true;
}

int main() {
    fio;
    
    ll n,m;cin>>n>>m;
    
    cout<<ceil((double)n/m)<<endl;
    
    
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A ;
  cin >> B >> C;
  int D;
  for(int i=B;i<=C;i++){
    if(i%A==0){
      D++;
    }
  }
  if(D>=1){
    cout << "OK" << endl;
  }
  else{
    cout << "NG" << endl;
  }
}   

Measured memory_bytes: 3632
def main():
    N = int(input())
    A = list(map(int, input().split()))
    SUM = 1

    if 0 in A:
        print(0)
        return

    for a in A:
        SUM = SUM * a
        if SUM > 1000000000000000000:
            print(-1)
            return

    print(SUM)
main()

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

typedef map<int, set<int> > msi;

#define F first
#define S second

const int inf = 2e9;

int n, ans;
msi xup, xdown, yleft, yright;
msi upm, upp, downm, downp;
msi leftm, leftp, rightm, rightp;

void relax(msi &a, msi &b, int mult) {
	for (auto &t: a) {
		if (!b.count(t.F)) continue;
		for (int i: t.S) {
			auto it = b[t.F].lower_bound(i);
			if (it == b[t.F].end()) continue;
			ans = min(ans, (*it - i) * mult);
		}
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x, y; char d;
		cin >> x >> y >> d;
		if (d == 'U') {
			xup[x].insert(y);
			upm[x - y].insert(y);
			upp[x + y].insert(y);
		} else if (d == 'D') {
			xdown[x].insert(y);
			downm[x - y].insert(y);
			downp[x + y].insert(y);
		} else if (d == 'L') {
			yleft[y].insert(x);
			leftm[x - y].insert(y);
			leftp[x + y].insert(y);
		} else {
			yright[y].insert(x);
			rightm[x - y].insert(y);
			rightp[x + y].insert(y);
		}
	}
	ans = inf;
	relax(xup, xdown, 5);      
	relax(yright, yleft, 5);  
	relax(upm, leftm, 10);    
	relax(upp, rightp, 10);    
	relax(rightm, downm, 10);  
	relax(leftp, downp, 10);  
	if (ans == inf) cout << "SAFE";
	else cout << ans;
}


Measured memory_bytes: 87892
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	int N;
	string S;

	std::vector<int> v;
	
	cin >> N >> S;
	int x = 0;
	v.pb(0);
	
	rep(i, N)
	{
		if (S[i] == 'I')
		{
			x++;
		}
		else
		{
			x--;
		}

		v.pb(x);
	}

	sort(v.begin(), v.end(), greater<int>());

	cout << v[0] << endl;

	
	return 0;
}


Measured memory_bytes: 256
def main():
    from collections import Counter

    N = int(input())
    a = list(map(float, input().split()))

    dp = [[[0]*(N+1) for _ in range(N+1)] for _ in range(N+1)]
    c = Counter(a)

    # メモ化再帰ではpypy3でもTLEするのでforループを使う
    # j==k==0の場合を計算 → k==0の場合を計算 → 一般の場合を計算
    for k in range(c[3]+1):
        for j in range(c[3]+c[2]-k+1):
            for i in range(N-j-k+1):
                if i+j+k == 0:
                    continue
                else:
                    tmp = N
                    if i > 0: # IndexError防止
                        tmp += dp[i-1][j][k]*i
                    if j > 0:
                        tmp += dp[i+1][j-1][k]*j
                    if k > 0:
                        tmp += dp[i][j+1][k-1]*k
                    dp[i][j][k] = tmp/(i+j+k) # 割り算をまとめないとTLE

    print(dp[c[1]][c[2]][c[3]])

if __name__ == '__main__':
    main()

Measured memory_bytes: 599176
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] a = new int[3];
		for (int i=0; i<3; i++) a[i]=scanner.nextInt();
		Arrays.sort(a);
		System.out.println(Math.abs(a[2]-a[0]));
	}
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using ld=long double;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

template<typename T> bool chmin(T &a,const T b){if(a>b){a=b; return true;}return false;}
template<typename T> bool chmax(T &a,const T b){if(a<b){a=b; return true;}return false;}


int main(){
    string S; cin >> S;
    int N=S.size();
    
    int pos=0, cnt=0;
    bool flag=false;
    vi ans(N, 0);
    for(int i=0; i<N; i++){
        if(S[i] == 'R'){
            cnt++;
            flag=false;
        }
        else if(S[i] == 'L' && !flag){
            pos=i;
            ans[pos-1]+=(cnt+1)/2;
            ans[pos]+=(cnt)/2+1;
            cnt=0;
            flag=true;
        }
        else if(S[i] == 'L' && flag){
            if((i-pos)%2 == 1) ans[pos-1]++;
            else ans[pos]++;
        }
    }
    for(int i=0; i<N; i++){
        cout << ans[i] << (i==N-1?"\n":" ");
    }
    return 0;
}

Measured memory_bytes: 3848
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<tuple>
#include<functional>
#include<iomanip>
using namespace std;

#define MAX_N 110
#define INF 999999999.99

int N, M, S, G, a, b, c, d;
double X[MAX_N][MAX_N][2];
double dist[MAX_N][MAX_N][MAX_N];

priority_queue<tuple<double, int, int, int>, vector<tuple<double, int, int, int>>, greater<tuple<double, int, int, int>>>Q;

double dijkstra() {
	dist[S][0][0] = 0;
	Q.push(make_tuple(0.0, S, 0, 0));

	while (!Q.empty())
	{
		tuple<double, int, int, int>tup = Q.top();
		Q.pop();
		double a1 = get<0>(tup);
		int a2 = get<1>(tup);
		int a3 = get<2>(tup);
		int a4 = get<3>(tup);

		for (int i = 1; i <= N; i++)
		{
			if (i == a4) {
				continue;
			}
			//X-1.
			if (a3 >= 1 && X[a2][i][1] >= a3 - 1)
			{
				double jikan = X[a2][i][0] / (a3 - 1);

				if (dist[i][a3 - 1][a2] > jikan + a1)
				{
					dist[i][a3 - 1][a2] = jikan + a1;
					Q.push(make_tuple(dist[i][a3 - 1][a2], i, a3 - 1, a2));
				}
			}
			//X.
			if (X[a2][i][1] >= a3)
			{
				double jikan = X[a2][i][0] / a3;

				if (dist[i][a3][a2] > jikan + a1)
				{
					dist[i][a3][a2] = jikan + a1;
					Q.push(make_tuple(dist[i][a3][a2], i, a3, a2));
				}
			}
			//X+1.
			if (X[a2][i][1] >= a3 + 1)
			{
				double jikan = X[a2][i][0] / (a3 + 1);

				if (dist[i][a3 + 1][a2] > jikan + a1)
				{
					dist[i][a3 + 1][a2] = jikan + a1;
					Q.push(make_tuple(dist[i][a3 + 1][a2], i, a3 + 1, a2));
				}
			}
		}
	}
	double RES = INF;
	for (int i = 0; i < MAX_N; i++) {
		RES = min(RES, dist[G][1][i]);
	}
	return RES;
}

int main() {
	while (true) {
		cin >> N >> M;
		if (N == 0 && M == 0) { break; }
		cin >> S >> G;
		for (int i = 0; i < MAX_N; i++) {
			for (int j = 0; j < MAX_N; j++) {
				X[i][j][0] = INF;
				X[i][j][1] = 0.0;
				for (int k = 0; k < MAX_N; k++) {
					dist[i][j][k] = INF;
				}
			}
		}
		for (int i = 0; i < M; i++) {
			cin >> a >> b >> c >> d;
			X[a][b][0] = c;
			X[b][a][0] = c;
			X[a][b][1] = d;
			X[b][a][1] = d;
		}
		double res1 = dijkstra();
		double res;
		res = res1;
		if (res > INF / 2) { cout << "unreachable" << endl; }
		else { cout << fixed << setprecision(15) << res << endl; }
	}
	return 0;
}

Measured memory_bytes: 14220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;

ll dp[3020][3020],dp2[3020][3020];//dp[index][weight]

int main(){
  int n,W;
  cin >> n >> W;
  pair<ll,ll> p[n];
  ll w[n],v[n];
  rep(i,n)cin >> p[i].second >> p[i].first;
  sort(p,p+n);
  rep(i,n){
    w[i]=p[i].second;
    v[i]=p[i].first;
  }
  rep(i,n+1){
    rep(j,W+1){
      if(j-w[i]>=0){
        dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j]);
      }
      else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }
  ll ans=dp[n-1][W-1]+v[n-1];
  w[n-2]=p[n-1].second;
  v[n-2]=p[n-1].first;
  rep(i,n+1){
    rep(j,W+1){
      if(j-w[i]>=0){
        dp2[i+1][j]=max(dp2[i][j-w[i]]+v[i],dp2[i][j]);
      }
      else{
        dp2[i+1][j]=dp2[i][j];
      }
    }
  }
  ans=max(ans,dp2[n-1][W-1]+p[n-2].first);
  cout << ans << endl;
return 0;}


Measured memory_bytes: 142336
S = raw_input()
A = [0]
for i in range(len(S)-1):
  if S[i]!=S[i+1]:
    A += [i+1]
A += [len(S)]
B = [A[i+1]-A[i] for i in range(len(A)-1)]

s = sum(B)
ans = 0
l = 0
for b in B:
  ans = max(ans, min(l+b, s-l))
  l += b
print ans


Measured memory_bytes: 7540
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]

count = 0
for i in range(N):
    s = C
    for j in range(M):
        s += A[i][j]*B[j]
    if s > 0:
        count += 1

print(count)


Measured memory_bytes: 3060
n,m,c = map(int,input().split(" "))
b = list(map(int,input().split(" ")))

count = 0
for i in range(n):
  li = [c]
  a = list(map(int,input().split(" ")))
  for x, y in zip(a,b):
    li.append(x*y)
  li_sum = sum(li)
  if li_sum > 0:
    count += 1
print(count)

Measured memory_bytes: 9004
a = input()

b = a[-1]

ans = "bon"
if b == "2" or b == "4" or b == "5" or b == "7" or b == "9":
    ans = "hon"
elif b == "0" or b == "1" or b == "6" or b == "8":
    ans = "pon"

print(ans)

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

using namespace std;

ll calc_gcd(ll a, ll b)
{
    ll tmp = a % b;
    if (tmp != 0)
	return calc_gcd(b, tmp);
    else 
	return b;
}

ll calc_lcm(ll a, ll b)
{
    ll gcd = calc_gcd(a, b);
    return a * b / gcd;
}

int main()
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll c_a = (a - 1) / c;
  ll c_b = b / c;
  ll d_a = (a - 1) / d;
  ll d_b = b / d;

  ll lcm = calc_lcm(c, d);
  ll lcm_a = (a - 1) / lcm;
  ll lcm_b = b / lcm;

  cout << (b - (a - 1)) - ((c_b - c_a) + (d_b - d_a) - (lcm_b - lcm_a)) << endl;

  return 0;
}


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

#define MAXN 1005
#define MAX_N 1000005
#define INF 1<<30
#define eps 1.0e-10

#define For(i,m,n) for(int i=(m);i<n;i++)

using namespace std;

struct point{
    int x;
    int y;
    int step;
    point(int x, int y, int step): x(x), y(y), step(step) {;}
    bool operator<(const point &p) const {
        return step > p.step;
    }
};

int vis[MAXN][MAXN], cost[MAXN][MAXN], dir[MAX_N], g[4][MAX_N];
int H,W,N,flag,sx,sy;
int move[4][2]={-1,0,0,1,1,0,0,-1};
char str[MAX_N], _map[MAXN][MAXN];

int main()
{
    while(scanf("%d%d%d",&H,&W,&N),H||W||N){
        memset(vis,0,sizeof(vis));
        memset(cost,0x0f,sizeof(cost));
        memset(g,0x0f,sizeof(g));
        flag=0;
        dir[0]=0;
        scanf("%s",str);
        For(i,0,N){
            dir[i+1]=dir[i];
            dir[i+1]+=(str[i]=='L'?3:1);
            dir[i+1]%=4;
        }
        for(int i=N;i>=0;i--){
            For(j,0,4) g[j][i]=g[j][i+1];
            g[dir[i]][i]=i;
        }
        For(i,0,H){
            scanf("%s",_map[i]);
            For(j,0,W) if(_map[i][j]=='S') sx=i, sy=j;
        }
        priority_queue<point> q;
        q.push(point(sx,sy,0));
        while(!q.empty()){
            point tmp=q.top();
            q.pop();
            if(!vis[tmp.x][tmp.y]){
                vis[tmp.x][tmp.y]=1;
                if(_map[tmp.x][tmp.y]=='G') {flag=1; break;}
                For(i,0,4){
                    int tx=tmp.x+move[i][0];
                    int ty=tmp.y+move[i][1];
                    int tcost=g[i][tmp.step];
                    if(tx>=0&&tx<H&&ty>=0&&ty<W&&_map[tx][ty]!='#'&&tcost<cost[tx][ty]){
                        cost[tx][ty]=tcost;
                        q.push(point(tx,ty,tcost));
                    }
                }
            }
        }
        puts(flag?"Yes":"No");
    }
    return 0;
}

Measured memory_bytes: 28008
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;

  int Ans = 1;
  char prev = S[0];
  for (int i = 1; i < N; i++) {
    if (prev != S[i]) Ans++;
    prev = S[i];
  }
  cout << Ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 200010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    unordered_map<int, vector<pii> > mp;

    for (int i = 1; i <= m; ++i) {
        int p, y;
        cin >> p >> y;
        mp[p].push_back(MP(y, i));
    }

    rep(i, limit) sort(all(mp[i]));
    vector<tuple<int, int, int> > output;

    rep(i, limit) {

        rep(j, mp[i].size()) {
            output.push_back(MT(mp[i][j].second, i, j + 1));
        }
    }

    sort(all(output));

    for (auto t : output) {
        cout << setfill('0') << right << setw(6) << get<1>(t);
        cout << setfill('0') << right << setw(6) << get<2>(t) << endl;
    }
    return 0;
}

Measured memory_bytes: 18760
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef array<ll,2> pll;
const ll NMAX=100005,MOD=1e9+7;
bool dp[NMAX];
ll v[NMAX];
int main()
{
    ll n,k;
    cin>>n>>k;
    for(ll i=0;i<n;i++) cin>>v[i];
    for(ll i=1;i<=k;i++){
        for(ll j=0;j<n;j++){
            if(i-v[j]>=0 && dp[i-v[j]]==0){
                dp[i]=1;
                break;
            }
        }
    }
    cout<<(dp[k]?"First":"Second");
    return 0;
}

///ABCDEFGHIJKLMNOPQRSTUVWXYZ
///11110111100000000000000000


Measured memory_bytes: 3740
N = int(input())
A = list(map(int, input().split()))

all = {}
for i, p in enumerate(A):
    all[p] = i+1

all = sorted(all.items(), key=lambda x:x[0])


for i in range(N):
    if i == N-1:
        print(all[i][1])
    else:
        print(all[i][1], end=' ')

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

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

    int out = 0;
    int r1 = (x / 500);

    out += r1 * 1000;
    x -= r1 * 500;

    int r2 = (x / 5);
    out += r2 * 5;

    cout << out << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0;i < n;i++){
        cin >> p.at(i);
    }
    int count = 0;
    int p_sec = 0;
    for (int i = 1;i < n - 1;i++){
        int p_max = max(p.at(i-1),max(p.at(i),p.at(i+1)));
        int p_min = min(p.at(i-1),min(p.at(i),p.at(i+1)));
        if (p.at(i) < p_max && p.at(i) > p_min){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int comp(const void *a, const void *b){return *(int*)a - *(int*)b;}

int main(){
  int N, K, i, j, kinds=0, tmp, ans=0, a[200000]={};
  scanf("%d %d", &N, &K);
  for(i=0;i<N;i++){
    scanf("%d", &tmp);
    a[tmp]++;
    if(a[tmp] == 1) kinds++;
  }
  qsort(a,sizeof(a)/sizeof(int),sizeof(int),comp);
  for(i=0;i<kinds-K;i++) ans += a[200000-kinds+i];
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

using ll = long long;

constexpr ll inf = 1e18;

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

  int n;
  cin >> n;

  vector<int> a(n);
  vector<vector<ll>> dp(n, vector<ll>(n));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    dp[i][i] = a[i];
  }

  for (int l = 2; l <= n; ++l) {
    for (int i = n - l; i >= 0; --i) {
      int r = i + l - 1;
      dp[i][r] = max(a[i] - dp[i + 1][r], a[r] - dp[i][r - 1]);
    }
  }

  cout << dp[0][n - 1] << '\n';

  return 0;
}


Measured memory_bytes: 70784
#include <stdio.h>
#include <stdlib.h>

int n;
int a[101];
int alice=0, bob=0;

void change(int *x, int *y);

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

	for(int i=0;i<2*n;i++){
		for(int j=0;j<n-1;j++){
			if(a[j+1]>a[j])	change(&a[j+1], &a[j]);
		}
	}

	for(int i=0;i<n;i++){
		if(i%2 == 0)	alice += a[i];
		else	bob += a[i];	
	}

	printf("%d", alice-bob);
		

	return 0;
}

void change(int *x, int *y){
	int z;
	z=*y;
	*y=*x;
	*x=z;
}


Measured memory_bytes: 128
from itertools import product

n = input()

if int(n) < 100:
    print(0)

else:
    ans = 0

    for i in range(3,len(n)+1):
        s = list(product("753",repeat=i))
        for combi in s:
            n_s = "".join(combi)
            if int(n_s) > int(n):
                continue
            if ("7" in combi) and ("5" in combi) and ("3" in combi):
                ans += 1
    
    print(ans)


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};


map<ll, int> factorize(ll n) {
    map<ll, int> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res[i] = 0;
        while (n % i == 0) {
            n /= i;
            res[i]++;
        }
    }

    if (n != 1) res[n] = 1;
    return res;

}

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

    vector<ll> numbers(n);
    rep(i, n) cin >> numbers[i];

    vector<map<ll, int>> facts(n);
    rep(i, n)facts[i] = factorize(numbers[i]);


    map<ll, int> facts_map;
    for (map<ll, int> &fact : facts) {
        for (pair<ll, int> f : fact) {
            cmax(facts_map[f.first], f.second);
        }
    }

    mint all = 1;
    for (pair<ll, int> f : facts_map) {
        for (int i = 0; i < f.second; i++) {
            all *= f.first;
        }
    }

    mint ans = 0;
    for (map<ll, int> &fact : facts) {
        mint rate = all;
        for (pair<ll, int> f : fact) {
            for (int i = 0; i < f.second; i++) {
                rate /= f.first;
            }
        }
        ans += rate;
    }


    cout << ans.x << endl;

}


Measured memory_bytes: 3968
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

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

double round(double r) {
    return (r > 0.0) ? floor(r + 0.5) : ceil(r - 0.5);
}

using namespace std;




int main() {
	
	int n;
	cin>>n;
	int s=0;vector<int> t(n);
	for(int i=0;i<n;i++){
		
		cin>>t[i];
		s+=t[i];
	}
	int y=int(round((double)s/n));
	//if(s%n){if(s>0)y++;else y--;}
	int ans=0;
	for(int i=0;i<n;i++){
		int x=abs(t[i]-y);
		ans+=x*x;
	}
	cout<<ans<<endl;



    return 0;
}

	
	


	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int P, Q, R;
    cin >> P >> Q >> R;

    int ans = min(P+Q, Q+R);
    ans = min(ans, P+R);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
{
  const process = (a: number[]): number => {
    if (a[0] >= 13) {
      return a[1]
    }
    if (a[0] <= 5) {
      return 0
    }
    return a[1] / 2
  }

  const Main = (input: string): string => {
    const a: string[] = input.split(" ")
    const na: number[] = a.map((e) => parseInt(e))
    const res = process(na)
    console.log(res)
    return res + ""
  }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"))
}

Measured memory_bytes: 7372
<?php

//5のn乗
$arr = array(5, 25, 125, 625, 3125, 15625);
while (($line = trim(fgets(STDIN))) !== '0') {
    $n = (int)$line;
    $cnt = 0;
    foreach ($arr as $m) {
        $cnt += (int)($n / $m);
    }
    echo $cnt, PHP_EOL;
}

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

int node[10];
string str;
int ans,a,n,cnt;
vector<int> v[10];

vector<int> parse(string s){
  if('1'<=s[0] && s[0]<= '9'){
    return v[s[0]-'0'-1];
  }

  int pos = 0;
  int k=0;
  while(pos<s.size()){
    if(s[pos]=='(')k++;
    if(s[pos]==')')k--;
    
    if(k==1 && s[pos] == ' '){
      vector<int> x = parse(s.substr(1,pos-1));
      vector<int> y = parse(s.substr(pos+1,(int)s.size()-2-pos));
      
      if(node[cnt] == 0){
	cnt++;
	vector<int> res;
	for(int i=0;i<4;i++)
	  res.push_back(x[i]&y[i]);	
	return res;
      }
      
      if(node[cnt] == 1){
	cnt++;
	vector<int> res;
	for(int i=0;i<4;i++)
	  res.push_back(x[i]|y[i]);	
	return res;
      }
      
      if(node[cnt] == 2){
	cnt++;
	vector<int> res;
	for(int i=0;i<4;i++)
	  res.push_back(x[i]!=y[i]);	
	return res;
      }
    }
    pos++;
  }
}

void rec(int s){
  if(s == a){
    cnt = 0;
    vector<int> tmp = parse(str);
    int pop=0;
 
    for(int i=0;i<4;i++)
      if(tmp[i])pop++;
    if(pop==4)ans++;
    
    return;
  }
  for(int i=0;i<3;i++){
    node[s] = i;
    rec(s+1);
  }
}

int main(){
  int c = 0;
  while(getline(cin,str)){
    if(str=="END")break;
    a = 0;
    for(int i=0;i<(int)str.size();i++)
      if(str[i] == ' ')a++;

    cin >> n;
    for(int i=0;i<n;i++){
      v[i].clear();
      int hoge;
      for(int j=0;j<4;j++){
	cin >> hoge;
	v[i].push_back(hoge);
      }
    }
    ans = 0;
    rec(0);
    cout << ans << endl;
    cin.ignore();
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int a[10][10][10],h,w,n;
int dx[]={1,0,0,1,1,0,1,1,1,-1,1,1,0};
int dy[]={0,1,0,0,1,1,1,1,-1,1,0,-1,1};
int dz[]={0,0,1,1,0,1,1,-1,1,1,-1,0,-1};
int dfs(int p,int t,int z,int y,int x){
  int res=1;
  x+=dx[t],y+=dy[t],z+=dz[t];
  if(x>=0&&y>=0&&z>=0&&x<10&&y<10&&z<10)
    if(a[z][y][x]==p)res+=dfs(p,t,z,y,x);
  return res;
}
int check(){
  int p=0;
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      for(int k=0;k<10;k++){
	if(a[i][j][k]){
	  for(int l=0;l<13;l++)
	    p=max(p,dfs(a[i][j][k],l,i,j,k));
	}
      }
  return p;
}
int main(){
  while(cin>>h>>w>>n,n){
    memset(a,0,sizeof(a));
    for(int i=0;i<n;i++){
      int q1,q2;
      cin>>q1>>q2;
      for(int j=0;j<10;j++)
	if(a[j][q1][q2]==0){
	  a[j][q1][q2]=i%2+1;
	  break;
	}
      if(check()>=w){
	if(i%2)cout<<"White"<<' '<<i+1<<endl;
	else cout<<"Black"<<' '<<i+1<<endl;
	i++;
	for(;i<n;i++)cin>>q1>>q2;
      }
      if(i==n-1)cout<<"Draw"<<endl;
    }
  }
}

Measured memory_bytes: 3020