akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main(){
  int h1,h2,k1,k2;
  cin >> h1 >>h2 >> k1 >> k2;
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int hp=0,kp=0;

  hp = h1*a + h2*b + (h1/10)*c + (h2/20)*d;
  kp = k1*a + k2*b + (k1/10)*c + (k2/20)*d;

  if(hp>kp) cout << "hiroshi" << endl;
  else if(hp< kp) cout << "kenjiro" << endl;
  else cout << "even" << endl;
  
  return 0;
}



Measured memory_bytes: 3112
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    string s;
    cin >> s;

    int x = 0;
    for (auto c : s) {
        int d = c - '0';
        x = (x * 10 + d) % 9;
    }

    if (x == 0) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}

Measured memory_bytes: 3748
Printf.printf "%d\n" @@
Scanf.scanf "%d %d\n" @@ fun n l ->
    let total =
        Array.init n (fun i -> i + l)
        |> Array.fold_left ( + ) 0
    in
    Array.init n (fun i -> i + l)
    |> Array.fold_left (fun x eat -> if abs x < abs eat then x else eat) 300
    |> ( - ) total;;
    


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

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

  for(int i=1;i<10;i++) {
    for(int j=1;j<10;j++) {
      if(i*j==kakeru) {
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}

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

static const int N = 1000;

int lcs(string X, string Y) {
	int c[N+1][N+1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 0; i <= m; i++) c[i][0] = 0;
	for (int j = 0; j <= n; j++) c[0][j] = 0;
	
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if(X[i] == Y[j]) {
				c[i][j] = c[i-1][j-1] + 1;
			} else {
				c[i][j] = max(c[i-1][j], c[i][j-1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	
	return maxl;
}

int main() {
	string s1, s2;
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    string s;
    cin >> s;
    lint ans = 0,ans2=0;
    REP(i,SZ(s)){
        if(s[i]=='I'){
            ans++;
        }else{
            ans--;
        }
        ans2 = max(ans, ans2);
    }
    cout << ans2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	int m = n-n/2;
	cout << fixed << setprecision(10) << (double)(m)/(double)(n) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r, c;

		r = sc.nextInt();
		c = sc.nextInt();

		int[][] matrix = new int[r + 1][c + 1];

		for(int i = 0; i < r; i++) {
			for(int j = 0; j < c; j++) {
				matrix[i][j] = sc.nextInt();
			}
		}

		sc.close();

		for(int i = 0; i <= r; i++) {
			matrix[i][c] = 0;
			for(int j = 0; j <= c; j++) {
				if(j < c) {
					System.out.printf("%d ", matrix[i][j]);
					matrix[i][c] = matrix[i][c] + matrix[i][j];
					matrix[r][j] = matrix[r][j] + matrix[i][j];
				} else if(j == c) {
					System.out.printf("%d\n", matrix[i][c]);
				}
			}
		}

	}
}



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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef long long ll;

const int MOD = 1000000007;
const int INF = 1000000007;

void solve() {
  int H, N;
  cin >> H >> N;
  vi dp(H + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    for (int j = 0; j < H; j++) {
      int nj = min(j + a, H);
      dp[nj] = min(dp[nj], dp[j] + b);
    }
  }
  cout << dp[H] << endl;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;

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

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 0;

        for(int i=0; i<N; i++){
            int x = sc.nextInt();
            int y = sc.nextInt();
            sum += (y-x)+1;
        }

        System.out.println(sum);
    }

}

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

int main(){
  std::string s;
  std::cin >> s;
  auto length = s.length();
  int cnt = 0;
  for(int i = 0; i < length/2; ++i)
    if(s[i] != s[length-1-i])
      ++cnt;
  std::cout << cnt << std::endl;
  return 0;
}


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

int main()
{
  int n;
  cin >> n;
  int* arr = new int[n];
  for (int i=0; i<n; i++)
  {
    cin >> arr[i];
  }
  for (int i=n-1; i>0; i--)
  {
    cout << arr[i] << ' ' << flush;
  }
  cout << arr[0] << endl;
}

Measured memory_bytes: 1188
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n, a, b;
    cin >> n >> a >> b;

    if(a * b < n || a + b > n + 1){
        cout << -1 << endl;
        return 0;
    }

    bool rev = false;
    if(a < b){
        swap(a, b);
        rev = true;
    }

    int m = n / a;
    int ex = n % a;
    int bLen = 0;
    if(ex > 0){
        bLen++;
    }

    if(bLen > b - m){
        cout << -1 << endl;
        return 0;
    }

    int need = b - bLen - m;
    while(need > 0){
        if(ex > 0){
            bLen++;
            ex--;
            need--;
            continue;
        }

        if(m <= 1){
            cout << -1 << endl;
            return 0;
        }
        m--;
        need++;
        ex += a;
    }
    //cout << m << " " << bLen << " " << ex << endl;

    vector<int> ans;
    int last = n;
    rep(i, m){
        rep(j, a){
            ans.push_back(last - a + 1 + j);
        }
        last -= a;
    }

    for(int i = 1; i <= n - m * a - bLen; i++){
        ans.push_back(i);
    }

    for(int i = n - a * m; i > n - m * a - bLen; i--){
        ans.push_back(i);
    }

    if(rev){
        reverse(ans.begin(), ans.end());
    }

    cout << ans[0];
    for(int i = 1; i < n; i++){
        cout << " " << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 6512
#include<stdio.h>
#pragma GCC optimize("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=1e9+7;
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline int Mult(int x,int y){long z=x*y-(long)((long double)x/MOD*y+1e-8)*MOD;return z;}
static inline void Radix(int A[],const int N)
{
  int temp[200001];
  rep(k,4)
  {
    int u[256]={},v[256]={};
    rep(i,N)u[A[i]>>8*k&255]++;
    rep(i,255)u[i+1]+=u[i];
    rep(i,N){temp[--u[A[N-1-i]>>8*k&255]]=A[N-1-i];}k++;
    rep(i,N)v[temp[i]>>8*k&255]++;
    rep(i,255)v[i+1]+=v[i];
    rep(i,N)A[--v[temp[N-1-i]>>8*k&255]]=temp[N-1-i];
  }
}
int main()
{
  int N=IN(),K=IN(),m=0,p=0,z=0,accum=1,A[200000];
  rep(i,N){A[i]=IN();if(A[i]>0)p++;else if(A[i]<0)m++;else z++;}
  Radix(A,N);
  if(K==N){if(z){return puts("0"),0;}else{rep(i,K){accum=Mult(accum,A[i]);}K=0;}}
  if(m+p<K)return puts("0"),0;
  if(!p&&K&1){if(z){return puts("0"),0;}else rep(i,K){accum=Mult(accum,A[N-1-i]);}K=0;}
  p+=z,m=p;
  if(K&1){K--;accum=Mult(accum,A[--p]);}
  while(K)
  {
    K-=2;
    if(p>=2&&m<=N-2&&1l*A[p-1]*A[p-2]>1l*A[m]*A[m+1])
    {accum=Mult(accum,A[--p]);accum=Mult(accum,A[--p]);continue;}
    if(p>=2&&m<=N-2&&1l*A[p-1]*A[p-2]<1l*A[m]*A[m+1])
    {accum=Mult(accum,A[m++]);accum=Mult(accum,A[m++]);continue;}
    if(p>=2){accum=Mult(accum,A[--p]);accum=Mult(accum,A[--p]);continue;}
    if(m<=N-2){accum=Mult(accum,A[m++]);accum=Mult(accum,A[m++]);continue;}
  }
  return printf("%d\n",accum<0?accum+MOD:accum),0;
}

Measured memory_bytes: 3160
nk = list(map(int,input().split()))
ls = list(map(int,input().split()))

d = dict()

for i in ls:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
       
l = list(d.values())
l.sort(reverse = True)

num = sum(l[nk[1]:])

print(num)

Measured memory_bytes: 32288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll x;
	cin>>x;
	vector<ll>b;
	for(ll i=2;i<=1000000007;i++){
		bool ch=true;
		for(auto itr=b.begin();itr!=b.end();itr++){
			if(i%*itr==0){
				ch=false;
				break;
			}
		}
		if(ch){
			if(i>=x){
				cout <<i;
				return 0;
			}
			b.push_back(i);
		}
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"APPROVED":"DENIED")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    
    bool ok = true;
    rep (i, n) {
        if (a[i] % 2 == 0) {
            if (a[i] % 3 == 0 || a[i] % 5 == 0) {

            }
            else {
                ok = false;
                break;
            }
        }
    }
    yorn(ok);


    return 0;
}

Measured memory_bytes: 3612
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int xX = sc.nextInt();
        int yY = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            x.add(sc.nextInt());
        }
        for (int i = 0; i < m; i++) {
            y.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(x);
        Collections.sort(y);

        int low = Math.max(xX, x.get(n - 1));
        int high = Math.min(yY, y.get(0));
        if (low < high) {
            System.out.println("No War");
        } else {
            System.out.println("War");
        }

    }

}


Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		solve3027();
	}

	public static void solve3027() {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int binaryNumDigits = Integer.toBinaryString(N).length();

		int ans = N == Math.pow(2, binaryNumDigits) - 1 ? binaryNumDigits : binaryNumDigits - 1;
		System.out.println(ans);

		sc.close();
	}
}



