akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

namespace AtCorder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Enumerable
                .Range(0, n)
                .Select(x => Console.ReadLine().Split(' '))
                .Select((x, i) => new { Name = x[0], Point = int.Parse(x[1]), Index = i + 1 })
                .OrderBy(x => x.Name)
                .ThenByDescending(x => x.Point)
                .ToArray();
            foreach (var item in a)
            {
                Console.WriteLine(item.Index);
            }
        }
    }
}


Measured memory_bytes: 11732
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define num(a) a-'0'
#define maxself(a,b) if(b>a)a=b
#define minself(a,b) if(b<a)a=b;
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define vi vector<int>
#define vl vector<long long int>
#define v vector
#define p pair
#define pb push_back
#define mk make_pair
#define ln "\n"
typedef long long int ll;
typedef long double ld;
typedef double d;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	int l[n];
	rep(i,0,n){
		cin>>l[i];
	}
	sort(l,l+n);
	ll ans=0;
	for(int i=n-1;i>=2;i--){
		int* u=l+i-1;
		int* b=l;
		while(u!=b){
			if(*u+*b>l[i]){
				ans+=u-b;
				u--;
			}
			else{
				b++;
			}
		}
	}
	cout<<ans<<ln;
}

int main(){
	boost_io;
	solve();
	return 0;
}

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

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


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

int main()
{
  int first = 0, second = 0, third = 0;
  for (int i = 0; i < 10; i++) {
    int n;
    cin >> n;
    if (n > first) {
      third = second;
      second = first;
      first = n;
    } 
    else if(n > second) {
      third = second;
      second = n;
    }
    else if(n > third) {
      third = n;
    }
  }
  cout << first << "\n" << second << "\n" << third << endl;
  return 0;
}

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

using namespace std;

int main(){
    int n;cin>>n;
    int mi,ma;
    for(int i=0;i<n;++i){
        int a;cin>>a;
        if(!i){
            mi=a;
            ma=a;
        }else{
            mi=min(mi,a);
            ma=max(ma,a);
        }
    }
    cout<<ma-mi<<endl;
}


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

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define endl "\n"
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e16;
const double PI = acos(-1);
const int N = 1e6 + 7;
int mod = 998244353;

const int maxn = 3002;
int dp[maxn][maxn];

