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

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

    vector<vector<int>> c(3,vector<int>(3));
    
    rep(i,3){
        rep(j,3) cin >> c[i][j];
    }
    
    bool flag = true;
    rep(i,2){ //i要素のチェック
        rep(j,2){
            if(c[i+1][j] - c[i][j] != c[i+1][j+1] - c[i][j+1]){
                flag = false;
                break;
            }
            if(c[j+1][i] - c[j][i] != c[j+1][i+1] - c[j][i+1]){
                flag = false;
                break;
            }
        }
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const string s[4] = {"dream", "dreamer", "erase", "eraser"};

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string S; cin >> S;

	bool ok = true;
	while(!S.empty()){
		bool update = false;
		rep (i, 4){
			if ((int)S.length() < (int)s[i].length()) continue;
			string t = S.substr((int)S.length() - (int)s[i].length());
			if (t == s[i]){
				S = S.substr(0, (int)S.length() - (int)s[i].length());
				update |= true;
				break;
			} // end if
		} // end rep
		if (!update){
			ok = false;
			break;
		} // end if
	} // end while

	cout << (ok ? "YES" : "NO") << endl;

	return 0;
}

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

int main(){
 int n;
        cin>>n;
        vector<vector<int>> happiness(n, vector<int>(3));
        vector<vector<int>> dp(n, vector<int>(3, -1));
        for(int i=0; i<n; i++){
                for(int j=0; j<3; j++){
                cin>>happiness[i][j];
}
        }
        for(int i=0; i<n; i++){
        for(int j=0;j<3;j++){
            if(i==0) {
dp[i][j] = happiness[i][j];
}
else{
    int maxAns = INT_MIN;
        for(int k=0;k<3;k++){
            if(k!=j){
                maxAns = max(dp[i-1][k], maxAns);
            }
}
dp[i][j] = happiness[i][j] + maxAns;
}
}
    }
    int ans = INT_MIN;
    for(int i=0;i<3;i++){
        ans = max(ans, dp[n-1][i]);
    }
    cout<<ans;

}







Measured memory_bytes: 14036
def solve(n, k):
    res = 0
    while n > 0:
        n = n // k
        res += 1
    return res


def main():
    n, k = map(int, input().split())
    res = solve(n, k)
    print(res)


def test():
    assert solve(11, 2) == 4
    assert solve(1010101, 10) == 7
    assert solve(314159265, 3) == 18


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3060
use proconio::input;
use std::collections::HashMap;

fn main() {
    input!(n: isize, s:[String; n]);
    let mut m = HashMap::new();
    for c in s {
        *m.entry(c).or_insert(0) += 1;
    }
    let s = ["AC", "WA", "TLE", "RE"].iter()
        .map(|s| (*s).to_owned()).collect::<Vec<String>>();

    for c in s {
        let value = match m.get(&c) {
            Some(&v) => v,
            _ => 0
        };
        println!("{} x {}", c, value)
    }
}


Measured memory_bytes: 7832
num=gets.chomp.split(" ")
x = num[1].to_i + 1
y =num[0].to_i
x.times do
  print("#")
end
puts("#")
y.times do
  str=gets.chomp
  print ("#")
  print(str)
  puts("#")
end
x.times do
  print("#")
end
puts("#")

Measured memory_bytes: 1788
n, m = map(int, input().split())
l = []
r = []
s = [0] * (n+1)
for i in range(m):
    tl, tr = map(int, input().split())
    s[tl-1] += 1
    s[tr] -= 1

for i in range(1, n+1):
    s[i] = s[i] + s[i-1]

print(s.count(m))


Measured memory_bytes: 7028
def gcd (a,b):
	if a < b:
		a,b = b,a
	return a if b == 0 else gcd(b,a%b)

n = int(input())
a = list(map(int,input().split(" ")))
ans = 1

