akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

int search(vll& a, int K, vector<int>& dp){
  if(dp[K]>=0) return dp[K];
  bool flag1=false;
  bool flag2=true;
  for(ll num : a){
    if(num <= K){
      flag1=true;

      int tmp = search(a, K-num, dp);
      if(tmp%2==0 && tmp>=0){
        flag2 = false;
        return dp[K] = tmp+1;
      }
    }
  }
  if(!flag1){
    return dp[K] = 0;
  }
  if(flag2){
    return dp[K] = 0;
  }
  return dp[K] = -1;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N, K;
  cin >> N >> K;
  vll a(N);
  rep(i, 0, N){
    cin >> a[i];
  }
  sort(a.begin(), a.end(), greater<ll>());
  vector<int> dp(K+1, -1);

  if(search(a, K, dp)%2==1) printf("First\n");
  else printf("Second\n");

  return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
int H, W;
bool f[401][401];
bool used[401][401];
int x[] = {-1,  0,  1,  0};
int y[] = { 0, -1,  0,  1};
ll res1, res0;

void dfs(int h, int w) {
   used[h][w] = 1;
   if (f[h][w]) res1++;
   else res0++;
   for (int i = 0; i < 4; i++) {
      int nw = w + x[i];
      int nh = h + y[i];
      if (nw >= 0 && nw < W && nh >= 0 && nh < H) {
         if (f[h][w] != f[nh][nw]) {
            if (!used[nh][nw]) {
               dfs(nh, nw);
            }
         }
      }
   }
}

int main() {
   cin >> H >> W;
   for (int h = 0; h < H; h++) {
      string s;
      cin >> s;
      for (int w = 0; w < W; w++) {
         if (s[w] == '#') f[h][w] = 1;
         else f[h][w] = 0;
      }
   }
   ll ans = 0;
   memset(used, 0, sizeof(used));
   for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
         if (f[h][w] == 0) continue;
         if (used[h][w]) continue;
         res0 = 0;
         res1 = 0;
         dfs(h, w);
         ans += res0 * res1;
      }
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
#define N 100
#define White 0
#define Gray 1
#define Black 2
void dfs_init(void);
void dfs(int);
int tops(void);
void push(int);
void pop(void);
int next(int);

int n, M[N][N];
int color[N],d[N],f[N],co,rem[N];
int S[N*N],top=-1;

int main(){
  int i,j,u,k,v;
  for(i = 0; i < N; i++){
    for(j = 0; j < N; j++){
      M[i][j] = 0; 
    }
  }

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d %d",&u,&k);
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      M[u-1][v-1] = 1;
    }
  }

  dfs_init();
  for(i = 0; i < n; i++){
    if(color[i] == White) dfs(i);
  } 
  
  for(i = 0; i < n; i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void dfs_init(){
  int i;
  for(i = 0; i < n; i++){
    color[i] = White;
  }
}

void dfs(int r){
  int u,v;
  
  push(r);
  color[r] = Gray;
  d[r] = ++co;
  
  while(top != -1){
    u = tops();
    v = next(u);
    if(v != -1){
      if(color[v] == White){
	color[v] = Gray;
	d[v] = ++co;
	push(v);
      }
    }
    else {
      pop();
      color[u] = Black;
      f[u] = ++co;
    }
  }
}

int tops(){
  return S[top];
}

void push(int u){
  S[++top] = u;
}

void pop(){
  top--;
}

int next(int u){
  int v;
  for(v = rem[u]; v < n; v++){
    rem[u] = v + 1;
    if(M[u][v]) return v;
  }
  return -1;
}

Measured memory_bytes: 644
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func isNotBridge(n int, table [][]bool, edge [2]int) bool {
	visited := make([]bool, n)
	// 0番目の頂点からスタート
	visited[0] = true

	// 辺を取り除く
	table[edge[0]][edge[1]], table[edge[1]][edge[0]] = false, false

	// bfs
	q := make([]int, 0)
	q = append(q, 0)
	for len(q) > 0 {
		from := q[0]
		for to := range table[from] {
			if table[from][to] && !visited[to] {
				q = append(q, to)
			}
		}
		visited[from] = true
		q = q[1:]
	}

	// 辺を復活
	table[edge[0]][edge[1]], table[edge[1]][edge[0]] = true, true

	// 全ての頂点を訪れたか?
	ok := true
	for i := range visited {
		ok = ok && visited[i]
	}
	return ok
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	edges := make([][2]int, m)
	table := make([][]bool, n)
	for i := range table {
		table[i] = make([]bool, n)
	}
	for i := 0; i < m; i++ {
		a, b := nextInt()-1, nextInt()-1
		edges[i][0], edges[i][1] = a, b
		table[a][b], table[b][a] = true, true
	}

	ans := 0
	for i := range edges {
		if !isNotBridge(n, table, edges[i]) {
			ans++
		}
	}

	puts(ans)
}


Measured memory_bytes: 768
// 12_22.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
using namespace std;

string s;
int c = 0;

int main()
{
	cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '2') {
			c++;
		}
	}

	cout << c << endl;
	return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


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