int32_t main()
{
    IOS;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, s;
    cin >> n >> s;
    vector<int> v(n+1);
    for(int i = 1; i <= n; i++)
        cin >> v[i];
    int ans = 0;
    for(int i = 1; i <= n; i++)
    {
        dp[i][v[i]] += i;
        dp[i][v[i]] %= mod;
        if(v[i] == s)
        {
            ans += i * (n - i + 1);
            ans %= mod;
        }
        for(int j = 1; j <= s; j++)
        {
            dp[i][j] += dp[i-1][j];
            dp[i][j] %= mod;
            if(j - v[i] >= 1)
            {
                dp[i][j] += dp[i-1][j-v[i]];
                dp[i][j] %= mod;
                if(j == s)
                {
                    ans += dp[i-1][j-v[i]] * (n - i + 1);
                    ans %= mod;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 70656
#include<cstdio>
#include<iostream>
#include<cstring> 
using namespace std;
bool vis[10];
bool judge(int x){
    while(x!=0){
        int temp=x%10;
        if(vis[temp]==1)
            return false;
        x/=10;
    }
    return true;
}
int main(){
    int n,k;
    scanf("%d%d",&n,&k);
 
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=k;i++){
        int x;
        scanf("%d",&x);
        vis[x]=true;
    }
 
    for(int i=n; ;i++){
        if(judge(i)){
            printf("%d\n",i);
            break;
        }
    }
    return 0;
} 

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;

vector<vector<int>> ans(500,vector<int> (500));
void level(int L,int from,int to){
    int num=to-from+1;
    if(num==2){
        ans.at(from).at(to)=L;
        ans.at(to).at(from)=L;
        return;
    }
    if(num==3){
        ans.at(from).at(to-1)=L;
        ans.at(from).at(to)=L;
        ans.at(to-1).at(to)=L+1;
        return;
    }
    int newto,newfrom;
    newfrom=num/2+from;
    newto=newfrom-1;
    for(int i=from;i<=newto;i++){
        for(int j=newfrom;j<=to;j++){
            ans.at(i).at(j)=L;
            ans.at(j).at(i)=L;
        }
    }
    level(L+1,from,newto);
    level(L+1,newfrom,to);
    return;
}

int main() {
    int N;
    cin>>N;
    level(1,0,N-1);
    rep(i,N-1){
        for(int j=i+1;j<N;j++){
            cout<<ans.at(i).at(j);
            if(j==N-1){cout<<endl;}
            else{cout<<" ";}
        }
    }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vl=vector<ll>;
#define MOD 998244353
int main() {
    ll N; cin>>N;
    ll K; cin>>K;
    vl L(K),R(K);
    for (int i = 0; i < K; i++){
        cin>>L[i]>>R[i];
    }
    vl dp(N+1,0),sum(N+1,0);
    dp[1]=1;sum[1]=1;
    for (int i = 2; i < N+1; i++){
        for (int j = 0; j < K; j++){
            if(i-L[j]<1)continue;
            if(i-R[j]<1)dp[i]=(dp[i]+sum[i-L[j]])%MOD;
            else dp[i]=((dp[i]+sum[i-L[j]]-sum[i-R[j]-1])%MOD+MOD)%MOD;
        }
        sum[i]=(sum[i-1]+dp[i])%MOD;
    }
    cout<<dp[N]<<endl;
}

Measured memory_bytes: 6420
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        String S = sc.next();
        sc.close();
    
        if(S.equals("AKIHABARA") || S.equals("KIHABARA") ||
            S.equals("AKIHBARA") || S.equals("AKIHABRA") ||
            S.equals("AKIHABAR") || S.equals("KIHBARA") ||
            S.equals("KIHABRA") || S.equals("KIHABAR") ||
            S.equals("AKIHBRA") || S.equals("AKIHBAR") ||
            S.equals("AKIHABR") || S.equals("KIHBRA") ||
            S.equals("AKIHBR") || S.equals("KIHABR") ||
            S.equals("KIHBAR") || S.equals("KIHBR"))
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

using ld = long double;

template<class T>
struct Point {
	typedef Point P;
	T x, y;
	explicit Point(T x=0, T y=0) : x(x), y(y) {}
	bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
	bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
	P operator+(P p) const { return P(x+p.x, y+p.y); }
	P operator-(P p) const { return P(x-p.x, y-p.y); }
	P operator*(T d) const { return P(x*d, y*d); }
	P operator/(T d) const { return P(x/d, y/d); }
	T dot(P p) const { return x*p.x + y*p.y; }
	T cross(P p) const { return x*p.y - y*p.x; }
	T cross(P a, P b) const { return (a-*this).cross(b-*this); }
	T dist2() const { return x*x + y*y; }
	ld dist() const { return sqrt((ld)dist2()); }
	// angle to x-axis in interval [-pi, pi]
	ld angle() const { return atan2(y, x); }
	P unit() const { return *this/dist(); } // makes dist()=1
	P perp() const { return P(-y, x); } // rotates +90 degrees
	P normal() const { return perp().unit(); }
	// returns point rotated 'a' radians ccw around the origin
	P rotate(ld a) const {
		return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
};

using P = Point<ld>;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n;
	cin >> n;
	ld l;
	cin >> l;
	const ld PI = 4.0 * atan(1.0);
	vector<ld> ang(n);
	for(int i = 0; i < n; i++) cin >> ang[i];
	P ans(0, 0);
	for(int i = 0; i < n; i++){
		for(int j = i+1; j < n; j++){
			int f = j - i - 1;
			int g = n - 2 - f;
			ans = ans + P(-1, 0).rotate(PI / l * (ang[i] + ang[j])) * f;
			ans = ans + P(1, 0).rotate(PI / l * (ang[i] + ang[j])) * g;
		}
	}
	ans = ans * 6 / n / (n-1) / (n-2);
	cout << fixed << setprecision(20);
	cout << ans.x << " " << ans.y << '\n';
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int t_hp = (a-1) / d;
  int a_hp = (c-1) / b;
  if (t_hp >= a_hp) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
    if (abs(b - a) <= (v - w) * t) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3640
a = int(input())
b = []
for i in range(a):
    c, d = input().split()
    b.append([c, int(d), i + 1])
b = sorted(b, key=lambda x: x[1], reverse=True)
b = sorted(b, key=lambda x: x[0])
for i in range(a):
    print(int(b[i][2]))


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=505,mod=1e9+7;
int n,m,f[N][N],g[N][N],a[N];

void update(int x){
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) g[i][j]=f[i][j],f[i][j]=0;
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){
		if(j+x<=m) f[i+1][j+x]=(1ll*f[i+1][j+x]+1ll*(i+1)*g[i][j])%mod;
		f[i][j]=(1ll*f[i][j]+1ll*g[i][j]*(mod+j-i*(x-1)))%mod;
		for(int k=1;k<x&&j+k<=m;k++) f[i][j+k]=(1ll*f[i][j+k]+2ll*g[i][j]*i)%mod;
		for(int k=0;k<x-1&&j+k<=m;k++) f[i-1][j+k]=(1ll*f[i-1][j+k]+1ll*g[i][j]*(x-k-1)*(i-1))%mod;
	}
}

signed main(){
	read(n,m);m++;
	for(int i=1;i<=n;i++) a[i]=read(a[i])+1;
	sort(a+1,a+1+n,greater<int>());
	f[1][a[1]]=1;
	for(int i=2;i<=n;i++) update(a[i]);
	write(f[1][m]);
}

Measured memory_bytes: 4020
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

ll N, K;
ll ans;

int main()
{
  scanf( "%lld%lld", &N, &K );

  repi( a, 1, N+1 ) if( (2*a) % K == 0 )
  {
    ll b = (K-a)%K;

    while( b < 0 )
      b += K;

    ans += ((N-a%K)/K+(a%K?1:0))*((N-b%K)/K+(b?1:0));
  }

  printf( "%lld\n", ans );
  
  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(n) for n in input().split()]
flag = 1
cnt = 0
while flag:
    flag = 0
    for i in range(N-1, 0, -1):
        if A[i] < A[i-1]:
            w = A[i-1]; A[i-1] = A[i]; A[i] = w
            cnt += 1
            flag = 1

for i, n in enumerate(A):
    if i == N - 1:
        print(n)
    else:
        print(n, end=' ')

print(cnt)



Measured memory_bytes: 5616
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

signed main(){ 
    IOS
    //io_set();
    ll a, b, k;
    cin >> a >> b >> k;
    ll g = __gcd(a, b);
    vll v;
    fo(i, 1, g){
        if(g%i == 0){
            v.pb(i);
        }
    }
    reverse(all(v));
    cout << v[k-1] << endl;
    return 0;
}



Measured memory_bytes: 256
from collections import deque
n = int(input())
Cs = input()

#%%
widx = deque()
ridx = deque()
for i in range(n):
    if Cs[i] == 'W':
        widx.append(i)
    else:
        ridx.append(i)
#%%
cnt = 0
while True:
    if len(widx) == 0 or len(ridx) == 0:
        break
    elif widx[0] < ridx[-1]:
        widx.popleft()
        ridx.pop()
        cnt += 1
    else:
        break

print(cnt)

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<bool>> edge(N+1, vector<bool>(N+1, false));
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        edge[A][B] = true;
        edge[B][A] = true;
    }
    vector<bool> use(N+1, false);
    vector<int> color(N+1, 0);
    bitset<777> bs;
    bs[0] = 1;
    for (int i = 1; i <= N; i++){
        if (use[i]) continue;
        use[i] = true;
        queue<int> q;
        q.push(i);
        color[i] = 1;
        int b = 1, w = 0;
        while(!q.empty()){
            int now = q.front();
            q.pop();
            for (int nxt = 1; nxt <= N; nxt++) {
                if (edge[now][nxt] || now==nxt) continue;
                if (color[now] == color[nxt]) {
                    cout << -1 << endl;
                    return 0;
                }
                if (use[nxt]) continue;
                color[nxt] = 3 - color[now];
                if (color[now]==1) w++;
                else b++;
                use[nxt] = true;
                q.push(nxt);
            }
        }
        bs = (bs << b) | (bs << w);
    }
    ll S = N/2;
    while (bs[S] == 0) S--;
    ll T = N-S;
    cout << S*(S-1)/2 + T*(T-1)/2 << endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  int i,j,sum;
  if(n % 2 == 0){
    printf("%d\n",n*(n/2 - 1));
    sum = n + 1;
    for(i=1;i<=(n/2);i++){
      for(j=i+1;j<=n-i;j++){
        printf("%d %d\n",i,j);
        printf("%d %d\n",sum - i,j);
      }
    }
  }else{
    printf("%d\n",(n-1)*(n-1)/2);
    sum = n;
    for(i=1;i<=(n/2);i++){
      for(j=i+1;j<=n-i-1;j++){
        printf("%d %d\n",i,j);
        printf("%d %d\n",sum - i,j);
      }
    }
    for(i=1;i<n;i++){
      printf("%d %d\n",n,i);
    }
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Scanner;

 class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		int n=scn.nextInt();
		int k=scn.nextInt();
		int q=scn.nextInt();
		int []arr=new int[q];
		int sum=0;
		HashMap<Integer,Integer> hmap=new HashMap<>();
		for(int i=0;i<q;i++) {
			arr[i]=scn.nextInt();
			if(hmap.containsKey(arr[i]-1)) {
				hmap.put(arr[i]-1, hmap.get(arr[i]-1)+1);
				sum++;
			}else {
				hmap.put(arr[i]-1,1);
				sum++;
			}
		}
		for(int i=0;i<n;i++) {
			if(hmap.containsKey(i)) {
			 int x=sum-hmap.get(i);
			 if(k-x>0) {
				 System.out.println("Yes");
			 }else {
				 System.out.println("No");
			 }
			}else {
				if(k-sum>0) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
	}

}


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

namespace ABC150A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string d;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = a * 500;
            if (b <= c)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            
            Console.ReadKey();

        }
    }
}
 


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

public class AtCoderB
{
    static void Main()
    {
        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            b = int.Parse(words[1]);
        }

        int nums = 1;
        int count = 0;
        while (nums < b)
        {
            count++;
            nums += (a - 1);
        }

        Console.WriteLine(count);
    }
}

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void answer1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void answer2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void answer3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void answer(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i, j;
  ll n;
  cin >> n;
  //ll a, b, c;
  //cin >> a >> b >> c;
  //string s; cin >> s;
  ll result = 0;
  bool judge = true;
  
  vector<ll> a(n);
  for(i = 0; i < n; i++)
    cin >> a[i];
  reverse(ALL(a));  
  ll bufmin = 2, bufmax = 2;
  ll bufl, bufr;  
  if(a[0]!=2)
  judge = false;
  for(i = 0; i < n - 1 && judge; i++){
      if(bufmin % a[i+1]==0)
      bufl = bufmin;
      else
      bufl = bufmin - (bufmin % a[i+1])+ a[i+1];

      bufr = bufmax + a[i] - 1;
      bufr = bufr - (bufr % a[i+1]);
      if(bufl > bufmax + a[i] - 1)
      judge = false;
      else
      {
          bufmax = bufr;
          bufmin = bufl;
      }
  }
  if(judge){
      cout << bufmin spa bufmax + a[i] - 1 << endl;
  }
  else
  {
      cout << -1 << endl;
  }
  
  

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair < int , int > pii;
typedef long long LL;
#define mpr make_pair
#define FS first
#define SC second
#define PB push_back
template < typename T > T MAX(T a,T b){return (a>b)?a:b;}
template < typename T > T MIN(T a,T b){return (a<b)?a:b;}
template < typename T > void UMAX(T &a,T b){a=(a>b?a:b);}
template < typename T > void UMIN(T &a,T b){a=(a<b?a:b);}
LL readint(){
	char c=getchar();
	LL ret=0ll;
	while(!(c>='0' && c<='9')) c=getchar();
	while(c>='0' && c<='9'){
		ret=ret*10ll+(LL)(c-'0');
		c=getchar();
	}
	return ret;
}
void putint(LL v){
	if(!v){
		putchar('0');
		return;
	}
	if(v>=10ll) putint(v/10ll);
	putchar('0'+(v%10ll));
}
char readch(){
	char c=getchar();
	while(c==' '||c=='\n') c=getchar();
	return c;
}
int n,a[1000005],b[1000005],C[2][2];
int calc(int n){
	int i,j,k;
	C[0][0]=C[1][0]=C[1][1]=1;
//	for(i=0;i<n;++i){
//		printf("%d" ,b[i]);
//	}
//	printf("\n");
	int res=0;
	for(i=0;i<n;++i){
		int cd=1,a=n-1,_b=i;
		while(a || _b){
			cd&=C[a&1][_b&1];
			a/=2;_b/=2;
		}
		if(cd) res^=b[i];
	}
	return res;
}
int main(){
	int i,j,k;
	scanf("%d",&n);
	for(i=0;i<n;++i){
		a[i]=readch()-'0';
	}
	bool has1=0;
	for(i=0;i<n-1;++i){
		b[i]=abs(a[i]-a[i+1]);
		if(b[i]==1) has1=1;
	}
	if(has1){
		for(i=0;i<n-1;++i){
			if(b[i]==2) b[i]=0;
		}
		printf("%d\n",calc(n-1));
	}
	else{
		for(i=0;i<n-1;++i){
			if(b[i]==2) b[i]=1;
		}
		printf("%d\n",calc(n-1)*2);
	}
	return 0;
}

Measured memory_bytes: 8064
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *

# S = input()
# N = int(input())
# K, N = [int(x) for x in input().split()]

A, B, C, K = [int(x) for x in input().split()]

score = min(A, K)

K -= A

if K <= 0:
    print(score)
    exit(0)

K -= B

if K <= 0:
    print(score)
    exit(0)

score -= min(K, C)

print(score)


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

using namespace std;
using ll = long long;
using ld = long double;

const int INF = 1e9 + 69;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int h, w, k;
int x1, y11, x2, y2;
queue<pair<int, int>> Q;

bool valid(int a, int b) {
  return a >= 1 && a <= h && b >= 1 && b <= w;
}

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

  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif

  cin >> h >> w >> k;
  cin >> x1 >> y11;
  cin >> x2 >> y2;

  vector<vector<char>> c(h + 1, vector<char>(w + 1));
  vector<vector<bool>> vis(h + 1, vector<bool>(w + 1, 0));
  vector<vector<int>> dist(h + 1, vector<int>(w + 1, INF));
  for(int i = 1; i <= h; i++) {
    for(int j = 1; j <= w; j++) {
      cin >> c[i][j];
    }
  }

  Q.emplace(x1, y11);
  dist[x1][y11] = 0;
  while(!Q.empty()) {
    pair<int, int> cur = Q.front();
    int x = cur.first;
    int y = cur.second;
    vis[x][y] = true;
    Q.pop();
    for(int i = 0; i < 4; i++) {
      for(int j = 1; j <= k; j++) {
        int nx = x + j * dx[i];
        int ny = y + j * dy[i];
        if(!valid(nx, ny) || c[nx][ny] == '@' || dist[nx][ny] <= dist[x][y]) break;
        if(dist[nx][ny] == dist[x][y] + 1) continue;
        if(vis[nx][ny]) continue;
        dist[nx][ny] = dist[x][y] + 1;
        Q.emplace(nx, ny);
      }
    }
  }
  if(!vis[x2][y2])
    cout << -1 << '\n';
  else 
    cout << dist[x2][y2] << '\n';
  return 0;
}


