akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int A,B,C;cin >> A >> B >> C;
    int hozon = A;
    for(int i = 0;i<500;i++){
        int V = A%B;
        A %= B;
        if(V == C){
            cout << "YES" << endl;
            return 0;
        }
        A += hozon;
    }
    cout << "NO" << endl;
}


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

using namespace std;

int main (int argc, char *argv[]) {
    vector<int> v1(10, 0);
    vector<int> v2(10, 0);
    for (int i = 0; i < 10; ++i) {
        cin>>v1[i];
    }
    for (int i = 0; i < 10; ++i) {
        cin>>v2[i];
    }
    sort(v1.begin(), v1.end(), greater<int>());
    sort(v2.begin(), v2.end(), greater<int>());
    cout<<v1[0]+v1[1]+v1[2]<<" "<<v2[0]+v2[1]+v2[2]<<endl;
    return 0;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X)
{
    cout << (500 * K >= X ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long K;
    scanf("%lld", &K);
    long long X;
    scanf("%lld", &X);
    solve(K, X);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e16
typedef long long ll;


int main() {
    ll N;
    cin >> N;
    ll m = INF;
    REP(i,5){
        ll t;
        cin >> t;
        m = min(m,t);
    }

    cout << 5 + (N-1)/m << endl;


    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define pii pair<ll ,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 1e6+5;
const ll mod=1e18;
ll n,m,a[maxn];
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    m=1;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1);
    if(a[1]==0){
        cout<<0<<'\n';
        return 0;
    }
    ll temp;
    for(int i=1;i<=n;i++){
        temp=mod/m;
        if(a[i]>temp){
            cout<<-1;
            return 0;
        }
        m*=a[i];
    }
    cout<<m;
    return 0;
}


Measured memory_bytes: 4440
#include <bits/stdc++.h>
#define int long long
const int inf = 1e18+9;
using namespace std;
int s,n;
signed main()
{
	cin>>n>>s;
	if(s > n)
	{
		cout<<-1;
		return 0;
	}

	if(s == n)
	{
		cout<<n+1;
		return 0;
	}

	for(int b=2;b<=sqrt(n);b++)
	{
		int ans = 0;
		int val = n;
		while(val > 0)
		{
			ans += (val % b);
			val /= b;
		}

		if(ans == s)
		{
			cout<<b;
			return 0;
		}
	}

	int tmp = n-s, ans = inf;
	// cout<<tmp<<' ';
	for(int i=1;i<=sqrt(n);i++)
	{
		if(tmp % i == 0)
		{
			int j = tmp/i;
			if((j+1) > sqrt(n))
			{
				if(j * (n/(j+1)) == tmp)
					ans = min(ans, j);
			}
		}
	}

	// cout<<"haha2\n";
	if(ans == inf)
	{
		cout<<-1;
		return 0;
	}

	cout<<ans+1;

}

Measured memory_bytes: 256
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
import std.string;
import std.numeric;
import std.range;
void main() {
	for(int count = 1; ; count++){
		auto w = readln.strip.to!int;
		if(w==0) break;
		auto n = readln.strip.to!int;
		auto wv = n.iota.map!(_ => readln.strip.split(',').map!(to!int).array).array;
		int[][] dp = new int[][](n+1,w+1);
		for(int i=n-1;i>=0;i--){
			for(int j=0;j<=w;j++){
				auto cv = wv[i][0];
				auto cw = wv[i][1];
				if(j<cw) dp[i][j] = dp[i+1][j];
				else dp[i][j] = max(dp[i+1][j], dp[i+1][j-cw]+cv);
			}
		}
		writefln("Case %d:", count);
		writeln(dp[0][w]);
		for(int j=w;j>0;j--){
			if(dp[0][w] != dp[0][j]){
				writeln(j+1);
				break;
			}
		}
	}
}

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

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> t(N);
  for (int i=0;i<N;++i) cin >> t[i];
  
  int ans=0;
  for (int i=0;i<N;++i){
    ans+=min(T, t[i]-t[i-1]);
  }
  ans+=T;//これ忘れた。ansがT個の数の和じゃなきゃおかしい。
  cout << ans << endl;
}


