akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n, m;
    string s[100], t[100];
    cin >> n;
    rep(i, n){
        cin >> s[i];
    }
    cin >> m;
    rep(i, m){
        cin >> t[i];
    }

    int count, ans = 0;
    rep(i, n){
        count = 0;
        rep(k, n){
            if(s[i] == s[k]){
                count++;
            }
        }
        rep(j, m){
            if(s[i] == t[j]){
                count--;
            }
        }
        ans = max(ans, count);
    }    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { reader: s.lock() };
    let mut a: Vec<i64> = sc.read_vec(4);
    a.sort();
    if a == vec![1, 4, 7, 9] {
        println!("YES");
    } else {
        println!("NO");
    }
}

pub struct Scanner<R> {
    reader: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

quickSortList :: (Ord a, VM.Unbox a) => [a] -> [a]
quickSortList xs = ST.runST $ do
    arr <- V.thaw $ V.fromList xs
    let beg = 0
        end = VM.length arr - 1
    quickSortVec beg end arr
    V.toList <$> V.freeze arr

quickSortVec l u arr
  | l >= u    = return ()
  | otherwise = do
      VM.unsafeSwap arr l ((u+l)`div`2)
      t <- VM.unsafeRead arr l
      let i = l
          j = u + 1
      nj <- loopVec t u i j arr
      VM.unsafeSwap arr l nj
      quickSortVec l (nj-1) arr
      quickSortVec (nj+1) u arr

loopVec !t !u !i !j arr = do
  ni <- doWhile i (+1)         (< t)
  nj <- doWhile j (subtract 1) (> t)
  if ni > nj
    then return nj
    else do VM.unsafeSwap arr ni nj
            loopVec t u ni nj arr
              where
                {-# INLINE doWhile #-}
                doWhile k op p
                  | nk > u    = return nk
                  | otherwise = do
                      x <- VM.unsafeRead arr nk
                      if p x then
                        doWhile nk op p
                        else
                        return nk
                        where
                          nk = op k

main = do
  [n, c, k] <- getIntList

  ts0 <- replicateM n getInt
  let ts = quickSortList ts0

  let solve ts@(x:xs) t res = let t' = x + k
                                  ts' = dropNWhile c t' ts
                              in solve ts' t' (res+1)
      solve [] _ res = res

      dropNWhile _ _ [] = []
      dropNWhile n t xs@(x:xs') | n == 0 || x > t = xs
                                | otherwise = dropNWhile (n-1) t xs'

  print $ solve ts 0 0

Measured memory_bytes: 23932
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<lint, int> pi;
typedef long long lint;
const int MAXN = 100005;

int n, m;
vector<int> ord;
vector<int> gph[MAXN];
int dp[MAXN], pdp[MAXN], par[MAXN], cz[MAXN];

void dfs(int x, int p){
	ord.push_back(x);
	par[x] = p;
	for(auto &i : gph[x]){
		if(i != p) dfs(i, x);
	}
}

int main(){
	cin >> n;
	for(int i=0; i<n-1; i++){
		int s, e;
		scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	dfs(0, -1);
	for(int i=ord.size()-1; i>=0; i--){
		int x = ord[i];
		for(auto &j : gph[x]){
			if(par[x] == j) continue;
			dp[x] += dp[j];
			if(dp[j] == 0) cz[x]++;
		}
		dp[x] += max(cz[x] - 1, 0);
	}
	for(int i=1; i<ord.size(); i++){
		int x = ord[i];
		int new_zero_count = cz[par[x]] - (dp[x] == 0);
		if(par[x] != 0 && pdp[par[x]] == 0) new_zero_count++;
		pdp[x] = dp[par[x]] - max(cz[par[x]] - 1, 0) - dp[x];
		pdp[x] += pdp[par[x]];
		pdp[x] += max(new_zero_count - 1, 0);
	}
	int ret = 1e9;
	for(int i=0; i<n; i++){
		int ans = 1;
		int count_zero = 0;
		for(auto &j : gph[i]){
			if(par[i] == j){
				ans += pdp[i];
				if(pdp[i] == 0) count_zero++;
			}
			else{
				ans += dp[j];
				if(dp[j] == 0) count_zero++;
			}
		}
		ans += max(count_zero - 1, 0);
		ret = min(ret, ans);
	}
	cout << ret << endl;
}


Measured memory_bytes: 12408
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INF = pow(2,29);
const int MOD = 1000000007;

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

  string result = "second";
  rep(i, N) {
    int a; cin >> a;
    if (a%2==1) result = "first";
  }
  cout << result << endl;
  return 0;
}

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

typedef long long int int64;
static const int64 mod = 1000000007LL;

int64 pow2(int x)
{	
	int64 val = 1;
	for(int i = 30;i >= 0;--i) {
		val = val * val % mod;
		if(((x >> i) & 1) == 1) {
			val = val * 2 % mod;
		}
	}
	return val;
}

std::pair<int64,int64> solve(std::vector<int> h)
{
	if(h.empty()) return std::make_pair(1,1);
	int min = h[0];
	for(int i = 1;i < h.size();++i) if(h[i] < min) min = h[i];
	std::vector<int> cur;
	int64 v1 = 1, v2 = 1;
	int w = 0;
	for(int i = 0;i <= h.size();++i) {
		if(i == h.size() || h[i] == min) {
			if(!cur.empty()) {
				std::pair<int64,int64> res = solve(cur);
				v1 = v1 * res.first % mod;
				v2 = v2 * (res.first + res.second) % mod;
				cur.clear();
			}
			++w;
		} else {	
			cur.push_back(h[i] - min);
		}
	}
	--w;
	return std::make_pair(v1*pow2(min)%mod, (v2*pow2(w)+(pow2(min)-2)*v1)%mod);
}

int main()
{
	int n;
	std::vector<int> h;
	scanf("%d",&n);
	for(int i = 0;i < n;++i) {
		int k;
		scanf("%d",&k);
		h.push_back(k);
	}
	std::pair<int64,int64> ans = solve(h);
	printf("%lld\n", ans.second);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
template<class T> inline bool amax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool amin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> ostream& operator << (ostream &os, const vector<T> &v) { os << "["; for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); it++) { os << (it != v.begin() ? ", " : "") << *it; } os << "]"; return os; }
template<class T> ostream& operator << (ostream &os, const set<T> &s) { os << "["; for (typename set<T>::const_iterator it = s.begin(); it != s.end(); it++) { os << (it != s.begin() ? ", " : "") << *it; } os << "]"; return os; }
template<class Key, class Val> ostream& operator << (ostream &os, const map<Key, Val> &m) { os << "{"; for (typename map<Key, Val>::const_iterator it = m.begin(); it != m.end(); it++) { os << (it != m.begin() ? ", " : "") << it->first << ":" << it->second; } os << "}"; return os; }
template<class T, class S> ostream& operator << (ostream &os, const pair<T, S> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <class T> istream& operator >> (istream &is, vector<T> &v) { for (size_t i = 0; i < v.size(); i++) is >> v[i]; return is; }
template <class Target, class Source> inline Target lexical_cast (const Source &s) { Target t; stringstream ss; ss << s; ss >> t; return t; }

//> v < ^ (clock wise)
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
const int INFI = 1<<28;
const long long int INFL = 1LL<<60;
const double INFD = 1e+300;
const float INFF = 1e+100;
const double EPS = 1e-8;
const long long int MOD = 1000000007;

int solve ();
int main () {
    cout.setf(ios::fixed); cout.precision(10);
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}

int solve () {
    int b, r, g ,c, s, t;
    while(cin >> b >> r >> g >> c >> s >> t, b || r || g || c || s || t){
        cout << (b * 15 + r * 15 + -3 * t + (5 * b + 3 * r) + 3 * s + (5 * 15) * b + (3 * 15) * r + g * 7 + c * 2 + 100) << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最大公約数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){
int N,M,C;
cin >> N >> M >> C;
vector<int> B(M);
vector<vector<int>> A = vector<vector<int>> (N,vector<int>(M));
int cnt = 0;
for(int i = 0; i < M; i++){
cin >> B[i];
}
for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j ++){
        cin >> A[i][j];
    }

}

for(int i = 0; i < N; i++){
    int ans = 0;
    for(int j = 0; j < M; j ++){
        ans += A[i][j]*B[j];
    }
if(ans+C > 0)cnt++;
}
cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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 () {
  int n, m;
  cin >> n >> m;
  if (n == m) yn;
  return 0;
}

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


int main() {
#ifdef LOCAL
ifstream fin("1.txt");
streambuf*p;
p=cin.rdbuf(fin.rdbuf());
#endif // LOCAL
ll n;
cin>>n;
bitset<32>b(n);
cout<<b<<endl;
cout<<(~b)<<endl;
cout<<(b<<1)<<endl;
cout<<(b>>1)<<endl;


#ifdef LOCAL
fin.close();
#endif // LOCAL
}



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

using namespace std;

int main(){
    int n,k;cin>>n>>k;
    bool visited[n+1];
    memset(visited,0,sizeof(visited));
    for(int i=0;i<k;i++){
        int d;cin>>d;
        for(int j=0;j<d;j++){
            int x;cin>>x;
            if(!visited[x]){
                visited[x]=true;
                n--;
            }
        }
    }
    cout <<n<<endl;
}


Measured memory_bytes: 3576
n = int(input())
xy = [[int(i) for i in input().split()] for i in range(n)]

if n == 1:
    print(1)
    exit()
dic = {}
for x1,y1 in xy:
    for x2,y2 in xy:
        if x1 == x2 and y1 == y2:
            continue
        dx = x2 - x1
        dy = y2 - y1
        key = "{},{}".format(dx,dy)
        if key in dic:
            dic[key] += 1
        else:
            dic[key] = 1

for k, v in sorted(dic.items(), key=lambda x: -x[1]):
    print(n-v)
    break

Measured memory_bytes: 39792
#include <iostream>
#include <vector>

bool serach(std::vector<int>, int);
bool serach(std::vector<int>, int, int, int);

int main(int argc, char const *argv[]){
	int n,q;
	int a,m;
	std::vector<int> A;
	std::cin >> n;
	for (int i = 0; i < n; ++i){
		std::cin >> a;
		A.push_back(a);
	}

	std::cin >> q;
	for (int i = 0; i < q; ++i){
		std::cin >> m;
		if(serach(A,m)) std::cout << "yes" << std::endl;
		else			std::cout << "no"  << std::endl;
	}

	return 0;
}

bool serach(std::vector<int> A, int m){
	for (int i = 0; i < A.size(); ++i){
		if(serach(A,0,m,i)) return true; 
	}
	return false;
}

bool serach(std::vector<int> A, int sum, int m, int I){
	sum += A[I];
	if(sum==m){
		return true;
	}else if(sum>m){
		return false;
	}else{
		for (int i = I+1; i < A.size(); ++i){
			if(serach(A,sum,m,i)) return true;
		}
		return false;		
	}
}


Measured memory_bytes: 3156
#include <iostream>

using namespace std;
struct solv{
    int water;
    int sugar;

    solv(int w, int s) : water(w), sugar(s) {}

    int weight() { return water + sugar; }
};

int a, b, c, d, e, f;

bool operator<(solv x, solv y) {
    return x.sugar*y.weight() < y.sugar*x.weight();
}

bool safe_weight(solv x) {
    return x.weight() <= f;
}

bool ok(solv x) {
    return x.sugar * 100 <= x.water * e;
}

solv dfs(solv now, int phase) {
    switch(phase) {
        case 0: {// add 100A water
            solv next(now.water+100*a, now.sugar);
            if(safe_weight(next)) {
                return max(dfs(next, 0), dfs(now, 1));
            } else {
                return dfs(now, 1);
            }
            break;
        }
        case 1: {// add 100B water
            solv next(now.water+100*b, now.sugar);
            if(safe_weight(next)) {
                return max(dfs(next, 1), dfs(now,2));
            } else {
                return dfs(now, 2);
            }
            break;
        }
        case 2: {// add C sugar
            solv next(now.water, now.sugar+c);
            if(safe_weight(next) && ok(next)) {
                return max(dfs(next, 2), dfs(now, 3));
            } else {
                return dfs(now, 3);
            }
            break;
        }
        case 3: {// add D sugar
            solv next(now.water, now.sugar+d);
            if(safe_weight(next) && ok(next)) {
                return max(dfs(next, 3), dfs(now, 4));
            } else {
                return dfs(now, 4);
            }
            break;
        }
        default: // end
            return now;
    }
}

solv dfsfirst() {
    return max(dfs(solv(100*a, 0), 0), dfs(solv(100*b, 0), 1));
}


int main() {
    cin >> a >> b >> c >> d >> e >> f;
    solv res = dfsfirst();
    cout << res.weight() << " " << res.sugar << endl;



    return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter, deque, defaultdict
from math import factorial
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a, b = MAP()
b *= 2
print(max(a-b,0))

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

int main(){
	string s; int n;
	cin>>n>>s;
	int tam=s.size();
	for(int i=0;i<tam;i++){
		if(s[i]+n<='Z'){
			s[i]=s[i]+n;
		}else {
			s[i]='A'+n-('Z'-s[i])-1;
		}
		
	}
	cout<<s;
	return 0;
}


Measured memory_bytes: 3604
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(int i=a; i<n; i++)
#define ford(i,a,n) for(int i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 20

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,m;
  cin>>n>>m;
  string s[n];
  fori(i,0,n) cin>>s[i];
  ll a[n][m]={};
  a[0][0]=1;
  fori(i,0,n)
  {
    fori(j,0,m)
    {
      if(i!=0)
      {
        if(s[i-1][j]!='#') a[i][j]=a[i-1][j];
      }
      if(j!=0)
      {
        if(s[i][j-1]!='#') a[i][j]=(a[i][j]+a[i][j-1])%mod;
      }
    }
  }
  cout<<a[n-1][m-1]<<endl;
  return 0;
}

ll gcd(ll a,ll b)
{
  if(b==0)
    return a;
  return gcd(b,a%b);
}

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

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

ll power(ll x,ll y,ll p)
{
  ll res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    y=y>>1;
    x=(x*x)%p;
  }
  return res;
}

ll power(ll x,ll y)
{
  ll res=1;
  while(y>0)
  {
    if(y&1)
      res=res*x;
    y=y>>1;
    x=x*x;
  }
  return res;
}


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

using namespace std;

int a[222222], s[20];
int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	for (int i = 0; i < n - 1; i++)
		if (a[i] >= a[i + 1])
			goto q;
	cout << 1 << endl;
	return 0;
q:
	int l = 1, r = n;
	while (l + 1 < r) {
		int m = (l + r) / 2;
		fill(s, s + 20, 0);
		for (int i = 1; i < n; i++) {
			if (a[i - 1] < min(a[i], 20)) {
				fill(s + a[i - 1], s + 20, 0);
				continue;
			}
			if (a[i] > 20)
				continue;
			int j = a[i] - 1;
			while (j + 1 && ++s[j] == m)
				s[j--] = 0;
			if (j < 0) goto p;
		}
		r = m;
		continue;
	p:
		l = m;
	}
	cout << r << endl;
	return 0;
}


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

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









Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
const int N=200000+10;

int a[N];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;++i)
        scanf("%d",a+i);
    --a[0];
    for(int i=1;i<n;++i)
    {
        if(a[i]>a[i-1])--a[i];
        else if(a[i]<a[i-1])
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0052();
	}
	
	class AOJ0052{
		
		int doIt(int n){
			int result = 0;
			while(n>0){
				n=n/5;
				result += n;
			}
			return result;
		}
		
		public AOJ0052() {
			while(true){
				int n = in.nextInt();
				if(n==0)break;
				System.out.println(doIt(n));
			}
		}
	}
}

