akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll I, O, T, J, L, S, Z;
int main(){
  cin >>I>>O>>T>>J>>L>>S>>Z;

  ll ans = O;
  ans += (I/2+ L/2+ J/2) * 2;

  ll ans2 = O;
  if (I > 0 && J > 0 && L > 0){
    ans2 += 3;
    ans2 += ((I-1)/2 + (L-1)/2+(J-1)/2) * 2;
  }
  cout << max(ans, ans2) << endl;

  return 0;
}


Measured memory_bytes: 3572
N, A, B, C, D = map(int, input().split())
S = list(input())

res = 'Yes'
# case 1
if C < D:
    for i in range(A-1, C-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'
    for i in range(B-1, D-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'
else:
    cnt = 0
    for i in range(B-2, D-1):
        if S[i] == '.' and S[i+1] == '.' and S[i+2] == '.':
            cnt += 1
    if cnt == 0:
        res = 'No'
    for i in range(A-1, C-1):
        if S[i] == '#' and S[i+1] == '#':
            res = 'No'

print(res)


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

int main() {
	string c;
	long long int conb=0,ans=0;
	cin>>c;
	for (char ch:c){
		if (ch=='B') conb++;
		else ans+=conb;
		
	}
	cout<<ans<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#define rep(i,n) for(int i=0;i<(n);++i)
typedef long int ll;
using namespace std;

int main(){
    int n;
    cin >> n;
    map<string,int> mp;
    rep(i,n) {
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        mp[s]++;
    } 
    ll ans = 0;
    for(auto itr = mp.begin();itr != mp.end();++itr){
        int s = itr -> second;
        ans += (ll)s*(s-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111




	void solve(){


		ini(n);
		if(n == 3){
			return out(2,3,55);
		}
		else if(n  == 4){
			return out(2,3,9,10);
		}
		else if(n == 5){
			return out(2,3,6,9,10);
		}
		else if(n == 6){
			return out(2,3,9,10,12,24);
		}
		else{
			vi morty;
			int one = 1;
			int tmp = 0;
			while(one){

				FOR(i,0,310000){
					morty.push_back(i*6+2);
					tmp+=i*6+2;
					if(morty.size() == n){one = 0;break;}
					morty.push_back(i*6+3);
					tmp+=i*6+3;
					if(morty.size() == n){one = 0;break;}
					morty.push_back(i*6+4);
					tmp+=i*6+4;
					if(morty.size() == n){one = 0;break;}
					morty.push_back(i*6+6);
					tmp+=i*6+6;
					if(morty.size() == n){one = 0;break;}
				}
			}
			if(tmp%6 == 2){
				morty.erase(find(all(morty),8));
				morty.push_back(30000);
			}
			if(tmp%6 == 3){
				morty.erase(find(all(morty),9));
				morty.push_back(30000);
			}
			if(tmp%6 == 5){
				morty.erase(find(all(morty),9));
				morty.push_back(29998);
			}
			FORR(x,morty)cout<<x<<" ";
			return;
		}
		
		


	}























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <numeric>
#include <string>
#include <cmath>

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

int main() {
	int n;
	cin >> n;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	vector <int> count(n+1,0);
	int a;
	for (int i = 1; i <= n; i++) {
		a = i;
		while (a > 0)
		{
			if (a == 1)break;
			if(a%2 == 0) count[i] += 1;
			a = a / 2;
		}
	}

	std::vector<int>::iterator iter = std::max_element(count.begin(), count.end());
	size_t index = std::distance(count.begin(), iter);

	cout << index << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
int a[3];
REP(i,3) cin >> a[i];
int ans = INF;
int temp;
REP(i,3) {
  temp = 0;
  REP(j,3) {
    temp += abs(a[j]-a[i]);
  }
  ans = min(ans,temp);
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

    int b0 = 0, b1 = 0, b2 = 1;
    int max = 1;

    int prev;
    scanf("%d", &prev);
    int i, x, len;
    for (i = 1; i < N; i++) {
        scanf("%d", &x);
        if (x != prev) {
            b2++;
        } else {
            len = b0 + b1 + b2;
            if (max < len) max = len;
            b0 = b1;
            b1 = b2;
            b2 = 1;
        }
        prev = x;
     }
    len = b0 + b1 + b2;
    if (max < len) max = len;
    printf("%d\n", max);

   return 0;
}

Measured memory_bytes: 2752
#include <iostream>
using namespace std;
int main(){
    char s;
    cin >> s;
    if (s == 'A'){
        cout << 'T' << endl;
    }
    else if (s == 'T'){
        cout << 'A' << endl;
    }
    else if (s == 'G'){
        cout << 'C' << endl;
    }
    else if (s == 'C'){
        cout << 'G' << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    int N;
    cin >> N;
    ll A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<ll> B(N + 1);
    ll right = 1;
    B[0] = 0;
    for (int i = 0; i < N; ++i) {
        B[i + 1] = A[i] + B[i];
    }
    ll count = 0;
    sort(B.begin(),B.end());
    ll tmpCount = 0;
    for (int i = 0; i <= N; ++i) {
        if(B[tmpCount] == B[i]){

        }else{
            count +=(i - tmpCount) * (i - tmpCount - 1) / 2;
            tmpCount = i;
        }
    }
    count +=(N + 1 - tmpCount) * (N - tmpCount) / 2;

    cout << count << endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main(void)
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if (a <= b && b <= c)
      printf("%d %d %d\n",a,b,c);
    else if (a <= c && c <= b)
      printf("%d %d %d\n",a,c,b);
    else if (b <= a && a <= c)
      printf("%d %d %d\n",b,a,c);
    else if (b <= c && c <= a)
      printf("%d %d %d\n",b,c,a);
    else if (c <= a && a <= b)
      printf("%d %d %d\n",c,a,b);
    else 
      printf("%d %d %d\n",c,b,a);
    return 0;
}



Measured memory_bytes: 2100
#include<iostream>    // ???????????????????§?????????£????????????
using namespace std;
#include<stdio.h>

typedef struct fox { int val; fox *prev, *next; } fox_t;

fox_t* init()
{
    fox_t* head = new fox_t;
    head->val = -1;
    head->next = NULL;
    head->prev = NULL;
    return head;
}

fox_t* make_tail(fox_t* head)
{
    fox_t* tail = new fox_t;
    tail->val = -1;
    head->next = tail;
    tail->next = NULL;
    tail->prev = head;
    return tail;
}

bool isEmpty(fox_t* head, fox_t* tail)
{
    return (head->next == tail ? true : false);
}

fox_t* b_insert(fox_t* tail, int data)
{
    fox_t* fox = new fox_t;
    fox->val = data;
    fox->prev = tail->prev;
    fox->next = tail;
    tail->prev->next = fox;
    tail->prev = fox;
    return fox;
}
// docking.
void unionfox(fox_t* head1, fox_t* tail1, fox_t* head2, fox_t* tail2)
{
    if(isEmpty(head1, tail1) || isEmpty(head2, tail2)) return;
    fox_t* fox = tail1->prev;
    fox->next = head2->next;
    head2->next->prev = fox;
    tail2->prev->next = tail1;
    tail1->prev = tail2->prev;
    delete tail2;
    delete head2;
}

int main()
{
    int color[100001];
    int c_num = 0;
    fox_t* foxhead[100001];
    fox_t* foxtail[100001];
    int i, n, m, q;
    int a, b;
	scanf("%d %d", &n, &m);
    for(i = 0; i <= n; i++){
        color[i] = -1;
        foxhead[i] = init();
        foxtail[i] = make_tail(foxhead[i]);
    }
    int c_a, c_b, val;

    for(i = 0; i < m; i++){
		scanf("%d %d", &a, &b);
        c_a = color[a];
        c_b = color[b];
        if(c_a < c_b){ swap(c_a, c_b); swap(a, b); }  // color[a] >= color[b].
        if(c_a < 0 && c_b < 0){
            color[a] = c_num; color[b] = c_num;
            b_insert(foxtail[c_num], a);
            b_insert(foxtail[c_num], b);
            c_num++;
        }else if(c_b < 0){
            color[b] = c_a;
            b_insert(foxtail[c_a], b);
        }else if(c_a == c_b){
            continue;
        }else{ // color[a] != color[b].
            fox_t* fox = foxhead[c_b]->next;
            while(fox != foxtail[c_b]){
                val = fox->val;
                color[val] = c_a;
                fox = fox->next;
            };
            unionfox(foxhead[c_a], foxtail[c_a], foxhead[c_b], foxtail[c_b]);
        }
    }
    scanf("%d", &q);
    for(i = 0; i < q; i++){
        scanf("%d %d", &a, &b);
        if(color[a] >= 0 && (color[a] == color[b])){
            printf("yes\n"); }else{ printf("no\n"); 
            }
    }
    return 0;
}

Measured memory_bytes: 12492
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

int prime(int a, int b) {
	if (a % 2 != 0)return b;
	else {
		b++;
		prime(a / 2, b);
	}
}


int main(void) {
	int N, num = 0, x = 0,order=1;
	cin >> N;
	x = prime(1, num);
	for (int i = 1;i <= N;i++) {
		if (prime(i, num) >= x) {
			x = prime(i, num);
			order = i;
			num = 0;
		}
	}

	cout << order << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, int> ii;
 
#define x first
#define y second
 
const int N = 1e5 + 10;

int n, e, t;
int x[N];
ll dp[N];
ll suffix_min[N];

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
 
	cin >> n >> e >> t;
	for (int i = 1; i <= n; i++) scanf("%d", &x[i]);
 
	suffix_min[n + 1] = 2 * x[n];
	dp[n] = t;
	suffix_min[n] = min(suffix_min[n + 1], dp[n] + 2 * x[n - 1]);
 
	for (int i = n - 1; i >= 1; i--) {
		ll &res = dp[i];
		int nxt = upper_bound(x + 1, x + n + 1, x[i] + t / 2) - x;
 
		if (nxt > n) res = t;
		else {
			res = dp[nxt] + t;
			res = min(res, suffix_min[nxt + 1] - 2 * x[i]);
		}
 
		suffix_min[i] = min(suffix_min[i + 1], res + 2 * x[i - 1]);
	}
 
	cout << dp[1] + e << endl;

	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph= vector<vector<int>>; 
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
// ミント
const int mod = 1e9+7 ;
//998244353;

struct mint {
  ll x; // typedef long long ll;
  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, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//昆布
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}   ;
 
mint modpow(ll a,ll b){
 if(b==0) return 1 ;
 mint c= modpow(a,b/2) ;
 if(b%2==1) return c*c*a ;
 else return c*c ;
}

mint komb(ll n,ll m){
  mint x=1 ;mint y=1 ;
  rep(i,m){
    x*= n-i ;
    y*= i+1 ;
  }
  return x/y ;
}
int main(){
  ll n,a, b; cin>>n>>a>>b ;
  mint  ans = modpow(2ll,n) ;
 ans =ans-1 ;

  mint hiku = komb(n,a)+komb(n,b) ;
  ans = ans-hiku ;
  cout<<ans<<endl ;
    return 0;
  }
   

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);

    for(int i=0; i<n; i++){
        cin >> h[i];
    }
    int pos=0;
    int _max=0,tmp=0;

    for(pos=0; pos<n-1;pos++){
        if(h[pos] >= h[pos+1]){
            tmp++;
        }else{
            _max = max(_max, tmp);
            tmp = 0;
        }
    }
    _max = max(_max, tmp);
    cout << _max << endl;
}

Measured memory_bytes: 640
S = input()
W = ["dream","dreamer","erase","eraser"]
while len(S) >= 5:
	if len(S) >= 7 and S[-7:] in W:
		S = S[:-7]
	elif len(S) >= 6 and S[-6:] in W:
		S = S[:-6]
	elif S[-5:] in W:
		S = S[:-5]
	else:
		print("NO")
		exit()
if not S:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 3188
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int N = sc.nextInt();
    int cnt = 0;
    for(int i = 1;i <= 9;i++){
        for(int j = 1;j <= 9;j++){
            if(i * j == N){
                cnt++;
            }
        }
    }
    if(cnt > 0) {
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
  }
}


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

#define st first
#define nd second
#define all(x) (x).begin(), (x).end()

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> void mini(T &l, T r){l = min(l, r);}
template <class T> void maxi(T &l, T r){l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h){cerr << sdbg << "=" << h << "\n";}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA... a){
	while (*sdbg != ','){cerr << *sdbg++;}cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
	os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}
template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
	return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef SFIC
	#define eput(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
	#define eput(...) 218
#endif

const int N = 2E5 + 10;

char s[N];

int main(){
	int n;
	scanf("%s%n", s, &n);
	ll ans = 0, cnt = 0;
	for (int i = 0; i < n; ++i){
		if (s[i] == 'B')
			++cnt;
		else
			ans += cnt;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 384
import re

N = int(input())
s = input()[:N]
s_check = s
s_check = re.sub('\(\)', '', s_check)

while len(s_check) > 0:
    for i in range(len(s_check)):
        if s_check[i] == ')':
            s = '(' + s
            s_check = '(' + s_check
            break
        elif s_check[i] == '(':
            break

    for i in range(len(s_check)):
        if s_check[-i-1] == '(':
            s = s + ')'
            s_check = s_check + ')'
            break
        elif s_check[-i-1] == ')':
            break

    s_check = re.sub('\(\)', '', s_check)

print(s)

Measured memory_bytes: 10000
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

B=list(map(int,input().split()))
A2=list(map(int,input().split()))
tmp=A2[0]-B[0]
for i in range(3):
    if not tmp==A2[i]-B[i]:
        print("No")
        exit()
        
A2=list(map(int,input().split()))
tmp=A2[0]-B[0]
for i in range(3):
    if not tmp==A2[i]-B[i]:
        print("No")
        exit()

print("Yes")

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

int main(){
    char b;
    cin >> b;
    if(b == 'A')
        cout << 'T' << endl;
    if(b == 'T')
        cout << 'A' << endl;
    if(b == 'C')
        cout << 'G' << endl;
    if(b == 'G')
        cout << 'C' << endl;
    
    return 0;
}


Measured memory_bytes: 256
using System;

public class Program {
 public static void Main(string[] args) {
   string[] stdin = Console.ReadLine().Split(' ');
   
   int num = int.Parse(stdin[0]);
   int train = int.Parse(stdin[1]);
   int taxi = int.Parse(stdin[2]);
   
   if ((num * train) > taxi) {
     Console.WriteLine(taxi.ToString());
   } else {
     Console.WriteLine((num * train).ToString());
   }
 }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define  ff     first
#define  ss     second
#define  pb     push_back
#define  all(x) (x).begin(), (x).end()
#define  rep(i,a,b) for(int i=a ; i<b ; ++i)
#define  deb(x) cout << #x << " - " << x << "\n";
#define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  D2(x)  { cerr << "[" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }
#define  ps(x,y) fixed<<setprecision(y)<<x
 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 10000000;
const ll MAX_N = 1e5 + 2;

int main() {
    IOS;
    int x,res;
    for(int i=0;i<5;i++){
        cin>>x;
        
        if(x==0){
            res = i+1;
        }
    }
    
    cout << res ;
    return 0;
}

Measured memory_bytes: 3652
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
limit = sum(B) - sum(A)

if limit < 0:
    print("No")
else:
    need = 0
    for a, b in zip(A, B):
        if b < a:
            need += a-b
    can = 0
    for a, b in zip(A, B):
        if a < b:
            can += (b-a)//2
    if need > can:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 4468
/*
 * ITP1_5_D.cpp
 *
 *  Created on: 2016/05/15
 *      Author: suna
 */

#include <iostream>

using namespace std;

//??¢??°??????
//1??????n?????§????????§???3??§?????????????????°???????????????1?????????3??§????????°???????????????
//3??§?????????????????°??????????????????
void call(int n)
{
	int x;
	for(int i=1; i <= n; i++)
	{
		x = i;
		//3??§???????????????????????????
		if( (x % 3) == 0 )
		{
			cout << " " << i;
		}
		//1???????????°???3??§??????????????????
		else
		{
			do{
				if( (x % 10) == 3)
				{
					cout << " " << i;
					break;
				}
				else
				{
					x /= 10;
				}
			}while(x);
		}
	}
	cout << endl;
}

int main(void)
{
	//???????????????????????\????????????
	int input_num;

	//????????\???
	cin >> input_num;

	call(input_num);
	return 0;
}

Measured memory_bytes: 1164
/*
In every question first approach must be basic, atleast give 15 mins for try to solve in basic approach
*/
 #include<iostream>
 #include<cstring>
 #include<string>
 #include<vector>
 #include<utility>
 #include<stdlib.h>
 #include<limits.h>
 #include<cmath>
 #include<set>
 #include<initializer_list>
 #include<unordered_set>
 #include<unordered_map>
 #include<map>
 #include<iomanip>
 #include<algorithm>
 #include<queue>
 #include<stack>
  
 #define sze 1000005
 #define ld long double
 //#define ll unsigned long long
 #define ll long long
 #define endl "\n"
 #define pb push_back
 #define mkp make_pair
 #define mod 1000000007
 #define ff first
 #define ss second
 #define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
 #define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
 #define all(c) (c).begin(),(c).end()
//#define pi = 3.14159265358979323846
  
 using namespace std;
 //const ll inf=1ll<<60;
// cout << fixed << setprecision(6) << pi <<" "<<npi<<endl;

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
      
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res%mod * a%mod)%mod;
        a = (a%mod * a%mod)%mod;
        b >>= 1;
    }
    return res;
}
//const int N=300005;

 int main()
 {
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     ll k; cin>>k;
     string s; cin>>s;
     if(s.length()<=k)
     {
         cout<<s<<endl;
     }
     else
     {
         F(i,0,k-1)
         {
             cout<<s[i];
         }
         cout<<"..."<<endl;
     }
     
 }


Measured memory_bytes: 3656
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cout<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int a,b,k;

main(){
    cin>>a>>b>>k;
	rep(i,k){
		if(i%2==0){
			a-=(a%2);
			a/=2;
			b+=a;
		}else{
			b-=(b%2);
			b/=2;
			a+=b;
		}
		//cout<<a<<' '<<b<<endl;
	}
	cout<<a<<' '<<b<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

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

long long gcd(long long a, long long b)
{
  while(b) {
    long long at = a;
    a = b;
    b = at % b;
  }
  return a;
}

int main()
{
  int N;
  cin >> N;
  vector<ll> A(N);
  REP(i, N) cin >> A[i];

  vector<ll> x(A), y(A);
  for (int i = 0; i < N - 1; i++) x[i+1] = gcd(x[i], x[i + 1]);
  for (int i = N - 1; i > 0; i--) y[i-1] = gcd(y[i - 1], y[i]);

  ll ans = x[N - 1];
  REP(i, N) {
    if (i == 0) ans = max(ans, y[i + 1]);
    if (i == N - 1) ans = max(ans, x[i - 1]);
    else ans = max(ans, gcd(x[i - 1], y[i + 1]));
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 2560
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<ll> A(1<<N);
    rep(i,1<<N) cin >> A[i];

    vector<pll> dp(1<<N);
    rep(i,1<<N) dp[i] = {A[i],0};
    vector<int> val(4);
    rep(i,N) {
        rep(mask,1<<N) {
            if (mask&(1<<i)) {
                tie(val[0],val[1]) = dp[mask];
                tie(val[2],val[3]) = dp[mask^(1<<i)];
                sort(all(val));
                dp[mask].first = val[3];
                dp[mask].second = val[2];            
            }
        }
    }

    vector<ll> ans(1<<N);
    rep(i,1<<N) ans[i] = dp[i].first+dp[i].second;
    rep(i,(1<<N)-1) chmax(ans[i+1],ans[i]);

    rep(i,(1<<N)-1) cout << ans[i+1] << ln;
}



Measured memory_bytes: 11264
import java.util.*;
import java.io.*;

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		double ans;
		ans=n/2;
		ans=ans+(double)(n%2);
		System.out.println(ans/(double)n);
		
	}
}
	

Measured memory_bytes: 25044
/**
 * Author  : dhakad_123
 * Created : 15.08.2020
 **/

#include<bits/stdc++.h>
using namespace std;



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


	int A , B , C , D;

	cin >> A;
	cin >> B;
	cin >> C;
	cin >> D;

	
	cout << min(A , B) + min(C , D) << endl;


       return 0;

}


Measured memory_bytes: 3636
/******** JUST GIVE IT A TRY,COULD'NT SOLVED YOU LEARNED SOMETHING NEW 
AND IF SOLVED IT MEANS YOU GREW *********/
    
//author RKN
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define pr pair<ll,ll>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define N 200001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);  
/*///////////////////////////////////////////////////////////////
DYNAMIC PROGRAMMING
///////////////////////////////////////////////////////////////*/

int main()
{
        int n;
        cin>>n;
        int arr[n][3];
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<3;j++)
            cin>>arr[i][j];
        }
        vector<vector<int>>dp(n,vector<int>(3,0));
        for(int i=0;i<3;i++)
        {
            dp[0][i]=arr[0][i];
        }
        for(int i=1;i<n;i++)
        {
            for(int j=0;j<3;j++)
            {
                dp[i][0]=max(dp[i][0],arr[i][0]+max(dp[i-1][2],dp[i-1][1]));
                dp[i][1]=max(dp[i][1],arr[i][1]+max(dp[i-1][0],dp[i-1][2]));
                dp[i][2]=max(dp[i][2],arr[i][2]+max(dp[i-1][0],dp[i-1][1]));
            }
        }
        cout<<*max_element(all(dp[n-1]));
}

Measured memory_bytes: 6912
N, M = map(int, input().split())

max_L = 0
min_R = 10**6
for i in range(M):
    l, r = map(int, input().split())
    if l > max_L:
        max_L = l
    if r < min_R:
        min_R = r
    
print(max(min_R - max_L + 1, 0))   

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

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

Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	int a[105],b[105],x,m,n,k=0,l=0;
	cin >> x;
	for (int i=0;i<x;i++)
	{
		cin >> a[i];
	}
	m=a[0];
	for (int i=0;i<x;i++)
	{
		cin >> b[i];
		m+=b[i];
	}
	for (int i=0;i<x;i++)
	{
		k+=a[i];
		for (int j=i;j<x;j++)
		{
		l+=b[j];
		}
		n=k+l;
		if (n>=m)
		{
			m=n;
		}
		l=0;
		n=0;
	}
	cout << m << endl;
	system("pause");
	return 0;
}

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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j >= 0 && S - i - j <= K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define FOR(i,k,n) for((i)=(k);(i)<(n);(i)++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define pb push_back
#define all(a) (a).begin(),(a).end()  //greater<int>()
using namespace std;

class GoHome {

	private: 
		int X,i,l,r;

	public:
		int step_num(int X){
			i=0;
			while(1){
				i+=1;
				l=i*(i-1)/2+1;
				r=(i+1)*i/2+1;

				if(l<=X && X<r){
					break;
				}
			}
			return i;
		}
};

int main(){ 
	int X;
	cin>>X;

	GoHome gh;

	cout<<gh.step_num(X)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include<time.h>
using namespace std;
typedef long long int llint;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

//aとbの最大公約数を求めるよ
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
long long extGCD(long long a, long long b, long long& x, long long& 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;
}

bool check(pair<pair<string, int>, int>a, pair<pair<string, int>, int>b) {
	if (a.first.first == b.first.first) {
		return a.first.second > b.first.second;
	}
	return a.first.first < b.first.first;
}

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'x')cnt++;
	}
	YES(cnt < 8);
	return 0;
}