Measured memory_bytes: 1024
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    d = int(readline())
    c = list(map(int, readline().split()))
    s = [list(map(int, readline().split())) for _ in range(d)]
    for i in range(d):
        print(s[i].index(max(s[i])) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68096
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

bool dp[4001][16001];
int x,y,tx,ty,ax[4001],ay[4001];

void dfsx(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<tx){
		dfsx(t+1,n+ax[t]);
		dfsx(t+1,n-ax[t]);
	}
	dp[t][n+8000]=1;
}

void dfsy(int t,int n){
	if(dp[t][n+8000]) return;
	if(t<ty){
		dfsy(t+1,n+ay[t]);
		dfsy(t+1,n-ay[t]);
	}
	dp[t][n+8000]=1;
}

int main()
{
	ios::sync_with_stdio(false);
	string s;
	cin>>s>>x>>y;
	bool fx=1;
	for(int i=0;i<s.length();i++){
		if(s[i]=='F'){
			if(fx) ax[tx]++;
			else ay[ty]++;
		}
		else{
			if(fx) fx=0,tx++;
			else fx=1,ty++;
		}
	}
	if(s[s.length()-1]=='F'){
		if(fx) tx++;
		else ty++;
	}
	dfsx(1,ax[0]);
	bool xx=dp[tx][8000+x]?1:0;
	memset(dp,0,sizeof(dp));
	dfsy(0,0);
	bool yy=dp[ty][8000+y]?1:0;
	if(xx&&yy) cout<<"Yes";
	else cout<<"No";
}

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


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

int comp(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}

int main(int argc, char **argv)
{
    int n, k;
    scanf("%d %d", &n, &k);

    int *l = (int *) calloc(n, sizeof(int));
    for (int i = 0; i < n; ++i) {
        scanf("%d", &l[i]);
    }
    qsort(l, n, sizeof(int), comp);

    int s = 0;
    for (int i = 0; i < k; ++i) {
        s += l[i];
    }
    printf("%d\n", s);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <string>
using namespace std;
int n;
struct mmtime
{
   int day,mon;
   int h,m;
   mmtime(){};
   void mset(int _day,int _mon,int _h,int _m)
   {
	   day=_day;
	   mon=_mon;
	   h=_h;m=_m;
   }
   void read()
   {
	   scanf("%d/%d %d:%d",&mon,&day,&h,&m);
   }   
   int  operator-(const mmtime & t)
   {
	   int nh=h-t.h;
	   int nm=m-t.m;
	   if (nm<0) {--nh;nm+=60;}
	   return nh*60+nm;
   }
};
struct md
{
   mmtime mytime;
   char type;
   int id;
   void read()
   {
	   char d[10];
	   mytime.read();
	   scanf("%s",d);
	   type=d[0];
	   scanf("%d",&id);
   }   
   bool operator<(const md& t) const
   {
	   return id<t.id;
   }
   int getv()
   {
	   return mytime.h*60+mytime.m;
   }
};
md data[1003];
int sum[1003];
int main()
{
	//freopen("in.txt","r",stdin);
	//froepen("out.txt","w",stdout);
    while (~scanf("%d",&n) && n)
	{	
		memset(sum,0,sizeof sum);
	    for (int i=0;i<n;++i)
		  data[i].read();
		
	    stable_sort(data,data+n);
         
//	for (int i=0;i<n;++i)
  //   	{
	//		printf("%d\n",data[i].id);
	//	}
	//	printf("--------------\n");
		int gn=0;
		while (data[gn].id==0) ++gn;
//	printf("-=-=-=-  %d\n",gn);
		int sn=0;
        for (int i=gn+1;i<n;i=i+2)
		{
			int a=data[i-1].getv();
			int b=data[i].getv();
			for (int k=1;k<gn;k=k+2)
			{
				int aa=data[k-1].getv();
				int bb=data[k].getv();
				if (data[i].mytime.day!=data[k].mytime.day || data[i].mytime.mon !=data[k].mytime.mon)
					continue;
                if (b<=aa|| bb<=a) continue;
				int jj[4];
				jj[0]=a;jj[1]=b;jj[2]=aa;jj[3]=bb;
				sort(jj,jj+4);
				//printf("%d %d %d %d \n",a,b,aa,bb);
				//printf("====%d \n",jj[2]-jj[1]);
				sum[sn]+=jj[2]-jj[1];
			}
			 if (i+1>=n || data[i].id!=data[i+1].id) 
			  ++sn;	
		
		}
	    int ans=0;	
		//for (int i=0;i<7;++i) printf("%d\n",sum[i]);
		for (int i=0;i<105;++i)
			ans=max(ans,sum[i]);
		printf("%d\n",ans);
	}
    
	return 0;
}

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

using namespace std;

struct Info
{
    int num;
    string name;
    int point;
    
    Info(int inputted_num,string inputted_name, int inputted_point)
    {
        num = inputted_num;
        name = inputted_name;
        point = inputted_point;
    }
};

bool cmp(const Info &a, const Info &b)
{   if(a.name == b.name){
    return b.point <a.point;
}
    return a.name < b.name;
}


int main() {
    int n; cin>>n;
    vector<Info> info;
    for(int i=0;i<n;i++){
        string tmp1;
        int tmp2;
        cin>>tmp1>>tmp2;
        info.push_back(Info(i+1,tmp1,tmp2));
        
       sort(info.begin(), info.end(),cmp);
    }
    
    for (auto itr : info)
    {
        cout<<itr.num<< endl;
    }
    return 0;
}


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

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

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

Int G[101][101];

int main() {
    Int n;
    cin >> n;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < n; j++) {
            cin >> G[i][j];
        }
    }
    Int sum = 0;
    for (Int i = 0; i < n; i++) {
        for (Int j = 0; j < n; j++) {
            sum += G[i][j];
        }
    }
    for (Int i = 0; i < n; i++) {
       for (Int j = i + 1; j < n; j++) {
           sum -= max(G[i][j], G[j][i]);
        }
    }
    dump(sum);
    return 0;
}



