akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <stack>

using namespace std;

int main(){

 int a,b;
 char s;

 cin>>a>>s>>b;

 if(s == '+')
    cout<<a+b<<endl;
 else
    cout<<a-b<<endl;


return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 300

double dp[MAX_N + 1][MAX_N + 1][MAX_N + 1];
int n;

double rec(int i, int j, int k){
    if(dp[i][j][k] != -1) return dp[i][j][k];
    if(i == 0 && j == 0 && k == 0) return dp[i][j][k] = 0;
    double res = 0;
    if(i > 0) res += i * rec(i - 1, j, k);
    if(j > 0) res += j * rec(i + 1, j - 1, k);
    if(k > 0) res += k * rec(i, j + 1, k - 1);
    res += n;
    res /= i + j + k;
    return dp[i][j][k] = res;
}

signed main(){
    cin >> n;
    int a;
    int cnt[3 + 1] = {};
    rep(i,n){
        cin >> a;
        cnt[a]++;
    }
    fill(dp[0][0], dp[n + 1][0], -1);
    printf("%.12lf\n", rec(cnt[1], cnt[2], cnt[3]));
    return 0;
}

Measured memory_bytes: 213376
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    H, N = map(int, readline().split())
    A = list(map(int, readline().split()))

    if sum(A) >= H:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 83296
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	ll ans=0;
	while(n--)
	{
		ll l,r;
		cin>>l>>r;
		ans+=r-l+1;
	}
	cout<<ans<<'\n';
}

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

	int sum=0;
	for(int i=0; i<m; ++i){
		int a;
		cin >> a;
		sum += a;
	}

	cout << (sum<=n ? n-sum : -1) << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int n, arr[210], ans;
int main() {
    cin >> n;
    n *= 2;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    sort(arr, arr + n);
    for (int i = 0; i < n; i += 2) {
        ans += arr[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
n=[True]*100001
n[0]=n[1]=False
for i in range(2,317):
  if n[i]:
    for j in range(i**2,100000,i):
      n[j]=False
c=[0]*100002
for i in range(3,100001,2):
  if n[i] and n[int((i+1)/2)]:
    c[i]=c[i]+1
for i in range(3,100001):
  c[i]=c[i]+c[i-1]
for i in range(int(input())):
  a=input().split(' ')
  print(c[int(a[1])]-c[int(a[0])-1])

Measured memory_bytes: 7156
n = int(input())
jpysum = 0
btcsum = 0
for i in range(n):
  x, u = map(str, input().split())
  if u == "JPY":
    jpysum += float(x)
  else:
    btcsum += float(x)
ans = jpysum + 380000.0 * btcsum
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define cu continue
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
#define vll vector <ll>
#define dbg(n) cout<<n<<' ';

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


    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
        cin>>a[i];
    ll dp[k+1];
    memset(dp,0,sizeof dp);
    for(ll j=1;j<=k;j++)
    {
        for(ll i=0;i<n;i++)
        {
            if(j-a[i]<0)
                cu;
            dp[j]|=(dp[j-a[i]]^1);
        }
    }
    if(dp[k]&1)
        cout<<"First\n";
    else
        cout<<"Second\n";
}       


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.nextLine();
		int cnt = 0;
		
		boolean kai = true;
		
		while (S.length() > 0) {
			
			if (S.endsWith("dream")) {
				S =  new String(S.substring(0,S.length() - 5));
			} else if (S.endsWith("dreamer")) {
				S = new String(S.substring(0,S.length() - 7));
			} else if (S.endsWith("erase")) {
				S = new String(S.substring(0,S.length() - 5));
			} else if (S.endsWith("eraser")) {
				S = new String(S.substring(0,S.length() - 6));
			} else {
				kai = false;
				break;
			}
			
			if (cnt % 1000 == 0) {
				System.gc();
			}
			
			cnt++;
			
		}
		
		System.gc();
		
		if (kai == true) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
		 
		 scan.close();

	}
}

Measured memory_bytes: 211256
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll h,w;
            cin>>h>>w;
            if(h==1 || w==1)
            {
                cout<<1<<endl;
                return 0;
            }
            ll ans=h*w;
            ans=(ans+1)/2;
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define pb(n) push_back(n);
#define maxii 200005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
vector<int> vi;
vector<lln> vl;
vector<pii> vii;
vector<pll> vll;