Measured memory_bytes: 17196
import std.stdio, std.string, std.conv, std.array, std.algorithm;
import std.uni, std.range, std.math, std.container, std.datetime;
import core.bitop;

immutable long MOD = 1_000_000_007;

void main(){
    char[] buf; readln(buf);
    auto N = buf.split.to!(int[])[0];
    string[] ans = new string[](N);
    foreach(i ; 0 .. N){
        readln(buf);
        ans[i] = buf.chomp.to!string;
    }
    sort(ans);
    writeln(join(ans));
}

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

int main(){
  int n;
  cin >> n;
  ll ans = 1;
  ll a[n];
  rep(i,n) cin >> a[i];
  rep(i,n) {
    if(a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i,n) {
    if(a[i] > INF/ans) {
      cout << -1 << endl;
      return 0;
    } else {
      ans *= a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4412
using System;

namespace _024_PhysicalExperiments
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				decimal velocity = decimal.Parse (inputStr);

				decimal time = velocity / 9.8m;
				decimal distance = 4.9m * time * time;
				decimal floor = decimal.Ceiling (distance / 5 + 1m);

				Console.WriteLine (floor);
			}
		}
	}
}

Measured memory_bytes: 9220
import java.util.*;
 
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
      	int n=sc.nextInt();
      	int o=0;
      	String s;
      	int n2=(int)(n/1.08);
      	if((int)(n2*1.08)==n)o=n2;
      	if((int)((n2+1)*1.08)==n)o=n2+1;
      	if(o==0)s=":(";
      	else s=Integer.toString(o);
      	System.out.println(s);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define mod 1000000007