for i in range(n):
	ans *= (a[i]//gcd(ans,a[i]))

print(ans)


Measured memory_bytes: 5600
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	public static void main(String[] args) {
		int N=sc.nextInt();
		int K=sc.nextInt();
		
		if(N%K==0)p(0);
		else p(1);
		
	}
	
	
	
	
	/*static boolean v(int i,long sum1,long sum2) {
		if(i==N) {
			long b=Math.abs(sum1-sum2);
			if(b==0) {
				if(sum1<=K) {
					return true;
				}else return false;
			}else if(b%D==0) {
				if(Math.max(sum1, sum2)<=K)return true;
				else return false;
			}
			else return false;
		}
		
		if(v(i+1,sum1,sum2+v[i]%D))return true;
		
		if(v(i+1,sum1+D-v[i]%D,sum2))return true;
		return false;
		
	}*/
	
	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
S = input()

a= S.count("a")
b= S.count("b")
c=S.count("c")
a,b,c = reversed(sorted([a]+[b]+[c]))

d={}
d["a"]=a
d["b"]=b
d["c"]=c

last2=""
last = ""
for i in range(len(S)):
    if last=="":
        d["a"]-=1
        last2=last
        last="a"
    elif last=="a" and last2=="":
        d["b"]-=1
        last2=last
        last="b"
    else:
        use = list(set("abc")-set(last)-set(last2))[0]
        d[use]-=1
        last2=last
        last=use

if d["a"]==0 and d["b"]==0 and d["c"]==0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAXN 100005
ll a[3], ans;
int main()
{
    cin >> a[0] >> a[1] >> a[2];
    if(a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0){
        printf("0\n");
        return 0;
    }
    sort(a, a + 3);
    printf("%lld", ((a[2] + 1) / 2) * a[1] * a[0] - (a[2] / 2) * a[1] * a[0]);


    return 0;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));
  $b=[0];
  for($i=0;$i<$n;$i++){
    $b[]=$a[$i];
  }
  $sum=0;
  $sa=[0];
  for($i=1;$i<=$n;$i++){
    $sum+=abs($b[$i]-$b[$i-1]);
    $sa[]=abs($b[$i+1]-$b[$i])+abs($b[$i]-$b[$i-1])-abs($b[$i+1]-$b[$i-1]);
  }
  $sum+=abs($b[$n]);

  for($i=1;$i<=$n;$i++){
    echo $sum-$sa[$i].PHP_EOL;  
  }


Measured memory_bytes: 30880
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int N, K;
    cin >> N >> K;
    if (K == 1) cout << 0 << endl;
    else cout << N - K << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define int long long int
#define ld double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

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

int dp[105][N];
pi p[N];

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
	#endif
	IOS;
	int n, w;
	cin >> n >> w;
	for(int i = 1; i <= n; i++){
		int ww, v;
		cin >> ww >> v;
		for(int j = 0; j <= w; j++){
			if(ww <= j)
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-ww] + v);
			else
				dp[i][j] = dp[i-1][j];
		}
	}
	cout << dp[n][w];
	return 0;
}

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

typedef long long LL;
const int N = 100005;

int n, s, x[N];
LL p[N], ans;

int dfs(int l, int r) {
	if (x[r] <= s) return ans += s - x[l], x[l];
	if (s <= x[l]) return ans += x[r] - s, x[r];
	if (p[l] >= p[r]) {
		int pos = (p[l] += p[r], dfs(l, r - 1));
		return ans += x[r] - pos, x[r];
	} else {
		int pos = (p[r] += p[l], dfs(l + 1, r));
		return ans += pos - x[l], x[l];
	}
}

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n >> s;
	for (int i = 0; i < n; ++i) std::cin >> x[i] >> p[i];
	dfs(0, n - 1), std::cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3968
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]


if __name__ == '__main__':
    s = s()
    cf = "CODEFESTIVAL2016"
    for i in range(len(s)):
        if s[i] != cf[i]:
            ans += 1
    print(ans)

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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	cin >> s;
	cout << s.substr(0, s.size() - 8) << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, K;
  cin >> N >> K;
  ll ans = 0ll;
  for (int b = K + 1; b <= N; b++) {
    for (int j = 0; j <= N; j += b) {
      if (j + b <= N)
        ans += b - K;  // [j+K,j+b)
      else if (j + K <= N)
        ans += N - (j + K) + 1;
      // dmp(ans);
    }
  }
  if (K == 0) ans -= N;
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


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

using namespace std;