using namespace std;

int n,k,cnt,ans;


int main()
{
	scanf("%d%d",&n,&k);
	string s;
	cin>>s;
	char now=s[0];
	cnt=1;
	int len=1;
	for(int i=1;i<n;i++)
	{
		if(s[i]!=now)
		{
			cnt++;
			ans=ans+len-1;
			now=s[i];
			len=1;
		}
		else
		    len++;
	}
	ans=ans+len-1;
	for(int i=1;i<=k;i++)
	{
		if(cnt==1)
		    break;
		if(cnt==2)
		{
			ans++;
			cnt--;
		}
		else
		{
			cnt=cnt-2;
			ans=ans+2;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
	int a,b,c,d,k,h;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	if(a<b){
		k=a;
	}
	else{
		k=b;
	}
	if(c<d){
		h=c;
	}
	else{
		h=d;
	}
	printf("%d\n",k+h);
	return 0;
}

Measured memory_bytes: 128
while True:
    n, x = [int(a) for a in input().split()]
    if n == x == 0:
        break
    cnt = 0
    for i in range(1, n):
        for j in range(i + 1, n):
            flag = False
            for k in range(j + 1, n + 1):
                if flag:
                    break
                if (i + j + k) == x:
                    cnt += 1
                    flag = True

    print(cnt)

Measured memory_bytes: 7728
#include <stdio.h>
#include <stdlib.h>
#define ABS(a) (((a)>(0))?a:-(a))

/* DATE 2019/09/13
ABC 131 B
URL: https://atcoder.jp/contests/abc131/tasks/abc131_b
*/

int main(void)
{
  int N, L;
  int sum = 0;
  int min;
  int flag = 0;
  int array[200] = {0};

  scanf("%d%d", &N, &L);
  for (size_t i = 0; i < N; i++) {
    array[i] = (i+1) + L - 1;
    if (array[i] == 0)flag = 1;
    sum += array[i];
  }

  if (flag == 1) {
    printf("%d\n", sum);
    return 0;
  }

  min = ABS(array[0]);
  for (size_t i = 1; i < N; i++) {
    if (ABS(array[i]) < min) {
      min = ABS(array[i]);
      flag = i;
    }
  }

  printf("%d", sum - array[flag]);
  return 0;
}


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

int main() {
  int n,a;
  cin >> n >> a;
  if(a >= n%500) cout << "Yes" << endl;
  else cout << "No"  << endl;
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <algorithm>
#include <chrono>
#include <random>
#include <vector>
#include <string>
#include <cmath>
#include <bitset>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define sq(x) ((x) * (x))
#define err(x) cerr << "["#x"]  " << (x) << "\n";
#define errp(x) cerr << "["#x"]  {" << ((x).first) << ", " << ((x).second) << "}\n";
#define errv(x) {cerr << "["#x"]  [";for(const auto& ___ : (x)) cerr << ___ << ", "; cerr << "]\n";}
#define errvn(x, n) {cerr << "["#x"]  [";for(auto ___ = 0; ___ < (n); ++___) cerr << (x)[___] << ", "; cerr << "]\n";}
#define errf() cerr << "\n\n";

//#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast, unroll-loops", "omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getrnd(int l, int r) {
    return uniform_int_distribution<int>(l, r)(rng);
}

ll getrndll(ll l, ll r) {
    return uniform_int_distribution<ll>(l, r)(rng);
}

template <typename T1, typename T2>
inline bool relax(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

template <typename T1, typename T2>
inline bool strain(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

// :::::::::::::::::::::::::::::::

const int MOD = 998244353;

int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    if (a < 0) a += MOD;
    return a;
}

int mul(int a, int b) {
    return 1LL * a * b % MOD;
}

int binpow(int a, ll n) {
    if (n < 0)
        a = binpow(a, MOD - 2), n *= -1;
    
    int res = 1;
    while (n) {
        if (n & 1)
            res = mul(res, a);
        a = mul(a, a);
        n /= 2;
    }
    return res;
}

int inv(int x) {
    return binpow(x, MOD - 2);
}

void solve() {
    int n, s;
    cin >> n >> s;
    
    vector<int> dp(s + 1, 0);
    dp[0] = binpow(2, n);
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        
        for (int j = s - x; j >= 0; --j) {
            dp[j + x] = add(dp[j + x], mul(inv(2), dp[j]));
        }
    }
    cout << dp[s] << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    srand(time(0));
    
    int t = 1;
//    cin >> t;
    while (t--)
        solve();
    
    return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8) << pow(pow(abs(x1-x2),2)+pow(abs(y1-y2),2),0.5) << endl;
    return 0;
}


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


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

    int now = 1;
    int ans = 0;
    rep(i, n) {
        if (a[i] == now) now++;
        else ans++;
    }
    if (now == 1) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 1024
PROGRAM-ID.                      ABC_044_A.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 a.
        03 anum BINARY-CHAR.

    01 chr.
        03 num BINARY-CHAR.

    01 w       PIC X(100).

    01 len     PIC 9(3).

    01 i       PIC 9(3).

    01 cnt1.
        03 cnt11 OCCURS 26.
            05 cnt PIC 9(3) VALUE ZERO.

    01 tmp     PIC 9(1).

    01 flg     PIC X(1) VALUE ZERO.

PROCEDURE                        DIVISION.
    ACCEPT w.

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(w).

    MOVE 'a' TO a.

    PERFORM VARYING i FROM 1 BY 1 UNTIL len < i
        MOVE w(i:1) TO chr
        ADD 1 TO cnt(num - anum + 1)
    END-PERFORM.

    PERFORM VARYING i FROM 1 BY 1 UNTIL 26 < i
        COMPUTE tmp = FUNCTION MOD(cnt(i), 2)
        IF ZERO < tmp THEN
            MOVE 1 TO flg
            EXIT PERFORM
        END-IF
    END-PERFORM.

    IF flg = ZERO THEN
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000001
#define pb push_back
using namespace std;

int main(){
	string s;
	cin>>s;
	bool c = false;
	for (int i = 0; i < 3; ++i)
	{
		if(s[i]=='7') c = true;
	}
 	
 	if(c) cout<<"Yes"<<endl;
 	else cout<<"No"<<endl;
return 0;
}

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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

int N, K;
vi A, F;

bool C(int t)
{
    int count = 0;
    REP(i, N)
    {
        if(A[i]*F[i] > t)
        {
            count += (A[i]*F[i]-t+F[i]-1) / F[i];
        }
    }
    return count <= K;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N >> K;
    A.resize(N);
    F.resize(N);
    REP(i, N) cin >> A[i];
    REP(i, N) cin >> F[i];
    sort(ALL(A));
    sort(ALL(F), greater<int>());
    int l = -1, r = INF;
    while(abs(r-l) > 1)
    {
        int mid = (l+r)/2;
        if(C(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

Measured memory_bytes: 3456
/* --- author: dxm --- */
#include<bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;

void qread(int &x){
	int neg=1;x=0;
	char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')neg=-1;c=getchar();}
	while(c>='0'&&c<='9')x=10*x+c-'0',c=getchar();
	x*=neg;
}

const int maxn=100005;
int n,mod;
vector<int>edge[maxn];
int dp[maxn],ans[maxn];

void dfs1(int x,int p){
	dp[x]=1;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		dfs1(y,x);
		dp[x]=1LL*dp[x]*(dp[y]+1)%mod;
	}
} 

void dfs2(int x,int p,int cur){
	ans[x]=1LL*cur*dp[x]%mod;
	vector<int>son,pre,suf;
	rep(i,edge[x].size()){
		int y=edge[x][i];
		if(y==p)continue;
		son.pb(y);
	}
	if(!son.size())return;
	int sz=son.size();
	pre.resize(sz);
	suf.resize(sz);
	pre[0]=(dp[son[0]]+1)%mod;
	REP(i,sz-1)pre[i]=1LL*pre[i-1]*(dp[son[i]]+1)%mod;
	suf[sz-1]=(dp[son[sz-1]]+1)%mod;
	for(int i=sz-2;i>=0;i--)suf[i]=1LL*suf[i+1]*(dp[son[i]]+1)%mod;
	rep(i,son.size()){
		int tmp=1LL*(!i?1:pre[i-1])*(i==sz-1?1:suf[i+1])%mod;
		dfs2(son[i],x,(1LL*cur*tmp%mod+1)%mod);
	}
}

int main(){
#ifdef FILE
	freopen("FILE.in","r",stdin);
	freopen("FILE.out","w",stdout);
#endif
	scanf("%d%d",&n,&mod);
	REP(i,n-1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge[u].pb(v);
		edge[v].pb(u);
	}
	dfs1(1,0);
	dfs2(1,0,1);
	REP(i,n)printf("%d\n",ans[i]);
#ifdef TIME
	printf("Running Time = %d ms\n",int(clock()*1000.0/CLOCKS_PER_SEC));
#endif
	return 0;
}

/*
Input:
-----------------
Output:
*/


Measured memory_bytes: 26752
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        sc.next();
        char[] s = sc.next().toCharArray();
        List<Character> ans = new LinkedList<>();
        ans.add(s[0]);
        for(int i = 0;i<s.length - 1;i++){
            if(s[i] != s[i + 1]){
                ans.add(s[i + 1]);
            }
        }
        System.out.println(ans.size());
    }
}

Measured memory_bytes: 28844
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String[] b = a.split(" ");
        int numA = Integer.parseInt(b[0]);
        int numB = Integer.parseInt(b[1]);
        int numC = Integer.parseInt(b[2]);
        if(numA + numB >= numC){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21588
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 2e5;
int N, A[Nmax];
ll K;

int main(){
	cin >> N >> K;
	for(int i=0; i<N; i++) cin >> A[i];

	vector<int> next(N, -1), pos(Nmax+1, -1);
	for(int i=0; i<N; i++){
		if(pos[A[i]]>=0){
			next[pos[A[i]]] = i;
		}
		pos[A[i]] = i;
	}
	for(int i=0; i<N; i++){
		if(next[pos[A[i]]]<0){
			next[pos[A[i]]] = i;
		}
	}

	int interval = 1;
	int idx = 0;
	while(idx!=N){
		if(next[idx]<=idx) interval++;
		idx = next[idx]+1;
	}

	K %= interval;

	//cout << K << endl;

	idx = 0;
	while(K>1){
		if(next[idx]<=idx) K--;
		idx = next[idx]+1;
		//cout << idx << " " << K << endl;
	}

	vector<int> ans;
	while(idx<N){
		if(next[idx]>idx) idx = next[idx]+1;
		else{
			ans.push_back(A[idx]);
			idx++;
		}
	}

	for(int i=0; i<ans.size(); i++) cout << ans[i] << (i==ans.size()-1?'\n':' ');

	return 0;
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector <long long> a(n + 1), dp(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    dp[1] = 1000;
    for (int i = 2; i <= n; i++)
    {
        dp[i] = dp[i - 1];
        for (int j = 1; j < n; j++)
        {
            dp[i] = max(dp[i], (dp[j] / a[j]) * a[i] + (dp[j] % a[j]));
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 3656
def mapint_inp():
    return map(int, input().split())

def intinp():
    return int(input())

A, B, C, D = mapint_inp()

t_win = True
turn = 1
while A > 0 and C > 0:
    if turn%2==1:
        C -= B
    else:
        A -= D
    turn += 1
    if A <= 0:
        t_win = False
        break
    if C <= 0:
        break

if t_win:
    print("Yes")
else:
    print("No")

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    double y, x;
} p_t;

string to_str(Int x) {
    string s = "";
    while (x > 0) {
        char a = '0' + (x % 10);
        s = a + s;
        x /= 10;
    }
    return s;
}

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> h(n);
    for (Int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(all(h), greater<Int>());
    if (k >= n) {
        dump(0);
        return 0;
    }
    Int res = 0;
    for (Int i = k; i < n; i++) {
        res += h[i];
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
const int MOD = 1e9 + 7;

int main() {
   ios_base::sync_with_stdio(0); cin.tie(0);
 	
   int n,d[105];
   cin>>n;
   for(int i =0;i<n;i++) {
   	cin>>d[i];
   } 

   int sum = 0;
   for(int i =0;i<n;i++) {
   	for(int j = i + 1 ; j< n;j++) {
   		sum += d[i] * d[j];
   	}
   }
   cout<<sum<<"\n";
   return 0;   
}

Measured memory_bytes: 256
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        N:usize,M:usize,SC:[(Usize1,char);M]
    }
    let mut ans = vec!['_'; N];
    for &(s, c) in SC.iter() {
        // println!("{:?},{},{}", ans, s, c);
        if ans[s] != '_' && ans[s] != c {
            println!("-1");
            return;
        }
        ans[s] = c;
    }
    if ans[0] == '0' && N != 1 {
        println!("-1");
        return;
    }
    if ans[0] == '_' && N != 1 {
        ans[0] = '1';
    }
    for &c in ans.iter() {
        if c == '_' {
            print!("0");
        } else {
            print!("{}", c);
        }
    }
}


Measured memory_bytes: 2164
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define gcd __gcd
#define lcm(n, m) n * m / gcd(n, m)
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define ea(i, n) for(auto&& i: n)
#define so(n) sort(n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// rtsq ルート, int 2*10^9, __gcd

int main() {
  ll A, B, a = 1;
  ci(A, B);
  for(int i = 100000; i > 1; i--){
    if(A % i == 0 && B % i == 0){
      A /= i;
      B /= i;
      a *= i;
    }
  }
  co(A * B * a);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

struct UnionFind {
    vector<int> par;
    UnionFind(int N) : par(N) {
        rep(i, N) par[i] = -1;
    }
    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        if (par[rx] > par[ry]) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind UF0(N), UF1(N);
    rep(i, K) {
        int p, q;
        cin >> p >> q;
        --p;
        --q;
        UF0.unite(p, q);
    }
    rep(i, L) {
        int r, s;
        cin >> r >> s;
        --r;
        --s;
        UF1.unite(r, s);
    }
    map<pair<int, int>, int> cnt;
    rep(i, N) ++cnt[pair<int, int>{UF0.root(i), UF1.root(i)}];
    rep(i, N) cout << cnt[pair<int, int>{UF0.root(i), UF1.root(i)}] << "\n";
    return 0;
}


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

class Point {
public:
	int x, y;
	Point(int x = 0, int y = 0) :x(x), y(y) {}
	Point operator + (Point p) {
		return Point(x + p.x, y + p.y);
	}
	Point operator - (Point p) {
		return Point(x - p.x, y - p.y);
	}
	bool operator == (const Point &p) const {
		return (x == p.x && y == p.y);
	}
};

class Constellation {
public:
	vector<Point> stars;
	void move(int x, int y) {
		Point p(x, y);
		for (int i = 0; i < stars.size(); i++) {
			stars[i] = stars[i] + p;
		}
	}
	bool doesMatch(vector<Point> v) {
		for (int i = 0; i < stars.size(); i++) {
			int j;
			for (j = 0; j < v.size(); j++) {
				if (stars[i] == v[j])break;
			}
			if (j == v.size())return false;
		}
		return true;
	}
};


int main() {
	int i, n, m, x, y;
	

	while (1) {
		cin >> m;
		if (m == 0)break;
		Constellation c;
		vector<Point> s;
		for (i = 0; i < m; i++) {
			cin >> x >> y;
			Point p(x, y);
			c.stars.push_back(p);
		}

		cin >> n;
		for (i = 0; i < n; i++) {
			cin >> x >> y;
			Point p(x, y);
			s.push_back(p);
		}

		//cout << endl;
		int diffx, diffy;
		for (i = 0; i < n; i++) {
			diffx = s[i].x - c.stars[0].x;
			diffy = s[i].y - c.stars[0].y;
			c.move(diffx, diffy);
			if (c.doesMatch(s)) {
				cout << diffx << " " << diffy << endl;
				break;
			}
			c.move(-1 * diffx, -1 * diffy);
		}
	}

	


	return 0;
}

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    int n;
    cin >> n;
    int ans = 0;
    for (int a = 1; a < n; a++)
    {
        ans += (n - 1) / a;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<ll> D(N);
  for(int i=0;i<N;i++) {
    ull a;
    cin >> a;
    int num=0;
    for(int ind=0;(1<<ind) <= a;ind++) {
      if( a&(1<<ind) ) {
        num = ind;
        break;
      }
    }
    D[i]=num;
  }
  sort(D.begin(),D.end());
  cout << D[0] << endl;
}

Measured memory_bytes: 256
n = int(input())
x = []
y = []
xy = []
maxlist = []
minlist = []
amax = 0
amin = 10**10
case1 = 0
case2 = 0
for i in range(n):
    store = [int(j) for j in input().split(' ')]
    if store[0] < store[1]:
        store[0], store[1] = store[1], store[0]
    if store[0] == amax:
        maxlist.append(i)
    elif store[0] > amax:
        amax = store[0]
        maxlist = [i]
    if store[1] == amin:
        minlist.append(i)
    elif store[1] < amin:
        amin = store[1]
        minlist = [i]
    x.append(store[0])
    y.append(store[1])
    xy.extend(store)

case1 = (max(x) - min(x)) * (max(y)-min(y))
for k in maxlist:
    if k in minlist:
        print(case1)
        exit()
for index in range(n):
    y[index] = [y[index], index]
y.sort()

bmax = y[n-1][0]
bmin = y[1][0]
xmin = 10**10
check = True
minsum = 10**10
for i in range(0, n-1):
    if x[y[i][1]] < xmin:
        xmin = x[y[i][1]]
    if x[y[i][1]] > bmax:
        bmax = x[y[i][1]]
    if check and xmin <= y[i+1][0]:
        bmin = xmin
        check = False
    elif check:
        bmin = y[i+1][0]
    if minsum > bmax - bmin:
        minsum = bmax - bmin
    if not check:
        break
case2 = minsum * (amax-amin)
print(min([case1, case2]))


Measured memory_bytes: 48184
def solve(lis_height,lis_width):
    h=len(lis_height)
    w=len(lis_width)
    dic = {}
    for i in range(h):
        k=0
        for j in range(i,h):
            k+=lis_height[j]
            if k in dic:
                dic[k]+=1
            else:
                dic[k]=1
    ans = 0
    #print(dic)
    #print(w,'a')
    for i in range(w):
        k=0
        for j in range(i,w):
            k+=lis_width[j]
           # print(j)
            if k in dic:
                ans += dic[k]
                #print(k,dic[k])

    print(ans)


while True:
    h,w=[int(i) for i in input().split(' ')]
   # print(a)
    if h == 0:
        break
    lis_h =[]
    lis_w=[]
    for i in range(h):
        lis_h.append(int(input()))
    for i in range(w):
        lis_w.append(int(input()))

    solve(lis_h,lis_w)



Measured memory_bytes: 34924
n, m = map(int,input().split())

broken = [0] * (n+1)
dp = [0] * (n+1)

for _ in range(m):
  broken[int(input())] = 1

dp[0] = 1

if broken[1] == 1:
  dp[1] = 0
else:
  dp[1] = 1

if n == 1:
  print(dp[n])
  exit()
else:
  for i in range(2, n+1):
    if broken[i] == 1:
      continue
    else:
      dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
      if dp[i] == 0 and dp[i-1] == 0:
        print(0)
        exit()

print(dp[n])

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

using namespace std;

int main(){
  long long a, b;
  string b_s;
  cin >> a >> b_s;
  b = (b_s[0] - '0')*100 + (b_s[2] - '0')*10 + (b_s[3] -'0');
  cout << a*b /100 << endl;
}



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

typedef long long int ll;
#define pb push_back

int main()
{
   ll n,i,j,k;
   ll mn=1e8;

   cin>>n;

   ll a[n];

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

   for(i=1;i<n;i++)
   {
    a[i]+=a[i-1];
   }

   for(i=0;i<n-1;i++)
   {
        mn=min(mn,abs(a[n-1]-2*a[i]));
   }
   cout<<mn;
}

Measured memory_bytes: 256
<?php

$resultArray = [];

while (true) {

    $inputArray = explode(' ', fgets(STDIN));

    $tyukan = $inputArray[0];
    $kimatu = $inputArray[1];
    $sai = $inputArray[2];
    
    if ($tyukan == -1 && $kimatu == -1 && $sai) {
        break;
    }
    
    if ($tyukan == -1 || $kimatu == -1) {
        $resultArray[] = 'F';
        continue;
    }
    
    $scoreSum = $tyukan + $kimatu;
    
    if ($scoreSum >= 80) {
        $resultArray[] = 'A';
    } else if ($scoreSum >= 65) { 
        $resultArray[] = 'B';
    } else if ($scoreSum >= 50) {
        $resultArray[] = 'C';
    } else if ($scoreSum >= 30) {
        $resultArray[] = getJudgeSaiScore($sai);
    } else {
        $resultArray[] = 'F';
    }
    
}

echo implode(PHP_EOL, $resultArray), PHP_EOL;

function getJudgeSaiScore($sai) {
    return $sai >= 50 ? 'C' : 'D';    
}


Measured memory_bytes: 9296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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


void solve(long long K){
    int x = 7%K;
    set<int> s;
    int i = 1;
    while(s.count(x) == 0){
        if(x == 0){
            cout << i << endl;
            return;
        }
        s.insert(x);
        x = (x*10 + 7) %K;
        i++;
    }
    cout << -1 << endl;
    return;
}

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


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

#define MAX_N 21
#define MAX_M 21

int main() {
	int A[MAX_N][MAX_M] = {0}, B[MAX_M] = {0};
	int N, M, C;
	int cnt = 0;
	cin >> N >> M >> C;
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = 0; j < M; j++) {
			sum += A[i][j]*B[j];
		}
		sum += C;
		if (sum > 0)
			cnt++;
	}
	cout << cnt << endl;
}


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

using namespace std;

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

	int num = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == '+') {
			num = num + 1;
		}
		else {
			num = num - 1;
		}
	}

	cout << num << endl;
}


Measured memory_bytes: 256
import bisect

n, m, k = map(int, input().split())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]

for i in range(1, n):
    a[i] += a[i-1]
for i in range(1, m):
    b[i] += b[i-1]

a = [0] + a
b = [0] + b

ans = 0

for i in range(n+1):
    can = k - a[i]
    if can < 0:
        break
    j = bisect.bisect_right(b, can)
    ans = max(ans, i+j-1)
print(ans)

Measured memory_bytes: 111488
N = int(input())
A = list(map(int,input().split()))
money = 1000
stock = 0
for i in range(N - 1):
    if A[i] > A[i + 1]:
        money += stock * A[i]
        stock = 0
    elif A[i] < A[i + 1]:
        stock += money // A[i]
        money %= A[i]
money += stock * A[N - 1]
print(money)


Measured memory_bytes: 61900
import java.util.Scanner;

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

        if (scanner.hasNextLine()) {
            String[] array = scanner.nextLine().split(" ");
            int H = Integer.parseInt(array[0]);
            int W = Integer.parseInt(array[1]);
            String[] board = new String[H];

            for (int i = 0; i < H; ++i) {
                board[i] = scanner.nextLine();
            }
            for (int y = 0; y < H; ++y) {
                for (int x = 0; x < W; ++x) {
                    if (board[y].charAt(x) == '#') {
                        boolean notFound = true;
                        if (y - 1 >= 0 && board[y - 1].charAt(x) == '#') {
                            notFound = false;
                        } else if (y + 1 < H && board[y + 1].charAt(x) == '#') {
                            notFound = false;
                        } else if (x - 1 >= 0 && board[y].charAt(x - 1) == '#') {
                            notFound = false;
                        } else if (x + 1 < W && board[y].charAt(x + 1) == '#') {
                            notFound = false;
                        }

                        if (notFound) {
                            System.out.println("No");
                            return;
                        }
                    }
                }
            }
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21972
#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 {
        cout << "a == b" << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
import java.util.Scanner;
import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
        	int n = scan.nextInt();
        	int s = scan.nextInt();
        	if(n == 0 && s == 0){
        		break;
        	}
        	int[] r = new int[n];
        	for(int i = 0;i < n;i++){
        		r[i] = scan.nextInt();
        	}
        	Arrays.sort(r);
        	int count = 0;
        	for(int i = n-1;i > 0;i--){
        		for(int j = i - 1;j >= 0;j--){
        			if(r[i]+r[j] <= s){
        				break;
        			}
        			count++;
        		}
        	}
        	System.out.println(count);
        }
	}
}

