akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

template <typename T> void output(T, int);
int gcd(int a, int b);

int main() {
    // source
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;
    vector<int> rr, bbb;
    bool ans = true;
    rep(i, n - 1) {
        if (s[i] == '#' && s[i + 1] == '#') {
            rr.push_back(i);
        }
        if (i != n - 2) {
            if (s[i] == '.' && s[i + 1] == '.' && s[i + 2] == '.') {
                bbb.push_back(i);
            }
        }
    }

    rep(i, rr.size()) {
        if (a <= rr[i] && rr[i] <= c) {
            ans = false;
        }
        if (b <= rr[i] && rr[i] <= d) {
            ans = false;
        }
    }

    bool judge = false;
    if (c > d) {
        rep(i, bbb.size()) {
            if (b - 1 <= bbb[i] && bbb[i] <= d - 1) {
                judge = true;
            }
        }

        if (b - a == 1 && s[b] + 1 == '.') {
            ans = true;
        }

        if (!judge) {
            ans = false;
        }
    }

    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}

template <typename T> T min(T a, T b) {

    if (a < b) {
        return a;
    } else {
        return b;
    }
}

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


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ab = getInt(sc);
		int bc = getInt(sc);

		System.out.println(ab*bc/2);


	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


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

template <typename A, typename B>string to_string(pair<A, B> p);template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p);template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p);string to_string(const string& s) {  return '"' + s + '"';}string to_string(const char* s) {  return to_string((string) s);}string to_string(bool b) {  return (b ? "true" : "false");}string to_string(vector<bool> v) {  bool first = true;  string res = "{";  for (int i = 0; i < static_cast<int>(v.size()); i++) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(v[i]);  }  res += "}";  return res;}template <size_t N>string to_string(bitset<N> v) {  string res = "";  for (size_t i = 0; i < N; i++) {    res += static_cast<char>('0' + v[i]);  }  return res;}template <typename A>string to_string(A v) {  bool first = true;  string res = "{";  for (const auto &x : v) {    if (!first) {      res += ", ";    }    first = false;    res += to_string(x);  }  res += "}";  return res;}template <typename A, typename B>string to_string(pair<A, B> p) {  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}template <typename A, typename B, typename C>string to_string(tuple<A, B, C> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";}template <typename A, typename B, typename C, typename D>string to_string(tuple<A, B, C, D> p) {  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";}void debug_out() { cerr << endl; }template <typename Head, typename... Tail>void debug_out(Head H, Tail... T) {  cerr << " " << to_string(H);  debug_out(T...);}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define set0(x) memset(x,0,sizeof(x))
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args) {
    read(first);
    read(args...);
}

string A;
int main() {
    cin>>A;
    for(int i=0;i<A.size();i++)if(A[i] == '?')A[i] = 'D';
    cout<<A<<endl;
    return 0;
}


Measured memory_bytes: 3752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}
int main() {
  int N; cin >> N;
  string S; cin >> S;
  vector<int> l(N + 1), r(N + 1);
  l[0] = 0;
  for (int i = 0; i < N; ++i) {
    if (S[i] == 'W') l[i + 1] = l[i] + 1;
    else             l[i + 1] = l[i];
  }
  r[N] = 0;
  for (int i = N; i > 0; --i) {
    if (S[i] == 'E') r[i - 1] = r[i] + 1;
    else             r[i - 1] = r[i];
  }

  int vmin = 1e9;
  for (int i = 0; i < N; ++i) {
    vmin = min(vmin, l[i] + r[i]);
  }
  cout << vmin << endl;
}


Measured memory_bytes: 6132
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;
/*******************************************************************************************/
vector<ll> get(ll n)
{
    vector<ll> div;

    for(ll i=1;i<=sqrt(n)+1;i++)
    {
        if(n%i==0)
        {
            div.pb(i);
            div.pb(n/i);
        }
    }

    return div;
}
void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    f(i,n) cin>>a[i];

    sort(a,a+n);

    vector<ll> div=get(a[0]);
    sort(div.begin(),div.end());
    vector<ll> v(div.size());

    ll ans=-1;
    f(i,n)
    {
        f(j,div.size()) if(a[i]%div[j]==0) v[j]++;
    }

    for(ll i=div.size()-1;i>-1;i--)
    {
        if(v[i]>=n-1)
        {
            ans=div[i];
            break;
        }
    }

    div=get(a[1]);
    sort(div.begin(),div.end());
    v.clear();
    v.resize(div.size());

    f(i,n)
    {
        f(j,div.size()) if(a[i]%div[j]==0) v[j]++;
    }

//    cout<<endl;
    for(ll i=div.size()-1;i>-1;i--)
    {
        if(v[i]>=n-1)
        {
            ans=max(ans,div[i]);
            break;
        }
    }

    cout<<ans<<"\n";
    return;
}

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

    ll t=1;
    //cin>>t;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 1024