void solve()
{
    int n;cin>>n;
    vector<int>arr(n);
    vector<int>sum(n,0);
    for(int i=0;i<n;i++)
    cin>>arr[i];
   sum[n-1]=arr[n-1];
   for(int i=n-2;i>=0;i--)
   sum[i]=(sum[i+1]+arr[i])%mod;
    
    int ans=0;
    for(int i=0;i<n;i++)
    {
        int term=(arr[i]*(sum[i]-arr[i]+mod))%mod;
        ans+=term%mod;
        ans=ans%mod;
    }
    cout<<ans%mod<<endl;
}
int32_t main()
{
    rapido;
    int t;
    //cin>>t;
    t=1;
       while(t--)
       solve();
}

Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	
   	ll n,x;    cin>>n>>x;
   	vl a(n),b(n,LINF);
   	rep(i,n)cin>>a[i];
   	ll ans=LINF;
   	rep(k,n){
   	    ll res=x*k;
   	    rep(i,n){
   	        b[i]=min(b[i],a[(i-k+n)%n]);
   	        res+=b[i];
   	    }
   	    ans=min(ans,res);
   	}
   	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  
  cin>>S;
  
  int turn=0;
  
  if(S.size()==1){
    cout<<turn<<endl;
    return 0;
  }
  
  for(int i=1;i<S.size();i++){
    if(S.at(i)==S.at(i-1)){
      if(S.at(i)=='0')
        S.at(i)='1';
      else
        S.at(i)='0';
      
      turn++;
    }
  }
 
  cout<<turn<<endl;
  
  return 0;
}

