akhauriyash/Code-Regression huggingface dataset:
// code by edsomjr https://atcoder.jp/contests/abc159/submissions/14625249

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAXH { 10 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int H, int W, int K, const vector<string>& xs)
{
    int ans = H*W;

    vector<vector<int>> ps(H + 1, vector<int>(W + 1, 0));

    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + xs[i - 1][j - 1] - '0';

#ifdef DEBUG
    for (int i = 1; i <= H; ++i)
        for (int j = 1; j <= W; ++j)
            cout << ps[i][j] << (j == W ? '\n' : ' ');
#endif

    for (int mask = 0; mask < (1 << (H - 1)); ++mask)
    {
        int res = 0, c = 0;

        for (int i = 0; i < H; ++i)
            if (mask & (1 << i))
                ++res;

        while (c < W)
        {
            vector<int> cuts(H, 0);
            int m = 0, pos = 0;

            for (int i = 0; i < H; ++i)
            {
                cuts[pos] += xs[i][c] == '1' ? 1 : 0;
                m = max(m, cuts[pos]);
                
                if (mask & (1 << i))
                    ++pos;
            }

#ifdef DEBUG
    cout << "mask = " << mask << ", c = " << c << ", cuts = ";
    for (auto c : cuts)
        cout << c << ' ';
    cout << endl;
#endif
            if (m > K) {
               res = 1000000;
                break;
            }

            ++c;

            for (int j = c; j < W; ++j)
            {
                pos = 0;

                for (int i = 0; i < H; ++i)
                {
                    cuts[pos] += xs[i][j] == '1' ? 1 : 0;
                    m = max(m, cuts[pos]);
                    
                    if (mask & (1 << i))
                        ++pos;
                }

#ifdef DEBUG
    cout << " -- new cuts = ";
    for (auto c : cuts)
        cout << c << ' ';
    cout << endl;
#endif


                if (m > K)
                {
                    c = j;
                    ++res;
                    break;
                } else
                    ++c;
            }

#ifdef DEBUG
    cout << "Aqui, c = " << c << ", res = " << res << endl;
#endif
        }

        ans = min(ans, res);
    }

    return ans;
}

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

    int H, W, K;
    cin >> H >> W >> K;

    vector<string> xs(H);

    for (int i = 0; i < H; ++i)
        cin >> xs[i];

    auto ans = solve(H, W, K, xs);

    cout << ans << '\n';

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef ONLINE_JUDGE
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
#endif
	int n;
	cin >> n;
	multiset<int> sett;
	for(int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		auto it = sett.lower_bound(a);
		if(it == sett.begin())
			sett.insert(a);
		else{
			it--;
			sett.erase(it);
			sett.insert(a);
		}
	}
	cout << sett.size();
	return 0;
}


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


int main() {
  int N, X ,T;
  cin >> N >> X >> T;
if (N%X==0) {cout << (N/X)*T << endl;}
else {cout << (N/X+1)*T << endl;}  
  // ここにプログラムを追記
}


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

long long GCD(long long a, long long b){ return b ? GCD(b, a%b) : a; }

int main() {
  
  int N;
  cin >> N;
  
  vector<long long> As(N);
  for(int i=0; i<N; i++){ cin >> As[i]; }
  
  long long res = As[0];
  for(int i=1; i<N; i++){
    res = GCD(res, As[i]);
  }
  
  cout << res << endl;
}


Measured memory_bytes: 1024
from itertools import product
H, W, K = map(int, input().split())
M = [input() for _ in range(H)]

ans = 0
for Hs in product(range(2), repeat=H):
    for Ws in product(range(2), repeat=W):
        cnt = 0
        for y in range(H):
            for x in range(W):
                if M[y][x] == '#' and Hs[y] and Ws[x]:
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)


Measured memory_bytes: 9192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int N = s.substring(1, s.length() - 1).length();
		System.out.println(s.substring(0, 1) + N + s.substring(s.length() - 1, s.length()));
	}
}


Measured memory_bytes: 23764
n,m = list(map(int,input().split()))
ans = [-1]*n
for i in range(m):
    s,c = list(map(int,input().split()))
    if ans[s-1] != -1 and ans[s-1] != c:
        ans = -1
        break
    ans[s-1] = c
    if s == 1 and n != 1 and c == 0:
        ans = -1
        break    

