akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
  long int n,k,c=0;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(a[i]<k)
      c++;
  }
  cout<<n-c;
}
  

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int h,w;
vector<pair<long long,int> >a;
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		long long x;cin>>x;
		a.push_back(make_pair(x,i));
	}
	for(int i=0;i<w;i++)
	{
		long long x;cin>>x;
		a.push_back(make_pair(x,h+i));
	}
	sort(a.begin(),a.end());
	long long ans=0;
	int cnth=h,cntw=w;
	for(int i=0;i<a.size();i++)
	{
		ans+=a[i].first*(a[i].second<h?cnth:cntw);
		(a[i].second<h?cntw:cnth)--;
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S; cin >> S;
  int a,b,len,cou;
  cou = 0;
  len = S.length(); 
  for (int i=0; i<len; i++){
    if (S[i]!=S[len-i-1]){
      cou = cou+1;
    }
  }
  int ans;
  ans = cou/2;
  cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
  N, M = map(int, input().split())
  acs = [0] * N
  was = [0] * N

  for _ in range(M):
    p, s = input().split()
    p = int(p) - 1

    if s == 'AC':
      acs[p] = 1
    elif acs[p] == 0:
      was[p] += 1

  s = 0
  p = 0

  for a, w in zip(acs, was):
    if a == 0:
      continue

    s += 1
    p += w

  print(s, p)


if __name__ == '__main__':
  main()


Measured memory_bytes: 46808
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int gcd(int m, int n){
	return __gcd(m, n);
}

//約数の全列挙
vector<int> divisor(int n){
    vector<int> res;
    for(int i=1; i*i<=n; i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i); //計算量を減らすため
        }
    }
    sort(res.begin(),res.end());
    return res;
}

int main(){
	int n,tmp=0;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a.begin(),a.end());

	vector<int> corner(divisor(a[1]));
	sort(corner.begin(),corner.end(),greater<int>());
	for(int i=0;i<corner.size();i++){
		int c=0;
		for(int j=1;j<n;j++){
			if(a[j]%corner[i]!=0) c++;
		}
		/*if(c==1){
			tmp=max(tmp,corner[i]);
			cout<<test[i]<<endl;
			return 0;
		}*/
		if(c==0){
			tmp=max(tmp,corner[i]);
		}
	}

	vector<int> test(divisor(a[0]));
	sort(test.begin(),test.end(),greater<int>());
	for(int i=0;i<test.size();i++){
		int c=0;
		for(int j=0;j<n;j++){
			if(a[j]%test[i]!=0) c++;
		}
		if(c==1){
			tmp=max(tmp,test[i]);
			/*cout<<test[i]<<endl;
			return 0;*/
		}
		if(c==0){
			tmp=max(tmp,test[i]);
		}
	}
	int ans=max(1,tmp);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

int main(){
    int a, b, c, k;
    scanf("%d %d %d %d", &a, &b, &c, &k);
    int ans=0;

    if (k<a){
        ans = k;
    } else {
        ans+=a;
        k-=a;
    }

    if (k>=b){
        k-=b;
    } else {
        k=0;
    }

    if (k!=0){
        ans-=k;
        k-=c;
    }

    printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 3824
a=[list(map(int,input().split()))for i in range(3)]
s=a[0]+a[1]+a[2]
def f(i):
    return s[i]+s[i+2]-s[i-1]-s[i+3]
if s[0]+s[4]+s[8]==sum(s)//3 and f(1)==0 and f(2)==0 and f(4)==0 and f(5)==0 and s[8]+s[0]==s[2]+s[6]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
   int N,M;
   cin >> N >> M;
   int MAX = N*M;
   int A[MAX]={};
   int count = 0;
   for(int i=0;i<N;i++){
      int K;
      scanf("%d",&K);
      for(int j=0;j<K;j++)
      scanf("%d",&A[count++]);
   }
   sort(A,A+MAX);
   count = 0;
   int sum = 0;
   for(int i=1;i<MAX;i++){
      if(A[i]==0)continue;
      if(A[i]==A[i-1]){
         count++;
      }else{
         count = 0;
      }
      if((count+1)==N){
         sum++;
      }
      //printf("%d ",A[i]);
   }

   cout << sum << 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)
using ll = long long;
const ll mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n, k; cin >> n >> k; 
   vector<ll> A(n), B, C;
   rep(i,n){
      cin >> A[i];
      if(A[i]<0)C.push_back(A[i]);
      else B.push_back(A[i]);
   }
   sort(B.begin(), B.end());
   reverse(B.begin(), B.end());
   sort(C.begin(), C.end());
   mint ans = 1;
   int cnt=0;
   int bi=0,ci=0;
   if(k==n){
      rep(i,k)ans*=mint(A[i]);
      cout << ans << endl;
   }
   else if((int(C.size())==n) && (k%2==1)){
      rep(i,k)ans *= mint(C[n-i-1]);
      cout << ans << endl;
   }
   else{
      while(cnt != k){
         if(bi >= (int(B.size())-1)){
            if(((k-cnt)%2)==1){
               ans*=mint(B[bi]);
               cnt++;
            }
            rep(i,k-cnt){
               ans*=mint(C[ci+i]);
            }
            cnt = k;
         }
         else if(ci >= (int(C.size())-1)){
            rep(i,k-cnt){
               ans*=mint(B[bi+i]);
            }
            cnt = k;
         }
         else if((cnt==(k-1))||((B[bi]*B[bi+1])>(C[ci]*C[ci+1]))){
            ans *= mint(B[bi]);
            bi++;
            cnt++;
         }
         else{
            ans *= mint(C[ci]);
            ans *= mint(C[ci+1]);
            ci+=2;
            cnt+=2;
         }
      }
      cout << ans << endl;
   }
}


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