struct monster {
  long X;
  long H;
};

int main(int argc, char** argv) {
  int N;
  long D, A;
  std::vector<monster> monsters;
  
  cin >> N >> D >> A;

  
  for (int i = 0; i < N; ++i) {
    monster m;
    cin >> m.X >> m.H;
    monsters.push_back(m);
  }

  std::sort(monsters.begin(), monsters.end(), [](const monster& x, const monster& y) {
                                                return x.X < y.X;
                                              });
  // for (monster m: monsters)
  //   cout << m.X << " " << m.H << endl;
  long result = 0;

  for (unsigned i = 0; i < monsters.size(); ++i) {
    if (monsters[i].H % A == 0) {
      monsters[i].H /= A;
    } else {
      monsters[i].H = monsters[i].H / A + 1;
    }
  }

  deque<long> cumsum_x;
  deque<long> cumsum_h;
  long cumsum = 0;

  
  for (unsigned i = 0; i < monsters.size(); ++i) {
    long x = monsters[i].X;
    // cout << cumsum_x.front() << " " << x - 2 * D << endl;
    while (!cumsum_x.empty() && cumsum_x.front() < x - 2 * D) {
      cumsum -= cumsum_h.front();
      cumsum_x.pop_front();
      cumsum_h.pop_front();
    }

    long h = monsters[i].H;

    // cout << x << " " << h << " " << cumsum << endl;
    if (cumsum >= h) {
      continue;
    } else {
      cumsum_x.push_back(x);
      cumsum_h.push_back(h - cumsum);
      result += h - cumsum;
      cumsum += h - cumsum;
    }
  }
  
  // for (unsigned i = 0; i < monsters.size(); ++i) {
  //   long at = monsters[i].X;
  //   long h = monsters[i].H;
  //   if (h <= 0)
  //     continue;

  //   result += h;
  //   for (unsigned j = i + 1; j < monsters.size() && monsters[j].X <= at + 2* D; ++j) {
  //     monsters[j].H -= h;
  //   }
  // }

  cout << result << endl;
  return 0;
}


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

#include <atcoder/all>

// #LIB#

using namespace std;
using namespace atcoder;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#ifdef ONLINE_JUDGE
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');
#endif

int main() {
  ll n, m;
  cin >> n >> m;
  dsu d(n);
  ll ans = n - 1;
  rep(i, m) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    if (!d.same(a, b)) {
      --ans;
      d.merge(a, b);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3760
# your code goes here
N = int(input())

A = list(map(int,input().split()))

ans = 0
ans_plus = 0
l = 0
r = 0
xor_sum = A[0]
sum = A[0]
while 1:
	if xor_sum == sum:
		ans_plus += 1
		ans += ans_plus
		if r == N-1:
			break
		else:
			r += 1
		xor_sum ^= A[r]
		sum += A[r] 
	else:
		ans_plus -= 1
		xor_sum ^= A[l]
		sum -= A[l]
		l += 1

print(ans)
	
	

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

long long a,b,c,d,e,f,r2,r3;
double r1;
unordered_set<int> voda,so;

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

    cin>>a>>b>>c>>d>>e>>f;

    for(int i=0;i<=f/100;i++)
        for(int j=0;j<=f/100;j++)
            voda.insert(i*a*100+j*b*100);
    for(int i=0;i<=f;i++)
        for(int j=0;j<=f;j++)
            so.insert(i*c+j*d);

    for(int i=100*a;i<=f;i++)
        if(voda.count(i)==1)
        {
            int raz=f-i;
            for(int j=0;j<=f;j++)
                if(so.count(j)==1)
                {
                    if(i+j<=f)
                    {
                        double p=100.0*j/(i+j);
                        if(p>=r1&&(1.0*e/100)>=(1.0*j/i))
                        {
                            r1=p;
                            r2=i;
                            r3=j;
                        }
                    }
                }
        }

    cout<<r2+r3<<" "<<r3<<endl;

    return 0;
}


Measured memory_bytes: 10204
import sys
input = sys.stdin.readline
inf = float('inf')


N,A,B = map(int,input().split())
X = list(map(int,input().split()))

ans = 0

for i in range(N-1):
    d = X[i+1]-X[i]
    ans += min(d*A, B)

print(ans)

Measured memory_bytes: 14172
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long


signed main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int n,m; cin >> n >> m;
    if(n + m == 2){
        cout << 1 << endl;
        return 0;
    }
    if(n < 3 && m < 3){
        cout << 0 << endl;
        return 0;
    }
    if(n == 1 || m == 1){
        cout << n + m - 3 << endl;
        return 0;
    }
    if(n == 2 || m == 2){
        cout << 0 << endl;
        return 0;
    }
    cout << (n-2) * (m-2) << endl;
}