if ans != -1:
    if ans[0] == -1 and n != 1:
        ans[0] = 1
    for i in range(n):
        if ans[i] == -1:
            ans[i] = '0'
        else:
            ans[i] = str(ans[i])
    print(''.join(ans))
else:
    print(ans)

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys

def calc_(order, d):
    ret = 0
    for i in range(3):
        target = order[i]
        ret += d[i][target]
    return ret

def calc(G, target, D):
    ret = 0
    for elm in G:
        ret += D[elm - 1][target]
    return ret

def dfs(idx, current, used, d):
    if idx == 3:
        ret = calc_(current, d)
        return ret
    ret = float('inf')
    for i, u in enumerate(used):
        if not u:
            used[i] = True
            tmp = dfs(idx + 1, current + [i], used, d)
            ret = min(ret, tmp)
            used[i] = False
    return ret

def solve(N: int, C: int, D: "List[List[int]]", c: "List[List[int]]"):
    groups = [[] for _ in range(3)]
    for i in range(N):
        for j in range(N):
            cc = c[i][j]
            groups[(i + j) % 3].append(cc)
    #print(groups)
    d = [[] for _ in range(3)]
    for i, G in enumerate(groups):
        for j in range(C):
            d[i].append(calc(G, j, D))
    ret = dfs(0, [], [False] * C, d)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = [ [ int(next(tokens)) for _ in range(C) ] for _ in range(C) ]  # type: "List[List[int]]"
    c = [ [ int(next(tokens)) for _ in range(N) ] for _ in range(N) ]  # type: "List[List[int]]"
    solve(N, C, D, c)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7680
#include <cstdio>
int dp[31]={1,1,2};
int main() {
	for(int i=3;i<=30;i++) {
		dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
	}
	int n;
	while(scanf("%d",&n),n) {
		int days=(dp[n]/10)+((dp[n]%10)?1:0);
		int years=(days/365)+((days%365)?1:0);
		printf("%d\n",years);
	}
}

Measured memory_bytes: 1028
using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        int K = int.Parse(ReadLine());
        int tmp = K/2;
        K -= tmp;
        WriteLine(K * tmp);
    }
    public static partial class MyEnumerable
    {
        public static IEnumerable<int> Range(int count)
        {
            return Enumerable.Range(0, count);
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N,M;
  cin >> N >> M;
  
  vector<int>X(M);
  for(int i=0; i<M; i++) cin >> X[i];
  sort(X.begin(),X.end()); ///X入力後並び替え
  
  vector<int>differ(M-1);
  for(int i=0; i<M-1; i++){
    differ[i] = X[i+1]-X[i];
  }
  sort(differ.begin(),differ.end());///差計算後並び替え
  
  int sum=0;///合計値
 
  if(M>N){
    vector<int>count(M-N);
    for(int i=0; i<M-N; i++){
    count[i] = differ[i];
    }///N-1の分だけ減らせる。
  
    for(int i=0; i<M-N; i++){
     sum += count[i]; 
    }
  }
  
  else sum=0;
  
  cout << sum << endl;
  
}



Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<queue>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cmath>
#include<ctime>
#include<map>
#include<typeinfo>
#define R(i, n) for(int i = 0;i < n; i++)
#define R1(i, n) for(int i = 1; i <= n; i++)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define SL(a) scanf("%lld", &a)
#define SL2(a, b) scanf("%lld%lld", &a, &b)
#define SL3(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define SC(a) scanf("%c", &a)
#define P(a) printf("%d", a)
#define PL(a) printf("%lld", a)
#define PY printf("YES")
#define PN printf("NO")
#define Py printf("Yes")
#define Pn printf("No")
using namespace std;
using ll = long long;
using PR = pair<int, int>;
const ll MOD = 1e+9 + 7;
const int INF = 1e+9;
const double PI = acos(-1);

int main() {
	int n, t;
	S2(n, t);
	vector<int> v(n);
	R(i, n) {
		S(v[i]);
	}
	ll ans = 0;
	ans += t;
	int now = 0;
	for (int i = 1; i < n; i++) {
		if (v[i] - v[i - 1] >= t) ans += t;
		else {
			ans -= t - (v[i] - v[i - 1]);
			ans += t;
		}
	}
	PL(ans);
}

Measured memory_bytes: 4056
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s = list(input())
if len(s) == len(set(s)):
    print('yes')
else:
    print('no')


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

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

    sort(s.begin(),s.end()); 
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#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 vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  int n,m,p,acsum=0,wasum=0;
  string s;
  cin >> n >> m;
  vi ac(n);
  vi wa(n);

  rep(i,0,m){
    cin >> p >> s;
    if(ac[p]==1){
      continue;
    }
    if(s=="AC"){
      wasum+= wa[p];
      ac[p]=1;
      acsum++;
    }else{
      wa[p]++;
    }
  }
  cout << acsum << " " << wasum;

  return 0;
}
//ac,acまでにしたwa(acしなかった場合0ペナ),

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