using namespace std;

bool check(int a) {
  int cnt = 0;
  for (int i = 1; i <= a; ++i) {
    if ((a % i) == 0) {++cnt;}
  }
  return cnt == 8;
}

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

  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    ans += check(i);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000000000000000
using namespace std;
ll dp[3001][3001][5];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int r,c;
	cin>>r>>c;
	ll a[r+1][c+1]={0};
	int k;
	cin>>k;
	for (int i=1;i<=k;i++)
	{
		ll x,y,z;
		cin>>x>>y>>z;
		a[x][y]=z;
	}

	for (int i=1;i<=r;i++)
	for (int j=1;j<=c;j++)
	for (int k=0;k<=3;k++){
		ll x=0,y=0;
		x=dp[i-1][j][0];
		if (k<3) x+=a[i][j];
		y=dp[i][j-1][k];
		if (k<3) y=max(y,dp[i][j-1][k+1]+a[i][j]);
		dp[i][j][k]=max(x,y);
	}
	cout<<dp[r][c][0]<<endl;
}

Measured memory_bytes: 425320
#include<bits/stdc++.h>
using namespace std;
long long n,k,sum;
int main()
{
	cin>>n>>k;
	for(long long i=k;i<=n+1;i++)
	{
		long long x=((i-1)*i)/2,y=((n-i+1+n)*i)/2;
		sum=(sum+(y-x+1));
	}
	cout<<sum%1000000007;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N){
    LL m = 1000000000000;
    LL a, b;
    for(LL i=1; i<= (LL)sqrt(N); i++){
        a = i;
        b = N / i;
        if(a*b == N && N%i==0){
            // cout<<a<<","<<b<<endl;
            m = min(a+b, m);
        }
    }
    // cout << a <<","<< b <<endl;
    cout<<m-2<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
	private static final long p = 1000000007;
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();



		int n = N/3;
		long ans = 0;
		for(int i=1;i<=n;i++) {
			int M = N - 3*i;
			ans = (ans + partition(M,i))%p;
		}

		System.out.println(ans);

	}

	public static long partition(long x,long d) {


		return modCombination(x+d-1,d-1,p);

	}
    public static final long modPow(long x, long n, final long mod) {
        long sum = 1;
        while (n > 0) {
            if ((n & 1) == 1) {      //ビットが立っていたら
                sum = sum * x % mod; //x^2^k1 * x^2^k2 * x^2^k3 * ・・・
            }
            x = x * x % mod;         //((x^2)^2)^2 ・・・
            n >>= 1;
        }
        return sum;
    }
    public static final long modCombination(long a, long b, final long mod) {
    	long P = 1;
    	for(long i=a;i>=a-b+1;i--) {
    		P = P*i%mod;
    	}
    	long F = 1;
    	for(long i=1;i<=b;i++) {
    		F = F*i%mod;
    	}

    	long modComb = P*modPow(F,mod-2,mod)%mod;
    	return modComb;
    }

}


Measured memory_bytes: 35520
#include <iostream>
#include <string>
int main()
{
	std::string s;
	std::cin >> s;
	int s_sub_toint = 0;
	int result = 10000;
	for (int i = 0; i < s.length() - 2; i++) {
		s_sub_toint = stoi(s.substr(i, 3));
		if (result > std::abs(753 - s_sub_toint))result = (std::abs(753-s_sub_toint));
	}
	std::cout<< result;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,x,m=0,z,y;
	cin>>n>>x;
	int a[n];
	a[n+1]=0;
	for(int i=1;i<=n;i++){cin>>a[i];}
    for(int i=1;i<n;i++){
    		z=a[i]+a[i+1]-x;
    		if(z>0){
    		m+=z;
    		if(a[i+1]<z){a[i+1]=0;}
    		else a[i+1]=a[i+1]-z;
		    }
	}
	 if(a[n]+a[n-1]-x>0)m+=a[n]+a[n+1]-x;
	cout<<m<<endl;
	return 0;		
	}

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

