akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

struct Edge {
    ll to, cost;
};

vector < Edge > tree[100005];

int main()
{
    int N;
    int Q, K;
    queue < int > que;
    ll min_cost[100005];

    memset(min_cost, -1, sizeof(min_cost));
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        ll A, B, C;
        cin >> A >> B >> C; --A, --B;
        tree[A].push_back( (Edge) { B, C } );
        tree[B].push_back( (Edge) { A, C } );
    }
    
    cin >> Q >> K; --K;
    
    que.push(K);
    min_cost[K] = 0;
    
    while(!que.empty()) {
        int node = que.front(); que.pop();
        for(int i = 0; i < tree[node].size(); i++) {
            ll u = tree[node][i].to, w = min_cost[node] + tree[node][i].cost;
            if(min_cost[u] == -1) {
                min_cost[u] = w;
                que.push(u);
            }
        }
    }


    for(int i = 0; i < Q; i++) {
        int A, B;
        cin >> A >> B; --A, --B;
        cout << min_cost[A] + min_cost[B] << endl;
    }

    return (0);
}


Measured memory_bytes: 11120
from collections import deque
N = int(input())
A = deque(sorted(list(map(int, input().split()))))
MAX, MIN = A.pop(), A.popleft()

ans = []
while len(A):
    if A[0] < 0:
        x, y = MAX, A.popleft()
        ans.append([MAX, y])
        MAX = MAX - y
    else:
        x, y = MIN, A.popleft()
        ans.append([x, y])
        MIN = MIN - y

ans.append([MAX, MIN])
print(MAX - MIN)
for x, y in ans:
    print(x, y)


Measured memory_bytes: 25200
int N,A[2<<17];
void sort_impl(int l,int r)
{
	if(r-l<=1);
	else if(r-l==2)
	{
		if(A[l+1]<A[l])
		{
			int tmp=A[l];
			A[l]=A[l+1];
			A[l+1]=tmp;
		}
	}
	else
	{
		int a=A[l];
		int b=A[(l+r)/2];
		int c=A[r-1];
		if((b<a)!=(b<c))
		{
			A[l]=b;
			A[(l+r)/2]=a;
		}
		else if((c<a)!=(c<b))
		{
			A[l]=c;
			A[r-1]=a;
		}
		int mid=l;
		int L=l,R=r-1;
		do{
			while(A[L]<A[mid])L++;
			while(A[mid]<A[R])R--;
			if(L<R)
			{
				int tmp=A[L];A[L]=A[R];A[R]=tmp;
				if(mid==L)mid=R;
				else if(mid==R)mid=L;
				L++;
				R--;
			}
			else if(L==R)L++,R--;
		}while(L<=R);
		sort_impl(l,R+1);
		sort_impl(L,r);
	}
}
void sort(int N)
{
	sort_impl(0,N);
}
main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d",&A[i]),A[i]-=i;
	sort(N);
	long ans=0,mid=A[N/2];
	for(int i=0;i<N;i++)ans+=A[i]<mid?mid-A[i]:A[i]-mid;
	printf("%lld\n",ans);
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
 
#define ll long long
 
