akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int x;cin >> x;
	if(x >= 1800)cout << 1 << endl;
	else if(x >= 1600)cout << 2 << endl;
	else if(x >= 1400)cout << 3 << endl;
	else if(x >= 1200)cout << 4 << endl;
	else if(x >= 1000)cout << 5 << endl;
	else if(x >= 800)cout << 6 << endl;
	else if(x >= 600)cout << 7 << endl;
	else if(x >= 400)cout << 8 << endl;

	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, vector<int> > P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007

int n;
vector<int> a;

ll f(const vector<int>& v){
  ll res=0;
  rep(i,n){
    res*=10LL;
    res+=v[i];
  }
  return res;
}

map<ll,int> d1,d2;

int main(){
  cin>>n;
  rep(i,n){
    int b;
    cin>>b;
    a.push_back(b);
  }
  d1[f(a)]=0;
  queue<vector<int> > que;
  que.push(a);
  while(que.size()){
    vector<int> crt=que.front();
    que.pop();
    if(d1[f(crt)]>=(n/2)-1)continue;
    rep(i,n)repl(j,i+1,n){
      vector<int> nxt=crt;
      reverse(nxt.begin()+i,nxt.begin()+j+1);
      if(d1.find(f(nxt))!=d1.end())continue;
      d1[f(nxt)]=d1[f(crt)]+1;
      que.push(nxt);
    }
  }

  vector<int> p;
  rep(i,n)p.push_back(i+1);
  que.push(p);
  d2[f(p)]=0;
  while(que.size()){
    vector<int> crt=que.front();
    que.pop();
    if(d1.find(f(crt))!=d1.end()){
      cout<<d1[f(crt)]+d2[f(crt)]<<endl;
      return 0;
    }
    rep(i,n)repl(j,i+1,n){
      vector<int> nxt=crt;
      reverse(nxt.begin()+i,nxt.begin()+j+1);
      if(d2.find(f(nxt))!=d2.end())continue;
      d2[f(nxt)]=d2[f(crt)]+1;
      que.push(nxt);
    }
  }
  return 0;
}



Measured memory_bytes: 198540
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
from scipy.misc import comb

# 再帰がやばいとき
# import sys
# sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def main():
    N = i_inpl()
    v = l_inpl()
    v.sort()
    tmp = (v[0] + v[1])/2
    for vi in v[2:]:
        tmp = (tmp + vi)/2
    print(tmp)

if __name__ == "__main__":
    main()


Measured memory_bytes: 14228
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
    int n;
    cin>>n;
    if(n==7 || n==5 || n==3){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
    

}





Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void) {
	double x1, y1, x2, y2;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
	printf("%.4lf\n", hypot(x1-x2, y1-y2));
	return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 8+1
int n,m,ans=0;
bool G[MAX_V][MAX_V];
bool used[MAX_V];

bool check(){
    FOR(i,1,n+1) if(!used[i]) return false;
    return true;
}

void dfs(int s){
    if(check()) ++ans;
    FOR(i,1,n+1){
        if(G[s][i] && !used[i]){
            //G[s][i] = false;
            used[i] = true;
            dfs(i);
            used[i] = false;
        }
    }
}

int main(){
    cin.tie(0), ios::sync_with_stdio(false);
    cin >> n >> m;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        G[a][b] = G[b][a] = true;
    }
    REP(i,n+1) used[i] = false;
    used[1] = true;
    dfs(1);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int k,n;

  cin >> k >> n;

  vector<int> a(k);

  vector<int> dis(n);

  int sum = 0;

  rep(i,n) cin >> a.at(i);

  for(int i = 0; i<n-1 ; i++){
    
      dis.at(i) = a.at(i+1)-a.at(i);
    
  }

  dis.at(n-1) = k-a.at(n-1)+a.at(0);

  sort(dis.begin(),dis.end());

  rep(i,n-1) sum+=dis.at(i);

  cout << sum;

}

Measured memory_bytes: 7960
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	string s,t;
	cin >> s >> t;
	t.erase(t.length()-1,1);
	if(s==t) cout << "Yes" <<endl;
    else cout <<"No"<<endl;
	
}
	