Measured memory_bytes: 256
//There was and will always be only one Chester
//RIP legend
#include<bits/stdc++.h>
#define Nilesh ios_base::sync_with_stdio(false)
using namespace std;
int main()
{
    Nilesh;
    int n;
    cin>>n;
    int f[100001]={0};
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        f[a[i]]++;
    }
    int mx=0,count=0;
    for(int i=0;i<=99998;i++)
    {
        count=f[i]+f[i+1]+f[i+2];
        if(count>mx)
            mx=count;
    }
    cout<<mx;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int INF = int(1e9);

int n;
int cnt[26], cur[26];
string s;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    forn(i, 26) cnt[i] = INF;
    forn(i, n) {
        cin >> s;
        forn(j, 26) cur[j] = 0;
        for (char c : s) {
            ++cur[c - 'a'];
        }
        forn(j, 26) {
            cnt[j] = min(cnt[j], cur[j]);
        }
    }
    forn(i, 26) forn(j, cnt[i]) {
        cout << char(i + 'a');
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
static const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int(i)=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(pri2i,n-1)cout<<a[pri2i]<<' '; cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
T prim(WeightedGraph< T > &g) {
  using Pi = pair< T, int >;
 
  T total = 0;
  vector< bool > used(g.size(), false);
  gPr(Pi)que;
  que.emplace(0, 0);
  while(!que.empty()) {
    Pi p = que.top();
    que.pop();
    if(used[p.se]) continue;
    used[p.se] = true;
    total += p.fi;
    for(auto &e : g[p.se]) {
      que.emplace(e.cost, e.to);
    }
  }
  return total;
}

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

template< typename T >
T kruskal(Edges< T > &edges, int V) {
  sort(begin(edges), end(edges), [](const edge< T > &a, const edge< T > &b) {
    return (a.cost < b.cost);
  });
  UnionFind tree(V);
  T ret = 0;
  for(auto &e : edges) {
    if(tree.unite(e.src, e.to)) ret += e.cost;
  }
  return (ret);
}

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n>>m; Edges<int>ed;
  rep(i,m){
    cin>>x>>y>>q;
    ed.eb(x,y,q);
  }
  pri1(kruskal(ed,n));
}


Measured memory_bytes: 4612
char buf[7000],out[114514];
B[3000];
p;
sz;
main()
{
	read(0,buf,7000);
	for(;;)
	{
		int k=buf[sz++];
		if(k<'0')break;
		p=p*10+k-'0';
	}
	for(int i=0;i<p;i++)
	{
		if(buf[sz]&1)
		{
			B[p-1]+=p-1;
			if(i)
			{
				int now=p-1;
				for(int j=p-2;j>0;j--)
				{
					B[j]+=now=now*i%p;
				}
			}
			else
			{
				B[0]=1;
			}
		}
		++sz;++sz;
	}
	int outsz=114514;
	for(int i=p-1;i>=0;i--)
	{
		int now=B[i]%p;
		out[--outsz]=10;
		do{
			out[--outsz]=now%10+'0';
		}while(now/=10);
	}
	write(1,out+outsz,114514-outsz);
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<int> c(n), ret(n, -1);
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
    }
    sort(c.rbegin(), c.rend());
    queue<int> que;
    int idx = 0;
    ret[0] = c[idx];
    idx++;
    que.push(0);
    while (!que.empty())
    {
        int cur = que.front();
        que.pop();
        for (auto v : g[cur])
        {
            if (ret[v] != -1)
                continue;
            ret[v] = c[idx];
            idx++;
            que.push(v);
        }
    }
    int sum = 0;
    for (int i = 1; i < n; i++)
        sum += c[i];
    cout << sum << endl;
    printv(ret);
}