using namespace std;
 
 
int main(){
    double n;
    cin >> n;
    for(int i = -300; i < 300; i++) {
        for (int j = -300; j < 300; j++) {
            double con = pow(i, 5) - pow(j, 5);
            if(con == n){
                cout << i << " " << j;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4188
#include <stdio.h>

int main(int argc, char **argv)
{
	unsigned int a, b;
	char inputs[1000];
	
	
	fgets( inputs, sizeof(inputs), stdin );
	sscanf( inputs , "%d %d", &a, &b );
	
	printf("%d %d\n", a*b, 2*a + 2*b);
	
	
	return 0;
}

Measured memory_bytes: 1816
import java.util.Scanner;

class Main{
 public static void main(String args[]){
   Scanner sc = new Scanner(System.in);
   int[][] a=new int[3][3];
   for(int i=0;i<3;i++) {
	   for(int j=0;j<3;j++) {
		   a[i][j]=sc.nextInt();
	   }
   }
   int n=sc.nextInt();
   int[] g=new int[n];
   
   for(int i=0;i<n;i++) {
	   g[i]=sc.nextInt();
	   for(int x=0;x<3;x++){
	        for(int y=0;y<3;y++){
	          if(g[i]==a[x][y]){
	            a[x][y]=0;
	          }
	        }
	   }
   }
   if((a[0][0]==a[0][1]&&a[0][1]==a[0][2])||(a[1][0]==a[1][1]&&a[1][1]==a[1][2])||(a[2][0]==a[2][1]&&a[2][1]==a[2][2])||(a[0][0]==a[1][0]&&a[1][0]==a[2][0])||(a[0][1]==a[1][1]&&a[2][1]==a[1][1])||(a[0][2]==a[1][2]&&a[1][2]==a[2][2])||(a[0][0]==a[1][1]&&a[1][1]==a[2][2])||(a[0][2]==a[1][1]&&a[1][1]==a[2][0])){
	      System.out.print("Yes");
   }
   else{
	      System.out.print("No");
   }
 }
}

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

vector<vector<int>> start;
vector<vector<int>> goal;
int mem[100001];

int lp(int in){
    if(mem[in]>=0) return mem[in];
    if(goal[in].size()==0){
        mem[in]=0;
        return 0;
    }
    else{
        int max=-1;
        for(int i=0;i<goal[in].size();i++){
            int from=goal[in][i];
            if(max<lp(from))max=lp(from);
        }
        mem[in]=max+1;
        return max+1;
    }
}

int main(void) {

    int N, M;
    cin >> N >> M;
    start = vector<vector<int>>(N + 1);
    goal = vector<vector<int>>(N + 1);
    for(int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        start[x].push_back(y);
        goal[y].push_back(x);
    }

    for(int i=1;i<=N;i++){
        mem[i]=-1;
    }
    
    int answer=-1;
    for(int i=1;i<=N;i++){
        if(start[i].size()==0){
            if(answer<lp(i))answer=lp(i);
        }
    }
    
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 16256
#入力
n, m = map(int, input().split())
H = list(map(int, input().split()))

A = [];
B = [];

for i in range(m):
  a, b = map(int, input().split())
  A.append(a)
  B.append(b)
  
list_ans = [1] * n;

for i in range(m):
  #左の山の方が右の山より小さい時
  if H[A[i] - 1] < H[B[i] - 1]:
    list_ans[A[i] - 1] = 0;
	
  #右の山の方が小さい時
  elif H[A[i] - 1] > H[B[i] - 1]:
    list_ans[B[i] - 1] = 0;
  
  #両方同じ時
  else:  
    list_ans[A[i] - 1] = 0;
    list_ans[B[i] - 1] = 0;
  
print(sum(list_ans))

Measured memory_bytes: 22248
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <tuple>
#include <stdlib.h>
using namespace std;
#define PI 3.14159265358979
typedef long long int ll;

int main()
{
	int a, b, c;
	string s, t;
	cin >> s;
	if (s == "SAT")a = 1;
	if (s == "FRI")a = 2;
	if (s == "THU")a = 3;
	if (s == "WED")a = 4;
	if (s == "TUE")a = 5;
	if (s == "MON")a = 6;
	if (s == "SUN")a = 7;
	cout << a;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static int N;
        static List<Evidence> evidences;

        static void Main(string[] args)
        {
            //[summary]C - HonestOrUnkind2
            N = int.Parse(Console.ReadLine());

            //全員の証言を先に取得しておく
            GetEvidences();

            Console.WriteLine(CountHonests());
        }

        static int CountHonests()
        {
            //bit全探索による実装
            int count = (int)Math.Pow(2, N);
            var binaries = Get2SystemNumbers(count).Reverse();
            
            //正直者の人数が多い順に、仮定が成立するか試していく
            foreach(var binary in binaries)
            {
                //char型の配列をint型に変換
                var men = binary.ToCharArray()
                                .Select(x => int.Parse(x.ToString())).ToArray();
                
                if (IsRightAssumption(men))
                {
                    return men.Sum();
                }
            }
            
            return 0;
        }

        static bool IsRightAssumption(int[] men)
        {
            foreach(var e in evidences)
            {
                //正直者と仮定した人の証言が、"men"の状態と一致しているかチェック
                if (men[e.Speaker] == 1)
                {
                    if (men[e.X] != e.Y)
                    {
                        return false;
                    }
                }
            }

            return true;
        }
        
        static IEnumerable<string> Get2SystemNumbers(int count, int n = 2)
        {
            //[summary]引数で受け取った個数分、N進数の文字列を作成する
            //(2,8,16進法のみ指定可能)
 
            //最大値のケタ数を取得
            string s = Convert.ToString(count - 1, n);
            int digit = s.Length;
 
            //取得するN進法の数は、"0"から"count-1"まで
            for (int i = 0; i < count; i++)
            {
                s = Convert.ToString(i, n);
                yield return s.PadLeft(digit, '0');
            }
        }

        static void GetEvidences()
        {
            evidences = new List<Evidence>();

            //人数分繰り返し
            for (int i = 0; i < N; i++)
            {
                int A = int.Parse(Console.ReadLine());

                //その人の行った証言の回数分繰り返し
                for (int j = 0; j < A; j++)
                {
                    var line = ReadLine();
                    int x = line[0] - 1;
                    int y = line[1];

                    evidences.Add(new Evidence(i, x, y));
                }
            }
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }

    struct Evidence
    {
        public int Speaker { set; get; }
        public int X { set; get; }
        public int Y { set; get; }

        public Evidence(int speaker, int x, int y)
        {
            Speaker = speaker;
            X = x;
            Y = y;
        }
    }
}

Measured memory_bytes: 19792
n = int(raw_input())
w = map(int,raw_input().split())
s = sum(w)
tbest = 0
difbest = s
temp = 0
for i in xrange(n):
	temp += w[i]
	d = abs(s-2*temp)
	if d < difbest:
		difbest = d
		tbest = i
print difbest

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

string fill(string s) {
  while (s.size() < 6) s = "0" + s;
  return s;
}

string create_id(int p, int o) {
  return fill(to_string(p)) + fill(to_string(o));
}

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

  int n, m; cin >> n >> m;
  vector<tuple<int, int, int>> db(m);
  for (int i = 0; i < m; i++) {
    int p, y; cin >> p >> y;
    db[i] = tuple<int, int, int>(p, y, i);
  }
  sort(db.begin(), db.end());
  vector<string> res(m);
  int prev = 0, j;
  for (auto &t : db) {
    int p = get<0>(t);
    int i = get<2>(t);
    (p == prev) ? j++ : j = 1;
    res[i] = create_id(p, j); 
    prev = p;
  }
  for (string &id : res) {
    cout << id << '\n';
  }
  return 0;
}

Measured memory_bytes: 8192
fun main(args: Array<String>) {
    abc62d()
}

fun abc62d() {
    val isPList = readLine()!!.map { it == 'p' }

    // 相手がパーを出す回数
    val ps = isPList.count { it }

    // シカくんがパーを出せる最大回数
    val deer = isPList.size / 2

    val answer = deer - ps

    println(answer)
}


Measured memory_bytes: 33792
#include <iostream>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  char c;
  bool h = true;
  while (cin >> c)
  {
    if (h && c == 'h')
    {
      h = false;
    }
    else if (!h && c == 'i')
    {
      h = true;
    }
    else
    {
	  h = false;
      break;
    }
  }
  if (!h)
  {
 	 cout << "No" << "\n";
  }
  else
  {
  	cout << "Yes" << "\n";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<int> A(N);
    ll out = 1;
    ll cnt = 1;
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]%2==0){
            cnt *= 2;          
        }
        out *=3;
    }
    
    cout << out-cnt << endl;
    return 0;
}


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

    int A = N % 100;
    int B = N / 100;

    if(A==0 || A>=13){
        if(B==0 || B>=13){
            cout << "NA" << endl;
        }
        else{
            cout << "MMYY" << endl;
        }
    }
    else{
        if(B==0 || B>=13){
            cout << "YYMM" << endl;
        }
        else{
            cout << "AMBIGUOUS" << endl;
        }
    }
}