Measured memory_bytes: 256
# 改良版
# - chunkではなくchunk_whileで切るほうが綺麗だと思ったけどchunk(&:itself)で良かった
MOD = 10**9+7
gets
S1 = gets.chomp
verts = S1.chars.chunk(&:itself).map{|c, cs| cs.size == 1}

prev_vert = nil
m = verts.map.with_index{|vert, i|
  if i == 0
    vert ? 3 : 6
  else
    prev_vert = verts[i-1]
    case
    when prev_vert && vert
      2
    when prev_vert
      2
    when vert
      1
    else
      3
    end
  end
}

p m.inject{|a, b| a*b%MOD}

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

 int main()
 {
     int a, b, i=0, count=1;
     vector<int> ans(10);
     char op;

     cin>>a>>op>>b;

     while(op!='?'){
         switch (op)
         {
             case '+':
                 ans[i] = a + b;
                 break;
             case '-':
                 ans[i] = a - b;
                 break;
             case '*':
                 ans[i] = a * b;
                 break;
             case '/':
                 if (b!=0)
                     ans[i] = a / b;
                 break;
             default:
                 break;
         }
         
         if (++i==count*10) {
             count++;
             ans.resize(count*10);
         }

         cin>>a>>op>>b;
         
     }

    for (int j=0; j<i; j++)
    {
        cout<<ans[j]<<endl;
    }
     return 0;
 }


Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }

lint com_cnt[26], N;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	REP(i, 26) {
		com_cnt[i] = 50;
	}
	lint cnt[26];
	REP(i, N) {
		string s;
		cin >> s;
		REP(j, 26) {
			cnt[j] = 0;
		}
		REP(j, s.size()) {
			cnt[s[j] - 'a']++;
		}
		REP(j, 26) {
			com_cnt[j] = min(com_cnt[j], cnt[j]);
		}
	}
	REP(i, 26) {
		REP(j, com_cnt[i]) {
			cout << (char)('a' + i);
		}
	}
	cout << endl;
}


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

int main() {

  int n;
  cin >> n;
  
  vector<int> a(n);

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

  vector<int> c;

  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      c.push_back(i);
    } else {
      c.insert(c.begin(), i);
    }
  }

  if (n % 2 == 0) {
    for (int i = 0; i < n; i++) {
      cout << a[c[i]] << " ";
    }
  } else {
    for (int i = n - 1; 0 <= i; i--) {
      cout << a[c[i]] << " ";
    }
  }

  cout << endl;

}

Measured memory_bytes: 3828
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] bunsetu = new int[3];
        for (int i = 0;i <= 2;i++)bunsetu[i] = sc.nextInt();
        Arrays.sort(bunsetu);
        if (bunsetu[0] == 5 && bunsetu[1] == 5 && bunsetu[2] == 7) System.out.println("YES");
        else System.out.println("NO");
    }
}