Measured memory_bytes: 1024
/*
	##############################
	## Author: Pratyush Gaurav ###
	## College: NIT ROURKELA #####
	##############################
*/
#include <bits/stdc++.h>

using namespace std;

typedef long long/*--------------------*/lli;
typedef long double/*------------------*/ld;
typedef unsigned long long/*-----------*/ulli;
typedef pair<lli, lli >/*--------------*/plli;
typedef vector<plli >/*----------------*/vplli;

#define rep(i,a)/*---------------------*/for(i = 0 ; i < a ; i++)
#define repr(i,a)/*--------------------*/for(i = a ; i >= 0 ; i--)
#define REP(i,a,b)/*-------------------*/for(i = a ; i <= b ; i++)
#define REPR(i,a,b)/*------------------*/for(i = a ; i >= b ; i--)

#define scan(N)/*----------------------*/scanf("%lld",&N)
#define print(N)/*---------------------*/printf("%lld",N)
#define scan2(N1,N2)/*-----------------*/scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2)/*----------------*/printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3)/*--------------*/scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3)/*-------------*/printf("%lld %lld %lld",N1,N2,N3)

#define lb/*---------------------------*/lower_bound
#define ub/*---------------------------*/upper_bound
#define pb/*---------------------------*/push_back
#define popb/*-------------------------*/pop_back

#define mem(a,b)/*---------------------*/memset(a,b,sizeof(a))
#define opt/*--------------------------*/ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sz/*---------------------------*/size()

#define MP/*---------------------------*/make_pair
#define bs/*---------------------------*/binary_search
#define gcd(a, b)/*--------------------*/__gcd(a, b)
#define lcm(a, b)/*--------------------*/((a)*((b)/gcd(a,b)))
#define sqr(x)/*-----------------------*/(x)*(x)
#define all(a)/*-----------------------*/a.begin(),a.end()

#define ff/*---------------------------*/first
#define ss/*---------------------------*/second

#define endl/*-------------------------*/'\n'
#define inf/*--------------------------*/(lli)2000000000000
#define MOD/*--------------------------*/(lli)1000000007
#define MAXN/*-------------------------*/100005

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0)
    {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else
    {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	lli n,ans = 0;
	cin >> n;
	lli i;
	map<lli,lli> mp;
	map<lli,lli>::iterator it;
	rep(i,n)
	{
	    lli x;
	    cin >> x;
	    mp[x]++;
	}
	for(it = mp.begin() ; it != mp.end() ; it++)
    {
        if(it->second < it->first)
            ans += it->second;
        else
            ans += abs(it->second - it->first);
    }
    cout << ans << endl;
	return 0;
}










Measured memory_bytes: 6272
import java.io.*;

class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0]),m=Integer.parseInt(s[1]);
        System.out.print(n*m);
    }
}


Measured memory_bytes: 32620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

ll kai(ll n){
  ll fac[n+1];
    fac[0]=fac[1]=1;
    for (int i=2;i<=n;i++){
    fac[i]=fac[i-1]*i%mod;
  }
  return fac[n];
}

int main(){
  int n,m;
  cin >> n >> m;
  if(abs(n-m)==1){
    cout << kai(n)*kai(m)%mod << endl;
  }
  else if(abs(n-m)==0){
    cout << kai(n)*kai(m)%mod*2%mod << endl;
  }
  else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
use std::io::stdin;

fn main() {
    let mut ab = String::new();
    stdin().read_line(&mut ab).unwrap();
    let mut ab: Vec<usize> = ab.trim().split_whitespace().flat_map(str::parse).collect();
    ab.sort();
    let (a, b) = (ab[0], ab[1]);
    let c = if b - a < 2 {
        a + b
    } else {
        b + b - 1
    };
    println!("{}", c);
}


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

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

  vector<int> C(26);
  for (int i = 0; i < 26; i++) cin >> C.at(i);

  vector<vector<int>> S(D, vector<int>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) cin >> S.at(i).at(j);
  }

  vector<int> L(26);
  long long total_score = 0;

  for (int d = 0; d < D; d++) {
    int type = 0;
    long long score = -1000000000000;

    // d 日目に i を開くとしたとき
    for (int i = 0; i < 26; i++) {
      long long tmp = 0;
      tmp += S.at(d).at(i);
      for (int j = 0; j < 26; j++) {
        if (j == i) continue;
        tmp -= C.at(j) * (d+1 - L.at(j));
      }
      if (tmp > score) {
        score = tmp;
        type = i;
      }
    }

    L.at(type) = d+1;
    total_score += score;

    cout << type + 1 << endl;
  }
}