Measured memory_bytes: 256
S = input()
S = sorted(S)

A = S.count("a")
B = S.count("b")
C = S.count("c")

member = [A, B, C]

if S == "ab" or S == "ac" or S == "bc":
    print("YES")
elif max(member) - min(member) <= 1:
    print("YES")
else:
    print("NO")

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

#define pb push_back
#define all(a) begin(a), end(a)
#define deb(x) cout << #x << " = " << x << endl
#define debu(x, y) cout << "( " << #x << ", " << #y << " ) = ( " << x << ", " << y << " )" << endl

typedef long long ll;
ll mod=1000000007;

template <typename T> vector<T> readVector(int n) { vector<T> res(n); for (int i = 0 ; i < n ; i++) cin >> res[i]; return res; }

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    if(x == 0) {
        cout << 1 << endl;
    } else cout << 0 << endl;
    return 0;
}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;

  map<int,int> odd,even;
  odd[0] = 0;
  even[0] = 0;

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    if(i %2 == 0){
      if(odd.count(tmp) == 0){
        odd[tmp] = 1;
      } else {
        odd[tmp] += 1;
      }
    } else { 
      if(even.count(tmp) == 0){
        even[tmp] = 1;
      } else {
        even[tmp] += 1;
      }
    }
  }
  // odd と evenの頻度1位と2位を取り出す
  vector<pair<int,int>> v_odd;
  for(auto x: odd){
    v_odd.push_back(make_pair(x.second, x.first));
  }

  sort(v_odd.rbegin(), v_odd.rend());

  vector<pair<int,int>> v_even;
  for(auto x: even){
    v_even.push_back(make_pair(x.second, x.first));
  }
  sort(v_even.rbegin(), v_even.rend());
//  cerr << v_odd[0].first << " " << v_odd[0].second << endl;
//  cerr << v_odd[1].first << " " << v_odd[1].second << endl;
//  cerr << v_even[0].first << " " << v_even[0].second << endl;
//  cerr << v_even[1].first << " " << v_even[1].second << endl;

  int ans = 0;
  if(v_odd[0].second != v_even[0].second){
    ans += (N/2) - v_odd[0].first;
    ans += (N/2) - v_even[0].first;
  } else {
    int tmpans1 = 0;
    int tmpans2 = 0;
    tmpans1 += (N/2) - v_odd[1].first;
    tmpans1 += (N/2) - v_even[0].first;
    tmpans2 += (N/2) - v_odd[0].first;
    tmpans2 += (N/2) - v_even[1].first;

    ans = min(tmpans1, tmpans2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6136
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }








const ll maxn=2e5+2;


int main()
{ fastio;
//freopen("test_input (1).txt", "r", stdin); 
//freopen("output.txt", "w", stdout);
ll n;cin>>n;
string s;cin>>s;
ll w=0;
forl(i,0,n){
    if(s[i]=='W')w++;
}
ll r=w;
forl(i,0,r){
    if(s[n-i-1]=='W')w--;
}
cout<<w;




return 0;
}




  










Measured memory_bytes: 3760
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int W,H;
	cin>>H>>W;
	vector<string>S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
		for(int j=0;j<2;j++)
		{
			cout<<S[i]<<endl;
		}
	}
}

Measured memory_bytes: 256
import sys

def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return abs(a)

def lcm(a, b):
    return abs(a * b) // gcd(a, b)

a, b = map(int, sys.stdin.readline().split())

def main():
    ans = lcm(a, b)
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<int>v(13, 0);
vector<int>ans, hoge;