lln arr[maxii];
lln arr2[maxii];
//bool check[maxii];
bool check2[1000][1000];
lln n,m;

int main()
{
    cin>>arr[0]>>arr[1]>>arr[2];
    sort(arr,arr+3);
    cout<<arr[0]+arr[1];
}






Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>
 
int main(void) {
    long long X;
    int ans = 1000;
    scanf("%lld", &X);

    while(X > 99) {
        int t = X % 1000;
        if(abs(753-t) < ans) {
            ans = abs(753-t);
        }
        X /= 10;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 128
//#####   #####   #####   #####   #####   #       #####   #   #//
//#   #   #   #   #       #       #   #   #       #   #   ## ##//
//#####   #####   #####   #       #####   #       #####   # # #//
//##      #   #       #   #       #   #   #       #   #   #   #//
//# #     #   #       #   #       #   #   #       #   #   #   #//
//#  #    #   #       #   #       #   #   #       #   #   #   #//
//#   #   #   #   #####   #####   #   #   #####   #   #   #   #//


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ppb pop_back
#define cs(n) cout<<n<<" "
#define cn(n) cout<<n<<"\n"
#define rep(i,j,k) for(int i=j;i<k;i++)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define deb(x) cout << #x << " " << x << endl;
ll bin(ll a, ll b, ll mod)
{
	if (b == 0)
		return 1;
	if (b % 2 == 0)
		return bin((a * a) % mod , b / 2 , mod) % mod;
	return ((a % mod) * (bin((a * a) % mod , b / 2 , mod) % mod)) % mod;
}
void solve()
{
	int n;
	cin >> n;
	ll ar[n];
	rep(i, 0, n) {
		cin >> ar[i];
	}
	ll sum = 0;
	rep(i, 0, n - 1) {
		if (ar[i + 1] < ar[i]) {
			sum += ar[i] - ar[i + 1];
			ar[i + 1] = ar[i];
		}
	}
	cout << sum;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	freopen("output.txt" , "w" , stdout);
#endif
	fastio;
	int t;
	t = 1;
	//cin>>t;
	while (t--)
	{
		solve();
	}
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
#endif
	return 0;
}

Measured memory_bytes: 5204
import math
def solve(n):

    ans = len(str(n))
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            tmp = n // i
            ans = min(ans, len(str(max(tmp, i))))

    return ans

if __name__ == "__main__":
    n = int(input())
    print(solve(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int x; cin>>x;
    if (x >= 30) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3632
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    [n, m] = li()
    broken = [int(input()) for _ in range(m)]
    mod = 10 ** 9 + 7

    pattern = [0] * (n + 1)
    pattern[0] = 1
    broken_index = 0
    checking = broken[broken_index] if len(broken) > broken_index else -1
    if checking != 1:
        pattern[1] = 1
    else:
        pattern[1] = 0
        broken_index = broken_index + 1
        checking = broken[broken_index] if len(broken) > broken_index else -1

    for i in range(2, n + 1):
        if checking != i:
            pattern[i] = (pattern[i - 2] + pattern[i - 1]) % mod
        else:
            pattern[i] = 0
            broken_index = broken_index + 1
            checking = broken[broken_index] if len(broken) > broken_index else -1
    print(pattern[n])


Measured memory_bytes: 7848
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	A, err := strconv.Atoi(scanner.Text())

	if err != nil {
		panic(err)
	}

	scanner.Scan()
	B, err := strconv.Atoi(scanner.Text())

	if err != nil {
		panic(err)
	}

	scanner.Scan()
	_, err = strconv.Atoi(scanner.Text())

	if err != nil {
		panic(err)
	}

	scanner.Scan()
	K, err := strconv.Atoi(scanner.Text())

	if err != nil {
		panic(err)
	}

	if A >= K {
		fmt.Println(K)
	} else {
		fmt.Println(A + (K-A-B)*(-1))
	}
}


Measured memory_bytes: 1776
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include <cstddef>
#include<queue>
using namespace std;

int main()
{
    int N;
    cin >> N;
    if(N % 2 == 0) cout << 0.5 <<endl;
    else cout << double((N / 2 )+ 1) / double(N) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<lint,lint> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
vector<pint> hi,lo;
lint loc(int x){
	return lo[x].fi;
}
lint hic(int x){
	return hi[x].fi;
}
int main()
{
	int n,a,b;cin>>n;
	rep(i,n){
		cin>>a>>b;hi.pb(mp(b,a));lo.pb(mp(a,b));
	}
	sort(All(hi));sort(All(lo));
	if(n%2==1){
		cout<<hic(n/2)-loc(n/2)+1<<endl;
	}
	else{
		cout<<hic(n/2)+hic(n/2-1)-loc(n/2)-loc(n/2-1)+1<<endl;
	}
}


Measured memory_bytes: 9812
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n, i, a[110], ans;
	double ave = 0, b, c=2100000000;
	cin >> n;
	for (i = 1; i <= n; i++)
	{
		cin >> a[i];
		ave += a[i];
	}
	ave /= n;
	for (i = 1; i <= n; i++)
	{
		b = a[i];
		if (c > abs(ave - b))
		{
			c = abs(ave - b);
			ans = i - 1;
			//printf("%f,%d\n", abs(ave - b), i - 1);
		}
	}
	cout << ans << endl;
}


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

typedef unsigned long long ull;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
const ull mod = 1e9 + 7;

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string S;	cin>>S;
	if(S=="ABC")	cout<< "ARC"<<endl;
	else cout<<"ABC"<<endl;


    return 0;
}




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

#define inf 100000000

int N,M;
int disL[200][200];//隣接行列の重みバージョン陸
int disS[200][200];//海
int r ;
int z[1000];
int disP[1000][200]={};

/*町番号は0からN-1とする（入力は1からN）*/

/*町Z(num)からZr（終点）への最短時間（船が町shipにある状況で）を返す
z  宅配順列の何番目か0->(r-1)
ship 船のある町番号0->N-1
*/
int recur(int num,int ship){
  int land,sea=inf,i;
  if(disP[num][ship]!=0)return disP[num][ship];
  if(num>=r-1)return 0;//ゴール
  land=disL[z[num]][z[num+1]]+recur(num+1,ship);
  
  for(i=0;i<N;i++){
    sea=min(sea,disL[ z[num] ][ship] + disS[ship][i] + disL[i][ z[num+1] ] + recur(num+1,i));
  }

  disP[num][ship]=min(land,sea);
  return disP[num][ship];
}


int main(){
  int i,j,k,x,y,t;
  char ch;
  while(true){

    for(i=0;i<1000;i++)
      for(j=0;j<200;j++)
	disP[i][j]=0;

    /*入力処理*/
    cin >>N>>M;
    if(N==0 && M==0)break;
    for(i=0;i<200;i++){
      for(j=0;j<200;j++){
	if(i!=j){
	  disL[i][j]=inf;
	  disS[i][j]=inf;
	}
	else {
	  disL[i][i]=0;
	  disS[i][i]=0;
	}
      }
    }
    

    /*陸路海路それぞれの最小値をセット*/
    for(i=0;i<M;i++){
      cin >>x>>y>>t>>ch;
      if(ch=='L'){
	disL[x-1][y-1]=min(disL[x-1][y-1],t);
	disL[y-1][x-1]=min(disL[y-1][x-1],t);
      }
      else if(ch=='S'){
	disS[x-1][y-1]=min(disS[x-1][y-1],t);
	disS[y-1][x-1]=min(disS[y-1][x-1],t);
      }
    }

    /*陸、海それぞれで各町同士の最短経路を出す*/  
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
	for(k=0;k<N;k++){
	  disL[j][k]=min(disL[j][k],disL[j][i]+disL[i][k]);
	  disS[j][k]=min(disS[j][k],disS[j][i]+disS[i][k]);
	}
      }
    }
    cin >> r;
    for(i=0;i<r;i++){
      cin >> j;
      z[i]=j-1;//町番号は0からN-1にする
    }
    cout << recur(0,z[0]) <<endl;
    
  }
}

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