int main() {
    string s;
    cin >> s;
    vector<int> a(26);
    for(int i=0;i<26;i++){
        a.at(i)=0;
    }
    for(int j=0;j<s.size();j++){
        a.at(s.at(j)-'a')++;
    }
    bool ans=1;
    for(int i=0;i<26;i++){
        if(a.at(i)>=2){
            ans=0;
            break;
        }
    }
    if(ans) cout << "yes" << endl;
    else cout << "no" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
vector<vector<bool>> seat;

int main() {
	ll a, b,v,w,t;
	cin >> a >> v >> b >> w >> t;
	//cout << abs(a - b) / abs(v - w) << " " << t << endl;
	if (v == w) {
		if (a == b) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		return 0;
	}
	if (v < w) {
		if (a == b) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		return 0;
	}
	if (abs(a - b) / abs(v - w) <= t) {
		if (abs(a - b) / abs(v - w) == t) {
			if (abs(a - b) % abs(v - w) != 0) {
				cout << "NO" << endl;
				return 0;
			}
			else {
				cout << "YES" << endl;
				return 0;
			}
		}
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 3128
from collections import Counter

N = int(input())
a = [int(i) for i in input().split()]

schedule = []
m = 0
if -min(a) > max(a) :
    mv = min(a)
    mi = a.index(mv)
    
    for i in range(N-2, -1, -1) :
        while a[i] > a[i + 1] :
            a[i] += mv
            schedule.append([mi+1, i+1])
            if a[i] < mv :
                mv = a[i]
                mi = i
            m += 1
else :
    Mv = max(a)
    Mi = a.index(Mv)
    
    for i in range(1, N) :
        while a[i-1] > a[i] :
            a[i] += Mv
            schedule.append([Mi+1, i+1])
            if a[i] > Mv :
                Mv = a[i]
                Mi = i
            m += 1

print(m)
for sch in schedule :
    print(*sch)

Measured memory_bytes: 38384
import java.util.*;

class Main {
 public static void main(String[] args) {
   Scanner sc = new Scanner(System.in);
   String name = sc.next();
   
   if(name.equals("ABC")){
     System.out.println("ARC");
   }
   else{
     System.out.println("ABC");
   }
   
 }
}

Measured memory_bytes: 35600
N, M = map(int, input().split())
original_data = [tuple(map(int, input().split())) for i in range(0, N)]
#print(original_data)
pattern = [
  (1, 1, 1),
  (1, -1, 1),
  (1, 1, -1),
  (-1, 1, 1),
  (-1, -1, 1),
  (-1, 1, -1),
  (1, -1, -1),
  (-1, -1, -1),
]

max_sum = 0
for p in pattern:
  res = []
  for x, y, z in original_data:
    total = x * p[0] + y * p[1] + z * p[2]
    res.append(total)
  res.sort(reverse=True)
  max_sum = max(max_sum, sum(res[:M]))
  #print(res)
print(max_sum)


Measured memory_bytes: 74060
from math import floor

N=int(input())
OKflag=False

# Nまでの整数について算出してゆく
for n in range(1,N+1):
    if floor(n*1.08)==N: # もし計算してNと一致したら
        print(n)
        OKflag=True # 見つかったのでフラグを立てる
        break

if OKflag==False: # もし見つからなかったら
    print(":(")

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

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

  int ans = 0;
  string S;

  cin >> S;
  for(int i = 0; i < S.size(); i++){
    if(i % 2 == 0){
      if(S[i] == '1') ans++;
    } else {
      if(S[i] == '0') ans++;
    }
  }
  ans = min((int)(S.length()) - ans, ans);
  cout << ans;
}

int min(int a, int b){
  if(a < b) return a;
  return b;
}

Measured memory_bytes: 512
def main():
  import bisect
  n=int(input())
  A=sorted(list(map(int,input().split())))
  B=list(map(int,input().split()))
  C=sorted(list(map(int,input().split())))
  lb,lc=len(B),len(C)
  ans=0
  for b in B:
    ma = bisect.bisect_left(A, b)
    mc = lc-bisect.bisect_right(C, b)
    ans += ma*mc
  print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 29212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

const int MAX_N = 51;
int N, A;
ll dp[MAX_N][MAX_N][MAX_N*MAX_N];
int input[MAX_N];

void solve()
{
	dp[0][0][0]=1;
	for(int i=1;i<=N;++i)for(int j=0;j<=i;++j){
		for(int k=0;k<=2500;++k){
			if(!k){
			    if(!j) dp[i][j][k]=1;
			}
			else{
				if(j!=i) dp[i][j][k]+=dp[i-1][j][k];
				if(k>=input[i-1] && j>=1) dp[i][j][k] += dp[i-1][j-1][k-input[i-1]];
			}
		}
	}
	ll ans = 0;
	for(int n=1;n<=N;++n)for(int sum=0;sum<=2500;++sum){
		if((double)sum/n == (double)A) ans+=dp[N][n][sum];
	}
	cout << ans << endl;
}

int main()
{
	cin >> N >> A;
	for(int i=0;i<N;++i)cin >> input[i];
	solve();
	return 0;
}

Measured memory_bytes: 51072
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int ans = 0;
	for (int i = 1; i <= N; i += 2) {
		int r = sqrt(i);
		int cnt = 2;

		for (int j = r; j > 1; j--) {
			if ((j * j) == i) cnt++;
			else {
				int n = i / j;
				if ((n * j) == i) cnt += 2;
			}
		}

		if (cnt == 8) {
			ans++;
			//cout << i << endl;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e6 + 5;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
char s[MAXN];
int n, m, k, a[MAXN], b[MAXN];
int l, resa[MAXN], resb[MAXN];
stack <pair <int, int>> stk;
int main() {
	read(n), read(m), read(k);
	scanf("\n%s", s + 1);
	for (int i = 1, j = n; i <= n; i++, j--)
		a[j] = s[i] - '0';
	scanf("\n%s", s + 1);
	for (int i = 1, j = m; i <= m; i++, j--)
		b[j] = s[i] - '0';
	for (int i = max(n, m); i >= 1; i--) {
		if (a[i] + b[i] == 1) stk.emplace(i, a[i] * 2 + b[i]);
		if (a[i] + b[i] <= 1) continue;
		int lft = k, pos = i, x = 3;
		stack <pair <int, int>> add;
		while (!stk.empty()) {
			pair <int, int> tmp = stk.top();
			if (pos == tmp.first) {
				stk.pop();
				if ((x ^ tmp.second) == 3) {
					x = 3;
					if (lft) lft--;
					else break;
				} else if (x == 3) {
					x &= tmp.second;
					add.emplace(tmp.first, tmp.second ^ 3);
				}
				pos += 1;
			} else if (x == 3) {
				if (tmp.first - pos > lft) break;
				lft -= tmp.first - pos;
				pos = tmp.first;
			} else break;
		}
		if (x == 3) resa[pos + lft] = resb[pos + lft] = 1;
		else add.emplace(pos, x);
		while (!add.empty()) {
			stk.push(add.top());
			add.pop();
		}
	}
	while (!stk.empty()) {
		pair <int, int> tmp = stk.top();
		resa[tmp.first] += (tmp.second >> 1) & 1;
		resb[tmp.first] += (tmp.second) & 1;
		stk.pop();
	}
	l = max(n, m) + k;
	while (resa[l] == 0) l--;
	for (int i = l; i >= 1; i--) putchar(resa[i] + '0');
	putchar('\n');
	l = max(n, m) + k;
	while (resb[l] == 0) l--;
	for (int i = l; i >= 1; i--) putchar(resb[i] + '0');
	putchar('\n');
	return 0;
}

Measured memory_bytes: 30720
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(0,min(b,d)-max(a,c));
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )

using namespace std;
using ll = long long;
using P = pair<int,int>;

int main()
{
    int n,m; cin>>n>>m;

    vector<int> v(n);
    rep(i,n)cin>>v[i];

    ll sum=0;
    rep(i,n)sum+=v[i];

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


    rep(i , m){
            if(v[i]*4*m<sum){
                cout<<"No"<<endl;
                return 0;
            }
    }
    cout << "Yes" << endl;



    return 0;
}


Measured memory_bytes: 256
use whiteread::parse_line;

fn main() {
    let mut time: Vec<u32> = Vec::new();
    let mut ans: u32 = 0;
    for _ in 0..5 {
        time.push(parse_line().unwrap());
    }
    time.sort_by_key(|x| x % 10);
    for &t in &time {
        if t % 10 == 0 {
            ans += t;
        } else {
            ans += (t / 10 + 1) * 10;
        }
    }
    if let Some(idx) = time.iter().position(|&x| x % 10 != 0) {
        println!("{}", ans - (10 - time[idx] % 10));
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2156
#include <iostream>
#include <queue>
using namespace std;
static const int N = 101;
void bfs(int);
int n,M[N][N],d[N],u,i,j;
string color[N];
int main(){
  int inu,k,v;
  cin >> n;
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      M[i][j]=0;
    }
  }
  for(i=1;i<=n;i++){
    cin >> inu >> k;
    for(j=0;j<k;j++){
      cin >> v;
      M[inu][v]=1;
    }
  }
  bfs(1);
  for(i=1;i<=n;i++){
    if(d[i]>1000000) cout << i << ' ' << -1 << endl;
    else cout << i << ' ' << d[i] << endl;
  }
  return 0;
}
void bfs(int s){
  queue<int> q;
  for(i=1;i<=n;i++){
    color[i]="WHITE";
    d[i]=1000000000;
  }
  color[s]="GLAY";
  d[s]=0;
  q.push(s);
  while(q.empty()!=true){
    u=q.front();
    q.pop();
    for(i=1;i<=n;i++){
      if(M[u][i]&&color[i]=="WHITE"){
	color[i]="GLAY";
	d[i]=d[u]+1;
	q.push(i);
      }
    }
    color[u]="BLACK";
  }
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 1e5 + 1e4;
int n;
vector<vector<int>>dp(n);
int query(int pos1 ,int l, int r) {
	l += maxn; r += maxn;
	int res = 0;
	while (l <= r) {
		if (l % 2 == 1)res += dp[pos1][l++];
		if (r % 2 == 0)res += dp[pos1][r--];
		l /= 2; r /= 2;
	}
	return res % mod;
}
void change(int pos1,int pos2, int val) {
	pos2 += maxn;
	dp[pos1][pos2] += val;
	for (pos2 /= 2; pos2 >= 1; pos2 /= 2) {
		dp[pos1][pos2] = dp[pos1][pos2 * 2] + dp[pos1][pos2 * 2 + 1];
	}
}
signed main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int  k;
	cin >> n >> k;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];
	dp = vector<vector<int>>(n, vector<int>(2*maxn));
	for (int i = 0; i <= a[0]; i++) {
		change(0, i, 1);
		change(0, i + 1, -1);
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= k; j++) {
			int get = query(i - 1, 0, j);
			if (get > 0) {
				int left = j, right = min(k, j + a[i]);
				change(i, left, get);
				change(i, right + 1, -get);
			}
		}
	}
	int ans = query(n - 1, 0, k);
	cout << ans % mod;
	return 0;
}

Measured memory_bytes: 174080
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N,H;
    cin>>N>>H;
    int a[N],b[N];
    int am=0;
    rep(i,N) {
        cin>>a[i]>>b[i];
        am=max(am,a[i]);
    }
    sort(b,b+N);
    reverse(b,b+N);
    int ans=0;
    rep(i,N){
        if(b[i]>am){
            H-=b[i];
            ans++;
        }else break;
        if(H<=0)break;
    }
    int x=(H+am-1)/am;
    cout << ans+max(0LL,x) << endl;






}