Measured memory_bytes: 3664
caseN = 0
while True:
    caseN += 1
    W = int(input())
    if W == 0: break
    N = int(input())
    tr = [list(map(int, input().split(','))) for _ in range(N)]
    dp = [0 for x in range(W+1)]
    for x in range(N):
        for y in range(W,tr[x][1]-1,-1):
            dp[y] = max(dp[y], dp[y-tr[x][1]] + tr[x][0])
    sum_weight = 0
    sum_value = 0
    ind = N%2
    for x in range(W+1):
        if dp[x] > sum_value:
            sum_weight = x
            sum_value = dp[x]
    print("Case ", caseN, ":", sep='')
    print(sum_value)
    print(sum_weight)

Measured memory_bytes: 6816
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ll n, d, x, y;
	cin >> n >> d;
	d *= d; int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> x >> y;
		x = x * x + y * y;
		if (x <= d)
			cnt++;
	}
	cout << cnt;
	return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
        long double N;
        int K;
        cin >> N >> K;

        long double ans = 0;
        long double a = 1/N;
        for(int i = 1; i <= N; i++)
        {
                int b = 0;
                int t = i;
                while(t < K)
                {
                        t *= 2;
                        b++;
                }
                double c = pow(0.5, b);
                ans += a * c;
        }

        cout << setprecision(12) << ans << endl;

        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
const int mod = 1000 * 1000 * 1000 + 7;

vector<vector<int>> dp;
vector<string> v;

int main() {
	int H, W; cin >> H >> W; v.resize(H);
	for (auto &x : v) { cin >> x; }
	dp.resize(H, vector<int>(W, 0));
	dp[0][0] = 1; for(int i = 0; i < H; i++) for (int j = 0; j < W; j++) if((i || j) && v[i][j] == '.')
			dp[i][j] = ((i ? dp[i - 1][j] : 0) + (j ? dp[i][j - 1] : 0)) % mod;
	cout << dp[H - 1][W - 1] << '\n'; cin.ignore(2); return 0;
}

Measured memory_bytes: 9504
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#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 Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

bool G[60][60];
bool visited[60];
int a[60];
int b[60];
int n, m;

// 全部のノードをdfs
void dfs(int v) {
    visited[v] = true;
    for(int i = 0; i < n; i++) {
        if(G[v][i] == false) continue;
        if(visited[i]) continue;
        dfs(i);
    }
}

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

    cin >> n >> m;
    rep(i, m) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]] = G[b[i]][a[i]] = true;
    }

    int cnt = 0;
    rep(i, m) {
        G[a[i]][b[i]] = G[b[i]][a[i]] = false; // 辺を削除
        fill(visited, visited + n, false);

        dfs(0);

        bool flg = false;
        rep(j, n) {
            if(visited[j] == false) flg = true;
        }
        if(flg) cnt++;
        G[a[i]][b[i]] = G[b[i]][a[i]] = true; // 辺を復活させる
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read();
    let d: u32 = read();
    let x: u32 = read();
    let a: Vec<u32> = (0..n).map(|_| read()).collect();
    let ans = a.iter().map(|x| (d + x - 1) / x).fold(0, |a, x| a + x) + x;
    println!("{}", ans);
}


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