int main(void)
{
    string s;
    cin >> s;

    rep(i,3){
        cout << s[i];
    }

    cout <<endl;
    return 0;
}


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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;

  ll d = abs(A-B);
  ll ans = 0;
  if (d % 2 == 0) ans = d / 2;
  else {
    if (A - 1 < N - B) {
      ans += A - 1;
      B = B - A + 1;
      A = 1;
    } else {
      ans += N - B;
      A += N - B;
      B = N;
    }

    d = abs(A-B);
    if (d % 2 == 0) ans += d / 2;
    else ans += d / 2 + 1;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
X,N = map(int, input().split())
ps = set(list(map(int, input().split())))

lim = max(X, 100 - X)
for i in range(lim + 1):
    if X-i not in ps:
        print(X-i)
        exit()

    if X+i not in ps:
        print(X+i)
        exit()

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

using namespace std;


void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    for (auto& x: a) {
        cin >> x;
    }
    sort(a.begin(), a.end());
    vector<pair<int, int>> cb(m);
    for (auto& p: cb) {
        cin >> p.second >> p.first;
    }
    sort(cb.begin(), cb.end(), [&](auto& u, auto& v){
            return u.first > v.first;
            });
    long long res = 0;
    auto it = a.begin();
    for (auto& p: cb) {
        int c = p.first, b = p.second;
        auto jt = lower_bound(it, a.end(), c);
        int k = jt - it;
        int d = min(k, b);
        res += 1ll*d*c;
        it += d;
        if (d < b || it == a.end()) {
            break;
        }
    }
    for (; it != a.end(); it++) {
        res += *it;
    }
    cout << res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    long long N, x; cin >> N >> x;
    vector<long long>a(N);
    long long count = 0;
    rep(i, N) {
        cin >> a[i];
        count += a[i];
    }
    if (count == x)cout << N << endl;
    else if (count < x)cout << N - 1 << endl;
    else {
        sort(a.begin(), a.end());
        reverse(a.begin(), a.end());
        rep(i, N) {
            count -= a[i];
            if (count <= x) {
                cout << N - i - 1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

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


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

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

	std::vector<lld> v(n);

	for(lld i=1;i<=n;i++)
		cin>>v[i];

	lld cash=1000;
	lld stocks = 0;
	for(lld i=1;i<n;i++)
	{
		if(v[i]>v[i+1])
		{
			stocks = (stocks*v[i])/v[i+1];
			cash = cash ;
		}

		else
		{
			stocks = cash/v[i];
			cash = (stocks)*v[i+1] + cash-(stocks*v[i]);
		}
	}

	cout<<cash<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i] >> B[i];
  vector<int> id(N);
  rep(i, N) id[i] = i;
  sort(all(id), [&](int i, int j) {
      return A[i] < A[j];
    });
  int rem = M;
  int i = 0;
  ll ans = 0;
  while(rem > 0) {
    if(B[id[i]] >= rem) {
      ans += A[id[i]] * rem;
      rem = 0;
    } else {
      ans += A[id[i]] * B[id[i]];
      rem -= B[id[i]];
    }
    i++;
  }
  cout << ans << "\n";
  return 0;
}


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

int main(){
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	vector<int> vec(100001);
	for(int i=0; i<=100000; i++){
		vec.at(i)=i*2*c+max(0,x-i)*a+max(0,y-i)*b;
	}
	sort(vec.begin(), vec.end());
	cout << vec.at(0) << endl;
}



Measured memory_bytes: 3804
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;

		int N=sc.nextInt();
		int size;
		boolean x=true;
		//int B=sc.nextInt();
		//int Q=sc.nextInt();
		
		String[] w=new String[N];
		w[0]=sc.next();
		
		size=w[0].length();
	
		char recent=w[0].charAt(size-1);
		for(int i=1;i<N;i++){
			
			w[i]=sc.next();
			int leng=w[i].length();
			
			for(int j=0;j<i;j++){
				if(w[j].equals(w[i])){
					x=false;
					break;
				}
			}
			
			if(recent!=w[i].charAt(0)){
				x=false;
				break;
			}else{
				recent=w[i].charAt(leng-1);
				
			}
			
		}

		if(x){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
		
		
	}
}

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


using namespace std;


int main()
{
	char m[102][102];
	fill_n(*m, 102 * 102, '#');
	int H, W;
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			char a;
			cin >> a;
			m[i][j] = a;
		}
	}
	for (int i = 0; i <= H + 1; i++) {
		for (int j = 0; j <= W + 1; j++) {
			cout << m[i][j];
		}
		cout << endl;
	}
	return (0);
}


