akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main() {
	long long int a, b, c, d, m, n, k, count = 0, result = 0, key, zyou;
	long long int s[2005] = {}, sum[2005] = {}, two[50], num[500600] = {}, memo[500600][50] = {};
	char str[200005];
	two[0] = 1;
	for (int i = 1; i < 50; i++) {
		two[i] = two[i - 1] * 2;
	}
	scanf("%lld%lld", &n, &k);

	for (int i = 1; i <= n; i++) {
		scanf("%lld", &s[i]);

		sum[i] = sum[i - 1] + s[i];

	}
	m = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {

			num[m] = sum[j] - sum[i];

			m++;
		}

	}
	for (int i = 49; 0 <= i; i--) {
		count = 0;
		for (int j = 0; j < m; j++) {
			if ((num[j] / two[i]) % 2 == 1) {
				memo[count][i] = j;
				count++;

			}

		}

		if (count >= k) {
			result += two[i];
			zyou = i;
			key = count;

			goto next;
		}
	}
next:
	for (int i = zyou - 1; 0 <= i; i--) {
		count = 0;
		for (int j = 0; j < key; j++) {

			if ((num[memo[j][zyou]] / two[i]) % 2 == 1) {
				memo[count][i] = memo[j][zyou];
				count++;


			}
			
		}
		if (count >= k) {

			result += two[i];
			zyou = i;
			key = count;

		}
	}
	printf("%lld", result);
}

Measured memory_bytes: 199680
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

long long int f(long long int mid, long long int a, long long int b){
	long long int p = a * mid;
	int d = 1;
	while (mid / 10)
	{
		d++;
		mid /= 10;
	}
	p += b * d;
	return p;
}

//深さ優先探索のテンプレ.デフォルトでは参照渡ししたsetに探索済みの頂点が格納される.
//graphは隣接リスト.vは探索開始地点.seenは空のセット
void dfs(vector<vector<pair<int, int>>> &graph, vector<int> &ans, int v, int c = -1, int p = -1)
{
	int k = 1;
	for (int i = 0; i < graph[v].size(); i++)
	{
		int nxt = graph[v][i].first;
		int ei = graph[v][i].second;
		if (nxt == p) continue;
		if (k == c)
			k++;
		ans[ei] = k;
		dfs(graph, ans, nxt, k, v);
		k++;
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<pair<int, int>>> graph(n);
	vector<int> ans(n - 1, 0);
	rep(i, n - 1)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(make_pair(b, i));
		graph[b].push_back(make_pair(a, i));
	}
	dfs(graph, ans, 0);
	int mx = 0;
	rep(i, n - 1) mx = max(int(graph[i].size()), mx);
	cout << mx << endl;
	rep(i, n - 1) cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 8320
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n, a, ans=0;
	cin>>n;
	vector<int>v(n+1);
	for(int i=1;i<=n;++i)cin>>v[i];
	a = v[1];
	for(int i=0;i<n;++i){
		if(a == 2) {
			cout<<ans+1<<endl;
			break;
		}
		a = v[a];
	    ++ans;
	}
	if(a != 2) cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 640
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))
dic = defaultdict(int)
ans = sum(A)
for a in A:
    dic[a] += 1
Q = int(input())
for i in range(Q):
    b, c = map(int, input().split())
    ans -= dic[b] * b
    ans -= dic[c] * c
    dic[c] += dic[b]
    dic[b] = 0
    ans += dic[c] * c
    print(ans)


Measured memory_bytes: 24148
N, M = map(int, input().split())
S = input()
T = input()
def gcd(a, b):

    return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(b, a % b)


L = lcm(N, M)

f = False

s_step = L // N
t_step = L // M
sL = lcm(s_step, t_step)
s = 0
t = 0

for i in range(0, L, sL):
    if i == 0:
        if S[i] == T[i]:
            continue
        else:
            f = True
            break
    else:
        s = i // s_step
        t = i // t_step
        if s > N - 1:
            break
        if t > M - 1:
            break
        if S[s] == T[t]:
            continue
        else:
            f = True
            break

if f:
    print(-1)
else:
    print(L)



