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

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <uint MD> struct ModInt {
    using M = ModInt;
    uint v;
    ModInt() : v(0) {}
    ModInt(ll _v) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<TEN(9) + 7>;

const int MF = TEN(6) + TEN(5);
V<Mint> fact(MF + 1), iFac(MF + 1);
void first() {
    fact[0] = 1;
    for (int i = 1; i <= MF; i++) fact[i] = fact[i-1] * Mint(i);
    iFac[MF] = fact[MF].inv();
    for (int i = MF; i >= 1; i--) iFac[i-1] = iFac[i] * Mint(i);
    assert((fact[114] * iFac[114]).v == 1);
}

Mint C(int n, int k) {
    if (n < k || n < 0) return Mint(0);
    return fact[n] * iFac[k] * iFac[n - k];
}
Mint K(int r, int c) {
    if (r < 0 || c < 0) return Mint(0);
    return C(r + c, c);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    first();
    int h, w, n;
    cin >> h >> w >> n;
    using P = pair<int, int>;
    V<P> v;
    v.push_back(P(0, 0));
    v.push_back(P(h - 1, w - 1));
    for (int i = 0; i < n; i++) {
        int r, c;
        cin >> r >> c; r--; c--;
        v.push_back(P(r, c));
    }
    sort(v.begin(), v.end());
    n += 2;
    V<Mint> dp(n);
    dp[0] = Mint(-1);
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < i; j++) {
            dp[i] -= dp[j] * K(v[i].first - v[j].first, v[i].second - v[j].second);
        }
    }
    cout << dp.back() << endl;
    return 0;
}