Measured memory_bytes: 256
/// prime factorization when number is big
#include <bits/stdc++.h>
using namespace std;
#define Mx 2000001
typedef long long L;
L A[Mx],vis[Mx],Mp_a[Mx],id,n,m;
vector<L>V;
void solve(){
    id=A[1];
    L c,flg=0,k,c1;
    while(true){
        vis[id]=1;
        V.push_back(id);
        id=A[id];
        if(vis[id]){
            flg=id;
            break;
        }
    }
    L sz=V.size();c=0;
    for(L i=0;i<sz;i++){
        if(V[i]==flg){
            m=m-c;
            c1=(sz-i);
            c1=m%c1;
            if(c1==0){
                printf("%lld\n",V[sz-1]);
            }else{
                printf("%lld\n",V[i+c1-1]);
            }
            return ;
        }
        c++;
        if(c==m){
            printf("%lld\n", V[i]);
            return ;
        }
    }
}
int main()
{
    scanf("%lld%lld",&n,&m);
    for(L i=1;i<=n;i++){
        scanf("%lld",&A[i]);
    }
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 8332
n = int(input())
s = input()
ans = 0

for i in range(n):
    s1 = list(s[: i + 1])
    s2 = list(s[i + 1 :])
    ss = [""] * n

    count = 0
    for j in range(len(s1)):
        if s1[j] in s2 and s1[j] not in ss:
            ss[j] = s1[j]
            count = count + 1

    ans = max(ans, count)

print(ans)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int D,T,S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>D>>T>>S;
	if(T*S>=D) {
		cout<<"Yes"<<endl;
	}
	else {
		cout<<"No"<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 300000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
		ifac[i + 1] = ifac[i] * mpow(i + 1, M - 2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int i;
	char s[20];
	cin >> s;
	for (i = 0; i < 4; i++)
		cout << s[i];
	cout << " ";
	for (i = 4; i < 12; i++)
		cout << s[i];
	cout << endl;
}

Measured memory_bytes: 4992
n = int(input())
a = input().split(" ")

dicta = {'0':0}

for i in a:
    if i in dicta:
        dicta[i] += 1
    else:
        dicta[i] = 1

ke = list(dicta.keys())
va = list(dicta.values())
ans = 0


for i in range(len(ke)):
    if int(ke[i])>va[i]:
        ans+= va[i]
    else :
        ans += va[i]-int(ke[i])

print(ans)


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

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && A != C){
        cout << "Yes" << endl;
        return 0;
    }
    if(A == C && A != B){
        cout << "Yes" << endl;
        return 0;
    }
    if(C == B && A != C){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
    int a,b;
    int k;
    scanf("%d%d%d",&a,&b,&k);
    int i;
    int last_i;
    for(i=a;i<a+k;i++)if(i<=b)printf("%d\n",i);
    if(i<b-k+1)i=b-k+1;
    for(;i<=b;i++)if(i>=a)printf("%d\n",i);
    return 0;
}

Measured memory_bytes: 128
str = input()
q = int(input())

for i in range(q):
    args = input().split()
    order = args[0]
    a = int(args[1])
    b = int(args[2])
    if order == "print":
        print(str[a : b + 1])
    elif order == "reverse":
        str = str[: a] + str[a : b + 1][: : -1] + str[b + 1 :]
    elif order == "replace":
        str = str[: a] + args[3] + str[b + 1 :]

    


Measured memory_bytes: 5616
#include <stdio.h>

long f(long x, long y) {
	if (y == 0L) return x;
	return f(y, x % y);
}

int main(void) {
	long a, b;
	scanf("%ld %ld", &a, &b);
	printf("%ld\n", f(a, b));
	return 0;
}

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

int main(){
 int h, m, s;
 cin >> s;
 
 h = s / 3600; s %= 3600;
 m = s / 60; s %= 60;
 
 cout << h << ":" << m << ":" << s << endl;
 
 return 0;
}

 


Measured memory_bytes: 3104
h,w,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*n]
ab_d={a*(10**9)+b-1 for a,b in ab}

