akhauriyash/Code-Regression huggingface dataset:
/*
观察把一个球射入后会发生怎样的事情。分情况讨论：
(1)S[1] = A。操作后S[1] = B，其余不变
(2)S[1] = B
       (a)当S[1 ~ N]均是B时，操作后S[1 <= i <= N] = A
       (b)当能找到第一个S[p] = A时，模拟发生了怎样的事情。用(球->)表示往右射的球，(<-球)表示往左射的球 
     		(球->)BB...BBA
		AA...AA(球->)A
		AA...AA(<-球)B
		AA...AB(球->)B
		AA...ABA(球->)
          因为球的左边是A，所以碰到下一个A的情况与当前分析的相同
   无论哪种情况，都可以看做先删掉S[1]，之后把S所有位置取反，最后在S尾部加上一个A。即S' = rev(S[2 ~ N]) + A
特判掉N = 1的情况。容易发现，每次出现情况1，下一次都是情况2，那么一定会在尾部加上一个A
那么不超过2N次操作后，一定会正好插入N次A，S变成BABABA...BABA或者ABABAB...ABA，这两种情况的求解都很简单 
*/

#include <cstdio>

using namespace std;
const int Max_N(1000050);

int N, K, L, R, Tot, Rev;
char S[Max_N];

int main()
{
	scanf("%d%d", &N, &K);
	scanf("%s", S + 1);
	if (N == 1)
	{
		if (K & 1)
			if (S[1] == 'A')
				putchar('B');
			else
				putchar('A');
		else
			printf("%s", S + 1);
		return 0;
	}
	L = 1, R = N;
	for (int i = 1;;++i)
	{
		if ((Rev == 0 && S[L] == 'A') || (Rev == 1 && S[L] == 'B'))
			if (S[L] == 'A')
				S[L] = 'B';
			else
				S[L] = 'A';
		else
		{
			++L, Rev ^= 1;
			if (Rev == 0)
				S[++R] = 'A';
			else
				S[++R] = 'B';
			++Tot;
		}
		if (i == K)
		{
			while (L <= R)
			{
				if (Rev == 0)
					putchar(S[L]);
				else
					if (S[L] == 'A')
						putchar('B');
					else
						putchar('A');
				++L;
			}
			break;
		}
		if (Tot == N)
		{
			if (Rev)
			{
				for (int j = L;j <= R;++j)
					if (S[j] == 'A')
						S[j] = 'B';
					else
						S[j] = 'A';
				Rev = 0;
			}
			K = (K - i) & 1;
			if (K == 1 && S[L] == 'A')
				S[L] = 'B';
			while (L <= R)
				putchar(S[L++]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 768
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    const K = parseInt(arg[0].split(" ")[2]);

    const CA = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    let exist = false;
    let answer = Infinity;
    
    for(let bit=0; bit<(1<<N); bit++) {
        let sum = [...Array(M+1)].fill(0);
        
        for(let i=0; i<N; i++) {
            if(bit & (1 << i)) {
                for(let j=0; j<M+1; j++) {
                    sum[j] += CA[i][j];
                }
                
                // console.log("sum:" + sum);
            }
        }
        
        const cost = sum.shift();
        
        if(sum.filter(n=>n>=K).length === M) {
            exist  = true;
            answer = Math.min(answer, cost); 
        }
    }
    
    if(exist) {
        console.log(answer);
    } else {
        console.log(-1);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 33632
MOD = 10**9 + 7

import time

def solve(N, A):
    ans = 0
    asum = sum(A)
    for i in range(N-1):
        asum -= A[i]
        ans = (ans + A[i] * asum) % MOD
    return ans

if __name__ == '__main__':
    N = int(input())
    A = [int(a)%MOD for a in input().split()]
    ans = solve(N, A)
    print(ans)

Measured memory_bytes: 94168
MOD = 1_000_000_007
n = gets.to_i

dp = Array.new(n + 1) { Array.new(2) { Array.new(2, 0) }}
dp[0][0][0] = 1

n.times do |i|
  dp[i+1][0][0] = (dp[i][0][0] * 8) % MOD
  dp[i+1][0][1] = (dp[i][0][0] + dp[i][0][1] * 9) % MOD
  dp[i+1][1][0] = (dp[i][0][0] + dp[i][1][0] * 9) % MOD
  dp[i+1][1][1] = (dp[i][1][0] + dp[i][0][1] + dp[i][1][1] * 10) % MOD
end

p dp[n][1][1]


Measured memory_bytes: 149556
program tsundoku
  implicit none
  integer :: n, m, h = 0, i, j
  integer(8) :: k
  integer(8), dimension(0:200001) :: a = 0, b = 0, x = 0, y = 0
  read(*,*) n, m, k
  read(*,*) a(1:n)
  read(*,*) b(1:m)
  do i = 1, n
    x(i) = x(i - 1) + a(i)
  end do
  do i = 1, m
    y(i) = y(i - 1) + b(i)
  end do
  j = m
  do i = 0, n
    if (x(i) > k) exit
    do while (y(j) > k - x(i))
      j = j - 1
    end do
    h = max(h, i + j)
  end do
  write(*,'(i0)') h
end program tsundoku

Measured memory_bytes: 9284
#include<iostream>
#include<cstdio> 
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout) 
typedef long long ll;
const ll mod=998244353;
const ll INF=0x3f3f3f3f;
const ll maxn=1e6+5;
const double pi = acos(-1.0);
using namespace std;
int cantor(int a[], int n)      
{
	int ans = 0;
	for(int i = 0; i < n; i++)
	{
		int x = 0;              
		int c = 1, m = 1;        
		for(int j = i + 1; j < n; j++)
		{
			if(a[j] < a[i]) 
				x++;
			m *= c; 
			c++;
		}
		ans += x * m;
	}
	return ans;
}
int a[100],b[100];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<n;i++) cin>>b[i];
	
	cout<<abs(cantor(a,n)-cantor(b,n))<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int H = scn.nextInt();
		int W = scn.nextInt();
		scn.nextLine();
		int[][] block = new int[H][W];

		int[][] yoko = new int[H][W];
		int[][] tate = new int[H][W];

		for (int i = 0; i < H; i++) {
			char[] ch = scn.nextLine().toCharArray();
			for (int j = 0; j < W; j++) {
				block[i][j] = (ch[j] == '#') ? 0 : 1;
			}
		}

		for (int h = 0; h < H; h++) {
			int count = 0;
			for(int w = 0;w < W;w++) {
				if(block[h][w] == 0) {
					count = 0;
					yoko[h][w] = -1;
				}else {
					count++;
					yoko[h][w] = count;
				}
			}
			count = 0;
			for(int w = W-1;w >= 0;w--) {
				if(yoko[h][w] == -1) {
					count = 0;
				}else {
					count = Math.max(yoko[h][w],count);
					yoko[h][w] = count;
				}
			}
		}

		for (int w = 0; w < W; w++) {
			int count = 0;
			for(int h = 0;h < H;h++) {
				if(block[h][w] == 0) {
					count = 0;
					tate[h][w] = -1;
				}else {
					count++;
					tate[h][w] = count;
				}
			}
			count = 0;
			for(int h = H-1;h >= 0;h--) {
				if(tate[h][w] == -1) {
					count = 0;
				}else {
					count = Math.max(tate[h][w],count);
					tate[h][w] = count;
				}
			}
		}


		long ans = 0;
		for (int h = 0; h < H; h++) {

			for (int w = 0; w < W; w++) {
				if (block[h][w] == 0)
					continue;

				ans = Math.max(ans, yoko[h][w] + tate[h][w] - 1);

			}
		}

		System.out.println(ans);
	}


}


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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> num(n);
    
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        num.at(a - 1)++;
        num.at(b - 1)++;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout << fixed
#define endl '\n'

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

void solve(istream& cin, ostream& cout) {
  int k, x;
  cin >> k >> x;
  FOR(i, x - k + 1, x + k - 1) cout << i << " ";
  cout << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 256
import numpy as np

x1, y1, x2, y2 = map(int, input().split())


def get_rotation_matrix(rad):
    rot = np.array([[np.cos(rad), -np.sin(rad)],
                    [np.sin(rad), np.cos(rad)]], dtype=np.int32)
    return rot


X1 = x1 - x2
Y1 = y1 - y2
r = get_rotation_matrix(np.pi / 2)
rotated = np.dot(-r, np.asarray([X1, Y1], dtype=np.int32))
print(str(rotated[0] + x2) + " " + str(rotated[1] + y2), end=" ")

X2 = -rotated[0]
Y2 = -rotated[1]
r = get_rotation_matrix(np.pi / 2)
XY4 = np.dot(-r, np.asarray([X2, Y2],dtype=np.int32))
x4 = XY4[0]
y4 = XY4[1]
print(str(x4 + rotated[0] + x2) + " " + str(y4 + rotated[1] + y2), end="")

Measured memory_bytes: 12400
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	ll a, b, c;
	scanf("%ld %ld %ld", &a, &b, &c);
	if(a>b) std::swap(a, b);
	if(b>c) std::swap(b, c);
	if(a>b) std::swap(a, b);
	if(a%2 && b%2 && c%2) printf("%ld\n", a*b);
	else puts("0");
	return 0;
}



Measured memory_bytes: 3740
/*Ankon Ghosh
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
///#include <ext/pb_ds/detail/standard_policies.hpp>*/
///using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define inf 1e16
#define MAX 100005
#define mod 998244353
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) printf("Case %lld: ",i)
#define setpre(number) cout<<fixed<<setprecision(10)<<number<<endl
#define pf(a) printf("%lld ",a)
#define pff(a,b) printf("%lld %lld\n",a,b)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll i=x;i<=y;i++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p make_pair
#define ff first
#define ss second
#define p_b push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define output freopen("output.txt","w",stdout)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp1;
vector<pair<ll,ll> >v,vpp,vp1;
vector<ll>v1,v2,fin;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb,mb1;
ll a,b,c,n,d,e,f,ta,sum=0,cnt=0,m,l,req,sz,maxi,k;
priority_queue<ll>pq;
string str;
ll table[6100+10][6100+10];
ll arr[100+10];
void calc()
{
    memset(arr,0,sizeof arr);
    arr[3]=1;
    arr[4]=2;
    for(ll i=5; i<=100; i++)
    {
        if(i%2==1)
            arr[i]=arr[i-1]+2;
        else
            arr[i]=arr[i-1]+1;
    }
}
int main()
{
    fast;
    cin>>n>>k;
    for(ll i=2; i<=n; i++)
    {
        v.p_b({1LL,i});
    }
    ll x=n-2;
    ll tot=((x)*(x+1))/2;
    if(k>tot)
    {
        cout<<-1<<endl;
        return 0;
    }

    for(ll i=2; i<n; i++)
    {
        for(ll j=i+1; j<=n; j++)
        {
            if(tot!=k)
            {
                v.p_b({i,j});
                tot--;
            }
        }
    }
    ll l=v.size();
    cout<<l<<endl;
    for(ll i=0; i<l; i++)
        cout<<v[i].ff<<" "<<v[i].ss<<endl;
    return 0;
}