Measured memory_bytes: 26276
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int MAX_V = 51;
const int MAX_L = (1 << 10);
const int MAX_K = 15;
const int INF = 1e9;
#define DEBUG

class C{
  public:
    int n, t, b;
    C(){}
    C( int _n, int _t ){ n = _n; t = _t; b = 0; }
    C( int _n, int _t, int _b){ n = _n; t = _t; b = _b; }
    bool operator > (const C &c) const { return t > c.t; }
};

int G[MAX_V][MAX_V], S, T, V, E, L, K;
bool B[MAX_V];
int closed[MAX_V][MAX_L][MAX_K], cnt[MAX_V][MAX_L];;
map<int, int> bn;

int solve(){
  priority_queue<C, vector<C>, greater<C>> open;
  open.push(C(S, 0));
  REP(i, MAX_V) REP(j, MAX_L) REP(k, MAX_K) closed[i][j][k] = INF;
  REP(i, MAX_V) REP(j, MAX_L) cnt[i][j] = 0;
  while(!open.empty()){
    C now = open.top(); open.pop();
    int n = now.n, b = now.b, t = now.t;
    if(B[n]) b = (b | (1 << bn[n]));
    if(cnt[n][b] >= K || closed[n][b][cnt[n][b]] < t) continue;
    closed[n][b][cnt[n][b]++] = t;
    REP(next, V){
      if(G[n][next] == INF) continue;
      open.push(C(next, t + G[n][next], b));
    }
  }
  return (closed[T][(1 << L) - 1][K - 1] == INF ? -1 : closed[T][(1 << L) - 1][K - 1]);
}