Measured memory_bytes: 3444
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int N;
int main(){
	scanf("%d",&N);
	int tt;
	ll ans=0;
	for(int i=1;i<=N;++i){
		scanf("%d",&tt);
		ans+=tt-1;
	}
	printf("%lld",ans);
	return 0;
}

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

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

  int amin,zmax;

  for(int i=0;i<s.size();i++) {
    if(s[i]=='A') {
      amin=i;
      break;
    }
  }
  for(int j=s.size()-1;j>0;j--) {
    if(s[j]=='Z') {
      zmax=j;
      break;
    }
  }
  cout << zmax-amin+1 << endl;
}


Measured memory_bytes: 640
def longest_common_subsequence(str1, str2)
  #
  # O(str1.size * str2.size)
  #
  # references:
  #   - https://www.youtube.com/watch?v=ASoaQq66foQ
  #   - https://qiita.com/_rdtr/items/c49aa20f8d48fbea8bd2
  #   - https://ikatakos.com/pot/programming_algorithm/dynamic_programming/longest_common_subsequence
  #
  n = str1.size
  m = str2.size
  dp = Array.new(n + 1) { Array.new(m + 1, 0) }
  str1 = str1.split("")
  str2 = str2.split("")
  str1.each_with_index do |c1, i|
    str2.each_with_index do |c2, j|
      if c1 != c2
        dp[i + 1][j + 1] = [dp[i][j + 1], dp[i + 1][j]].max 
      else
        dp[i + 1][j + 1] = dp[i][j] + 1
      end
    end
  end
  dp[n][m]
end





n = gets.to_i
ans = []
n.times do
  x = gets.chomp
  y = gets.chomp
  ans << longest_common_subsequence(x, y)
end
puts ans