Measured memory_bytes: 68068
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

template <class InputIterator, class T>
bool contains(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// =========ここまでテンプレ============

int main()
{
    ll s;
    ll w;
    cin >> s;
    cin >> w;
    if (w >= s)
    {
        cout << "unsafe";
    }
    else
    {
        cout << "safe";
    }
}

Measured memory_bytes: 3124
#include<iostream>
#include<cstdio>
#define N 100
using namespace std;

int main(){
    int n;
    scanf("%d", &n);
    
    int c[N];
    for(int i = 0; i<n; i++){
        scanf("%d", &c[i]);
    }
    
    for(int i = n-1; i > 0; i--){
        printf("%d ", c[i]);
    }
    
    printf("%d\n", c[0]);
    
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<vector<int>> A(2, vector<int>(N));
	for (auto &row : A) {
		for (auto &x : row) {
			cin >> x;
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		int result
			= accumulate(A[0].begin(), A[0].begin() + i + 1, 0)
			+ accumulate(A[1].begin() + i, A[1].end(), 0);
		ans = max(ans, result);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int c=0;
int solve(int *a,int *b,int i,int n)
{
	if(i>=n)
	return 0;
	c=min(solve(a,b,i+1,n),solve(a,b,i+2,n));
	return a[i]-c;	
}
 int main()
 {
 	int n;
 	cin>>n;
 	int a[n][3];
 	for(int i=0;i<n;i++)
 	{
 		cin>>a[i][0];
 		cin>>a[i][1];
 		cin>>a[i][2];
 	}
 	
 	if(n==1)
 	{
 		cout<<max(a[0][0],max(a[0][1],a[0][2]))<<endl;
 		return 0;
 	}
 	for(int i=1;i<n;i++)
 	{
 		a[i][0]=max(a[i-1][0],max(a[i][0]+a[i-1][1],a[i-1][2]+a[i][0]));
 		a[i][1]=max(a[i-1][1],max(a[i][1]+a[i-1][0],a[i-1][2]+a[i][1]));
 		a[i][2]=max(a[i-1][2],max(a[i][2]+a[i-1][0],a[i-1][1]+a[i][2]));
 	}
 	cout<<max(a[n-1][0],max(a[n-1][1],a[n-1][2]))<<endl;
 }

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int N, M, Q;
VEC(VEC(int)) qrys;
VEC(int) A;

int recurse(int m, int n)
{
    if (A.size() == M + 1) {
        int score = 0;
        FOR(q, 0, Q) {
            VEC(int)& v = qrys[q];
            int a = v[0], b = v[1], c = v[2], d = v[3];
            if (A[b] - A[a] == c)
                score += d;
        }

        return score;
    }

    if (n > N) {
        return 0;
    }

    int ret = recurse(m, n + 1);

    A.push_back(n);
    ret = max(ret, recurse(m + 1, n));
    A.pop_back();
    return ret;
}

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    cin >> M >> N >> Q;
    qrys.resize(Q);
    A = VEC(int)(0);

    FOR(i, 0, Q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        qrys[i] = VEC(int){a, b, c, d};
    }

    int ret = recurse(1, 1);
    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 3656
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.16 16:54:53
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repf(i,j,n) for(int i=(j);i<(n);i++)
#define repe(i,j,n) for(int i=(j);i<=(n);i++)
#define repr(i,j,n) for(int i=(n)-1;i>=0;i--)

int mod=1e9+7;


signed main(){
	int n,m;cin>>n>>m;
	vector<int> s(n),t(m);
	rep(i,n)cin>>s[i];
	rep(i,m)cin>>t[i];
	vector<vector<int>>dp(n+1,vector<int>(m+1,0));
	dp[0][0]=1;

	rep(i,n+1)rep(j,m+1){
		if(i>0)(dp[i][j]+=dp[i-1][j])%=mod;
		if(j>0)(dp[i][j]+=dp[i][j-1])%=mod;
		if(i>0&&j>0&&s[i-1]!=t[j-1])(dp[i][j]+=mod-dp[i-1][j-1])%=mod;
	}
	cout<<dp[n][m]<<endl;
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 1e9 + 1
#define INF_LL 1LL<<60
#define ll long long
#define ALL(x)          (x).begin(),(x).end()

#define MAX_V 105

#define MAX_N 100
#define MAX_M 100

ll ten[10000007];
vector<int> ans;
int n;

bool canMake(ll mid) {
    ans.resize(0);
    int tmp = n;
    REP_REV(i, mid) {
        if(tmp >= ten[i]) {
            tmp -= ten[i];
            ans.push_back(ten[i]);
        }
        if(tmp == 0) return true;
    }
    return false;
}

int main(){
    cin >> n;
    REP(i, n) ten[i] = i+1;

    ll ub = n+1, lb = 0;
    while(ub - lb > 1) {
        int mid = (lb + ub) / 2;

        if(canMake(mid)) ub = mid;
        else lb = mid;
    }

    //cout << ub << endl;
    canMake(ub);

    REP(i, ans.size()) {
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 78464
import sys
s = input()
for idx, i in enumerate(s):
    if i not in ['L','U','R','D']:
        print('No')
    elif i == 'R' and (idx+1) % 2 == 0:
        print('No')
        sys.exit()
    elif i == 'L' and (idx+1) % 2 == 1:
        print('No')
        sys.exit()
print("Yes")



Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;
int main(){

        int a,b,x; cin>>a>>b>>x;
        string ans ="NO";
        if(x-a <= b and x >= a) ans="YES";
        cout << ans << endl;
        return 0;
}


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

int main(void){
    
    long long N;
    cin >> N;
    
    int for_size = sqrt(N) + 1;
    int ans = 11;
    
    for(int i = 1; i <= for_size; i++){
        if(N % i == 0){
            string A = to_string(i);
            string B = to_string(N/i);
            int string_Max = max(A.size(), B.size());
            ans = min(ans, string_Max);
        }
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 256
#include<stdio.h>
#define M 102

int Ad[M][M];
int d[M];
int Q[M];
char color[M];
void enqueue(int);
int dequeue(void);
int n,head=0,tail=0;

int main(){

  int i,j,m,u,k;

  scanf("%d",&n);

  for(i=1;i<M;i++){
    Q[i]=0;
    for(j=1;j<M;j++){
      Ad[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    color[i]='W';
    d[i]=-1;
    if(k!=0){for(j=1;j<=k;j++){
      scanf("%d",&Ad[u][j]);
      }
    }
  }
     
  color[1]='G';
  d[1]=0;
  enqueue(1);

  while(head!=tail){
    u = dequeue();
    m = 1;
    while(Ad[u][m]!=0){
      if(color[Ad[u][m]]=='W'){
	color[Ad[u][m]]='G';
        d[Ad[u][m]]=d[u]+1;
        enqueue(Ad[u][m]);}
        m++;
      }
    color[u]='B';
  }
  
  for(i=1;i<=n;i++){
    printf("%d %d\n",i,d[i]);
  }
 
  return 0;
}


void enqueue(int y){
  Q[tail]= y;
  if(tail+1==n-1) tail=0;
  else tail++;
}

int dequeue(void){
  int x;
  x = Q[head];
  if(head+1==n-1) head=0;
  else head++;

  return x;
}

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


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

    for(int i=0; i<s.length(); i++){
        char tmp = s[i] + n;
        if(tmp > 'Z') tmp -= 26;
        s[i] = tmp;
    }

    cout << s << endl;

    return 0;
}


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 59;


template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

WeightedGraph< int64 > g;
int v[100000];
int64 val[100000];
int64 low = 0, high = INF;

void fail() {
  cout << 0 << endl;
  exit(0);
}

void dfs(int idx, int par, int sign, int64 weight) {
  if(v[idx]) {
    if(v[idx] == sign) {
      if(val[idx] != weight) fail();
    } else {
      int64 tmp = val[idx] - weight;
      if(sign < 0) tmp *= -1;
      if(tmp % 2 == 1 || tmp <= 0) fail();
      low = max(low, tmp / 2);
      high = min(high, tmp / 2);
    }
    return;
  } else {
    v[idx] = sign;
    val[idx] = weight;
    if(sign > 0) low = max(low, 1 - weight);
    else high = min(high, weight - 1);
  }
  for(auto &e : g[idx]) {
    if(e.to != par) dfs(e.to, idx, sign * -1, e.cost - weight);
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  g = WeightedGraph< int64 >(N);
  for(int i = 0; i < M; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --a, --b;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  dfs(0, -1, 1, 0);
  cout << max(0LL, high - low + 1) << endl;
}



Measured memory_bytes: 15232
from itertools import accumulate
N, M, X = map(int, input().split(' '))
Toll = list(map(int, input().split(' ')))
cost = [1 if i in Toll else 0 for i in range(N+1)]
cost_cum = list(accumulate(cost))
print(min(cost_cum[X]-cost_cum[0], cost_cum[N]-cost_cum[X]))

Measured memory_bytes: 3060
#include <iostream>
#include <sstream>

using namespace std;

int main(){
  string in;  

  while(getline(cin,in) ,in != "0"){
    stringstream s(in);
    int sum = 0,n;
    bool flg = false;

    while(s >> n){
      if(2 <= n && n <= 9){
	sum += n;
      }else if(n >= 10){
	sum += 10;
      }else{
	sum++;
	flg = true;
      }
    }

    if(sum <= 11 && flg){
      sum += 10;
    } 

    if(sum > 21){
      cout << 0 << endl;
    }else{
      cout << sum << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1224