Measured memory_bytes: 3624
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(sc.next());
			if (n == 0) break;
			String[] w = new String[n];
			for (int i  = 0; i < n; i++) {
				w[i] = sc.next();
			}
			for (int i = 0; i < n; i++) {
				boolean a = false;
				boolean b = false;
				boolean c = false;
				boolean d = false;
				boolean e = false;
				int index = i;
				int len = 0;
				while (index < n && len < 5) {
					len += w[index++].length();
				}
				if (len == 5)
					a = true;
				else
					continue;
				len = 0;
				while (index < n &&len < 7) {
					len += w[index++].length();
				}
				if (len == 7)
					b = true;
				else
					continue;
				len = 0;
				while (index < n && len < 5) {
					len += w[index++].length();
				}
				if (len == 5)
					c = true;
				else
					continue;
				len = 0;
				while (index < n && len < 7) {
					len += w[index++].length();
				}
				if (len == 7)
					d = true;
				else
					continue;
				len = 0;
				while (index < n && len < 7) {
					len += w[index++].length();
				}
				if (len == 7)
					e = true;
				else
					continue;
				if (a && b && c && d && e) {
					System.out.println(i + 1);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 31216
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
S = inpll(m)
P = inpl()

ans = 0
for bi in itertools.product([0,1],repeat=n):
    for i in range(m):
        cnt = 0
        for j in range(S[i][0]):
            if bi[S[i][j+1]-1] == 1:
               cnt += 1
        if cnt%2 != P[i]:
            break
        else:
            continue
        break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 31232
#include<bits/stdc++.h>
using namespace std;
int main() {
  long long N, white, ans; cin >> N;
  vector<long long> V(N);
  char c;
  cin >> c; if (c=='.') V[0]=1;
  for (long long i=1; i<N; i++) {
    cin >> c;
    if (c=='.') V[i]= V[i-1]+1;
    else V[i]= V[i-1];
  }
  white = V[N-1];
  ans = white;
  for (long long i=0; i<N; i++) {
    ans = min(ans, i+1-V[i]+ white-V[i]);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1792
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

bool dcl(P a, P b){
    return atan2(a.first, a.second) < atan2(b.first, b.second);
}

int main(){
    ll N; cin >> N;
    vector<P> C(N);
    rep(i, 0, N){
        ll a, b; cin >> a >> b;
        C[i] = mp(a, b);
    }
    sort(C.begin(),C.end(),dcl);
    vector<P> D(0);
    rep(i, 0, N){
        D.emplace_back(C[i]);
    }
    rep(i, 0, N){
        D.emplace_back(C[i]);
    }
    long double ma = 0;
    ll v = 0;
    rep(i, 0, N){
        rep(j, i+1, i+N+1){
            ll m = 0, n = 0;
            rep(k, i, j){
                m += D[k].first; n += D[k].second;  
            }
            ma = max(ma, sqrtl(m*m + n*n));
            v++;
        }
    }
    //prtl(v);
    cout << setprecision(15) << ma;
}


Measured memory_bytes: 384
#include<iostream>
using namespace std;
#include<string>
#include<stdio.h>

typedef struct box { int val; box *prev, *next; } box_t;
box_t* init()
{
    box_t* head = new box_t;
    head->val = -1;
    head->next = NULL;
    head->prev = NULL;
    return head;
}
box_t* make_tail(box_t* head)
{
    box_t* tail = new box_t;
    tail->val = -1;
    head->next = tail;
    tail->next = NULL;
    tail->prev = head;
    return tail;
}
// f_insert, f_delete_key, f_delete, b_delete, f_show.
box_t* f_insert(box_t* head, int data)
{
    box_t* box = new box_t;
    box->val = data;
    box->next = head->next;
    box->prev = head;
    head->next->prev = box;
    head->next = box;
    return box;
}
int f_delete_key(box_t* head, box_t* tail, int key)
{
    box_t* box = head->next;
    while(box != tail){
        if(box->val == key){
            box->next->prev = box->prev;
            box->prev->next = box->next;
            delete box;
            return 1; }
        box = box->next; };
    return -1;
}
int f_delete(box_t* head)
{
    if(!(head->next->next)) return -1;
    box_t* box = head->next;
    head->next = box->next;
    box->next->prev = head;
    delete box;
    return 1;
}
int b_delete(box_t* tail)
{
    if(!(tail->prev->prev)) return -1;
    box_t* box = tail->prev;
    tail->prev = box->prev;
    box->prev->next = tail;
    delete box;
    return 1;
}
void f_show(box_t* head, box_t* tail)
{
    box_t* box = head->next;
    while(box != tail){
        printf("%d", box->val);
        box = box->next;
        if(box != tail) printf(" "); };
    printf("\n");
    return;
}

int main()
{
    int i, n;
    scanf("%d", &n);
    char cmd[12]; int key;
    box_t* head = init();
    box_t* tail = make_tail(head);
    for(i = 0; i < n; i++){
        scanf("%s", cmd);
        if(cmd[0] == 'i'){ scanf("%d", &key); f_insert(head, key); }
        else if(cmd[6] == 'F'){ f_delete(head); }else if(cmd[6] == 'L'){ b_delete(tail); }
        else{ scanf("%d", &key); f_delete_key(head, tail, key); }
    }
    f_show(head, tail);
    return 0;
}

Measured memory_bytes: 32364
#include <bits/stdc++.h>
#define int long long
#define multi_test true and false
using namespace std;

void solve()
{
    int k, a, b;
    cin >> k >> a >> b;
    if (a > b)
        swap(a, b);
    bool bani = false;
    if (a % k == 0)
        bani = true;
    int temp = a / k * k + k;
    if (temp <= b)
        bani = true;
    cout << (bani ? "OK" : "NG") << endl;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int test = 1;
    if (multi_test)
        cin >> test;

    while (test--)
        solve();
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <set>
#include <cstring>
#include <map>
#include <bitset>
#include <random>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <ctime>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define sc second
#define fs first
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template<class T> T sqr(T x) { return x*x; }
ld pi = 3.1415926535897932384626433832795;
ll mod = 1e9 + 7;
const int N = 1e6 + 10;

typedef vector<vector<ll> > mtrx;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll ans[111];

int try_solve(int n) {
	ll a = 1;
	while (1) {
		int id = 0;
		for (int i = 0; i < n; i++)
			if (ans[i] > ans[id]) id = i;
		if (ans[id] < n) {
			return a-1;
		}
		a++;
		for (int i = 0; i < n; i++) ans[i] += 1;
		ans[id] -= n + 1;
	}
}

ll b[111];
bool can(ll k, int n) {
	for (int i = 0; i < n; i++)
		b[i] = ans[i] + k;
	ll dd = n + 1;
	ll need = 0;
	for (int i = 0; i < n; i++)
		need += (b[i]-(n-1) + dd-1) / dd;
	return need <= k;
}

int main(){
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ans[i];
	ll res = 0;
	while (1) {
		ll temp = 0;
		for (int i = 0; i < n; i++) {
			ll t = (ans[i] - (n - 1)) / n;
			temp += t;
			ans[i] -= t*(n+1);
		}
		for (int i = 0; i < n; i++)
			ans[i] += temp;
		res += temp;
		if (temp == 0) break;
	}
	cout << res + try_solve(n);
	//ll k;
	//cin >> k;
	/*
	if (k == 1) {
		cout << 3 << '\n' << 0 << ' ' << 0 << ' ' << 3;
	}
	else if (k == 2) {
		cout << 2 << '\n' << 2 << ' ' << 2;
	} else if (k < 10)
	cout << 2 << '\n' << 2 - 1 << ' ' << 2ll - 1ll + k;
	else {
		ll n = 50;
		ll cur = k;
		for (int i = 0; i < n; i++) {
			ans[i] = n-1;
			ll add = min(cur, k / n);
			ans[i] += add;
			cur -= add;
		}
		for (int i = 0; i < cur; i++)
			ans[i] += n-cur;
		//ans[0] += 1;
		//ans[0] += 10;
		cout << n << endl;
		for (int i = 0; i < n; i++) {
			cout << ans[i] << ' ';
		}
		//try_solve(k, n);
	}*/
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll a,b;cin>>a>>b;
  if(a<=0&&0<=b)out("Zero");
  else if(a>0)out("Positive");
  else {
    if((b-a+1)%2==0)out("Positive");
    else out("Negative");
  }




  return 0;
}


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

int main() {
  string s, t;
  cin >> s;
  
  int i, x, ans = 999;
  for(i = 0; i < s.size() - 2; i++){
    t = s.substr(i, 3);
    x = stoi(t);
    ans = min(ans, abs(753 - x));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int64_t long long
constexpr int64_t MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;++i){
        int cnt=0;
        int x=i;
        while(x){
            cnt++;
            x/=10;
        }
        if(cnt%2)++ans;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
void func(int,int);
int za[91][91];
int m,n;
int x,y;
int cnt,max;
int main(void)
{
	int i,j;
	scanf("%d",&m);
	scanf("%d",&n);
	while(m!=0 && n!=0){
		max=-1;
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				za[i][j]=0;
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				scanf("%d",&za[i][j]);
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				if(za[i][j]==1){
					//cnt++;
					func(i,j);
				}
			}
		}
		printf("%d\n",max);
		scanf("%d",&m);
		scanf("%d",&n);
	}
	return 0;
}
void func(int x,int y)
{
	//printf("y=%d x=%d\n",y,x);
	//cnt=0;
	int i,j;
	if(x+1<=m){
		if(za[x+1][y]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
				//printf("max=%d\n",max);
			}
			
			za[x+1][y]=0;
			func(x+1,y);
			za[x+1][y]=1;
			cnt--;
		}
	}
	if(y+1<=n){
		if(za[x][y+1]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
				//printf("max=%d\n",max);
			}
			
			za[x][y+1]=0;
			func(x,y+1);
			za[x][y+1]=1;
			cnt--;
		}
	}
	if(x-1>=0){
		if(za[x-1][y]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
				//printf("max=%d\n",max);
			}
			
			za[x-1][y]=0;
			func(x-1,y);
			za[x-1][y]=1;
			cnt--;
		}
	}
	if(y-1>=0){
		if(za[x][y-1]==1){
			cnt++;
			if(max<cnt){
				max=cnt;
				//printf("max=%d\n",max);
			}
			
			za[x][y-1]=0;
			func(x,y-1);
			za[x][y-1]=1;
			cnt--;
		}
	}
	//cnt=0;
}
	
		

Measured memory_bytes: 1056
/*It’s going to be hard,
but hard does not mean impossible.*/

#include <bits/stdc++.h>

// definitions
#define __Imperial_Lord__ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define _cps CLOCKS_PER_SEC
#define f first
#define s second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (long long)(r); i++)
#define repb(i, r, l) for (long long i = (r); i > (long long)(l); i--)
#define acc(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define high(x) __builtin_popcountll(x)
#define pb push_back
#define pf push_front
#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"
#define p2(a, b) cout << a << " " << b << "\n"
#define p3(a, b, c) cout << a << " " << b << " " << c <<"\n"
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d <<"\n"
#define exec cerr<<"Time taken : "<<(ld)(clock())/_cps<<"s"<<"\n"
#define mod1 998244353
#define mod 1000000007
#define pi 3.1415926535897932384

using namespace std;

// alias name for common data types
typedef vector<long long> vl;
typedef vector<long double> vld;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dql;
typedef deque <char> dqc;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1e18;

template <class ...Args>
istream &read_args(Args &...args) {return (cin >> ... >> args);}
#define read(...)   __VA_ARGS__; read_args(__VA_ARGS__)

// cin and cout overloaded for vectors
template<typename T>    istream& operator>>(istream& is,  vector<T>& v)
{
    for (auto& i : v)
        is >> i;
    return is;
}
template<typename T>    ostream& operator<<(ostream& os,  vector<T>& v)
{
    for (auto& i : v)
        os << i << ' ';
    return os;
}

// code beigns in main
int main()
{
    __Imperial_Lord__
    ll t = 1;
    // cin >> t;
    
    while (t--)
    {
        ll read(x);
        if(x>=400 && x<600) p1("8");
        else if(x>=600 && x<800) p1("7");
        else if(x>=800 && x<1000) p1("6");
        else if(x>=1000 && x<1200) p1("5");
        else if(x>=1200 && x<1400) p1("4");
        else if(x>=1400 && x<1600) p1("3");
        else if(x>=1600 && x<1800) p1("2");
        else if(x>=1800 && x<2000) p1("1");
    }   
    exec;
}





Measured memory_bytes: 3796
#include <cstdio>

long long ex2[63];
long long A,B;
long long askzero(long long minv,int dig) {
	//(minv), ... , 111..1 at least one
	minv=(minv&(ex2[dig]-1));
	long long ret=1;
	for(int i=dig-1;i>=0;i--) {
		if(minv&ex2[i]) {
		} else {
			ret+=ex2[i];
		}
	}
	if(minv==0) ret--;
	return ret;
}
int main() {
	ex2[0]=1;
	for(int i=1;i<62;i++) ex2[i]=ex2[i-1]*2;
	scanf("%lld%lld",&A,&B);
	if(A==B) {
		printf("1\n");
		return 0;
	}
	long long sol=0;
	for(int dig=61;dig>=0;dig--) {
		if((A&ex2[dig])!=(B&ex2[dig])) {
			if(dig==0) {
				printf("2\n");
				return 0;
			}
			//printf("%lld %lld %d\n",A,B,dig);
			//different
			//dig==0: continue
			sol+=askzero(A&(ex2[dig]-1),dig);
			if((A&(ex2[dig]-1))==0) sol++;
			//dig==1
			int dig2=dig-1;
			while(1) {
				if(B&ex2[dig2]) break;
				dig2--;
				if(dig2==-1) break;
			}
			A=(A&(ex2[dig]-1));
			if(dig2<0) {
				sol+=askzero(A,dig)+1;
			} else if(A<=ex2[dig2+1]-1) {
				sol+=ex2[dig];
			} else {
				sol+=askzero(A,dig);
				sol+=ex2[dig2+1];
			}
			//sol+=ex2[dig2+1]*(askzero((A>>(dig2+1)),dig-dig2-1)+1);
			break;
		}
	}
	printf("%lld\n",sol);
	return 0;
}


Measured memory_bytes: 128
from collections import Counter

S=input()
n=len(S)
dp=[[0]*n for _ in range(20)]

for i,s in enumerate(S):
    dp[0][i]=i-1 if s =='L' else i+1

for k in range(19):
    for i in range(n):
        dp[k+1][i]=dp[k][dp[k][i]]

C=Counter(dp[-1])

print(*[C[i] for i in range(n)])

Measured memory_bytes: 35620
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll x,y,z;
	cin >> x >> y >> z;
	ll i = 0;
	while(1){
		if (x >= (y*i +z*(i+1))){
			i++;
		}
		else{
			break;
		}
	}
	cout << i - 1 <<endl;

	return 0;
}

Measured memory_bytes: 256
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]