x, n = map(int, input().split())
not_p = []
if n != 0:
    p = list(map(int, input().split()))
    not_p = [i for i in range(201) if i not in p]
else:
    not_p = [i for i in range(201)]

mn = 101
ans = 100
for i in not_p:
    d = abs(x - i)
    if mn > d:
        mn = d
        ans = i

print(ans)

Measured memory_bytes: 61916
N = int(input())
nums =list(map(int, input().split()))
a = {}
INF = 10**5
for num in nums:
  if not num in a:
    a[num] = 1
  else:
    a[num] += 1
  if len(a) > 3:
    print('No')
    exit()
def same_count(dic):
  v_max = 0
  v_min = INF
  for v in dic.values():
    v_max = max(v_max, v)
    v_min = min(v_min, v)
  return v_max == v_min
def xor_zero(dic):
  a = 0
  for k in dic.keys():
    a ^= k
  return True if a == 0 else False

def double_count(dic):
  v_max = 0
  v_min = INF
  for v in dic.values():
    v_max = max(v_max, v)
    v_min = min(v_min, v)
  return v_max == v_min*2 and dic[0] == v_min

answer = False
if len(a) == 3:
  answer = same_count(a) and xor_zero(a)
elif len(a) == 2:
  answer = 0 in a.keys() and double_count(a)
elif len(a) == 1:
  answer = 0 in a.keys()
if answer:
  print('Yes')
else:
  print('No')

  
    


Measured memory_bytes: 85432
def func():
    pass


def main():
    l = [0, 0, 0, 0]
    for i in range(3):
        a, b = map(int, input().split())
        l[a - 1] += 1
        l[b - 1] += 1

    l.sort()
    # print(l)
    if l == [1, 1, 2, 2]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
s=input()
a=[]
d=[]
sum=0
for i,line in enumerate(s):
    if line == "\\":
        d.append(i)
    elif line == "/" and d:
        j=d.pop()
        a_tmp=i-j
        sum+=a_tmp
        while a and a[-1][0] > j:
            a_tmp += a.pop()[1]
        a.append([j,a_tmp])
 
print(sum)
print(len(a),*[s for i,s in a])


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

int main(){
    int A[5][4][11],n;
    for(int i=1;i<=4;i++)
     for(int j=1;j<=3;j++)
      for(int k=1;k<=10;k++) A[i][j][k]=0;
    
    cin >> n;
    for(int i=0;i<n;i++){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }
    
    for(int b=1;b<=4;b++){
     if(b>1)cout << "####################\n";
     for(int f=1;f<=3;f++){
      for(int r=1;r<=10;r++){
          cout << " " <<  A[b][f][r];
      }
      cout << endl;
     }
    }
    return 0;
}


Measured memory_bytes: 3096
package main

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