Measured memory_bytes: 19412
class SegmentTree():

    def __init__(self, iterable, func, e):
        self.func = func
        self.e = e
        ls = list(iterable)
        self.n = 1 << len(ls).bit_length()
        ls.extend( [self.e] * (self.n - len(ls)) )
        self.data = [self.e] * self.n + ls
        for i in range(self.n-1, 0, -1):
            self.data[i] = self.func(self.data[2*i], self.data[2*i+1])

    def replace(self, index, value):
        index += self.n
        self.data[index] = value
        index //= 2
        while index > 0:
            self.data[index] = self.func(self.data[2*index], self.data[2*index+1])
            index //= 2
        
    def folded(self, l, r):
        left_folded = self.e
        right_folded = self.e
        l += self.n
        r += self.n
        while l < r:
            if l % 2:
                left_folded = self.func(left_folded, self.data[l])
                l += 1
            if r % 2:
                r -= 1
                right_folded = self.func(self.data[r], right_folded)
            l //= 2
            r //= 2
        return self.func(left_folded, right_folded)


N = int(input())
Ps = list(map(lambda c: int(c) - 1, input().split()))

def max_tuple(t1, t2):
    if t1[0] < t2[0]:
        t1, t2 = t2, t1

    if t1[1] > t2[0]:
        return t1
    else:
        return (t1[0], t2[0])

