akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>

#define REP(i, n) for(int i=1;i<n+1;i++)

using namespace std;

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

//const int maxN = 200000;

ll N;
ll ans = 0;

int main() {
    cin >> N;
    if (N == 100000) {
        ans += 90000;
    } else {
        if (N >= 10000) {
            ll b = N / 10000;
            ans += (b - 1) * 10000;
            ans += N - b * 10000 + 1;
        }
    }

    if (N >= 1000) {
        ans += 900;
    } else {
        if (N >= 100) {
            ll a = N / 100;
            ans += (a - 1) * 100;
            ans += N - a * 100 + 1;
        }
    }

    if (N >= 10) {
        ans += 9;
    } else {
        ans += N;
    }

    cout << ans;
}





Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;
const long mod = 1000000007;

void dfs(vector<vector<pair<long, long>>>& tree, vector<long>& sh_path, long K, long par,long now,long cost) {

	sh_path[now] = cost;

	for (auto e : tree[now]) {
		if (e.first == par) continue;

		dfs(tree, sh_path, K, now, e.first, cost + e.second);

	}

}

int main() {

	long N; cin >> N;

	vector<vector<pair<long, long>>> tree(N);
	vector<long> sh_path(N);//Kからの最短距離


	for (int i = 0; i < N - 1; i++) {//入力
		long A, B, C; cin >> A >> B >> C;
		A--; B--;

		tree[A].push_back(make_pair(B, C));
		tree[B].push_back(make_pair(A, C));
	}

	long Q, K; cin >> Q >> K; K--;

	dfs(tree, sh_path, K, -1, K, 0);

	for (int i = 0; i < Q; i++) {//出力

		long X, Y; cin >> X >> Y; X--; Y--;

		cout << sh_path[X] + sh_path[Y] << endl;
	}

}

Measured memory_bytes: 17408
#21:40
#21:
while True:
    n,m = map(int,input().split())
    if n ==0 : break


    #難易度と最大推薦度の辞書
    question_dict={}

    for i in range(n):
        difficult,recommend = map(int,input().split())
        if difficult in question_dict:
            question_dict[difficult] = max(question_dict[difficult],recommend)
        else:
            question_dict[difficult] = recommend

    print(sum(question_dict.values()))


Measured memory_bytes: 5612
N,M = map(int,input().split())
L,R = map(int,input().split())
pass_card = R - L + 1
for _ in range(M-1):
  L_now,R_now = map(int,input().split())
  if R_now < L or L_now > R:
    pass_card = 0
    break
  else:
    if R_now < R and L_now > L:
      R = R_now
      L = L_now 
    elif R_now < R and L_now < L:
      R = R_now
    elif R_now > R and L_now > L:
      L = L_now
    pass_card = R - L + 1
print(pass_card)
    

    


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

vector<bool>a(10);
long ans=0;
  string s ;

void cal(){
  long sum=0;;
  for(int i=0;i<s.size();i++){
    int kari =s.at(i) -'0';
    sum*=10;
    if(i==s.size()-1){
      ans+=kari+sum;
    }
    if(a.at(i)){
      ans+=kari;
      ans+=sum;
      sum=0;
    }
    else{
      sum+=kari;
    }
  }
}
      

void dfs(int d){
  if(d==s.size()-1){
    cal();
    return;
  }
  a.at(d)=false;dfs(d+1);
  a.at(d)=true;dfs(d+1);
}