Measured memory_bytes: 3768
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string.h>
#define N 1002
int main() {
	char tCard[N] = "", hCard[N] = "",*p1,*p2="";
	int tPoint = 0, hPoint = 0,n,i;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", tCard, hCard);
		p1 = tCard;
		p2 = hCard;
		while (*p1||*p2) {
			if (*p1 != *p2)break;
			*(p1++);
			*(p2++);
		}
		if (*p1 || *p2) { --*p1; --*p2; }
		if (*p1 - *p2==0) { tPoint++; hPoint++; }
		else if (*p1 - *p2 < 0)hPoint += 3;
		else if (*p1 - *p2 > 0)tPoint += 3;
	}
	printf("%d %d\n", tPoint, hPoint);
		return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <inttypes.h>

int64_t zettaiti(int64_t x) {
	return x < 0 ? -x : x;
}

/* x以下の最大を求める(ない場合は最小) */
int asumisu(const int64_t data[], int n, int64_t x) {
	int yes = 0, no = n - 1;
	if (data[yes] > x) return 0;
	if (data[no] <= x) return no;
	while (yes + 1 < no) {
		int mid = yes + (no - yes) / 2;
		if (data[mid] <= x) yes = mid; else no = mid;
	}
	return yes;
}

/* x以上の最小を求める(ない場合は最大) */
int mizuhasu(const int64_t data[], int n, int64_t x) {
	int no = 0, yes = n - 1;
	if (data[yes] < x) return n - 1;
	if (data[no] >= x) return no;
	while (no + 1 < yes) {
		int mid = no + (yes - no) / 2;
		if (data[mid] >= x) yes = mid; else no = mid;
	}
	return yes;
}