ans=[set() for _ in range(9)]
for a,b in ab:
    temp=[None for _ in [0]*25]
    for p in range(25):
        i,j=p//5,p%5
        if 0<a+i-2<=h and 0<b+j-2<=w:
            if (a+i-2)*(10**9)+b+j-3 in ab_d:
                temp[i*5+j]=1
            else:
                temp[i*5+j]=0
    for p in range(9):
        i,j=p//3,p%3
        cnt=[temp[(i+k)*5+j+l] for k in range(3) for l in range(3)]
        if None not in cnt:
            ans[sum(cnt)-1].add((a+i-2)*(10**9)+b+j-3)
                
ans=[len(ans[i]) for i in range(9)]

print((h-2)*(w-2)-sum(ans))
for i in ans:
    print(i)

Measured memory_bytes: 117608
n,k = map(int,input().split())
lis = list(map(int,input().split()))
ans = 0
for i in range(n-1):
  if lis[i] + lis[i+1] > k:
    num = lis[i+1]+lis[i] -k
    ans += num
    if num >= lis[i+1]:
      num -= lis[i+1]
      lis[i+1] = 0
      lis[i] -= num
    else:
      lis[i+1] -= num
print(ans)


Measured memory_bytes: 14588
#include <bits/stdc++.h> 
using namespace std;
#define MAX 13
int solve(int idx, vector<int>& arr, vector<int>& dp){
    if(idx >= arr.size()-1)
        return 0;
    if(dp[idx] != -1)
        return dp[idx];
    if(idx == arr.size()-2)
        return dp[idx] = abs(arr[idx]-arr[idx+1]);
    return dp[idx] = min(abs(arr[idx]-arr[idx+1])+solve(idx+1,arr,dp), 
        abs(arr[idx]-arr[idx+2])+solve(idx+2,arr,dp));
}
int main()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    vector<int> sol(n, -1);
    for(int i=0; i<n; ++i)
        cin >> arr[i];
    cout << solve(0, arr, sol);
    return 0;
}

Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf (ll)2e18
#define EPS 1e-12
#define mod 1000000007LL
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;

inline void solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	map<int, int> mp;
	ll otv = 0;
	for (int i = 0; i < n; i++) {
		if (i >= v[i])
			otv += mp[i + 1 - v[i]];
		mp[i + 1 + v[i]]++;
	}

	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	fore(t, 0, q)
	{
		solve();
		cout << '\n';
	}
}

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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  vector < string > s = {"AC", "WA", "TLE", "RE"};
  vector < int > cnt (4, 0);
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    for (int j = 0; j < 4; j++) {
      if (s[j] == t) cnt[j]++;
    }
  }

  for (int i = 0; i < 4; i++) {
    cout << s[i] << " x " << cnt[i] << '\n';
  }
}


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

using namespace std;

#define ll long long
#define pb push_back
#define vi vector<int>
#define bn(n) (n).begin(), (n).end()
#define FOR(n) for(int i = 0; i < (int)n; i++)