Measured memory_bytes: 512
import java.util.*;

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

class Solver {

    public void run() {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();

        int cnt = 0;
        for (int i = 0; i <= A; i++) {
            for (int j = 0; j <= B; j++) {
                for (int k = 0; k <= C; k++) {
                    int sum = i * 500 + j * 100 + k * 50;
                    if (sum == X) {
                        cnt++;
                    }
                }
            }
        }

        System.out.println(cnt);

        return;
    }

}

Measured memory_bytes: 21972
# 00.11 sec    7004 KB    5 lines     214 bytes 
n,m,l=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(n)]
b=[list(map(int,input().split()))for _ in range(m)]
[print(*x)for x in[[sum(s*t for s,t in zip(c,l))for l in zip(*b)]for c in a]]

Measured memory_bytes: 7004
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define lld long long
#define llu unsigned long long

using namespace std;
long long n,i,s,c,a[100010];
int main()
{

	scanf("%lld",&n);
	for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
	sort(a,a+n);
	for(c=1,s=i=0;i<n-1;i++)
	{
		s+=a[i];
		if(s*2>=a[i+1])			
			c++;
		else
			c=1;			
	}
	printf("%lld\n",c);
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int i,j,k,n,d,sum=0;
  int x[11][11],cnt=0;
  scanf("%d %d",&n,&d);
  for(i=0;i<n;i++){
    for(j=0;j<d;j++)
      scanf("%d",&x[i][j]);
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      sum=0;
      for(k=0;k<d;k++)
        sum += (x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      for(k=0;k<127;k++){
        if(sum == k*k)
          cnt++;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main() {
	int n;
	map<int, int> arr0;
	map<int, int> arr1;
	int v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> v;
		if (i % 2 == 0) {
			if (arr0.find(v) == arr0.end()) arr0[v] = 0;
			arr0[v] += 1;
		}
		if (i % 2 == 1) {
			if (arr1.find(v) == arr1.end()) arr1[v] = 0;
			arr1[v] += 1;
		}
	}
	pair<pair<int, int>, pair<int, int>> maxim0 = { {-1, 0}, {-1, 0} };
	pair<pair<int, int>, pair<int, int>> maxim1 = { { -1, 0 }, {-1, 0 }};
	for (auto elem : arr0) {
		if (elem.second > maxim0.second.second && elem.second <= maxim0.first.second) {
			maxim0.second = elem;
		}
		if (elem.second > maxim0.first.second) {
			maxim0.second = maxim0.first;
			maxim0.first = elem;
		}
	}
	for (auto elem : arr1) {
		if (elem.second > maxim1.second.second) {
			maxim1.second = elem;
		}
		if (elem.second > maxim1.first.second) {
			maxim1.second = maxim1.first;
			maxim1.first = elem;
		}
	}
	int a1, a2;
	//cout << maxim0.first.second << " " << maxim0.second.second << endl;
	//cout << maxim1.first.second << " " << maxim1.second.second << endl;
	if (maxim0.first.first != maxim1.first.first) {
		cout << n - maxim0.first.second - maxim1.first.second << endl;
		return 0;
	}
	if (maxim0.first.second + maxim1.second.second > maxim1.first.second + maxim0.second.second) {
		cout << n - (maxim0.first.second + maxim1.second.second) << endl;
	}
	else {
		cout << n - (maxim1.first.second + maxim0.second.second) << endl;
	}
}

Measured memory_bytes: 4992
#include <stdio.h>
#define LL long long
LL x,i,j,y;
LL f(LL a)
{
    return a*a*a*a*a;
}
int main()
{
    scanf("%lld",&x);
    for(i=-1000; i<=1000; i++)
    {
        y=f(i)+x;
        for(j=-1000; j<=1000; j++)
        {
            if(f(j)==y)
            {
                printf("%lld %lld\n",j,i);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<string>
#include<cstdlib>
#define N 10
#define M 1000000000

using namespace std;
typedef long long lli;

int pw[N];
lli dp[N];

void init(int& n){
  dp[0]=1;
  for(int i=1; i<N; ++i){
    pw[i]=0;
    if(dp[i-1]){
      dp[i] = n*dp[i-1];
      if(dp[i]>M) dp[i]=0;
    }else{
      dp[i]=0;
    }
  }
}

int main(){
  int n, t;
  string s;
  cin >> n >> t >> s;
  init(n);
  for(int i=0; i<s.size(); ++i){
    if(isdigit(s[i])) ++pw[s[i]-'0'];
  }
  lli ans=0;
  for(int i=0; i<N; ++i){
    if(!pw[i]) continue;
    if(!dp[i]){ ans=-1; break; }
    ans += pw[i]*dp[i];
    if(ans>M){ ans=-1; break; }
  }
  if(ans!=-1) ans*=t;
  if(ans>M) ans=-1;
  if(ans==-1) cout << "TLE" << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1196
/**
 * File              : c.cpp
 * Author            : recurze
 * Date              : 00:17 21.01.2019
 * Last Modified Date: 00:23 21.01.2019
 */

#include <cstdio>
#include <algorithm>

void readInput();
void solve();
void printAns();

int main() {
    int t = 1;
    //(void)scanf("%d", &t);

    for (int tc = 1; tc <= t; ++tc) {
        readInput();
        solve();
        printAns();
    }
}

const int N = 1010101;

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

void printA() {
    for (int i = 0; i < n; ++i) {
        printf("%d ", *(a + i));
    }
    printf("\n");
}
int ans = 0;
void solve() {
    int last = 0;
    while (1) {
        int i = (int) (std::max_element(a, a + n) - a);
        if (a[i] == 0) {
            break;
        }

        last = a[i];
        ans += last;
        for (int j = i + 1; j < n; ++j) {
            last = std::min(last, a[j]);
            a[j] -= last;
        }

        last = a[i];
        for (int j = i - 1; j > -1; --j) {
            last = std::min(last, a[j]);
            a[j] -= last;
        }

        a[i] = 0;
    }
}

void printAns() {
    printf("%d\n", ans);
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static double a, b;
	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		if( !sc.hasNext() )return false;
		a = sc.nextDouble();
		b = sc.nextDouble();
		return true;
	}
	
	static void solve(){
		double res = a * b / 3.305785;
		System.out.println(res);
	}

}

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

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> p(a),q(b),r(c);
    for(int i=0;i<a;i++) cin>>p[i];
    for(int i=0;i<b;i++) cin>>q[i];
    for(int i=0;i<c;i++) cin>>r[i];
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    vector<int> v;
    for(int i=0;i<x;i++) v.push_back(p[i]);
    for(int i=0;i<y;i++) v.push_back(q[i]);
    for(int i=0;i<c;i++) v.push_back(r[i]);
    sort(v.rbegin(),v.rend());
    cout<<accumulate(v.begin(),v.begin()+x+y,0LL)<<endl;
}

Measured memory_bytes: 3572
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
int n,len;
string b[101];
int main()
{
    int i;
    cin>>n>>len;
    for(int i=0; i<n; i++)
    {
        cin>>b[i];
    }
    sort(b,b+n);
    for(i=0; i<n; i++)
        cout<<b[i];
    return 0;
}


Measured memory_bytes: 256
import itertools
h,w,k = map(int,input().split())

c =[list(input()) for i in range(h)]

ans = 0

for row_bit in itertools.product(range(2),repeat=h):
    for col_bit in itertools.product(range(2),repeat=w):
        cnt = 0
        for row in range(h):
            for col in range(w):
                if c[row][col] == "#" and (row_bit[row] and col_bit[col]):
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)



Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl

int main() {
  int n, k, ans; cin >> n >> k;
  ans = 0;

  rep(i, n) {
    int x; cin >> x;
    ans += (min(abs(x-k), x)*2);
  }
  
  p(ans);
}


Measured memory_bytes: 256
using System;
//using System.Text;
namespace AIZU_Cs_
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, y;
            string[] s = Console.ReadLine().Split(' ');
            x = int.Parse(s[0]);
            y = int.Parse(s[1]);
            if (x == y) Console.WriteLine("a == b");
            else if (x > y) Console.WriteLine("a > b");
            else if (x < y) Console.WriteLine("a < b");
        }
    }
}

Measured memory_bytes: 8728
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        
        for (int i = 1; i <= 5; i++){
            int x = scan.nextInt();
            
            if (x == 0){
                System.out.println(i);
                break;
            }
        }
    }
}