func main() {
	var a, n int
	fmt.Scan(&n)
	set := make(map[int]int, 0)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		a, _ = strconv.Atoi(sc.Text())
		set[a]++
	}
	ks := make([]int, 0)
	for k := range set {
		ks = append(ks, k)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ks)))
	// fmt.Println("n", n, "set", set, "ks", ks)
	ans := 0
	for i := 0; i < len(ks); i++ {
		if set[ks[i]] != ks[i] {
			if set[ks[i]] > ks[i] {
				ans += set[ks[i]] - ks[i]
			} else {
				ans += set[ks[i]]
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 7936
#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else
#define DMP(...) ((void)0)
#endif

#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	lint I, O, J, L, skip;
	cin >> I >> O >> skip >> J >> L >> skip >> skip;
	DMP(I, O, J, L);

	lint ans = 0;
	ans += O;
	ans += I / 2 * 2;
	ans += J / 2 * 2;
	ans += L / 2 * 2;

	auto majority = [](auto a, auto b, auto c) {
		return (a & 1) & (b & 1) & (c != 0) | (a != 0) & (b & 1) & (c & 1) | (a & 1) & (b != 0) & (c & 1);
	};

	if (majority(I, J, L)) ans += 1 + 2 * (I & J & L & 1);

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 3624
//#pragma GCC optimize ('O3')
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mp make_pair
#define f first
#define s second
#define pb push_back

const int N = 1e5 + 5;
const int M = 5e5 + 5;
const int OO = 1e9;
const int mod = 1e9 + 7;

int sum;
string s;

void init() {}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> s;

    for(auto i : s) {
        sum += i-'0';
    }

    cout << (sum%9 ? "No" : "Yes") << '\n';

    return 0;
}

Measured memory_bytes: 3712
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;

const int maxn = 3e5 + 5;

int n, m;
int l[maxn], r[maxn];
int c[maxn];

void add(int x, int d){
    for(int i = x;i < maxn;i += i & -i){
        c[i] += d;
    }
}

int Sum(int x){
    int res = 0;
    for(int i = x;i > 0;i -= i & -i){
        res += c[i];
    }
    return res;
}

vector<int> G[maxn];

int main(){
    cin >> n >> m;
    for(int i = 1;i <= n;i++){
        scanf("%d%d", &l[i], &r[i]);
        r[i]++;
        G[r[i] - l[i]].push_back(i);
    }
    int sum = n;
    for(int i = 1;i <= m;i++){
        for(auto it : G[i]){
            add(l[it], 1);
            add(r[it], -1);
        }
        sum -= G[i].size();
        int ans = sum;
        for(int j = i;j <= m;j += i){
            ans += Sum(j);
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 14592
#include<bits/stdc++.h>
using namespace std;
#define int long long
int rv[30];
struct node{
  int id,left,right,par;
  node(){par=-1;}
};
node t[30];
void dfs(int v,int p){
  if(p==0){
    cout<<" "<<t[v].id;
    if(~t[v].left)  dfs(rv[t[v].left ],p);
    if(~t[v].right) dfs(rv[t[v].right],p);
  }
  if(p==1){
    if(~t[v].left)  dfs(rv[t[v].left ],p);
    cout<<" "<<t[v].id;
    if(~t[v].right) dfs(rv[t[v].right],p);
  }
  if(p==2){
    if(~t[v].left)  dfs(rv[t[v].left ],p);
    if(~t[v].right) dfs(rv[t[v].right],p);
    cout<<" "<<t[v].id;
  }
}
signed main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++) cin>>t[i].id>>t[i].left>>t[i].right;
  for(int i=0;i<n;i++) rv[t[i].id]=i;
  for(int i=0;i<n;i++){
    //cout<<t[i].id<<":"<<t[i].left<<":"<<t[i].right<<endl;
    if(~t[i].left)  t[rv[t[i].left ]].par=t[i].id;
    if(~t[i].right) t[rv[t[i].right]].par=t[i].id;
  }
  for(int i=0;i<n;i++){
    if(t[i].par==-1){
      cout<<"Preorder"<<endl;
      dfs(i,0);
      cout<<endl;
      cout<<"Inorder"<<endl;
      dfs(i,1);
      cout<<endl;
      cout<<"Postorder"<<endl;
      dfs(i,2);
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3120
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAXN = 110;
int c[4], v[MAXN];
vector<int> a[4];
int main() {
	int N;
	long long W;
	cin >> N >> W;
	long long w1;
	int v;
	cin >> w1 >> v;
	c[0]++;
	a[0].push_back(v);
	for (int i = 2; i <= N; i++) {
		long long w;
		cin >> w >> v;
		c[w - w1]++;
		a[w - w1].push_back(v);
	}	
	for (int i = 0; i <= 3; i++) {
		sort(a[i].begin(), a[i].end(), greater<int>());
	}
	long long ans = 0;
	long long sv[4] = {0, 0, 0, 0};
	for (int i = 0; i <= c[0] && i*w1 <= W; i++) {
		if (i > 0) sv[0] += a[0][i-1];
		sv[1] = 0;
		for (int j = 0; j <= c[1] && i*w1+j*(w1+1) <= W; j++) {
			if (j > 0) sv[1] += a[1][j-1];
			sv[2] = 0;
			for (int k = 0; k <= c[2] && i*w1+j*(w1+1)+k*(w1+2) <= W; k++) {
				if (k > 0) sv[2] += a[2][k-1];
				sv[3] = 0;
				for (int l = 0; l <= c[3] && i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3) <= W; l++) {
					if (l > 0) sv[3] += a[3][l-1];
					ans = max(ans, sv[0]+sv[1]+sv[2]+sv[3]);
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
using namespace std;

char str[100];
int main(){
	scanf("%s", str);
	int len = strlen(str);
	if(len == 2)
	printf("%s", str);
	else if(len == 3){
		swap(str[0],str[2]);
		printf("%s", str);}
	return 0;

}


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e9+5, mod = 1e9+7;

void solve() {
    int n; cin >> n;

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

    int ans = 0;
    sort(a, a + n);

    for (int i = 0; i < n - 2; ++i) {
        for (int j = i + 1; j < n - 1; ++j) {
            if (a[j] != a[i]) {
                for (int k = j + 1; k < n; ++k) {
                    if (a[k] != a[j] && a[k] != a[i] && a[k] < a[i] + a[j]) {
                        ++ans;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1; 
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 3672
import collections
def main():
    N, M = map(int, input().split())
    bridges = []
    for _ in range(M):
        a, b = map(int, input().split())
        bridges.append([a, b])
    bridges = bridges[::-1]
    parent = [i for i in range(N+1)]
    count = dict()
    for i in range(N+1): count[i] = 1

    def find(i):
        if parent[i] != i:
            parent[i] = find(parent[i])
        return parent[i]

    def union(i, j):
        pi, pj = find(i), find(j)
        df = 0
        if pi != pj:
            if count[pi] > count[pj]:
                parent[pj] = pi
                df += count[pi] * count[pj]
                count[pi] += count[pj]
                del count[pj]
            else:
                parent[pi] = pj
                df += count[pi] * count[pj]
                count[pj] += count[pi]
                del count[pi]                
        return df

    ans = [N*(N-1)//2]
    for a, b in bridges[:-1]:
        d = union(a, b)
        ans.append(ans[-1]-d)
    return ans[::-1]

if __name__ == '__main__':
    output = main()
    for v in output:
        print(v)

Measured memory_bytes: 105304
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

template <class T>
T GCD(T a, T b) { return b == 0 ? a : GCD(b, a%b); }

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

  ll gcd = 0, maxa = 0;
  REP(i, N) {
    ll a; cin >> a;
    gcd = GCD(gcd, a);
    maxa = max(maxa, a);
  }

  if (K%gcd == 0 && K <= maxa) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    long long int n,a[100010],b[100010],sum = 0,tmp,i;
    scanf("%lld",&n);
    for (i = 0; i <= n; i++)
    {
        scanf("%lld",&a[i]);
        sum += a[i];
    }
    for (i = 0; i < n; i++)
    {
        scanf("%lld",&b[i]);

        if (b[i] >= a[i])
        {
            b[i] -= a[i];
            a[i] = 0;
            if (b[i] <= a[i + 1])
            {
                a[i + 1] -= b[i];
            }
            else
            {
                a[i + 1] = 0;
            }
        }
        else
        {
            a[i] -= b[i];
        }
        
    }

    for (i = 0; i < n + 1; i++)
    {
        sum -= a[i];
    }
    printf("%lld",sum);
}


Measured memory_bytes: 1664
/* 苦手・・ */
#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 2e9
#define INF_LL 1LL<<60
#define ll long long

typedef pair<ll, ll> P;

int main() {
    int k, x;
    cin >> k >> x;
    if(k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=1000+10;
const ll mod=1e9+7;

struct camel{
	int k,l,r;
};

bool cmp(const camel& a,const camel& b){
	return a.k<b.k;
}

ll calc(vector<camel> a){
	ll minSum=0;
	int n=(int)a.size();
	sort(all(a),cmp);
	multiset<int> MS;
	for(int i=0;i<n;++i){
		int pos=a[i].k;
		MS.insert(a[i].l-a[i].r);
		while(pos<(int)MS.size()){
			auto it=MS.begin();
			minSum+=*it;
			MS.erase(it);
		}
	}
	return minSum;
}
		
void solve(){
	int n;
	ll ans=0;
	cin>>n;
	vector<camel> inFront,inBack;
	vector<camel> a(n);
	for(int i=0;i<n;++i){
		cin>>a[i].k>>a[i].l>>a[i].r;
		if(a[i].l>a[i].r){
			ans+=a[i].l;
			inFront.push_back(a[i]);
		}
		else{
			swap(a[i].l,a[i].r);
			ans+=a[i].l;
			a[i].k=n-a[i].k;
			inBack.push_back(a[i]);
		}
	}
	ans-=calc(inFront);
	ans-=calc(inBack);
	cout<<ans<<endl;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin>>t;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 13928
x,y=map(int,input().split())
a={1,3,5,7,8,10,12}
b={4,6,9,11}
c={2}
if x in a:
  group_x=0
elif x in b:
  group_x=1
else:
  group_x=2

if y in a:
  group_y=0
elif y in b:
  group_y=1
else:
  group_y=2

if group_x==group_y:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int A, B;
	string S;
	cin >> A >> S >> B;
	if (S[0] == '+') cout << A + B << endl;
	else if (S[0] == '-') cout << A - B << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner scan = new Scanner(System.in);
		
		long a = scan.nextLong();
		long b = scan.nextLong();
		long c = scan.nextLong();
		long d = scan.nextLong();
		scan.close();
		
		long numC = b/c - (a - 1)/c;
		long numD = b/d - (a - 1)/d;
		long lcmCD = lcm(c, d);
		long numCD = b/lcmCD - (a - 1)/lcmCD;
		
		//System.out.println(numC + " " + numD + " " + numCD);
		System.out.println(b - a + 1 - numC - numD + numCD);
		
	}
	
	public static long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}
	
	public static long gcd(long a, long b) {
		//System.out.println(a + " " + b);
		if(a < b) {
			return gcd(b, a);
		}
		if(b == 0) {
			return a;
		}
		return gcd(b, a%b);
	}

}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    int N, K, temp;
    std::vector<int> x;
    
    std::cin >> N >> K;
    for (int i=0; i<N; ++i) {
        std::cin >> temp;
        x.push_back(temp);
    }
    
    int ans = 0;
    for (int i=0; i<N; ++i) {
        ans += std::abs(2 * std::min({ std::abs(x[i]), std::abs(x[i]-K) }));
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
H, W= map(int, input().split())
A=[]
b=[]
ans=[0 for i in range(H)]
for i in range(H):
    A.append(list(map(int, input().split())))
for j in range(W):
    b.append(int(input()))
for i in range(H):
    for j in range(W):
        ans[i]+=A[i][j]*b[j]
    print(ans[i])

Measured memory_bytes: 8052
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t;
	cin >> s >> t;
	int x = stoi(s + t);
	for (int i = 1; i <= 1000; i++) {
		if (i * i == x) {
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
void solve()
{   ll X,Y,Z;
    cin>>n>>m;
    vector<double> v(n);
    double sum=0;
    for(int i=0;i<n;i++) {cin>>v[i];sum+=v[i];}
        sort(v.begin(),v.end(),greater<int>());
    double y=(sum/(double)(4*m));
    for(int i=0;i<m;i++)
    {
        if(v[i]<y){cout<<"No";return;}
    }
    cout<<"Yes";
    
}

int main()
{   //seive();
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

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

int getInt() {
    int s;
    scanf("%d", &s);
    return s;
}

int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> t(n);

    REP(i,n) cin >> s[i] >> t[i];

    string ss; cin >> ss;

    int sl = false;
    int ans = 0;
    REP(i,n) {
        if(sl) ans += t[i];
        if(ss == s[i]) sl = true;
    }

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
struct lll
{
    long long x,y,z;
}a[510];
int main()
{
    long long n;
    cin>>n;
    for(long long i=1;i<n;i++)
        cin>>a[i].x>>a[i].y>>a[i].z;
    for(long long i=1;i<n;i++)
    {
        long long sum=0;
        for(long long j=i;j<n;j++)
        {
            if(j==i)
                sum+=a[j].x+a[j].y;
            else
            {
                if(sum<=a[j].y)
                {
                    sum=a[j].x+a[j].y;
                }
                else
                {
                    if((sum-a[j].y)%a[j].z!=0)
                    {
                        long long t=a[j].z-(sum-a[j].y)%a[j].z;
                        sum+=t+a[j].x;
                    }
                    else
                    {
                        sum+=a[j].x;
                    }

                }

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


Measured memory_bytes: 256
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>
using namespace std;
	typedef long long ll;
	const int maxn=100050;
	ll a,b,c,n;
	string s[maxn]; 
	bool ans;
	string ot;
	void dfs(int i){
		if(ans)
			return ;
		if(!(a>=0&&b>=0&&c>=0))
			return ;
		if(i==n+1){
			ans=1;
			return ;
		}
		if(s[i]=="AB"){
			a--;b++;
			ot+='B';
			dfs(i+1);
			if(ans)
				return ;
			ot.erase(ot.end()-1);
			a++,b--;
			
			a++,b--;
			ot+='A';
			dfs(i+1);
			if(ans)
				return ;
			a--,b++;
			ot.erase(ot.end()-1);
			
		}
		else if(s[i]=="AC"){
			a--;c++;
			ot+='C';
			dfs(i+1);
			if(ans)
				return ;
			ot.erase(ot.end()-1);
			a++,c--;
			
			a++,c--;
			ot+='A';
			dfs(i+1);
			if(ans)
				return ;
			a--;c++;
			ot.erase(ot.end()-1);
		}
		else{
			b--;c++;
			ot+='C';
			dfs(i+1);
			if(ans)
				return ;
			ot.erase(ot.end()-1);
			b++,c--;
			
			
			b++,c--;
			ot+='B';
			dfs(i+1);
			if(ans)
				return ;
			b--;c++;
			ot.erase(ot.end()-1);
		}
		return ;
	}
	int main(){
		cin>>n>>a>>b>>c;
		for(int i=1;i<=n;i++)
			cin>>s[i];
		dfs(1);
		if(ans){
			cout<<"Yes"<<endl;
			for(char ch:ot)
				cout<<ch<<endl;
		}
			
		else
			cout<<"No"<<endl;
		return 0;
	}

Measured memory_bytes: 11552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0048
{
	class Program
	{
		static void Main(string[] args)
		{
			float[]		weight	= { 48.00f, 51.00f, 54.00f, 57.00f, 60.00f, 64.00f, 69.00f, 75.00f, 81.00f, 91.00f, 100000.00f };
			string[]	name	= { "light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy" };

			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	w	= float.Parse( s );
				for( int i = 0; ; i++ ) {
					if( w <= weight[ i ] ) {
						Console.WriteLine( name[ i ] );
						break;
					}
				}
			}
		}
	}
}

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

using namespace std;
using ll = long long;

int main(){
    int a, b; cin >> a >> b;
    int count = 1;
    int tmp = a;
    while(true){
        if(b == 1){
            cout << 0 << endl;
            return 0;
        }
        if(tmp >= b){
            cout << count << endl;
            return 0;
        }
        tmp = tmp - 1 + a;
        count++;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int K,S;
    cin>>K>>S;
    int cnt=0;
    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            int z=S-i-j;
            if(z>=0&&z<=K)cnt++;
        }
    }
    cout<<cnt<<endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

//#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rrep(i,a,b) for (int i = a; i >= b; i--)



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int te=1;
	//cin>>te;
	while(te--){
        ll a,c,n,ans=0LL,q,b;
        //string ans="";
        cin>>n;
        ll myxor=0LL;
        vector< ll > v(n+1);
        rep(i,1,n) {cin>>v[i]; myxor = myxor^v[i];}

        rep(i,1,n){
            cout<< (myxor^v[i])<<' ';
        }
	}
	return 0;
}


Measured memory_bytes: 4768
use proconio::{input, fastout, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars,
        t: Chars,
    }

    let mut ans: usize = t.len();

    for i in 0..=s.len()-t.len() {
        let temp = s.iter().skip(i).zip(t.iter()).filter(|&(&s, &t)| s != t).count();

        ans = std::cmp::min(ans, temp);
    }

    println!("{}", ans);
}


Measured memory_bytes: 2184
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    ll a, b, k;
    cin >> a >> b >> k;
    for (int i = 0; i < k; ++i) {
        (i & 1 ? b : a) -= (i & 1 ? b : a) % 2;
        (i & 1 ? b : a) /= 2;
        (i & 1 ? a : b) += (i & 1 ? b : a);
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 3628
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
ll L[100000], R[100000];
multiset<ll> LS, RS;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N; for (int j = 0; j < N; ++j) cin >> L[j] >> R[j];

    ll lo = 0, ro = 0, ans = 0;

    LS.insert(-(1LL << 60));
    RS.insert(1LL << 60);

    for (int j = 0; j < N; ++j) {
        if (j > 0) {
            lo -= R[j] - L[j];
            ro += R[j-1] - L[j-1];
        }

        if (L[j] < *LS.rbegin() + lo) {
            ans += (*LS.rbegin() + lo) - L[j];

            RS.insert((*LS.rbegin() + lo) - ro);
            LS.insert(L[j] - lo);
            LS.insert(L[j] - lo);
            LS.erase(LS.find(*LS.rbegin()));
        } else if (L[j] > *RS.begin() + ro) {
            ans += L[j] - (*RS.begin() + ro);

            LS.insert((*RS.begin() + ro) - lo);
            RS.insert(L[j] - ro);
            RS.insert(L[j] - ro);
            RS.erase(RS.begin());
        } else {
            LS.insert(L[j] - lo);
            RS.insert(L[j] - ro);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>

int main(){
  int i,j,n,m,l,b[50005],c;
  int s[50005],t[50005],e[50005];
  int sar[50005];
  scanf("%d%d",&n,&m);
  i=0;
  while(scanf("%d%d%d",&s[i],&t[i],&e[i]),s[i]!=0){
    i++;
  }
  c=i;
  scanf("%d",&l);
  for(i=0;i<l;i++){
    for(j=1;j<=m;j++){scanf("%d",&b[j]);}
    for(j=1;j<=n;j++){sar[j]=0;}
    for(j=0;j<c;j++){
      //printf("%d %d %d\n",s[j],t[j],e[j]);
      sar[s[j]]+=(b[t[j]]*e[j]);
    }
    for(j=1;j<=n;j++){
      if(j!=1){printf(" ");}
      printf("%d",sar[j]);
    }printf("\n");
  }
}



Measured memory_bytes: 2348
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E,mn = INF,mx = 0;
int dp[NMAX] = {};

string S;
vec v;

ll ans = 0;

void solve(){
  // main algorithm

}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N;

  for (int i = 0; i < N; ++i)
  {
    cin >> A;
    mn = min(A, mn);
    mx = max(A,mx);
  }
  ans = mx - mn;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
using ll = int64_t;
using Graph = vector<vector<int> >;
const ll M = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> a;
    for(int i=0;i<n;i++){
        ll f;
        cin >> f;
        a.push_back(f);
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    ll sum=0;
    int cnt=1;
    while(cnt<n){
        sum+=a.at(cnt/2);
        cnt++;
    }
    cout << sum << endl;
}

Measured memory_bytes: 5296
#include <cmath>
#include <functional>
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>

using namespace std;

typedef long long ll;

#ifdef iq
  mt19937 rnd(228);
#else
  mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif

const ll inf = (ll) (1e18) + 7;

int main() {
#ifdef iq
  freopen("a.in", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector <ll> a(n + 1);
  for (int i = 0; i <= n; i++) cin >> a[i];
  if (n == 0 && a[0] == 1) {
    cout << 1 << endl;
    return 0;
  }
  ll ok = 0;
  ll l = 1, r = 1;
  if (a[0] != 0) {
    cout << -1 << '\n';
    return 0;
  }
  ll sum = 0;
  vector <ll> x;
  vector <pair <ll, ll> > e;
  e.push_back({-1, -1});
  for (int i = 0; i <= n; i++) {
    ok += a[i];
    if (i) {
      if (l > r) {
        cout << -1 << '\n';
        return 0;
      }
      e.push_back({l, r});
      l = l - a[i];
      r = 2 * r - a[i];
      r = min(r, inf);
      l = max(l, 0ll);
      if (l > r) {
        cout << -1 << '\n';
        return 0;
      }
    }
  }
  r = 0;
  for (int i = n; i >= 0; i--) {
    sum += r;
    if (i) {
      auto c = e[i];
      c.second = min(c.second, r + a[i]);
      c.first = max(c.first, (r + a[i] + 1) / 2);
      if (c.first > c.second) {
        assert(0);
        //cout << -1 << '\n';
        //return 0;
      }
      r = c.second;
    }
  }
  cout << sum + ok << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define INF 1000000000000000LL
#define N 5010
int n;
PII a[N];
ll f[N], g[N]; // min height

bool cmp(PII x, PII y) {
	return x.fi + x.se < y.fi + y.se || x.fi + x.se == y.fi + y.se && x.se < y.se;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++)
		cin >> a[i].fi >> a[i].se;
	sort(a, a+n, cmp);
	for (int i = 0; i <= n; i ++) f[i] = INF;
	f[0] = 0;
	for (int i = 0; i < n; i ++) {
		memcpy(g, f, sizeof g);
		for (int j = 0; j <= n; j ++) f[j] = INF;
		for (int j = 0; j <= n; j ++) if (g[j] < INF) {
			if (g[j] <= a[i].fi) f[j+1] = min(f[j+1], g[j] + a[i].se);
			f[j] = min(f[j], g[j]);
		}
	}
	int S = 0;
	for (int i = 0; i <= n; i ++)
		if (f[i] < INF) S = max(S, i);
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 384
S=list(input())
K=int(input())

if K==1:
  print(sorted(S)[0])
  exit()

ans=[]
if K<=len(S):
  s0=sorted(S[:-K+1])[0]
  for j,e in enumerate(S[:-K+1]):
    if e==s0:
      for i in range(1,K+1):
        a="".join(S[j:j+i])
        if a not in ans:
          ans.append(a)
      
sl=S[-K+1:]
for i in range(K-1):
  for j in range(i+1,K):
    a="".join(sl[i:j])
    if a not in ans:
      ans.append(a)

ans.sort()
print(ans[K-1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long n,W,dp[201][200001];
pair<long long,long long> v[201];
int main()
{
    cin >> n >> W;
    for(int i=1; i<=n; i++)
        cin >> v[i].first >> v[i].second;
    sort(v+1,v+1+n);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=W; j++)
        {
            if(j < v[i].first) dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            else dp[i][j] = max(max(dp[i-1][j],dp[i][j-1]),dp[i-1][j-v[i].first] + v[i].second);
        }
    }
    cout << dp[n][W];
}

Measured memory_bytes: 156416
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> dp(100001, 100001);
    dp[0] = 0;
    for (int i = 0; i < 100001; i++){
        if (i != 100000){dp[i+1] = min(dp[i+1], dp[i]+1);}
        for (int j = 6; i+j < 100001; j *= 6){dp[i+j] = min(dp[i+j], dp[i]+1);}
        for (int j = 9; i+j < 100001; j *= 9){dp[i+j] = min(dp[i+j], dp[i]+1);}
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3764
#include<cstdio>
#include<iostream>
#include<cstdlib>
using namespace std;
int ans[3];
int num[4];
bool Is_find=false;
void print()
{
	printf("%d",num[0]);
	for(int i=1;i<4;i++)
	{
		if(ans[i-1]==1)printf("+");
		else printf("-");
		printf("%d",num[i]);
	}
	printf("=7\n");
}
void work(int now,int i)
{
	if(now==7&&i==3&&Is_find==false){print();Is_find=true;return;}
	if(i==3)return;
	ans[i]=1;work(now+num[i+1],i+1);
	ans[i]=0;work(now-num[i+1],i+1);
	return;
}
int main()
{
	char c;
	for(int i=0;i<4;i++){scanf("%c",&c);num[i]=c-'0';}
	work(num[0],0);
	return 0;
}


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

int solve(string s, string& t) {
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
        ans += (s[i] != t[i]);
    }
    return ans;
}
int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        int ans = 0, mod = 1e9 + 7;
        int sum = 0;
        for (int j = 0; j < n; j++) {
            ans += sum * a[j];
            ans %= mod;
            sum += a[j];
            sum %= mod;
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 4776
#include <iostream>
#include <string>
#include <cctype>

using namespace std;

void CaesarCipher(const string&);
int main(){
  string str;
  while(getline(cin,str)){
    CaesarCipher(str);
  }
}


void CaesarCipher(const string& str){
  string diffstr=str;
  int diff=1;
  while(diffstr.find("the")==string::npos&&
        diffstr.find("this")==string::npos&&
        diffstr.find("that")==string::npos ){
    for(int i=0;i<str.length();i++){
      if( !isalpha(str[i])) continue;
      diffstr[i]=(diff+str[i]-'a')%26+'a';
    }
    diff++;
  }
  cout<<diffstr<<endl;
}

Measured memory_bytes: 1188
<?php
/*
    http://agc005.contest.atcoder.jp/tasks/agc005_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%s", $S);
$arrS = str_split($S);
$A = "CODEFESTIVAL2016";
$arrA = str_split($A);
$ans = 0;

for ($i = 0; $i < count($arrS); $i++) {
	if ($arrS[$i] != $arrA[$i]) $ans++;
}
echo $ans . PHP_EOL;

Measured memory_bytes: 3704
# -*- coding: utf-8 -*-
"""
Created on Sat May  2 21:55:08 2020

@author: matha
"""


#import sys

#sys.stdin = open(r"C:\Users\oshim\Documents\contestCodes\Lab_02\quarantine_individual_practice_contest_01\input.txt", "r")


s = list(input())

c = 0


i = 1
while i < len(s):
    if (s[i] != s[i-1]):
        s.pop(i-1)
        s.pop(i-1)
        c += 2
        if (i>2):
            i = i-2
        if i ==2:
            i = i-1
    else:
        i+=1
    

print(c)




Measured memory_bytes: 3956
# -*- coding: utf-8 -*-
"""
A - Digits Sum
https://atcoder.jp/contests/agc025/tasks/agc025_a

"""
import sys


def solve(N):
    def calc_dsum(a, b):
        a_sum = sum([int(ch) for ch in str(a)])
        b_sum = sum([int(ch) for ch in str(b)])
        return a_sum + b_sum

    ans = []
    for a in range(1, (N//2)+1):
        b = N - a
        ans.append(calc_dsum(a, b))
    return min(ans)


def main(args):
    N = int(input())
    ans = solve(N)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main()
{
    string t,w,wk;
    cin>>w;

    int cnt=0;
    do{
        cin>>t;
        wk=t;
        transform(t.begin(),t.end(),t.begin(),::tolower);
        if(t==w)
            cnt++;

    }while(wk!="END_OF_TEXT");

    cout<<cnt<<endl;

    return 0;
}  


Measured memory_bytes: 3192
N = int(input())
A = list(map(lambda x: format(int(x), "060b"), input().split()))
Num = 10**9 + 7
digit = [0 for i in range(60)]
for a in A:
  for i in range(60):
    if a[i] == "1":
      digit[i] += 1
#print(digit)
ans = 0
for i in range(60):
  ans = (ans * 2 + digit[i] * (N-digit[i])) %Num
print(ans)

Measured memory_bytes: 154472
import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

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

def num():
	return map(int , input().split())

def nu():
	return int(input())

def find_gcd(x , y):
	while (y):
		x , y = y , x % y
	return x

n=nu()
z=n # Copying N to form the sum of digits
s=0 # Store the sum of digits
while(n!=0):
	s+=n%10
	n=n//10
if(z%s==0):
	print("Yes")
else:
	print("No")


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

int main() {
  string a,b;
  cin >> a >> b;
  int max=0;
  for(int i=0;i<a.size()-b.size()+1;i++){
    int k=0;
      for(int l=0;l<b.size();l++){
        if(a[i+l]==b[l]) k++;
    }
    if(k>max) max=k;
  }
  cout << b.size()-max << endl;
}


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


int main() {
  
    int N; cin >> N;
    vector<int> H(N);
    forn(i, N) cin >> H[i];
    int pre = -1;
    forn(i, N) {
        if (pre < H[i]) {
            pre = H[i]-1;
        } else if (pre == H[i]) {
            pre = H[i];
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T>
inline bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template <class T>
T GCD(T a, T b) {if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b);}

int main(){
    int n, y;
    cin >> n >> y;
    y /= 1000;
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= n - i; j++){
            if(n - i - j == y - 10 * i - 5 * j){
                cout << i << ' ' << j << ' ' << n - i - j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 384
#include <cassert>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

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

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

int main() {
    ll a, b;
	while (cin >> a >> b) {
	    cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
	return 0;
}


Measured memory_bytes: 3008
#include<bits/stdc++.h>
#define all(x) (x).begin() , (x).end()
#define ll long long 
#define pb push_back
#define mp make_pair


using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin>>a>>b>>c;
    int m = min(a ,b);
    int mx = max(a , b);
    for(int i = m ; i <= mx; ++i){
      if(i == c)return cout<<"Yes" , 0;
    }
    cout<<"No";
}


Measured memory_bytes: 256