void solve() {
    int n;
    cin >> n;
    string ans;
    vector<string> v;
    for (int i = 0; i <n; i++) {
        string a;
        cin >> a;
        v.push_back(a);
    }
    for (char c = 'a'; c <= 'z'; c++) {
        int temp = 1e9;
        for (int i = 0; i < n; i++) {
            int cnt = count(v[i].begin(), v[i].end(), c);
            if (cnt < temp) {
                temp = cnt;
            }
        }
        for (int i = 0; i < temp; i++) {
            ans += c;
        }
    }
    cout << ans << "\n";
}

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

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


Measured memory_bytes: 3588
K,N = map(int,input().split())
A = list(map(int,input().split()))
ans = K - A[N-1] + A[0]
for i in range(1,N):
  if ans < A[i]-A[i-1]:
    ans = A[i] - A[i-1]
ans = K-ans
print(ans)

Measured memory_bytes: 26436
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        cin = new Scanner();
        int[] ar = cin.ArrayInt(2);


        WriteLine(ar[0]==ar[1]?ar[0]*2:Math.Max(ar[0],ar[1])*2-1);
        Console.ReadLine();

    }
    static bool search(int[] array,int len,int key)
    {
        for (int a = 0; a < len; a++)
        {
            if (array[a]==key) return true;
        }
        return false;
    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, c[MAXN], num[2 * MAXN], x[MAXN], par[2*MAXN][20], d[MAXN];
vector<int> a[MAXN * 2];
vector<int> b[MAXN * 2];
ll res;

void dfs(int u, int p) {
    num[u] = 1;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v == p) continue;
        par[v][0] = u;
        d[v] = d[u]+1;
        dfs(v, u);
        num[u] += num[v];
    }
}

int lca(int u, int v) {
    if (u > n) return u;
    if (v > n) return v;
    if (d[v] < d[u]) FORE(i,19,0) if (d[par[u][i]] >= d[v]) u = par[u][i];
    if (d[u] < d[v]) FORE(i,19,0) if (d[par[v][i]] >= d[u]) v = par[v][i];
    FORE(i,19,0) if (par[u][i] != par[v][i]) { u = par[u][i]; v = par[v][i]; }
    while (u != v) { u = par[u][0]; v = par[v][0]; }
    return u;
}

void dfs2(int u, int p) {
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v == p) continue;
        int col = c[v];
        int tmp = x[col];
        b[tmp].push_back(v);
        // cout << tmp << ' ' << v << endl;
        x[col] = v;
        dfs2(v, u);
        x[col] = tmp;
    }
}

void dfs3(int u) {
    // cout << "------- " << u << endl;
    int itr = 0;
    FOR(i,0,SZ(a[u])-1) {
        int v = a[u][i];
        if (v == par[u][0]) continue;
        int e = num[v];
        // cout << v << ' ' << e << endl;
        while (itr < SZ(b[u])) {
            int V = b[u][itr];
            // cout << V << endl;
            if (lca(v, V) != v) break;
            e -= num[V];
            itr++;
        }
        
        res += (ll) e * (e + 1) / 2;
    }
    FOR(i,0,SZ(b[u])-1) {
        int v = b[u][i];
        dfs3(v);
    }
}