satisfaction = 0
last = [0]*26

for i in range(D):

    best_sat = satisfaction
    best_T = 0
    for t in range(26):
        t_sat = S[i][t] + satisfaction - \
                sum([C[k]*((i+1)-last[k]) for k in range(26)]) + C[t]*((i+1)-last[t])
        if t_sat > best_sat:
            best_T = t
            best_sat = t_sat

    saticfaction = S[i][best_T] \
                   + satisfaction - sum([C[k]*((i+1)-last[k]) for k in range(26)]) \
                   + C[best_T]*((i+1)-last[best_T])
    last[best_T] = i + 1
    # print('i:'+str(i))
    # print(last)
    print(best_T+1)


Measured memory_bytes: 9548
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//for
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//range
#define all_range(C) begin(C), end(C)
//STL
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//chmin&chmax
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//GCD
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//LCM
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//POW
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

//main.cpp----------------------------


int main() {
  string s;
  cin >> s;

  int r1 = (s[0]-'0')*10 + (s[1]-'0');
  int r2 = (s[2]-'0')*10 + (s[3]-'0');

  if(r1==0&&r2==0) {
    cout << "NA" << endl;
  }else if(r2==0) {
    if(r1<=12) {
      cout << "MMYY" << endl;
    }else {
      cout << "NA" << endl;
    }
  }else if(r1==0){
    if(r2<=12) {
      cout << "YYMM" << endl;
    }else {
      cout << "NA" << endl;
    }
  }else {
    if(r1<=12&&r2<=12) {
      cout << "AMBIGUOUS" << endl;
    }else if(r1>12&&r2>12) {
      cout << "NA" << endl;
    }else if(r1>12){
      cout << "YYMM" << endl;
    }else if(r2>12) {
      cout << "MMYY" << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = input.split("\n");
	N = input[0]
	a_arr = input[1].split(" ")

	console.log(
	a_arr.map((a, i) => {
		return a%2===1 && (i+1)%2===1 ? 1 : 0
	}).reduce((prev, curr) => prev + curr, 0)
	)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29684
#include <cstdio>

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

constexpr i64 MOD = 1000000007;

template<u64 N>
class T
{
	public:
		constexpr T() : data()
		{
			for (i64 i = 0; i <= N; ++i)
			{
				data[i] = i;
			}
			for (i64 i = 2; i <= N; ++i)
			{
				if (data[i] != i) continue;
				for (i64 j = i; j <= N; j += i)
				{
					data[j] = data[j] / i * (i - 1);
				}
			}
			for (i64 i = 1; i <= N; ++i)
			{
				data[i] = (data[i] + data[i - 1]) % MOD;
			}
		}

		i32 data[N + 1];
};


template<typename T>
constexpr T pow_mod(T a, T b, T m)
{
	T r = 1;
	while (b > 0)
	{
		if ((b & 1) != 0) r = (r * a) % m;
		a = (a * a) % m;
		b >>= 1;
	}
	return r;
}

constexpr T<100000> t;

int main()
{
	i64 n, k;
	scanf("%lld%lld", &n, &k);
	i64 ans = 0;
	for (i64 i = 1; i <= k;)
	{
		i64 j = k / (k / i);
		ans = (ans + pow_mod(k / i, n, MOD) * (t.data[j] + MOD - t.data[i - 1])) % MOD;
		i = j + 1;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 1940
#11
from collections import Counter
N = int(input())
a = list(map(int, input().split()))


mod = 10 ** 9 + 7
up = [1 for i in range(N+1)]
for i in range(2, N+1):
    up[i] = up[i-1]*i % mod
down = [1 for i in range(N+1)]
down[N] = pow(up[N], mod-2, mod)
for i in range(N-1, 0, -1):
    down[i] = (i+1)*down[i+1] % mod


def ncr(n, r):
    if not n >= r >= 0:
        return 0
    else:
        return up[n]*down[n-r]*down[r] % mod


duplicated_number, _cnt = Counter(a).most_common()[0]
index_que = []

for i in range(N+1):
    if a[i] == duplicated_number:
        index_que.append(i)
        
A, B = min(index_que), max(index_que)

for k in range(1, N+2):
    if k == 1:
        print(N)
    else:
        ans = ncr(N-1, k-2)+ncr(N-1, k)+2 * ncr(N-1, k-1)-ncr(N-B+A, k-1)
        print(ans % mod)



Measured memory_bytes: 114048
#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;

int main()
{
	unsigned int n, a, b, ans;

	// input
	cin >> n >> a >> b;

	// calc
	if (a * n > b) {
		ans = b;
	}else {
		ans = a * n;
	}

	// output
	cout << ans;
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
B,C=[0 for i in range(n+1)],[]
cnt=0
for i in range(1,n+1)[::-1]:
    sum_B=sum(B[j] for j in range(i,n+1,i))
    if sum_B%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)
print(cnt)
print(*[i for i in C[::-1]])

Measured memory_bytes: 14844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> pii;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
#define all(a) a.begin(), a.end()

const int MOD = 1e9+7;
const int INF = 1001001001;
int edge[8][8] {0};

int main(){
    int N, M;
    cin >> N >> M;
    rep(i, 0, M){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edge[a][b] = 1;
        edge[b][a] = 1;
    }
    int ans = 0;
    vector<int> v(N);
    iota(v.begin(), v.end(), 0);
    do {
        bool ok = true;
        if (v[0] != 0) continue;
        rep(i, 1, N){
            if (edge[v[i-1]][v[i]]) continue;
            ok = false;
            break;
        }
        if (ok){
            ans++;
        }
    } while(next_permutation(v.begin(), v.end()));
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

struct ST {
  string s;
  int p;
  int i;
};
bool operator<(const ST& a, const ST& b){
  if(a.s == b.s) return a.p > b.p;
  return a.s < b.s;
}

int main(){
  int N;
  cin >> N;
  vector<ST> v;
  rep(i,N){
    ST st;
    cin >> st.s >> st.p;
    st.i = i+1;
    v.push_back(st);
  }
  sort(ALLOF(v));
  rep(i,v.size()){
    cout << v[i].i << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) { //Passes samples, but WA
		Scanner input = new Scanner(System.in);
		int N = input.nextInt();
		double[][] dp = new double[N+1][N+1];
		double[] p = new double[N+1];
		double answer = 0.0;
		double bug = 1.0; //keep track of tails' product
		for (int i = 1; i <= N; i++) {
			p[i] = input.nextDouble();
		}
		dp[1][1] = p[1];
		bug=1.0-p[1];
		for (int i = 2; i <= N; i++) { //Filling diagonals of DP table
			dp[i][i] = dp[i-1][i-1]*p[i];
		}
		for (int j = 2; j <= N; j++) { //Filling 1st row of DP table
			dp[1][j] = dp[1][j-1]*(1.0-p[j])+p[j]*(bug);
			bug*=(1.0-p[j]);
		}
		for (int i = 2; i < N; i++) { //dp[N][N] is already filled, last row not necessary
			for (int j = i+1; j <= N; j++) {
				dp[i][j]=dp[i][j-1]*(1.0-p[j])+dp[i-1][j-1]*p[j]; 
			}
		}
		/*for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				System.out.print(dp[i][j]+" ");
			}
			System.out.print("\n");
		}*/
		for (int i = N/2+1; i <= N; i++) {
			answer+=dp[i][N];
		}
		System.out.println(answer);
	}
}

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

int main() {
  int64_t X;
  cin >> X;
  
  int64_t a = 0;
  int i = 0;
  
  if (X <= 1335850880) {
    a = 100;
    while (a < X) {
      i++;
      a = a*1.01;
    }
  }
  else {
    i = 1706;
    a = 1335850880;
    while (a < X) {
      i++;
      a = a*1.01;
    }
  }
    cout << i << endl;
  
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

ll N,K;
vector<int> A;

int first[200020];
int pre[200020];

int dp[200020];
bool used[200020];

int main(){
  cin>>N>>K;
  A.resize(N);
  for(int i=0;i<N;i++) cin>>A[i];

  for(int i=N-1;i>=0;i--) first[A[i]]=i;

  for(int i=0;i<N;i++){
    pre[A[i]]=-1;
    dp[i]=-1;
  }
  dp[N]=-1;

  for(int i=N-1;i>=0;i--){
    if(pre[A[i]]==-1){
      dp[i]=i;
    }else{
      if(pre[A[i]]==N-1) dp[i]=-1;
      else dp[i]=dp[pre[A[i]]+1];
    }
    pre[A[i]]=i;
  }

  vector<int> res;
  int now=0;
  while(dp[now]!=-1){
    res.push_back(dp[now]);
    now=dp[now];
    now=first[A[now]]+1;
  }
  res.push_back(-1);



  ll M=res.size();
  K%=M;

  if(K==0){
    cout<<endl;
    return 0;
  }

  int cnt=res[K-1];
  vector<int> ans;
    for(int i=cnt;i<N;i++){
      if(used[A[i]]){
        while(1){
          if(ans.back()==A[i]){
            used[A[i]]=false;
            ans.pop_back();
            break;
          }else{
            used[ans.back()]=false;
            ans.pop_back();
          }
        }
      }else{
        used[A[i]]=1;
        ans.push_back(A[i]);
      }
    }

    for(int i=0;i<ans.size();i++) cout<<ans[i]<<" ";
    cout<<endl;
  

  return 0;
}


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

int main(){
	int N;
	cin >> N;
	int j = 0;
			for (int i = 0; i < N; i++){
		string s;
		cin >> s;
		j++;
				if (s == "Y") {
					cout << "Four" <<endl;
			break;
		}
		if (j == N ){
		cout << "Three" << endl;}
	}
}


Measured memory_bytes: 256
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = list(map(int, input().split()))
    #a = [list(input().split()) for i in range(n)]
    #a = [int(input()) for i in range(n)]
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    s=list(input())
    n=len(s)
    l1=s[:(n-1)//2]
    l2=s[(n+3)//2-1:]
    if s==s[::-1] and l1==l1[::-1] and l2==l2[::-1]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()



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

int main(){
	string x;
	int k=0;
	while(true){
		cin>>x;
		if (x=="0")break;
		for(int i=0;i<x.size();i++){
			k+=x[i]-'0';
			}
		cout<<k<<endl;
		k=0;
		}
 return 0;
 }



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

typedef long long ll;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)



void solve(){
    
    int n; cin >> n;
    cout << (1000 - (n % 1000)) % 1000 << '\n';
    
}


int main(){
	boost;
	int t = 1;
// 	cin >> t;
// 	precompute();
	for(int i = 1; i <= t; i++){
	   // cout << "Case #" << i << ": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define FORD(i, a, b) for (int i=a; i>(int)(b); i--)
#define PPC(x) __builtin_popcount(x)
#define MSB(x) (31 - __builtin_clz(x))
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define ithBit(m, i) ((m) >> (i) & 1)
#define ft first
#define sd second
#ifdef DEBUG
#include "debug.h"
#else
#define dbg(...) 0
#endif
using namespace std;

const int maxN = 1 << 18;

void solve()
{
	long long n, a, b;
	scanf ("%lld%lld%lld", &n, &a, &b);
	if (a == 0)
		printf("0\n");
	else if (b == 0)
		printf("%lld\n", n);
	else
		printf("%lld\n", n/(a+b)*a + min(a, n%(a+b)));
} 

 
int main()
{
    int t;
    t=1;//scanf ("%d", &t);
    while (t--)
    	solve();
    return 0;    
}


Measured memory_bytes: 256
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
H,W = map(int,input().split())
S = [input().rstrip() for _ in range(H)]

LR = [[0 for _ in range(W)] for _ in range(H)]
UD = [[0 for _ in range(W)] for _ in range(H)]

# 横方向
for h in range(H):
    cnt = 0
    for w in range(W):
        if S[h][w] == "#":
            cnt = 0
        else:
            cnt += 1
        LR[h][w] = cnt
for h in range(H):
    cnt = 0
    for w in range(W):
        if LR[h][W-1-w] == 0:
            cnt = 0
        else:
            if cnt==0:
                cnt = LR[h][W-1-w]
            else:
                LR[h][W-1-w] = cnt

# 縦方向
for w in range(W):
    cnt = 0
    for h in range(H):
        if S[h][w] == "#":
            cnt = 0
        else:
            cnt += 1
        UD[h][w] = cnt
for w in range(W):
    cnt = 0
    for h in range(H):
        if UD[H-1-h][w] == 0:
            cnt = 0
        else:
            if cnt==0:
                cnt = UD[H-1-h][w]
            else:
                UD[H-1-h][w] = cnt

ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans, LR[h][w] + UD[h][w] - 1)

print(ans)

Measured memory_bytes: 123612
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

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

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = 0 # -の個数
minus = 10**9 # 絶対値が最小の数を入れる
ans = 0

for i in range(N):
    if A[i] < 0:
        cnt += 1
        minus = min(minus, -A[i])
        ans += -A[i]
    else:
        minus = min(minus, A[i])
        ans += A[i]

if cnt % 2 == 0:
    print(ans)
else:
    print(ans - minus * 2)

Measured memory_bytes: 14252
# -*- coding: utf-8 -*-
import sys
from collections import Counter
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    n=int(input())
    a=list(map(int1,input().split()))
    index=[-1]*n
    for i,x in enumerate(a):
        if index[x]==-1:
            index[x]=i
        else:
            d=(index[x],i)
            break
    def COMinit(n,MOD):
        fac,finv,inv=[0]*max(2,n+1),[0]*max(2,n+1),[0]*max(2,n+1)
        fac[0]=fac[1]=1
        finv[0]=finv[1]=1
        inv[1]=1
        for i in range(2,(n+1)):
            fac[i]=fac[i-1]*i%MOD
            inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
            finv[i]=finv[i-1]*inv[i]%MOD
        return fac,finv,inv
    
    fac,finv,inv=COMinit(n,MOD)
    
    def COM(n, k, MOD=MOD):
        if n<k or n<0 or k<0:
            return 0
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD
    
    for i in range(1,n+2):
        ans=COM(n-1,i)
        p=COM(d[0]+n-d[1],i-1)
        q=COM(n-1,i-1)-p
        ans+=p+q*2
        ans+=COM(n-1,i-2)
        print(ans%MOD)

if __name__ == '__main__':
    main()


Measured memory_bytes: 59628
#include <iostream>
#include <string>
using namespace std;
int main() {
 int a;
 int b;
 int c;
 cin>>a;
 cin>>b;
 cin>>c;
 
 if(b-a==c-b){
 	cout<<"YES"<<endl;
 }
 else{
 	cout<<"NO"<<endl;
 }
 
 
 
 return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int a, b;
int d, r;
double f;

int main()
{
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = (double)a / (double)b;
  printf("%d %d %f\n", d, r, f);
  return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int a, b; cin >> a >> b;
    if (a <= 8 && b <= 8) puts("Yay!");
    else puts(":(");
}

Measured memory_bytes: 3608
//By Vlgd
#include<bits/stdc++.h>
using namespace std;
int A[20],n,q,x;
bool f(int m,int i){
	if(m==0) return true;
	if(i>=n) return false;
	return f(m,i+1)||f(m-A[i],i+1);
}
int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for (int i=0;i<q;i++){
		scanf("%d",&x);
		if(f(x,0)) printf("yes\n");
		else printf("no\n");
	}
}


Measured memory_bytes: 3148
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class AABD {
public:
	void solve(istream& in, ostream& out) {
        int n; in >> n;
        if(n >= 1000){
            out << "ABD" << endl;
        }else{
            out << "ABC" << endl;
        }
	}
};

int main() {
	AABD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
double p[3010],f[3010][3010];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		cin>>p[i];
	}
	f[0][0]=1;
	for (int i=1;i<=n;i++)
	{
		f[i][0]=f[i-1][0]*(1-p[i]);
		for (int j=1;j<=i;j++)
		{
			f[i][j]=f[i-1][j-1]*p[i]+f[i-1][j]*(1-p[i]);
		}
	}
	double ans=0.0;
	for (int i=0;i<=n;i++)
	{
		if (i>n-i)
		{
			ans+=f[n][i];
		}
	}
	printf("%.11lf\n",ans);
	return 0;
}


Measured memory_bytes: 69120
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int A = cin.nextint;
        int B = cin.nextint;
        var S = cin.next;
        bool flag = true;
        for (int i = 0; i < A + B + 1; i++)
        {
            if (i != A)
            {
                if (S[i] < '0' || '9' < S[i])
                {
                    flag = false;
                }
            }
            else
            {
                if (S[i] != '-')
                {
                    flag = false;
                }
            }
        }
        WriteLine(flag ? "Yes" : "No");
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    int S;
    cin >> S;
    int Left = S / 100;
    int Right = S % 100;
    if(1 <= Left && Left <= 12){
       if(1 <= Right && Right <= 12) cout << "AMBIGUOUS" << endl;
       else cout << "MMYY" << endl;
    }
    else
    {
       if(1<=Right && Right<=12) cout << "YYMM" << endl;
       else cout << "NA" << endl;
    }
}

Measured memory_bytes: 256
S = input()
rep = ["", "A"]

for i1 in range(2):
  for i2 in range(2):
    for i3 in range(2):
      for i4 in range(2):
        if rep[i1]+"KIH"+rep[i2]+"B"+rep[i3]+"R"+rep[i4] == S:
          print("YES")
          exit()

print("NO")

Measured memory_bytes: 3060
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
b.sort()
c.sort()
ans=0
for i in range(n):
  temp1=bisect.bisect_left(a,b[i])
  temp2=bisect.bisect(c,b[i])
  ans=ans+temp1*(n-temp2)
print(ans)

Measured memory_bytes: 23360
s = input()
if s[0] == '>':
  s = '<' + s
if s[-1] == '<':
  s = s + '>'
feat = []
combo = 1
n = len(s)
for i in range(1,n):
  if s[i-1] == s[i]:
    combo += 1
  else:
    feat.append(combo)
    combo = 1
feat.append(combo)
#print(feat)
m = len(feat)
ans = 0
for i in range(m):
  ans += feat[i] * (feat[i]-1) // 2
for j in range(m//2):
  ans += max( feat[2*j] , feat[2*j+1] )
print(ans)

Measured memory_bytes: 6320