Measured memory_bytes: 1792
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int h, w; cin >> h >> w;
    string s[h], red[h], blue[h];
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        red[i] = string(s[i]);
        blue[i] = string(s[i]);
    }
    for (int i = 0; i < h; i++) {
        red[i][0] = '#'; blue[i][w-1] = '#';
        if (0 < i && i < h-1) {
            for (int j = 1; j < w-1; j++) {
                if (i % 2) red[i][j] = '#';
                else blue[i][j] = '#';
            }
        }
    }
    for (string s : red) cout << s << endl;
    cout << endl;
    for (string s : blue) cout << s << endl;
}



Measured memory_bytes: 1536
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val vn = readLine()!!.split(" ").map(String::toInt)
    val cn = readLine()!!.split(" ").map(String::toInt)

    var x = 0
    var y = 0
    for (i in 0..(n - 1)) {
        if (vn[i] - cn[i] > 0) {
            x += vn[i]
            y += cn[i]
        }
    }
    println(x - y)
}


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

const int N=200005;
int n,ans,s,cnt[3005];
char ch[N];

int ksm(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b%2) res=res*a%2019;
		a=a*a%2019,b/=2;
	}
	return res;
}

int main()
{
	scanf("%s",ch+1),n=strlen(ch+1);
	cnt[0]=1;
	for(int i=1;i<=n;i++)
	{
		s=(s+(ch[i]-'0')*ksm(10,n-i))%2019;
//		cout<<i<<' '<<s<<endl;
		ans+=cnt[s],cnt[s]++;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 4032
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

// list up all factors
template <typename T>
set<T> factors(T a) {
    set<T> facs;
    for (T i = 1; i * i <= a; ++i) {
        if (a % i == 0) {
            facs.insert(i);
            facs.insert(a / i);
        }
    }
    return facs;
}

int main() {
    ll n;
    cin >> n;
    set<ll> fac = factors(n);
    ll ret      = INF;
    for (auto &f : fac) {
        chmin(ret, f + n / f);
    }
    cout << ret - 2 << "\n";

    return 0;
}

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

void fnInput(string& rsColor)
{
  int nColorSiz;
  cin >> nColorSiz >> rsColor;
}

int fnColorCount(string sColor)
{
  int nColorCnt = 0;
  int nBgn = 0;

  while (nBgn < sColor.size())
  {
    nColorCnt++;
    int nFoward = nBgn + 1;

    while ( nFoward < sColor.size()  &&
            sColor[nBgn] == sColor[nFoward] )
      nFoward++;

    nBgn = nFoward;
  }
  return nColorCnt;
}

int main()
{
  string sColor;

  fnInput(sColor);
  cout << fnColorCount(sColor) << endl;

  return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int K, X, i;
    scanf("%d%d", &K, &X);
    for (i=X-K+1; i<=X+K-1; i++) {
        if (i<X+K-1) printf("%d ", i);
        else printf("%d", i);
    }
    return 0;
}


Measured memory_bytes: 128
s = input()
if (s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2]):
	if s[0] == s[1] == s[2] == s[3]:
		print("No")
	else:
		print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
static const int MAX=10000;
static const int INF=(1<<20);
static const int W=0;
static const int G=1;
static const int B=2;
int n;
vector<pair<int,int> >adj[MAX];
void dijkstra(){
  priority_queue<pair<int,int> >pq;
  int color[MAX];
  int d[MAX];
  for(int i=0;i<n;i++){
    d[i]=INF;
    color[i]=W;
  }
  d[0]=0;
  pq.push(make_pair(0,0));
  color[0]=G;
  while(!pq.empty()){
    pair<int,int>f=pq.top();
    pq.pop();
    int u=f.second;
    color[u]=B;
    if(d[u]<f.first*(-1)) continue;
    for(int j=0;j<adj[u].size();j++){
      int v=adj[u][j].first;
      if(color[v]==B) continue;
      if(d[v]>d[u]+adj[u][j].second){
	d[v]=d[u]+adj[u][j].second;
	pq.push(make_pair(d[v]*(-1),v));
	color[v]=G;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<i<<" "<<(d[i]==INF ? -1 : d[i])<<endl;
  }
}
int main(){
  int k,u,v,c;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(int j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      adj[u].push_back(make_pair(v,c));
    }
  }
  dijkstra();
  return 0;
}
      


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++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;

    }
}