Measured memory_bytes: 3176
N=int(input())
people=list(input())

Wlist=[0]*(N+1)
Elist=[0]*(N+1)
for i in range(N):
    Wlist[i+1]=Wlist[i]
    if people[i]=='W':
        Wlist[i+1]+=1
    Elist[i+1]=Elist[i]
    if people[i]=='E':
        Elist[i+1]+=1

#print(Wlist)
#print(Elist)

List=[]
for i in range(N):
    List.append(Wlist[i]+(Elist[N]-Elist[i+1]))

print(min(List))

Measured memory_bytes: 31820
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define repi_(i,a,b) for(int i=(a), i##_len=(b); i<=i##_len; ++i)
#define rep_(i,n) repi_(i,0,n)
#define all(x) (x).begin(),(x).end()
#define vsort(v) sort((v).begin(), (v).end())
#define gsort(v) tsort(v); reverse((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define cnt(v, n) count(all(v), n)
#define vmin(v) *min_element(v.begin(), v.end())
#define vmax(v) *max_element(v.begin(), v.end())
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define cosp(x) cout<<(x)<<' '
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#define POSSIBLE(c) coc(c, "POSSIBLE", "IMPOSSIBLE")
#define Possible(c) coc(c, "Possible", "Impossible")
#define possible(c) coc(c, "possible", "impossible")
#define inf INT_MAX
#ifdef tqktmp_2
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif


typedef long long lint;
typedef vector<int> ivec; typedef vector<string> svec;

lint dx[8] = { 0,1,1,1,0,-1,-1,-1 },
dy[8] = { 1,1,0,-1,-1,-1,0,1 };

template<class T>inline bool maxi(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool mini(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }




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

	lint a; cin >> a;
	string s; cin >> s;
	lint l = s.length();
	lint x = 0;
	lint mx=0;
	rep(i, l) {
		if (s[i] == 'I')x++;
		else x--;
		maxi(mx, x);
	}
	co(mx);
	gc();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int t=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]!=s[s.size()-i-1])
		t++;
	}
	cout<<t/2;
	return 0;
}

Measured memory_bytes: 256
require 'prime'

M = 10 ** 5 + 1

is_prime = [false] * M
is_like_2017 = [false] * M
primes = Prime.each(M).to_a

primes.each{ |p| is_prime[p] = true }
primes.each{ |p| is_like_2017[p] = true if is_prime[(p+1)/2] }