int main() {
  while(cin >>V >>E >>L >>K && V){
    REP(i, MAX_V) REP(j, MAX_V) G[i][j] = INF;
    memset(B, 0, sizeof(B));
    REP(i, E){
      int u, v, c; cin >>u >>v >>c;
      --u; --v;
      G[u][v] = G[v][u] = c;
    }
    cin >>S >>T;
    --S; --T;
    REP(i, L){
      int n; cin >>n;
      --n;
      B[n] = true;
      bn[n] = i;
    }
    int ans = solve();
    if(ans == -1) cout <<"NA" <<endl;
    else cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 79408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main(){
    int n, k;   cin >> n >>k;
    string s;   cin >> s;
    vector<ll> a;
    if(s[0]=='0') a.push_back(0);
    int cnt=1;
    REP(i, n){
        if(s[i]==s[i+1]){
            cnt += 1;
            if(i==n-1) a.push_back(cnt);
        }else{
            a.push_back(cnt);
            cnt = 1;
        }
    }
    if(s.back()=='0') a.push_back(0);
    //尺取り法
    int left=0, right=0, sum=0, res=0;
    //for(auto x: a) cout << x << endl;
    while(right<a.size()){
        
        while(right<a.size() && right-left<=2*k){
            sum += a[right++];
        }
        //cout << sum << endl;
        res = max(sum, res);
        sum -= a[left]+a[left+1];
        left += 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 1528
N,M,X=gets.split.map(&:to_i)
b=[[0]*(M+1)]
N.times{
  a=gets.split.map(&:to_i)
  d=[]
  b.each{|c|
    d<<(M+1).times.map{|i|c[i]+a[i]}
  }
  b+=d
}
b.sort{|x,y|x[0]<=>y[0]}.each{|c|
  if (1..M).all?{|i|c[i]>=X}
    p c[0]
    exit
  end
}
p -1

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

using namespace std;

int main()
{
    int N, M;
    int *a, *b;

    cin >> N >> M;

    a = new int[M];
    b = new int[M];

    vector<int> num(N, 0);

    for(int i=0; i<M; i++){
        cin >> a[i] >> b[i];

        num.at(a[i]-1) = num.at(a[i]-1) + 1;
        num.at(b[i]-1) = num.at(b[i]-1) + 1;
    }

    for(int i=0; i<num.size(); i++){
        cout << num.at(i) << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a <= 5) {
            System.out.println(0);
        } else if (a <= 12) {
            System.out.println(b / 2);
        } else {
            System.out.println(b);
        }

    }

}


Measured memory_bytes: 21844
N, M = list(map(int, input().split()))
base = []
for i in range(N):
    x = list(map(int, input().split()))
    _ = x.pop(0)
    tmp = [0] * M
    for j in x:
        tmp[j-1] = 1

    base.append(tmp)

base = list(map(list, zip(*base)))

count = 0
for x in base:
    if not 0 in x:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

int main() {
	string S;
    cin>>S;
	if(S.length()==2) cout << S<<endl;
	else cout <<S[2]<<S[1]<<S[0]<<endl; 
}


Measured memory_bytes: 892
n,m,x = map(int, input().split())
C = []
for i in range(n):
    C.append(list(map(int, input().split())))

ans = []
import itertools
for tuple_ in itertools.product(range(2), repeat=n):
    res = [0]*(m+1)
    #print(tuple_)
    for i,f in enumerate(tuple_):
        if f:
            for j in range(m+1):
                res[j] += C[i][j]
    #print('res', res)
    ng = 0
    for k in range(m):
        if res[k+1] < x:
            ng += 1
    if ng == 0:
        ans.append(res[0])
if ans:
    print(min(ans))
else:
    print('-1')
#print(ans)



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

int main() {
  string s;
  int counter = 0;
  cin >> s;
  if(s[0]=='1') counter++;
  if(s[1]=='1') counter++;
  if(s[2]=='1') counter++;
  cout << counter << endl;
}
    

Measured memory_bytes: 3596
import java.util.Scanner;

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();
        int D = sc.nextInt();

        System.out.println(Math.min(A, B) + Math.min(C, D));
    }
}


Measured memory_bytes: 21716
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define all(x) x.begin(),x.end()
#define endl '\n'
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define all(x) x.begin(),x.end()
#define clr(v,val) memset(v,val,sizeof(v))
#define rep(i,m,n) for(int i=m ; i<n ; i++)
#define forr(i,m,n) for(int i=m ; i<=n ; i++)
#define pb push_back
#define pff push_front
#define re return
#define bit __builtin_popcountll
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 10;
using namespace std;
int main(){
    IO;
    int n,o=0;
    cin>>n;
    forr(i,1,n){
    if(i&1)
        o++;
    }
    cout<<fixed<<setprecision(9)<<ld(o)/ld(n);


}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    S = input()
    T = input()
    ls = len(S)
    lt = len(T)

    ans = INF
    for i in range(ls - lt + 1):
        cur = 0
        for j in range(lt):
            if S[i + j] != T[j]:
                cur += 1
        ans = min(ans, cur)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 67480
#include<iostream>
#define ll long long
using namespace std;

ll A,B,N,res;
ll ans;
int main(){
    scanf("%lld%lld%lld",&A,&B,&N);
    if( N >= B ){
        res = N/B*B-1;
    }else{
        res = N;
    }
    ans = (A*res/B) - A *(res/B);
    printf("%lld\n",ans);
}

Measured memory_bytes: 3760
n,q=map(int,input().split())
s=input()

cnt = [False] * n

for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        cnt[i] = True

acc = [0] * n
now = 0

for i in range(n):
    if cnt[i]:
        now += 1
    acc[i] = now


for _ in range(q):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    cnt_b = acc[b]
    cnt_a = acc[a] if a >= 0 else 0
    print(cnt_b - cnt_a)


Measured memory_bytes: 6876
n=int(input())
if n<=9:
    print(n)
    exit()
dp=[[0]*10 for _ in range(10)]
for k in range(1,n+1):
    s=str(k)
    dp[int(s[0])][int(s[-1])]+=1
ans=0
for i in range(10):
    for j in range(10):
        ans+=dp[i][j]*dp[j][i]
print(ans)

Measured memory_bytes: 9040
#include "bits/stdc++.h"
#include <random>
using namespace std; typedef unsigned long long _ulong; typedef long long int lint; typedef pair<lint, lint> plint; typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define endk '\n'
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const lint MOD = 1e9 + 7, INF = 1e18;
lint dx[8] = { 0, -1, 1, 0, 1, -1, 1, -1 }, dy[8] = { 1, 0, 0, -1, -1, -1, 1, 1 };

lint H, W, dp[1000][1000], sy, sx, gy, gx;
char mp[1000][1000];

struct tlint {
	lint y;
	lint x;
};

int main() {
	cin >> H >> W;
	cin >> sy >> sx; sy--; sx--;
	cin >> gy >> gx; gy--; gx--;
	REP(i, H) {
		REP(j, W) {
			cin >> mp[i][j];
			dp[i][j] = INF;
		}
	}

	deque<tlint> que;
	dp[sy][sx] = 0;
	que.push_front({ sy, sx });
	while (!que.empty()) {
		tlint curr = que.front(); que.pop_front();
		if (curr.y == gy && curr.x == gx) break;
		REP(k, 4) {
			lint ny = curr.y + dy[k], nx = curr.x + dx[k];
			if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
			if (mp[ny][nx] == '#') continue;
			if (dp[ny][nx] > dp[curr.y][curr.x]) {
				dp[ny][nx] = dp[curr.y][curr.x];
				que.push_front({ ny, nx });
			}
		}
		REP(i, 5) {
			REP(j, 5) {
				lint ny = curr.y - 2 + i, nx = curr.x - 2 + j;
				if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
				if (mp[ny][nx] == '#') continue;
				if (dp[ny][nx] > dp[curr.y][curr.x] + 1) {
					dp[ny][nx] = dp[curr.y][curr.x] + 1;
					que.push_back({ ny, nx });
				}
			}
		}
	}

	if (dp[gy][gx] == INF) cout << -1 << endk;
	else cout << dp[gy][gx] << endk;
}


Measured memory_bytes: 12580
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int a,b;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(a);in(b);
	printf("%d\n",a+b/2);
	return 0;
}


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