Measured memory_bytes: 8960
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	var n, w, s, e bool
	for i := 0; i < len(S); i++ {
		switch S[i] {
		case 'N':
			n = true
		case 'W':
			w = true
		case 'S':
			s = true
		case 'E':
			e = true
		}
	}
	if n == s && w == e {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
int N,ans=0,h[110]={},tall=0;

signed main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> h[i];
    tall=max(tall,h[i]);
  }
  h[N]=0;
  for(int i=0;i<tall;i++){
    for(int j=0;j<N;j++){
      if(h[j]>i && h[j+1]<=i) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

output = ''

hiraki = 0
for i in S:
    if i == '(':
        hiraki += 1
        output += i
    else:
        if hiraki > 0:
            hiraki -= 1
            output += i
        else:
            output = '(' + output
            output += i

output += ')' * hiraki

print(output)


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
import sys
import os

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

l = []

for i in range(n):
    l.append((i+1, a[i]))

nl = sorted(l, key=lambda x:x[1])

for i in nl:
    print(i[0], end='')
    if i != nl[-1]:
        print(' ', end='')
    else:
      	print('')

Measured memory_bytes: 20796
/**
 * Combinatorial - Longest Increasing Subsequence
 */

#include <iostream>

using namespace std;

const int INF = 1 << 30;

int main() {

    int N;
    int A[100000];

    cin >> N;

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

    int dp[100001];
    fill(dp, dp + 100001, INF);
    dp[0] = -1;

    for (int i = 0; i < N; i++) {
        *lower_bound(dp, dp + N + 1, A[i]) = A[i];
    }

    cout << lower_bound(dp, dp + N + 1, INF) - dp - 1 << endl;
}

Measured memory_bytes: 3864
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args)throws Exception {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(input.readLine());
        System.out.println((int)Math.pow((int)Math.sqrt(n), 2));
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
int main()
{
    int n,p;string s;cin>>n>>p>>s;
    int64_t ans=0;
    if(p==2||p==5){
        REP(i,n)if(!((s[i]-'0')%p))ans+=i+1;
    }else{
        map<int,int>cnt;
        cnt[0]=1;
        int cur=0,ten=1;
        REP(i,n){
            (cur+=(s[n-1-i]-'0')*ten)%=p;
            ans+=cnt[cur]++;
            (ten*=10)%=p;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> A(N), B(M);
	map<int, int> posX, posY;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		posX[A[i]] = i;
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
		posY[B[i]] = i;
	}
	ll res = 1, xs = 0, ys = 0;
	for (int i = N * M; i > 0 && res; i--) {
		if (!posX.count(i) && !posY.count(i)) {
			res = res * (xs * ys - (N * M - i)) % mod;
			continue;
		}
		if (posX.count(i) && posY.count(i)) {
			++xs;
			++ys;
			continue;
		}
		if (posX.count(i)) {
			res = res * ys % mod;
			++xs;
		}
		else {
			res = res * xs % mod;
			++ys;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
from bisect import bisect_left
N, M = map(int,input().split())
A = list(map(int,input().split()))
D = defaultdict(int)
for i in A:
  D[i]+=1
for _ in range(M):
  a, b = map(int,input().split())
  D[b]+=a
D_sorted = sorted(D.items(), key=lambda x:x[0], reverse = True)
ans = 0
count = 0
for x, c in D_sorted:
  if count+c < N:
    ans+=x*c
    count+=c
  else:
    ans+=x*(N-count)
    break
print(ans)

Measured memory_bytes: 46956
let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let build_max_heap (t : int array) h =
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= h && t.(l) > t.(i) then l else i in
    let m = if r <= h && t.(r) > t.(m) then r else m in
    if m <> i then begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end
  and doit i =
    if i > 0 then (max_heapify i; doit (i - 1))
  in
  doit (int_of_float (float_of_int h /. 2.))

let () =
  let h = read_int () in
  let t = Array.make (h + 1) 0 in
  let rec read i =
    if i <= h then (t.(i) <- Scanf.scanf "%d " (fun i -> i); read (i + 1))
  in
  read 1;
  build_max_heap t h;
  let rec doit i =
    if i <= h then (print_string " "; print_int t.(i); doit (i + 1))
  in
  doit 1;
  print_newline ()

Measured memory_bytes: 8592
#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()
{
    string s;
    cin >> s;
    char x = s[s.size() - 1];
    if (x != 's')
        cout << s << 's' << endl;
    else
        cout << s << "es" << endl;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstring>
#include <regex>
#include <sstream>

typedef long long ll;
constexpr double PI = 3.141592653589793;
constexpr int INF = 1e9 + 10;
constexpr ll INFL = 1e18 + 10;

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

struct edge
{
public:
    int to;
    int cost;
};

// O(|E|(log|V|))
void dijkstra(std::vector<int> &dist, const std::vector<std::vector<edge>> &graph, int s)
{
    typedef std::pair<int, int> P;
    std::priority_queue<P, std::vector<P>, std::greater<P>> pq;
    for (auto &e : dist)
    {
        e = INF;
    }

    dist[s] = 0;
    // P(distance from start, vertex index)
    pq.push(P(0, s));
    while (!pq.empty())
    {
        P cur = pq.top();
        pq.pop();
        int v = cur.second;
        int cost = cur.first;
        if (dist[v] < cost)
        {
            continue;
        }
        for (const auto &next : graph[v])
        {
            if (dist[next.to] > next.cost + dist[v])
            {
                dist[next.to] = next.cost + dist[v];
                pq.push(P(dist[next.to], next.to));
            }
        }
    }
}

void restorePath(
    std::vector<int> &path,
    const std::vector<int> &dist,
    const std::vector<std::vector<edge>> &graph,
    int e)
{
    int cur = e;
    path.push_back(e);
    while (dist[cur] != 0)
    {
        for (const auto &n : graph[cur])
        {
            if (dist[n.to] + n.cost == dist[cur])
            {
                path.push_back(n.to);
                cur = n.to;
                break;
            }
        }
    }
    std::reverse(path.begin(), path.end());
}

using namespace std;
//    cout << setprecision(20) << ans << "\n";

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

    ll n;
    cin >> n;
    vector<ll> l(86, 0);
    l[0] = 2;
    l[1] = 1;
    for (int i = 2; i <= n; i++)
    {
        l[i] = l[i - 1] + l[i - 2];
    }
    cout << l[n] << "\n";

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[3],i,j=0;
    for(i=0;i<3;i++)
    {
        scanf("%1d",&a[i]);
    }
    for(i=0;i<3;i++)
    {
        if(a[i]==7)
            {printf("Yes\n");
            break;}
            else j++;
    }
    if(j==3)
        printf("No\n");
    return 0;
}


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

int main(){
    long long n, T;
    cin >> n >> T;
    
    vector<long long> t(n);
    for (int i = 0; i < n; i++) cin >> t[i];
    
    long long ans = 0;
    
    for (int i = 1; i < n; i++){
        
        // 次の人が来るまでの時間を計算する
        long long diff = t[i]-t[i-1];
        
        // 次の人がT秒以内に来るならば、お湯は出続ける.
        // そうでなければ, お湯はT秒間出て止まる.
        ans += min(T, diff);
    }
    
    
    // 注意せよ. 最後にボタンが押された時, お湯がT秒間必ず出る.
    ans += T;
    cout << ans << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>


using namespace std;

int main()
{
	int a = 0;
	int b = 0;
	int c = 0;
	int i = 0;
	string str;
	string order;

	cin >> str;
	cin >> c;
	for (i = 0; i < c; i++)
	{
		string rep;
		cin >> order >> a >> b;
		if (order == "print")
		{
			cout << str.substr(a , b - a + 1) << endl;
		}
		else if (order == "reverse")
		{

			string rev = str.substr(a, b - a + 1);        //a文字目からb文字目までをrepとする
			reverse(rev.begin(), rev.end());
			str = str.replace(a, b - a + 1, rev);
//			str = str.substr(0, a) + rev + str.substr(b + 1, str.size() - a - 1);
		}
		else if (order == "replace")
		{

			cin >> rep;
			str = str.replace(a, b - a + 1, rep);
		}
	}

	return 0;
}


Measured memory_bytes: 3232
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    long long int n, m;
    cin >> n >> m;
    
    long long int l, r;
    long long int ansl, ansr;
    ansl = 0;
    ansr = n;
    for (long long int i = 0; i < m; i++) {
        cin >> l >> r;
        ansl = max(ansl, l);
        ansr = min(ansr, r);
    }

    long long int ans = ansr-ansl+1;
    if (ans < 0) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdio>
#include<string>
#include<map>
#include <algorithm>
#include <cmath>
#include<vector>
#include<stack>
#define INF 0x3f3f3f3f  
#define maxn 1000000+10
using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	if (2 * k > (b - a))
	{
		for (int i = a; i <= b; i++)
			cout << i << endl;
		return 0;
	}
	else
	{
		for (int i = a; i < a + k; i++)
			cout << i << endl;
		for (int i = b - k + 1; i <= b; i++)
			cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main() {
  int cnt;
  cin >> cnt;
  unsigned long max_n=0, max_ns_score=(unsigned long)-1;
  for (int i=0; i<cnt; i++) {
    unsigned long n, score;
    cin >> n >> score;
    if (max_n == 0) {
      max_n = n; max_ns_score = score;
    }
    if (max_n < n) {
      max_n = n; max_ns_score = score;
    }
  }
    cout << (max_n+max_ns_score) << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,min=1000,k,j,max=0;
  static int n;
  scanf("%d",&n);
  j=n;
  for(k=n,i=0;i<3;i++){
     k=n%10;
     n=n/10;
     if(k<min) min=k;
     if(k>max) max=k;  
  }
  for(i=0;i<=max;i++){
     if(j<=(min*100+min*10+min)){
       printf("%d%d%d",min,min,min);
       return 0;
     }
       else min++;
  }
  return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

def main():
    for number in m:
        if solve(0, number):
            print('yes')
        else :
            print('no')

def memolize(f):
    cache = {}

    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper

@memolize
def solve(i, m):
    if m == 0:
        return True

    if i >= n:
        return False

    res = solve(i + 1, m) or solve(i + 1, m - a[i])
    return res

if __name__ == '__main__':
    main()



Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define ll long long 
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()

using namespace std;

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

    int n;
    cin >> n;

    string s;
    cin >> s;

    int ans = n;

    rep(i,n-1){
        if(s[i]==s[i+1]) ans--;
    }

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

Measured memory_bytes: 512
n = int(input())
def dfs(s): #sで始まる753数
    if int(s)>n:
        return 0
    ret = 1 if all(s.count(f) for f in "753") else 0
    for c in '753':
        ret += dfs(s+c)
    return ret

print(dfs('0'))

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define rjm	rep(j,m)


#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}


#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define INF bit(60)




int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;	
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
//find_by_order(k) - return iterator k-th largest element (k from 0)
//order_of_key(x) - return number of items that smaller than x
typedef long long LL;

int main() {
	int M, K;
	cin >> M >> K;
	int bil = 1;
	for (int i = 0; i < M; i++) {
		bil *= 2;
	}
	bil--;
	if (K == 0) {
		for (int i = 0; i <= bil; i++) {
			if (i > 0) printf(" ");
			printf("%d", i);
		}
		for (int i = bil; i >= 0; i--) {
			printf(" %d", i);
		}
		printf("\n");
	} else {
		if (bil % 4 == 3) {
			if (K > bil) printf("-1\n");
			else {
				bool awal = 1;
				for (int i = 0; i <= bil; i++) {
					if (i != K) {
						if (!awal) printf(" ");
						awal = 0;
						printf("%d", i);
					}
				}
				printf(" %d", K);
				for (int i = bil; i >= 0; i--) {
					if (i != K) printf(" %d", i);
				}
				printf(" %d\n", K);
			}
		} else printf("-1\n");
	} 
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
# input
S = input()

temp = 0
C = 0
ans = 0

if S[0] == 'A':
    ans += 1

for i in range(2, len(S) - 1):
    if S[i] == 'C':
        temp += 1
        C = i
if temp == 1:
    ans += 1

if S[1].islower():
    for i in range(2, len(S)):
        if i != C and S[i].isupper():
            print('WA')
            exit()
    ans += 1

if ans == 3:
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <vector>
#include <numeric>

using namespace std;
int main() {
	int N, X;
	vector<int> v;

	cin >> N >> X;
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		v.push_back(abs(X - tmp));
	}

	int ans=v.at(0);

	for (int i = 1; i < N; i++)
	{
		ans = __gcd(v.at(i), ans);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
int main(){
	string s,t,u;
	cin>>s>>t>>u;
	s[0]+='A'-'a';
	t[0]+='A'-'a';
	u[0]+='A'-'a';
	cout<<s[0]<<t[0]<<u[0]<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;


int main()
{

int n;
cin>>n;
string s;
cin>>s;

int ans=0;
for(int index=0;index<=s.size()-3;index++)
{
    if(s[index]=='A'&&s[index+1]=='B'&&s[index+2]=='C')
        ans++;
}
cout<<ans<<endl;
return 0;
 }



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int N;
  cin >> N;

  int A[N];
  for(int n; n<N; ++n){
    cin >> A[n];
  }

  sort(A, A+N);

  cout << abs(A[0]-A[N-1]) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    long int max,min,sum;
    int n,a[10001],i;
    scanf("%d",&n);
	    for(i=0;i<n;i++){
	        scanf("%d",&a[i]);
	        if(i==0){
	            max = a[i];
	            min = a[i];
	        }
	        sum += a[i];
	        if(max < a[i]){
	            max =a[i];
	        }
	        if(min > a[i]){
	            min =a[i];
	        }
    }
    printf("%ld %ld %ld\n",min,max,sum);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back

int main(){
    int a,b;
    cin >> a >> b;
    int count=0;
    for(int i=a;i<=b;i++){
        string s=to_string(i);
        if(s[0]==s[4]&&s[1]==s[3]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
*L,=map(int,input().split())

L.sort()
from bisect import*
i=0
ans=0
while i<N:
    j=i+1
    while j<N:
        ans+=bisect_left(L,L[i]+L[j])-j-1
        j+=1
    i+=1

print(ans)


Measured memory_bytes: 9352
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
	int n,g[105],i,a,min=200,max=-200,k;
	long long x,t=999999999;
	scanf("%d",&n);
	memset(g,-99,sizeof(g));
	for(i=0;i<n;i++)
	{
		cin>>g[i];
		a=g[i];
		if(a>max)max=a;
		if(a<min)min=a;
	};
	for(i=min;i<=max;i++)
	{	x=0;
		for(k=0;k<n;k++)
		{
			x=x+(g[k]-i)*(g[k]-i);
		};
		if(x<t)t=x;	
	};
	printf("%d",t);	
	return 0;	
}

Measured memory_bytes: 256
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007


int N,M,X;
int C[20];
int A[20][20];
signed main(){
    scanf("%lld %lld %lld",&N,&M,&X);
    rep(i,N){
        scanf("%lld",&C[i]);
        rep(j,M){
            scanf("%lld",&A[i][j]);
        }
    }
    int ans=LLINF;
    rep(i,1<<N){
        int sans=0;
        int algos[20];
         rep(k,M)algos[k]=0;
        rep(j,N){
            if((i>>j)%2==1){
                sans+=C[j];
                rep(k,M){
                    algos[k]+=A[j][k];
                }
            }
        }
        rep(k,M){
            if(algos[k]<X)break;
            else if(k==M-1)ans=min(sans,ans);
        }

    }
    if(ans==LLINF){printf("-1\n");}
    else{printf("%lld\n",ans);}
    return 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)2e5 + 3;
const int infint = (int)1e9 + 3;
const ll inf = (ll)1e15;
ll n, T, E, x[MAXN], dp[MAXN], seg[4 * MAXN], lazy[4 * MAXN];
void upd(int node, int x)
{
	seg[node] += x;
	lazy[node] += x;
	return;
}
void shift(int node)
{
	upd(node << 1, lazy[node]);
	upd(node << 1 | 1, lazy[node]);
	lazy[node] = 0;
}
void add(int node, int st, int en, int l, int r, int x)
{
	if(l >= en || st >= r)
		return;
	if(l <= st && en <= r)
	{
		upd(node, x);
		return;
	}
	int mid = (st + en) >> 1;
	shift(node);
	add(node << 1, st, mid, l, r, x);
	add(node << 1 | 1, mid, en, l, r, x);
	seg[node] = min(seg[node << 1], seg[node << 1 | 1]);
}
ll get(int node, int st, int en, int l, int r)
{
	if(l >= en || st >= r)
		return inf;
	if(l <= st && en <= r)
		return seg[node];
	int mid = (st + en) >> 1;
	shift(node);
	return min(get(node << 1, st, mid, l, r), get(node << 1 | 1, mid, en, l, r));
}
int main()
{
	ios::sync_with_stdio(false); 
	cin.tie(0); cout.tie(0);
	cin >> n >> E >> T;
	for (int i = 1; i <= n; i++)
		cin >> x[i];
	
	for (int i = 0; i < n; i++)
		add(1, 0, n + 1, i, i + 1, x[i + 1] + T);
	
	add(1, 0, n + 1, 0, 1, -x[1]);
	
	int ptr = 0;
	for (int i = 1; i <= n; i++)
	{
		add(1, 0, n + 1, 0, ptr, 2 * x[i] - 2 * x[i - 1]);
		while(ptr < i && 2 * x[i] - x[ptr + 1] >= x[ptr + 1] + T)
			add(1, 0, n + 1, ptr, ptr + 1, -x[ptr + 1] - T + 2 * x[i] - x[ptr + 1]), ptr++;
		dp[i] = get(1, 0, n + 1, 0, i) + x[i];
		add(1, 0, n + 1, i, i + 1, dp[i] - x[i] - x[i + 1]);
	}
	cout << dp[n] + E - x[n];
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"
*/

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  // z = malloc(sizeof(struct node));  // node構造体サイズのメモリ領域をとる
  z = (Node *)malloc(sizeof(Node));
  z->key = k;   // ポインタ変数にアクセスする時はアロー演算子
  z->left = NIL;
  z->right = NIL;
  
  while(x != NIL){
      y = x;    // 最終的なzの親を決定する
      if(z->key < x->key) x = x->left;
      else x = x->right;
  }
  z->parent = y;
  if(y == NIL){
      root = z; // 親要素が空であれば、zが根となる
  }else{
      if(z->key < y->key){
          y->left = z;
      }else{
          y->right = z;
      }
  }
}

void inorder(Node *u){
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main()
{
    int n, i, x;
    string com;
    scanf("%d", &n);

    rep(i, n){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        }else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
}


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

#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;


void solve() {
    int n;
    cin >> n;
     vector<int> have(int(1e6) + 6);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        have[a[i]]++;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        bool ok = true;
        --have[a[i]];
        for (int div = 1; div * div <= a[i]; ++div) {
            if (a[i] % div == 0) {
                int fdiv = div, sdiv = a[i] / div;
                if (have[fdiv] || have[sdiv]) {
                    ok = false;
                    break;
                }
            }
        }
        ans += ok;
        ++have[a[i]];
    }
    cout << ans << "\n";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 7964
/**
*    created: 04.07.2020 21:56:47
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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 long double pi = acos(-1.0);
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

signed main() {

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

    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int cnt = 0;
    rep(i,n-1) if (a[i] == i + 1) swap(a[i], a[i+1]), cnt++;
    if (a[n-1] == n) cnt++;
    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 3980
import sys
from collections import deque
def input():
    return sys.stdin.readline()[:-1]
def main():
    N, M = map(int,input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        A, B = map(int,input().split())
        G[A-1].append(B-1)
        G[B-1].append(A-1)
    Q = deque([0])
    ans = [-1]*N
    while len(Q) > 0:
        ima = Q.popleft()
        for tsugi in G[ima]:
            if ans[tsugi] == -1:
                ans[tsugi] = ima+1
                Q.append(tsugi)
    print("Yes")
    for e in ans[1:]:
        print(e)
if __name__ == '__main__':
    main()


Measured memory_bytes: 37704
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vi a;

bool f(int m){
	stack<P> st;
	st.push({0,a[0]});
	for(int i=1;i<n;i++){
		if(a[i-1]<a[i]) st.push({0,a[i]-a[i-1]});
		else{
			int t=0,L=a[i-1];
			while(L>a[i]){
				P p=st.top();st.pop();
				L-=p.second;
				if(L<a[i]) st.push({p.first,a[i]-L});
			}
			while(!st.empty()){
				P p=st.top();st.pop();
				if(p.first<m-1){
					p.second--;
					if(p.second) st.push(p);
					st.push({p.first+1,1});
					if(t) st.push({0,t});
					break;
				}
				t+=p.second;
			}
			if(st.empty()) return 0;
		}
	}
	return 1;
}

int main(){
	cin>>n;
	a=vi(n);
	for(auto &i:a) cin>>i;
	int l=0,r=n;
	while(r-l>1){
		int m=(l+r)/2;
		if(f(m)) r=m;
		else l=m;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 2720
s = input()


def isKai(t):
  return list(t) == list(reversed(list(t)))


n = len(s)

if isKai(s) and isKai(s[:(n - 1) // 2]) and isKai(s[(n + 3) // 2 - 1:]):
  print('Yes')
else:
  print('No')


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

Measured memory_bytes: 2588
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = 100010;

int n, k;

vector<ll> v[Maxn];

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

    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        ll t, d;
        cin >> t >> d;
        --t;
        v[t].emplace_back(d);
    }
    for (int i = 0; i < n; ++i) {
        sort(v[i].begin(), v[i].end());
    }
    vector<ll> y0, y1;
    for (int i = 0; i < n; ++i) {
        if (v[i].empty()) continue;
        y1.emplace_back(v[i].back());
        v[i].pop_back();
        y0.insert(y0.end(), v[i].begin(), v[i].end());
    }
    sort(y0.begin(), y0.end(), greater<ll>());
    sort(y1.begin(), y1.end(), greater<ll>());

    int kind = max(0, k - (int) y0.size());
    ll sum = 0;
    for (int i = 0; i < kind; ++i) {
        sum += y1[i];
    }
    for (int i = 0; i < k - kind; ++i) {
        sum += y0[i];
    }

    ll ans = sum + 1LL * kind * kind;
    while (kind <= min(k + 1, (int) y1.size())) {
        ans = max(ans, sum + 1LL * kind * kind);
        sum += y1[kind];
        if (kind >= k) break;
        sum -= y0[k - kind - 1];
        ++kind;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6904
N,K = map(int,input().split())
A = [int(i) for i in input().split()]

within = 0
between = 0
for n in range(N):
    for i in range(N):
        if A[n] > A[i]:
            between += 1
            if n < i:
                within += 1

ans = 0
mod = 10**9+7
ans += within*K
ans %= mod
ans += (between*K*(K-1))//2
ans %= mod

print(ans)


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n, l, MIN = 500, sum = 0;
    cin >> n >> l;
    for(int i = l; i < l + n; i++){
        sum += i;
        if(abs(MIN) > abs(i)) MIN = i;
    }
    print(sum - MIN);
}


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

int a,b,a1,a2;
bool flag;
char s[105][105];

int main(){
//	freopen("1.out","w",stdout);
	cin>>a>>b;
	cout<<100<<" "<<100<<endl;
	if(a>b)swap(a,b),flag=true;else flag=false;b=b-a;
	a=a*2-2;
	a1=a/100+2;a2=a%100;
	for(int j=1;j<=100;j++)s[1][j]='#';
	for(int i=2;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(i<=a1){
				if(i+j&1){
					s[i][j]='#';
				}else{
					s[i][j]='.';
				}
			}
			if(a1+1==i&&j<=a2){
				if(i+j&1){
					s[i][j]='#';
				}else{
					s[i][j]='.';
				}
			}
		}
	}
	for(int j=1;j<=100;j++){
		if(s[a1+1][j]!='.'&&s[a1+1][j]!='#')s[a1+1][j]='.';
	}
	for(int j=1;j<=100;j++){
		s[a1+2][j]='.';
	}
	for(int i=a1+3;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(j&1&&i&1){
				if(b>0){
					b--;
					s[i][j]='#';
				}else{
					s[i][j]='.';
				}
			}else{
				s[i][j]='.';
			}
		}
	}
	for(int i=1;i<=100;i++){
		for(int j=1;j<=100;j++){
			if(flag){
				if(s[i][j]=='.'){
					cout<<'#';
				}else{
					cout<<'.';
				}
			}else cout<<s[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 2000000000000000000
ll gcd(ll a, ll b) {
    if (b > a) return gcd(b, a);
    else if(b == 0) return a;
    else return gcd(b, a % b);
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll A = 1, B = 1;
    rep(i, n) {
        ll t, a;
        cin >> t >> a;
        ll ok = INF2/max(t, a);
        ll ng = 0;
        while(abs(ok - ng) > 1) {
            ll mid = (ok + ng) / 2;
            ll nextA = mid * t;
            ll nextB = mid * a;
            if (nextA >= A && nextB >= B) ok = mid;
            else ng = mid;
        }
        A = ok * t;
        B = ok * a;
        //cout << "*" << A << " " << B << endl;
    }
    cout << A + B << endl;

    return 0;
}
// 1:1 2:3 A = B * 3 * 2 / 2

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		HashMap<Integer, Integer> count = new HashMap<Integer, Integer>();
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		for(int i=0; i<n; i++) {
			int n_likes = sc.nextInt();
			for(int j=0; j<n_likes; j++) {
				int food = sc.nextInt();
				count.merge(food, 1, Integer::sum);
			}
		}
		sc.close();
		int ans = 0;
		for(int key : count.keySet()) {
			if(count.get(key) == n)
				ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 27348
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define YES cout << "YES" << endl
#define NO  cout << "NO"  << endl
#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX powl(2, 63)-1
using namespace std;
typedef long long ll;

int main(){
  int N, H, W;  cin >> N >> H >> W;
  int ans;
  rep(i, 0, N){
    int a, b; cin >> a >> b;
    if(a>=H and b>=W) ans++;
  }
  cout << ans << endl;
  return 0;
}

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 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 mm (1e16)

ll Mod=(1e9+7);

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    int ans=0,count=0;
    for(int i=n-2;i>=0;i--){
        if(v[i]>=v[i+1]) count++;
        else{
            ans=max(ans,count);
            count=0;
        }
    }
    ans=max(count,ans);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

int main() {

	string S;
	int K;
	cin >> K;
	cin >> S;


	if (S.length() <= K) {
		cout << S;
		return 0;
	}
	else {
		for (int i = 0; i < K; i++) {
			cout << S[i];
		}
		cout << "...";
		return 0;


	}


}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if (a+b == c+d) {
        cout << "Balanced\n";
    } else if (a+b > c+d) {
        cout << "Left\n";
    } else {
        cout << "Right\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define f(a, b, c) for (ll(a) = (b); (a) < (c); ++(a))  
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL)); 
#define rep(i, n) f(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define all(v) v.begin(), v.end()  
#define wh(t) while (t--) 
#define inf 1e18
#define modd 998244353
#define pp(var) cout<<var<<"\n";
#define pm(var1, var2) cout<<var1<<" "<<var2<<"\n"; 

const ll N = 2e5 + 5;

ll binpow(ll a,ll n)
{
    ll i=1;
    while(n>0)
    {
        if(n&1)
            i=(i*a);
        a=(a*a);
        n = n>>1;
    }
    return i;
}
 
ll isprime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}

vl w,val;

ll solve(ll W){
	ll n = w.size();
	ll dp[n+1][W+1];
	
	for(ll i = 0; i <= n; ++i){
		for(ll j = 0; j <= W; ++j){
			if(i ==0 || j == 0)
				dp[i][j] = 0;
			else if(w[i-1] <= j){
				dp[i][j] = max(val[i-1] + dp[i-1][j-w[i-1]],dp[i-1][j]);;
			}
			else dp[i][j] = dp[i-1][j];
		}
	}
	return dp[n][W];
}

int main(){
    fast;
    ll n,m,l,r,i,j,k,a,b,c,q,t,x,y,d;
   	ll weight;
	cin>>n>>weight;
   	w.resize(n);
   	val.resize(n);
	rep(i,n){
		cin>>w[i]>>val[i];
	}    
	pp(solve(weight));
}

Measured memory_bytes: 79232
w=input()
dict={}
for i in range(len(w)):
  if w[i] in dict:
    dict[w[i]]+=1
  else:
    dict[w[i]]=1
ans=True
for a,b in dict.items():
  if b%2==1:
    print("No")
    ans=False
    break
if ans:
  print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int sum=0;
  if(a+b>2*c){
    sum+=min(x,y)*2*c;
    if(a>2*c){
      sum+=(x-min(x,y))*2*c;
    }else{
      sum+=(x-min(x,y))*a;
    }

    if(b>2*c){
      sum+=(y-min(x,y))*2*c;
    }else{
      sum+=(y-min(x,y))*b;
    }
  }else{

    if(a>2*c){
      sum+=(x)*2*c;
    }else{
      sum+=(x)*a;
    }

    if(b>2*c){
      sum+=(y)*2*c;
    }else{
      sum+=(y)*b;
    }
  }
  cout<<sum<<endl;
  return 0;
}


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

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n;
   cin >> n;
   vector<int> a(n),val(n+1,0);
   f(i,0,n){
      cin >> a[i];
   }
   f(i,1,n+1){
      cin >> val[i];
   }
   int c[n];
   f(i,1,n){
      cin >> c[i];
   }
   int ans = 0;
   f(i,0,n){
      if(!i){
         ans += val[a[i]];
      }else{
         ans += val[a[i]];
         if(a[i-1]+1 == a[i]){
            ans += c[a[i-1]];
         }
      }
   }
   cout << ans << '\n';
   return 0;
} 

Measured memory_bytes: 256
// RAKSHIT KADAM

 #include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
//int power(int x, unsigned int y, unsigned int m)
//{
//    if (y == 0)
//        return 1;
//    int p = power(x, y/2, m) % m;
//    p = (p * p) % m;
//
//    return (y%2 == 0)? p : (x * p) % m;
//}
//ll modInverse(int a, int m)
//{
//    int g = gcd(a, m);
//
//    {
//        // If a and m are relatively prime, then modulo inverse
//        // is a^(m-2) mode m
//
//             return power(a, m-2, m);
//    }
//}
//int gcd(int a, int b)
//{
//    if (b == 0)
//        return a;
//    return gcd(b, a % b);
//
//}
//vector<ll>v[200080];
//ll vis[200080];
//
//void dfs(ll root)
//{
//    vis[root]=1;
//    for(auto it:v[root])
//    {
//        if(vis[it]==0)
//        {
//            dfs(it);
//        }
//    }
//}
void solve()
{
    
}

 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {
//        solve();
//    }
    ll a,b=0;
    fore(i,0,3){cin>>a;b+=a;}
    if(b>=22)cout<<"bust"<<endl;
    else cout<<"win"<<endl;
  
    return 0;
    }




Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] arg){
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String str = "abcdefghijklmnopqrstuvwxyz";
        int[] count = new int[1000];
        try{
        String x;
            x = reader.readLine();
            while(x != null){
            x = x.toLowerCase();
            for(int n =0; n < x.length() ; n++){
                if(x.charAt(n) == ' ' || x.charAt(n)=='.') continue;
                char z = x.charAt(n);
                count[ z ]++;
            }
            x = reader.readLine();
            }
        }catch(IOException e){
            System.out.println(e);
        }
        for(int i = 0 ; i<str.length(); i++){
            char y = str.charAt(i);
            System.out.println(str.charAt(i) +" : "+ count[y] );
        }
    }
}


Measured memory_bytes: 24324
// Graph
#include <stdio.h>

#define MAX 101

int main(){
  int i, j, n, k, row, col, Adj[MAX][MAX];
  scanf("%d", &n);
  
  for(i=1; i <= n; i++){
    for(j=1; j <= n; j++){
      Adj[i][j] = 0;
    }
  }
  
  for(i=1; i <= n; i++){
    scanf("%d%d", &row, &k);
    for(j=1; j <= k; j++){
      scanf("%d", &col);
      Adj[row][col] = col;
    }
  }
  
  for(i=1; i <= n; i++){
    for(j=1; j <= n; j++){
      if(j != 1)printf(" ");
      if(Adj[i][j] != 0)printf("1");
      else printf("0");
    }
    printf("\n");
  }
  return 0;
}



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

int top,S[1000];

int pop();
void push(int);

int main(){
  int x;
  char s[100];
  top=0;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      x=pop();
      x+=pop();
      push(x);
    }
    else if(s[0]=='-'){
      x=0;
      x-=pop();
      x+=pop();
      push(x);
    }
    else if(s[0]=='*'){
      x=pop();
      x*=pop();
      push(x);
    }
    else push(atoi(s));  
  }
  printf("%d\n",pop());
  return 0;
}
	 
void push(int x){
  S[++top] = x;
}

int pop(void){
  top--;
  return S[top+1];
}



Measured memory_bytes: 2108
#pragma region Macros
#include <bits/stdc++.h>
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;
#pragma endregion
int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);

	string S, T;
	cin >> S >> T;
	cout << T << S << '\n';

	return 0;
}


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

int
main(void)
{
	char line[80];
	int n;
	double xa, ya, ra, xb, yb, rb;
	
	while (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d", &n) == 1) {
			for (int i = 0; i < n; i++) {
				if (fgets(line, sizeof line, stdin) == NULL) {
					return 1;
				}
				if (sscanf(line, "%lf %lf %lf %lf %lf %lf",
						   &xa, &ya, &ra, &xb, &yb, &rb) != 6) {
					return 1;
				}

				double d = sqrt((xb - xa)*(xb - xa) + (yb - ya)*(yb - ya));
				
				int rt;
				if (ra + rb < d) {
					rt = 0;
				} else if (fabs(ra - rb) <= d) {
					rt = 1;
				} else if (ra - rb > d) {
					rt = 2;
				} else {
					rt = -2;
				}

				printf("%d\n", rt);
			}
		}
	}

	return 0;
}

Measured memory_bytes: 1088
H,W,K = map(int,input().split())

c = []
ch = [0]*H        # H=iのときの黒の個数
cw = [0]*W        # W=jのときの黒の個数
sum_cnt = 0         #総数
for i in range(H):
    c_buf = input()
    ch[i] = c_buf.count('#')
    for j in range(W):
        if c_buf[j] == '#':
            cw[j] += 1
    sum_cnt += ch[i]
    c.append(c_buf)

import copy
cw_buf = copy.copy(cw)
ans = 0

for i in range(2**H):
    cw = copy.copy(cw_buf)
    cnt = sum_cnt
    for i2 in range(H):
        if (i >> i2) & 1:
            cnt -= ch[i2]
            for j in range(W):
                if c[i2][j] == '#':
                    cw[j] -= 1

    for j in range(2**W):
        cnt2 = cnt
        for j2 in range(W):
            if (j >> j2)&1:
                cnt2 -= cw[j2]

        if cnt2 == K:
            ans += 1

print(ans)

Measured memory_bytes: 68652
/* It's a shot in the dark
 				But I will make it */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=1000000000;

bool cmp(pair<int,int> a, pair<int,int> b){
	return a.second<b.second;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >>n;
	int a[n],b[n];
	for(int i=0;i<n;i++){
		cin >>a[i]>>b[i];
	}
	bool ok =0;
	for(int i=0;i<n;i++){
		if(i+2<n&&a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
			ok=1;
			break;
		}
	}
	if(ok){
		cout <<"Yes\n";
	}
	else{
		cout <<"No\n";
	}

}


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

int main()
{
    int m1,d1;
    int m2,d2;
    cin>>m1>>d1;
    cin>>m2>>d2;
    if(m1<m2)
    cout<<"1";
    else
    cout<<"0";
    return 0;
}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n+1);
  int cnt=0;
  for(int i=1;i<=n;i++){
    cin >> a[i];
    if(a[i]!=i)
      cnt++;
  }
  if(cnt==0||cnt==2){
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s1 = Console.ReadLine();
		string s2 = Console.ReadLine();
		int ans = 0;
		for(var i=0;i<3;i++){
			if(s1.Substring(i,1)==s2.Substring(i,1)){
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140