Measured memory_bytes: 17212
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

bool is_prime(int n) {
    if(n == 1) return false; // 1 は素数ではない。
    for(int i = 2; i*i <= n; ++i) { // 2 <= i <= sqrt(n) に約数があれば、
        if(n % i == 0) return false; // n は素数ではない
    }
    return true;
}

int main() {
   int N;
   cin >> N;
   int cnt = 0;
   for (int i = 1; i <= 55555; i++) {
      if (!is_prime(i)) continue;
      if ((i - 1) % 5 == 0) {
         cout << i << " " << endl;
         cnt++;
      }
      if (cnt == N) break;
   }

   return 0;
}


Measured memory_bytes: 256
n = int(input())
tatelist = [input() for i in range(n)]

jlist = [sorted(tatelist[i]) for i in range(n)]
klist = ["".join(jlist[i]) for i in range(n)]

kdic = {}

count = 0
for i in range(n):
    if klist[i] in kdic.keys():
        count += kdic[klist[i]]
        kdic[klist[i]] += 1

    else:
        kdic[klist[i]] = 1

print(count)



Measured memory_bytes: 47756
/*
 * Author: Anmol Choudhary
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n"
#define deb2(x,y) cout<<"["<<#x<<"="<<x<<"] , ["<<#y<<"="<<y<<"]"<<"\n"
const ll mod = 1000000007;
const ll maxn = 500005;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
void solve()
{
    vector<pair<string,int>>v;
    int n;
    cin>>n;
    rep0(i,n){
        string s;
        cin>>s;
        int x;
        cin>>x;
        v.pb({s,x});
    }
    string s;
    cin>>s;
    int an=0;
    int i=0;
    for(i;i<n;i++) if(v[i].f==s) break;
    repp(j,i+1,n) an+=v[j].s;
    pr(an);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


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

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

	int ans = 0;
	for( int i = s.size() - 2; i > 0; i -= 2 ) {
		if( s.substr( 0, i / 2 ) == s.substr( i / 2, i / 2 ) ) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
t= list(input())
n=len(t)

words = []

# for i in range(n):
#     if i==0:
#         if t[i]=='?':
#             t[i]='D'
#     else:
#         if t[i]=='?':
#             if t[i-1]=='D':
#                 t[i]='P'
#             elif t[i-1]=='P':
#                 t[i]='D'

for i in range(n):
    if i==0:
        if t[i]=='?':
            words.append('D')
        else:
            words.append(t[i])
    else:
        if t[i]=='?':
            if t[i-1]=='D':
                words.append('D')
            elif t[i-1]=='P':
                words.append('D')
            elif t[i-1]=='?':
                words.append('D')
        else:
            words.append(t[i])


ans = ''.join(t)  
ans1 = ''.join(words)


print(ans1)

Measured memory_bytes: 12488
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <map>
using namespace std;
int main() {
	int n,ans = 0,now = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < n;i++) {
		if (now == a[i]) {
			ans--;
			now--;
		}
		else {
			ans++;
			now = a[i];
		}
	}
	cout << ans << endl;
	
	

	return 0;
}



Measured memory_bytes: 640
N,L = map(int,input().split())
buf = 0
if L > 0 :
    for i in range(1,N) :
        buf += L + (i+1) - 1
    print(buf)
elif L <= 0 and L+N-1 >= 0 :
    for i in range(N) :
        buf += L + (i+1) - 1
    print(buf)
else :
    for i in range(N-1) :
        buf += L + (i+1) - 1
    print(buf)

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


#define ll long long
#define pb push_back
#define mp make_pair
#define loop(i, a, b) for(int i = (a); i < (b); i++)
#define loopb(i, a, b) for(int i = (a); i > (b); --i)

typedef pair <int,int> ii;
typedef vector <int> vi;
typedef vector <ii> vii;
typedef vector <ll> vl;

const int mod = 1e9+7;
const int inf = 2e18+5;

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

    int h,w,i2,j2;
    cin>>h>>w;
    vector <string> a(h);
    loop(i,0,h)
      cin>>a[i];

    ll dp[h][w];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;

    loop(i,0,h){
      loop(j,0,w){
        //Iterate over right and bottom neighbours
        for(i2:{i,i+1}){
          if(i2==i)
            j2=j+1;
          else
            j2=j;
          if(i2<h && j2<w && a[i2][j2]=='.'){
            dp[i2][j2] += dp[i][j];
            dp[i2][j2] %= mod;
          }
        }
      }
    }
    cout<<dp[h-1][w-1];
    return 0;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repr(i, s, e) for(int i=s; i>=e; i--)
#define reps(i, s, e) for(int i=s; i<e; i++)
#define inf 1e18
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*b/gcd(a, b); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], int n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int keta(ll num){ int k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


int memo[1010];

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

    int n;
    cin >> n;

    rep(i, 1010){
        memo[i] = 0;
    }

    reps(i, 2, n+1){
        int num = i;
        reps(j, 2, num+1){
            while(num%j == 0){
                num /= j;
                memo[j]++;
            }
        }
    }

    ll res = 1;
    ll mod = 1e9+7;
    rep(i, 1010){
        if(memo[i] != 0){
            res *= (memo[i]+1);
            res %= mod;
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int x1,x2,x3,x4,x5;
    cin>>x1>>x2>>x3>>x4>>x5;
    if(x1==0)cout<<1<<endl;
    else if(x2==0)cout<<2<<endl;
    else if(x3==0)cout<<3<<endl;
    else if(x4==0)cout<<4<<endl;
    else cout<<5<<endl;
}


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

int main() {
  int n,m;
  cin >> n >>m;
  vector<int> l(m);
  vector<int> r(m);
  for(int i=0; i<m;i++) cin >> l[i] >> r[i];
  
  int ans=0;
  int lmax=*max_element(l.begin(),l.end());
  int rmin=*min_element(r.begin(),r.end());
  for(int i=1; i<n+1; i++) {
    if(lmax<=i&&i<=rmin) ++ans;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
n = int(input())
p = [float(x) for x in input().split()]
dp = []
for i in range(n+1):
    tp = []
    for j in range(n+1):
        tp.append(0)
    dp.append(tp)
dp[0][1] =  p[0]
dp[0][0] = 1-p[0]
for i  in range(n):
    if i<=0:
        continue
    dp[i][0] = dp[i-1][0]*(1-p[i])
    for j in range(i+1):
        dp[i][j+1] = dp[i-1][j]*p[i]
        dp[i][j+1] += dp[i-1][j+1]*(1-p[i])

k = int(n/2)+1
ans = 0
#print(dp)
for j in range(k, n+1):
    ans += dp[n-1][j]
print(ans)

Measured memory_bytes: 257160
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <string>
#include <ctime>
#include <stdio.h>
#include <string.h>

using namespace std;

#define re return
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repm(i, n) for (int i = 1; i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define vi vector<int>
#define vl vector<long>
#define vll vector<ll>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector< pair<int,int> >
#define ll long long
#define ld long double 
#define str string
// freopen("firesafe.in", "r", stdin);
// freopen("firesafe.out", "w", stdout);

//map<ll,ll>mmap;
int main(){
   int n;
   cin>>n;
   int color[100]={0};
   int a[5000];
   rep(i,n){
    cin>>a[i];
    if(a[i]>=1&& a[i]<=399){
      color[1]++;
    }
    if(a[i]>=400&& a[i]<=799){
      color[2]++;
    }
    if(a[i]>=800&& a[i]<=1199){
      color[3]++;
    }
        if(a[i]>=1200&& a[i]<=1599){
      color[4]++;
    }
        if(a[i]>=1600&& a[i]<=1999){
      color[5]++;
    }
        if(a[i]>=2000&& a[i]<=2399){
      color[6]++;
    }
        if(a[i]>=2400&& a[i]<=2799){
      color[7]++;
    }
        if(a[i]>=2800&& a[i]<=3199){
      color[8]++;
    }
    if(a[i]>=3200){
      color[9]++;
    }
   }
   int cnt=0;
   for(int i=1;i<=8;i++){
    if(color[i]!=0){
      cnt++;
    }
   }
   int mini=cnt;
   int maxi;
   if(cnt+color[9]<=100){
      maxi=cnt+color[9];
   }else{
      maxi=100;
   }
   if(cnt==0){
      mini=1;
      if(color[9]>100){
        maxi=100;
      }else{
        maxi=color[9];
      }
   }

    cout<<mini<<" "<<maxi<<endl;
}

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

int main() {
    int N;
    string S;
    cin >> N >> S;
    vector<int> l(N), r(N);
    vector<int> lp, rp;
    for(int i=0; i<N; ++i) {
        if(S[i] == '>') {
            l[i] = 1;
            lp.push_back(i);
        } else {
            r[i] = 1;
            rp.push_back(i);
        }
    }
    for(int i=0; i<N-1; ++i) {
        l[i+1] += l[i];
    }
    for(int i=N-1; i>=1; --i) {
        r[i-1] += r[i];
    }
    int res = 0;
    for(int i=0; i<N; ++i) {
        if(S[i] == '>') {
            if(l[i] > r[i]) {
                int idx = l[i] - r[i] -1;
                res = max(res, N-lp[idx]);
            } else {
                int idx = r[i] - l[i];
                res = max(res, rp[rp.size()-idx-1]+1);
            }
        } else {
            if(l[i] >= r[i]) {
                int idx = l[i] - r[i];
                res = max(res, N-lp[idx]);
            } else {
                int idx = r[i] - l[i];
                res = max(res, rp[rp.size()-idx]+1);
            }
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 4524
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream> 
#include <cmath>
#include <map>
#include <queue>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
const ll MOD=ll(1e9+7);
 
//repetition
#define REP(i,n)  for(ll i=0;i<n;i++)
 
ll P_POW(ll i, ll n) {
  if(n==0) return 1;
 
  n--;
  ll rep = i;
 
  while(n) {
    rep = rep * i;
    n--;
  }
  return rep;
} 
 
unsigned GetDigit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
 
unsigned binarySearch(ll target, ll max, ll min) {
  while((max - min) > 1) {
      if((max + min)/2 > target) {
        max = (max + min)/2;
        min = min;
      } else {
        max = max;
        min = (max + min)/2;
      }
    }
}
 
ll solve(ll n) {
    if (n % 2 == 1) return 0;
 
    ll res = 0;
    n /= 2;
    int c = 1;
 
    while ((ll) n/((ll)pow(5,c))) {
      res += n/P_POW(5,c);
      c++;
    }
    return res;
}
 
void f(int rest, string s) {
  char abc[] = "abc";
  if(rest == 0) {
    cout << s << endl;
  } else {
    for(int i=0; i < 3; i++) {
      f(rest - 1, s+abc[i]);
    }
  }
} 
 
int main() {
  // vector<vector<ll>> a(n ,vector<ll>{2,0});
  // vector
  // vector<ll> s(n,0);
  // vector<vector<ll>> v;
  // map<ll,ll> m;
  // priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
  // vector<pair<ll, ll>> epv(n, {0, 0});
  
  /* iterator
  for(auto&& m: em) {
    epv.push_back({ m.second, m.first });
  }
  */

  ll n, m;
  cin >> n >> m;

  map<ll,ll> mac;
  map<ll,ll> mwa;

  ll p;
  string s;

  ll totalwa = 0;
  ll totalac = 0;

  while(m--){
    cin >> p >> s;

    if(mac[p] == 1) continue;

    if(s == "AC") {
      mac[p] = 1;
      totalac++;
      totalwa += mwa[p];
    }
    if(s == "WA") {
      mwa[p]++;
    }
  }

  cout << totalac << " " << totalwa << endl;

}