int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> c[i];
    FOR(i,1,n-1) {
        int u, v;
        cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    a[0].push_back(1);

    par[1][0] = 1;
    dfs(1, 0);
    FOR(j,1,19)
        FOR(i,1,n) par[i][j] = par[par[i][j-1]][j-1];

    FOR(i,1,n) {
        x[i] = i+n;
        a[i+n].push_back(1);
        num[x[i]] = n+1;
    }
    dfs2(0, -1);

    FOR(i,1,n) {
        int root = n + i;
        res = 0;
        dfs3(root);
        res = (ll) n * (n+1) / 2 - res;
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 79396
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

const LLI mod = 1e9+7;

LLI dp[100100][13];

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

  string s;
  while(cin >> s){
    int n = s.size();

    fill_array(dp, 0);

    dp[0][0] = 1;

    REP(i,n){
      REP(j,13){
        if(s[i]=='?'){
          REP(k,10){
            (dp[i+1][(j*10+k)%13] += dp[i][j]) %= mod;
          }
        }else{
          int k = j*10+(s[i]-'0');
          (dp[i+1][k%13] += dp[i][j]) %= mod;
        }
      }
    }

    LLI ans = dp[n][5];
    cout << ans << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007

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; }



int main(int argc, char const *argv[]) {
  ll n,k,s,INF=1e9;
  cin >> n >> k >> s;
  if(s==INF) INF-=1;
  vector<ll> a(n,INF);
  for(ll i=0; i<k; i++) a[i]=s;
  for(ll i=0; i<n; i++) cout << a[i] << " ";
  cout << endl;
  return 0;
}


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

int main()
{
    int n, k, p[1000], ans = 0;
    cin >> n >> k;
    for (int in = 0; in < n; in++)
    {
        cin >> p[in];
    }
    sort(p, p + n);

    for (int i = 0; i < k; i++)
    {
        ans += p[i];
    }  

    cout << ans << endl;
}

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

int main() {
  int n,k;
  int64_t sum=0;
  cin >> n >> k;
  int64_t h[n];
  for(int i=0;i<n;i++) cin >> h[i];
  priority_queue<int> pque;
  for(int i=0;i<n;i++) pque.push(h[i]);
  for(int i=0;i<k && !(pque.size() == 0);i++) pque.pop();
  while(!(pque.size() == 0)) {sum += pque.top(); pque.pop();}
  cout << sum << endl;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  double ans = 0;
  int ans_all = 0;
  int ans_sug = 0;
  REP (i, 30) {
    REP (j, 15) {
      REP (k, 1500) {
        int water = i * a * 100 + j * b * 100;
        int l = max(0, min((f - (water + k * c)) / d, (e * water / 100 - k * c) / d));
        int sugar = k * c + l * d;
        if (water + sugar <= f && e * water / 100 >= sugar && ans <= double(sugar) / double(water + sugar) ) {
          ans_all = water + sugar;
          ans_sug = sugar;
          ans = double(sugar) / double(water + sugar);
        }
      }
    }
  }
  cout << ans_all << " " << ans_sug << endl;
}


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

using namespace std;

int main(){
    constexpr double o=1.0;
    int n,k;
    cin>>n>>k;
    double ans=0;
    for (int i = 1; i <= n; ++i) {
        if(i>=k)ans+= o/n;
        else{
            int t=i;
            int cnt=0;
            while(t<k){
                t=t*2;
                ++cnt;
            }
            ans+=o/(n*pow(2,cnt));
        }
    }
    cout<<setprecision(15);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
N = int(input())
#print(N)

num = 0
for i in range(1, N+1, 2):
    rec = 0
    for j in range(1, i+1):
        #print(i,j, "i,j")
        if i % j == 0:
            rec += 1
    #print(rec,"rec")
    if rec == 8:
        num += 1
        
print(num)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n;
    cin >> n;
    vector<int> v(101);
    for (int i = 1; i <= n; ++i) {
        int k = i;
        for (int j = 2; j <= 100; ++j) {
            while(k%j == 0) {
                v[j]++;
                k /= j;
            }
        }
    }
    int ans = 0;
    for (int i = 2; i <= 100; ++i) {
        if(v[i] >= 74) ans++;
        for (int j = i+1; j <= 100; ++j) {
            if(v[i] >= 24 && v[j] >= 2) ans++;
            if(v[i] >= 2 && v[j] >= 24) ans++;
            if(v[i] >= 14 && v[j] >= 4) ans++;
            if(v[i] >= 4 && v[j] >= 14) ans++;
            for (int k = j+1; k <= 100; ++k) {
                if(v[i] >= 2 && v[j] >= 4 && v[k] >= 4) ans++;
                if(v[i] >= 4 && v[j] >= 2 && v[k] >= 4) ans++;
                if(v[i] >= 4 && v[j] >= 4 && v[k] >= 2) ans++;
            }
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
using namespace std;
 
int main(){
    double x1,x2,x3,y1,y2,y3,xp,yp;
    double calc1,calc2,calc3;
 
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&xp,&yp)!=EOF){
        calc1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
        calc2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
        calc3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
 
        if((calc1>0&&calc2>0&&calc3>0) || (calc1<0&&calc2<0&&calc3<0)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}


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

int main()
{
    int n,k,i,cnt=0;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=k)
        {
            cnt++;
        }
    }
    cout<<cnt<<endl;



}


Measured memory_bytes: 3828
mod = 10**9+7
k = int(input())
s = input()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, len(s)+k+5):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
pow1 = 1
for i in range(len(s), len(s)+k+1):
  ans += pow1 * pow(26, k+len(s)-i, mod)*cmb(i-1, len(s)-1, mod)
  pow1 *= 25
  pow1 %= mod
  ans %= mod
  
print(ans)

Measured memory_bytes: 227080
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			
			if(Math.max(A, B) >= 9) {
				System.out.println(":(");
			}else {
				System.out.println("Yay!");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21076
N, M = map(int, input().split())
 
ac, wa = [0]*N, [0]*N
 
for i in range(M):
    p, s = input().split()
    if s == 'WA' and ac[int(p)-1] == 0:
            wa[int(p)-1] += 1
    elif s == 'AC' and ac[int(p)-1] == 0:
            ac[int(p)-1] += 1
print('%d %d' % (sum(ac), sum([wa[k] for k in [i for i, j in enumerate(ac) if j != 0]])))

Measured memory_bytes: 9396
PROGRAM snack
      IMPLICIT NONE
      integer(16) :: a,b
      integer(16) :: big,sma,piyo,gcd,lcm
      
      read*,a,b
      
      big = max( a,b )
      sma = min( a,b )
      
      do while( .true. )
        if( mod(big,sma)==0 ) exit
        piyo = sma
        sma = mod( big,sma )
        big = piyo
      end do
      gcd = sma
      
      lcm = a*b/gcd
      
      print*,lcm
      
      END PROGRAM

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    char[] ns = scanner.next().toCharArray();
    int N = ns.length;
    for (int i = 0; i < N; i++) ns[i] = (char) (ns[i] - '0');
    int K = scanner.nextInt();

    long[][] dp1 = new long[N + 1][K + 1];
    long[][] dp2 = new long[N + 1][K + 1];
    dp2[0][0] = 1;
    for (int i = 1; i <= N; i++) {
      dp1[i][0] = 1;
      for (int j = 1; j <= K; j++) {
        dp1[i][j] = dp1[i - 1][j] + 9 * dp1[i - 1][j - 1];
        if (ns[i - 1] != 0) dp1[i][j] += dp2[i - 1][j] + (ns[i - 1] - 1) * dp2[i - 1][j - 1];
        if (ns[i - 1] == 0) dp2[i][j] = dp2[i - 1][j];
        else dp2[i][j]= dp2[i - 1][j - 1];
      }
    }
    System.out.println(dp1[N][K] + dp2[N][K]);
  }
}


Measured memory_bytes: 23764
import java.util.*;

public class Main{
    static int[] n = new int[9];
    static int[][] perms = new int[362880][9];

    public static void main(String[] args) {
        setPermutation();

        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();

        for (int t=0; t<T; t++) {
            for (int i=0; i<9; i++) n[i] = sc.nextInt();
            for (int i=0; i<9; i++) {
                char c = sc.next().toCharArray()[0];
                if (c == 'G') n[i] += 10;
                else if (c == 'B') n[i] += 20;
            }

            Arrays.sort(n);

            boolean flg = true;
            for (int[] perm : perms) {
                if (judge(perm)) {
                    System.out.println(1);
                    flg = false;
                    break;
                }
            }
            if (flg) System.out.println(0);
        }
    }

    static boolean judge(int[] p) {
        return isSet(n[p[0]], n[p[1]], n[p[2]])
                && isSet(n[p[3]], n[p[4]], n[p[5]])
                && isSet(n[p[6]], n[p[7]], n[p[8]]);
    }

    static boolean isSet(int a, int b, int c) {
        if (a == b && b == c) return true;
        else if (a+1 == b && b+1 == c) return true;
        else return false;
    }

    static void setPermutation() {
        final int[] HASH_BASE = {40320, 5040, 720, 120, 24, 6, 2, 1, 1};

        int n;
        List<Integer> list;
        for (int i=0; i<362880; i++) {
            n = i;
            list = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8));
            for (int j=0; j<9; j++) {
                perms[i][j] = list.get(n / HASH_BASE[j]);
                list.remove(n / HASH_BASE[j]);
                n %= HASH_BASE[j];
            }
        }
    }
}

Measured memory_bytes: 88084