LL comb(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;

}

LL Bin(LL n, LL k) {
    if(k < 0 || n < k) {
        return 0;

    }
    LL ret = 1;
    for(LL i = 1; i <= k; ++i) {
        ret *= n--;
        ret /= i;

    }
    return ret;
}

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

    LL n, a, b;
    cin >> n >> a >> b;

    vector< LL > v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];

    }
    sort(all(v), greater<LL>());
    LL mn = LINF;
    LL sum = 0;
    for(int i = 0; i < a; ++i) {
        sum += v[i];
        mn = v[i];

    }

    long double avg = (double)sum / a;

    int pos = 0;
    while(v[pos] != mn) {
        ++pos;

    }

    int p = pos;
    int cnt = 0;
    while(p < n && v[p] == mn) {
        ++p; ++cnt;

    }

    if(mn != v[0]) {
        printf("%.10Lf\n%lld\n", avg, Bin(cnt, a - pos));
        return 0;

    }

    LL res = 0;
    for(int i = a; i <= b; ++i) {
        res += Bin(cnt, i - pos);

    }
    printf("%.10Lf\n%lld\n", avg, res);

    return 0;
}



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

typedef long long ll;

const int N = 4000 + 20;
ll n, ans;
string s;
map<char, int> cnt;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++)
			if (s[i] != s[j])
				ans += i - cnt[s[i]] - cnt[s[j]] + (2 * i - j >= 0 && s[2 * i - j] != s[i] && s[2 * i - j] != s[j]? -1: 0);
		cnt[s[i]]++;
	}
	return cout << ans << endl, 0;
}