using namespace std;

int main()
{
    char s[5];
    cin>>s;
    if(s[0]=='a' && s[1]=='b' && s[2]=='c' ||s[0]=='a' && s[1]=='c' && s[2]=='b'|| s[0]=='b' && s[1]=='a' && s[2]=='c' || s[0]=='b' && s[1]=='c' && s[2]=='a' || s[0]=='c' && s[1]=='a' && s[2]=='b' || s[0]=='c' && s[1]=='b' && s[2]=='a')
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            sum = 500 * i + 100 * j + 50 * k
            if sum == X:
                count += 1

print(count)

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

int main() {
	int n;
	cin >> n;
	int a[114];
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	int ans = 1e9;

	for (int i = a[0]; i <= a[n - 1]; i++) {
		int res = 0;
		for (int j = 0; j < n; j++) {
			res += (i - a[j])*(i - a[j]);
		}
		ans = min(res, ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    int k=t.length();
    if(n<k){
    cout<<"UNRESTORABLE"<<endl;
    return 0; 
    }
    bool can=false;
    for(int i=n-1;i-k>=-1;i--){
        bool ans = true;
        for(int j=k-1;j>=0;j--){
            if(t[j]==s[i-(k-1-j)]||s[i-(k-1-j)]=='?'){

            }
            else{
                ans = false;
            }
        }
        if(ans){
            can = true;
            for(int j=k-1;j>=0;j--){
                s[i-(k-1-j)]=t[j];
            }
            break;
        }
    }
    if(can){
        rep(i,n){
            if(s[i]=='?'){
                s[i]='a';
            }
        }
        cout<<s<<endl;
    }
    else{
    cout<<"UNRESTORABLE"<<endl;
    }
}

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    k, x = map(int, input().split())
    f = x-k+1 if x-k+1 > -1000000 else -1000000
    l = x+k-1 if x+k-1 < 1000000 else 1000000
    ans = [i for i in range(f, l+1)]
    print(*ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>


int main(void)
{
	//変数の宣言
	int a,b;
	
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	int min;
	//データの読み込み
	scanf("%d %d",&a,&b);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(a<=8&&b<=8){
		printf("Yay!");
	}else{
		printf(":(");
	}
	
	
//	printf("計算部分終了\n");
	//出力
	
	//printf("%lld %lld",min,max);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18


long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

vector<ll> factors[1100000];

int main(){
    for(int i = 2; i <= 1000100; i++){
		if(factors[i].size() == 0){
			for(int j = i; j <= 1000100; j += i){
				factors[j].push_back(i);
			}
		}
	}

    int n;
    cin >> n;
    map<ll, ll> m;

    ll tmplcm = 1;
    ll a[n];
    ll tmpp = 1, tmpr;
    rep(i, n){
        cin >> a[i];
        ll tmp = a[i];

        for(ll num : factors[tmp]){
			ll cnt = 0;
			while(tmp % num == 0){
				cnt += 1;
				tmp /= num;
			}
			m[num] = max(m[num], cnt);
		}
    }

    ll s = 1;
    for (auto p : m){
        rep(i, p.second){
            s *= p.first;
            s %= MOD;
        }
    }
    
    ll ans = 0;
    rep(i, n){
        ans += s * rev_mod(a[i]) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 73088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	bool flag=true;
	rep(i,n){
		cin>>a[i];
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0){
				flag=false;
			}
		}
	}
	if(flag){
		cout<<"APPROVED"<<endl;
	}else{
		cout<<"DENIED"<<endl;
	}
}

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

int main() 
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,c;
	cin>>n>>c;
	int d[50][50];
	for(int i=1;i<=c;i++)
	for(int j=1;j<=c;j++)
	cin>>d[i][j];
	int a[n+1][n+1];
	vector<int> v0(c+1,0),v1(c+1,0),v2(c+1,0);
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			cin>>a[i][j];
			if((i+j)%3==0)
			v0[a[i][j]]++;
			if((i+j)%3==1)
			v1[a[i][j]]++;
			if((i+j)%3==2)
			v2[a[i][j]]++;
		}
	}
	int ans=1000000000;
	for(int i=1;i<=c;i++)
	{
		for(int j=1;j<=c;j++)
		{
			if(j!=i){
			for(int k=1;k<=c;k++)
			{
				if(k!=j){
				if(i!=j && j!=k && i!=k)
				{
					int aa=0,bb=0,cc=0;
					for(int l=1;l<=c;l++)
					if(l!=i)
					aa+= d[l][i]*v0[l];
					for(int l=1;l<=c;l++)
					if(l!=j)
					bb+= d[l][j]*v1[l];
					for(int l=1;l<=c;l++)
					if(l!=k)
					cc+= d[l][k]*v2[l];
					ans = min(ans,aa+bb+cc);
				}
				}
			}}
		}
	}
	cout<<ans<<endl;
/*
	int mi1=INT_MAX,mi2=INT_MAX,mi3=INT_MAX,rr=0;
	for(int cc=1;cc<=c;cc++)
	{
		int sum=0;
		for(int j=0;j<v0.size();j++)
		{
			if(v0[j]!=cc)
			sum+= d[v0[j]][cc];
		}
		mi1= min(mi1,sum);
	}
	for(int cc=1;cc<=c;cc++)
	{
		int sum=0;
		for(int j=0;j<v1.size();j++)
		{
			if(v1[j]!=cc)
			sum+= d[v1[j]][cc];
		}
		mi2= min(mi2,sum);
	}
	for(int cc=1;cc<=c;cc++)
	{
		int sum=0;
		for(int j=0;j<v2.size();j++)
		{
			if(v2[j]!=cc)
			sum+= d[v2[j]][cc];
		}
		mi3= min(mi3,sum);
	}
	if(mi1!=INT_MAX)
	rr+=mi1;
	if(mi2!=INT_MAX)
	rr+=mi2;
	if(mi3!=INT_MAX)
	rr+=mi3;
	cout<<rr<<endl;*/
	return 0;
} 

Measured memory_bytes: 1280
N = input().split()
A, B = int(N[0]), int(N[1])
if A == 1 or B == 1:
    if A == 1 and B != 1:
        print('Alice')
    elif A != 1 and B == 1:
        print('Bob')
    else:
        print('Draw')
else:
    if A > B:
        print('Alice')
    elif A < B:
        print('Bob')
    else:
        print('Draw')

Measured memory_bytes: 3064
/*
AOJ - ITP1_8_a
Date: 20181003
Author: Mikoron * ♡mikoiwate♡
 */

#define MAX 1200

#include<stdio.h>

int main(void) {
        short i;
        char words[MAX];

        fgets(words, sizeof(words), stdin);

        i = 0;
        while(words[i] != '\0') {
                if(words[i] > 64 && words[i] < 91) words[i] += 32;
                else if(words[i] > 96 && words[i] < 123) words[i] -= 32;
                printf("%c", words[i]);
                i++;
        }

        return 0;
}



Measured memory_bytes: 2068
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>

#define MAX_V 101
#define INF 10000000

using namespace std;


struct edge{int to, cost; };
typedef pair<int, int> P;

int V,mincost[MAX_V];
vector<edge>G[MAX_V];

int Prim(int s){
  priority_queue<P, vector<P>, greater<P> >que;
  fill(mincost, mincost+V, INF);

  vector<bool> visited(V);
  fill(visited.begin(),visited.end(),false);

  mincost[s]=0;
  que.push(P(0,s));
  int res=0;
  while(!que.empty()){
    P p = que.top();
    que.pop();
    
    int v = p.second;
    if(visited[v])continue;
    visited[v]=true;
    res+=mincost[v];

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


int main(void){
  int m,a,b,c;
  char ch1,ch2;
  edge e;

  while(cin >> V,V){
    for(int i=0;i<V;i++)G[i].clear();
    cin >> m;
    for(int i=0;i<m;i++){
      cin >> a >> ch1 >> b >> ch2 >> c;
      c=c/100-1;
      e.to=b,e.cost=c;
      G[a].push_back(e);
      e.to=a;
      G[b].push_back(e);
    }
      cout << Prim(0) << endl;
  }

  return 0;
}

Measured memory_bytes: 1340
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  V<> a(n), c(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  V<> b(n + 1);
  for (int i = 1; i < n + 1; i++) if (c[i]) for (int j = 0; j < min(c[i], i); j++) b[i - j]++;
  int res = 0;
  for (int i = 1; i < n + 1; i++) res += !c[i] and !b[i];
  for (int im = 0; im < m; im++) {
    int x, y; cin >> x >> y, x--;
    if (a[x] != y) {
      if (a[x] - c[a[x]] + 1 > 0) {
        b[a[x] - c[a[x]] + 1]--;
        res += !b[a[x] - c[a[x]] + 1] and !c[a[x] - c[a[x]] + 1];
      }
      if (y - c[y] > 0) {
        res -= !b[y - c[y]] and !c[y - c[y]];
        b[y - c[y]]++;
      }
      c[a[x]]--;
      res += !b[a[x]] and !c[a[x]];
      res -= !b[y] and !c[y];
      c[a[x] = y]++;
    }
    cout << res << '\n';
  }
}

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


unsigned int xor128(){
	static unsigned int x=123456789;
	static unsigned int y=362436069;
	static unsigned int z=521288629;
	static unsigned int w=88675123;
	unsigned int t;
	t=x^(x<<11);
	x=y;y=z;z=w;
	return w=(w^(w>>19))^(t^(t>>8));
}
struct node{
	node*l,*r;
	int cnt,val,Min;
};
node pool[400000];
int p;

inline int cnt(node*t){return t?t->cnt:0;}
inline int Min(node*t){return t?t->Min:INF;}

inline node*update(node*t){
	t->cnt=cnt(t->l)+cnt(t->r)+1;
	t->Min=min({t->val,Min(t->l),Min(t->r)});
	return t;
}
inline node*merge(node*l,node*r){
	if(!l)return r;
	if(!r)return l;
	if(rand()%(cnt(l)+cnt(r))<cnt(l)){
		l->r=merge(l->r,r);
		return update(l);
	}
	else{
		r->l=merge(l,r->l);
		return update(r);
	}
}
inline pair<node*,node*>split(node*t,int k){
	if(!t)return make_pair((node*)NULL,(node*)NULL);
	if(k<=cnt(t->l)){
		auto p=split(t->l,k);
		t->l=p.second;
		return make_pair(p.first,update(t));
	}
	else{
		auto p=split(t->r,k-cnt(t->l)-1);
		t->r=p.first;
		return make_pair(update(t),p.second);
	}
}

int main(){
	int n,q;scanf("%d%d",&n,&q);
	node*root=NULL;
	rep(i,n){
		int a;scanf("%d",&a);
		node*t=&pool[p++];
		*t={NULL,NULL,1,a,a};
		root=merge(root,t);
	}
	rep(i,q){
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y-1);
			auto c=split(b.second,1);
			root=merge(merge(merge(a.first,c.first),b.first),c.second);
		}
		else if(x==1){
			z++;
			auto a=split(root,y);
			auto b=split(a.second,z-y);
			printf("%d\n",Min(b.first));
			root=merge(merge(a.first,b.first),b.second);
		}
		else{
			auto a=split(root,y);
			auto b=split(a.second,1);
			b.first->val=z;
			update(b.first);
			root=merge(merge(a.first,b.first),b.second);
		}
	}
}


Measured memory_bytes: 9492
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int (i) = (a); (i) < (b); ++(i))
#define per(i, a, b) for (int (i) = (a); (i) >= (b); --(i))
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define ff first
#define ss second
#define sz(x) ((int) x.size())
#define rd(type, ...) type __VA_ARGS__; sc(__VA_ARGS__)
#define rda(a, n) rep(i, 0, n) cin >> a[i];
#define rdaa(a, n, m) rep(i, 0, n) rep(j, 0, m) cin >> a[i][j];
#define rdv(type, v, n) vector<type> v(n); rep(__ii, 0, n) cin >> v[__ii]
#define rdm(type, v, h, w) vector<vector<type>> v(h, vector<type>(w)); rep(__ii, 0, h) rep(__jj, 0, w) cin >> v[__ii][__jj]
#define rdv2(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_rdv2_Init(n, __VA_ARGS__); for(int w_=0; w_<n; ++w_){MACRO_rdv2_Scan(w_, __VA_ARGS__);}
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "] : ", debug_out(__VA_ARGS__)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
void solve();
signed main() {ios::sync_with_stdio(false); cin.tie(0);
  cout << fixed; cout.precision(20); solve(); return 0;}
