akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

static class CodeJam
{
    static int Solve(int N, int K, string S)
    {
        var list = new List<int>();
        for (int i = 0; i < N;)
        {
            int c0 = 0, c1 = 0;
            while (i < N && S[i] == '1') { ++c1; ++i; }
            while (i < N && S[i] == '0') { ++c0; ++i; }
            list.Add(c1);
            list.Add(c0);
        }
        switch (S.Last())
        {
        case '0': list.Add(0); break;
        case '1': list.RemoveAt(list.Count - 1); break;
        }

        if (list.Count <= 3)
        {
            return N;
        }
        else
        {
            int n = Math.Min(list.Count, K * 2 + 1);
            int sum = list.Take(n).Sum();
            int max = sum;
            for (int i = n; i + 1 < list.Count; i += 2)
            {
                sum -= list[i - n];
                sum -= list[i - n + 1];
                sum += list[i];
                sum += list[i + 1];
                max = Math.Max(sum, max);
            }
            return max;
        }
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var S = Console.ReadLine();
        Console.WriteLine(Solve(V[0], V[1], S));
    }
}


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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    int h,n;
    cin>>h>>n;
    Vi a(n);
    REP(i,n) cin>>a[i];

    int sum_a = SUM(a);
    if(sum_a>=h){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}

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

#define MAX 3000

int dp[MAX + 1][MAX + 1];

string getLCS(string &s, string &t, int len) {
    string LCS;
    int i = 0, j = 0;
    while(len > 0) {
        if(s[i] == t[j]) {
            LCS.push_back(s[i]);
            i++;
            j++;
            len--;
        }
        else {
            if(dp[i][j + 1] > dp[i + 1][j]) j++;
            else i++;
        }
    }
    return LCS;
}

// Top Down Approach
int lengthLCS(string &s, string &t, int i, int j) {
    if((i >= s.length()) || (j >= t.length())) return 0; // Base Case
    if(dp[i][j] != -1) return dp[i][j]; // Look Up
    // Recursive Case
    if(s[i] == t[j]) return (dp[i][j] = (1 + lengthLCS(s, t, (i + 1), (j + 1))));
    else return (dp[i][j] = max(lengthLCS(s, t, i, (j + 1)), lengthLCS(s, t, (i + 1), j)));
}

string LCS(string s, string t) {
    memset(dp, -1, sizeof(dp));
    int len = lengthLCS(s, t, 0, 0);
    return getLCS(s, t, len);
}

int main() {
    string s, t;
    cin >> s >> t;
    cout << LCS(s, t) << endl;
    return 0;
}

Measured memory_bytes: 39156
k = gets.chomp.to_i

arr = Array.new(k+1,0)

ngo = 7
(k+1).times do |i|
	arr[i] = ngo % k
	ngo = (ngo * 10 + 7) % k
	#puts i if i%10000 == 0
end

ngo = arr.index{|a| a == 0}  
puts ngo != nil ? ngo + 1 : -1

Measured memory_bytes: 21852
import java.util.Scanner;