max_two_elems = SegmentTree([(P, -1) for P in Ps], max_tuple, (-1, -1))

ans = 0
for i, P in enumerate(Ps):
    ok = 0
    ng = i + 1
    while ng - ok > 1:
        mid = (ng + ok) // 2
        largest, _ = max_two_elems.folded(i - mid, i + 1)
        if largest == P:
            ok = mid
        else:
            ng = mid
    l_width_1 = ng

    if l_width_1 == i + 1:
        l_width_2 = 0
    else:
        ok = 0
        ng = i - l_width_1 + 1
        while ng - ok > 1:
            mid = (ng + ok) // 2
            _, second_largest = max_two_elems.folded(i - l_width_1 - mid, i + 1)
            if second_largest <= P:
                ok = mid
            else:
                ng = mid
        l_width_2 = ng

    ok = 0
    ng = N - i
    while ng - ok > 1:
        mid = (ng + ok) // 2
        largest, _ = max_two_elems.folded(i, i + mid + 1)
        if largest == P:
            ok = mid
        else:
            ng = mid
    r_width_1 = ng

    if r_width_1 == N - i:
        r_width_2 = 0
    else:
        ok = 0
        ng = N - i - r_width_1
        while ng - ok > 1:
            mid = (ng + ok) // 2
            _, second_largest = max_two_elems.folded(i, i + r_width_1 + mid + 1)
            if second_largest <= P:
                ok = mid
            else:
                ng = mid
        r_width_2 = ng

    #print(P+1, l_width_2, l_width_1, r_width_1, r_width_2)
    ans += (l_width_2 * r_width_1 + l_width_1 * r_width_2) * (P + 1)
    