// Repeat
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
// Container Util
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

int main() {
    string W; cin >> W;
    map<char,int> m;
    REP(i, W.size()) m[W[i]]++;

    REP(i, m.size()) {
        if (m[i] % 2 == 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int dp[1<<21];
int a[22][22];
int N;

void solve()
{
    dp[0] = 1;
   for(int mask = 1;mask<(1<<N);mask++){
       for(int j=0;j<N;j++)
       {
           if((mask&(1<<j) && a[__builtin_popcount(mask)-1][j]))
           {
               dp[mask] = (dp[mask] + dp[mask ^ (1<<j)])%1000000007;
           }
       }
   }
   cout<<dp[(1<<N)-1]<<"\n";
}


int main()
{
    cin>> N;
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    cin>>a[i][j];
    solve();
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int main()
{
  char s[11], t[12];
  while (scanf(" %s %s", s, t) != EOF)
  {
    t[strlen(s)] = '\0';
    printf("%s\n", !strcmp(s, t) ? "Yes" : "No");
  }
  return 0;
}

Measured memory_bytes: 3760
alfa_map = {"A":0,"B":1,"C":2,"D":3,"E":4,"F":5}
X, Y = map(str,input().split())
if alfa_map[X] > alfa_map[Y]:
  print(">")
elif alfa_map[X] < alfa_map[Y]:
  print("<")
else:
  print("=")

Measured memory_bytes: 3060
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std; 
using namespace __gnu_pbds;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
 
template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;
 
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define F0Rd(i,a) for (int i = a - 1; i >=0 ; i--)
#define FORd(i,a,b) for (int i = b - 1; i >= a; i--)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'
 
#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define print(x) cout << x << newl;
#define finish(x) return cout << x << "\n", 0;
#define bug(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " " << 
 
const int MXN = 2e5 + 5;
//const int MXN = 1e6 + 5;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
 
const int MX = 1e5 + 5;
ll DP[MX][2];
int N, x, y, vis[MX];
vi adj[MX];

void dfs(int u){
    if (vis[u]) return;
    vis[u] = 1;
    ll p0 = 1, p1 = 1;
    for (int v : adj[u]){
        if (!vis[v]){
            dfs(v);
            p0 = (p0 * (DP[v][0] + DP[v][1])) % INF;
            p1 = (p1 * DP[v][0]) % INF;
        }
    }
    DP[u][0] = p0; DP[u][1] = p1;
    return;
}




int main(){ FAST
    //ifstream cin("/Users/konwoo/input.txt");
    //ofstream cout("/Users/konwoo/output.txt");

    cin >> N;
    F0R(i,N-1){
        cin >> x >> y;
        adj[x].pb(y); adj[y].pb(x);
    }
    dfs(1);
    ll ans = (DP[1][0] + DP[1][1]) % INF;
    finish(ans);
    




    



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}


Measured memory_bytes: 11904
def main():
    n, w_max = map(int, input().split())
    dp = [[0] * (w_max + 1) for _ in range(n + 1)]
    for i1 in range(1, n + 1):
        w, v = map(int, input().split())
        for col in range(1, w_max + 1):
            if w <= col:
                dp[i1][col] = max(dp[i1 - 1][col], dp[i1 - 1][col - w] + v)
            else:
                dp[i1][col] = dp[i1 - 1][col]

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


if __name__ == '__main__':
    main()


Measured memory_bytes: 118512
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

using std::min;
using std::max;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()

ll inq(ll x, ll y, ll mod)
{
    if (y == 0) return 1;
    ll l = inq(x, y / 2, mod);
    if (y % 2) return l * l % mod * x % mod;
    return l * l % mod;
}

ll rev(ll x, ll mod)
{
    return inq(x, mod - 2, mod);
}

inline int nextInt()
{
    int x = 0;
    char c = getchar();
    int mi = (c == '-');
    if (c == '-') c = getchar();
    while ('0' <= c && c <= '9')
    {
        x = 10 * x + c - '0';
        c = getchar();
    }
    if (mi) return x * -1;
    return x;
}

int l;
int n, m;
int a[50000];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> l;
    a[1] = 1;
    for (int i = 2; i < 30; i++) a[i] = a[i - 1] * 2;
    for (int i = 2; i < 30; i++)
    {
        if (a[i] <= l)
        {
            n = i;
        }
    }
    struct t{
        int a, b, c;
    };
    vector<t> e;
    int f = 1;
    for (int i = 1; i + 1 <= n; i++)
    {
        e.push_back({i, i + 1, 0});
        e.push_back({i, i + 1, f});
        f *= 2;
    }
    int k = l - a[n];
    int cur = a[n] - 1;
    for (int j = n - 1; j >= 1; j--)
    {
        if (k >= a[j])
        {
            e.push_back({j, n, cur + 1});
            cur += a[j];
            k -= a[j];
        }
    }
    cout << n << " " << e.size() << endl;
    for (int i = 0; i < e.size(); i++)
    {
        cout << e[i].a << " " << e[i].b << " " << e[i].c << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace ABC081B_ShiftOnly
{
    public class MainClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] inp = Console.ReadLine().Split(' ').Select<string, int>(e => int.Parse(e)).ToArray();
            int cnt = 0;
            bool flag = true;
            while (flag)
            {
                if(inp.Any(e => e%2 != 0))
                {
                    break;
                }
                inp = inp.Select(e => e / 2).ToArray();

                cnt++;
            }

            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 13396
import math

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

n, m = map(int, input().split())

if n >= 2:
    x = permutations_count(n, 2)
else:
    x = 0
if m >= 2:
    y = permutations_count(m, 2)
else:
    y = 0
print((x + y)//2)

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

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define PRINT(item) cout << (item) << endl;
#define PRINT_VEC(V) \
    for (auto v : (V)) cout << v << ' ';
const int MOD = 1000000007;
/* cout << fixed << setprecision(10) << decimal << endl; */

int main() {
    /* code */
    ll N, K;
    cin >> N >> K;
    vector<ll> H(N);
    REP(i, N) { cin >> H[i]; }
    sort(H.begin(), H.end(), greater<ll>());
    ll sum;
    if (K >= N)
        sum = 0;
    else
        sum = accumulate(H.begin() + K, H.end(), 0LL);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;

int main(){ 
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll res = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] >= a[i]) {
      res += a[i - 1] - a[i];
      a[i] = a[i - 1];
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 4032
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    
    if(a < b) cout << "a < b" << endl;
    
    else if(a > b) cout << "a > b" << endl;
    
    else if(a == b) cout << "a == b" << endl;
    
    return 0;
}


Measured memory_bytes: 3104
N = int(input(), 10)
times = list(map(int, input().split()))

M = int(input(), 10)
answers = []
for _ in range(M):
    problem, become_time = tuple(map(int, input().split()))
    answer_elem = times[:]
    answer_elem[problem-1] = become_time
    answers.append(answer_elem)

for ans in answers:
    print(sum(ans))




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

int main() {
    int n;
    scanf("%d", &n);
    int h[n];
    for (int i=0; i<n; i++) {
        scanf("%d", &h[i]);
    }
    h[0]--;
    bool flag = true;
    for (int i=1; i<n; i++) {
        if (h[i]>h[i-1]) h[i]--;
        if (h[i-1]>h[i]) {
            flag = false;
            break;
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
#endif

// Loops --------------------------------------------------------------------

#define loop(i,s,e)         for(ll i=(s); i<(e); i++)
#define rloop(i,s,e)        for(ll i=(s); i>=(e); i--)
#define iter(it,var)        for(auto it=var.begin(); it!=var.end(); it++)
#define riter(it,var)       for(auto it=var.rbegin(); it!=var.rend(); it++)

// Extra --------------------------------------------------------------------

#define ull                 unsigned long long int
#define ll                  long long int
#define ld                  long double
#define endl                '\n'
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()

// Template -----------------------------------------------------------------

template <typename T> 
inline bool inrange(T a, T l, T r) {
    if(l>r) swap(l,r);
    return (a>=l and a<=r);
}
template <typename T, typename U> 
inline bool exist(T val, U &any) {
    return (any.find(val) != any.end());
}
// multiple input
template <typename T> 
inline void inp(T &any) {
    cin >> any;
}
template <typename T, typename... U> 
inline void inp(T &a, U &...b) {
    cin >> a; inp(b...);
}
// scan vector
template <typename T> 
inline istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator>>(istream &in, pair<T,U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(ll &T)
{
    string s;
    std::cin>>s;

    if(s=="ABC") {
        s = "ARC";
    }
    else {
        s = "ABC";
    }
    std::cout<<s<<endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt","r",stdin);
        freopen("D:/dhiraj/Programming/o1.txt","w",stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int t = 1;
    loop(i,1,t+1)
    {
        cerr<<"Case #"<<i<<"\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3656
N, M = map(int,input().split())
PY = [list(map(int,input().split())) for i in range(M)]
for i in range(M):
    PY[i].append(i)
PY.sort()
cnt = 1
ken = 0
for i in range(M):
    if i != 0:
        if PY[i][0]!=PY[i-1][0]:
            cnt = 1
        else: cnt += 1
    PY[i].append("0"*(6-len(str(PY[i][0])))+str(PY[i][0])+"0"*(6-len(str(cnt)))+str(cnt))
ans = sorted(PY, key =lambda x:x[2])
for i in range(M):
    print(ans[i][3])

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

int n,a[1000];

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

	cin>>n;
	REP(i,n) cin>>a[i];

	REP(i,n) {
		REP(j,i) {
			if(abs(a[i]-a[j])%(n-1)==0) {
				cout<<a[i]<<' '<<a[j]<<endl;
				return 0;
			}
		}
	}

}




Measured memory_bytes: 3228
import Data.List
import Control.Monad
import Data.Function

f :: Int -> Int -> Bool
f b k = if (n `mod` 2 == 0) && (2*b `mod` k == 0) && n > 0
        then True
        else False
    where n = (2*b`div`k-(k-1))

main :: IO ()
main = do
    fix $ \loop -> do
        b <- readLn
        unless (b == 0) $ do
            let k = head $ (filter (<= b) . filter (f b)) (reverse [1..10^5])
            let n = (2*b`div`k-(k-1)) `div` 2
            putStrLn $ show n ++ " " ++ show k
            loop
    return ()


Measured memory_bytes: 16608
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a < 10 && b < 10 ? a * b : -1) << '\n';
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	
	long long ma;
	cin>>ma;
	
	long long ans=0;
	long long a;
	
	for(int i=1;i<n;i++)
	{
		cin>>a;
		
		ma=max(ma,a);
		ans+=(ma-a);	
	}
	
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int n, q, count = 0;
  int S[10000], T[500];

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> S[i];
  }
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> T[i];
  }

  //T??????????????????????????????????????????S????????¨??????????¢????
  for(int i = 0; i < q; i++){
    //T[i] == S[j] ????????????S?????????????¢????????????¢??¢?´¢???
    for(int j = 0; j < n; j++){
      if(T[i] == S[j]){
        count++;
        break;
      }
    }
  }

  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

//////////////////////////////////////


//////////////////////////////////////

int main() {
    
    ll N;
    cin >> N;
    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll now;
    ll ans = 0;
    ll bunbo = 2;
    while (bunbo < N) {
        bunbo *= 5;
        ans += N / bunbo;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, i, j, k, c, a[105];
int main() {
    scanf("%d", &n);
    for (i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (i = 1; i <= n; ++i)
        for (j = i + 1; j <= n; ++j)
            for (k = j + 1; k <= n; ++k)
                if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k] &&
                    a[i] + a[j] > a[k] && a[i] + a[k] > a[j] &&
                    a[j] + a[k] > a[i])
                    ++c;
    printf("%d", c);
}

Measured memory_bytes: 3864
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        string[] s = Console.ReadLine().Split(' ');
        int A = int.Parse(s[0]), B = int.Parse(s[1]), K = int.Parse(s[2]);
        for (int i = 0; i < (K % 2 == 0 ? K : K - 1) / 2; i++)
        {
            //TKHS
            A = (A % 2 == 0 ? A : A - 1);
            B += A / 2;
            A /= 2;

            B = (B % 2 == 0 ? B : B - 1);
            A += B / 2;
            B /= 2;
        }
        if (K % 2 == 1) {
            A = (A % 2 == 0 ? A : A - 1);
            B += A / 2;
            A /= 2;
        }
        Console.WriteLine(A + " " + B);
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static int[] SpIntRead(char c)
    {
        return Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = strReverce(ret);
        return ret;
    }

}


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

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll, ll> pll;
typedef map< ll, ll> mll;

#define pie_value 3.14159265358979323846

int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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


	ll d, t, s;
	cin >> d >> t >> s;

	ll a = s * t;
	if (a >= d) {
		cout << "Yes" << nl;
	} else {
		cout << "No" << nl;
	}




	return 0;
}


Measured memory_bytes: 3648
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int64_t N, n_blue, n_red;
    cin >> N >> n_blue >> n_red;

    int64_t q, p;
    q = N / (n_blue + n_red);
    p = N % (n_blue + n_red);

    p = (p > n_blue) ? n_blue : p;
    cout << q * n_blue + p << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;


int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int a , b , c;
    cin >> a >> b >> c;
    cout << max(0 , b + c - a) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string as = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string ab = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------
int main() {

  ll n;
  cin >> n;
  string s[n];
  rep(i, n) cin >> s[i];

  ll cnt = 0;
  sort(s, s+n);
  string t = "";
  rep(i, n) {
    if(t!=s[i]) {
      ++cnt;
      t = s[i];
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 9860
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    n, k = map(int, input().split())
    a = []
    for i in range(k):
        d = int(input())
        ai = list(map(int, input().split()))
        a = a + ai
 
    print(n-len(set(a)))
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define REP(i,first,last) for(int i=first;i<=last;++i)
#define DOW(i,first,last) for(int i=first;i>=last;--i)
using namespace std;
char s[114514];
int main()
{
	return 0&(scanf("%s",s)&printf("%c%d%c\n",s[0],strlen(s)-2,s[strlen(s)-1]));
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdint.h>
using namespace std;

int sieve(int x)
{
  int ret = 0;
  vector<bool> v(x + 1, true);
  for (int i = 2; i <= x; i++) {
    if (v[i]) {
      ret++;
      for (int j = i + i; j <= x; j += i) {
        v[j] = false;
      }
    }
  }

  return ret;
}

int main()
{
  for (int n; cin >> n; ) {
    cout << sieve(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}


int main(void){
  string s;cin>>s;
  rep(i,s.size()){
    if(s[i] == 'L' && i%2 == 0){
      cout<<"No"<<endl;return 0;
    }else if(s[i] == 'R' && i%2 == 1){
      cout<<"No"<<endl;return 0;
    }
  }
  cout<<"Yes"<<endl;
  return 0;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;
ll n,m,a,b;
ll quick(ll a,ll b){
	ll res=1,t=a;
	while(b){
		if(b&1)res=(res*t)%mod;
		t=(t*t)%mod;
		b>>=1;
	}
	return res;
}
ll jie[N],inv[N];
void init(){
	jie[0]=inv[0]=1;
	for(int i=1;i<N;i++)jie[i]=(jie[i-1]*i)%mod,inv[i]=quick(jie[i],mod-2);
}
ll c(ll a,ll b){
	return ((jie[b]*inv[a])%mod*inv[b-a])%mod;
}
int main()
{
	init(); 
	ll a,b,n,m;
	cin>>n>>m>>a>>b; 
	ll ans=0;
	for(int i=1;i<=n-a;i++){
		ll ans1=c(b-1,b+i-2); 
		ll ans2=c(m-b-1,n-i+m-b-1);
		ans=(ans+ans1*ans2)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6756
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
#define ld long double
using namespace std;

int main()
{ 
    fast;
    ll n,k;
    cin>>n>>k;

    ll dp[k+2][n+2];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;

    ll f[10000],fi[10000],inv[10000];
    f[0]=f[1]=fi[0]=fi[1]=inv[0]=inv[1]=1;

    for(ll i=2;i<10000;i++)
    {
      f[i]=f[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      fi[i]=fi[i-1]*inv[i]%mod;
    }

    ll ans=f[n];
    ll ak;

    for(ll i=1;i<=k;i++)
    {
      cin>>ak;
     for(ll prev=0;prev<=n ;prev++)
     {
      for(ll cur=0;cur+prev<=n and cur<=ak;cur++)
        dp[i][cur+prev]=(dp[i][cur+prev]+ dp[i-1][prev]*f[n-cur]%mod*fi[cur]%mod*fi[ak-cur]%mod*fi[n-ak]%mod)%mod;
     }
    }
    cout<<f[n]*dp[k][n]%mod<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S; cin>>S;
  int K=0;
  sort(S.begin(),S.end());
  for(int i=0; i<S.size()-1;i++){
    if(S.at(i)!=S.at(i+1))
      K++;
    else continue;
  }
  if(K==S.size()-1)
    cout<<"yes"<<endl;
  else cout<<"no"<<endl;
}


Measured memory_bytes: 3564
#include<stdio.h>
main()
{
	int a,b,c,n,N,M[100],X,sum;
	scanf ("%d",&N);
	scanf ("%d",&X);
	scanf ("%d",&M[0]);
	sum=M[0];
	c=M[0];
	for (n=1;n!=N;n++){
		scanf ("%d",&M[n]);
		sum+=M[n];
		a=c-M[n];
		if(a>0){
			c=M[n];
			}
		}
	b=(X-sum)/c;
	printf ("%d",(b+N));
}

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

#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

struct edge {
    lli from;
    lli to;
    lli cost;
};
vector<edge> edges;


lli d[2001]; // 各頂点の始点からの距離
lli V;       // 頂点の数
lli E;       // 辺の数
lli r;       // 始点の番号

bool calc_shortest_path(lli start) {
    REP(i, 0, V) {
        d[i] = LLONG_MAX;
    }
    d[start] = 0;

    lli loop_count = 0;
    bool updated;
    while (true) {
        if (loop_count == V)
            return false;

        updated = false;
        REP(i, 0, (lli)edges.size()) {
            edge e = edges[i];
            if (d[e.from] == LLONG_MAX)
                continue;
            if (d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
                updated = true;
            }
        }

        loop_count++;
        if (!updated)
            break;
    }
    return true;
}

int main() {
    cin >> V >> E >> r;
    REP(i, 0, E) {
        lli s; // 始点
        lli t; // 終点
        lli d; // 重み
        cin >> s >> t >> d;
        edge e = {s, t, d};
        edges.push_back(e);
    }

    if (calc_shortest_path(r)) {
        REP(i, 0, V) {
            if (d[i] == LLONG_MAX)
                cout << "INF" << endl;
            else
                cout << d[i] << endl;
        }
    }
    else {
        cout << "NEGATIVE CYCLE" << endl;
    }



    //REP(i, 0, edges.size()) {
    //    cout << "from:   " << edges[i].from;
    //    cout << ", to:   " << edges[i].to;
    //    cout << ", cost: " << edges[i].cost << endl;
    //}
}


// 入力例
// 4 5 0
// 0 1 2
// 0 2 3
// 1 2 -5
// 1 3 1
// 2 3 2
//
// コピー用
// 4 5 0 0 1 2 0 2 3 1 2 -5 1 3 1 2 3 2




Measured memory_bytes: 3264
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int toval( char a ){
  if( a == 'A' ) return 1;
  if( a == 'C' ) return 2;
  if( a == 'G' ) return 3;
  if( a == 'T' ) return 4;
  return 0;
}  

#define TS 60000

struct _htd{
  char s[13]; // str
  struct _htd * n; // next
};
typedef struct _htd HTD;

int main(){

  int i, j;
  int n;
  int hash, found;
  char cmd[7], str[13];
  HTD * ht[TS]; // hashTable
  HTD * tp; // table pointer

  memset( ht, '\0', sizeof(ht) );

  scanf( "%d\n", &n );
  

  for( i=0; i<n; i++ ){
    scanf( "%s %s", cmd, str );

    if( cmd[0] == 'i' ){ // insert
      
      // calc hash
      hash = 0;
      for( j=0; j<strlen(str); j++ )
        hash += toval(str[j])*pow(4,j);
      hash = hash%TS;

      // find avaliable space
      if( ht[hash] == NULL ){
        ht[hash] = (HTD*)malloc(sizeof(HTD));
        tp = ht[hash];
      }else{
        tp = ht[hash];
        while( tp->n != NULL ) tp = tp->n;
        tp->n = (HTD*)malloc(sizeof(HTD));
        tp = tp->n;
      }

      strcpy( tp->s, str );

      //printf( " %d[%d+%d] <- %s\n", (hash+j)%TS, hash, j, str );
    }

    if( cmd[0] == 'f' ){ // find

      // calc hash
      hash = 0;
      for( j=0; j<strlen(str); j++ )
        hash += toval(str[j])*pow(4,j);
      hash = hash%TS;

      // find item
      found = 0;
      if( ht[hash] != NULL ){
        tp = ht[hash];
        while( tp != NULL ){
          if( strcmp( tp->s, str) == 0 ){
            found++;
             break;
          }
          tp = tp->n;  
        }
      }
      
      
      if( found ) printf( "yes\n" );
      else printf( "no\n" );
    }

  }



  return 0;

}


Measured memory_bytes: 20176