template<typename T> void chmin(T &a, T b) {if (a > b) a = b;}
template<typename T> void chmax(T &a, T b) {if (a < b) a = b;}
template<typename T> void MACRO_rdv2_Init(int n, T& t) { t.resize(n); }
template<typename First, typename... Rest> void MACRO_rdv2_Init(int n, First& first, Rest& ...rest) { first.resize(n); MACRO_rdv2_Init(n, rest...); }
template<typename T> void MACRO_rdv2_Scan(int p, T& t) { std::cin >> t[p]; }
template<typename First, typename... Rest> void MACRO_rdv2_Scan(int p, First& first, Rest& ...rest) { std::cin >> first[p]; MACRO_rdv2_Scan(p, rest...); }
template<typename T> void wrv(const vector<T> &v) {rep(__ii, 0, sz(v)) {if (__ii) cout << ' '; cout << v[__ii];} cout << '\n';} 
template<typename T> void wrm(const vector<vector<T>> &v) {rep(__ii, 0, sz(v)) {rep(__jj, 0, v[__ii].size()) {if (__jj) cout << ' '; cout << v[__ii][__jj];} cout << '\n';}}
template<typename T> void sc(T& x) {cin >> x;}
template<typename Head, typename... Tail> void sc(Head& head, Tail&... tail) {cin >> head; sc(tail...);}
template<typename T> void wr(const T& x) {cout << x << '\n';}
template<typename Head, typename... Tail> void wr(const Head& head, const Tail&... tail) {cout << head << ' '; wr(tail...);}
template<typename T> void wrf(const T& x) {cout << x << endl;}
template<typename Head, typename... Tail> void wrf(const Head& head, const Tail&... tail) {cout << head << ' '; wrf(tail...);}
template<typename T> void debug_out(const T& x) {cerr << x << '\n';}
template<typename Head, typename... Tail> void debug_out(const Head& head, const Tail&... tail) {cerr << head << ' '; debug_out(tail...);}
template<typename... T> void err(const T&... cod) {wr(cod...); exit(0);}