int main()
{
  int N;
  int AC=0,WA=0,TLE=0,RE=0;
  string S;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    cin>>S;
    if(S=="AC")
      AC++;
    if(S=="WA")
      WA++;
    if(S=="TLE")
      TLE++;
    if(S=="RE")
      RE++;
  }
  cout<<"AC x "<<AC<<"\n";
  cout<<"WA x "<<WA<<"\n";
  cout<<"TLE x "<<TLE<<"\n";
  cout<<"RE x "<<RE<<"\n";
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ll w, h, x, y;
    int cnt = 0;
    cin>>w>>h>>x>>y;
    if (x*2==w and y*2==h) cnt=1;
    cout << fixed<<setprecision(10)<< h*w/2.0 << " " << cnt <<endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"sort"
	"strconv"
)

type IntListForSort []int

func (s IntListForSort) Len() int           { return len(s) }
func (s IntListForSort) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSort) Less(i, j int) bool { return s[i] < s[j] }

func sortIntList(intList []int) {
	sort.Sort(IntListForSort(intList))
}

type IntListForSortDesc []int

func (s IntListForSortDesc) Len() int           { return len(s) }
func (s IntListForSortDesc) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSortDesc) Less(i, j int) bool { return s[i] > s[j] }

func sortIntListDesc(intList []int) {
	sort.Sort(IntListForSortDesc(intList))
}

// ASC前提
func binarySearchInt(intList []int, key int, iMin int, iMax int) int {
	if iMax < iMin {
		return -1
	} else {
		iMid := iMin + (iMax-iMin)/2
		if intList[iMid] > key {
			return binarySearchInt(intList, key, iMin, iMid-1)
		} else if intList[iMid] < key {
			return binarySearchInt(intList, key, iMid+1, iMax)
		} else {
			return iMid
		}
	}
}

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	n, _ := strconv.Atoi(input())
	fmt.Println(n * n * n)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    string s, t;
    cin >> s >> t;

    rep(i,2*n) {
        if (i%2==0) cout << s[i/2];
        else cout << t[(i-1)/2];
    }

    cout << endl;

}

Measured memory_bytes: 256
x = list(map(int,input().split()))
n = x[0]
k = x[1]
sunuke = [0]*n

for i in range(k):
    d = int(input())
    a = list(map(int,input().split()))
    for i in range(d):
        sunuke[a[i]-1] += 1

count = 0
for i in range(n):
    if sunuke[i] == 0:
        count += 1

print(count)

Measured memory_bytes: 9140
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

int main(void){
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            if(i<b && j<a)
                cout << 1;
            else if(i>=b && j<a)
                cout << 0;
            else if(i<b && j>=a)
                cout << 0;
            else if(i>=b && j>=a)
                cout << 1;
        }
        cout << endl;
    }
    return 0;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;

using pll = pair<ll,ll>;
using vpl = vector<pll>;
using vvpl = vector<vpl>;

using tll = tuple<ll,ll,ll>;
using vtl = vector<tll>;

using vb = vector<bool>;
using vvb = vector<vb>;

using ld = long double;
using vd = vector<ld>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;

#define R(a,i) for(ll a=0; a < (i); (a)++)
#define FOR(a,i,j) for(ll a=(i); a < (j); (a)++)
#define RD(a,i) for(ll a=(i)-1; (a) >= 0; (a)--)
#define FORD(a,i,j) for(ll a=(j)-1; (a) >= (i); (a)--)

#define xx first
#define yy second
#define pb push_back
#define eb emplace_back

#define all(X) begin(X),end(X)
#define sz(X) (X).size()

const ll oo = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-9;

#define DBG 0
#define TR(X) {if(DBG) cerr << (#X) << " = " << (X) << "\n";}
#define TRV(X,i) {if(DBG) cerr << (#X) << "[" << i << "] = " << (X[i]) << "\n";}
#define TRM(X,i,j) {if(DBG) cerr << (#X) << "[" << i << "][" << j << "] = " << (X[i][j]) << "\n";}
#define TRP(X,i,j) {if(DBG) cerr << (#X) << "[" << i << "][" << j << "] = (" << (X[i][j]).xx << ", " << (X[i][j]).yy << ")\n";}
#define hline {if(DBG) cerr << "----------------------------------------------------------------------" << "\n";}
#define PK(X) {if(DBG) cerr << (X) << "\n";}

const ll mod = 1e9+7;

template <class T>
void myMin(T& a, T b){
	a = min(a,b);
}