Measured memory_bytes: 3664
#include <stdio.h>

int main(void)
{
    int W, H, x, y, r;
    
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    
    if(x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 584
N = int(input())
K = int(input())
x = [int(c) for c in input().split() ]

cnt = 0
for i in range(N):
    a = 0
    b = 0
    a = abs(x[i]-0)*2
    b = abs(x[i]-K)*2
    if a <= b:
        cnt += a
    else:
        cnt += b

print(cnt)

Measured memory_bytes: 9192
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
	int q,a,b;
	string s,t;
	cin>>q;
	multimap<string,int>m;
	for(;q--;){
		cin>>a;
		if(a==0)cin>>s>>b,m.emplace(s,b);
		if(a==1){cin>>s;auto it1=m.lower_bound(s),it2=m.upper_bound(s);for(;it1!=it2;++it1)cout<<it1->second<<endl;}
		if(a==2)cin>>s,m.erase(s);
		if(a==3){cin>>s>>t;auto it1=m.lower_bound(s),it2=m.upper_bound(t);for(;it1!=it2;++it1)cout<<it1->first<<' '<<it1->second<<endl;}
	}
}



Measured memory_bytes: 24844
def main():
    n, m, l = map(int, input().split())

    nm_mat = [
        [int(x) for x in input().split()]
        for _ in range(n)
    ]
    ml_mat = [
        [int(x) for x in input().split()]
        for _ in range(m)
    ]
    nl_mat = [
        [0] * l
        for _ in range(n)
    ]

    for i_n, row in enumerate(nm_mat):
        for i_l in range(l):
            col = [ml_mat[i_m][i_l] for i_m in range(m)]
            inner_product = sum(x * y for x, y in zip(row, col))

            nl_mat[i_n][i_l] = inner_product

    for row in nl_mat:
        print(" ".join(map(str, row)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 6636
import java.util.Scanner;

public class Main {
	public static long gcd(long a, long b){
		if (a < b) {
			long tmp = a;
			a = b;
			b = tmp;
		}
		if (b == 0) return a;
		return gcd(b, a%b);
	}

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        long b = Long.parseLong(sc.next());
        long c = Long.parseLong(sc.next());
        long d = Long.parseLong(sc.next());
        a -= 1;

        long lcm = c * d / gcd(c,d);
        long n = b - (b/c) - (b/d) + (b/lcm);
        long m = a - (a/c) - (a/d) + (a/lcm);
        System.out.println(n-m);
	}
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std;
int a,b;
int main(){
    scanf("%d%d",&a,&b);
    if(a>0&&b>0){
        printf("Positive\n");
    } 
    else if(max(a,b)>=0&&min(a,b)<=0||a==0||b==0){
        printf("Zero\n");
    } 
    else{
        if((abs(min(a,b))-abs(max(a,b)))%2==0) {
            printf("Negative\n");
        } 
        else{
            printf("Positive\n");
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

void kock(int n, double x1,double  y1, double  x2,double y2); 
int main(){
 
  int n;
  double x1 = 0.0, y1 = 0.0;
  double x2 = 100.0, y2 = 0.0;
 
  scanf("%d",&n);
  printf("%.8f %.8f\n",x1,y1);
  kock(n, x1,y1, x2,y2);
  printf("%.8f %.8f\n",x2,y2);
  return 0;
}
  
void kock(int n, double x1,double  y1, double  x2,double y2){
  double ox,oy, px,py, qx,qy;
  if (n > 0){
 
  ox = (2 * x1 + 1 * x2) / 3 ;
  oy = (2 * y1 + 1 * y2) / 3 ;
 
  px = (1 * x1 + 2 * x2) / 3 ;
  py = (1 * y1 + 2 * y2) / 3 ;
 
  qx = ((px - ox) * cos(M_PI / 3) - (py - oy) * sin(M_PI / 3)) + ox;
  qy = ((px - ox) * sin(M_PI / 3) + (py - oy) * cos(M_PI / 3)) + oy;
   
 
  kock(n-1, x1,y1, ox,oy);
  printf("%.8f %.8f\n",ox,oy);
  kock(n-1, ox,oy, qx,qy);
  printf("%.8f %.8f\n",qx,qy);
  kock(n-1, qx,qy, px,py);
  printf("%.8f %.8f\n",px,py);
  kock(n-1, px,py, x2,y2);
  }
}




Measured memory_bytes: 2056
n,a,b = map(int, input().split())		# 5 7 2

if a>b: a,b=b,a

ans = 0
x=0

d = b-a
if d%2==1:

	if a-1 < n-b:
		x = a-1
		ans+=x+1
		a = 1
		b = b-ans
	else:
		x = n-b
		ans+=x+1
		b = n
		a = a+ans

d = abs(b-a)

ans += d//2
print(ans)



Measured memory_bytes: 3064
N, M = map(int, input().split())

s_lst = [[False] * N for _ in range(M)]
for i in range(M):
    ks = list(map(int, input().split()))
    for j, value in enumerate(ks):
        if j != 0:
            s_lst[i][value-1] = True
p = list(map(int, input().split()))
# print(s_lst)

ans = 0
for bit in range(2**N):
    cnt = [0] * M
    for i in range(N):
        if (bit>>i) & 1 == 1:
            for j in range(M):
                if s_lst[j][i]:
                    cnt[j] += 1
    flug = True
    for i in range(M):
        if cnt[i] % 2 != p[i]:
            flug = False
    if flug:
        ans += 1
print(ans)


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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
#define int ll
int X;
int A,B,C,K;
int32_t main(){
	fast;
	cin>>A>>B>>C>>K;
	
	FOR(anum,0,K){
		FOR(bnum,0,K - anum){
			int nA = A, nB = B, nC = C;
			
			FOR(i,1,anum) nA *= 2;
			FOR(j,1,bnum) nB *= 2;
			FOR(c,1,K - anum - bnum) nC *= 2;
			
			if (nB > nA && nC > nB){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}


Measured memory_bytes: 3628
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner (System.in);
        int k = input.nextInt();
        int x = input.nextInt();
        k = k*500;
        if(k>=x) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <set>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

ll dp[2020][2020];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N,M; cin >> N >> M;
    vector<int> S(N),T(M);
    REP(i,N) cin >> S[i];
    REP(i,M) cin >> T[i];
    // init 
    REP(i,N+1) dp[i][0] = 1;
    REP(i,M+1) dp[0][i] = 1;
    for(int i=1;i<=N;++i){
        for(int j=1;j<=M;++j){
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            if(S[i-1] != T[j-1]) dp[i][j] -= dp[i-1][j-1];
            dp[i][j] = (dp[i][j] + 10*MOD) % MOD;
        }
    }
    cout << dp[N][M] << endl;

    return 0;
}

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

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


Measured memory_bytes: 4052
#include <cstdio> 
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
int N,M;
int P[100000],Y[100000]; vector<int> yd[100001];
int main () {

  scanf("%d%d",&N,&M);
  rep(i,M){
    scanf("%d%d",&P[i],&Y[i]);
    yd[P[i]].push_back(Y[i]);
  }
  rep(i,N){
    sort(ALL(yd[i+1]));
  }
  rep(i,M){
    printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(ALL(yd[P[i]]),Y[i])-yd[P[i]].begin())+1);
  }
}

Measured memory_bytes: 7680
package main
import "fmt"

func main() {

  var a int
  fmt.Scan(&a)
  var s string
  fmt.Scan(&s)
  var rcount = 0
  
  for _,val := range s {
    if val == 'R' {
      rcount++
    }
  }
  if (rcount << 1) - a > 0 {
    fmt.Printf("Yes")
  }else {
    fmt.Printf("No")
  }   
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")

using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int a,b;
    cin>>a>>b;
    if(a+b>a-b && a+b>a*b)
        cout<<a+b<<'\n';
    else if(a-b>a+b && a-b>a*b)
        cout<<a-b<<'\n';
    else if(a*b>a-b && a*b>a+b)
        cout<<a*b<<'\n';
    else
        cout<<a+b<<'\n';
    return 0;
}


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

string s;
bool p[10];

long long e()
{
    long long ans = 0;
    int i = 0;
    while(i<s.length())
    {
        long long num = 0;
        while(i<s.length() && !p[i])
        {
            num = num * 10LL + 1LL * (s[i] - '0');
            i++;
        }
        ans += num;
        p[i] = 0;
    }
    return ans;
}

void f(int i)
{
    for(int j = 0; j < 10; j++) p[j] = 0;
    int j = s.length() - 1;
    while(i)
    {
        p[j] = i & 1;
        i >>= 1;
        j--;
    }
}

int main()
{
    cin >> s;
    long long ans = 0;
    for(int i = 0; i < (1 << s.length()); i++)
    {
        f(i);
        ans += e();
    }
    cout << ans/2LL << endl;
    return 0;
}


Measured memory_bytes: 256
a, b = gets.strip.split.map(&:to_i)
max = 0
3.times do |i|
  if i == 0
    max = a + b
  elsif i == 1
    max = a - b if a - b > max
  elsif i == 2
    max = a * b if a * b > max 
  end
end
puts max


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define maxn 100010
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,a[maxn];
int main()
{
	read(n);
	for(int i=1;i<=n;i++)
		read(a[i]);
	sort(a+1,a+1+n,greater<int>());
	for(int i=1;i<=n;i++)
		if(a[i+1]<i+1)
		{
			int j=0;
			while(a[i+1+j]==i)
				j+=1;
			if(((a[i]-i)&1)||(j&1))
				puts("First");
			else
				puts("Second");
			return 0;
		}
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int long long int
#define pb push_back
#define inf 1e18
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=2e5;
int h[N+1];
int n;
int dp[N+1];
int k;
int solve(int pos){
    if(pos>n){
        return inf;
    }
    if(pos==n)
        return 0;
    if(dp[pos]!=-1)
        return dp[pos];
    int ans=inf;
    for(int i=1;i<=k;i++){
        if(pos+i<=n){
            ans=min(ans,solve(pos+i)+abs(h[pos+i]-h[pos]));
        }
    }
    return dp[pos]=ans;
}
signed main()
{
     
    CHAL_BAAP_KO_MT_SIKHA
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>h[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(1);
}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){
  char s;
  cin>>s;
  if(islower(s)){
    cout<<'a'<<endl;
  }
  else{
    cout<<'A'<<endl;
  }
  
}

Measured memory_bytes: 3552
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    private static final int INF = (int) 1e9 + 5;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        solve2(scanner, writer);
        scanner.close();
        writer.close();
    }

    public static void solve2(Scanner scanner, PrintWriter writer) {
        int n = scanner.nextInt();

        int[][] activities = new int[n][];
        for (int i = 0; i < n; i++) {
            activities[i] = new int[3];
            activities[i][0] = scanner.nextInt();
            activities[i][1] = scanner.nextInt();
            activities[i][2] = scanner.nextInt();
        }

        // dp[i][j] denote max points of day i-th if playing activity j
        int[] dp = new int[3];

        // First day
        dp[0] = activities[0][0];
        dp[1] = activities[0][1];
        dp[2] = activities[0][2];

        for (int i = 1; i < n; i++) {
            int[] new_dp = new int[3];
            new_dp[0] = Math.max(dp[1] + activities[i][0], dp[2] + activities[i][0]);
            new_dp[1] = Math.max(dp[0] + activities[i][1], dp[2] + activities[i][1]);
            new_dp[2] = Math.max(dp[0] + activities[i][2], dp[1] + activities[i][2]);

            dp = new_dp;
        }

        int ans = Math.max(dp[0], Math.max(dp[1], dp[2]));
        writer.println(ans);
    }
}


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

int main() {
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if(N <= K ){
        cout << X * N << endl;
    }
    else if(N > K ){
        cout << (X * K + Y * (N - K)) << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10; 

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   string s,t;
   cin >> s >> t;
   int ans = 0;
   f(i,0,3){
      if(s[i]==t[i]) ans++;
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
K,N=map(int,input().split())
A=list(map(int,input().split()))
a=A[N-1]-A[0]
for i in range(1,N):
    if i!=N-1:
        a=min(a,K+A[i-1]-A[i],K+A[i+1]-A[i])
    else:
        a=min(a,K+A[i-1]-A[i])
print(a)

Measured memory_bytes: 26444
#include <stdio.h>

int main(){
    char b;
    
    scanf("%c", &b);
    
    switch(b){
        case 'A':
            printf("T");
            break;
        case 'T':
            printf("A");
            break;
        case 'C':
            printf("G");
            break;
        case 'G':
            printf("C");
    } 
        
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
#define ONLINE_JUDGE
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}

const ll mod = 1e9+7;

int X[] = {0,1,0,-1,-1,-1,1,1};
int Y[] = {1,0,-1,0,-1,1,-1,1};

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

const int maxn = 10;

int main() {
#ifndef ONLINE_JUDGE
    freopen("qns.txt","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    string s;
    cin >> s;
    int res = 700;
    for(int i=0;i<3;i++) {
        if(s[i] == 'o') res += 100;
    }
    cout << res << endl;
#ifndef ONLINE_JUDGE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
gets
ary = []
["S", "H", "C", "D"].each do |a|
  13.times{|i| ary << "#{a} #{i+1}"}
end

ARGF.each_line do |line|
  data = line.chomp
  ary.delete(data) if ary.include?(data)
end
puts ary

Measured memory_bytes: 6088
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		String ans = "";
		for(int i = 0; i < n; i++) {
			ans += s.charAt(i);
			ans += t.charAt(i);
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21844