public class Main {
    //Power Socket
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(), b = sc.nextInt();
        int cnt = 0;
        int plugs = 1;
        while (plugs < b) {
            cnt++;
            plugs += a - 1;
        }
        System.out.println(cnt);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define MAX 200010
#define inf 1<<30
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int v,e,r;
vector<pii> g[MAX];

void dijkstra(){
  int d[MAX];
  priority_queue<pii,vector<pii>,greater<pii> > pq;
  fill(d,d+MAX,inf);
  d[r]=0;
  pq.push(mp(0,r));

  while(pq.size()){
    pii u=pq.top();
    pq.pop();
    if(d[u.s]<u.f)continue;

    FOR(i,0,g[u.s].size()){
      int next=g[u.s][i].f;
      int cost=d[u.s]+g[u.s][i].s;
      if(cost<d[next]){
        d[next]=cost;
        pq.push(mp(cost,next));
      }
    }
  }
  FOR(i,0,v){
    if(d[i]==inf)cout<<"INF"<<endl;
    else cout<<d[i]<<endl;
  }
  return;
}

int main()
{
  cin>>v>>e>>r;
  FOR(i,0,e){
    int a,b,c;
    cin>>a>>b>>c;
    g[a].pb(mp(b,c));
  }
  dijkstra();
  return 0;
}

Measured memory_bytes: 15844
k = int(input())
if k%2==0:
    k = (k/2)*(k/2)
    k = int(k)
    print(k)
else:
    k = (k/2)
    k = int(k)
    k1 = k+1
    k2 = k* k1
    k2 = int(k2)
    print(k2)



Measured memory_bytes: 2940
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int n;//料理の種類
int x;
int sum;
bool prime[1000001];
int main()
{

  for(int i = 0;i <1000001;i++){
    prime[i] = true;
  }
  prime[0] = false;
  prime[1] = false;
  for(int i = 2;i <1000001;i++){
    if(prime[i]){
      for(int j = 2*i;j <1000001;j+=i){
	prime[j]= false;
      }
    }
  }
  while(cin>>n>>x,n||x){
    bool flag1=false;
    int dish[40];
    bool check[1000001];
    for(int i = 0;i < 1000001;i++){
      check[i]=false;
    }
    for(int i = 0;i < n;i++){
      cin>>dish[i];
    }
    check[0] =true;//0はどの料理からでも作れる
    for(int i = 0;i <=x;i++){
      if(check[i]){
	for(int j = 0;j <n;j++){
	  if(i + dish[j]<=x)
	    check[i+dish[j]] = true;
	}
      }
    }
    int ans = 0;

    for(int i =x;i >0;i--){//上から調べる
      if(check[i]&&prime[i]){
	flag1 = true;
	ans = i;
	break;
      }
    }
 for(int i = 0 ;i < 100000000;i++){
     x +=1;
     x -=1;
}
    if(flag1)
      cout <<ans<<endl;
    else
      cout <<"NA"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3112
import sys

s = input()
t = input()


lists = [_ for _ in s]
listt = [_ for _ in t]



for i in range(0,len(s)):
    for j in range(0, len(t)):
        if s[i]<t[j]:
            print('Yes')
            sys.exit()

lists.sort()
listt.sort()

if len(lists)<len(listt) and lists[0:len(lists)]==listt[0:len(lists)]:
    print('Yes')
    sys.exit()

print('No')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    if(n*a>=b)
        cout<<b;
    else
    {
        cout<<n*a;
    }
    
	return 0;
}

Measured memory_bytes: 3584
from itertools import product
INF = 2<<30
while True:
    N = input()
    if N == 0:
        break
    g = [[INF if i!=j else 0 for j in xrange(11)] for i in xrange(11)]
    used = [False]*11
    for _ in xrange(N):
        a,b,c = map(int,raw_input().split())
        g[a][b] = g[b][a] = c
        used[a] = used[b] = True
    for k,i,j in product(xrange(11),repeat=3):
        g[i][j] = min(g[i][j],g[i][k]+g[k][j])
    a = [sum(filter(lambda x:x<(INF),g[i])) if used[i] else INF for i in xrange(11)]
    print "{} {}".format(*min(zip(range(11),a),key=lambda(i,s):s))

Measured memory_bytes: 4412
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main(){
  prep();
  int n;
  cin >> n;
  vector<pair<int, int> > arr[n];
  for (int i=0; i<n; i++){
      int nn;
      cin >> nn;
      for (int j=0; j<nn; j++){
          int x, y;
          cin >> x >> y;
          arr[i].push_back({x, y});
      }
  }
  int poww = pow(2, n);
  int maxx = 0;
  for (int i=0; i<poww; i++){
      bitset<16> bs(i);
      
      bool good = true;
      for (int j=0; j<n; j++){
          bool once = false;
          for (int k=0; k<arr[j].size(); k++){
              int a, b;
              a = arr[j][k].first;
              b = arr[j][k].second;
              
              
              if (bs[a-1] != b){
                  once = true;
              }
              
          }
          int lie = bs[j]^1;
          if (lie && !once){
              good = false;
              break;
          }else if (!lie && once){
              good = false;
              break;
          }
      }
      if (good){
          maxx = max(maxx, (int)bs.count());
      }
  }
  cout << maxx;
  return 0; 
}


Measured memory_bytes: 256
def solve freq, n
  half = n / 2
  color = "NO COLOR"
  freq.size.times do |i|
    if freq[i] && freq[i] > half
      color = i
      break
    end
  end
  color
end

until (n = $stdin.gets.to_i) == 0
  freq = Array.new
  star = $stdin.gets.chomp.split(" ").map(&:to_i).sort!
  star.each do |color|
    freq[color] = 0 if freq[color] == nil
    freq[color] += 1
  end
  puts solve(freq, n)
end

Measured memory_bytes: 129040
from collections import deque
 
O=input()
E=input()
 
o=deque(O)
e=deque(E)
 
s=''
while True:
  if not e  and not o:
    break
  if o:
    s+=o.popleft()
  if e:
    s+=e.popleft()
    
  
print(s)

Measured memory_bytes: 9032
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
vector<ll> a , b , A , B;
int main()
{
        cin >> n;
        A.resize(n);
        B.resize(n);
        for(ll i=0;i<n;i++) cin >> A[i];
        for(ll i=0;i<n;i++) cin >> B[i];
        ll T = 0;
        //sort(B.begin() , B.end());
        ll ans = 0LL;
        for(ll i = 0 ; i <= 28 ; i++)
        {
                T = 1LL << i;
                ll ret = 0;
                a.clear();
                b.clear();
                a = A;
                b = B;
                for(ll i=0;i<n;i++) a[i] = (a[i] % (T+T));
                for(ll i=0;i<n;i++) b[i] = (b[i] % (T+T));
                sort(b.begin() , b.end());
                for(auto j : a)
                {
                        auto st = lower_bound(b.begin() , b.end() , T - j);
                        auto ed = lower_bound(b.begin() , b.end() , T+T - j);
                        ret = (ret + (ed-st))%2;
                        st = lower_bound(b.begin() , b.end() , T+T+T - j);
                        ed = lower_bound(b.begin() , b.end() , T+T+T+T - j);
                        ret = (ret + (ed-st))%2;
                }
                ret = ret % 2;
                if(ret) ans += (1LL << i);
        }
        cout << ans <<endl;
        return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <map>
#include <string.h>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(a) (a).begin(), (a).end()
using namespace std;
int main(){
    int h,w;
    cin >> h >> w;
    int cnt = 0;
    rep(i,h){
        string s;
        cin >> s;
        rep(j,w){
            if(s.at(j) == '#') cnt++;
            if(cnt == h + w){
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
}


Measured memory_bytes: 256
#include<iostream>

int main(){

    int a ,b;

    std::cin >> a >> b;

    if(a >= 13)
        std::cout << b << std::endl;
    else if(a >= 6 && a <= 12)
        std::cout << b / 2 << std::endl;
    else
        std::cout << 0 << std::endl;
    
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int ans = 0;
    switch (S) {
      case "SUN":
        ans = 7;
        break;
      case "MON":
        ans = 6;
        break;
      case "TUE":
        ans = 5;
        break;
      case "WED":
        ans = 4;
        break;
      case "THU":
        ans = 3;
        break;
      case "FRI":
        ans = 2;
        break;
      case "SAT":
        ans = 1;
        break;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a;
    long long x;
    int q=500;
    int i,k;
    cin >> k >> x;
        a=q*k;

    if(a>=x)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")

#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define o cout<<"BUG"<<endl;
#define	IOS ios_base::sync_with_stdio(0);
#define en "\n"
#define FOR(i, j, n) for(int j = i; j < n; ++j)
#define forn(i, j, n) for(int j = i; j <= n; ++j)
#define nfor(i, j, n) for(int j = n; j >= i; --j)
#define sortv(vv) sort(vv.begin(), vv.end())
#define all(v) v.begin(), v.end()
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>


using namespace std;
const ll maxn=1e5+100,inf=1e18,LOG=23,mod=1e9+7;
int block = 300, timer = 0;
const ld EPS = 1e-7;

#define bt(i) (1 << (i))
#define int ll

int k, dp[60][12];

main()
{
	cin >> k;
	dp[1][0] = 1;
	dp[1][1] = 1;
	dp[1][2] = 1;
	dp[1][3] = 1;
	dp[1][4] = 1;
	dp[1][5] = 1;
	dp[1][6] = 1;
	dp[1][7] = 1;
	dp[1][8] = 1;
	dp[1][9] = 1;
	forn(2, i, 19)
	{
		forn(0, last, 9)
		{
			if(last > 0)
				dp[i][last] += dp[i - 1][last - 1];
			dp[i][last] += dp[i - 1][last];
			if(last < 9)
				dp[i][last] += dp[i - 1][last + 1];
		}
	}
	int S = 0;
	int len = 0;
	vector <int> v;
	forn(1, i, 19)
	{
		forn(1, last, 9)
		{
			S += dp[i][last];
			if(S >= k)
			{
				len = i;
				v.pb(last);
				k -= S - dp[i][last];
				break;
			}
		}
		if(len != 0) break;
	}
	nfor(1, i, len - 1)
	{
		S = 0;
		if(v.back() - 1 >= 0)
		{
			S += dp[i][v.back() - 1];
		}
		if(S >= k)
		{
			v.pb(v.back() - 1);
			continue;
		}
		S += dp[i][v.back()];
		if(S >= k)
		{
			k -= S - dp[i][v.back()];
			v.pb(v.back());
			continue;
		}
		if(v.back() + 1 <= 9)
		{
			S += dp[i][v.back() + 1];
		}
		if(S >= k)
		{
			k -= S - dp[i][v.back() + 1];
			v.pb(v.back() + 1);
			continue;
		}
	}
	for(auto i : v)
	{
		cout << i;
	}
}

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

int main(){
 int K,S;
 cin >> K >> S;

 int ans = 0;

 for(int x = 0; x <= K; ++x){
    for(int y = 0; y <= K; ++y){
       int z = S - x - y;
       if(0 <= z && z <= K) ans++;
    }
 }
 cout << ans << endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N, M;
	cin >> N >> M;

	vector<vector<int>> g(N);
	for(int i = 0; i < M; i++){
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
	}
	int S, T;
	cin >> S >> T;
	S--; T--;

	queue<P> que;
	que.push(P(S, 0));
	vector<vector<int>> dist(N, vector<int>(3, INF));
	dist[S][0] = 0;
	while(not que.empty()){
		P p = que.front(); que.pop();
		int v = p.first, l = p.second;
		for(int nv: g[v]){
			int nl = (l+1) % 3;
			if(dist[nv][nl] != INF) continue;
			dist[nv][nl] = dist[v][l] + 1;
			que.push(P(nv, nl));
		}
	}

	cout << (dist[T][0] == INF ? -1 : dist[T][0] / 3) << '\n';

	return 0;
}

Measured memory_bytes: 11136
def euclid_gcd(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp
    if b == 0:
        return a
    else:
        return euclid_gcd(b, a % b)

def gcd(n_list):
    ans = n_list[0]
    for n in n_list:
       ans = euclid_gcd(ans, n)
    return ans



if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    answer = gcd(A)

    print(answer)

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

int main()
{
	uint32_t n, m, mi = 1;
	cin >> n >> m;
	if (n == 1)
	{
		cout << m;
		return 0;
	}
	for (uint32_t i = 2, j = min((uint32_t)sqrt(m), m / n); i <= j; i++)
		if (m%i == 0)
		{
			if (i < n && (m / i) >= n) mi = i;
			else if (i >= n)
			{
				mi = max(m / i, mi);
				break;
			}
		}
	cout << mi << endl;
	return 0;
}
 

Measured memory_bytes: 256
n, a, b = map(int, input().split())


def sum_digit(n):
    result = 0
    while True:
        result += (n % 10)
        n //= 10
        if n == 0:
            break

    return result


summary = 0
for i in range(1, n + 1):
    sum_of_digits = sum_digit(i)
    if a <= sum_of_digits <= b:
        summary += i

print(summary)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[8]={-1,-1,-1,0,0,1,1,1},dy[8]={-1,0,1,-1,1,-1,0,1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  while(cin >> n >> m && n) {
    string s[n];
    rep(i,n) R s[i];
    map<string,int> d;
    rep(i,n) {
      rep(j,m) {
        rep(k,8) {
          string t="";
          int x=i,y=j;
          while(1) {
            t+=s[x][y];
            d[t]++;
            x+=dx[k];
            y+=dy[k];
            if(x<0) x+=n;
            if(x>=n) x-=n;
            if(y<0) y+=m;
            if(y>=m) y-=m;
            if(x==i&&y==j) break;
          }
        }
      }
    }
    string ans="0";
    tr(it,d) {
      if(it->F.size()<=1 || it->S<2) continue;
      if(ans.size()<it->F.size()) ans=it->F;
      else if(ans.size()==it->F.size()) ans=min(ans,it->F);
    }
    pr(ans);
  }
}

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


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

int main(){
  int ac = 0,wa = 0,tle = 0,re = 0;
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    string x;
    cin >> x;
    if(x == "AC"){
      ac++;
    }
    else if(x == "WA"){
      wa++;
    }
    else if(x == "TLE"){
      tle++;
    }
    else{
      re++;
    }
  }
  
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	reverse(ALL(s));
	if (s.size() <= 4) {
		cout << "NO" << endl; return 0;
	}
	string t = "";
	rep(i, s.size() - 4) {
		if (i < s.size() - 6 && s.substr(i, 7) == "remaerd") {
			t += "remaerd";
			i += 6;
		}
		else if (i < s.size() - 5 && s.substr(i, 6) == "resare") {
			t += "resare";
			i += 5;
		}
		else if (i < s.size() - 4 && s.substr(i, 5) == "maerd") {
			t += "maerd";
			i += 4;
		}
		else if (i < s.size() - 4 && s.substr(i, 5) == "esare") {
			t += "esare"; i += 4;
		}
		else {
			cout << "NO" << endl; return 0;
		}
	}
	if (s == t)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    vector<vector<int>> a(n, vector<int>(m));
    for(auto& i : b){
        cin >> i;
    }
    for(auto& i : a){
        for(auto& j : i){
            cin >> j;
        }
    }
    int ans = 0;
    REP(i, n){
        int sum = c;
        REP(j, m){
            sum += a[i][j] * b[j];
        }
        if(sum > 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int a, b;
    cin >> a >> b;
    cout << (a*3 + b)/2; 
    cout << endl;
}


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

int main() {
  vector<int> vec(3);
  cin >> vec.at(0) >> vec.at(1) >>vec.at(2);
  
  sort(vec.begin(),vec.end());
  
  if(vec[0] == vec[1] && vec[1] != vec[2] || vec[0] != vec[1] && vec[1] == vec[2]) {
    cout <<"Yes" <<endl;
  }
  
  else {
    cout <<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i <= (n); ++i)
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans = "No";
	if (a + b >= c)ans = "Yes";
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n, t=-1;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (t == -1) t = a[i];
        else if (t != a[i]) t = -2;
    }
    if (t != -2) {
        cout << 0 << endl;
        return 0;
    }
    sort(a.begin(), a.end());
    int ans = 1e9+7;
    for (int i=a[0]; i<=a[a.size()-1]; ++i) {
        int sum = 0;
        for (int j = 0; j < n; ++j) {
            sum += pow(a[j]-i, 2);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_C&lang=jp
#  Koch Curve : python3
#  2018.12.09 yonezawa


#from collections import deque
import sys
input = sys.stdin.readline
import cProfile
from math import cos,sin,radians

t = set()
def koch(n,st,ed):
    if (n == 0 ):
        print ('{:.8f} {:.8f}'.format(*ed))
        return
    s1 = st
    s5 = ed
    (x1,y1) = st
    (x5,y5) = ed

    x2 = x1 + (x5 - x1) / 3.0
    y2 = y1 + (y5 - y1)  / 3.0
    s2 = (x2,y2)

    x4 = x1 + ((x5 -x1 ) / 3.0 ) * 2
    y4 = y1 + ((y5 - y1) / 3.0 ) * 2
    s4 = (x4,y4)

    x3 = (x4-x2) * cos(radians(60)) - (y4-y2 ) * sin(radians(60)) + x2
    y3 = (x4-x2) * sin(radians(60)) + (y4-y2 ) * cos(radians(60)) + y2
    s3 = (x3,y3)

    t.add(s1)
    t.add(s2)
    t.add(s3)
    t.add(s4)
    t.add(s5)
    #print ("n=",n,*s1)
    koch (n-1,s1,s2)
    #print ("n=",n,*s2)
    koch (n-1,s2,s3)
    #print ("n=",n,*s3)
    koch (n-1,s3,s4)
    #print ("n=",n,*s4)
    koch (n-1,s4,s5)
    #print ("n=",n,*s5)

def main():
    n = int(input())
#    if ( n == 0):
#        print ('{:.8f} {:.8f}'.format(0,0))
#        print ('{:.8f} {:.8f}'.format(100,0))
#        return
    print ('{:.8f} {:.8f}'.format(0,0))
    koch(n,(0,0),(100,0))

#    l = sorted(t)
#    for i in l:
#        print ('{:.8f} {:.8f}'.format(*i))
if __name__ == '__main__':
    main()
    #pr = cProfile.Profile()
    #pr.runcall(main)
    #pr.print_stats()


Measured memory_bytes: 8068
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
#include <set>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 200000;
ll n;
ll a[MAX_N];

ll calc(ll b) {
  ll res = 0;
  REP(i, n) {
    res += abs(a[i] - (b + i));
  }
  return res;
}

int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  ll lb = -INFi, ub = INFi;
  while(ub - lb > 2) {
    ll lmid = (ub + lb) / 2, umid = (ub + lb) / 2 + 1;
    ll calcl = calc(lmid);
    ll calcu = calc(umid);
    if (calcl < calcu) ub = umid;
    else if (calcl > calcu) lb = lmid;
    else break;
  }

  ll ans = min(calc(ub), calc(lb));
  cout <<  min(calc((ub + lb) / 2), ans) << endl;;


  return 0;
}


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

int main() {
  string s;
  cin>>s;
  int vec[4]={0};
  for(int i=0;i<s.size();i++){
    if(s[i]=='N'){
      vec[0]++;
    }
    if(s[i]=='W'){
      vec[1]++;
    }
    if(s[i]=='S'){
      vec[2]++;
    }
    if(s[i]=='E'){
      vec[3]++;
    }
  }
  if(min(vec[0],vec[2])==0&&max(vec[0],vec[2])>0){
    cout<<"No"<<endl;
    return 0;
  }
  if(min(vec[1],vec[3])==0&&max(vec[1],vec[3])>0){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
 
int main()
{
  int n;
  string s;
  cin >> n >> s;
  
  string ans;
  if(s.size() <= n)
  {
    ans = s;
  }
  else
  {
    ans = s.substr(0, n);
    ans += "...";
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3608
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

import math


n = ni()

nums = [1]*(n+1)

for i in range(2,n+1):
  for j in range(i,n+1,i):
    nums[j]+=1

# print(nums)
cnt=0
for i in range(n+1):
  cnt+=nums[i]*i

print(cnt)

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

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

    char x[300];
    memset(x, 0, sizeof(x));

    bool y[300];
    memset(y, 0, sizeof(y));

    for (int i = 0; i < 200; i++) x[i] = i;

    for (int i = 0; i < s1.size(); i++) {
        char c = s1[i] - 'a';
        char d = s2[i] - 'a';
        
        if (x[c] == d) {
            y[d] = 1;
            continue;
        }
        if (y[x[c]] == 1 || y[d] == 1) {
            //cout << i << endl;
            //cout << (char)(x[c] + 'a') << endl;
            goto fail;
        }
        char p = x[c];
        for (int i = 0; i < 26; i++) {
            if (x[i] == p) {
                x[i] = d;
            } else if (x[i] == d) {
                x[i] = p;
            }
        }
        y[d] = 1;
    }

    success:
        cout << "Yes" << endl;
        return 0;
    fail:
        cout << "No" << endl;
        return 0;
    return 0;
}


Measured memory_bytes: 776
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;

void solv()
{
	char S[10]; scanf("%s", S);
	sort(S, S + 4);
	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

const int maxn=1e5+100;
int dp[maxn],arr[maxn];

int main() {
	std::ios::sync_with_stdio(false);
	int N,K;
	cin >> N >> K;
	for(int i=1; i<=N; i++) {
		cin >> arr[i];
		dp[i] = 0x3f3f3f3f;
	}
	dp[0] = dp[1] = 0;
	for(int k=2; k<=N; k++)
		for(int i=min(k-1,K); i>0; i--) dp[k] = min(dp[k],dp[k-i]+abs(arr[k]-arr[k-i]));
	cout << dp[N] << endl;
	return 0;
}

Measured memory_bytes: 1152
#include <bits//stdc++.h>
using namespace std;
#define int long long
#define rep(i,n,k) for(int i=n;i<k;i++)
#define P make_pair
#define F first
#define S second
#define M LLONG_MAX
signed main(void){
    int n,m,ans,w,p,q;
    ans=0;
    string s,s1,s2;
    cin>>s>>n;
    rep(i,0,n){
        cin>>m;
        if(m==1){
            ans++;
            string t;
            t=s1;
            s1=s2;
            s2=t;
            continue;
        }
        cin>>p;
        string t;
        cin>>t;
        if(p==1)
        s1+=t;
        else
        s2+=t;
    }
    if(ans%2){
        string t;
        t=s;
        rep(i,0,s.size()){
            s[i]=t[s.size()-i-1];
        }
    }
    string t;
    rep(i,0,s1.size())
    cout<<s1[s1.size()-i-1];
    rep(i,0,s.size())
    cout<<s[i];
    rep(i,0,s2.size())
    cout<<s2[i];
    cout<<endl;
    
}


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

using namespace std;

int main()
{
    string s,x="";
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if (s[i]=='B')
        {
            if (x!="")
                x.erase(x.size()-1,1);
        }
        else
            x+=s[i];
    }
    cout<<x;
    return 0;
}


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

vector<int> a;

int main() {
	int n, m, sum = 0;
	cin >> n >> m;
	a = vector<int>(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}

	double rate = (double)1 / (double)(4 * m);
	sort(a.rbegin(), a.rend());
	for (int i = 0; i < m; i++) {
		if (a[i] < (sum * rate)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

string s;

void init()
{
	cin >> s;
}



void solve()
{
	rep(i, s.length()) {
		if (s[i] == ',') cout << ' ';
		else cout << s[i];
	}
	cout << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan =  new Scanner(System.in);
		
		int n = scan.nextInt();
		int k = scan.nextInt();
		int a[] = new int[n];
		long ans  = 0;
		for(int i=0;i<n;i++) {
			a[i] = scan.nextInt();
		}
		
		for(int i=0;i<n;i++) {
			ans += a[i];
			if(i>=k) {
				if(ans-a[i-k] > ans-a[i]) {
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
				
				ans -= a[i-k];
			}
		}
		
		

	}

}


Measured memory_bytes: 60436
#include "bits/stdc++.h"
using namespace std;

const int maxn = 1e5 + 10;

int n;
string s;
vector <string> test;
int dp[maxn];

int f(int i) {
	if(dp[i] == -1) {
		if(i == n)
			return dp[i] = 1;

		dp[i] = 0;

		for(auto S: test) {
			int sz = (int)S.size();

			if(i + sz - 1 < n) {
				string cmp = s.substr(i, sz);
				
				if(S == cmp)
					dp[i] |= f(i + sz);
			}
		}
	}

	return dp[i];
}

int main() {
	cin >> s;
	n = (int)s.size();

	test.push_back("dream");
	test.push_back("dreamer");
	test.push_back("erase");
	test.push_back("eraser");

	memset(dp, -1, sizeof(dp));

	if(f(0))
		printf("YES\n");
	else
		printf("NO\n");

	return 0;
}	

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

using namespace std;

template<typename T>
class SegTree {
public:
    explicit SegTree(int n, T def) : actualN(n), N(calcN_(n)), def(def), mVal(2*calcN_(n), def) {}
    explicit SegTree(const vector<T>& v, T def) : actualN(v.size()), N(calcN_(v.size())), def(def), mVal(2*calcN_(v.size()), def) {
        for(int i=0;i<actualN;i++) mVal[i+N] = v[i];
        for(int i=N-1;i;i--) mVal[i] = operate(mVal[2*i], mVal[2*i+1]);
    }
    void update(int idx, T value){
        int i = N + idx;
        update_(mVal[i], value);
        for(int t=i/2;t>=1;t/=2){
            mVal[t] = operate(mVal[2*t], mVal[2*t+1]);
        }
    }
    T get(int l, int r){
        l = max(0, l);
        r = min(N, r);
        int offset = N;
        T resL = def;
        T resR = def;
        while(offset > 0){
            if(l >= r) break;
            if(l&1){ resL = operate(resL, mVal[offset+l]); l++; }
            if(r&1){ resR = operate(mVal[offset+r-1], resR); }
            l /= 2;
            r /= 2;
            offset /= 2;
        }
        return operate(resL, resR);
    }
    int maxRight(int l, T v){
        l = max(0, l) + N;
        T resL = def;
        while(l){
            if(l&1){
                T next = operate(resL, mVal[l]);
                if(next >= v){
                    while(l < N){
                        l *= 2;
                        next = operate(resL, mVal[l]);
                        if(next < v){
                            resL = next;
                            ++l;
                        }
                    }
                    return l - N;
                }
                resL = next;
                if(!(l&(l+1))) break;
                l++;
            }
            l /= 2;
        }
        return actualN;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void update_(T& data, T val) { data = val; }
    T operate(T a, T b) { return max(a, b); }
    const int N;
    const int actualN;
    const T def;
    vector<T> mVal;
};

int main(){
    int N, Q; cin >> N >> Q;
    vector<int> v(N);
    for(auto& t : v) cin >> t;
    SegTree<int> seg(v, 0);
    for(int i=0;i<Q;i++){
        int t, x, v; cin >> t >> x >> v;
        if(t==1){
            seg.update(x-1, v);
        } else if(t==2){
            cout << seg.get(x-1, v) << endl;
        } else {
            cout << seg.maxRight(x-1, v) + 1 << endl;
        }
    }
}

Measured memory_bytes: 6076
#include <iostream>
#include <cstdio>

using namespace std;

int calcDay(int y, int m, int d) {
	int total_day = 0;
	for (int i = 1; i <= 1000; ++i) {
		for (int j = 1; j <= 10; ++j) {
			if (i % 3 == 0 || j % 2 != 0) {
				for (int k = 1; k <= 20; ++k) {
					total_day++;
					if (i == y && j == m && k == d) {
						return total_day;
					}
				}
			}
			else {
				for (int k = 1; k <= 19; ++k) {
					total_day++;
					if (i == y && j == m && k == d) {
						return total_day;
					}

				}
			}
		}
	}
	return total_day;
}

int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		int mday = calcDay(1000, 1, 1);

		int y, m, d;
		cin >> y >> m >> d;

		int bday = calcDay(y, m, d);

		printf("%d\n", mday - bday);
	
	}
}

Measured memory_bytes: 1144
import { stringLiteral } from "@babel/types"

// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { X: number, A: number } => {
  const [X, A] = lines[0].split(' ').map(line => +line)
  const obj = { X, A }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { X, A } = parseLines(lines)
  if (X < A) {
    return '0'
  } else {
    return '10'
  }
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}


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

ll n, m, w[109], v[109], dp[109][100009];

ll call(ll i, ll j)
{
    if(i == 0)
        return 0;
    if(dp[i][j] != 0)
        return dp[i][j];
    if(j < w[i])
        dp[i][j] = call(i-1, j);
    else
        dp[i][j] = max(call(i-1, j), call(i-1, j-w[i]) + v[i]);
    return dp[i][j];
}

int main()
{
    ll i;
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        cin >> w[i] >> v[i];

    cout << call(n, m);
}


Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

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






int main() {
   int h,w;
   cin >> h >> w;
   char c[h+1][w+1];
   rep (i,h){
       rep (j,w){
           cin >> c[i][j];
       }
   }
   int cnt = 0;
   for (int i = 0;i < h;){
       cnt ++;
       rep (j,w){
        cout << c[i][j];
       }
       cout << endl;
       if (cnt == 2){
           cnt = 0;
           i++;
       }
       //cout << i << endl;
   }

}

Measured memory_bytes: 256
int i,n,a,b,x,y;
  for(;scanf("%d",&n),n;printf("%d %d\n",a,b)){
    for(a=b=i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      if(x>y)a+=x+y;
      else if(x<y)b+=x+y;
      else a+=x,b+=x;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string s;
    vector<char> st;
    cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'T' && st.size() > 0 && st.back() == 'S'){
            st.pop_back();
            continue;
        }else{
            st.push_back(s[i]);
        }
    }
    cout << st.size() << endl;
    return 0;
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl
using namespace std;
int main()
{
    int r, g;
    cin >> r >> g;
    cout << r + 2 * (g - r) << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9+7;

long long dp[101][4][4][4];
//文字数 最後から 3 2 1文字目の3つ
//dp[10][3][2][2]は10文字で最後が322の文字数
int main(void){
	int N;
	cin >> N;
	//長さ0の文字列は1である
	//0,1,2に関する制約しかないので
	//Sは333Sと考えてもよい
	//iが文字列の文字数
	dp[0][3][3][3]=1;
	for(int i=0;i<N;i++){
		//jが最後から3文字目の文字
		for(int j=0;j<4;j++){
			//kが最後から2文字目の文字
			for(int k=0;k<4;k++){
				//lが最後から1文字目の文字
				for(int l=0;l<4;l++){
					//条件に当てはまるものがないときcontinue;
					if(dp[i][j][k][l]==0)continue;
					//新しく追加する文字
					for(int a=0;a<4;a++){
						if(a==2&&k==0&&l==1)continue;
						if(a==2&&k==1&&l==0)continue;
						if(a==1&&k==0&&l==2)continue;
						if(a==2&&j==0&&l==1)continue;
						if(a==2&&j==0&&k==1)continue;
						dp[i+1][k][l][a]+=dp[i][j][k][l];
						dp[i+1][k][l][a]%=mod;
					}
				}
			}
		}
	}
	long long ans = 0;
	for(int i=0;i<4;i++)for(int j=0;j<4;j++)for(int k=0;k<4;k++){
		ans+=dp[N][i][j][k];
		ans%=mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
H,W = [int(x) for x in input().split()]
A = [[int(x) for x in input().split()]for _ in range(H)]
flag= 0
ans = []
for i in range(H):
  if i%2==0:
    for j in range(W):
      if A[i][j]%2==1 and flag!=1:
        flag=1
        A[i][j] -=1
      elif A[i][j]%2==1 and flag==1:
        A[i][j]+=1
        flag=0
      if flag==1:
        if j<W-1:
          ans.append([i+1,j+1,i+1,j+2])
        else:
          if i+2<=H:
            ans.append([i+1,j+1,i+2,j+1])
  elif i%2==1:
    for j in range(W-1,-1,-1):
      if A[i][j]%2==1 and flag!=1:
        flag=1
        A[i][j] -=1
      elif A[i][j]%2==1 and flag==1:
        A[i][j]+=1
        flag=0
      if flag==1:
        if j>0:
          ans.append([i+1,j+1,i+1,j])
        else:
          if i+2<=H:
            ans.append([i+1,j+1,i+2,j+1])
print(len(ans))
for a,b,c,d in ans:
  print(a,b,c,d)

Measured memory_bytes: 72924
#define ll long long
#define lld long double
#define cn(n)  ll n;cin >> n;
#define tes(t) ll t;cin>>t;while(t--) 
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define al(v) v.begin(), v.end()
#define oset(X) tree<X, null_type, less<X>, rb_tree_tag, tree_order_statistics_node_update>
#define roset(X) tree<X, null_type, greater<X>, rb_tree_tag, tree_order_statistics_node_update>
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const ll MOD2 = 998244353;
const long double PI = 3.141592653589793;
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
ll power(ll x, ll y, ll p){ll res = 1;x %= p;while (y > 0){if (y & 1)res = (res * x) % p;y = y >> 1;x = (x * x) % p;}return res;}
ll po(ll base, ll powerRaised){if (powerRaised != 0)return (base * po(base, powerRaised - 1));else return 1;}
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a * b) / gcd(a, b);}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif //*
  // tes(t)
  // {
  
  // }
  ll n;
  cin>>n;
  if(n>=30)
  cout<<"Yes";
  else cout<<"No";

  
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); i++)
#define RREP(i, a, b) for(int i=(int)(a); i>=(int)(b); i--)
#define ALL(v) v.begin(), v.end()
#define INF 2e9
typedef long long ll;
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(a>b){a=b; return 1;}return 0;}

using namespace std;

int main()
{
    int L, R;
    cin >> L >> R;
    int m=INF;
    int range=L+4038;
    if(R-L<4038){
        range=R;
    }
    REP(i, L, range){
        REP(j, i+1, range+1){
            chmin(m, ((i%2019)*(j%2019))%2019);
        }
    }
    cout << m << endl;
    return 0;
}


Measured memory_bytes: 256