int main() {
	int n;
	cin >> n;
	v[0]++;
	REP(i, 0, n) {
		int tmp;
		cin >> tmp;
		v[tmp]++;
	}
	REP(i, 1, 12) {
		if (v[i] > 2) {
			cout << 0 << endl; return 0;
		}
	}
	if (v[0] >= 2) {
		cout << 0 << endl; return 0;
	}
	if (v[12] >= 2) {
		cout << 0 << endl; return 0;
	}
	REP(i, 1, 12) {
		if (v[i] == 2) {
			if (v[i - 1] == 1 || v[i + 1] == 1) {
				cout << 1 << endl; return 0;
			}
		}
	}
	if (v[1] == 1) {
		cout << 1 << endl; return 0;
	}
	if (v[12] == 1) {
		if (v[11] == 1) {
			cout << 1 << endl; return 0;
		}	
	}
	REP(i, 0, 13) {
		REP(j, 0, v[i]) {
			hoge.push_back(i);
		}
	}
	REP(i, 0, hoge.size()) {
		if (i % 2 == 1) {
			ans.push_back(24 - hoge[i]);
		}
		else {
			ans.push_back(hoge[i]);
		}
	}
	sort(all(ans));
	int diff = hoge[1];
	REP(i, 1, ans.size()) {
		diff = min(diff, ans[i] - ans[i - 1]);
	}
	cout << diff << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

S=input().strip()
T=input().strip()

max = 0
for i in range(len(S)-len(T)+1):
    hit = 0
    for j in range(len(T)):
        if T[j] == S[j+i]:
            hit += 1
    if hit > max:
        max = hit

print(len(T)-max)


Measured memory_bytes: 67552
#include <iostream>
int main(void){
	int N, mi = 10000, ma = 0;
	std::cin >> N;
	for(int i = 0; i < N; i++){
		int a;
		 std::cin >> a;
		mi = std::min(mi, a);
		ma = std::max(ma, a);
	}
	std::cout << ma - mi << std::endl;
}


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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

ll n,d,ans;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>d;
    d*=2;
    d++;
    ans = n/d;
    if(n%d != 0)ans++;
    cout<<ans<<newl;

}


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


const int INF = 1e9+7;

int main(){
    long long n,k;
    cin>>n>>k;
    
    long long arr[n],dp[n];
    
    memset(dp,INF,sizeof(dp));
    
    for(int i=0;i<n;i++)
        cin>>arr[i];
    
    dp[0]=0;
    
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(arr[j]-arr[i]));
            }
        }
    }
    cout<<dp[n-1]<<endl;

}


Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define ll long long