Measured memory_bytes: 35540
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;

namespace mine
{
    typedef long long ll;
    const int MAX_N=110000,MAX_M=410000;
    const int INF=0x3f3f3f3f;
    int mymax(int x,int y) {return x>y?x:y;}
    int mymin(int x,int y) {return x<y?x:y;}

    void main()
    {
        int n,k;scanf("%d%d",&n,&k);
        ll ans=0;
        for(int a=1;a<=n;a++)
        {
            if((2*(k-a)%k)!=0) continue;
            int l=double(a-k)/k+1,r=floor(double(n-k+a)/k);
            //printf("a=%d l=%d r=%d\n",a,l,r);
            ans+=ll(r-l+1)*(r-l+1);
        }
        printf("%lld",ans);
    }
};

int main()
{
    mine::main();
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

struct State{
    int at;
    ll cost;
    State(int a, ll c) : at(a), cost(c){}
    bool operator>(const State& s) const{
        return cost > s.cost;
    }
};

struct Edge{
    int to;
    ll cost;
    Edge(int t, ll c) : to(t), cost(c){}
};

using Graph = vector<vector<Edge> >;
const ll INF = 1e15;

void dijkstra(int s, const Graph& G, vector<ll>& minc){
    minc.assign(G.size(), INF);
    priority_queue<State, vector<State>, greater<State> > pq;
    pq.emplace(s, 0);
    minc[s] = 0;
    while(!pq.empty()){
        State cur = pq.top();
        pq.pop();
        if(minc[cur.at] < cur.cost) continue;
        for(const Edge& e : G[cur.at]){
            ll cost = cur.cost + e.cost;
            if(minc[e.to] <= cost) continue;
            minc[e.to] = cost;
            pq.emplace(e.to, cost);
        }
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    Graph g1(n), g2(n);
    for(int i = 0; i < m; i++){
        int u, v;
        ll a, b;
        cin >> u >> v >> a >> b;
        u--; v--;
        g1[u].emplace_back(v, a);
        g1[v].emplace_back(u, a);
        g2[u].emplace_back(v, b);
        g2[v].emplace_back(u, b);
    }
    vector<ll> minc1(n, INF), minc2(n, INF);
    dijkstra(s, g1, minc1);
    dijkstra(t, g2, minc2);
    vector<ll> ans(n, INF);
    for(int i = n-1; i >= 0; i--){
        ans[i] = min(ans[i], minc1[i] + minc2[i]);
        if(i < n-1) ans[i] = min(ans[i], ans[i+1]);
    }
    for(int i = 0; i < n; i++){
        cout << INF - ans[i] << endl;
    }
    return 0;
}

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

#define ll long long
using namespace std;
const int maxn = 1e5+7;
ll s[maxn],sum[65];
int mx;
ll K[65];
ll dp[65][2][2];
void getS(ll num){
    int i=0;
    while(num){
        if(num & 1) sum[i]++;
        ++i;
        num >>= 1;
    }
    mx = max(mx,i-1);
}
int main() {
    int n;
    ll k;
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;++i){
        scanf("%lld",&s[i]);
        getS(s[i]);
    }
    int p=0;
    while(k){
        if(k & 1) K[p]++;
        ++p;
        k >>= 1;
    }
    if(p==0){
        ll ans=0;
        for(int i=1;i<=n;++i){
            ans += s[i];
        }
        printf("%lld\n",ans);
        return 0;
    }
    p-=1;
    mx = max(p,mx);
    dp[p][1][0] = (n*1ll-sum[p])*(1ll << p);
    dp[p][0][1] = sum[p]*(1ll << p);
    ll temp;
    for(ll i=p - 1;i>=0;--i){
        ll b = (n*1ll-sum[i])*(1ll << i);//1
        ll a = sum[i]*(1ll << i);//0
        if(K[i] == 1){
            temp = max(dp[i+1][0][0],dp[i+1][1][0]);
            if(temp>0) {
                dp[i][1][0] = temp + b;
            }
           temp = max(dp[i+1][0][1],dp[i+1][1][1]);
           if(temp>0){
               dp[i][1][1] = temp + b;
           }
           temp = max(max(dp[i+1][0][0],dp[i+1][0][1]),max(dp[i+1][1][1],dp[i+1][1][0]));
            if(temp>0){
                dp[i][0][1] = temp + a;
            }
        }else if(K[i] == 0){
            temp =  max(dp[i+1][0][0],dp[i+1][1][0]);
            if(temp>0){
                dp[i][0][0] = temp + a;
            }
           temp = max(dp[i+1][0][1],dp[i+1][1][1]);
           if(temp>0){
               dp[i][1][1] =  temp + b;
           }
            temp = max(dp[i+1][1][1],dp[i+1][0][1]);
           if(temp > 0){
               dp[i][0][1] = temp + a;
           }
        }

    }
    ll ans = max(max(dp[0][1][0],dp[0][1][1]),max(dp[0][0][1],dp[0][0][0]));
    for(ll i=mx;i>p;--i){
        ans += sum[i]*(1ll<<i);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
i = input().split()

p = int(i[0])
q = int(i[1])
r = int(i[2])

v1 = p + q
v2 = q + r
v3 = p + r

if v1 < v2 and v1 < v3:
    print(v1)
elif v2 < v3:
    print(v2)
else:
    print(v3)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int num_mem;
    for(int i=1;; i++)
        {
        String str1 = in.next();
        String str2 = in.next();
        int num1 = Integer.parseInt(str1);
        int num2 = Integer.parseInt(str2);
        if(num1 == 0 && num2 == 0){break;}
        else{
            if(num1 > num2)
                {num_mem = num1;
                num1 = num2;
                num2 = num_mem;
                }
            System.out.println(num1+" "+num2);
            }
        }
    }
    
}

Measured memory_bytes: 36248
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long p = 1;
    long w = 1000000007L;
    for(long i=1; i<=N; i++){
      p = (p*i)%w;
    }
    System.out.println(p);
  }
}


