akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		boolean bool = true;
		String b = sc.next();

		if(a.equals("H")) {
			bool = true;
		}else {
			bool = false;
		}

		if(bool) {
			System.out.println(b);
		}else {
			if(b.equals("H"))
				System.out.println("D");
			else
				System.out.println("H");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <climits> 

int main()
{
    long N;
    std::cin >> N;
    std::vector<long> capacity;
    long stage=5;
    for(long i=0; i<stage; i++){
        long temp;
        std::cin >> temp;
        capacity.push_back(temp);
    }
    std::sort(capacity.begin(),capacity.end());
    long initiation_interval=capacity[0];
    long latency = stage-1;
    std::cout << (long)(latency+std::ceil((double)N/(double)initiation_interval)) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<list>
#include<queue>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define MAXN 0x3f3f3f3f3f3f3f3f
#define PI acos(-1.0)
#define E exp(1.0)
using namespace std;

//#define debug

const int N=8;
#define FREE -1
#define NOT_FREE 1

int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
bool e[N][N];


void inin(){
    for(int i=0;i<=N;i++){
        row[i]=col[i]=FREE;
    }
    for(int i=0;i<2*N-1;i++){
        dpos[i]=dneg[i]=FREE;
    }
}

void printboard(){
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(e[i][j]){
                if(row[i]!=j) return;
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cout<<(row[i]==j?"Q":".");
        }cout<<endl;
    }
}

void dfs(int i){
    if(i==N){
        printboard();
        return;
    }
    for(int j=0;j<N;j++){
        if(col[j]!=FREE||dpos[i+j]!=FREE||dneg[i-j+N-1]!=FREE){
            continue;
        }
        row[i]=j;col[j]=NOT_FREE;dpos[i+j]=NOT_FREE;dneg[i-j+N-1]=NOT_FREE;
        dfs(i+1);
        row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}

int main()
{
    #ifdef debug
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif // debug

    ACCELERATE;
    inin();
    mm(e,0);
    int k;
    cin>>k;
    while(k--){
        int a,b;
        cin>>a>>b;
        e[a][b]=1;
    }
    dfs(0);
    return 0;
}



Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;

vector<set<int>> st(27);
string now,c;
int qu[500005];
int m,n,q,l,r;
int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n>>now;
  for(int i = 1;i <= n;i++){    
    qu[i] = now[i-1] - 'a';
    st[qu[i]].insert(i);
  }
  cin>>m;
  while(m--){
    cin>>q;
    if(q == 1){
      cin>>l>>c;
      st[qu[l]].erase(l);
      qu[l] = c[0] - 'a';
      st[qu[l]].insert(l);
    }
    else{
      cin>>l>>r;
      int cnt = 0;
      for(int i = 0;i < 26;i++){
	if(st[i].lower_bound(l) != st[i].lower_bound(r+1)) cnt++;
      }
      cout<<cnt<<endl;
    }
  }
  return 0;
}


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

using namespace std;

int main(){
    string s,result;
//    char result[24];
    result = "Good";
    cin >> s;
    for(int i=0;i<int(s.size())-1;i++){
        if(s[i]==s[i+1]){
            result = "Bad";
        }
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

int main() {
	COME_LET_THE_GAMES_BEGIN();
	int A, B, C;
	cin >> A >> B >> C;
	cout << A * B / 2 << endl;
}

Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b, c, n, r, x;
    int i, tmp;

    for(;;){
      a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt();
      if(a + b + c == 0)break;
      if(a > b){
        tmp = a; a = b; b = tmp;
      }
      if(b > c){
        tmp = b; b = c; c = tmp;
      }
      if(a > b){
        tmp = a; a = b; b = tmp;
      }
      r = (a * a + b * b);
      n = sc.nextInt();
      for(i = 0;i < n;i++){
        x = sc.nextInt();
        if(4 * x * x > r)out.println("OK");
        else out.println("NA");
      }
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17196
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>

using namespace std;

int main(void)
{
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++){
		if (S[i] == '1')
			S[i] = '9';
		else if (S[i] == '9')
			S[i] = '1';
	}
	cout << S << endl;
}

Measured memory_bytes: 256
a = str(input())
n = 0
w = 0
e = 0
s = 0
for i in a:
    if i == "N":
        n += 1
    elif i == "W":
        w += 1
    elif i == "E":
        e += 1
    elif i == "S":
        s += 1
ans = True
if (n == 0 and s != 0) or (n != 0 and s == 0):
    ans = False
if (e == 0 and w != 0) or (e != 0 and w == 0):
    ans = False
if ans == True:
    print("Yes")
else:
    print("No")

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

int main()
{
  int n, m;
  cin >> n >> m;
  valarray<int> a(n);
  for (auto&& e : a) cin >> e;
  auto f = [&](auto x){return x * 4 * m >= a.sum();};
  cout << (count_if(begin(a), end(a), f) >= m ? "Yes" : "No") << endl;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    cin >> N;
    V<int> a(N);
    rep(i, N) cin >> a[i];
    int ans = 0;
    rep(i, N) {
        if (i % 2 == 0 && a[i] % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int dx[13] = {1, 0, 0, 1,  1, 1,  1, 0,  0, 1,  1,  1,  1};
int dy[13] = {0, 1, 0, 1, -1, 0,  0, 1,  1, 1, -1,  1, -1};
int dz[13] = {0, 0, 1, 0,  0, 1, -1, 1, -1, 1,  1, -1, -1};

bool valid(int z, int y, int x, int n)
{
    return (0 <= min(z, min(y, x)) && max(z, max(y, x)) < n);
}

int main()
{
    int n, m, p;
    
    while (scanf("%d %d %d", &n, &m, &p) && n){
        int in[7][7][7];
        int ct[7][7] = {0};
        int fin = -1;
        
        memset(in, -1, sizeof(in));
        for (int R = 0; R < p; R++){
            int x, y;
            scanf("%d %d", &x, &y);
            if (~fin) continue;
            --x; --y;
            in[ct[y][x]++][y][x] = (R & 1);
            
            bool won = false;
            for (int i = 0; i < n; i++){
                for (int j = 0; j < n; j++){
                    for (int k = 0; k < n; k++){
                        if (in[i][j][k] < 0) continue;
                        for (int sel = 0; sel < 13; sel++){
                            int col = in[i][j][k];
                            bool ok = true;
                            for (int t = 1; t < m; t++){
                                int nz = i + t * dz[sel];
                                int ny = j + t * dy[sel];
                                int nx = k + t * dx[sel];
                                if (!valid(nz, ny, nx, n) || in[nz][ny][nx] != col){
                                    ok = false;
                                    break;
                                }
                            }
                            if (ok){
                                fin = R + 1;
                                goto endloop;
                            }
                        }
                    }
                }
                endloop:;
            }
        }
        printf("%s", ~fin ? ((fin & 1) ? "Black" : "White") : "Draw");
        if (~fin) printf(" %d\n", fin);
        else printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll R, G, B, N;
    cin >> R >> G >> B >> N;
    ll ans = 0;
    for(int r = 0; r <= 3000; r++) {
        for(int g = 0; g <= 3000; g++) {
            int b = N - r * R - g * G;
            if(b % B == 0 && b >= 0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        int[] b = new int[n - 1];
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < n - 1; i++)
        {
            b[i] = int.Parse(input[i]);
        }

        int sum = b[0];
        for (int i = 1; i < n - 1; i++)
        {
            sum += Math.Min(b[i - 1], b[i]);
        }
        sum += b[n - 2];

        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    int i = 0, count = 0;
    int j = i + 2;

    while (j < n)
    {
        if ((p[i] > p[i + 1] && p[i + 1] > p[j]) || (p[i] < p[i + 1] && p[i + 1] < p[j]))
        {
            count++;
        }
        i++;
        j++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())

if A>=B and C>=D:
    print(B+D)
elif A>=B and C<=D:
    print(B+C)
elif A<=B and C>=D:
    print(A+D)
elif A<=B and C<=D:
    print(A+C)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; ++i)
#define all(x) begin(x), end(x)
#define gets(s) fgets(s,size(s),stdin)
using namespace std;
typedef long long ll;
typedef string str;
template<typename T>
using vec=vector<T>;
template<typename T>
using uset=unordered_set<T>;
template<typename T,typename S>
using umap=unordered_map<T,S>;
 
const int mod=1000000007;
const double pi=3.1415926535;

int main() {
    int x,n;
    bitset<128> b;
    scanf("%d%d",&x,&n);
    rep(i,n) {
        int t;
        scanf("%d",&t);
        b[t]=true;
    }
    rep(i,102) {
        if(!b[x-i]) {
            printf("%d",x-i);
            break;
        } else if(!b[x+i]) {
            printf("%d",x+i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
    int N,D;
    cin >> N >> D;
    
    for(int i=1;i<=N;i++){
        if(N<=(2*D+1)*i){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll lo = 0, hi = 2e9;
    while (hi - lo > 1) {
        ll mid = (hi + lo) / 2;
        ll need = 0;
        for (int i = 0; i < n; i++) {
            need += (a[i] - 1) / mid;
        }
        if (need <= k) {
            hi = mid;
        } else {
            lo = mid;
        }
    }
    cout << hi << '\n';
    return 0;
}

Measured memory_bytes: 4696
#include <iostream>
#include <cstdio>
using namespace std;
const int N=200010;
int n,m; int cnt[N];
int readin() {
	int x=0,f=1; char ch=getchar();
	while(ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main() {
	n=readin(),m=readin();
	for (int a,b,i=1;i<=m;i++) {
		a=readin(),b=readin();
		if (a==1) cnt[b]++;
		if (b==n) cnt[a]++;
	}
	for (int i=1;i<=n;i++)
		if (cnt[i]==2) {
			printf("POSSIBLE\n");
			return 0;
		}
	printf("IMPOSSIBLE\n");
	return 0;
}

Measured memory_bytes: 1024
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
int p[11000];
int q[11000];
int dp[1100][11000];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		scanf("%d%d",p+i,q+i);
	}
	for(int i=0;i<=a;i++)for(int j=0;j<=b;j++){
		dp[j][i]=mod;
	}
	dp[0][0]=0;
	for(int i=0;i<b;i++){
		for(int j=0;j<=a;j++){
			dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
			dp[i][min(a,p[i]+j)]=min(dp[i][min(a,p[i]+j)],dp[i][j]+q[i]);
		}
	}
	printf("%d\n",dp[b][a]);
}

Measured memory_bytes: 45184
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e6 + 200;

int n, pre[MAX_N], suf[MAX_N], ans = 0x7fffffff;
char str[MAX_N];

void prepare()
{
    for (int i = 1; i <= n; i++)
        pre[i] = pre[i - 1] + (str[i] == '0' ? -1 : 1);
    suf[n + 1] = MAX_N;
    for (int i = n; i >= 0; i--)
        suf[i] = min(suf[i + 1], pre[i]);
}

void solve(int lbound)
{
    int bias = 0, upper = 0;
    for (int i = 1; i <= n; i++)
    {
        if (str[i] == '?' && suf[i] - 2 - bias >= lbound)
            bias += 2;
        pre[i] -= bias, upper = max(upper, pre[i]);
    }
    ans = min(ans, upper - lbound);
}

int main()
{
    scanf("%s", str + 1), n = strlen(str + 1);
    prepare(), solve(suf[0]);
    prepare(), solve(suf[0] - 1);
    printf("%d\n", ans);
    return 0;
}

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

/*
   AtCoder contest
   coder : yoichidon
 */

public class Main {

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

        int A = sc.nextInt();
        int B = sc.nextInt();

        System.out.println(B%A==0 ? A+B : B-A);



    }
}


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

using namespace std;
int main(void){
    int n,a,b;
    cin >> n >> a >> b;
    
    string s;
    cin >> s;
    
    int pass = 0;
    int overseas_pass = 1;
    
    for (int i = 0; i < n; i++){
        
        if (s[i] == 'a'){
            
            if (pass < a + b){
                cout << "Yes" << endl;
                pass++;
            }
            else{
                cout << "No" << endl;
            }
        }
        else if (s[i] == 'b'){
            
            if (pass < a + b && overseas_pass <= b){
                cout << "Yes" << endl;
                pass++;
                overseas_pass++;
                //cout << overseas_pass << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 5 + 2e3;
const int mod = 1e9+7;
int n,m;
int a[maxn] , b[maxn] ;
LL f[maxn][maxn];

void Read(){
	
//	#define TASK "ABC"
//	freopen(TASK".inp", "r", stdin); freopen(TASK".out", "w", stdout);
    ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for(int i=1 ; i<=n ; i++) cin >> a[i] ;
	for(int i=1 ; i<=m ; i++) cin >> b[i] ;
	
}
void Magic(){
	
	f[0][0] = 1;
	for(int i=1 ; i<=max(n,m) ; i++) f[i][0] = 1 , f[0][i] = 1;
	
	for(int i=1 ; i<=n ; i++){
		for(int j=1 ; j<=m ; j++){
			f[i][j] = ( f[i-1][j] + f[i][j-1] - f[i-1][j-1] + mod) % mod;
			if (a[i] == b[j]) f[i][j] = ( f[i][j] + f[i-1][j-1] ) % mod;
		}
	}
	
}
void Write(){
	cout << f[n][m] ;
}
int main(){
    
    Read();
    Magic();
    Write();
    
    return 0;
}


Measured memory_bytes: 34916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	private static boolean ispf = false;

	public static void main(String[] args) throws Exception {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] systemInLine = br.readLine().split(" ");
		int provinceCount = Integer.parseInt(systemInLine[0]);
		int cityCount = Integer.parseInt(systemInLine[1]);
		pf("辖区总数:" + provinceCount + " 城市总数:" + cityCount);

		
		/**
		 * 所有的城市
		 */
		
		//城市数组，0：省份，1：年份，2：输入顺序号，4：年份序号
		int[][]  proviceCityArray = new int[cityCount][4];

		for (int i = 0; i < cityCount; i++) {
			systemInLine = br.readLine().split(" ");
			int provinceIndex = Integer.parseInt(systemInLine[0]);
			int cityCreateYear = Integer.parseInt(systemInLine[1]);
			proviceCityArray[i][0]= provinceIndex;
			proviceCityArray[i][1]= cityCreateYear;
			proviceCityArray[i][2]= i+1;
		}
		br.close();
		
		
		
		/**
		 * 这次排序后辖区和年份已经排序了
		 */
	
		Arrays.sort(proviceCityArray,(o1, o2) -> (o1[0] == o2[0]) ? (o1[1] - o2[1]) : (o1[0] - o2[0]));
		
		for (int i = 0; i < proviceCityArray.length; i++) {
			if(i==0) {
				proviceCityArray[i][3] = 1;
			}else {
				if((proviceCityArray[i][0] == proviceCityArray[i - 1][0])) {//于上一次比较
					proviceCityArray[i][3] = proviceCityArray[i - 1][3] + 1;
				}else {
					proviceCityArray[i][3] = 1;
				}
			}
		}
		
		/**
		 * 再次排序拍会回来
		 */
		 Arrays.sort(proviceCityArray, (o1, o2) -> o1[2] - o2[2]);
		 String[] padding = new String[]{"", "0", "00", "000", "0000", "00000"};
		for (int i = 0; i < proviceCityArray.length; i++) {
			//System.out.println(String.format("%06d", proviceCityArray[i][0])+String.format("%06d", proviceCityArray[i][3]));
			System.out.println(
					padding[getPadingIndex(proviceCityArray[i][0])]+proviceCityArray[i][0]+
					        padding[getPadingIndex(proviceCityArray[i][3])]+proviceCityArray[i][3]);
		}
		
	}

	public static void pf(String s) {
		if (ispf) {
			System.out.println(s);
		}
	}
	 private static int getPadingIndex(int n) {
	        if (n < 10) return 5;
	        else if (n < 100) return 4;
	        else if (n < 1000) return 3;
	        else if (n < 10000) return 2;
	        else if (n < 100000) return 1;
	        else return 0;
	    }
}


Measured memory_bytes: 78644
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  int n;
  while(cin>>n,n){
    vector<int> x(n);
    REP(i,n)cin>>x[i];
    sort(ALL(x));
    int ans=INF;
    REP(i,x.size()-1){
      ans=min(ans,x[i+1]-x[i]);
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n, k, s;
	cin >> n >> k >> s;
	if(s < 1e9){
		rep(i, n){
			if(i != 0) cout << " ";
			if(i < k) cout << s;
			else cout << s+1;
		}
	}else{
		rep(i, n){
			if(i != 0) cout << " ";
			if(i < k) cout << s;
			else cout << 1;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1280
import sys
sys.setrecursionlimit(10**9)

INF = 10**20
def main():
    H,N = map(int,input().split())
    A,B = [],[]
    for _ in range(N):
        a,b = map(int,input().split())
        A.append(a)
        B.append(b)

    tp = 3 * 10**4
    dp = [INF] * tp
    dp[0] = 0
    ans = INF
    for h in range(tp):
        minim = INF
        for i in range(N):
            dp_i = h-A[i]
            if dp_i >= 0 and dp[dp_i] != INF:
                minim = min(minim,dp[dp_i]+B[i])
                # print(dp[h-A[i]]+B[i])

        if minim != INF:
            dp[h] = minim
            if h >= H:
                ans = min(ans,dp[h])


    print(ans)


if __name__ == "__main__":
  main()


Measured memory_bytes: 44456
def print_list(s, a, b):
    print(s[a:b+1])

def reverse_list(s, a, b):
    s1 = "".join(s[:a])
    s2 = "".join(reversed(s[a:b+1]))
    s3 = "".join(s[b+1:])
    return list(s1+s2+s3)

def replace_list(s, a, b, p):
    s1 = "".join(s[:a])
    s3 = "".join(s[b+1:])
    return list(s1+p+s3)

s = list(input())
pl = []
cmd = []
n = int(input())
i = 0

while n > i:
    cmd = input().split()
    if cmd[0] == "print":
        pl.append("".join(s[int(cmd[1]):int(cmd[2])+1]))
    elif cmd[0] == "reverse":
        s = reverse_list(s, int(cmd[1]), int(cmd[2]))
    elif cmd[0] == "replace":
        s = replace_list(s, int(cmd[1]), int(cmd[2]), cmd[3])
    i += 1

for p in pl:
    print(p)



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

int main() {
  long long n, ans = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if ((i%3) && (i%5)) {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>
#include <unordered_set>

using namespace std;
using ll = long long;
const int BIG = 1000000007;


int main() {
    ll n;
    cin >> n;
    set<ll> kx,ky;
    for(ll i = 0;i < n;++i){
        ll x,y;
        cin >> x >> y;
        kx.insert(x + y);
        ky.insert(x - y);
    }
    ll kxmax = *kx.rbegin() - *kx.begin();
    ll kymax = *ky.rbegin() - *ky.begin();
    
    ll ans = max(kxmax,kymax);
    cout << ans << endl;
}




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




int main(){ 
      int n;
      cin >> n;
      vector<pair<pair<string,int>,int>> spi(n);
      for(int i=0;i<n;i++){
            cin >> spi[i].first.first >> spi[i].first.second;
            spi[i].first.second *= -1;
            spi[i].second = i;
      }
      sort(spi.begin(),spi.end());
      for(int i=0;i<n;i++){
            cout << spi[i].second +1 << endl;
            //cout << spi[i].first.first<<endl<<spi[i].first.second<<endl;
      }

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int h,w;
  bool flg,FLG,tmp,TMP;
  while(cin >> h >> w && h||w){
    flg = true,tmp=false;
    for(int i=0;i<h;i++){
      FLG = flg,TMP=tmp;
      for(int j=0;j<w;j++){
    cout << (FLG ? "#" : ".");
    swap(FLG,TMP);
      }
      cout << endl;
      swap(flg,tmp);
    }
    cout << endl;
  }
}


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

int main(){
    int N;
    cin>>N;
    int b[1000000]={};
    int num;
    for(int i=0;i<N-1;i++) {
        cin>>num;
        b[num-1]++;
    }
    for(int i=0;i<N;i++){
        cout<<b[i]<<endl;
    }

}



Measured memory_bytes: 7504
N=int(input())
H=list(map(int,input().split()))
ans=0
M=0
for i in range(N):
  if(M<H[i]):
    M=H[i]
for i in range(M):
  X=0
  for j in range (N):
    H[j]=min(H[j],M-i)
    if(j):
      if(H[j]!=H[j-1] and H[j-1]==M-i):
        X+=1
    if(j==N-1):
      if(H[j]==M-i):
        X+=1
  ans+=X
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
inline void write(LL x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x);putchar(' ');}
inline void pr2(LL x){write(x);putchar('\n');}
const int MAXN=200005;
int n,a[MAXN],b[MAXN];
struct node
{
	int a,b,x;
	node(){}
	node(int _a,int _b,int _x){a=_a;b=_b;x=_x;}
	friend bool operator <(node n1,node n2){return n1.b!=n2.b?n1.b<n2.b:n1.a>n2.a;}
};
priority_queue<node> hp;
int main()
{
	n=read();
	bool tf=true;
	for(int i=1;i<=n;i++)
	{
		a[i]=read(),b[i]=read();
		if(a[i]!=b[i])tf=false;
	}
	if(tf)return puts("0"),0;
	LL ans=0,sum=0;
	for(int i=1;i<=n;i++)if(a[i]<=b[i])ans+=a[i],b[i]-=a[i],a[i]=0;
	for(int i=1;i<=n;i++)if(a[i]&&a[i]>=b[i])hp.push(node(a[i]-b[i],b[i],i));
	for(int i=1;i<=n;i++)if(b[i]>=a[i])sum+=b[i];
	while(!hp.empty())
	{
		int x=hp.top().x;hp.pop();
		int ls=a[x]-b[x];//差值
		LL t=min((LL)ls,sum); 
		ls-=t;sum-=t;ans+=t;
		if(!sum)break;
		ans+=b[x];
	}
	pr2(ans);
	return 0;
}


Measured memory_bytes: 704
/*
      author : nishi5451
      created: 11.08.2020 00:36:47
*/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;


int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(*a.rbegin()==*b.begin() && *b.rbegin()==*c.begin()){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair <ll,ll> P;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define print(x) cout << x << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll MOD = 1000000007;


int main()
{
    ll N;
    cin >> N;
    vector<ll> P(N);
    ll mi = 100000000000;
    rep(i, N) {
        cin >> P[i];
    }
    ll cnt = 0;
    rep(i, N)
    {
        if (mi > P[i]) {
            mi = P[i];
            cnt++;
        }
    }
    print(cnt);
    return 0;
}


Measured memory_bytes: 1792
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::{max, min};
fn main() {
    input! { n, t, mut ab: [(usize, usize); n] };
    ab.sort();
    let mut dp = vec![0; t + 1];
    for i in 0..n {
        let (a, b) = ab[i];
        for j in (0..t).rev() {
            let nj = min(j + a, t);
            dp[nj] = max(dp[nj], dp[j] + b);
        }
    }
    println!("{}", dp.iter().max().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define dep(i,a,b) for(int i = a; i >= b; i--)
using namespace std;
const int N = 2e5 + 10, M = 1e6 + 10;
int n, a[N], b[N];

struct edge{ int to, pre; } e[M << 1]; int u[N], l = 1;
void ins(int a, int b) { e[++l] = (edge){b, u[a]}, u[a] = l; }
#define v e[i].to
#define reg(i,a) for(int i = u[a]; i; i = e[i].pre)

int da[N], db[N];

void insert(int a, int b) { ins(a, b), ins(b, a); }

int vis[M];
void dfs(int x) {
	for(int &i = u[x]; i; i = e[i].pre) {
		if (vis[i >> 1]) continue;
		vis[i >> 1] = i;
		dfs(v);
	}
}

int main() {
	scanf("%d",&n);
	rep(i,1,n) { scanf("%d",a + i); if (~a[i]) da[a[i]]++; }
	rep(i,1,n) { scanf("%d",b + i); if (~b[i]) db[b[i]]++; }
	rep(i,1,n) if ((da[i] & 1) ^ (db[i] & 1)) { printf("IMPOSSIBLE\n"); return 0; } 
	printf("POSSIBLE\n");
	rep(i,1,n) if (~a[i]) insert(a[i], i);
	rep(i,1,n) if (~b[i]) insert(n + b[i], n + i);
	rep(i,1,n) if (a[i] == -1) rep(j,1,n) if (b[j] == -1)
		insert(i, n + j);
	static int id[N];
	rep(i,1,n) if (!(da[i] & 1)) insert(i, i + n), id[i] = l >> 1;
	dfs(1);
	rep(i,1,n) if (da[i] & 1) printf("0 ");
	else printf("%d ",(vis[id[i]] & 1) ? 1 : -1);
	printf("\n");
	return 0;
}

Measured memory_bytes: 19456
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        mut s: i64,
    }

    let mut ans = 0;
    for i in 1.. {
        if s == 1 || s == 2 || s == 4 {
            ans = i + 3;
            break;
        }
        if s % 2 == 0 {
            s /= 2;
        } else {
            s = 3 * s + 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
//#include <bits/stdc++.h>
#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define LL long long
#define pii pair<int,int>

using namespace std;
const int MOD=1e5+10;

int main()
{
	int d,n;
	cin>>d>>n;
	
	int ans=n;
	if(n==100) ans=101;
	if(d==1) ans*=100;
	if(d==2) ans*=10000; 
	
	cout<<ans;
    rt0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int n,m;
	int maxn = -999999999,minn;
	cin >> n >> m;
	minn = m;
	for(int i = 1; i < n; ++i)
	{
		cin >> m;
		maxn = max(maxn,m-minn);
		minn = min(minn,m);
	}
	cout << maxn << endl;
	return 0;
}


Measured memory_bytes: 3116
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,A[SIZE],B[SIZE];

void solve() {
    cin>>N;
    REP(i,N)cin>>A[i];
    int ans = 0;
    REP1(i,N-1) {
        ans ^= A[i];
    }
    B[0]=ans;
    out("%lld ", B[0]);
    REP1(i,N-1) {
        B[i] = A[i]^A[0]^B[0];
        out("%lld ", B[i]);
    }
    out("\n");
}



Measured memory_bytes: 6804
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

string s;
int main(int argc, const char * argv[]) {
  cin >> s;
  
  int first, last;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'A') {
      first = i;
      break;
    }
  }
  
  for (int i = s.size() - 1; i >= 0 ; i--) {
    if (s[i] == 'Z') {
      last = i;
      break;
    }
  }
  
  cout << last - first + 1 << endl;
  return 0;
}


Measured memory_bytes: 640
import std.stdio, std.string, std.conv, std.array, std.algorithm;

void main() {
   while (true) {
   auto a = readln.split.map!(to!int);
   if (a[0] == 0 && a[1] == 0) break;
   if (a[0] < a[1]) writeln(a[0], " ", a[1]);
   else writeln(a[1], " ", a[0]);
   }
}

Measured memory_bytes: 2416
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
int main(void) {
    using std::cos;
    using std::cout;
    using std::sin;
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    double a, b;
    int h, m;
    std::cin >> a >> b >> h >> m;

    double aRad = M_PI * (double)h / 6.0 + M_PI * (double)m / 360.0;
    double ax   = a * cos(aRad);
    double ay   = a * sin(aRad);

    double bRad = M_PI * (double)m / 30.0;
    double bx   = b * cos(bRad);
    double by   = b * sin(bRad);
    // cout << aRad << ", " << bRad << std::endl;
    // cout << ax << ", " << ay << std::endl;
    // cout << bx << ", " << by << std::endl;

    double dist2 = pow(ax - bx, 2.0) + pow(ay - by, 2.0);
    double dist  = sqrt(dist2);

    std::cout << dist << std::endl;
    return 0;
}


Measured memory_bytes: 4120
using System;
using System.Linq;

namespace id_0034cs
{
    class Program
    {
        static void Main(string[] args)
        {
            string tmp;
            while ((tmp = Console.ReadLine()) != null)
            {
                var vs = tmp.Split(',').Select(int.Parse).ToArray();
                int[] l = new int[10]; 
                var v1 = vs[10];
                var v2 = vs[11];
                Array.Copy(vs, l, 10);
                var sum = (double)(l.Sum());
                var crosspoint = (double)v1 / ((double)(v1) + (double)(v2))*sum;
                var distance = 0.0;
                foreach(var i in Enumerable.Range(0, 10))
                {
                    distance += (double)l[i];
                    if(crosspoint <= distance)
                    {
                        Console.WriteLine(i+1);
                        break;
                    }
                }

            }
        }
    }
}



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

int N, M;

int gauss(int n)
{
    return n * (n + 1) / 2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> N >> M;
    cout << gauss(N - 1) + gauss(M - 1);
    cin >> N;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll a, b,k,ans;
	cin >> a >> b>>k;
	if (b - a + 1 <= k) {
		for (int i = a; i <= b; i++) {
			cout << i << endl;
		}
		return 0;
	}
	ll check1[105], check2[105];
	for (int i = 0; i < k; i++) {
		ans = a + i;
		check1[i] = ans;
		
	}
	for (int i = 0; i < k; i++) {
		cout << check1[i] << endl;
	}
	ll ans2;
	int flag = 0;
	for (int i = k-1; i >= 0; i--) {
		ans2 = b - i;
		
		for (int j = 0; j < k; j++) {
			if (check1[j] == ans2) {
				flag = 1;
			}
		}
		if (!flag) {
			cout << ans2 << endl;
		}
		flag = 0;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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

int main()
{   
    int H,W,h,w; cin >> H >> W >> h >> w;
    cout << (H-h)*(W-w) << endl;
}
    

Measured memory_bytes: 256
def c_shopping_street(N, F, P):
    ans = -float('inf')
    for b in range(1, 1024):  # (2の10乗-1)通り、営業するか否かの選び方がある
        cc = 0  # 利益の暫定値
        for i in range(N):
            c = 0  # 自分と店iとの営業時間が「かぶる」のは何回かを格納
            for j in range(10):
                if ((b >> j) % 2 == 1) and F[i][j] == 1:
                    c += 1
            cc += P[i][c]
        ans = max(ans, cc)  # 利益の最大値を更新
    return ans

N = int(input())
F = [[int(i) for i in input().split()] for j in range(N)]
P = [[int(i) for i in input().split()] for j in range(N)]
print(c_shopping_street(N, F, P))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int main(void){
	int a[100];
	for (int i = 0; i < 100; i++)a[i] = 0;
	int n,x, y, z;
	scanf("%d %d", &n,&z);
	for (int i = 0; i < z; i++){
		scanf("%d %d", &x, &y);
		a[x - 1]++;
		a[y - 1]++;
	}
	for (int i = 0; i < n; i++)printf("%d\n", a[i]);
	return 0;
}


Measured memory_bytes: 128
h, w  = gets.split.map(&:to_i)
map = Array.new(h)

h.times do |i|
  map[i] = gets.chomp.chars
end

nmap = []
map.each do |line|
  nmap << line if line.include?('#')
end

map = []
nmap = nmap.transpose
nmap.each do |line|
  map << line if line.include?('#')
end

map = map.transpose

map.each do |line|
  puts line.join
end

Measured memory_bytes: 2300
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BEcho {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    string S;
	    in >> N >> S;
	    if (N % 2 == 1) {
	        out << "No" << "\n";
	        return;
	    }
	    REP(i,0,N / 2) {
	        if (S[i] != S[i + N/2]) {
                out << "No" << "\n";
                return;
	        }
	    }
        out << "Yes" << "\n";
        return;
	}
};


signed main() {
	BEcho solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
	int N, Y, i, j, k;
	cin >> N >> Y;
	for (i = 0; i <= N; ++i) {
		for (j = 0; j <= N-i; ++j) {
			k = N - i - j;
			if (10000 * i + 5000 * j + 1000 * k == Y) {
				cout << i << " " << j << " " << k << " " << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
	return 0;
}

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

using namespace std;

int dif(int, int);

int main(){
    
    int a, b, c, d;

    cin >> a >> b >> c >> d;

    if((dif(a, b) <= d && dif(b, c) <= d) || dif(a, c) <= d){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

int dif(int x, int y){
    return abs(x - y);
}

Measured memory_bytes: 256
n = int(input())
d = [int(x) for x in input().split(' ')]

m = {}
for item in d:
    if item in m:
        m[item] += 1
    else:
        m[item] = 1

if d[0] == 0 and m[0] == 1:
    prev = 1
    s = 1
    visited = 1
    for i in range(1, 10 ** 5):
        if not i in m:
            break
        v = m[i]
        visited += v

        s *= (prev ** v)
        s = s % 998244353
        prev = v
    if visited != n:
        s = 0
else:
    s = 0

print(s)


Measured memory_bytes: 18592
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using vi = vector<int>;

#define scan(x) cin >>x;
#define print(x) cout << x << endl;
#define Endl endl
#define inf 99999999
#define llinf 1LL << 32

int main() {

	ll n, a, b;
	scan(n); scan(a); scan(b);

	if (n == 1) {
		if (a != b) {
			print(0);
		}
		else {
			print(1);
		}
	}
	else if(a > b) {
		print(0);
	}
	else {
		print(((n - 2) * (b - a) +1));
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
int inf = 1e9;

int main() {
  int n; cin >> n;
  vector<int> p(n);
  vector<int> a(n, 0);
  vector<int> b(n, 0);
  for(int i=0; i<n; i++) cin >> p[i];
  int m = 30000;
  for(int i=0; i<n; i++) {
    a[i] = m * i;
    b[i] = m * (n-i);
  }
  for(int i=0; i<n; i++) {
    a[p[i]-1] += (i + 1);
  }

  for(int i=0; i<n; i++) {
    if(i != n-1) cout << a[i] << " ";
    else cout << a[i] << endl;
  }
  for(int i=0; i<n; i++) {
    if(i != n-1) cout << b[i] << " ";
    else cout << b[i] << endl;
  }

  return 0;
}


//EOF


Measured memory_bytes: 896