sum = [0] * M

(1...M).each do |i|
  sum[i] = sum[i-1]
  sum[i] += 1 if is_like_2017[i]
end

Q = gets.to_i
Q.times do |i|
  l, r = gets.split.map(&:to_i)
  puts sum[r] - sum[l-1]
end

Measured memory_bytes: 5304
#include<stdio.h>

int main(void)
{
   int n, l[100], i, x, s=0;

   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%d",&l[i]);
      s+=l[i];
   }

   x=l[0];
   for(i=1;i<n;i++)
      if(l[i]>x)
         x=l[i];

   if(x*2<s)
      printf("Yes\n");
   else
      printf("No\n");
   return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a >= 9 || b >= 9) {
        cout << ":(" << endl;
    }
    else  {
        cout << "Yay!" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

LL A, B;

void solve()
{
    if (A == B) {
        puts("1");
        return;
    }

    LL ans = 0;

    for (int i = 60; i >= 0; --i) {
        LL a = A >> i & 1, b = B >> i & 1;
        if (a ^ b) {
            LL t = 1ll << i;
            assert(A < t && B >= t);
            int l;
            for (l = i - 1; l >= 0; --l) {
                if (B >> l & 1)
                    break;
            }
            ans = t - A + std::min((t - A) + (1ll << (l + 1)), t);
            break;
        }
        A ^= a << i;
        B ^= b << i;
    }

    printf("%lld\n", ans);
}

int main()
{
#ifdef __DEBUG
    freopen("D.in", "r", stdin);
    freopen("D.out", "w", stdout);
#endif

    read(A); read(B);
    solve();

    return 0;
}

// 若言琴上有琴声，放在匣中何不鸣？
//     -- 苏轼《琴诗》


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

n = max(a,max(b,c))

if n == a:
	print((2**k)*n+b+c)
elif n == b:
	print((2**k)*n+a+c)
else:
	print((2**k)*n+a+b)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,m;
  cin>>n>>m;
  int arr[200000];
  for(int i=0;i<m;i++)cin>>arr[i];
  sort(arr,arr+m);
    int _min=arr[m-1]-arr[0];
  for(int i=0;i<m-1;i++)
    _min=min(_min,n-arr[i+1]+arr[i]);
  cout<<_min;
}

Measured memory_bytes: 1024
#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>;

const ll mod = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> L(k);
    vector<int> R(k);
    rep(i,k){
        cin >> L[i] >> R[i];
    }
    vector<mint> dp(n+1,0);
    vector <mint> dpsum(n+1,0);
    dpsum[1] = 1;
    dp[1] = 1;
    for (int i = 2; i < n+1; i++){
        rep(j,k){
          int li = i-R[j];
          int ri = i-L[j];
          if (ri < 0) continue;
          li = max(1,li);
          dp[i] += dpsum[ri]-dpsum[li-1];
        }
        dpsum[i] = dpsum[i-1]+dp[i];
    }
    
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 6340
#include <iostream>

using namespace std;

int main(){
   int a[2],in;
   a[0] = a[1] = 0;
   for(int i=0;i<2;i++){
      for(int j=0;j<4;j++){
	 cin >> in;
	 a[i] += in;
      }
   }
   cout << (a[0]>a[1]? a[0]:a[1]) << endl;
   return 0;
}

Measured memory_bytes: 1160
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<utility>//pair
#include<list>
#include<vector>//可変長配列
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define all(a) (a).begin(),(a).end()
#define mp make_pair
#define pb push_back
#define ll __int64
#define __int64 long long
#define P pair<int,int>
#define PP pair<ll,ll>
#define F first
#define S second
int dx[8] = { 1,0,-1,0,1,-1,-1,1 };
int dy[8] = { 0,1,0,-1,1,1,-1,-1 };


double l;

