akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		int N = nextInt();
		int i = nextInt();




		System.out.println(N-i+1);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22996
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String args[] ) throws Exception {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){	
			int count = scanner.nextInt();//??????????????°??????????????????
			for(int i = 0;i<count;i++){
				double a = scanner.nextInt();//??????????????°??????????????????
				double b = scanner.nextInt();//????????????????????????????????°??????????????????
				double c = scanner.nextInt();//??????????????????3???????????°??????????????????
				double d = a*a;
				double f = b*b;
				double g = c*c;
				if(d == f+g || f== d+g || g==d+f){
					System.out.println("YES");
			    }else{
			    	System.out.println("NO");
			    }
			}
		}
    }
}

Measured memory_bytes: 33672
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

ll INF = 1000000000000000000;

int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i,n) cin >> a[i];
    ll sum = a[0];
    sort(a.begin(),a.end());
    if(a[0]==0) {
        cout<< 0 << endl;
        return 0;
    }
    for(int i = 1;i<n;i++) {
        if(sum > INF/a[i]) {
            cout << -1 << endl;
            return 0;
        }
        sum *= a[i];
    }
    if(sum > INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << sum << endl;
}



Measured memory_bytes: 4044
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        long mod = (long)Math.pow(10,9)+7;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt()-1;
        int b = sc.nextInt()-1;
        int c = sc.nextInt()-1;
        int d = sc.nextInt()-1;
        char[] s = sc.next().toCharArray();
        boolean block2 = false;
        for(int i = a; i < Math.max(c,d)-1; i++){
            if(s[i] == '#' && s[i+1] == '#'){
                block2 = true;
                break;
            }
        }
        if(block2){
            System.out.println("No");
        }else if(c < d){
            System.out.println("Yes");
        }else{
            boolean road3 = false;
            for(int i = b; i <= d; i++){
                if(s[i-1] == '.' && s[i] == '.' && s[i+1] == '.'){
                    road3 = true;
                    break;
                }
            }
            System.out.println(road3 ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 26600
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> A(N); rep(i,N) cin>>A[i];
  const ll MAX=1000000000;
  ll left=-MAX,right=MAX,mid=0;
  ll ans=0; rep(i,N) ans+=abs(A[i]-(mid+i+1));
  while(abs(right-left)>2){
    ll left_mid=(left+mid)/2;
    ll sans=0;
    rep(i,N) sans+=abs(A[i]-(left_mid+i+1));
    if(chmin(ans,sans)){
      right=mid;
      mid=left_mid;
      continue;
    }
    ll right_mid=(right+mid)/2;
    sans=0;
    rep(i,N) sans+=abs(A[i]-(right_mid+i+1));
    if(chmin(ans,sans)){
      left=mid;
      mid=right_mid;
      continue;
    }
    left=left_mid;
    right=right_mid;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int xx = x2 - x1;
    int yy = y2 - y1;
    int x3 = x2 - yy;
    int y3 = y2 + xx;
    int x4 = x3 - xx;
    int y4 = y3 - yy;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
}


Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
#include<math.h>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
#define hayai cin.tie(0);ios::sync_with_stdio(false);
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
ll mod=998244353;

int main(){
    hayai
    string s;
    cin>>s;
    int n=s.size();
    if(n%2==1) n--;
    else n-=2;
    while(n>0){
      bool ok=true;
      rep0(i,n/2){
        if(s[i]!=s[i+n/2]){
          ok=false;
        }
      }
      if(ok){
        cout<<n<<endl;
        return 0;
      }
      else{
        n-=2;
      }
    }
    cout<<n<<endl;
      return 0;
}

Measured memory_bytes: 768
from collections import deque
n,d,a=map(int,input().split())
xh=[list(map(int,input().split())) for _ in range(n)]
xh.sort()
d=2*d
ans=0
total=0
q=deque()
for i in range(n):
  x,h=xh[i]
  while len(q)>=1 and x>q[0][0]:
    total-=q.popleft()[1]
  h-=total
  if h>0:
    num=(h-1)//a+1
    damage=a*num
    ans+=num
    total+=damage
    q.append([x+d,damage])
print(ans)


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

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

string s;
int main()
{
	//freopen("in.txt", "r", stdin);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> s;
	s = s.substr(0,SZ(s) - 8);
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll a,b,c,d;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
    cin>>t;
    while(t--){
        cin>>a>>b>>c>>d;
        if(a<b){
            printf("No\n");continue;
        }
        if(b>d){
            printf("No\n");continue;
        }
        if(c>=(b-1)){
            printf("Yes\n");continue;
        }
        if(((a%b+((b-1-a%b)/gcd(b,d))*gcd(b,d))>c)) printf("No\n");
        else printf("Yes\n");

    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iostream>
#include<string>
#include<cstdlib>
using namespace std;
int main(void)
{
	int a, b, c;
	cin >> a >> b;
	if (a >= 13)
	{
		cout << b << endl;
	}
	else if (a >= 6 && a <= 12)
	{
		cout << b / 2 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}


Measured memory_bytes: 256
N = int(input())

work = sorted([list(map(int,input().split())) for i in range(N)], key = lambda x: x[1])
dead = [w[1] - w[0] for w in work]

now = 0

for i in range(N):
  if now > dead[i]:
    ans = "No"
    break
  now += work[i][0]
else:
  ans = "Yes"

print(ans)

Measured memory_bytes: 58260
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int K = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int sum = 0;
        for(int i = 0; i < N; i++)
        {
            sum += 2 * Math.Min(K - x[i], x[i]);
        }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=300005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

int n,m,k;

int main(){
	Init();
	cin>>n>>m>>k;
	ll res=0;
	for(int i=0;i<=k;i++){
		int j=k-i;
		(res+=nCk(n+m+2*k,n+2*i)*(i?nCk(n+2*i,i)-nCk(n+2*i,i-1)+mod:nCk(n+2*i,i))%mod*(j?nCk(m+2*j,j)-nCk(m+2*j,j-1)+mod:nCk(m+2*j,j)))%=mod;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 5440
fun main(args: Array<String>) = yorukatsu18c()

fun yorukatsu18c() {
    val n = readLine()!!.toInt()
    val sList = Array(n) { readLine()!! }

    val initials = listOf('M', 'A', 'R', 'C', 'H')

    val counts = initials.map { initial -> sList.count { it.startsWith(initial) } }

    val answer = counts.indices.map { i ->
        (i + 1..counts.lastIndex).map { j ->
            (j + 1..counts.lastIndex).map { k ->
                counts[i].toLong() * counts[j] * counts[k]
            }
        }
    }.flatten().flatten().sum()

    println(answer)
}


Measured memory_bytes: 43208
// abc109_a
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
  int a, b;
  cin >> a >> b;

  if (a % 2 && b % 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
from collections import deque

N, M = map(int, input().split())
e = [[] for _ in range(N)]
# e[v]: 隣接頂点リスト

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    e[a].append(b)
    e[b].append(a)

ans = [0]
ans = deque(ans)
# 0-indexedで格納、出力は1-indexedに直す

in_path = [False] * N
in_path[0] = True
# パスに含まれるか

while True:
    f = ans[0]
    for v in e[f]:
        if not in_path[v]:
            ans.appendleft(v)
            in_path[v] = True
            break
    else:
        break

while True:
    b = ans[-1]
    for v in e[b]:
        if not in_path[v]:
            ans.append(v)
            in_path[v] = True
            break
    else:
        break

print(len(ans))
print(*list(map(lambda x: x + 1, ans)))


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

#define debug(x) cout << (#x) << " is " << x << endl;
#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;

#define N 200005
lli a[N];
lli n, k;

bool ck(lli l){
	lli cnt = 0;
	for(lli i=0; i<n; i++){
		if(a[i]%l == 0) cnt += (a[i]/l)-1;
		else cnt += a[i]/l;
	}
	return cnt <= k;
}

int main()
{
    cin >> n >> k;
    lli mx = 0;
    for(lli i=0; i<n; i++){
		cin >> a[i];
		mx = max(mx, a[i]);
	}
	lli lo=1, hi=mx, mid, ans=mx;
	while(lo <= hi){
		mid = lo + (hi-lo)/2;
		if(ck(mid)){
			ans = mid;
			hi = mid-1;
		}
		else lo = mid+1;
	}
	cout << ans << endl;
     
    return 0;
}


Measured memory_bytes: 5176
#include<stdio.h>
#include<stdlib.h>
 
int main(){
  int *a;
  int i,j,n,v,l;
 
  scanf("%d",&n);
 
  a=(int *)malloc(n*sizeof(int));
 
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
   
  for(j=0;j<n;j++){
    if(j!=n-1)
      printf("%d ",a[j]);
     
    else if(j==n-1)
      printf("%d",a[j]);
     
  }
   
  printf("\n");
 
  for(i=1;i<n;i++){
    v=a[i];
    j=i-1;
 
    while(j>=0 && a[j]>v){
      a[j+1]=a[j];
      j--;
    }
 
    a[j+1]=v;
 
    for(l=0;l<n;l++){
      if(l!=n-1)
    printf("%d ",a[l]);
       
      else if(l==n-1)
    printf("%d",a[l]);
       
    }
 
    printf("\n");
  }
 
  free(a);
 
  return 0;
}


Measured memory_bytes: 2700
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int s;
	double w, h;

#if INPUT_FROM_FILE
	//std::ifstream ifs("test.txt");
	FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(fscanf(fp, "%d,%lf,%lf", &s, &w, &h) != EOF){
#else
	while(scanf("%d,%lf,%lf", &s, &w, &h) != EOF){
#endif
		if(w / (h * h) >= 25){
			std::cout << s << std::endl;
		}
	}


 
#if INPUT_FROM_FILE
	fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <vector>
#include <cstdlib>  
#include <algorithm>
#include <string>

using namespace std;
 
int main() {
    double n;cin>>n;
    double t,a;cin>>t>>a;
    double ss = 1000000000;
    int ans = 0;
    for(int i = 1;i<=n;i++){
      double h;cin>>h;
      double k = t-h*0.006;
      double sa = abs(k-a);
      if(ss >= sa){
        ss = sa;
        ans = i;
      }
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

template <typename T>
class seg {
	T t;
	using N = typename T::N;
	using F = typename T::F;
	vector<N> nt;
	vector<F> ft;
	void eval(int p, int l, int r) {
		if (ft[p] == t.IF)
			return;
		nt[p] = t.FN(ft[p], r - l, nt[p]);
		if (l + 1 < r) {
			t.FF(ft[p], ft[p + 1]);
			t.FF(ft[p], ft[p + (r - l & -2)]);
		}
		ft[p] = t.IF;
	}
	N init(N n, int p, int l, int r) {
		if (l + 1 == r)
			return nt[p] = n;
		int m = (l + r) / 2;
		return nt[p] = t.NN(init(n, p + 1, l, m), init(n, p + (r - l & -2), m, r));
	}
	N upd(int a, int b, F f, int p, int l, int r) {
		eval(p, l, r);
		if (b <= l || r <= a)
			return nt[p];
		if (a <= l && r <= b)
			return t.FN(ft[p] = f, r - l, nt[p]);
		int m = (l + r) / 2;
		return nt[p] = t.NN(upd(a, b, f, p + 1, l, m), upd(a, b, f, p + (r - l & -2), m, r));
	}
	N get(int a, int b, int p, int l, int r) {
		eval(p, l, r);
		if (b <= l || r <= a)
			return t.IN;
		if (a <= l && r <= b)
			return nt[p];
		int m = (l + r) / 2;
		return t.NN(get(a, b, p + 1, l, m), get(a, b, p + (r - l & -2), m, r));
	}
public:
	const int s;
	seg(int s) :s(s), nt(s * 2 - 1, t.IN), ft(s * 2 - 1, t.IF) {}
	seg(int s, N n) :seg(s) {
		init(n, 0, 0, s);
	}
	void upd(int a, int b, F f) {
		upd(a, b, f, 0, 0, s);
	}
	N get(int a, int b) {
		return get(a, b, 0, 0, s);
	}
};

struct Min {
	typedef int N, F;
	const N IN = 1e9;
	const F IF = 1e9;
	N NN(N m, N n) { return min(m, n); }
	N FN(F f, int, N n) { return min(f, n); }
	void FF(F f, F &g) { g = min(f, g); }
};
int b[222222];
pair<int, int> l[222222];
int main() {
	int n;
	cin >> n;
	int d = n;
	for (int i = 0; i < n; i++)
		scanf("%d", b + i), d -= b[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++)
		scanf("%d%d", &l[i].first, &l[i].second);
	sort(l, l + q);
	l[q].first = n + 1;
	seg<Min> s(n + 1);
	s.upd(0, 1, d);
	int p = 1;
	for (int i = 0;; i++) {
		for (; p < l[i].first; p++)
			s.upd(p, p + 1, s.get(p - 1, p) + b[p - 1] * 2 - 1);
		if (i == q) break;
		s.upd(l[i].second, l[i].second + 1, s.get(p - 1, l[i].second));
	}
	cout << s.get(n, n + 1) << endl;
	return 0;
}


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

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

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3
#define mod 10007

int n;
string s;
ll dp[1111][10];
map<char,ll> h;

int main(){
	cin.sync_with_stdio(false);
  cin>>n;
  cin>>s;
  h['J']=0; h['O']=1; h['I']=2;
  dp[0][1]=1;
  rep(i,n)rep(j,(1<<3)){
    rep(k,(1<<3)){
      if(((k>>h[s[i]])&1)==0||(k&j)==0)continue;
      dp[i+1][k]=(dp[i+1][k]+dp[i][j])%mod;
    }
  }
  ll res=0;
  rep(j,(1<<3)){
    res=(res+dp[n][j])%mod;
  }
  cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3232
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = 0
if(A[0] != 0):
    cnt = -1
else:
    cur = A[0]
    for i in range(1,N):
        if(A[i] - A[i-1] > 1):
            cnt = -1
            break
        elif(A[i] - A[i-1] == 1):
            cnt += 1
            cur = A[i]
        else:
            cnt += A[i]
            cur = A[i]
print(cnt)

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


int main(){
  string X, Y;
  int q;
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> X >> Y;
    vector<vector<int> > dp(X.size(), vector<int>(Y.size(), 0));
    for(int i = 0; i < X.size(); i++){
      for(int j = 0; j < Y.size(); j++){
        if(X[i] == Y[j]){
          if(i == 0 || j == 0)dp[i][j] = 1;
          else dp[i][j] = dp[i - 1][j - 1] + 1;
        }else {
          if(i == 0 && j == 0)dp[i][j] = 0;
          else if(i == 0 && j != 0)dp[i][j] = dp[i][j - 1];
          else if(i != 0 && j == 0)dp[i][j] = dp[i - 1][j];
          else dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
        }
      }
    }
    cout << dp[X.size() - 1][Y.size() - 1] << endl;
  }
}

Measured memory_bytes: 6860
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

H,W,N = map(int,input().split())
sr,sc = map(int,input().split())
S = input().rstrip()
T = input().rstrip()

taka = [('L','U'),('L','D'),('R','D'),('R','U')]
aoki = [('R','D'),('R','U'),('L','U'),('L','D')]

def sousa(x, s):
    if s == 'L':
        return [x[0], x[1]-1]
    elif s == 'R':
        return [x[0], x[1]+1]
    elif s == 'U':
        return [x[0]-1, x[1]]
    elif s == 'D':
        return [x[0]+1, x[1]]
    return x

def sousa_inv(x, s):
    if s == 'R':
        return [x[0], x[1]-1]
    elif s == 'L':
        return [x[0], x[1]+1]
    elif s == 'D':
        return [x[0]-1, x[1]]
    elif s == 'U':
        return [x[0]+1, x[1]]
    return x


def judge(x):
    if x[0]<= 0 or x[1]<=0:
        return False
    elif x[0]>H or x[1]>W:
        return False
    else:
        return True


for i in range(4):
    cur = [sr, sc]
    for s,t in zip(S,T):
        if s in taka[i]:
            cur = sousa(cur, s)
        if not judge(cur):
            print('NO')
            exit()
        if t in aoki[i]:
            cur = sousa(cur, t)
        if not judge(cur):
            cur = sousa_inv(cur, t)

print('YES')


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

int howmanytimes2 (int x){
    int count =0;
    while(x%2==0){
        count ++;
        x /=2;
    }
    return count;
}

int main() {
    int N;
    cin>>N;
    int ans =0;
    vector<int>data(N);
    rep(i,N){
        cin>>data[i];
        ans += howmanytimes2(data[i]);
    }
    cout <<ans <<endl;
}

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

using namespace std;

int main() {
    int x, y; cin >> x >> y;
    int g[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    cout << (g[x] == g[y]? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define frep(i, m, n) for(int i = m;i < n;i++)
#define frepr(i, m, n) for(int i = m;i >= n;i--)
#define vsort(v) sort(v.begin(),v.end())
#define ll long long
#define inf 999999999
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vst;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef pair<int,P> PP;
typedef pair<ll,LP> LPP;


int main(){
    ll n,m;
    cin >> n >> m;
    vector<int> a(n),b;
    rep(i,n)cin >> a[i];
    vsort(a);

    rep(i,m){
        if(b.size()==0){
            b.push_back(a[a.size()-1]/2);
            if(b[b.size()-1]<b[b.size()-2]){
                rep(j,b.size()){
                    if(b[j]>=b[b.size()-1]){
                        b.insert(b.begin()+j,b[b.size()-1]);
                        // rep(j,b.size())cout << b[j] << " ";
                        // cout << endl;
                        b.pop_back();
                        break;
                    }
                }
            }
            a.pop_back();
            
        }
        else if(a.size()==0){
            b[b.size()-1]/=2;
            if(b[b.size()-1]<b[b.size()-2]){
                rep(j,b.size()){
                    if(b[j]>=b[b.size()-1]){
                        b.insert(b.begin()+j,b[b.size()-1]);
                        // rep(j,b.size())cout << b[j] << " ";
                        // cout << endl;
                        b.pop_back();
                        break;
                    }
                }
            }
        }
        else{
            if(a[a.size()-1]>b[b.size()-1]){
                b.push_back(a[a.size()-1]/2);
                if(b[b.size()-1]<b[b.size()-2]){
                    rep(j,b.size()){
                        if(b[j]>=b[b.size()-1]){
                            b.insert(b.begin()+j,b[b.size()-1]);
                            // rep(j,b.size())cout << b[j] << " ";
                            // cout << endl;
                            b.pop_back();
                            break;
                        }
                    }
                }
                a.pop_back();
            }
            else{
                b[b.size()-1]/=2;
                if(b[b.size()-1]<b[b.size()-2]){
                    rep(j,b.size()){
                        if(b[j]>=b[b.size()-1]){
                            b.insert(b.begin()+j,b[b.size()-1]);
                            // rep(j,b.size())cout << b[j] << " ";
                            // cout << endl;
                            b.pop_back();
                            break;
                        }
                    }
                }
            }
            
        }
        // rep(j,a.size())cout << a[j] << " ";
        // cout << endl;
        // rep(j,b.size())cout << b[j] << " ";
        // cout << endl;
    }
    ll ans=0;
    rep(i,a.size()){ans+=a[i];
    // cout<<a[i]<<endl;
    }
    // cout <<"------------" <<endl;
    rep(i,b.size()){ans+=b[i];
    // cout<<a[i]<<endl;
    }
    cout << ans << endl;

    return 0;
}

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


 long long gcd(long long a, long long b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

long long lcm(long long a, long long b)
{
   return a * b / gcd(a, b);
}

int main()
{
   long long a, b;
   cin >> a >> b;

   cout  << lcm(a, b) << endl;
   return 0;
}

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

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

    for(int i=0;i<=25;i++){
        for(int j=0;j<=(100-i*4)/7;j++){
            if(N==i*4+j*7){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }

    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
struct Mod {
	ll num;
	Mod() : num(0) { ; }
	Mod(ll n) : num(n) { ; }
	operator ll() { return num; }
};

const ll mod = 1000000007;

Mod operator+(Mod a, Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator-(Mod a, Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator*(Mod a, Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator^(Mod a, ll n)
{
	if (n == 0) return Mod(1);
	Mod res = (a * a) ^ (n / 2);
	if (n % 2) res = res * a;
	return res;
}
Mod inv(Mod a) { return a ^ (mod - 2); }
Mod operator/(Mod a, Mod b) { return a * inv(b); }

Mod fact[222222];

void init()
{
	fact[0] = 1;
	REP(i, 222220) fact[i + 1] = fact[i] * (Mod)(i + 1);
}

/*
Mod fact(Mod n)
{
	if (n < 0) assert(false);
	if (n == 0 || n == 1) return 1;
	else return n*fact(n - (Mod)1);
}
*/
Mod nPk(Mod n, Mod k)
{
	if (n < 0 || k < 0 || n < k) return 0;
	return fact[n] / fact[k];
}

Mod nCk(Mod n, Mod k)
{
	if (n < 0 || k < 0 || n < k) return 0;
	return nPk(n, k) / fact[n - k];
}

Mod nHk(Mod n, Mod k)
{
	return nCk(n + k - (Mod)1, k);
}


int main()
{
	init();
	int N, M, k;
	cin >> N >> M >> k;
	Mod n(N), m(M), ans(0);
	REP(i, k + 1)
	{
		int j = k - i;
		Mod ver = nCk(m + (Mod)2 * (Mod)i, i) - nCk(m + (Mod)2 * (Mod)i, i - 1);
		Mod hor = nCk(n + (Mod)2 * (Mod)j, j) - nCk(n + (Mod)2 * (Mod)j, j - 1);
		Mod vm = M + i * 2, vh = N + j * 2;
		Mod res = ver*hor*nCk(vm+vh, vh);
		ans += res;
	}
	cout << (int)ans << endl;
	return 0;
}

Measured memory_bytes: 4836
//Bismillahir rahmanir rahim
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1000000007;
ll n;
ll arr[25][25];
ll dp[25][1<<22];
ll solve(ll pos,ll mask,ll cnt)
{
    if(pos==n+1){
        if(cnt==n) return 1LL;
        return 0LL;
    }
    ll &ret=dp[pos][mask];
    if(ret!=-1) return ret;
    ret=0;
    for(ll i=1;i<=n;i++){
        if(!(mask&(1<<i)) && arr[pos][i]==1){
            int nmask=mask;
            nmask |=(1<<i);
            ret+=solve(pos+1,nmask,cnt+1);
            ret%=mod;
        }
    }
    return ret;
}
int main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<=n;j++){
            scanf("%lld",&arr[i][j]);
        }
    }
    memset(dp,-1,sizeof(dp));
    ll ans=solve(1,0,0);
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 819456
/*********************************************************************************************/
/**                                                                                          //
//                            _ooOoo_                                                        //
//                           o8888888o                                                       //
//                           88" . "88                                                       //
//                           (| -_- |)                                                       //
//                            O\ = /O                                                        //
//                        ____/`---'\____                                                    //
//                      .   ' \\| |// `.                                                     //
//                       / \\||| : |||// \                                                   //
//                     / _||||| -:- |||||- \                                                 //
//                       | | \\\ - /// | |                                                   //
//                     | \_| ''\---/'' | |                                                   //
//                      \ .-\__ `-` ___/-. /                                                 //
//                   ___`. .' /--.--\ `. . __                                                //
//                ."" '< `.___\_<|>_/___.' >'"".                                             //
//               | | : `- \`.;`\ _ /`;.`/ - ` : | |                                          //
//                 \ \ `-. \_ __\ /__ _/ .-` / /                                             //
//         ======`-.____`-.___\_____/___.-`____.-'======                                     //
//                            `=---='                                                        //
//                                                       //                                  //
//         .............................................                                     //
//                  佛祖保佑             永无BUG                                            //
********************************************************************************************/
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
const int mod=1000000009;
int vis[10000];
int main()
{
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    int a7=0,a5=0;
    for(int i=0; i<3; i++)
    {
        if(a[i]==7)
            a7++;
        if(a[i]==5)
            a5++;
    }
    if(a7==1&&a5==2)
        cout<<"YES\n"<<endl;
    else
        cout<<"NO\n"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

int n;
string query(vector<int> &v) {
	cout << "?";
	rep(i, n) {
		cout << " " << v[i] + 1;
	}
	cout << endl;
	string res; cin >> res; return res;
}
string query2(int i) {
	vector<int> v;
	rep(j, n)v.push_back(i + j);
	return query(v);
}
void solve() {
	cin >> n;
	if (n == 1) {
		cout << "? 1" << endl;
		string res; cin >> res;
		if (res == "Red") {
			cout << "! RB" << endl;
		}
		else {
			cout << "! BR" << endl;
		}
		return;
	}
	int l = 0, r = n;
	string cl = query2(l);
	string cr = query2(r);
	while (r - l > 1) {
		int mid = (l + r) / 2;
		string c = query2(mid);
		if (c == cl)l = mid;
		else r = mid;
	}
	string ans; ans.resize(2 * n);
	int sz = 2 * n;
	int le = l, ri= (l + n) % sz;
	if (cl == "Red") {
		ans[le] = 'R';
		ans[ri] = 'B';
	}
	else {
		ans[le] = 'B';
		ans[ri] = 'R';
	}
	rep(j, n - 1) {
		int id = (le + 1 + j) % sz;
		vector<int> q;
		q.push_back(le); q.push_back(ri);
		rep(k, n - 1) {
			int iid = (le + 1 + k) % sz;
			if (j != k)q.push_back(iid);
		}
		string u = query(q);
		if (u == "-1")return;
		if (u == "Red")ans[id] = 'B';
		else ans[id] = 'R';
	}
	rep(j, n - 1) {
		int id = (ri + 1 + j) % sz;
		vector<int> q;
		q.push_back(le); q.push_back(ri);
		rep(k, n - 1) {
			int iid = (ri + 1 + k) % sz;
			if (j != k)q.push_back(iid);
		}
		string u = query(q);
		if (u == "-1")return;
		if (u == "Red")ans[id] = 'B';
		else ans[id] = 'R';
	}
	cout << "! " << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(9);
	//init();
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 724
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
neighbor = [[] for _ in range(n)]

for i in range(m):
    a, b = list(map(int, input().split()))
    neighbor[a - 1].append(b - 1)
    neighbor[b - 1].append(a - 1)

cnt = 0
for i in range(n):
    if all([h[i] > h[j] for j in neighbor[i]]):
        cnt += 1
print(cnt)

Measured memory_bytes: 29848
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#define REP(i, START, n, STEP) for(int i = START; i < (n); i += (STEP))
#define rep(i, n) REP(i, 0, n, 1)
using namespace std;

typedef long long int ll;

int main()
{
	int n, k, h, count = 0;
	cin >> n >> k;

	rep(i, n) {
		cin >> h;
		if (h >= k)count++;
	}
	cout << count;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main() {
	char str[1000] = "";
	while (1)
	{
		scanf("%s", str);
		if (strcmp(str, "0") == 0) { break; }
		
		int sum = 0;

		for (int i = 0; i < strlen(str); i++) {
			sum += (int)str[i] - (int)'0';
		}
		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 1852
s,asi=gets.split.map(&:to_i)
i=0
if asi <= s*4
  if asi%2==0
    (0..s).each do |n|
      if n*2+(s-n)*4==asi
        puts "Yes"
        i+=1
        break
      end
    end
  else
    puts "No"
    i+=1
  end
else
  puts "No"
  i+=1
end
if i==0
  puts "No"
end



Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s, t; cin >> s >> t;
    int sl = s.size();
    int tl = t.size();
    int ans = 1001001001;
    for(int i = 0; i + tl <= sl; i++){
        int cnt = 0;
        string tmp = s.substr(i, tl);
        //cout << tmp << endl;
        for(int j = 0; j < tl; j++){
            if(tmp[j] != t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
/* ex4_2
   urah  */

#include <stdio.h>
#include <math.h>

// プロトタイプ宣言
double distance(int len_hour_hand, int len_minute_hand, double hour, double minute);

int main(void){
    int len_hour_hand, len_minute_hand;
    double hour, minute, ans;

    // 入力の受け取り
    scanf("%d\t%d\t%lf\t%lf", &len_hour_hand, &len_minute_hand, &hour, &minute);
    // 関数の呼び起こし
    ans = distance(len_hour_hand, len_minute_hand, hour, minute);
    // 出力
    printf("%.9f\n", ans);

    return 0;
}

// 関数の定義
double distance(int len_hour_hand, int len_minute_hand, double hour, double minute){
    double ans, angle;

    // 二つの針の角度を求める
    angle = ((hour + minute / 60) / 12 - minute / 60) * 2 * M_PI;
    // 余弦定理
    ans = sqrt(pow(len_hour_hand, 2) + pow(len_minute_hand, 2) - 2 * len_hour_hand * len_minute_hand * cos(angle));

    return ans;
}

Measured memory_bytes: 2600
num_list = []
daikin = 0
for num in range(3):
    i = int(input())
    num_list.append(i)
num_list.sort()
daikin += num_list[0]
num_list = []
for num1 in range(2):
    i = int(input())
    num_list.append(i)
num_list.sort()
daikin += num_list[0]
daikin -= 50
print(daikin)


Measured memory_bytes: 5600
#include <iostream>

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

using namespace std;

int main() {
  int n, t;
  while (cin >> n >> t) {
    int result = 1 << 28;
    REP(i,n) {
      int a, b;
      cin >> a >> b;
      
      if (b <= t) result = min(result, a);
    }
    if (result == 1 << 28) {
      cout << "TLE" << endl;
    } else {
      cout << result << endl;
    }
  }
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

n,m,x=map(int,input().split())
A=list(map(int,input().split()))
i=bisect.bisect_left(A,x)
print(min(i,m-i))

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

using namespace std;

double solve(int N,int K){
    
    double res = 0;
    for(int i = 1; i <= N; i++){
        int point = i;
        double ansd = 1;
        while(K > point){
            ansd *= 0.50; 
            point += point;
        }
        ansd *= (1.0/ N);
        res += ansd;
    }
    

    return res;
}

int main(){
    int N,K;
    cin >> N >> K;

    double ans = 0;
    double p = solve(N,K);

    ans =  p;

    cout << setprecision(12)<<ans << endl;
    

    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
xyh = li2(N)

for c_x in range(101):
    for c_y in range(101):
        flag = 0
        left = 1
        right = float('inf')
        for i in range(N):
            #print(i, left, right)
            tmp = xyh[i][2] + abs(c_x-xyh[i][0]) + abs(c_y-xyh[i][1])
            #print(tmp, xyh[i][2])
            if xyh[i][2] > 0:
                if not(left <= tmp <= right):
                    flag = 1
                    break
                left = right = tmp
            else:
                if tmp < 1 or left > tmp:
                    flag = 1
                    break
                right = min(right, tmp)
        if not flag:
            print(c_x, c_y, right)
            exit()

Measured memory_bytes: 43740
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	const int N  = 200000;
	int n, t;
	int time[N];
	ll x = 0;
	
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> time[i];
	}
	// i人目が来てから(i + 1)人目が来るまでの間隔が
	// t秒以内なら，その間お湯は出続ける
	// t秒よりも長いなら，t秒間出続けて止まる
	// つまり，次の人が来るまでの間隔とtを比べて短い方を全ての間隔(i = 0 ～ n - 2)に対して足し合わせればよい
	// ただし，最後の人が来た後は必ずt秒間お湯が出る
	for (int i = 0; i < n - 1; i++) {
		x += min(time[i + 1] - time[i], t);
	}
	// 最後の1回
	x += t;

	cout << x << endl;

	return (0);
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("YES")  # type: str


def no():
    print("NO")  # type: str


def solve(X: int):
    if X == 3 or X == 5 or X == 7:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;

const int Mod = 1e9+7;

int add(int a, int b) {
  return (a += b) >= Mod ? a - Mod : a;
}

int sub(int a, int b) {
  return (a -= b) < 0 ? a + Mod : a;
}

int mul(int a, int b) {
  return 1ll * a * b % Mod;
}

const int N = 2e5 + 5;

int n, m, c[N], a[N];

vector<int> pos[N];

int id[N], f[N], g[N];

int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (i == 1 || a[i] != a[i - 1]) {
      c[++m] = a[i];
    }
  }
  for (int i = 1; i <= m; i++) {
    pos[c[i]].push_back(i);
    id[i] = pos[c[i]].size() - 1;
  }
  f[0] = g[0] = 1;
  for (int i = 1; i <= m; i++) {
    f[i] = f[i - 1];
    int t = id[i] - 1;
    if (t >= 0) {
      f[i] = add(f[i], g[pos[c[i]][t]]);
    }
    g[i] = f[i - 1];
    if (t >= 0) {
      g[i] = add(g[i], g[pos[c[i]][t]]);
    }
  }
  cout << f[m] << endl;
}

Measured memory_bytes: 15104
from collections import Counter
n,k=map(int,input().split())
a=list(map(int,input().split()))
a=Counter(a).most_common()
cnt=len(a)-k
ans=0
if cnt > 0:
  for i in range(cnt):
    k,v=a[-i-1]
    ans+=v
print(ans)

Measured memory_bytes: 39348
// 簡易競プロテンプレ
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(void){
 string a,b; cin >> a >> b;
 for(int i=0;i<a.size();i++){
  cout << a[i]; if (i<b.size()) cout << b[i];
 }cout << endl;
 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> edge(n);
    rep(i,0,m){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    queue<int> q;
    q.push(0);
    vector<int> ans(n, -1);
    while(!q.empty()){
        int now = q.front(); q.pop();
        for(int e: edge[now]){
            if(ans[e] == -1){
                q.push(e);
                ans[e] = now;
            }
        }
    }
    rep(i,1,n){

        if(ans[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i,1,n){
        cout << ++ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 10152
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  if(a > 8 || b > 8) cout << ":(" << endl;
  else cout << "Yay!" << endl;
}

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

int main() {
    int a[4];

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

    while (1) { 
        a[2] -= a[1];
        if (a[2] <= 0) {
            cout << "Yes";
            break;
        }

        a[0] -= a[3];
        if (a[0] <= 0) {
            cout << "No";
            break;
        }
    }
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL << 60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  int N;
  cin >> N;
  vector<pair<string,int>> pp(N);
  vector<string> str(N);
  vector<int> p(N);
  for(int i=0; i<N; i++){
    cin >> str[i] >> p[i];
    p[i] *= -1;
    pp[i] = make_pair(str[i],p[i]);
  }
  sort(pp.begin(),pp.end());
  for(auto m: pp){
    for(int i=0; i<N; i++){
      if(m.first==str[i] && m.second==p[i]){
        cout << i+1 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
def combi_mod(n, r, mod):
    child = 1
    mother = 1
    for i in range(r):
        child = child * (n-i) % mod
        mother = mother * (i+1) % mod
    return child * pow(mother, mod-2, mod) % mod

n, a, b = map(int, input().split())
mod = 10**9 + 7

ans = pow(2, n, mod) - 1
ans %= mod
ans += mod - combi_mod(n, a, mod)
ans %= mod
ans += mod - combi_mod(n, b, mod)
ans %= mod
print(ans)

Measured memory_bytes: 3188
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

S = _S()
S += 'E'
# print(S)

ans = np.zeros(len(S)+1,dtype='int')
bc = S[0]
count = 1

for i in range(1,len(S)):
    cc = S[i]
    if cc == bc:
        count += 1
        continue
    else:
        # RRRL
        if cc == 'L':
            # 切り上げ
            ans[i-1] += math.ceil(count/2)
            # 切り捨て
            ans[i] += math.floor(count/2)
            count = 1
            bc = 'L'
        # LLLR
        else:
            ans[i-count] += math.ceil(count/2)
            ans[i-count-1] += math.floor(count/2)
            count = 1
            bc = 'R'

print(*ans[:-2])


    

Measured memory_bytes: 31948
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
const int MAXN=1005,MAXM=200005;
 
int N,M;
vector<int> adj[MAXN];
int E[MAXM][2];
 
int p[MAXN][MAXN],q[MAXN][MAXN];
bool vis[MAXN];
 
void mark(int s,int u,int id,int mk[])
{
	if(u==s||vis[u])return;
	vis[u]=true;
	mk[u]=id;
	for(int i=0;i<(int)adj[u].size();i++)
		mark(s,adj[u][i],id,mk);
}
 
int main()
{
	scanf("%d%d",&N,&M);
	for(int i=1,a,b;i<=M;i++)
	{
		scanf("%d%d",&a,&b);
		E[i][0]=a;E[i][1]=b;
		adj[a].push_back(b);
	}
	
	for(int i=1;i<=N;i++)
	{
		memset(vis,0,sizeof vis);
		int id=0;
		for(int j=0;j<(int)adj[i].size();j++)
			mark(i,adj[i][j],++id,p[i]);
		memset(vis,0,sizeof vis);
		reverse(adj[i].begin(),adj[i].end());
		id=adj[i].size();
		for(int j=0;j<(int)adj[i].size();j++)
			mark(i,adj[i][j],id--,q[i]);
	}
	
	for(int i=1;i<=M;i++)
		if((p[E[i][1]][E[i][0]]>0)==(p[E[i][0]][E[i][1]]!=q[E[i][0]][E[i][1]]))
			puts("same");
		else
			puts("diff");
	
	return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 long long N;
  cin>>N;
  long long x=0;
  for(int i=1;i<N+1;i++){
    if(i%5!=0 && i%3!=0){
      x+=i;
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3648