using namespace std;


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a;
    cin>>a;
    vector<int>vec(a);
    for(int i=0;i<a;i++){
        cin>>vec[i];
        vec[i]-=(i+1);
    }
    sort(vec.begin(),vec.end());
    int s=vec[a/2];
    ll sum=0;
    for(auto it:vec)
        sum+=abs(it-s);
    cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	char a[10];
	scanf("%[^\n]",a);
	if(a[0] == 'S'){
		printf("Cloudy\n");
	}
	else if(a[0]=='C'){
		printf("Rainy\n");
	}
	else{
		printf("Sunny\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int n;
int S[12];
int C[12];
int cnt;	//操作回数
bool first_flag;
map<int, int> hindo;



//numは数列の長さ
void operation(int num)
{
	hindo.clear();
	
	for (int i=0; i<num; i++)
	{
		if (hindo.find(S[i]) == hindo.end())
		{
			//初めての数だった場合
			hindo[S[i]] = 1;
		} else {
			hindo[S[i]]++;
		}
	}
	
	for (int i=0; i<num; i++)
	{
		C[i] = hindo[S[i]];
	}
}



//numは数列の長さ
bool check_same_array(int num)
{
	bool flag = true;
	
	for (int i=0; i<num; i++)
	{
		if (S[i] != C[i])
		{
			flag = false;
			break;
		}
	}
	
	return flag;
}



void replace_array(int num)
{
	for (int i=0; i<num; i++)
	{
		S[i] = C[i];
	}
}



int main()
{
	while (cin >> n)
	{
		if (n == 0) break;
		
		for (int i=0; i<n; i++)
		{
			cin >> S[i];
		}
		
		cnt = 0;
		while (1)
		{
			operation(n);
			cnt++;
			if (check_same_array(n))
			{
				//数列が同じだった場合
				cout << cnt - 1 << endl;
				first_flag = true;
				for (int i=0; i<n; i++)
				{
					if (first_flag)
					{
						cout << C[i];
						first_flag = false;
					} else {
						cout << " " << C[i];
					}
				}
				cout << endl;
				break;
			} else {
				replace_array(n);
			}
		}
		
		/*
		for (int i=0; i<n; i++)
		{
			cout << C[i] << " ";
		}
		*/
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
// rep(i,1,10) is from 1 to 9 and rep(I,10,1) is from 9 to 1
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define mi multiset<int>
#define mii multiset<pii>
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int modp(int a,int n)
{
    if(n==0) return 1;
    if(n==1) return a;
    int res=modp(a,n/2);
    if(n%2==0) return (res*res);
    else return (a*res*res);
}

vi adj[1000005],ans;
vector<bool> vis(1000005,false);
map<pii,int> problem,elected;
int check=0;

bool dfs(int s)
{
    bool y=0;
    vis[s]=true;
    for(int u:adj[s])
    {
        if(!vis[u])
        {
            vis[u]=true;
            if(problem[{u,s}]||problem[{s,u}])
            {
                y=1;
                if(!dfs(u))
                {
                    ans.pb(u);
                }
            }
            else
            {
                if(dfs(u))
                {
                    y=1;
                }
            }
        }
    }
    return y;
}

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    // int f,g,d;
    cin>>n>>k;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    vi dp(n);
  rep(i,0,n) dp[i]=INT_MAX;
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    // rep(i,2,n)
    // {
    //     dp[i]=min(dp[i-2]+abs(a[i-2]-a[i]),dp[i-1]+abs(a[i]-a[i-1]));
    // }
    rep(i,2,n)
    {
        rep(j,1,k+1)
        {
            if(i-j>=0)
            {
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
    }
    cout<<dp[n-1];
}


signed main()
{
//    #ifndef ONLINE_JUDGE 
  //     freopen("input.txt","r",stdin);
    //   freopen("output.txt","w",stdout);
    //#endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 25344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // B - Echo

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        
        String s = sc.next();

        String s1 = s.substring(0, n / 2);
        String s2 = s.substring(n / 2, n);
        
        String ans = (n % 2 == 0 && s1.equals(s2) ? "Yes" : "No");
        
        System.out.println(ans);
    }

}

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

using namespace std;
#ifdef CLION
ifstream ifs("/home/kyuridenamida/CLionProjects/untitled4/input.txt");
#define cin ifs
#endif

int A[2000];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> A[i];
    sort(A, A + n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < i; j++) {
            for (int k = 0; k < j; k++) {
                if (A[j] + A[k] > A[i]) {
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
   int a,b,i,j;
   while(1){
   scanf("%d%d",&a,&b);
   if(a==0 && b==0)
    break;
   for(i=0;i<a;i++)
   {
       for(j=0;j<b;j++)
       {

        printf("#");
       }
       printf("\n");
   }
   printf("\n");

   }



}



Measured memory_bytes: 2036
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  if (n == 0) {
    cout << "0" << endl;
    return 0;
  }

  while (n) {
    if (n % 2) {
      n--;
      s += '1';
    } else {
      s += '0';
    }
    n /= -2;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * ????????? str ?????\???????????¨?????????????????????????????????????????????????????°????????????????????????????????? ?????????????§???±??°???????????§???20 ????????\?????¨????????????
	 * 
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);

		String inputData = br.readLine();

		for (int i = inputData.length(); i > 0; i--) {
			System.out.print(inputData.charAt(i - 1));
		}
		System.out.println("");

	}

}

Measured memory_bytes: 16860
/*input
*/
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back
 
using ll = long long;
using pii = pair<int, int>;
 
template<typename T> using V = vector<T>;

const int N = 5e5 + 10;
bool visit[N];
int indeg[N], pathlen[N];
int adj[N];

// z[i] stores the value of the longest common prefix between s 
// and the suffix of s starting at i
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}

bool find_match(vector<int> &z, int tlen, int pos) {
	return z[pos + tlen + 1] == tlen;
}

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	// Find maximum value of i such that i copies of T appears as a substring in infinite copies
	// of string S.
	string s, t; cin >> s >> t;
	int slen = s.length(), tlen = t.length();
	string st = s;
	while (st.length() < slen + tlen) {
		st += s;
	}
	string nw = t + "?" + st;
	vector<int> z = z_function(nw);
	for (int i = 0; i < slen; ++i) {
		bool good = find_match(z, tlen, i);
		adj[i] = -1;
		visit[i] = false;
		if (good) {
			int j = (i + tlen) % slen;
			adj[i] = j;
			++indeg[j];
		}
	}
	queue<int> Q;
	for (int i = 0; i < slen; ++i) {
		if(!indeg[i]) {
			Q.push(i);
			visit[i] = true;
		}
	}
	while(!Q.empty()) {
		int u = Q.front(); Q.pop();
		if(adj[u] == -1)
			continue;
		int v = adj[u];
		pathlen[v] = max(pathlen[v], pathlen[u] + 1);
		visit[v] = true;
		--indeg[v];
		if(indeg[v] == 0)
			Q.push(v);
	}
	int ans = 0;
	for (int i = 0; i < slen; ++i) {
		if(!visit[i]) {
			cout << -1 << '\n'; return 0;
		}
		ans = max(ans, pathlen[i]);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 20856
#include <bits/stdc++.h>
#define N 300005
using namespace std;

int n,ans=N;
char a[N];
int s[N],s2[N];

int work(int x)
{
  return s2[x-1]+s[n]-s[x];
}

signed main()
{
  cin>>n;
  scanf("%s",a+1);
  for(int i=1;i<=n;i++)
    s[i]=s[i-1]+(a[i]=='E'),
    s2[i]=s2[i-1]+(a[i]=='W');
  for(int i=1;i<=n;i++)
    ans=min(ans,work(i));
  cout<<ans;
  return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
int n,m,x,ans=0;
int c[21],a[21][21],sum[21],mini=1200007;
bool check()
{
	for(int i=1;i<=m;i++)
	{
		if(sum[i]<x) return 0;
	}
	return 1;
}
void dfs(int cur)
{
	if(check()==1)
	{
		if(ans<mini) mini=ans;
		return;
	}
	if(cur>n) return;
	for(int i=1;i<=m;i++) sum[i]+=a[cur][i];
	ans+=c[cur];
	dfs(cur+1);
	for(int i=1;i<=m;i++) sum[i]-=a[cur][i];
	ans-=c[cur];
	dfs(cur+1);
	return;
}
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++) cin>>a[i][j];
	}
	dfs(1);
	if(mini==1200007) cout<<-1;
	else cout<<mini;
    return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_N 30
#define MAX_M 20
#define INF (1<<29)
 
int N,M,mini,ansS;
bool edge[MAX_M][MAX_N];
 
class Union_Find{
public:
    int par[MAX_M],rank[MAX_M],size[MAX_M];
    Union_Find(int N){
	for(int i = 0 ; i < N ; i++){
	    par[i] = i;
	    rank[i] = 0;
	    size[i] = 1;
	}
    }
 
    int find(int x){
	if(par[x] == x){
	    return x;
	}
	return par[x] = find(par[x]);
    }
 
    void unite(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y) return;
	if(rank[x] < rank[y]){
	    par[x] = y;
	    size[y] += size[x];
	}else{
	    par[y] = x;
	    size[x] += size[y];
	    if(rank[x] == rank[y]){
		rank[x]++;
	    }
	}
    }
 
    bool same(int x,int y){
	return find(x) == find(y);
    }
 
    int getSize(int x){
	return size[find(x)];
    }
};
 
bool check(int S){
    int idx = 0,arr[MAX_M];
    if(S == 0) return false;
    for(int i = 0 ; i < N ; i++){
	if(S >> i & 1){
	    arr[idx++] = i;
	}
    }
    Union_Find uf(M);
    for(int i = 0 ; i < M ; i++){
	for(int j = i+1 ; j < M ; j++){
	    if(uf.same(i,j)) continue;
	    for(int k = 0 ; k < idx ; k++){
		if(edge[i][arr[k]] && edge[j][arr[k]]){
		    uf.unite(i,j);
		}
	    }
	}
    }
    return (uf.getSize(0) == M);
}
 
void rec(int idx,int S,int num){
    if(num < mini && check(S)){
	mini = num; ansS = S;
	return;
    }
    if(num == 5 || num >= mini) return;
    for(int i = idx ; i < N ; i++){
	if(S >> i & 1) continue;
	rec(i+1,S|(1<<i),num+1);
    }
}
 
int main(){
    int K;
    bool blank = false;
    string lang[MAX_N],in;
    while(cin >> N >> M, N){
	map<string,int> mp;
	memset(edge,false,sizeof(edge));
	if(blank){ cout << endl; }
	blank = true;
	for(int i = 0 ; i < N ; i++){
	    cin >> lang[i];
	    mp[lang[i]] = i;
	}
	for(int i = 0 ; i < M ; i++){
	    cin >> K;
	    for(int j = 0 ; j < K ; j++){
		cin >> in;
		edge[i][mp[in]] = true;
	    }
	}
	mini = INF;
	rec(0,0,0);
	if(mini == INF){
	    cout << "Impossible" << endl;
	}else{
	    cout << __builtin_popcount(ansS) << endl;
	    for(int i = 0 ; i < N ; i++){
		if(ansS >> i & 1){
		    cout << lang[i] << endl;
		}
	    }
	}
    }
    return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    string S;
    cin >> S;
    if(S=="RSS" || S=="SRS" || S=="SSR" || S=="RSR") cout << 1;
    if(S=="RRS" || S== "SRR") cout << 2;
    if(S=="RRR") cout << 3 << endl;
    if(S=="SSS") cout << 0;
    return 0;
}

Measured memory_bytes: 3620
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
    input! {
        n: usize,
        mut l: [i64; n]
    }
    assert!(n <= 100);
    l.sort();l.reverse();
    
    let mut ans = 0i64;

    for i in 0..n-1 {
        for j in i+1..n {
            for k in j+1..n {
                if l[i] >= l[j] + l[k] {
                    break;
                }
                if l[i] != l[j] && l[j] != l[k] {
                    ans += 1;
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2160
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef unsigned long long int uint64;
typedef long long int          int64;
 
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void get_N (int64 *n)
{
  int cnt;
  
  cnt = scanf("%lld", n);

  return;
}

void get_NK (int64 *n, int64 *k)
{
  int cnt;
  
  cnt = scanf("%lld %lld", n, k);

  return;
}

typedef struct _tmp_t {
  int64    a;
  int64    b;
} tmp_t;


int compare_a(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->a > y->a) return 1;
  if (x->a < y->a) return -1;

  return 0;
}

int compare_b(const void *a, const void *b)
{
  tmp_t *x;
  tmp_t *y;

  x = (tmp_t *)a;
  y = (tmp_t *)b;

  if (x->b > y->b) return 1;
  if (x->b < y->b) return -1;

  return 0;
}

void qsort_a (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_a);
}

void qsort_b (tmp_t *array, int size)
{
  qsort(array, size, sizeof(tmp_t), compare_b);
}

char S[4];

int main()
{
  int cnt;
  int N, K;
  int i;
  int result = 0;

  cnt = scanf("%s", S);

  if ((S[0] == 'S') &&
      (S[1] == 'U')) {
    result = 7;
    goto end;
  }
  if ((S[0] == 'M') &&
      (S[1] == 'O')) {
    result = 6;
    goto end;
  }
  if ((S[0] == 'T') &&
      (S[1] == 'U')) {
    result = 5;
    goto end;
  }
  if ((S[0] == 'W') &&
      (S[1] == 'E')) {
    result = 4;
    goto end;
  }
  if ((S[0] == 'T') &&
      (S[1] == 'H')) {
    result = 3;
    goto end;
  }
  if ((S[0] == 'F') &&
      (S[1] == 'R')) {
    result = 2;
    goto end;
  }
  if ((S[0] == 'S') &&
      (S[1] == 'A')) {
    result = 1;
    goto end;
  }

end:
  printf("%d", result);

  return 0;
}



Measured memory_bytes: 128
s = input()

dp = [[0]*(len(s)+1) for _ in [0]*4]
dp[0][0] = 1
mod = 10**9 + 7

for i, (c, n0, n1, n2, n3) in enumerate(zip(s, dp[0], dp[1], dp[2], dp[3]), start=1):
    m = 3 if c=="?" else 1
    dp[0][i] = (n0*m) % mod
    dp[1][i] = (n1*m + n0*(c=="A" or c=="?")) % mod
    dp[2][i] = (n2*m + n1*(c=="B" or c=="?")) % mod
    dp[3][i] = (n3*m + n2*(c=="C" or c=="?")) % mod

print(dp[-1][-1])


Measured memory_bytes: 19056
A,B=list(map(int,input().split()))
S=input()
for i in range(0,A):
    if S[i]!='0'and S[i]!='1'and S[i]!='2'and S[i]!='3'and S[i]!='4'and S[i]!='5'and S[i]!='6'and S[i]!='7'and S[i]!='8'and S[i]!='9':
        print('No')
        exit()
if S[A]!='-':
    print('No')
    exit()
for i in range(A+1,A+B+1):
    if S[i]!='0'and S[i]!='1'and S[i]!='2'and S[i]!='3'and S[i]!='4'and S[i]!='5'and S[i]!='6'and S[i]!='7'and S[i]!='8'and S[i]!='9':
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int ans;
int main(){
	int n;
	cin>>n;
	int a[n-1];
	for(int i=1;i<=n-1;i++)
	cin>>a[i];
	ans+=a[1];
	ans+=a[n-1];
	for(int i=2;i<=n-1;i++){
		ans+=min(a[i],a[i-1]);
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
using namespace std;


int main(int argc, char *args[]) {
	int A;
	int B;
	int C;
	int X;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;
	int counter = 0;
	int sum;
	for (int i = 0; i <= A; i++) {
		for (int j = 0; j <= B; j++) {
			for (int k = 0; k <= C; k++) {
				sum = 500 * i + 100 * j + 50 * k;
				if (sum == X) {
					counter += 1;
				}
			}
		}
	}
	cout << counter << endl;
}


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


# define ll long long 
# define str string 
# define se second 
# define fi first
# define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

using namespace std;

ll b, c, d;
string s;
char ch='0';
int used[111111];

void sum(int a){

}

int main()
{
	set < int > st;
	cin >> s;
	if(s.size() % 2 == 1 ) cout <<"No\n";
	else {
		for (int i = 0; i < s.size(); i+=2){
			if(s[i] == 'h' && s[i+1] == 'i') d++;
			else {
				cout<<"No\n";
				exit (0);
			}
		}
		cout<<"Yes\n";
	}

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Console.ReadLine();
            var y = int.Parse(x);
            var sb = new StringBuilder();
            x.Reverse().ToList().ForEach(t => sb.Append(t));
            if (y == int.Parse(sb.ToString()))
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
            
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX(x,y) ((x)>(y)?(x):(y))
#define MIN(x,y) ((x)<(y)?(x):(y))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef long long int ll;
#define mp(a,b) make_pair(a,b)
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vll vector<vl>
#define pb push_back
#define w(t) int t;cin>>t;while(t--)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
int main(){
    fastio;
    ll x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3624
H,W = map(int,input().split())

if(H == 1 or W == 1):
    print(1)

else:
    if(H%2 == 0):
        i = H//2
    if(H%2 != 0):
        i = H//2 + 1
    
    j = H-i

    if(W%2 == 0):
        sum = i*(W//2) + j*(W//2)

    if(W%2 != 0):
        sum = i*(W//2 + 1) + j*(W//2)
    

    print(sum)


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

int main() {
  int A, B;
  cin >> A >> B;
  int AB = A + B;
  
  if ( (A % 3 == 0 || B % 3 == 0) || ( AB % 3 == 0 ) ){
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<int>> c(10,vector<int>(10));
  vector<vector<int>> a(h,vector<int>(w));
  rep(i,10){
    rep(j,10){
      cin >> c.at(i).at(j);
    }
  }
  rep(i,h){
    rep(j,w){
      cin >> a.at(i).at(j);
      if(a.at(i).at(j) == -1){
        a.at(i).at(j) = 1;
      }
    }
  }
  vector<int> cost(10);
  rep(k,10){
    rep(i,10){
      rep(j,10){
        c.at(i).at(j) = min(c.at(i).at(j),c.at(i).at(k) + c.at(k).at(j));
      }
    }
  }
  long answer = 0;
  int tmp;
  rep(i,h){
    rep(j,w){
      tmp = a.at(i).at(j);
      answer += c.at(tmp).at(1);
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 384
/* ex7_3
   bonbonc    */

#include <stdio.h> 
#include <stdlib.h>

int main(void){
    int row,column,copied_row,flag,i,j,k;
    scanf("%d %d",&row,&column);
    copied_row = row;//行数をコピー
    char **squares;
    
    // 各行の配列へのポインタ分のメモリ領域を確保 
    squares = (char**)calloc(row, sizeof(char*));
    if (squares == NULL){
        exit(1);//エラー処理
    }
    // 各行の要素分のメモリ領域を確保 
    for ( i = 0; i < row; i++){
        squares[i] = (char*)calloc(column, sizeof(char));
        if (squares[i] == NULL){
            exit(1);
        }
    }
    
    for ( i = 0; i < row; i++){
        for ( j = 0; j < column; j++){
            scanf(" %c",&squares[i][j]);//入力を受け取る
        }
    }
    //白のみの行を探索してその行を削除する
    for ( i = 0; i < row; i++){
        flag = 1;
        for ( j = 0; j < column; j++){
            if (squares[i][j] == '#'){
                flag = 0;
            }
        }
        //白のみだった場合
        if (flag==1){
            for (j = i;j < row-1;j++){
                for ( k = 0; k < column; k++){
                    //行を上に平行移動
                    squares[j][k] = squares[j+1][k];
                } 
            }
            row -= 1;
            i -= 1;
        }
        
        
    }
    //白のみの列を探してその列を削除する
    for ( i = 0; i < column; i++){
        flag = 1;
        for ( j = 0; j < row; j++){
            if (squares[j][i] == '#'){
                flag = 0;
            }
            
        }
        //白のみの列だった場合
        if (flag==1){
            for ( j = i; j < column-1; j++){
                for ( k = 0; k < row; k++){
                    squares[k][j] = squares[k][j+1];
                }                
            }
            column -= 1;
            i -= 1;
        }
    }
    
    for ( i = 0; i < row; i++){
        for ( j = 0; j < column; j++){
            printf("%c",squares[i][j]);//答えを出力
        }
        printf("\n"); 
    }

    for ( i = 0; i < copied_row; i++){
        free(squares[i]);//各行メモリ解放
    }
    free(squares);//メモリ解放
    return 0;
}


Measured memory_bytes: 1644
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();

    	int[] T=new int[N];
    	for(int i=0;i<N;i++) {
    		T[i]=sc.nextInt();
    	}

    	int M=sc.nextInt();

    	int[][] P=new int[M][2];
    	for(int i=0;i<M;i++) {
    		P[i][0]=sc.nextInt()-1;
    		P[i][1]=sc.nextInt();
    	}

    	for(int t=0;t<M;t++) {
    		int sum=0;
	    	for(int i=0;i<N;i++) {

	    		if(P[t][0]!=i) {
	    			sum+=T[i];
	    		}else {
	    			sum+=P[t][1];
	    		}
	    	}

	    	System.out.println(sum);
    	}
    }
}



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

const int mod = 1000000007;

map <int, int> all;

int main () {
	int n; scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		all[x] = 1;
	}
	for (int i = 0; i < n; i++) {
		int y; scanf("%d", &y);
		all[y] = -1;
	}
	int cnt = 0;
	long long ans = 1;
	for (map <int, int> :: iterator it = all.begin(); it != all.end(); it++) {
		int x = it->second;
		if (x == 1) {
			if (cnt < 0) ans = ans * abs(cnt) % mod;
			cnt++;
		} else {
			if (cnt > 0) ans = ans * abs(cnt) % mod;
			cnt--;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main(void){
	while(1){
		int n; cin >> n;
		if(!n)  break;

		int a[1001];
		for(int i=0; i<n; i++){
			cin >> a[i];
		}
		
		int ans = 5000000;
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				ans = min(ans, abs(a[i]-a[j]));
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

using pqg = priority_queue<ll,vector<ll>, greater<ll> >; // 1,3,5..
using pql = priority_queue<ll,vector<ll> >; //5, 3, 1...

using pqg_p = priority_queue<P,vector<P>, greater<P> >; // 1,3,5..
using pql_p = priority_queue<P,vector<P> >; //5, 3, 1...

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)


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

  set<string> s;
  set<string> s2;
  set<string> s3;
  int N;
  string _s;
  cin >>N;
  cin >> _s;

  REP(i,N-2) {
    string _s3 = _s.substr(i,1);
    if (s3.count(_s3) != 0) continue;
    s3.insert(_s3);

    REPS(j,i+1,N-1) {
      string _s2 = _s.substr(i,1) + _s.substr(j,1);
      if (s2.count(_s2) != 0) continue;

      s2.insert(_s2);
      REPS(k,j+1,N) {
        s.insert(_s2 + _s.substr(k,1));
      }
    }
  }


  cout << s.size() << endl;

}


Measured memory_bytes: 384