template <class T>
void myMax(T& a, T b){
	a = max(a,b);
}

int main(void){
	cin.sync_with_stdio(false);
	cin.tie(0);

	ll N;
	cin >> N;

	vvl adj(N, vl(N, 0));

	FOR(i,0,N){
		FOR(j,0,N){
			cin >> adj[i][j];
		}
	}

	vl dp(1LL << N);
	FOR(i,0,(1LL << N)){
		ll cur = 0;
		FOR(j,0,N){
			FOR(k,j,N){
				if(( i & ( (1LL << j) | (1LL << k))) == ( (1LL << j) | (1LL << k))) {
					cur += adj[j][k];
				}
			}
		}
		dp[i] = cur;
		TR(bitset<16>(i));
		TR(dp[i]);
	}

	vl res(1LL << N);
	FOR(mask,0, 1LL<<N) {
		hline;
		TR(bitset<16>(mask));
		for(ll smask = mask; smask > 0; smask = (smask - 1) & mask) {
			TR(bitset<16>(smask));
			TR(bitset<16>(mask ^ smask));
			myMax(res[mask], dp[smask] + res[mask ^ smask]);
			TR(res[mask]);
		}
	}

	cout << res[(1LL << N) - 1] << endl;
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>

int main(){
	int h, w, n;
	std::cin >> h >> w >> n;
	int cnt = 0;
	int i = 0;
	while(cnt < n){
		i++;
		if(h>=w){
			cnt += h;
			w--;
		}else{
			cnt += w;
			h--;
		}
	}
	std::cout << i <<std::endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
n,p=map(int,input().split())
d=defaultdict(int)
for i in range(2,int(p**.5)+1):
  while p%i==0:
    p//=i
    d[i]+=1
if p>1:
  d[p]+=1
ans=1
for k, v in d.items():
  ans *= k**(v//n)
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
ll f(ll X) {
    ll res = 0;
    while (X > 0) {
        res += X % 10;
        X /= 10;
    }
    return res;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    if (n % f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

int main(){
    long long h,w;
    cin >> h >> w;
    long long ans = h*w;
    if(ans % 2==1)ans = (ans+1)/2;
    else ans /= 2;
    if(h==1 || w==1)ans =1;
    cout << ans << endl;
}

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

int main() {
	
	int n;
	int p[20]={};
	int a,v;
	int max=0;
	
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>a>>v;
		
		p[a-1] = v;
		if(v>max)max=v;
	}
	
	for(int i=0;i<n;++i){
		if(p[i]==max){
			cout<<i+1<<" "<<p[i]<<endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using psi = pair<string, int>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
const int mod = 1e9+7;
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a / gcd(a, b)*b;}

int N, M, K, H, W, L, R, X;
string S, T;

signed main(){
  cin >> S;
  rep(i,3){
    if(S[i]==S[i+1]){
      COUT("Bad");
      return 0;
    }
  }
  COUT("Good");
  return 0;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String base = null;
		String comparison = null;
		
		try {
			base = br.readLine();
			comparison = br.readLine();
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
		
		Inversions(base, comparison, br);
		
	}

	public static void Inversions(String base, String comparison,  BufferedReader br){ 
		int length = base.length() - comparison.length();
		String 	container;
		
		for(int i = 0; i <= length ; i ++ ) {
			container = base.substring( i, i + comparison.length() );
			if( container.equals(comparison) ) {
				System.out.println(i);
			}
		}
		
	}
}

/* 実行時間計測用

		long start = System.currentTimeMillis();
		long end = System.currentTimeMillis();
		System.out.println((end - start)  + "ms:計測時間");
*/


Measured memory_bytes: 24596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,a,b) for(int i=(a);i<=(b);i++)
#define em emplace_back
#define ALL(x) (x).begin(),(x).end()
#define mkp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define oi ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
//#define lb(x) (x&-x)

int n,cnt=0;
int main(){
    //oi;
    cin>>n;
    REP1(i,1,n) if(i&1)cnt++;
    cout<<fixed<<setprecision(6)<<(double)cnt/n<<"\n";
//    system("pause");
    return 0;
}


Measured memory_bytes: 384