int main() {
  cin>>s;
  dfs(0);
  cout <<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cstring>
#include<vector>
#include<map>

typedef long long ll;
//sort(rt,rt+sizeof(rt)/sizeof(rt[0]),greater<>());
using namespace std;

#define rep(i,n) for(i=0;i<n;i++)
int main(){
    int i,n;
    cin>>n;
    int a[101],b[101];
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    int cnt=0;
    rep(i,n){
        if(a[i]==b[i]){
            cnt++;
        }else{
            cnt=0;
        }
        if(cnt==3){
            cout<<"Yes";
            return 0;
        }else{
            ;
        }
    }
    cout<<"No";
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n; cin >> n;
  
  ll sum = 0;
  ll cmin = INFll;
  rep(i, n) {
    ll a, b; cin >> a >> b;
    sum += a;
    if (a > b) chmin(cmin, b);
  }

  if (cmin == INFll) cout << 0 << endl;
  else cout << (sum - cmin) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int a,b,c,k;
  cin>>a>>b>>c>>k;
  k=k&1;
  if(k) swap(a,b);
  cout<<a-b<<endl;
  return 0;
}


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

typedef long long ll;
const int maxn = 100010;
int n, a[maxn], c[maxn * 2];

void add(int p) {
    for (; p <= 2 * n + 1; p += p & -p) c[p]++;
}

int query(int p) {
    int s = 0;
    for (; p; p -= p & -p) s += c[p];
    return s;
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    if (n == 1) printf("%d\n", a[1]), exit(0);
    auto chk = [&](int x) {
        memset(c, 0, sizeof(c));
        int cur = n + 1;
        long long ans = 0;
        add(cur);
        for (int i = 1; i <= n; i++) {
            if (a[i] >= x) cur++;
            else cur--;
            ans += query(cur), add(cur);
        }
        return ans;
    };
    int l = 1, r = 1e9, ans;
    ll all = 1LL * n * (n + 1) / 2;
    while (l <= r) {
        int mid = (l + r) >> 1;
        chk(mid) >= all / 2 ? l = (ans = mid) + 1 : r = mid - 1;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(){
  int i,j,n,a[100],minj,tmp,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }if(i != minj){
      tmp=a[i];
      a[i]=a[minj];
      a[minj]=tmp;
      cnt++;
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d\n",a[i]);
  printf("%d\n",cnt);
  return 0;
}



Measured memory_bytes: 2104
S = input()
N = len(S)
a = []
for s in S:
    a.append(int(s))
MOD = 2019

cur = 0
cten = 0
li = [0 for i in range(MOD)]
for aa in reversed(a):
    if cten==0:
        cten = 1
    else:
        cten = (cten*10)%MOD
    cur = (aa*cten+cur)%MOD
    li[cur] += 1
    # print(cur)

sm = 0
for l in li:
    sm += l*(l-1)//2
sm += li[0]
print(sm)


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {

  int t[3][3];
  REP(i, 3) REP(j, 3) cin >> t[i][j];

  int N; cin >> N;
  REP(n, N) {
    int x; cin >> x;
    REP(i, 3) REP(j, 3) if (t[i][j] == x) t[i][j] = -1;
  }
  bool yes = false;
  REP(i, 3) {
    int k = 0;
    REP(j, 3) if (t[i][j] == -1) k++;
    if (k == 3) yes = true;
  }
  REP(j, 3) {
    int k = 0;
    REP(i, 3) if (t[i][j] == -1) k++;
    if (k == 3) yes = true;
  }
  {
    int k = 0;
    REP(i, 3) {
      if (t[i][i] == -1) k++;
    }
    if (k == 3) yes = true;
  }
  {
    int k = 0;
    REP(i, 3) {
      if (t[i][2-i] == -1) k++;
    }
    if (k == 3) yes = true;
  }


  if (yes)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code

int main()
{
	int n;
	cin>>n;
	vector<int> v(n+2);
	ll total = 0;
	v[0] = 0;
	v[n+1] = 0;
	repn(i, 1, n)
	{
		cin>>v[i];
		total += abs(v[i] - v[i-1]);
	}
	total += abs(v[n+1] - v[n]);
	repn(i, 1, n)
	{
		ll tmp = total - abs(v[i] - v[i-1]) - abs(v[i+1] - v[i]) + abs(v[i+1] - v[i-1]);
		cout<<tmp<<endl;
	}
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

using ll = long long int;
using P = pair<int,int>;

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

const ll INF=(ll)1e19;
//const int INF=(1<<30);

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

  double ans=0;
  REP(i,n){
    double x;
    string u;
    cin >> x >> u;
    if(u=="BTC"){
      ans += x * 380000;
    }else{
      ans += x;
    }
  }
  printf("%06f\n", ans);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//for(int i = 0; i<n; i++)
 
 
int main()
{
    int h,w;cin>>h>>w;
    char a[100][100];
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) cin >> a[i][j];
    }
    int c[100] = {0};
    for(int i = 0; i < h; i++){
        bool bo = false;
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#') bo =  true;
        }
        if(bo) c[i]++;
    }
    int b[100] = {0};
    for(int i = 0; i < w; i++){
        bool bo = false;
        for(int j = 0; j < h; j++){
            if(a[j][i] == '#') bo =  true;
        }
        if(bo) b[i]++;
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++) {
            if(c[i]&&b[j])cout << a[i][j];
        }
        if(c[i]) cout << endl;
    }
    return 0;
    
}

Measured memory_bytes: 256
s = input()
t = len(s)

l = s[0]
r = s[-1]

if l == r:
    t -= 3
else:
    f = 0
    for si in s[1:-2]:
        if si == l:
            f = 1
        if f and si == r:
            f = 2
    if f == 2:
        t -= 4
    else:
        t -= 2

if t % 2:
    print("First")
else:
    print("Second")


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N; cin >> N;
    ll mod = 1e9 + 7;

    ll ans = 1;
    reps(i, N) {
        ans = (ans * i) % mod;
    }
    ans % mod;
    cout << ans << endl;
}