void solve() {
  rd(int, h, a);
  wr((h + a - 1) / a);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,ans=1,need=0;
  cin>>a>>b;
  need+=a;
  while(need < b){
    need+=a-1;
    ans++;
  }
  if(b == 1)
    ans=0;
  cout<<ans<<'\n';
  return(0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long getsum(long a,long b){
  if(a<b){
    long t;
    t=a;
    a=b;
    b=t;
  }
  return a*(a+1)/2+((b-1)*b)/2;
}
int main(){
  char s[500000];
  cin>>s;
  long sum=0;
  long a=0,b=0;
  int c=0;
  for(long i=0;s[i]!='\0';i++){//cout<<sum<<endl;
    if(s[i]=='<'){
     if(c==0){
       a++;
     }
     else{
       sum+=getsum(a,b);
       a=1;
       b=0;
     }
      c=0;
    }
    else{
      b++;
      c=1;
    }
  }
  sum+=getsum(a,b);
  cout<<sum;
  return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main{
    public void solve(){
    Scanner sc = new Scanner(System.in);
    int t,n;
        for(int i=0;i<=3;i++){
        t = sc.nextInt();
        n = sc.nextInt();
        if(t==1){
            int kei = 6000*n;
            System.out.println(kei);
        }else{
            if(t==2){
                int kei = 4000*n;
                System.out.println(kei);
                }else{
                    if(t==3){
                        int kei = 3000*n;
                        System.out.println(kei);
                        }else{
                        int kei = 2000*n;
                        System.out.println(kei);
                    }
            }
        }
    }
    }
        public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 17364
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define NMini 1
#define NMaxes 10000
#define Mini 2
#define Maxes 100000000
int main(){
  int i,j,N,num[NMaxes],count=0;
  scanf("%d",&N);

  if(N>NMaxes || N<NMini) exit(1);

  for(i=N;i>0;i--){
    scanf("%d",&num[i]);
    if(num[i]>=Mini && num[i]<=Maxes){
      if(num[i]!=2 && num[i]%2==0) count++;
      else{
	for(j=3;j<=sqrt(num[i]);j+=2){
	  if(num[i]%j==0){
	    count++;
	    break;
	  }
	}
      }
    }
    else break;
  }
  printf("%d\n",N-count);
  return 0;
}



Measured memory_bytes: 2124
import java.util.*;
import java.io.*;

public class Main {
    static long MOD = 998244353;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int n = scanner.nextInt();
        char[] s = scanner.next().toCharArray();
        long ans = 1;
        for(int i = 2; i <= n; i++) ans = (ans * (long)i) % MOD;
        int[] cnt = new int[3];
        String x = "RGB";
        int curMin = 0, curMax = 0;
        long open = 0, closed = 0, other = 0;
        for(int i = 0; i < 3*n; i++) {
            int ind = x.indexOf(s[i]);
            cnt[ind]++;
            int newMin = Math.min(Math.min(cnt[0], cnt[1]), cnt[2]);
            int newMax = Math.max(Math.max(cnt[0], cnt[1]), cnt[2]);
            //clsoed something
            //can choose which we close
            if (newMin != curMin)  {
                ans = (ans * other) % MOD;
                closed++;
                other--;
            }
            //opened a new one
            else if (newMax != curMax) {
                open++;
            }
            //add an other to an opened one
            else {
                ans = (ans * open) % MOD;
                open--;
                other++;
            }
            curMin = newMin;
            curMax = newMax;
        }
        out.println(ans);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 26728
n,x,y=map(int,input().split())
ans=[[1000000]*n for i in range(n)]
for i in range(n-1):
    for j in range(i+1,n):
        ans[i][j]=min(j-i,abs(x-1-i)+1+abs(y-1-j))
_ans=[0]*(n-1)
for i in range(n-1):
    for j in range(i+1,n):
        _ans[ans[i][j]-1]+=1
for i in range(n-1):
    print(_ans[i])

Measured memory_bytes: 83192
#include<bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define mer make_pair
#define fi first
#define se second
using namespace std;

map<int,bool> mp;

int main(){
	//my new name is Veex
	//clock_t start1=clock();
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=a;i<=min(b,a+k-1);i++){
		cout<<i<<endl;
		mp[i]=true;
	}
	for(int i=max(a,b-k+1);i<=b;i++){
		if(mp[i])
			continue;
		cout<<i<<endl;
	}
	//((double)(clock()-start1)/CLOCKS_PER_SEC)*1000;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <utility>
#include <functional>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    int n; cin>>n;
    string s; cin>>s;
    ll ct[26]={};
    for(int i=0; i<n; i++){
        ct[s[i]-'a']++;
    }
    ll ans=1;
    for(int i=0; i<26; i++){
        ans=ans*(ct[i]+1)%MOD;
    }
    ans=(ans+MOD-1)%MOD;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505

#define mod 998244353

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int r;
	cin >> r;
	cout << (ll) 3 * r * r;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	for (int z=0;z<s.size();z++){
		if (s[z] == '?') s[z] = 'D';
	}
	cout << s << endl;
}

Measured memory_bytes: 3732
# abc096_c
H,W = map(int,input().split())
#glid = [][]
glid = ["."+input()+"." for i in range(H)]
glid.append("."*(W+2))
glid.insert(0,"."*(W+2))
ans = "Yes"
for i in range(1,H+1):
    for j in range(1,W+1):
        if glid[i][j]=="#":
            if glid[i][j-1] != "#" and glid[i][j+1] != "#" and glid[i-1][j] != "#" and glid[i+1][j] != "#" :
#                print(i,j,glid[i])
#                print(glid[i][j-1],glid[i][j+1], glid[i-1][j], glid[i+1][j])
                ans = "No"
print(ans)



Measured memory_bytes: 3064