int A, B;
int Q;
int64_t s[114514];
int64_t t[114514];
int64_t x[114514];

int main(void) {
	int i;
	if (scanf("%d%d%d", &A, &B, &Q) != 3) return 1;
	for (i = 0; i < A; i++) {
		if (scanf("%" SCNd64, &s[i]) != 1) return 1;
	}
	for (i = 0; i < B; i++) {
		if (scanf("%" SCNd64, &t[i]) != 1) return 1;
	}
	for (i = 0; i < Q; i++) {
		if (scanf("%" SCNd64, &x[i]) != 1) return 1;
	}

	for (i = 0; i < Q; i++) {
		int64_t gourikiayame = INT64_C(99999999999999999);
		int64_t zinzya[2], tera[2];
		int j, k;
		zinzya[0] = s[asumisu(s, A, x[i])];
		zinzya[1] = s[mizuhasu(s, A, x[i])];
		tera[0] = t[asumisu(t, B, x[i])];
		tera[1] = t[mizuhasu(t, B, x[i])];
		for (j = 0; j < 2; j++) {
			for (k = 0; k < 2; k++) {
				int64_t sumipe;
				sumipe = zettaiti(zinzya[j] - x[i]) + zettaiti(tera[k] - zinzya[j]);
				if (sumipe < gourikiayame) gourikiayame = sumipe;
				sumipe = zettaiti(tera[k] - x[i]) + zettaiti(zinzya[j] - tera[k]);
				if (sumipe < gourikiayame) gourikiayame = sumipe;
			}
		}
		printf("%" PRId64 "\n", gourikiayame);
	}
	return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
int main(){
  int i,j,k,n,cnt;
  int *array,v;

  scanf("%d",&n);
  array = (int *)malloc(n * sizeof(int));

  for(i=0;i<n;i++) scanf("%d",&array[i]);
  k = n;
  while(k >= 0){
    printf("%d",array[n-k]);
    k--;
    if(k <= 0)break;
    printf(" ");
    }
    printf("\n");

   for(i=1;i<=n-1;i++){
     v = array[i];
     //printf("array[i](v) = %d\n",v);
     if(array[i-1] > v){
      cnt++;
     j = i - 1;
     while(j >= 0 && array[j] > v){
        array[j+1] = array[j];
        array[j] = v;
        //printf("array[j] = %d ,array[j+1] = %d\n",array[j],array[j+1]);
        j--;
      }
      //array[j] = v;
    }
       //for(k=0;k<n;k++) printf("%d ",array[k]);
    //printf("\n");
    k = n;
  while(k >= 0){
    printf("%d",array[n-k]);
    k--;
    if(k <= 0)break;
    printf(" ");
    }
    printf("\n");
  }
  free(array);
  return 0;
}


Measured memory_bytes: 2128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll h, w;
  cin >> h >> w;
  if (h == 1) { // if 1, we can't move
    cout << 1 << endl;
    return 0;
  }
  if (w == 1) { // if 1, we can't move
    cout << 1 << endl;
    return 0;
  }

  // cout << "h: " << h << endl;
  // cout << "w: " << w << endl;
  // cout << "(w+1)/2: " << (w+1)/2 << endl;

  ll ans = 0;
  ans += 1ll * w * (h/2);
  if ((h%2) == 1) {
    ans += (w+1)/2;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
//#define MAX 300000
int main()
{
	int n, count = 0, i, min;
	char s[300005];
	while(scanf("%d", &n) != EOF )
	{
//		printf("000\n");
		scanf("%d", &n);
		count = 0;
		scanf("%s", s);
		for (i = 1; i < n; i++){
			if (s[i] == 'E')
				count++;
		}
		min = count;
//		if (s[0] == 'E')
//			count--;
//		if (min > count)
//			min = count;
//		printf("count = %d", count);
		for (i = 0; i < n-1; i++)
		{
			if(s[i] == 'W' && s[i+1] == 'W'){
				count++;
			}
			else if (s[i] == 'W' && s[i+1] == 'E'){
				continue;
			}
			else if (s[i] == 'E' && s[i+1] == 'W'){
				continue;
			}
			else if (s[i] == 'E' && s[i+1] == 'E'){
				count--;
			}
//			printf("count = %d\n", count);
			if (min > count)
				min = count;
		}
		printf("%d\n", min);
	}
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
    
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    string s;
    int n, q;
    cin >> n >> q;
    cin >> s;
    vector<int> prefix(s.size(), 0);
    for(int i = 0; i < s.size() - 1; i++) {
        if(s[i] == 'A' and s[i + 1] == 'C') {
            prefix[i + 1]++;
        }
        if(i)
            prefix[i] += prefix[i - 1];
    }

    if(s.size() > 1)
        prefix[s.size() - 1] += prefix[s.size() - 2];

    for(int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        int cur_ans = prefix[r];
        if(l) {
            cur_ans -= prefix[l - 1];
            if(s[l - 1] == 'A' and s[l] == 'C') cur_ans--;
        }
        cout << cur_ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 1001001001;
  rep(i,n-m+1){
    string sub = s.substr(i,m);
    int tmp = 0;
    rep(j,m){
      if(sub[j] != t[j]) tmp++;
    }
    ans = min(tmp,ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<string>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const double eps=1e-9;
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(c>=a&&b>=c)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long mod = 1_000_000_007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), K = in.nextInt();
		int a[] = new int[N + 1];
		for ( int i = 1; i <= N; i++ ) {
			a[i] = in.nextInt();
		}
		in.close();

		long dp[][] = new long[N + 1][K + 1];
		dp[0][0] = 1;

		for ( int n = 1; n <= N; n++ ) {
			for ( int k = 0; k <= K; k++ ) {
				if ( k == 0 ) {
					dp[n][k] = 1;
					
				} else if ( k <= a[n] ) {
					dp[n][k] = (dp[n][k - 1] + dp[n - 1][k]) % mod;
					
				} else {
					dp[n][k] = (dp[n][k - 1] + dp[n - 1][k] - dp[n - 1][k - a[n] - 1]) % mod;
					
				} 
			}
		}

		//				for ( long[] ls : dp ) {
		//					for ( long l : ls ) {
		//						System.out.print(l + " ");
		//					}
		//					System.out.println();
		//				}
		System.out.println((dp[N][K] + mod)% mod);
	}
}


Measured memory_bytes: 127444
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
using namespace std; 
void fastio()
{
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
signed main()
{
    fastio();
   int n,k;
    cin>>n>>k;
    int ans=0,a,b;
    while(n--)
    {
        cin>>a>>b;
        int x=(a*a)+(b*b);
       // cout<<x<<" "
       int xx=k*k;
        if(xx>=x)
        ans++;
    }
    cout<<ans;
    
       
}
    


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

int N,M,T,P;

void solve(){
    vector<int> d(T),c(T);
    vector<int> x(P),y(P);
    for(int i=0;i<T;i++) cin>>d[i]>>c[i];
    for(int i=0;i<P;i++) cin>>x[i]>>y[i];

    int num[50][50]={};
    for(int i=0;i<M;i++) for(int j=0;j<N;j++) num[i][j]=1;
    int h=M,w=N;
    for(int i=0;i<T;i++){
        int nex[50][50]={};
        int nh,nw;
        if(d[i]==1){
            nh=h;
            nw=max(c[i],w-c[i]);
            for(int j=0;j<nh;j++){
                for(int k=c[i];k<w;k++){
                    nex[j][k-c[i]]+=num[j][k];
                }
            }
            for(int j=0;j<nh;j++){
                for(int k=0;k<c[i];k++){
                    nex[j][c[i]-1-k]+=num[j][k];
                }
            }
        }else{
            nh=max(c[i],h-c[i]);
            nw=w;
            for(int j=c[i];j<h;j++){
                for(int k=0;k<nw;k++){
                    nex[j-c[i]][k]+=num[j][k];
                }
            }
            for(int j=0;j<c[i];j++){
                for(int k=0;k<nw;k++){
                    nex[c[i]-1-j][k]+=num[j][k];
                }
            }
        }

        for(int j=0;j<nh;j++){
            for(int k=0;k<nw;k++){
                num[j][k]=nex[j][k];
            }
        }
        h=nh;
        w=nw;
    }

    for(int i=0;i<P;i++){
        cout<<num[y[i]][x[i]]<<endl;
    }
}

int main(){
  while(1){
      cin>>N>>M>>T>>P;
      if(N==0) break;
      solve();
  }

  return 0;
}



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

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

using namespace std;

#define MOD 1000000007

// x^n in mod
ll mod_pow(ll x, ll n){
  if(n==0) return 1;

  if(n%2==0){
    return mod_pow(x*x%MOD, n/2) % MOD;
  }else{
    return x * mod_pow(x, (n-1)) % MOD;
  }
}

ll mod_pow_r(ll x, ll n){
  if(x==0)return 0;
  if(n==0) return 1;

  ll ret = 1;
  while(n){
    if(n&1) ret=ret*x%MOD;
    n /= 2;
    x=x*x%MOD;
  }
  
  return ret;
}


ll fac(ll n){
  ll res = 1;
  rep(i, n){
    res *= (i+1);
    res %= MOD;
  }
  return res;
}

// nCr
ll comb(ll n, ll r){
  if(n<0 || n<r || r<0)return 0;
  ll fn = fac(n);
  ll fr = fac(r);
  ll fn_r = fac(n-r);
  
  ll d = (mod_pow(fr, MOD-2)*mod_pow(fn_r, MOD-2))%MOD;
  ll u = fn%MOD;

  return u * d % MOD;
}

int main(){
  ll x,y;
  cin>>x>>y;
  
  if((x+y)%3!=0){
    cout<<0;
    return 0;
  }

  ll k = x-(x+y)/3;
  ll l = y-(x+y)/3;

//  cout<<k<<' '<<l<<endl;
  cout<<comb(k+l, k);
  

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include <string>
#include <cmath>
#include<queue>
#define PI 3.141592653589793238
#define INF -1
#define ll long long
using namespace std;

int main()
{
	string b1, b2, sur;
	int c1, c2;

	cin >> b1 >> b2;
	cin >> c1 >> c2;
	cin >> sur;

	if (b1 == sur) {
		c1--;
	} else {
		c2--;
	}

	printf("%d %d", c1, c2);

	return 0;
}

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

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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);

    for (int &n : p) {
        cin >> n;
    }

    int ans = 0;
    for (int i = 2; i < n; i++) {
        if (((p.at(i -2) < p.at(i - 1)) && (p.at(i - 1) < p.at(i))) ||
            ((p.at(i -2) > p.at(i - 1)) && (p.at(i - 1) > p.at(i))))
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt;
    for ( v = 0; v < n; v++ ) {
    if ( M[u][v] == 0 ) continue;
    if ( color[v] == WHITE ) {
        dfs_visit(v);
    }
    }
    color[u] = BLACK;
    f[u] = ++tt;
    
}

void dfs() {
    int u;
   
    for ( u = 0; u < n; u++ ) color[u] = WHITE; tt = 0;
    for ( u = 0; u < n; u++ ) {
        if ( color[u] == WHITE ) dfs_visit(u);
    }
    for ( u = 0; u < n; u++ ) {
        printf("%d %d %d\n", u + 1, d[u], f[u]);
    }
    }



int main() {
    int u, v, k, i, j;
    scanf("%d", &n);
    for ( i = 0; i <n; i++){
        for ( j = 0; j<n; j++){
                   M[i][j] = 0;
        }
    }
        for ( i = 0; i < n; i++){
            scanf("%d %d", &u, &k);
            u--;
            for(j=0;j < k; j++){
            scanf("%d", &v);
                v--;
                M[u][v] = 1;
            }
        }
        dfs();
        return 0;
    }


Measured memory_bytes: 2104
N,M=map(int,input().split())
results = [False]*N
penalties = [0]*N
for _ in range(M):
    p,S=input().split()
    p = int(p)
    if S == 'AC':
        results[p-1] = True
    else:
        if not results[p-1]:
            penalties[p-1] += 1

points1 = 0
points2 = 0

for i in range(N):
    if results[i]:
        points1 += 1
        points2 += penalties[i]

print('{} {}'.format(points1,points2))


Measured memory_bytes: 71444
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 1000000000000000007mope
#define ll long long
using namespace std;
signed main(){
	map<int,int> mope;
	int n,m;
	cin>>n>>m;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x; cin>>x; a.pb(x);
	}
	mope[0]++;
	int ans = 0;
	int cur = 0;
	for(int i=0;i<n;i++){
		cur = ( cur + a[i] ) % m;
		ans += mope[cur];
		mope[cur]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4980
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define break break
#define continue continue
#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	int h, a; cin >> h >> a;
	ans = h/a;
	if(h%a != 0) ans++;

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

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

int gcd(int x, int y);

int main(){
  int N;
  cin >> N;
  vector<int> Ai(N);
  for (int i=0;i<N;i++){
    cin >> Ai[i];
  }

  int res;
  for (int i=0;i<N-1;i++){
    if  (i==0) {
      res = gcd(Ai[i],Ai[i+1]);
    } else {
      res = gcd(res, Ai[i+1]);
    }
  }
  cout << res << endl;
}

int gcd(int x, int y){
  if (x < y) {
    int tmp = x;
    x = y;
    y = tmp;
  }
  if (y==0){
    return x;
  }

  return gcd(y, x%y);
}

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

int main()
{
  int A[3][3];
  for (int i = 0; i < 3; i++) {
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  } 
  int N;
  cin >> N;
  int b;
  int B[3][3];
  for (int i = 0; i < N; i++) {
    cin >> b;
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        if (b == A[j][k]) {
          B[j][k] = 1;
        }
      }
    }
  }
  //縦のループ
  for (int i = 0; i < 3; i++) {
    if (B[i][0] * B[i][1] * B[i][2] == 1) {
      cout << "Yes";
      return 0;
    }
  }
  //横のループ
  for (int i = 0; i < 3; i++) {
    if (B[0][i] * B[1][i] * B[2][i] == 1) {
      cout << "Yes";
      return 0;
    }
  }
  //斜め
  if (B[0][0] * B[1][1] * B[2][2] == 1) {
    cout << "Yes";
    return 0;
  }
  if (B[2][0] * B[1][1] * B[0][2] == 1) {
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;

  }

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

using namespace std;


int main() {
    
    int h, w;
    
    while (cin >> h >> w)
    {
        if (h == 0 && w == 0)
            break;

        for (int y = 0; y < h; ++y)
        {
            for (int x = 0; x < w; ++x)
            {
                if ((x + y) % 2 == 0)
                    cout << '#';
                else
                    cout << '.';
            }
            cout << endl;
        }

        cout << endl;
    }

    return 0;
} 

Measured memory_bytes: 3104
"use strict";
function Main(input) {
    let T = input.split("\n").map((v) => v - 0);
    let N = T[0];
    let min = Math.min(...T.slice(1, 6));
    let t = Math.ceil(N / min) + 4;
    console.log(t);
}
if (typeof window === 'undefined') Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(void){
    long long int n;
    std::cin >> n;
    std::vector<long long int> yn(n);
    for(int i = 1; i <= n; i++){
	for(int j = i; j <=n; j = j + i){
	    yn[j]++;
	}
    }

    long long int sum = 0;
    for(int i = 1; i <= n; i++){
	sum += i * yn[i];
    }

    std::cout << sum << std::endl;


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int last = A.at(0);
  long long sum = 0;
  for (int i = 0; i < A.size(); i++) {
    // cout << A.at(i) << endl;
    if (last > A.at(i)) {
      sum += (last - A.at(i));
    } else {
      last = A.at(i);
    }
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;
 
string str[101];
int H, W, cnt;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
char ch;
 
void dfs(int x, int y)
{
    if (x < 0 || x >= H || y < 0 || y >= W|| ch != str[x][y]) return;
    str[x][y] = '0';
    for (int i = 0; i < 4; i++) {
	int nx = x + dx[i];
	int ny = y + dy[i];
	dfs(nx, ny);
    }  
}
 
int main()
{
    while (cin >> H >> W, H + W) {
	for (int i = 0; i < H; i++) { 
	    cin >> str[i];
	}
	cnt = 0;
	for (int i = 0; i < H; i++) {
	    for (int j = 0; j < W; j++) {
		if (str[i][j] != '0') {
		    ch = str[i][j];
		    dfs(i, j);
		    cnt++;
		}
	    }
	}
	cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] V = new int[N];
		int[] C = new int[N];
		int ans = 0;
		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			int dif = V[i] - C[i];
			if (dif > 0) {
				ans += dif;
			}
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<ll>v;
    for(int i=1; ;i++){
        ll x=i*i;
        if(x>1000000000LL)break;
        v.push_back(x);
    }
    ll x;
    cin>>x;
    int id=lower_bound(v.begin(),v.end(),x)-v.begin();
    vector<ll>::iterator it;
    it=find(v.begin(),v.end(),x);
    if(it!=v.end())cout<<v[id]<<endl;
    else cout<<v[id-1]<<endl;
}


Measured memory_bytes: 3748
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        //累積GCD
        long[] left = new long[n];
        var fisrtflag = true;
        for (int i = 0; i < a.Length; i++)
        {
            if (fisrtflag)
            {
                left[i] = Gcd(a[i], a[i]);
                fisrtflag = false;
            }
            else
            {
                left[i] = Gcd(left[i - 1], a[i]);
            }
        }

        long[] right = new long[n];
        fisrtflag = true;
        for (int i = 0; i < a.Length; i++)
        {
            if (fisrtflag)
            {
                right[i] = Gcd(a[a.Length - 1], a[a.Length - 1]);
                fisrtflag = false;
            }
            else 
            { 
            right[i] = Gcd(right[i - 1], a[a.Length - 1 - i]);
            }
        }

        long ans = 0;
        long tmp = 0;
        //n-1の最大公約数を求める
        for (int i = 0; i < a.Length; i++)
        {
            if (i == 0)
            {
                ans = Math.Max(ans, right[a.Length - 1 - i - 1]);
            }
            else if (i == a.Length - 1)
            {
                ans = Math.Max(ans, left[i - 1]);
            }
            else
            {
                ans = Math.Max(ans, Gcd(left[i - 1], right[a.Length - 1 - i - 1]));
            }
        }

        // 出力
        Console.WriteLine(ans);
    }

    // ユークリッドの互除法 
    public static long Gcd(long a, long b)
    {
        if (a < b)
        {
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        }
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }
}

Measured memory_bytes: 26076
#include <iostream>

using namespace std;

#define MOD 1000000007
#define N_MAX 200002

using namespace std;

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

ll inv[N_MAX],fac[N_MAX],finv[N_MAX];

void init(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<N_MAX;i++){
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        fac[i]=fac[i-1]*(ll) i%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll inv_(ll n){
    if(n == 1) return 1;
    else return MOD-inv_(MOD%n)*(MOD/n)%MOD;
}

ll comb(ll n, ll r){
  ll ans;
  if(n < r){
      ans = 0;
  }else{
      ans = (fac[n]*finv[r])%MOD;
      ans = (ans*finv[n-r])%MOD;
      ans = (ans+MOD)%MOD;
  }
  return ans;
}

P add(P a, P b){
    P ans;
    ans.first = (a.first*b.second+a.second*b.first)%MOD;
    ans.second = (a.second*b.second)%MOD;
    return ans;
}

P sub(P a, P b){
    P ans;
    ans.first = ((a.first*b.second-a.second*b.first)%MOD+MOD)%MOD;
    ans.second = (a.second*b.second)%MOD;
    return ans;
}

P mul(P a, P b){
    P ans;
    ans.first = (a.first*b.first)%MOD;
    ans.second = (a.second*b.second)%MOD;
    return ans;
}

int main(){
    init();
    long N, A, B, C;
    cin >> N >> A >> B >> C;
    P ans = P(0, 1);
    ll powA[200001];
    ll powB[200001];
    ll powAB[200001];
    powA[0] = 1;
    powB[0] = 1;
    powAB[0] = 1;
    for(int i = 1; i <= 2*N; i++) {
        powA[i] = powA[i-1]*A;
        powA[i] %= MOD;
        powB[i] = powB[i-1]*B;
        powB[i] %= MOD;
        powAB[i] = powAB[i-1]*(A+B);
        powAB[i] %= MOD;
    }
    for(int i = N; i <= 2*N-1; i++){
        ll a = ((((comb(i-1, N-1)*powA[N]))%MOD)*powB[i-N])%MOD;
        ll b = powAB[i];
        a += (((((comb(i-1, N-1)*powB[N]))%MOD)*powA[i-N])%MOD);
        a %= MOD;
        a *= i;
        a %= MOD;
        //cout << a << ' ' << b << endl;
        ans = add(ans, P(a, b));
        //cout << ans.first << ' ' << ans.second << endl;
    }
    //cout << ans.first << ' ' << ans.second << endl;
    ans = mul(ans, P(100, A+B));
    cout << (ans.first*inv_(ans.second))%MOD << endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

//iはx_i番目に置かなくてはならない
//それより左にiが(i-1)個ほしい
//それより右にはiは(N-i)個ある
//これが任意のiに対して成立すれば、
//数列は作成可能

vector<int> ans(300000, -1);
int main()
{
  int N;
  cin >> N;
  vector<pair<int, int>> x; // (xi, i)

  for (int i = 1; i <= N; i++) {
    int xi;
    cin >> xi;
    x.push_back(make_pair(xi, i));
  }
  sort(x.begin(), x.end());

  for (int i = 0; i < x.size();i++) {
    int num = x[i].second;
    int pos = x[i].first;
    ans[pos] = num;

    int cnt = 0;
    for (int j = 1; j < pos; j++) {
      if (cnt == num - 1) break;
      if (ans[j] == -1) {
        ans[j] = num;
        cnt++;
      }
    }
    if (cnt < num - 1) {
      cout << "No" << endl;
      return 0;
    }
  }
  /*for (int i = 1; i <= N*N; i++) {
    if (ans[i] != -1) cout << ans[i] << ' ';
    else cout << "x ";
  }
  cout << endl;*/

  for (int i = 0; i < x.size(); i++) {
    int num = x[i].second;
    int pos = x[i].first;
    
    int cnt = 0;
    for (int j = pos + 1; j <= N*N; j++) {
      if (cnt == N - num) break;
      if (ans[j] == -1) {
        ans[j] = num;
        cnt++;
      }
    }
    if (cnt < N - num) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  for (int i = 1; i <= N*N; i++) {
    if (ans[i] != -1) cout << ans[i] << ' ';
    else cout << "  ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 2304
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int L = in.nextInt();
    int min = Integer.MAX_VALUE;
    int sum = 0;
    for (int i = 0; i < N; i++) {
      sum += L + i;
      if (Math.abs(L + i) < Math.abs(min)) {
        min = L + i;
      }
    }
    System.out.println(sum - min);
  }
}


Measured memory_bytes: 21716
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
print(N == 1 ? "Hello World" : readInt()!+readInt()!)


Measured memory_bytes: 1024
while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  H = range(h)
  C = [0]*(h+1)
  M = C[:]
  a=[0]*w
  for i in H:
    x = map(int,list(raw_input().replace("*","0").replace(".","1")))
    b=[0]*w
    sp=-1
    C = [-1]*(h+1)
    for j in range(w):
      if x[j]==0:
        c=0
      elif x[j]==1:
        c=a[j]+1
      b[j]=c
      if c>sp:
        C[sp+1:c+1]=[j]*(c-sp)
      elif c<sp:
        for k in range(c+1,sp+1):
          M[k]=max(M[k],j-C[k])
          C[k]=-1
      sp=c
    for k in range(1,sp+1):
      if C[k]>=0:
        M[k]=max(M[k],w-C[k])
    a=b[:]
  s=0
  for i in range(h+1):
    s=max(s,M[i]*i)
  print s

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

using namespace std;

#define MAX 26

bool data[MAX][MAX];
bool used[MAX];
vector<char> ans;
set<int> st;

bool cyc(int now, int cnt){
  if(cnt == 1){
    return true;
  }
  set<int>::iterator it;
  for(it = st.begin() ; it != st.end() ; ++it){
    int next = (*it) - 'a';
    ans.push_back((char)(*it));
    if(data[now][next] && cyc(next, cnt-1)){
      return true;
    }
    ans.pop_back();
  }
  return false;
}

int main(){
  int n;
  string str;

  cin >> n;
  while(n--){
    memset(data,false,sizeof(data));
    st.clear();

    cin >> str;
    string tmp;
    for(int i = 0 ; i < str.size() ; i++){
      if(str[i] == '-') continue;
      tmp += str[i];
    }
    str = tmp;
    st.insert(str[0]);
    for(int i = 2 ; i < str.size() ; i += 2){
      if(str[i-1] == '<'){
        data[str[i]-'a'][str[i-2]-'a'] = true;
      }else{
        data[str[i-2]-'a'][str[i]-'a'] = true;
      }
      if(!st.count(str[i])){
        st.insert(str[i]);
      }
    }

    int size = st.size();
    set<int>::iterator it;
    for(it = st.begin() ; it != st.end() ; ++it){
      ans.clear();
      memset(used,false,sizeof(used));
      ans.push_back((char)(*it));
   
      if(cyc((*it)-'a', size)){
        break;
      }
    }

    for(int i = 0 ; i < ans.size() ; i++){
      cout << ans[i];
    }
    cout << endl;
  }

  return 0;
}

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

void solve(int n)
{
    long long count=0L;
    for(int i=1;i<=n;i++){
        if(i%3==0||i%5==0){

        }else
        {
            count=count+i;
        }
    }
    cout<<count;
}

int main()
{
    int cc;
    cin>>cc;
    solve(cc);
    return 0;

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fst first
#define snd second
#define rep(n) for(lint I = 0; (I) < (lint)(n); ++(I))
#define repeat(i, n) for(lint i = 0; (i) < (lint)(n); ++(i))
#define repeat_to(i, n) for(lint i = 0; (i) <= (lint)(n); ++(i))
#define repeat_from(i, m, n) for(lint i = (m); (i) < (lint)(n); ++(i))
#define repeat_from_to(i, m, n) for(lint i = (m); (i) <= (lint)(n); ++(i))
#define repeat_reverse_from_to(i, m, n) for(lint i = (m); (i) >= (lint)(n); --(i))
#define el cout<<endl
#define dump(x) cout<<" "<<#x<<"="<<x
#define pdump(p) cout<<" "<<#p<<"=("<<p.fst<<","<<p.snd<<")"
#define vdump(v) for(size_t I=0; I<v.size(); ++I){cout<<" "<<#v<<"["<<I<<"]="<<v[I];} cout<<endl
using namespace std; using lint = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<lint, lint>;

int main(void) {
    lint a, b;
    cin >> a >> b;
    lint n = 0;
    if (a % 4 == 0) {} //relax
    else {
        lint s = (a/4)*4;
        repeat_from_to (i, s, a-1) {
            //dump(i);
            n ^= i;
        }
    }
    if (b % 4 == 3) {} //relax
    else {
        lint e = (b/4)*4 + 3;
        repeat_from_to (i, b+1, e) {
            //dump(i);
            n ^= i;
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 4) << " " << s.substr(4) <<endl;
}


Measured memory_bytes: 256