Measured memory_bytes: 3572
import math
A, B, H, M = map(int, input().split())

p = 0
o = 0
for i in range(1, H+1):
    p += 30
for q in range(1, M+1):
    o += 6
y = M * 0.5
p = p + y
C = p - o

H = abs(o - p)
total = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(H)))
print(total)


Measured memory_bytes: 9496
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		String s = "CODEFESTIVAL2016";
		Scanner sc = new Scanner(System.in);
		String t = sc.next();
		int count = 0;
		for(int i=0;i<s.length();i++) {
			if (s.charAt(i) != t.charAt(i)) {
				count++;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 10064
#include<bits/stdc++.h>
using namespace std;
bool cmp(int a,int b)
{
	return a<b;
}
int main()
{
	int a,b,sun,in[3];
	scanf("%d%d",&a,&b);
	in[0]=a+b;
	in[1]=a-b;
	in[2]=a*b;
	sort(in,in+3,cmp);
	printf("%d",in[2]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <functional>
#include <sstream>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007
#define M 998244353

using namespace std;

struct like2017{
    lli i,j;
    lli cnt=0;
    vector<lli> vec;
    
    like2017(lli n){
        rep(i,0,n+1){
            if(i%2==0){
                vec.push_back(0);
            }
            else{
                vec.push_back(1);
            }
        }
    }
    
    void check(lli n){
        vec[1]=0;
        vec[2]=1;
        rep(i,1,100001){
            if(vec[i]>=1){
                rep(j,2,(100000/i)+1){
                    vec[i*j]=0;
                }
                if(vec[(i+1)/2]>=1){
                    vec[i]=2;
                }
            }
        }
        rep(i,1,100001){
            if(vec[i]==2){
                cnt++;
            }
            vec[i]=cnt;
        }
    }
    
    lli search(lli a,lli b){
        lli c=vec[b]-vec[a-1];
        return c;
    }
    
    void print(){
        rep(i,1,100001){
            if(vec[i]!=vec[i-1]){
                cout<<i<<"は、"<<vec[i]<<"個目の2017に似てる数"<<endl;
            }
        }
    }
    
};

int main() {
    lli q,l,r;
    vector<lli> ans;
    lli i,j,k;
    cin>>q;
    like2017 num(100000);
    num.check(1);
    rep(i,0,q){
        cin>>l>>r;
        ans.push_back(num.search(l,r));
    }
//    num.print();
    rep(i,0,q){
        cout<<ans[i]<<endl;
    }
}


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


int main() {
	int n,cnt=0;cin>>n;
	vector<int> p,q;
	rep(i,n){
		int k;cin>>k;
		p.push_back(k);
	}
	q=p;
	sort(p.begin(),p.end());
	rep(i,n){
		if(p.at(i)!=q.at(i))cnt++;
	}
	if(cnt==2||cnt==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;
const ll INF=1000000000;

int main(){
    ll S;
    cin >> S;
    cout << 0 << ' ' << 0 << ' ' << INF << ' ' << 1 << ' ';
    ll y=(S+INF-1)/INF;
    ll x=y*INF-S;
    cout << x << ' ' << y << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef tuple<double, int, int, int> T;	//(cost, pos, prev_pos, speed)

double INF = 1e+9;
int n, m;
int s, g;
vector<int> et[30];
vector<int> ec[30];
vector<int> es[30];
double dp[30][30][31];	//dp[pos][prev_pos][speed] = minCost

int main() {
	int i;
	
	while (cin >> n >> m) {
		if (!n) break;
		cin >> s >> g;
		s--; g--;
		
		int i, j, k;
		
		rep(i, n) {
			et[i].clear();
			ec[i].clear();
			es[i].clear();
		}
		
		rep(i, m) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			x--; y--;
			et[x].push_back(y);
			ec[x].push_back(d);
			es[x].push_back(c);
			et[y].push_back(x);
			ec[y].push_back(d);
			es[y].push_back(c);
		}
		
		priority_queue<T, vector<T>, greater<T>> que;
		rep(i, n) rep(j, n) rep(k, 31) dp[i][j][k] = INF;
		
		dp[s][s][0] = 0;
		que.push(T(0, s, s, 0));
		while (!que.empty()) {
			T now = que.top(); que.pop();
			double cst = get<0>(now);
			int pos = get<1>(now);
			int pre = get<2>(now);
			int speed = get<3>(now);
			
			rep(i, et[pos].size()) {
				int npos = et[pos][i];
				if (npos == pre) continue;
				for (j = -1; j <= 1; j++) {
					int nspeed = speed + j;
					if (nspeed <= 0 || nspeed > es[pos][i]) continue;
					double ncst = cst + (double)ec[pos][i] / nspeed;
					if (dp[npos][pos][nspeed] > ncst) {
						dp[npos][pos][nspeed] = ncst;
						que.push(T(ncst, npos, pos, nspeed));
					}
				}
			}
		}
		
		//dp[g][*][1]
		double ans = INF;
		rep(i, n) {
			ans = min(ans, dp[g][i][1]);
		}
		if (ans >= INF) {
			cout << "unreachable" << endl;
		}
		else {
			printf("%.14f\n", ans);
		}
	}
	return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;


ll n, k;

ll f[400005];
ll F[400005];

ll pot(ll x, ll y) {
	if (y == 0) return 1;
	ll sol = pot(x, y/2);
	sol = sol*sol%MOD;
	if (y%2) sol=sol*x%MOD;
	return sol;
}

ll div_(ll x, ll y) {
	return x*pot(y, MOD-2)%MOD;
}

ll choose(ll x, ll y) {
	if (y>=400005) {
		return div_(F[x-k], f[y])%MOD;
	}
	return div_(f[x], (f[y]*f[x-y])%MOD);
}

int main() {
	f[0] = 1;
	for (int i=1 ; i<400005 ; i++) {
		f[i] = (f[i-1] * i) % MOD;
	}
	cin >>n>>k;
	F[0] = 1;
	for (ll i=k-n+1 ; i<=n ; i++) {
		F[0] = (F[0]*i)%MOD;
	}
	for (ll i=1 ; i<=n ; i++) {
		F[i] = div_(F[i-1], (k-n+i))*(k+i)%MOD;
	}
	ll sol = 0;
	for (ll i=0 ; i<=min(n, k) ; i++) {
		sol += choose(n, i)*choose(n-1, i)%MOD;
		sol %= MOD;
	}
	cout <<sol<<endl;
	return 0;
}

Measured memory_bytes: 6016
import numpy as np
n = int(input())
a = list(map(int,input().split()))
dp = np.full((2, n//2 + 1), -10**18, dtype=np.int64)
"""
dp[i][j] := iは偶奇, jは何個決めるか
"""
dp[0][0] = 0
dp[1][0] = 0
for i in range(n):
	k = i % 2
	for j in [2, 1, 0]:
		if i//2+j <= n//2:
			if i//2-1+j >= 0:
				dp[k][i//2+j] = np.maximum(dp[1-k][i//2+j], dp[k][i//2-1+j]+a[i])

print(max(dp[0][n//2], dp[1][n//2]))

Measured memory_bytes: 50856
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {

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

	int count = 0;
	for (int i = 1; i <= d; i++) {
		if (i % 10 >= 2 && i / 10 >= 2 && (i % 10) * (i / 10) <= m) {
			count++;
		}
	}
	COUT(count);


	return 0;
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    for ( int i = 0; i < N; ++i ){
        cin >> a[i];
    }
    int n = 1;
    int c = 0;
    for ( int i = 0; i < N; ++i){
        if ( a[i] == n ){
            n += 1;
            c += 1;
        }
    }
    if ( c == 0 ){
        cout << -1 << endl;
    } else {
        cout << N - c << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <sstream>
using namespace std;

typedef long long LL;
#define lowbit(x) ((x)&(-x))
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a))
#define	GE() printf(">----------\n")
#define	IN() freopen("in.txt","r",stdin)
#define	OUT() freopen("out.txt","w",stdout)
const int mod=1e9+7;
const LL inf=0x3f3f3f3f3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-8;
const int maxn=100005;

int main() {
    int x;
    while(cin>>x){
        int y=floor(log(x)/log(2));
        cout<<pow(2, y)<<endl;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


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


    ll n , m , d;
    cin >> n >> m >> d;
    
    
    if(d == 0){
        cout << fixed << setprecision(16) << (ld)((1.0/(ld)n)*((ld)m-1.0)) << endl;
    }else{
        cout << fixed << setprecision(16) << (ld)(((ld)(n-d)) * 2.0 /((ld)(n*n))) * ((ld)(m-1)) << endl;
    }
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def peak():
    condition = input()
    condition_list = condition.split()
    N = int(condition_list[0])
    M = int(condition_list[1])
    
    height_str = input()
    height_list_str = height_str.split()
    height_list = [0]
    for i in height_list_str:
        height_list.append(int(i))
    
    road_list = []
    for i in range(0, M):
        road_str = input()
        road_set_str = road_str.split()
        road_set = []
        for i in road_set_str:
            road_set.append(int(i))
        road_list.append(road_set)
    
    #road_list = []
    #for i in road_list_str:
        #road_list.append(int(i))
    
    good_point = set()
    for i in range(1, N+1):
        good_point.add(i)
    
    for road_set in road_list:
        i = road_set[0]
        j = road_set[1]
        if height_list[i] < height_list[j]:
            good_point.discard(i)
        elif height_list[i] > height_list[j]:
            good_point.discard(j)
        elif height_list[i] == height_list[j]:
            good_point.discard(i)
            good_point.discard(j)
    
    #print(good_point)
    print(len(good_point))
    return

peak()

Measured memory_bytes: 47084
K = int(input())
from fractions import gcd
from math import ceil
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

sum_gcd = [0]*K
for i in range(1,K+1):
    c = 0
    for j in range(1,K+1):
        c += gcd(i,j)
    sum_gcd[i-1] = c
ans = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        ans += sum_gcd[gcd(a,b)-1]

print(ans)

Measured memory_bytes: 10628
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

const int MR = 1e5 + 10;

char s[MR];

int main()
{
	scanf("%s", s);
	int n = strlen(s);

	if (s[n - 1] == '1' || s[0] == '0')
	{
		printf("-1\n");
		return 0;
	}

	int b = 0, e = n - 2;

	while (b < e)
	{
		if(s[b] != s[e])
		{
			printf("-1\n");
			return 0;
		}

		b++; e--;
	}

	int akt = 1, last = 1;
	REP(i, b + 1)
	{
		printf("%d %d\n", akt, last + 1);
		if (s[i] == '1')
		{

			akt = last + 1;
			last = akt;
		}
		else
			last++;
	}

	FOR(i, b + 1, n - 1)
		printf("%d %d\n", akt, i + 2);

	return 0;
}

Measured memory_bytes: 1536
n,k =map(int,input().split())
a=list(map(int,input().split()))
a = [1] + a
def next(i):
    return a[i]

z = [0] * (n+1)

place = 1
T = 0
interval = 0
if k < n:
    for i in range(k):
        place = next(place)
    print(place);exit()
place = 0
k += 1
for i in range(n):
    place = next(place)
    if z[place] != 0:
        interval = T - z[place]  + 1
        break
    z[1] = 1 
    T += 1
    z[place] = T

m = (k-z[place])%interval
for i in range(m):
    place = next(place)
print(place)


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

int main() {
  int N;
  cin >> N;
  int G = 0, P = 0, W = 0, Y = 0;
  for (int i = 0; i < N; i++){
    string color;
    cin >> color;
    if (color == "G") {
      G = 1;
    }
    if (color == "P") {
      P = 1;
    }
    if (color == "W") {
      W = 1;
    }
    if (color == "Y") {
      Y = 1;
    }
  }
  if (G + Y + P + W == 3){
    cout << "Three" << endl;
  }
  if (G + Y + P + W == 4){
    cout << "Four" << endl;
  }

}

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


bool plus_comp(pair<ll, ll> one, pair<ll, ll> ano){
    return (one.first + one.second) > (ano.first + ano.second);
}

int main(){
    int n;
    vector<pair<ll, ll>> p;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        p.push_back(make_pair(tmp1, tmp2));
    }
    

    sort(p.begin(), p.end(), plus_comp);

    ll ans = 0;
    for(int i = 0; i < p.size(); i++)
    {
        if(i % 2 == 0){
            ans += p[i].first;
        }else{
            ans -= p[i].second;
        }
    }
    

    cout << ans << endl;

}

Measured memory_bytes: 2420
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.function.Predicate;

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		int N_haku = scan.nextInt();
		int K_first = scan.nextInt();
		int X_yen = scan.nextInt();
		int Y_yen = scan.nextInt();

		int firstDay = Math.min(N_haku, K_first);
		int firstCost = firstDay * X_yen;

		int secondDay = Math.max(N_haku - K_first, 0);
		int secondCost = secondDay * Y_yen;

		System.out.println(firstCost + secondCost);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 27052
#include <iostream>
using namespace std;
int main(void){


    int A, B; cin >> A >> B;
    
    int j = 1;
    int ans = 0;
    
    while(B > j){
      --j;
      j += A;
      ++ans;
    }
    
    cout << ans;
    
    return 0;
    
}


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

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

#define INF 1e9

int dp[102][102]={0}, e[102][102]={0};

int main(){
    int n, m;
    cin >> n >> m;
    for(int i=0;i<=100;++i)
        for(int j=0;j<=100;++j){
            dp[i][j] = (i == j ? 0 : INF);
            e[i][j] = INF;
        }

    for(int i=0;i<m;++i){
        int a, b, c;
        cin >> a >> b >> c;
        dp[a][b] = c;
        dp[b][a] = c;
        e[a][b] = c;
        e[b][a] = c;
    }

    for(int k=1;k<=n;++k)
        for(int i=1;i<=n;++i)
            for(int j=1;j<=n;++j)
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);

    int ans = m;
    for(int i=1;i<=n;++i){
        for(int j=i+1;j<=n;++j){
            if(e[i][j] == INF)continue;
            bool flag = true;
            for(int k=1;k<=n;++k){
                if(dp[i][k] + dp[k][j] < e[i][j])flag = false;
            }
            if(flag)ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 1e18;
const ll fact_table = 5000000;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
vector<ll> R[550010];
vector<pair<ll, double> > tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<"\n";
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
//ll mod = 1000000007;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,f,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
ll dp[5005][5005];
char s[500005];
char t[500005];
bool used[500005];

ll win(ll idx){
    if(s[idx] == 'p'){
        return b;
    }else if(s[idx] == 'r'){
        return c;
    }else{
        return a;
    }
    return 0;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n >> k;
    cin >> a >> b >> c;
    cin >> s;
    for(ll i=0;i<n;i++){
        if(i < k){
            used[i] = true;
            ans += win(i);
        }else{
            if(used[i-k] && s[i] == s[i-k]){
                continue;
            }else{
                used[i] = true;
                ans += win(i);
            }
        }
    }
    p(ans);
    return 0;
}















Measured memory_bytes: 38016
#include <stdio.h>

int main(int argc, char *argv[])
{
    int X, i, t = 0;

    scanf("%d", &X);

    for ( i = 1; i <= X; i++ ){
        t += i;
        if ( t >= X ){
            break;
        }
    }
    printf("%d\n", i);
    return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>

using namespace std;

const int INF = 1000000007;

const int MAX_H = 50;
const int MAX_W = 50;

// 下、右、上、左
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = { 1, 0, -1, 0 };

int H, W;

char field[MAX_H][MAX_W + 1];
char cpy[MAX_H][MAX_W + 1];

int memo[MAX_H][MAX_W];

int bfs(int i, int j)
{
    queue< pair<int, int> > que;

    // スタート地点をキューに入れる
    que.push(make_pair(i, j));

    while (que.size())
    {
        pair<int, int> p = que.front();
        que.pop();

        i = p.first;
        j = p.second;

        // 行った
        cpy[i][j] = '#';

        if (i == H - 1 && j == W - 1) return 0;
        for (int k = 0; k < 4; k++)
        {
            int ni = i + dy[k];
            int nj = j + dx[k];

            if (ni < 0 || H <= ni
                || nj < 0 || W <= nj
                || cpy[ni][nj] == '#'
                || memo[ni][nj] < INF)
            {
                continue;
            }

            memo[ni][nj] = memo[i][j] + 1;
            que.push(make_pair(ni, nj));
        }
    }
    return -1;
}

int main()
{
    if (scanf("%d%d", &H, &W) < 2) return 0;

    int bcnt = 0;
    for (int i = 0; i < H; i++)
    {
        if (scanf("%s", field[i]) < 1) return 0;

        for (int j = 0; j < W; j++)
        {
            if (field[i][j] == '.') bcnt++;
            memo[i][j] = INF;
        }
    }

    memcpy(cpy, field, sizeof field);

    memo[0][0] = 1;

    // 幅優先探索 Breadth-First Search
    int ret = bfs(0, 0);

    if (ret == -1)
    {
        printf("%d\n", ret);
    }
    else
    {
        printf("%d\n", bcnt - memo[H - 1][W - 1]);
    }

    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

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

int main() {
	int V, E, r;
	cin >> V >> E >> r;
	vector<vector<Edge>> graph(V);
	Rep(i, E) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].push_back(Edge(t, d));
	}
	vector<int> dist(V, INFTY);
	dist[r] = 0;
	Rep(i, V) {
		bool flag = false;
		Rep(j, V) {
			Rep(k, graph[j].size()) {
				if (dist[j] != INFTY && dist[graph[j][k].to] > dist[j] + graph[j][k].weight) {
					dist[graph[j][k].to] = dist[j] + graph[j][k].weight;
					flag = true;
					if (i == V - 1) {
						cout << "NEGATIVE CYCLE" << endl;
						return 0;
					}
				}
			}
		}
		if (!flag) break;
	}
	Rep(i, V) {
		if (dist[i] == INFTY) cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
	return 0;
}


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

int S[10];
int k[10];
int s[10][10] = {0};
int p[10];
int ans = 0;

void rec(int j,int N, int M){
    int count;
    int judge;

    if(j==N){
        count = 0;
        for (int i = 0; i < M; i++)
        {
            judge = 0;
            for (int l = 0; l < k[i]; l++)
            {
                judge += S[s[i][l]-1];
            }
            if(judge%2 == p[i]) count++;
        }
        if(count == M) ans++;
        return;
    }
    S[j]=0;
    rec(j+1,N,M);
    S[j]=1;
    rec(j+1,N,M);
}

void makeCombination(int N,int M){
    for (int i = 0; i < N; i++)
    {
        S[i]=0;
    }
    rec(0,N,M);
}

int main(){
    int N,M;
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        cin >> k[i];
        for (int l = 0; l < k[i]; l++)
        {
            cin >> s[i][l];
        }
        
    }

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

    makeCombination(N,M);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
int main(){
    string S;
    getline(cin,S);

    if (S.length() == 3){
        printf("%c%c%c\n",S[2],S[1],S[0]);
    }else{
        printf("%c%c\n",S[0],S[1]);
    }
    return 0;
}

Measured memory_bytes: 256
D,target=map(int,input().split())
l=[]
ans=10**9

for i in range(D):
    l.append(list(map(int,input().split())))

for i in range(2**D):
    score=0
    problems=0
    resindex=-1
    for j in range(D):
        if i>>j&1==1:
            score+=(j+1)*100*l[j][0]+l[j][1]
            problems+=l[j][0]
        else:
            resindex=j

    if score>=target:
        ans=min(ans,problems)
    elif resindex>=0 and score+l[resindex][0]*(resindex+1)*100>=target:
        problems+=-(-(target-score)//((resindex+1)*100))
        ans=min(ans,problems)

print(ans)

Measured memory_bytes: 3064
def solve():
    N = int(input())
    print(dfs("",N, [False,False,False]))

def dfs(num, N, include):
    cnt = 0
    digit = ['7','5','3']

    for i in range(len(digit)):
        next_num = num + digit[i]
        next_include = include[:]
        next_include[i] = True
        if int(next_num) <= N:
            if next_include == [True,True,True]:
                cnt += 1
            cnt += dfs(next_num,N, next_include)
    
    return cnt
    
if __name__ == '__main__':
    solve()

Measured memory_bytes: 51548
#include<stdio.h>

int main(void)
{
    int h,n,i;

    scanf("%d%d",&h,&n);
    int a;
    for(i=0;i<n;i++){
        scanf("%d",&a);
        h=h-a;}
    if(h<=0) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,c;
    scanf("%d", &a); 
    scanf("%d", &b); 
    scanf("%d", &c); 

    int max = a;
  
    if(max < b) max = b;
    if(max < c) max = c;
    printf("%d\n",a+b+c-max);

    return 0;
    
}

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

wa = [0] * N
pnt = [0] * N
ac = [False] * N

for _ in range(M):
    p, s = list(map(str, input().split()))
    if s == 'WA':
      wa[int(p) - 1] += 1
    elif s == 'AC' and not (ac[int(p) - 1]):
      ac[int(p) - 1] = not (ac[int(p) - 1])
      pnt[int(p) - 1] += wa[int(p) - 1]

print(ac.count(True), sum(pnt))

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    double l;cin >> l;
    cout << fixed << setprecision(9) << pow(l/3,3) << endl;
}

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

int n, m, q, p[502][502];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m >> q;
    for(int i = 1; i <= m; i++){
        int l, r;
        cin >> l >> r;
        p[l][r]++;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            p[i][j] += p[i][j-1];
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            p[i][j] += p[i-1][j];
        }
    }
    for(int i = 1; i <= q; i++){
        int l, r;
        cin >> l >> r;
        int ans = p[r][r] + p[l-1][l-1] - p[l-1][r] - p[r][l-1];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
vector <char> v;
vector<int> num;

int main(){
  int a , b;
  int ans = 0;

  cin >> a>>b;

  for (int i = 1; i< a+1;i++){
    if(i < a){for (int j = 0; j < 31 ;j ++){
      if(i == j)ans++;
    }
  }
  else if(i == a){
    for (int j = 0; j < b+1 ;j ++){
      if(i == j)ans++;
    }
  }
}
cout << ans<<endl;
return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
#define pp pair<pii,pii>
const int hell =1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
int p[100000]={0};
bool b[100000]={false};

void pri()
{
  

  rep(i,2,100000)
  for(int j=i+i;j<100000;j+=i)b[j]=true;

    rep(i,2,100000)if(b[i]==false)p[i]=1;
}



int solve( ){

int a,b;
cin>>a>>b;
int mx=max(a,b),mn=min(a,b);
if(mx-mn>=1)
{
	cout<<mx+mx-1;
}
if(mn==mx)
{
	cout<<2*mn;
}


return 0;
}



signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);

 // pri();
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
   //cout << "Processor time taken is "
     // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  string str; cin >> str;
  int count=0,c=0,len=str.length();
  for(int i=0;i<len;i++){
    if(c==0 && str[i]=='T')count++;
    else if(str[i]=='T')c--;
    else c++;
  }
  cout << 2*count;
}


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

int main()
{
	long n, a, b, ans, rem;
	cin >> n >> a >> b;
	ans = n / (a + b) * a;
	rem = n % (a + b);
	ans += min(rem, a);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256