int main() {
	cin >> l;
	double ok = 0.0, ng = l;
	rep(i, 1000) {
		double mid = (ok + ng) / 2;
		if (mid + mid + mid > l)
			ng = mid;
		else
			ok = mid;
	}
	printf("%.10lf\n", ng*ng*ng);
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int year,month,date;
  
  year = atoi(S.substr(0,4).c_str());
  month = atoi(S.substr(5,2).c_str());
  date = atoi(S.substr(8,2).c_str());
  
  bool flag =false;
  if(year < 2019){
    flag = true;
  }else if(year == 2019){
    if(month < 4){
      flag = true;
    }else if(month == 4 && date <= 30){
      flag = true;
    }
  }
  
  if(flag)cout << "Heisei" <<endl;
  else cout << "TBD" << endl;
}

Measured memory_bytes: 256
function Main(input) {

	input = input.split("\n");
	
    const X = parseInt(input[0]);

    if (400<=X && X<600) {
        console.log( '8' );
    } else if (600<=X && X<800) {
        console.log( '7' );
    } else if (800<=X && X<1000) {
        console.log( '6' );
    } else if (1000<=X && X<1200) {
        console.log( '5' );
    }else if (1200<=X && X<1400) {
        console.log( '4' );
    }else if (1400<=X && X<1600) {
        console.log( '3' );
    }else if (1600<=X && X<1800) {
        console.log( '2' );
    }else if (1800<=X && X<2000) {
        console.log( '1' );
    }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

int main()
{
    char c;
    int s = 0;
    while (cin >> c) {
        s += (c-'0');
        s %= 9;
    }
    cout << (s ? "No" : "Yes") << '\n';
    return 0;
}


Measured memory_bytes: 3588
class combination():
    #素数のmod取るときのみ　速い
    def __init__(self, n, mod):
        self.n = n
        self.fac = [1] * (n + 1)
        self.inv = [1] * (n + 1)
        for j in range(1, n + 1):
            self.fac[j] = self.fac[j - 1] * j % mod

        self.inv[n] = pow(self.fac[n], mod - 2, mod)
        for j in range(n - 1, -1, -1):
            self.inv[j] = self.inv[j + 1] * (j + 1) % mod

    def comb(self, n, r, mod):
        if r > n or n < 0 or r < 0:
            return 0
        return self.fac[n] * self.inv[n - r] * self.inv[r] % mod

def examA():
    N, P = LI()
    A = LI()
    odd = 0; even = 0
    for a in A:
        if a%2==1:
            odd +=1
        else:
            even +=1
    C = combination(N,mod)
    ans = 0
    if P==1:
        for i in range((odd+1)//2):
            ans += 2**even * C.comb(odd,i*2+1,mod)
    else:
        for i in range(odd//2+1):
            ans += 2**even * C.comb(odd,i*2,mod)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,inf
mod = 10**9 + 7
inf = 10**18

if __name__ == '__main__':
    examA()


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		for(int i = 0;i < n;i++){
			String str = scan.nextLine();
			str = str.replaceAll("Hoshino","Hoshina");
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 17268
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INF = 1000000007;
const int mod = 1000000007;

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

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

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

//----------------------------------------------------------------

int main()
{
    ll x, y;
    cin >> x >> y;
    int cnt = 0;
    while (x <= y)
    {
        cnt++;
        x = x * 2;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    inlis = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        for j in range(n):
            if i < j:
                ans += inlis[i] * inlis[j]
    print(ans)
    
    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 63292
#include <stdio.h>

int main(void) {

  int x, y, z, k, s;
  int count = 0;
  scanf("%d%d", &k, &s);

  for (x = 0; x <= k; x++) {
    for (y = 0; y <= k; y++) {
      if ((s - (x + y)) >= 0 && (s - (x + y)) <= k)
         count++;
      }
    }

  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 128
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

A = LS()

acum = 0
stack = []
for a in A:
    if a == '+':
        acum = stack.pop()
        acum += stack.pop()
        stack.append(acum)
    elif a == '-':
        acum = stack.pop()
        acum = stack.pop() - acum
        stack.append(acum)
    elif a == '*':
        acum = stack.pop()
        acum *= stack.pop()
        stack.append(acum)
    else:
        stack.append(int(a))
print(acum)


Measured memory_bytes: 6792
with Ada.Text_IO;
use Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Integer_Text_IO;

procedure Main is
	x:Integer;
    y:Integer;
    z:Integer;
begin
	get(x);
	get(y);
	get(z);
    put(z);
    new_line;
    put(x);
    new_line;
    put(y);
    new_line;
end Main;

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

const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
const int MOD=1000000007;

vector<P>E[500000];
int c[500000];

int main(){
	int x,y,z,n,m;cin>>x>>y>>z>>n>>m;
	int s,t;cin>>s>>t;s--;t--;
	int d=x+y+z;
	rep(i,n){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[d+i].push_back(P(1,a));
		E[d+i].push_back(P(1,x+b));
		E[a].push_back(P(0,d+i));
		E[x+b].push_back(P(0,d+i));
	}
	int e=x+y+z+n;
	rep(i,m){
		int c,d;scanf("%d%d",&c,&d);c--;d--;
		E[e+i].push_back(P(1,x+c));
		E[e+i].push_back(P(1,x+y+d));
		E[x+c].push_back(P(0,e+i));
		E[x+y+d].push_back(P(0,e+i));
	}
	memset(c,0x3f,sizeof(c));
	deque<int>que;
	c[s+d]=0;que.push_front(s+d);
	while(!que.empty()){
		int p=que.front();que.pop_front();
		for(auto u:E[p]){
			if(c[u.second]>c[p]+u.first){
				c[u.second]=c[p]+u.first;
				if(u.first==0)que.push_front(u.second);
				else que.push_back(u.second);
			}
		}
	}
	int ans=c[d+n+t];
	if(ans==INF)puts("-1");
	else cout<<ans<<endl;
}


Measured memory_bytes: 31624
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

function Main(input) {

    var abcstr = input[0].split(' ');
    var abc = [parseInt(abcstr[0], 10), parseInt(abcstr[1], 10), parseInt(abcstr[2], 10)];

    abc.sort(function(a, b) {
        if (a < b) return 1;
        if (a > b) return -1;
        return 0;
    });

    var k = parseInt(input[1], 10);

    var i = 0;
    for (i = 0; i < k; i++) {
        abc[0] *= 2;
    }

    var ans = 0;
    for (i = 0; i < abc.length; i++) {
        ans += abc[i];
    }

    console.log(ans);

    return 0;
}


Measured memory_bytes: 7628
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    char[] s = scanner.next().toCharArray();
    long k = scanner.nextLong();

    for (char ch : s) {
      if (ch == '1') {
        k--;
        if (k == 0) {
          System.out.println('1');
          return;
        }
      } else {
        System.out.println(ch);
        return;
      }
    }
  }
}


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

using namespace std;

#define DB( x ) cout << #x << " = " << x << endl;
#define LEFT(n) (2 * (n))
#define RIGHT(n) (2 * (n) + 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> node;
//typedef vector <vector <ll>> matrix;

const ll INF = 1e9;
const double EPS = 1e-9;
const ll MOD = (ll)(1000000007);
const ll MAXV = (ll)(1e5 - 100);
const ll MAXE = (ll)(1e6 + 10);


int main(){
	cin.sync_with_stdio( 0 );cin.tie( 0 );

	int n;

	cin >> n;

	vector<int> A(n);

	for(int i = 0;i < n;i ++)
		cin >> A[i];

	bool ok = true;
	for(int i = n - 2;i >= 0;i --)
		if(A[i] > A[i + 1]){
			A[i] --;
			if(A[i] > A[i + 1]){
				ok = false;
				break;
			}
		}

	if(ok)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<char> S(N);
  for (int i = 0; i < N; i++) {
  	cin >> S.at(i);
  }
  
  vector<int> counts(4);
  for (int i = 0; i < N; i++) {
  	if (S.at(i) == 'P') counts.at(0)++;
    if (S.at(i) == 'W') counts.at(1)++;
    if (S.at(i) == 'G') counts.at(2)++;
    if (S.at(i) == 'Y') counts.at(3)++;
  }
 
  int sum = 0;
  for (int i = 0; i < 4; i++) {
    if (counts.at(i) > 0) sum++;
  }
  if (sum == 3) cout << "Three" << endl;
  else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
signed main(){
  ll n;
  cin>>n;
  if(n<=111){
	cout<<"111\n";
  }else if(n>111 && n<=222){
    cout<<"222\n";
  }else if(n>222 && n<=333){
    cout<<"333\n";
  }else if(n>333 && n<=444){
    cout<<"444\n";
  }else if(n>444 && n<=555){
    cout<<"555\n";
  }else if(n>555 && n<=666){
    cout<<"666\n";
  }else if(n>666 && n<=777){
    cout<<"777\n";
  }else if(n>777 && n<=888){
    cout<<"888\n";
   }else if(n>888){
    cout<<"999\n";
  }
  return(0);
}

Measured memory_bytes: 256
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    sscanf($line, '%d %d %d', $c1, $c2, $c3);
    $card = array_fill(1, 10, 0);
    $sum = $c1 + $c2;
    $diff = 20 - $sum;
    ++$card[$c1] && ++$card[$c2] && ++$card[$c3];
    $n = 0;
    for ($i = 1; $i <= 10; $i++) {
        $i <= $diff && !$card[$i] && $n++;
    }
    echo $n / 7 * 100 >= 50 ? "YES\n" : "NO\n";
}

Measured memory_bytes: 6624
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int p[100];
    int maxP = 0, maxI;
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(maxP<p[i]){
            maxP = p[i];
            maxI = i;
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        if(i == maxI){
            ans += p[i]/2;
        }else{
            ans += p[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

void debug_out() { std::cout << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n)-1); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n)-1); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    int weight;
    edge(int f,int t,int w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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

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

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

bool isPalindrome(string s){
    string t = s;
    reverse(all(t));
    return s==t;
}

constexpr ll INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

std::vector<int> Eratosthenes( const int N )
{
    std::vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    auto p = Eratosthenes(n);
    vector<ll> c(p.size());
    Rep(i,2,n+1){
        int x = i;
        int flag = 0;
        while(x>1){
            if(x%p[flag]==0){
                x /= p[flag];
                c[flag]++;
            }
            else{
                flag++;
            }
        }
    }
    vector<ll> q(5);
    for(auto s: c){
        if(s>=74) q[4]++;
        if(s>=24) q[3]++;
        if(s>=14) q[2]++;
        if(s>=4) q[1]++;
        if(s>=2) q[0]++;
    }
    ll ans = 0;
    ans += q[4];
    ans += q[3]*(q[0]-1);
    ans += q[2]*(q[1]-1);
    ans += q[1]*(q[1]-1)*(q[0]-2)/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
  int A, B, C, k;scanf("%d%d%d%d", &A, &B, &C, &k);
  return  printf("%d\n",
                 k <= A  ?  k : 
                  (k <= A + B ? A 
                   	: A - (k - A - B))
           ), 0;
}


Measured memory_bytes: 1736
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
#define RF(x) freopen(x,"r",stdin)
#define WF(x) freopen(x,"w",stdout)
typedef long long LL;
using namespace std;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
const LL MOD = 1e9+7;
const int SIZE = 1e6+5;
const LL INF = 1LL<<60;
const double eps = 1e-4;
const double PI=3.1415926535897932;
const int SZE = 1e6+1;

int p[200009][2];

int fp(int x,int i){
	if(p[x][i]==x)return x;
	return p[x][i]=fp(p[x][i],i);
}

void mg(int x,int y,int i){
	int p1=fp(x,i),p2=fp(y,i);
	p[p1][i]=p[p2][i];
}

PII v[200009];

int main(){
	DRIII(n,k,l);
	REP(i,n)p[i][0]=p[i][1]=i;
	REP(i,k){
		DRII(a,b);a--;b--;
		mg(a,b,0);
	}
	REP(i,l){
		DRII(a,b);a--;b--;
		mg(a,b,1);
	}
	REP(i,n)v[i]=MP(fp(i,0),fp(i,1));
	sort(v,v+n);
	REP(i,n){
		PII vv=MP(fp(i,0),fp(i,1));
		printf("%lld ",upper_bound(v,v+n,vv)-lower_bound(v,v+n,vv));
	}
}


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

int main()
{
    int N;
    int count = 0;
    cin >> N;
    for (int i = 1;i < N + 1;i++) {
        if (to_string(i).length() % 2 == 1) {
            count++;
        }
    }
    cout << count<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s,t;
  cin>>s>>t;
  int n=s.size();
  int m=t.size();
  vector<vector<int>>a(n+1,vector<int>(m+1));
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
    {
      if(s[i-1]==t[j-1])
        a[i][j]=a[i-1][j-1]+1;
      else
        a[i][j]=max(a[i-1][j],a[i][j-1]);
    }
  }
  string ans=" ";
  int x=n,y=m;
  while(y!=0 && x!=0)
  {
    if(a[x-1][y]==a[x][y])
      --x;
    else if(a[x][y-1]==a[x][y])
      --y;
    else
    {
      ans=t[y-1]+ans;
      --x;
      --y;
    }
  }
  cout<<ans<<"\n";
  return 0;
}

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

using namespace std;

vector < pair<int, int> > rocas;
vector < vector <int>  >table(102,vector <int> (10002));
vector < vector <bool> >visited(102, vector <bool> (10002));

int dp(int,int);
int main(){
        int n,weight;
        cin>>n>>weight;
        rocas.resize(n);
        for(int i=0; i<n; i++){
                cin>>rocas[i].first>>rocas[i].second;
        }
        cout<<dp(0,weight)<<"\n";
}
int dp(int ind,int weight){
        if(ind==rocas.size() || weight==0){
                return 0;
        }
        if(weight<0){
                return (-pow(2,31));
        }
        if(visited[ind][weight]){
                return table[ind][weight];
        }
        visited[ind][weight]=true;
        //int si=recursive(ind+1,weight);
        int no=dp(ind,weight-rocas[ind].second)+rocas[ind].first;
        int si=dp(ind+1,weight);
        table[ind][weight]=max(si,no);
        return table[ind][weight];

}



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

int main() {
	string s;
	cin >> s;
	
	set<int> set;
	for(int i = 0; i < s.length() - 1; i++)
		for(int j = i + 1; j < s.length(); j++){
			if (s[i] != s[j]){
				set.insert(i);
				set.insert(j);
			}
		}
	if (set.size() == 3){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;


int main()
{
    int n ;
    cin >> n ;
    double c = 0;
    while (n--)
    {
        double a ; string s; 
        cin >> a >> s;
        if(s == "JPY"){
            c+=a;
        }
        else{
            c+=(380000.0*a);
        }
    }
    cout << c << endl; 
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a,b;
  cin>>a>>b;
  if(a.at(0)==b.at(2)&&a.at(1)==b.at(1)&&a.at(2)==b.at(0)) {
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>

#define rep(i,n) for (long long int i = 0; i < (n); i++)
#define rep1(i,n) for (long long int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

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

int main()
{
    int n, m; cin >> n >> m;
    int ac = 0, wa = 0;
    vector<int> acv(n, 0), wav(n,0);
    rep(i,m) {
        int p;
        string s;
        cin >> p; cin >> s;
        p--;
        if (s == "WA" && wav[p] >= 0) {
            wav[p]++;
        } else if (s == "AC" && wav[p] >= 0) {
            wa += wav[p];
            wav[p] = -1;
            ac++;
        }
    }
    cout << ac << " " << wa << endl;

    return 0;
}


Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

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

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    int a[100005];
    int ans = 0;
    
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        ans += a[i] / 2;
        a[i] %= 2;
        if (a[i] == 1&&i!=n-1&&a[i+1]>0) {
            ans++;
            a[i] = 0;
            a[i + 1]--;
        }
    }
    cout << ans << endl;

    return 0;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

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

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}
} uf;

void answer(bool f) {
	puts(f ? "Yes" : "No");
	exit(0);
}

int main() {
	int N; cin >> N;
	V<int> A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	V<pii> sa(N), sb(N);
	rep(i, N) sa[i] = mp(A[i], i);
	rep(i, N) sb[i] = mp(B[i], i);
	sort(ALL(sa)); sort(ALL(sb));

	uf.init(N);

	rep(i, N) {
		if (sa[i].fi > sb[i].fi) {
			answer(0);
		}
		uf.unite(sa[i].se, sb[i].se);
	}

	rep(i, N) {
		if (i > 0 && sa[i].fi <= sb[i-1].fi) {
			answer(1);
		}
		if (uf.find(i) != uf.find(0)) {
			answer(1);
		}
	}
	answer(0);

	return 0;
}

Measured memory_bytes: 3328