Measured memory_bytes: 47892
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL sum = a;
    LL res = 1;
    while(b){
        if(b&1){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int main(){
    LL L, R;
    cin >> L >> R;
    if(R-L>=2019){
        cout << 0 << endl;
        return 0;
    }
    L %= 2019;
    R %= 2019;
    while(L>=R)R+=2019;
    int ans = 2020;
    for(int i=L;i<=R;++i){
        for(int j=i+1;j<=R;++j){
            ans = min(ans, i*j%2019);
        }
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long int ll;

int main()
{
    string s;
    cin >> s;
    for(ll i = 0;i < s.size() / 2 - 1;i++){
        if(s[i] != s[s.size() - i - 1]){
            cout << "No";
            return 0;
        }
    }
    for(ll i = 0;i < (s.size() - 1) / 2;i++){
        if(s[i] != s[(s.size() - 1) / 2 - 1 - i]){
            cout << "No";
            return 0;
        }
    }
    for(ll i = (s.size() + 3) / 2 - 1;i < s.size();i++){
        if(s[i] != s[s.size() - i - 1]){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String args[]){
		try{
			new Main();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
	
	public Main() throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String line;
		
		while((line = in.readLine()) != null){
			int n = Integer.parseInt(line);
			int a = n%39;
			if(a==0) System.out.println("3C39");
			else if(a<10) System.out.println("3C0" + Integer.toString(a));
			else System.out.println("3C" + Integer.toString(a));
		}
	}
}

Measured memory_bytes: 9304
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int S;
	cin >> S;
	int h = S / 3600;
	int m = (S % 3600) / 60;
	int s = (S % 3600) % 60;
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<ll,ll> P;
#define fi first
#define se second
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
 int n;
cin>>n;
vector<int> a(n+1),balls(n+1,0),ans;
for(int i=1;i<n+1;i++)cin>>a.at(i);
for(int i=n;i>0;i--){
    int sum=0,cnt=1;
    while(cnt*i<=n){
        sum^=balls.at(cnt*i);
        cnt++;
    }
    if(sum!=a.at(i)){
        balls.at(i)^=1;
        ans.push_back(i);
    }
}
cout<<ans.size()<<endl;
for(int i=ans.size()-1;i>=0;i--)cout<<ans.at(i)<<" ";
cout<<endl;

}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

//????¬?????´???????

char f[1010][1010];
int cumsum[1010][1010][3];

int main() {
	int m, n, l;
	char *table = "JOI";

	cin >> m >> n >> l;
	for (int i = 1; i <= m; ++i) {
		for (int j = 1; j <= n; ++j) {
			cin >> f[i][j];
		}
	}

	for (int k = 0; k < 3; ++k) {
		for (int i = 1; i <= m; ++i) {
			for (int j = 1; j <= n; ++j) {
				cumsum[i][j][k] = cumsum[i][j - 1][k] + (f[i][j] == table[k] ? 1 : 0);
			}
		}
	}
	for (int k = 0; k < 3; ++k) {
		for (int j = 1; j <= n; ++j) {
			for (int i = 1; i <= m; ++i) {
				cumsum[i][j][k] += cumsum[i - 1][j][k];
			}
		}
	}

	int a, b, c, d;
	while (l--) {
		cin >> a >> b >> c >> d;
		for (int i = 0; i < 3; ++i) {
			cout << cumsum[c][d][i] - cumsum[c][b - 1][i] - cumsum[a - 1][d][i] + cumsum[a - 1][b - 1][i];

			if (i < 2)
				cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 15796
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <math.h>

using namespace std;



int main(){

    int n;
    cin >> n;
    int t[120000], x[120000], y[130000];

    t[0] = x[0] = y[0] = 0;
    for(int i = 0; i < n; i++){
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }
    int dt, dist;

    bool can = true;

    for(int i = 0; i < n; i++){
        dt = t[i + 1] - t[i];
        dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if(dist > dt){
            can = false;
        }

        if(dt % 2 != dist %2){
            can = false;
        }
    }

    if(can == true){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }

    return 0; 

}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n, t;
  cin >> n >> t;
  vector<int> imos(t + 1);
  REP(i, n) {
    int l, r;
    cin >> l >> r;
    imos[l]++;
    imos[r]--;
  }
  REP(i, t) imos[i + 1] += imos[i];
  int ans = 0;
  REP(i, t + 1) ans = max(ans, imos[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3120
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <cmath>
#include <queue>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

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


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};
vector<int> G[200010];
vector<int> c(10010, 0);
int num[200010];
bool used[200010];
int now_c = 0;

int dfs(int s) {
    if (used[s]) {
        return 0;
    } else {
        used[s] = true;
    }

    num[s] = c[now_c];
    now_c++;

    for (int i = 0; i < G[s].size(); i++) {
        dfs(G[s][i]);
    }
    return 0;
}

int main() {
    int N; cin >> N;
    vector<int> a(N);

    rep(i,N){
        cin >> a[i];
    }

    multiset<int> st;

    st.insert(a[0]);

    for(int i=1; i<N; i++){
        auto ptr = st.lower_bound(a[i]);
        if(ptr == st.end()){
            st.erase(--st.end());
            st.insert(a[i]);
        }else{
            if(ptr==st.begin()) {
                st.insert(a[i]);
            }else{
                ptr--;
                st.erase(ptr);
                st.insert(a[i]);
            }
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 10112
#include <iostream>
#include <cstring>
using namespace std;
int l[100];
int main()
{
  int N;
  while(cin >> N){
    memset(l,0,sizeof(l));
    for(int i=0; i<N; i++){
      cin >> l[i];
    }
    for(int k = 0; k<N; k++){
      if(k!=0) cout << " ";
      cout << l[k];
    }
    cout << endl;
    for(int j=1; j<N; j++){
      int key = l[j];
      int i = j-1;
      while(i >= 0 && l[i] > key){
        l[i+1] = l[i];
        i--;
      }
      l[i+1] = key;
      for(int k = 0; k<N; k++){
        if(k!=0) cout << " ";
        cout << l[k];
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int s[2][5]={0},n;
int check(int p){
	int i,j,sum;
	for(i=1;i<5;i++){
		sum=s[0][0];
		for(j=1;j<5;j++){
			sum+=j==i?s[p+1][j]:s[p][j];
		}
		if(sum==7){n=i;return 1;}
	}
	return 0;
}
int main(void){
	int i,j,p;
	for(i=0;i<5;i++){
		if(i-1){
			s[0][i]=getchar()-'0';
			s[1][i]=-s[0][i];
			s[2][i]=s[0][i];
		}
	}
	for(i=0;i<2;i++){
		if(check(i)){
			printf("%d",s[0][0]);
			for(j=2;j<5;j++){
				p=j==n?i+1:i;
				if(0<=s[p][j]){printf("+");}
				printf("%d",s[p][j]);
			}
			printf("=7");
			return 0;
		}
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int solve(){
  int n, l, r;
  int a[100];
  
  scanf("%d%d%d", &n, &l, &r);
  if(!n) return 0;
  
  for(int i=0;i<n;i++){
    scanf("%d", a+i);
  }

  int ans = 0;
  
  for(int i=l;i<=r;i++){
    int t = n;
    for(int j=0;j<n;j++){
      if(i % a[j] == 0){
        t = j;
        break;
      }
    }

    ans += t%2 == 0;
  }

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

int main(){
  while(solve());
}



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

int main()
{
    int n,m;
    scanf(" %d %d", &n, &m);
    vector<int> e(m);
    rep(i,m) scanf(" %d", &e[i]);

    vector<bool> ap(n+1);
    for(int i=m-1; i>=0; --i)if(!ap[e[i]])
    {
        printf("%d\n", e[i]);
        ap[e[i]]=true;
    }

    for(int i=1; i<=n; ++i)if(!ap[i]) printf("%d\n", i);
    return 0;
}

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

const int _ = 5e5 + 7 , MOD = 998244353; int fac[_] , ifac[_] , N , K;
int poww(long long a , int b){int tms = 1; while(b){if(b & 1) tms = tms * a % MOD; a = a * a % MOD; b >>= 1;} return tms;}
int binom(int a , int b){return a < b || b < 0 ? 0 : 1ll * fac[a] * ifac[b] % MOD * ifac[a - b] % MOD;}

int main(){
	cin >> N >> K; fac[0] = 1; for(int i = 1 ; i <= K ; ++i) fac[i] = 1ll * fac[i - 1] * i % MOD;
	ifac[K] = poww(fac[K] , MOD - 2); for(int i = K - 1 ; ~i ; --i) ifac[i] = ifac[i + 1] * (i + 1ll) % MOD;
	int sum = 0;
	for(int i = 0 ; K - 2 * i >= 0 ; ++i)
		if(K - N - i >= 0) sum = (0ll + sum + binom(K - (K == 2 * i) , i - (K == 2 * i)) - binom(K - (K == 2 * i) , 2 * i + N - K - 1 - (K == 2 * i)) + MOD) % MOD;
	
	cout << sum; return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  int N,ans=0;
  cin>>N;
  vector<int> L;
  REP(i,2*N){
    int a;
    cin>>a;
    L.emplace_back(a);
  }
  
  SORT(L);
  REP(i,N) ans+=L.at(2*i);
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  char a, b;
  cin >> a >> b;
  if (a < b) cout << "<" << endl;
  else if (a == b) cout << "=" << endl;
  else cout << ">" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1000000007;
signed main(){
  int N,ans=1;
  cin>>N;
  vector<int> A(3,-1);
  while(N--){
    int a;
    cin>>a;
    vector<int> B(0);
    for(int i=0;i<3;i++)
      if(A[i]+1==a)
        B.push_back(i);
    if(B.size()==0){
      puts("0");
      return 0;
    }
    ans=ans*((int)B.size())%mod;
    A[B[0]]++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string ROMA = "IVXLCDM";
const int N[] = {1, 5, 10, 50, 100, 500, 1000};

int main(void){
    map<char, int> cor;
    rep(i, 7) cor[ROMA[i]] = N[i];

    int res, pre;
    for(string in; res = pre = 0, cin >> in; cout << res << endl)
        rep(i, in.size()){
            int cur = cor[in[i]];
            res += cur - (pre < cur ? 2 * pre:0);
            pre = cur;
        }
 
    return 0;
}

Measured memory_bytes: 1192
package main

import (
	"fmt"
)

func main() {
	var N, K, Q, A int
	fmt.Scan(&N, &K, &Q)
	m := map[int]int{}
	for i := 0; i < Q; i++ {
		fmt.Scan(&A)
		m[A]++
	}
	var r string
	for i := 1; i <= N; i++ {
		if v, ok := m[i]; ok {
			if K-Q+v > 0 {
				r = "Yes"
			} else {
				r = "No"
			}
		} else {
			if K-Q > 0 {
				r = "Yes"
			} else {
				r = "No"
			}
		}
		fmt.Println(r)
	}
}


Measured memory_bytes: 8448
#include<iostream>

using namespace std;

typedef long long ll;

int main(){
  ll H,h,M,m,K;
  cin >> H >> M >> h >> m >> K;
  ll time;
  time = (h - H) * 60 + m - M;
  if(time < K) cout << 0 << endl;
  else cout << time - K << endl;
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

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

  int cnt = 0;
  vector<int> a(n, 0);
  for(int i=0;i<n;++i) {
    while(a[i] < h[i]) {
      for(int j=i;j<n;++j) {
        if(a[j] < h[j]) {
          a[j]++;
        } else {
          break;
        }
      }
      
      cnt++;
    }
  }
  cout << cnt << endl;

  
}


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

int main() {
	int n;
	while(cin >> n) {
		if(n==0) break;
		vector<pair<double,string> > ans(n);
		for(int i=0;i<n;i++) {
			string l;
			int p,a,b,c,d,e,f,s,m;
			cin >> l;
			cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
			ans[i].first = (-1)*( (f*m*s)-p) /(double)((a+b+c) + (d+e)*m);
			ans[i].second = l;
		}
		sort(ans.begin(),ans.end());
		for(int i=0;i<n;i++) {
			cout << ans[i].second << endl;
		}
		cout << "#" << endl;
	}
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  string s;
  cin>>s;
  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;
  return 0;
}



Measured memory_bytes: 3624
n = int(input())
count =0
store_list=[]
dictA={}
ans_list=[1]*n
for _ in range(n):
    s = input()
    s_list = list(s)
    s_list.sort()
    a =tuple(s_list)
    dictA.setdefault(a,0)
    dictA[a] +=1 
    #print(dictA)
#print(sum(ans_list))
total = 0
for value in dictA.values() :
    total += value*(value-1)/2
       
print(int(total))

Measured memory_bytes: 28548
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N,L; scanf("%d %d", &N, &L);

	vector<string> s(N);
	REP(i,N){
		cin >> s[i];
	}

	SORT(s);

	string ans = "";
	REP(i,N){
		ans += s[i];
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <algorithm> 
#include <set>
#include <sstream>
#include <bit>
#include <bitset>
#include <iomanip>
#include <queue>
typedef long long int ll;
using namespace std;
int main() {
	int N, W; cin >> N >> W;
	vector<ll>weight(N), value(N);
	vector<vector<ll>>DP(N+1, vector<ll>(W+1,0));
	ll ans = 0;
	for (int i = 0; i < N;i++) cin >> weight[i] >> value[i];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j >= weight[i]) {
				DP[i + 1][j] = max(DP[i][j], DP[i][j - weight[i]] + value[i]);
			}
			else {
				DP[i + 1][j] = DP[i][j];
			}
		}
	}
	cout << DP[N][W] << endl;
}

Measured memory_bytes: 82696
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var N = long.Parse(Console.ReadLine());
            Console.WriteLine(Enumerable.Range(1, (long)Math.Sqrt(N)).Where(elem => N % elem == 0).Select(elem => elem + (N / elem) - 2).Min());
        }
    }

    class Enumerable
    {
        public static IEnumerable<long> Range(long start, long count)
        {
            for (int i = 0; i < count; i++)
            {
                yield return i + start;
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

int main(){
	int n,m; cin >> n >> m;
	vector<vector<int> > v(m);

	for(int i=0;i<m;i++){
		int k; cin >> k;
		v[i].resize(k);
		for(int j=0;j<k;j++){
			cin >> v[i][j];
			v[i][j]--;
		}
	}
	vector<int> p(m);
	for(int i=0;i<m;i++){
		cin >> p[i];
	}
	int ans=0;
	for(int i=0;i<(1<<n);i++){
		bool ok=true;
		for(int j=0;j<m;j++){
			int c=0;
			for(int id:v[j]){
				if((i>>id)&1)c++;
			}
			if(c%2!=p[j])ok=false;
		}
		if(ok)ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

// UG02-53-20-001

int main()
{
    int rate;
    scanf("%d", &rate);{

        if( rate < 1200 ){
            printf("ABC");
        }
else if( rate < 2800 ){
            printf("ARC");
        }
else{
            printf("AGC");
        }
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, X; cin >> N >> X;
    int x[100100];
    rep(i, N) {
        int y; cin >> y;
        x[i] = abs(y - X);
    }
    int D = x[0];
    rep(i, N) {
        D = gcd(D, x[i]);
    }
    cout << D << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

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

    vector<int> H(N);
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }

    reverse(all(H));
    for (int i = 0; i < N-1; i++) {
        if (H[i] < H[i+1]) {
            H[i+1]--;
        }
        if (H[i] < H[i+1]) {
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vector<pair<ll, ll>> wk(n);
    int a,b,c;
    rep(i,n) {
        cin >> a >> b;
        c = b-a;
        wk[i] = make_pair(b, a);
    }
    sort(wk.begin(), wk.end());
    string ans = "Yes";
    ll now = 0;
    rep(i,n) {
        // cout << now << ' ' << wk[i].first << ' ' << wk[i].second << endl;
        if (wk[i].first < now + wk[i].second) {
            ans = "No";
            break;
        } else {
            now += wk[i].second;
        }
    }
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int k,n;
int a[1000000];
int main() {
    scanf("%d %d",&k,&n);
    for(int i=0;i<n;i++) scanf("%d",&a[i]);
    int t=a[0]+k-a[n-1];
    for(int i=1;i<n;i++) t=max(t,a[i]-a[i-1]);
    printf("%d",k-t);
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    ll x;
    cin >> x;
//    ll ans = 0;
    if(360 % x == 0){
        //ans = 360 /x;
        cout << 360/x << endl;
        return 0;
    }else{
        reps(i,1,180){
            if((360*i) % x== 0)
            {
                cout << 360*i/x << endl;
                return 0;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 3632
/* Simplicity and Goodness */

#include <bits/stdc++.h>
using namespace std;
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define deb(x) cout << #x << ' ' << x << '\n'
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define per(i,ini) for(int i=ini;i>=0;i--)
#define tc int tt; scn(tt); while(tt --)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int N = 2e5+2;


int main()
{
    string s1, s2;
    cin >> s1 >> s2;

    string s3 = s2.substr(0, s1.length());


    if(s3 == s1)
    printf("Yes\n");
    else
    printf("No\n");

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp(a, b) make_pair(a, b)
#define ls (rt << 1)
#define rs (rt << 1 | 1) 
typedef pair<int, int> pii; 
const ll mod = 1e9 + 7;
template <class T> T lowbit(T x){return ((x)&(-(x)));}
const int maxn = 2e5 + 10;
int main()
{
	string s;
	cin >> s;
	if(s == "ARC") puts("ABC");
	else puts("ARC");	 
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
}

int solve(){
    cout << N*(N-1)/2 + M*(M-1)/2 << endl;
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

string s = "ATCG", t;

int main() {
	cin >> t;
	
	int p = s.find(t);
	
	cout << s[p + (p % 2 == 0 ? +1 : -1)] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SSS")
    cout<<0<<endl;
  if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR")
    cout<<1<<endl;
  if(s=="RRS"||s=="SRR")
    cout<<2<<endl;
  if(s=="RRR")
    cout<<3<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>

using namespace std;

void solve(int x[], int y[], int h[], int N) {
    for (int cx = 0; cx <= 100; cx++) {
        for (int cy = 0; cy <= 100; cy++) {
            int ch = 0;
            for (int i = 0; i < N; i++) {
                if (h[i] != 0) {
                    ch = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
                    break;
                }
            }
            bool flag = true;
            for (int i = 0; i < N; i++) {
                if ( max(ch - abs(x[i]-cx) - abs(y[i]-cy), 0 ) != h[i]) {
                    flag = false;
                }
            }
            if (flag) {
                cout << cx << " " << cy << " " << ch << endl;
                return;
            }
        }
    }
}
int main() {
    int N;
    int x[102], y[102], h[102];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> h[i];
    }

    solve(x, y, h, N);

    return 0;
}


Measured memory_bytes: 256
// C - Peaks
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	int N,M; cin>>N>>M;
	vi H(N);
	vvi AB(M, vi(2));
	rep(i, N) cin>>H[i];
	rep(i, M) cin>>AB[i][0]>>AB[i][1];

	vi ok(N, 1); // ok=1, ng=0

	rep(i, M){
		int a = AB[i][0]-1, b = AB[i][1]-1;
		if(H[a] <= H[b]) ok[a] = 0;
		if(H[a] >= H[b]) ok[b] = 0;
	}

	int ans = 0;
	rep(i, N) if(ok[i]) ans++;
	cout<< ans <<endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, W;
  cin >> n >> W;
  vector<int> w(n), v(n);
  for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
  vector<vector<long long>> dp(n, vector<long long> (W + 1, 0));
  for(int j = 0; j <= W; j++) {
    dp[n - 1][j] = (j >= w[n - 1] ? v[n - 1] : 0);
  }
  for(int i = n - 2; i >= 0; --i) {
    for(int j = 0; j <= W; j++) {      
      dp[i][j] = dp[i + 1][j];
      if(j >= w[i]) {
        dp[i][j] = max(dp[i][j], (long long)v[i] + dp[i + 1][j - w[i]]);
      }      
    }
  }
  cout << dp[0][W] << '\n';  
  return 0;
}


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

int main(){
    int n; string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n-2){
        if("ABC"==s.substr(i,3)) ans++;
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#pragma warning(disable:4996)
using namespace std;

bool memo[52][52][52][52];
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,1,0,-1 };

long long int powint(long long int a, long long int b) {
  assert(b >= 0);
  if (b == 0)return 1;
  if (b == 1)return a;
  long long int ans = 1;
  long long int aa = powint(a, b / 2);
  ans *= aa*aa;
  if (b % 2)ans *= a;
  return ans;
}

struct aa {
  int ly;
  int lx;
  int ry;
  int rx;
};

int main() {
  while (1) {
    memset(memo, false, sizeof(memo));
    int W, H; cin >> W >> H;
    if (!W)break;
    vector<vector<int>>lmap(H + 2, vector<int>(W + 2, 1));
    vector<vector<int>>rmap(H + 2, vector<int>(W + 2, 1));

    int lsx, lsy, rsx, rsy;
    for (int i = 0; i < H; ++i) {
      string st; cin >> st;
      for (int j = 0; j < W; ++j) {
        if (st[j] == '.') {
          lmap[i+1][j + 1] = 0;
        }
        else if (st[j] == 'L') {
          lsx = j + 1; lsy = i + 1;
          lmap[i + 1][j + 1] = 0;
        }
        else if (st[j] == '%') {

          lmap[i + 1][j + 1] = 2;
        }
      }
       cin >> st;
      for (int j = 0; j < W; ++j) {
        if (st[j] == '.') {
          rmap[i + 1][j + 1] = 0;
        }
        else if (st[j] == 'R') {
          rsx = j + 1; rsy = i + 1;
          rmap[i + 1][j + 1] = 0;
        }
        else if (st[j] == '%') {

          rmap[i + 1][j + 1] = 2;
        }
      }
    }

    memo[lsy][lsx][rsy][rsx] = true;
    vector<aa>que;
    que.push_back(aa{ lsy,lsx,rsy,rsx });
    bool ok = false;
    while (que.size()) {
      aa atop(que.back());
      que.pop_back();
      
      for (int i = 0; i < 4; ++i) {
        const int lway = i;
         int rway = i;
        if (i == 0)rway = 2;
        if (i == 2)rway = 0;
        int nlx,nly,nrx,nry;
        if (lmap[atop.ly + dy[lway]][atop.lx + dx[lway]]!=1) {
          nlx = atop.lx + dx[lway];
          nly = atop.ly + dy[lway];
        }
        else {
          nlx = atop.lx;
          nly = atop.ly;
        }
        if (rmap[atop.ry + dy[rway]][atop.rx + dx[rway]]!=1) {
          nrx = atop.rx + dx[rway];
          nry = atop.ry + dy[rway];
        }else {
          nrx = atop.rx;
          nry = atop.ry;
        }
        if (!memo[nly][nlx][nry][nrx]) {
          memo[nly][nlx][nry][nrx] = true;
          if (lmap[nly][nlx] == 2 && rmap[nry][nrx] == 2) {
            ok = true;
            break;
          }
          else if (lmap[nly][nlx]==2||rmap[nry][nrx]==2) {

          }
          else {

            que.push_back(aa{ nly,nlx,nry,nrx });
          }
        }
      }
      if (ok)break;
    }
    if (ok) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 42920
#include <iostream>
#include <iomanip>
using namespace std;
int main(void){
    // Your code here!
    //今から文字入力
   int a,b;
   cin>>a>>b;
   cout<<fixed<<setprecision(5);
   cout<<a/b<<" "<<a%b<<" "<<(double)a/b<<endl;
    return 0;
}



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

const ll mod = 1000000007;
int main(){
	ll n,k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll p = 0;
	ll q = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = i+1; j < n; ++j) {
			if(a[i] > a[j]) p++;
		}
	}
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			if(a[i] > a[j]) q++;
		}
	}
	ll c1 = k;
	ll c2 = k*(k-1)/2LL % mod;
	ll ans = (c1*p + c2*q) % mod;
	cout << ans << endl;
    return 0;
}

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

const int max_n = 500 + 10;
const int max_a = 1e6;

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main()
{
    int a, b;
    cin >> a >> b;
    int result = a + b;
    chmax(result, a - b);
    chmax(result, a * b);
    cout << result << endl;
}

Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.ByteString.Char8 as BS

main = do
  [n,d] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let m = 2 * d + 1
  print $ (n + m - 1) `quot` m


Measured memory_bytes: 380
// Your code here!

import std.stdio;
import std.range;
import std.array;
import std.algorithm;
import std.conv;
import std.string;

void main(){
  auto input = readln().chomp().to!int;
  if(input <= 999){
      writeln("ABC");
  }else{
      writeln("ABD");
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        String[] S = new String[N];
        for(int i =0; i < N; i++)
        {
            S[i] = Console.ReadLine();
        }
        Array.Sort(S);
        long counter =1;
        for (int i = 0; i < N-1; i++)
        {
            if (S[i] != S[i + 1]) counter++;
        }
        Console.WriteLine(counter);
    }
}

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

int main(){
  int n;
  cin >> n;
  
  vector<int> num(n);
  
  for(int i = 0; i < n; i++){
    cin >> num.at(i);
  }
  
  int count = 0;
  int i = 0;
  
  while(true){
    if(num.at(i) % 2 == 0){
      num.at(i) /= 2;
    }else{
      break;
    }
    
    i++;
    if(i == n){
      i = 0;
      count++;
    } 
  }  
  cout << count << endl;
}

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

using namespace std;

int main()
{
	bool swapFlag = false;
	int N, redNum = 0, sum = 0, ans = 0;
	cin >> N;
	string c;
	cin >> c;
	for (int i = 0; i < N; i++) {
		if (c[i] == 'R') {
			redNum++;
		}
	}
	for (int i = 0; i < redNum; i++) {
		if (c[i] == 'R') {
			sum++;
		}
	}
	ans = redNum - sum;
	cout << ans << endl;
}



Measured memory_bytes: 3728
#include <bits/stdc++.h>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i]>>y[i];
typedef long long int ll;
using namespace std;

int main(){
	int n; cin >>n;
	vector<int> t(n);
	for(int i=0;i<n;i++)cin>> t[i];
	int m; cin >>m;
    vector<int> p(m),x(m);
	cinf(m,p,x);
	int sum=0;
	for(int i=0;i<n;i++){
		sum+=t[i];
	}
	for(int i=0;i<m;i++){
		cout<<sum-t[p[i]-1]+x[i]<< endl;
	}
} 

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

int stricmp(char* ch1,char* ch2){
	int ch1_length = 0,ch2_length = 0,div;
	for(int i = 0; ch1[i] != '\0';i++) ch1_length++;
	for(int i = 0; ch2[i] != '\0';i++) ch2_length++;
	if(ch1_length != ch2_length) return -1;
	for(int i = 0; ch1[i] != '\0';i++)
	{
		div = ch1[i] -ch2[i];
		if(div != 0 && div != 32 && div != -32)
			return -1;
	}
	return 0;
}

int main(){
	char W[11],T[1001];
	int count = 0;
	scanf("%s",W);
	while(true){
		scanf("%s",T);
		if(strcmp("END_OF_TEXT",T) == 0) break;
		if(stricmp(T, W) == 0) count++;
	}
	printf("%d\n",count);
}

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

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

  // int out = 0;
  // int safe = 0;
  // for(int i=0; i<n-1; i++) {
  //   if(c[i]=='W' && c[i+1]=='R') out++;
  //   if(c[i]=='R' && c[i+1]=='W') safe++;
  // }

  int rcount = 0;
  for(int i=0; i<n; i++) {
    if(c[i]=='R') rcount++;
  }

  int ans = 0;
  for(int i=0; i<rcount; i++) {
    if(c[i]=='W') ans++;
  }

  cout<<ans<<endl;




  return 0;
}

Measured memory_bytes: 3748