Measured memory_bytes: 23764
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

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

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))




int main(){
	int N;
	cin>>N;
	int res[201],gt[201][3];
	CLR(res);CLR(gt);
	REP(i,N)REP(j,3)cin>>gt[i][j];
	REP(j,3){
		int cnt[102];
		CLR(cnt);
		REP(i,N)cnt[gt[i][j]]++;
		REP(i,N)if(cnt[gt[i][j]]==1)res[i]+=gt[i][j];
	}
	REP(i,N)cout<<res[i]<<endl;
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main(){
	int kane,a,b;
	while(0<=scanf("%d",&kane)){
		if(kane==0) break;
		a=0;
		kane=1000-kane;
		while(kane>=500){
			kane-=500;
			++a;
		}
		while(kane>=100){
			kane-=100;
			++a;
		}
		while(kane>=50){
			kane-=50;
			++a;
		}
		while(kane>=10){
			kane-=10;
			++a;
		}
		while(kane>=5){
			kane-=5;
			++a;
		}
		while(kane>=1){
			kane-=1;
			++a;
		}
		printf("%d\n",a);
	}
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main() {
  int n, m, dig = 0, ans = 0, x = 1;
  scanf("%d", &n);
  m = n;
  while (m != 0) {
    m /= 10;
    dig++;
  }
  if (dig%2 == 0) {
    for (size_t i = 0; i < dig/2; i++) {
      ans += 9*x;
      x *= 100;
    }
  }else {
    for (size_t i = 0; i < (dig-1)/2; i++) {
      ans += 9*x;
      x *= 100;
    }
    ans += n-x+1;
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >>n;
    ll t = n;
    ll sum = 0;
    while(t > 0){
      sum += t%10;
      t /=10;
    }
    if(n%sum ==0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <string>

int main(int argc, char const *argv[]) {
  std::string s;
  std::getline(std::cin, s);
  std::string::const_iterator it = s.begin();
  while(it != s.end()){
    char c;
    c = *it;
    if(c == '\n')break;
    if(std::islower(c)){
      c = (char)std::toupper(c);
    }else if(std::isupper(c)){
      c = (char)std::tolower(c);
    }
      std::cout << c;
      it++;
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 3148
#include <iostream>
using namespace std;
string comp[4] = {"AC", "WA", "TLE", "RE"};
int res[4] = {};
int main()
{
	int t; cin >> t;
	while (t--)
	{
		string s; cin >> s;
		for (int i = 0; i < 4; i++)
		{
			if (comp[i] == s) res[i]++;
		}
	}
	for (int i = 0; i < 4; i++)
	{
		cout << comp[i] << " x " << res[i] << "\n";
	}
	return 0;
}

Measured memory_bytes: 3628
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sn = new Scanner(System.in);
        String s = sn.nextLine();
        ArrayList<Character> a = new ArrayList();
        
        for(int i=0;i<s.length();i++){
            if(!a.contains(s.charAt(i))){
                a.add(s.charAt(i));
            }
        }
        boolean perfect = true;
        for(int i=0;i<a.size();i++){
            char x = a.get(i);
            int count=0;
            for(int j=0;j<s.length();j++){
                if(x==s.charAt(j))
                    count++;
            }
            if(count%2!=0){
                perfect=false;
                break;
            }
        }
        if(perfect)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
    
}


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

int main()
{
    int n, k;
    cin >> n >> k;
    int ans = 1;
    while(n--){
        if(ans*2 < ans+k){
            ans *=2;
        }else{
            ans = ans+k;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		char[] c = S.toCharArray();
		
		int ans = 0;
		
		for (char m : c) {
			if ('+' == m) ans++;
			if ('-' == m) ans--;
		}
		
		System.out.println(ans);
		
		sc.close();
	}

}


Measured memory_bytes: 23252