Measured memory_bytes: 12800
typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
const int MAX = 510000;
 const int MOD = 998244353;
 long long modpow(long long a, long long n) {
      long long res = 1;
      while (n > 0) {
          if (n & 1) res = res * a % MOD;
          a = a * a % MOD;
          n >>= 1;
      }
      return res;
  }
 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;
 }
int main() {
    ll a,b,c,d;
    std::cin >> a>>b>>c>>d;
    vector<vector<ll>> dp(c-a+1,vector<ll>(d-b+1,0));
    dp[0][0]=1;
    
    for (int i = 1; i <=c-a; i++) {
        dp[i][0] = dp[i-1][0]*b%MOD;
    }
    for (int i = 1; i <= d-b; i++) {
        dp[0][i] = dp[0][i-1]*a%MOD;
    }
    
    for (int i = 0; i < c-a; i++) {
        for (int j = 0; j < d-b; j++) {
            dp[i+1][j+1] = dp[i+1][j]*(a+i+1)%MOD+dp[i][j+1]*(b+j+1)%MOD-dp[i][j]*(a+i)%MOD*(b+j)%MOD+MOD;
            dp[i+1][j+1] %= MOD;
        }
        
    }
    
    std::cout << dp[c-a][d-b] << std::endl;
}


Measured memory_bytes: 73588
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;