print(ans)


Measured memory_bytes: 100768
n,m=[int(s) for s in input().split()]
key=[]
for i in range(m):
  cost,b=[int(s) for s in input().split()]
  op=0
  for i in input().split():
    op+=1<<(int(i)-1)
  key.append([cost,op])
N=2**n
dp=[[10**7 for _ in range(N)] for _ in range(m)]
dp[0][key[0][1]]=key[0][0]
dp[0][0]=0
for i in range(1,m):
  for j in range(N):
    dp[i][j]=min([dp[i-1][j],dp[i][j]])
    x=j|key[i][1]
    dp[i][x]=min([dp[i][x],dp[i-1][j]+key[i][0]])
if dp[m-1][N-1]==10**7:
  print(-1)
else:
  print(dp[m-1][N-1])      


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

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

    int x, a, b;
    cin >> x >> a >> b;
    int aa = abs(x - a);
    int bb = abs(x - b);
    if(aa < bb)
        cout << 'A';
    else
        cout << 'B';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int n, ans;
#undef int
int main()
{
	#define int ll
	scanf("%lld", &n);
	for (int i = 1; i <= sqrt(n+1); i++)
	{
		if (n%i == 0)
		{
			ll a = n/i;
			if (a < i-1) ans += i-1;
			if (i < a-1) ans += a-1;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9 + 7;
const int M = 2e6 + 5;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   if(pow < 0) return 0;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ll mult_mod(ll a , ll b){a = a%mod; b = b%mod;ll c = (a * b)%mod;return c;}
ll add_mod(ll a , ll b){a = (a + mod)%mod;b = (b + mod)%mod;ll c = (a + b)%mod;return c;}
ll fac[(int)(2e6 + 7)] , inv_fac[(int)(2e6 + 7)];
void precomp_factorial(){fac[0] = 1;for(ll i = 1 ; i <= M ; i++) fac[i] = mult_mod(i , fac[i - 1]);
    inv_fac[M] = inv(fac[M]);for(ll i = M - 1 ; i >= 0 ; i--) inv_fac[i] = mult_mod(i + 1 , inv_fac[i + 1]);}
ll nCk(ll n , ll k){ll ans = fac[n];ans = mult_mod(ans , inv_fac[n - k]);ans = mult_mod(ans , inv_fac[k]);return ans;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};

map <pair<int,int>,int> mp;
int main(void)
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll cnt1 = b/c - (a-1LL)/c;
    ll cnt2 = b/d - (a-1LL)/d;
    ll lcm = (c*d)/gcd(c,d);
    ll cnt3 = b/lcm - (a-1LL)/lcm;
    //cout << cnt1 << " " << cnt2 << " " << cnt3 << endl;
    ll ans = b-a+1LL - cnt1 - cnt2 + cnt3;
    cout << ans;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

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

LL fac[SIZE], finv[SIZE], inv[SIZE];
void combInit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for( int i = 2; i < SIZE; ++i ) {
        fac[i] = (fac[i - 1] * i) % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (finv[i - 1] * inv[i]) % MOD;

    }
}

LL comb(int n, int k) {
    if( n < k ) return 0;
    if( n < 0 || k < 0 ) return 0;
    return (fac[n] * (finv[k] * finv[n - k] % MOD)) % MOD;

}

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n, m;
    cin >> n >> m;
    vector< int > v(m);
    for( int i = 0; i < m; ++i ) {
        cin >> v[i];

    }
    sort(all(v));
    if( m == 1 ) {
        cout << 0 << endl;
        return 0;

    }

    vector< int > diff;
    for( int i = 1; i < m; ++i ) {
        diff.pb(v[i] - v[i - 1]);

    }

    LL res = v[m - 1] - v[0];
    sort(all(diff), greater<>());
    int pos = 0;
    n--;
    while( n > 0 && pos < diff.size() ) {
        res -= diff[pos];
        pos++;
        n--;

    }
    cout << res << endl;
}



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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

class UnionFind{
public:

    vector<int> root;
    vector<int> rank;
    vector<int> sizev;

    UnionFind();

    //1-indexでアクセスすること想定
    UnionFind(int n){

        for(int i = 0; i <= n; i++){
            root.push_back(i);
            rank.push_back(1);
            sizev.push_back(1);
        }
    }

    int find(int n){

        vector<int> update;
        int count = 0;

        while(n != root[n]){
            
            update.push_back(n);
            n = root[n];
            count++;
        }

        for(int i = 0; i < count; i++){
            root[update[i]] = n;
        }

        return n;
    }

    bool same(int a, int b){
        a = find(a);
        b = find(b);

        return a == b;
    }

    int size(int n){
        return sizev[find(n)];
    }

    void merge(int a, int b){

        a = find(a);
        b = find(b);

        if(a != b){

            if(rank[a] < rank[b]){
                root[a] = b;
                sizev[b] += sizev[a];
            }else{
                root[b] = a;
                sizev[a] += sizev[b];

                if(rank[a] == rank[b]){
                    rank[a]++;
                }
            }
        
        }
    }
};

int main(){

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> p(n);

    rep(i, n){
        int tmp;
        cin >> tmp;
        p[i] = mpair(tmp, i + 1);
    }

    sort(ALL(p));

    UnionFind uf(n);

    rep(i, m){
        int x, y;
        cin >> x >> y;

        uf.merge(x, y);
    }

    int ans = 0;

    rep(i, n){
        int num = p[i].first;
        int start_index = p[i].second;

        assert(num == i + 1);

        if(uf.same(num, start_index)){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2412
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  vector<double> x(n), y(n);
  rep(i, 0, n) cin >> x[i];
  rep(i, 0, n) cin >> y[i];

  double ans1 = 0, ans4 = 0;
  rep(i, 0, n) {
    double w = abs(x[i] - y[i]);
    ans1 += w;
    chmax(ans4, w);
  }
  cout << fixed << setprecision(10) << ans1 << endl;

  double ans2 = 0;
  rep(i, 0, n) ans2 += pow(x[i] - y[i], 2);
  cout << sqrt(ans2) << endl;

  double ans3 = 0;
  rep(i, 0, n) ans3 += pow(abs(x[i] - y[i]), 3);
  cout << cbrt(ans3) << endl;

  cout << ans4 << endl;
}



Measured memory_bytes: 3488
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>

#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

void call2(int num) {

	//numを10で割っていって、 
	//numを10で割った商が0になるまでループ

	for (int i = 3; i<=num; i++) {

		//３の倍数なら出力
		if (i % 3 == 0) {
			cout << " " << i;
			continue;
		}
		for (int j = i; j!=0; j /= 10) {
			//３のつく数字なら出力
			if (j % 10 == 3) {
				cout << " " << i;
				break;
			}
		}
	}
	cout << endl;
}

int main() {

	//call(50);
	int num;
	cin >> num;
	call2(num);

	return 0;
}


Measured memory_bytes: 3096