void solve(std::string S, std::string T){
    unsigned long int x = 0;
    for (int i=0;i<S.length(); ++i){
        if (S[i] != T[i]) {
            x++;
        }
    }

    cout << x << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 4068
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  long long  N, T;
  long long  t[200005];
  cin>>N>>T;
  REP(i,0,N) cin>>t[i];

  long long r = t[0]+T;
  long long sum = T*N;
  REP(i,1,N){
    if(t[i] < r){
      sum -= (r - t[i]);
    }
    r = t[i] + T;
  }

  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 1792
def main():
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))

    path = []
    for i in range(H):
        if i % 2 == 0:
            path += [[i, j] for j in range(W)]
        else:
            path += [[i, j] for j in range(W-1, -1, -1)]

    ans = [[0 for _ in range(W)] for _ in range(H)]
    B = []
    for i in range(N):
        B += [i+1]*A[i]

    k = 0
    for i, j in path:
        ans[i][j] = B[k]
        k += 1
    return ans


if __name__ == '__main__':
    output = main()
    for i in range(len(output)):
        print(" ".join(map(str, output[i])))

Measured memory_bytes: 4596
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;



int main() {
	int n, k, a[100000];
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int j = i;
		int count = 0;
		while (k > j) {
			j *= 2;
			count++;
		}
		a[i-1] = count;
	}
	double ans = 0;
	for (int i = 0; i < n; i++) {
		ans += pow(0.5, a[i]);
	}
	printf("%.9f", ans / n);

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int allR=0, nR=0, nL=0;
    int ans = INF;
    rep(i,n){
        if(s[i]=='E') allR += 1;
    }
    rep(i,n){
        if(s[i]=='W'){
            ans = min(ans,nL+allR-nR);
            nL += 1;
        }else{
            ans = min(ans,nL+allR-nR-1);
            nR += 1;
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 900
from collections import deque
import itertools
h,w=map(int,input().split())
s=["#"+input()+"#" for i in range(h)]
s.insert(0,'#'*(w+2))
s.append('#'*(w+2))
def dep(s,t,p,q,time):
    print(s)
    s[p][q]=min(time,s[p][q])
    time+=1
    if t[p+1][q]=="." :
        dep(s,t,p+1,q,time)
    if t[p-1][q]=="." :
        dep(s,t,p-1,q,time)
    if t[p][q+1]=="." :
        dep(s,t,p,q+1,time)
    if t[p][q-1]=="." :
        dep(s,t,p,q-1,time)
    return max(itertools.chain.from_iterable(s))

m=0
for i in range(h):
    for j in range(w):
        if s[i+1][j+1]=='.':
            t=[[-1 for l in range(w+2)] for l2 in range(h+2)]
            time=0
            q1=deque([])
            t[i+1][j+1]=time
            q1.appendleft([i+1,j+1])
            while len(q1)!=0:
                q=q1.pop()
                time=t[q[0]][q[1]]+1
                if s[q[0]+1][q[1]]=='.' and t[q[0]+1][q[1]]==-1:
                    t[q[0]+1][q[1]]=time
                    q1.appendleft([q[0]+1,q[1]])
                if s[q[0] - 1][q[1]] == '.' and t[q[0]-1][q[1]] == -1:
                    t[q[0] - 1][q[1]] = time
                    q1.appendleft([q[0] - 1, q[1]])
                if s[q[0]][q[1]+1] == '.' and t[q[0]][q[1]+1] == -1:
                    t[q[0] ][q[1]+1] = time
                    q1.appendleft([q[0] , q[1]+1])
                if s[q[0]][q[1]-1] == '.' and t[q[0]][q[1]-1] == -1:
                    t[q[0] ][q[1]-1] = time
                    q1.appendleft([q[0], q[1]-1])
            m=max(max(itertools.chain.from_iterable(t)),m)
print(m)

Measured memory_bytes: 3312
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a;
    cin>>a;
  }
  cout<<(n-m-1)<<endl;
  return 0;
}

Measured memory_bytes: 3084
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#include<cctype>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repp(i,j,n) for (int i = (j); i < (n); i++)
using namespace std;
typedef long long ll;
int main() {
    ll X;
	cin >> X;
	ll P = 100, step = 0;
	while (P < X) {
		P += P / 100;
	    step++;
	}
    cout << step << endl;
	return 0;
}


Measured memory_bytes: 3568