akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.NoSuchElementException;

public class Main {

	ArrayList<Integer> prime;

	int N,n;

	public void solve() {
		N = nextInt();

		boolean find = false;
		n = N;
		out.print(N + ":");
		for(int i = 2;i <= N / 2;i++){
			while(n % i == 0){
				find = true;
				out.print(" " + i);
				n /= i;
			}
		}
		if(!find)out.print(" " + N);
		out.println();


	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int dp[309][309][309], A, B, C;

int main() {
	cin >> A >> B >> C;
	dp[A][B][C] = 1;
	for (int i = 0; i <= 300; i++) {
		for (int j = 0; j <= 300; j++) {
			for (int k = 0; k <= 300; k++) {
				if (dp[i][j][k] == 0) continue;
				dp[i + 1][j + 1][k] = 1;
				dp[i + 1][j][k + 1] = 1;
				dp[i][j + 1][k + 1] = 1;
				dp[i + 2][j][k] = 1;
				dp[i][j + 2][k] = 1;
				dp[i][j][k + 2] = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 0; i <= 300; i++) {
		if (dp[i][i][i] == 1) { ans = (i * 3 - A - B - C) / 2; break; }
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 114944
N = int(input())
m = a = r = c = h = 0

for k in range(N):
    S = str(input())
    if S[0] == "M":
        m+=1
    elif S[0] == "A":
        a+=1
    elif S[0] == "R":
        r+=1
    elif S[0] == "C":
        c+=1
    elif S[0] == "H":
        h+=1
print(m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h)


Measured memory_bytes: 3064
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int m, f, r;
    int s;
 
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;
 
        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}



Measured memory_bytes: 2052
#include <cstdio>  
#include <algorithm>  
#include <iostream>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
using namespace std;
#define maxn (int)1e5+500
int a[55];
long long dp[55][6000];
int main()
{
	int n,s;
	while (~scanf("%d%d", &n,&s))
	{
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &a[i]);
			a[i] -= s;
		}
		memset(dp, 0, sizeof(dp));
		dp[0][3000] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 6000; j++)
			{
				dp[i + 1][j] = dp[i][j];
				if (j - a[i] >= 0 && j - a[i] < 6000)
					dp[i + 1][j] += dp[i][j - a[i]];
			}
		cout << dp[n][3000]-1 << endl;
	}
}

Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main() {
    int row, col;
    cin >> row >> col;
    string cboard[52];
    int iboard[52][52];
    for (int i = 0; i < row; i++) {
        cin >> cboard[i];
    }
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            iboard[i][j] = 0;
        }
    }
    const int dx[8] = { -1, 0, 1, -1, 1, -1, 0, 1 };
    const int dy[8] = { -1, -1, -1, 0, 0, 1, 1, 1 };
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            if (cboard[i][j] != '#') {
                continue;
            }
            for (int d = 0; d < 8; d++) {
                if (i + dx[d] < 0 or i + dx[d] >= row) { 
                    continue;
                }
                if (j + dy[d] < 0 or j + dy[d] >= col) {
                    continue;
                }
                iboard[i + dx[d]][j + dy[d]]++;
            }
        }
    }
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            if (cboard[i][j] == '#'){
                cout << '#';
        }
            else {
                cout << iboard[i][j];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define rg register
using namespace std;
const int MAXN=1010;
int n,x,Ans,A[MAXN];
int main()
{   scanf("%d%d",&n,&x);   
	for(rg int i=1;i<=n;i++) scanf("%d",&A[i]);
	sort(A+1,A+n+1);
	for(rg int i=1;i<=n;i++)
		if(x>=A[i]) x-=A[i];
		else {   printf("%d\n",i-1);   return 0;   }
	printf("%d\n",n-(x>0));
}


Measured memory_bytes: 256
#include <stdio.h>
#define LEN 105

int main(){
  
  int n,i;
  int num[LEN];
  scanf("%d",&n);

  for(i=0;i<n;i++){scanf("%d",&num[i]);}
  for(i=n-1;i>=0;i--){
    printf("%d",num[i]);
    if(i != 0)printf(" ");
  }
  printf("\n");
  return 0;
}



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

int main(){
  int d;
  while (cin >> d) {
    int n = 600 / d;
    int ans = 0;
    for (int i = 1; i <= n - 1; i++) {
      ans += i * d * d * i * d;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3008
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
	
	public static long sum;
	public static String s;
	public static void dfs( List<String> strs, String str, int n ) {
		str += s.charAt(n);
		if( n == s.length()-1 ) {
			strs.add(str);
			for(String tmp: strs)
				sum += Long.valueOf(tmp);
			strs.clear();
		}
		else {
			List<String> strs_tmp = new ArrayList<>(strs);
			String str_tmp = str;
			strs.add(str);
			str = "";
			dfs(strs, str, n+1);
			strs = strs_tmp;
			str = str_tmp;
			dfs(strs, str, n+1);
		}
	}
	
	public static void main(String args[] ) {
		Scanner sc = new Scanner(System.in);
		
		s = sc.next();
		List<String> strs = new ArrayList<>();
		dfs(strs, "", 0 );
		System.out.println( sum );
		
		sc.close();
	}
}

Measured memory_bytes: 39356
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n;cin>>n;
  int c = 0;
  int m = n;
  while(m){
    m /= 10;
    c++;
  }
  int ans = 0;
  for(int i = 1; i < c; i += 2) {
    ans += (int)pow(10, i) - (int)pow(10, i-1);
  }
  if(c%2==1) ans += n-(int)pow(10, c-1) + 1;
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
/*|In The Name of Allah|*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pair<int,int> > vii;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef pair<int, int> pii;
#define el	'\n'
#define lp(i,n) for(int i = 0;i < int(n);i++)
#define rlp(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rng(i,a,b) for(int i = int(a);i <= int(b);i++)
#define mp(x,y)  	make_pair((x),(y))
#define pb(x)    	push_back((x))
#define all(v)  	((v).begin()),((v).end())
#define sz(x)  		((int) (x).size())
#define bits(a) 	__builtin_popcountll(a)
#define fr first
#define sc second
#define pii pair<int, int>
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define SS stringstream
#define ll long long
#define clr(x, y) memset(x, y, sizeof(x))
#define foreach(it,x) for(__typeof__((x).begin()) it = (x).begin(); it != (x).end(); ++it)
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
ll gcd(ll a, ll b){if (a == 0)return b;return gcd(b % a, a);}



void MisSiOn_ImPosSiBlE(){
//freopen("portals.in", "r", stdin);
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

}


int const N = 5e6 + 9, mod = 1e9+7 , oo = 0x3f3f3f3f;
//------------------------------------------------------------------------------------




int prefx[N];
int prefy[N];
int prefz[N];
    string str;
int main()
{

    MisSiOn_ImPosSiBlE();

    int x,y;
    cin>>x>>y;
    if (x==y){
        cout<<x+y;
    }
    else cout<< max(x,y)+(max(x,y)-1);




















/*
*/
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a, b = n.times.map { gets.split.map(&:to_i) }.transpose.map(&:sort)
puts _ = if n.odd?
  b[n / 2] - a[n / 2] + 1
else
  l = a[n/2-1] + a[n/2]
  r = b[n/2-1] + b[n/2]
  r - l + 1
end

Measured memory_bytes: 36160
a, b, c, x = map(int,[input() for i in range(4)])
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i * 500 + j * 100 + k * 50 == x:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
using namespace std;
using ll = long long;
const int MAX_N = 100000;

int cnt[MAX_N];

void init(int n)
{
    rep(i, 0, n + 1)
        cnt[i] = n;

    vector<int> numbers;
    for (int i = 1; i <= n; i *= 6)
        numbers.push_back(i);
    for (int i = 9; i <= n; i *= 9)
        numbers.push_back(i);
    
    cnt[0] = 0;
    rep(i, 1, n + 1)
    {
        for (auto num: numbers)
        {
            if (i - num >= 0)
                cnt[i] = min(cnt[i], cnt[i - num] + 1);
        }
        // cout << i << ' ' << cnt[i] << endl;
    }
}

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

    cout << cnt[n] << endl;
    return 0;
}

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

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

  while(N--){
    int t,x,y;
    scanf("%d%d%d", &t,&x,&y);

    if(t<(x+y) || (x+y+t)%2){
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

#define N 100

int main(void){
  int n, A[N];
  int i, j, min_i, cnt=0;
  
  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d", A+i);

  for(i=0; i<n-1; i++){
    min_i=i;
    for(j=i+1; j<n; j++){
      if(A[min_i]>A[j]){
	min_i=j;
      }
    }
    if(i!=min_i){
      swap(A[i], A[min_i]);
      cnt++;
    }
  }

  for(i=0; i<n; i++){
    if(i) printf(" %d", A[i]); 
    else  printf("%d", A[i]);
  }

  printf("\n%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 2712
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

# 標準入力を取得
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

# 求解処理
p = 0
q = 0
order = 1
for t in itertools.permutations(range(1, N + 1), N):
    if t == P:
        p = order
    if t == Q:
        q = order
    order += 1

ans = abs(p - q)

# 結果出力
print(ans)


Measured memory_bytes: 9140
L=[1]
s=2
for i in range(2,32):
  while True:
    s=s*i
    if s<=1000:
      L.append(s)
    else:
      s=i+1
      break
L=sorted(list(set(L)))
N=int(input())
S=[i for i in L if i<=N]
print(S[-1])

Measured memory_bytes: 9128
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <climits>
#include <unordered_map>
#include <numeric>
#include <cstring>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
int main(){
    int n;
    cin >> n;
    vector<int>x(n),y(n),h(n);
    rep(i,n){
        cin >> x[i] >> y[i] >> h[i];
    }
    rep(a,101)rep(b,101){
        int ans = 0;
        rep(i,n){
            if(h[i]){
                ans = h[i] + abs(x[i] - a) + abs(y[i] - b);
            }
        }
        bool flag = true;
        rep(i,n){
            if(h[i] != max(ans-abs(x[i]-a)-abs(y[i]-b),0))flag = false;
        }
        if(flag){
            cout << a << " " << b << " " << ans << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

void Ok() {
    cout << "Yes" << endl;
    exit(0);
}

void Ng() {
    cout << "No" << endl;
    exit(0);
}

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

    int N;
    vector<int> P;

    cin >> N;
    P.resize(N);
    rep(i, N) {
        cin >> P[i];
        P[i]--;
    }

    vector<int> l(N + 1, 0), r(N + 1, N - 1);
    rep(i, N) l[i + 1] = max(l[i], P[i]);
    for(int i = N - 1; i >= 0; i--)
        r[i] = min(r[i + 1], P[i]);

    rep(i, N - 1) if((P[i] == i) == (P[i + 1] == i + 1) && l[i + 1] != i) Ng();

    FOR(i, 1, N - 1)
    if(P[i] > i && l[i] > P[i] || P[i] < i && r[i] < P[i]) Ng();

    Ok();

    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#define int long long 
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int n;
int a[100000], b[100000];
P pa[100000];

signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, n) pa[i] = P(a[i] + b[i], i);
	sort(pa, pa + n, greater<P>());
	
	int ans = 0;
	rep(i, n) {
		int id = pa[i].second;
		if (i % 2 == 0) ans += a[id];
		else ans -= b[id];
	}
	cout << ans << endl;
	return 0;
}

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

string ss, THIS("this"), THAT("that");
int a, b, n;

bool ifincluded(string key, string trg){
    int count = 0;
    string::iterator itkey = key.begin();
    for(string::iterator it = trg.begin(); it != trg.end(); it++){
        if( *it == *itkey ){
            itkey++;
            if( itkey == key.end() ){
                return 1;
            }
        }else{
            itkey = key.begin();
            if( *it == *key.begin() ){
                itkey++;
            }
        }

    }
    return false;
}

int main(){
    cin >> n;
    getline(cin, ss);
    while( n-- > 0 ){
        getline(cin, ss);
        string cs;
        bool ok = false;
        for(a = 1; !ok && a < 26; a++){
            if( a != 1 && 26%a == 0 ) continue;
            for(b = 0; !ok && b < 26; b++){
                cs = ss;
                for(string::iterator it = cs.begin(); it != cs.end(); it++){
                    if( isalpha( *it ) ){
                        *it = ( (*it-'a') * a + b) % 26 + 'a'; 
                    }
                }
                if( ifincluded( THIS, cs ) ||
                    ifincluded( THAT, cs ) ){
                    ok = 1;
                }
            }
        }
        cout << cs << endl;
    }
    return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
int vis[200005];
int main()
{
    int n,m,i,j,a[200005];
    memset(vis,0,sizeof(vis));
    cin>>n;
    int cnt=1;
    while(1)
    {
        if(vis[n]==1)
        {
            cout<<cnt<<endl;
            break;
        }
        else vis[n]=1;
        if(n%2==0)
        {
            n=n/2;
        }
        else n=3*n+1;
        cnt++;
    }
    return 0;
}



Measured memory_bytes: 4312
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double max_n = 0;
  int ans_1 = 100*a, ans_2 = 0;
  for(int i=0; i*a*100<=f; ++i){
    for(int j=0; j*b*100<=f; ++j){
      int w = (a*i+b*j)*100;
      if(w == 0) continue;
      for(int k=0; k*c<=f-w; ++k){
        for(int l=0; l*d<=f-w; ++l){
          int s = k*c+l*d;
          if(s == 0 || w+s > f || s > (w/100)*e) continue;
          double n = 100*s*1.0/((w+s)*1.0);
          max_n = max(max_n, n);
          if(n != max_n) continue;
          ans_1 = w+s;
          ans_2 = s;
        }
      }
    }
  }
  cout << ans_1 << " " << ans_2 << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int H,W,white,cnt,dx[]={0,0,1,-1},dy[]={1,-1,0,0},i,j,x,y;
char s[55][55];
struct P{int x,y,c;}t;
queue<P>q;
int main(){
  cin>>H>>W;
  for(i=1;i<=H;i++){
    scanf("%s",s[i]+1);
    for(j=1;j<=W;j++)if(s[i][j]=='.')white++;
  }
  if(s[1][1]=='.')q.push({1,1,1});
  while(!q.empty()){
    t=q.front();q.pop();
    if(t.x==H&&t.y==W){
      cnt=t.c;
      break;
    }
    for(i=0;i<4;i++){
      x=t.x+dx[i];
      y=t.y+dy[i];
      if(s[x][y]=='.'){
        q.push({x,y,t.c+1});
        s[x][y]='#';
      }
    }
  }
  cout<<(cnt?white-cnt:-1)<<endl;
}


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

#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
typedef std::complex<int> P;

template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i] << endl;
	}
	return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last) {
			out << ",";
		}
	}
	out << "]";
	return out;
}

const int MAX_N = 1 << 19;
//?????°???????????¨???????????°??????????????????
int SIZE, dat[MAX_N], lazy[MAX_N];

//?????????
void init(int n_) {
	//?°????????????????????´???°???2???????????????
	//n_????¬???????????´???°, SIZE???????????°, 2*SIZE-1??????????´???°
	SIZE = 1;
	while (SIZE < n_) {
		SIZE *= 2;
	}
	//??????????????????0???
	for (int i = 0; i < 2 * SIZE - 1; i++) {
		dat[i] = 0;
		lazy[i] = 0;
	}
}

void lazy_evaluate(int k) {
	dat[k] += lazy[k];
	if (k < SIZE - 1) {
		lazy[k * 2 + 1] += lazy[k];
		lazy[k * 2 + 2] += lazy[k];
	}
	lazy[k] = 0;
}

void update_add_range(int a, int b, int k, int l, int r, int x) {
	if (r <= a || b <= l) {
		return;
	}
	if (a <= l && r <= b) {
		lazy[k] += x;
		lazy_evaluate(k);
	} else {
		lazy_evaluate(k);
		update_add_range(a, b, k * 2 + 1, l, (l + r) / 2, x);
		update_add_range(a, b, k * 2 + 2, (l + r) / 2, r, x);
		dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		return;
	}
}

int getSum(int a, int b, int k, int l, int r) {
	if(r<=a || b<=l){
		return 0;
	}
	if(a<=l && r<=b){
		return dat[k];
	}else{
		int vl = getSum(a, b, 2*k+1, l, (l+r)/2);
		int vr = getSum(a, b, 2*k+2, (l+r)/2, r);
		return vl + vr;
	}
}

int add(int k, int x){
	k += SIZE - 1;
	dat[k] += x;
	while(k > 0){
		k = (k - 1) / 2;
		dat[k] = dat[2*k+1] + dat[2*k+2];
	}
}



int N, Q;
void solve() {
	//ifcin("/storage/emulated/0/AppProjects/AtCoder/jni/in.txt");
	cin >> N >> Q;
	init(N);
	rep(q,0,Q)
	{
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			add(x-1, y);
		} else {
			cout << getSum(x-1, y-1+1, 0, 0, SIZE) << endl;
		}
	}
}

int main() {
	solve();
}

Measured memory_bytes: 5136
S = input()
c1 = S[0] == "A"
c2 = S[2:-1].count("C") == 1
if c1 and c2:
    cnt = 0
    for s in S:
        if s.isupper():
           cnt += 1
    if cnt == 2:
        print("AC")
    else:print("WA")
else:
    print("WA") 

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
#include<algorithm>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

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

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

int main(){
  int N,K,X,Y;
  cin >> N >> K >> X >> Y;
  if(N <= K){
    cout << N*X << endl;
  }
  else{
    cout << K*X + (N-K)*Y << endl;
  }
}

Measured memory_bytes: 256
# region
import sys

DEBUG = True if (len(sys.argv) > 1 and sys.argv[1] == "DEBUG") else False


def dp(value):
    if DEBUG:
        print(value)
    return


def input_text(split=" "):
    # 入力
    result = []
    while True:
        try:
            row = list(
                map(lambda x: int(x) if x.isdecimal() else x, input().split(split))
            )
            result.append(row)
        except EOFError:
            break
    return result


# endregion
it = input_text()

k = it[0][0]
a = it[1][0]
b = it[1][1]

n = 0
while k * n <= b:
    if a <= k * n <= b:
        print("OK")
        sys.exit()
    n += 1

print("NG")


Measured memory_bytes: 61872
#include <bits/stdc++.h>
using namespace std;
#define ri rd<int>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; --i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++i)

template<class T> T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - '0'; return f ? x : -x;
}

void TAK() {
	exit(0);
}

int ask(int p) {
	static char res[7];
	printf("%d\n", p); fflush(stdout);
	scanf("%s", res);
	if (res[0] == 'V') TAK();
	return res[0] == 'M' ? 0 : 1;
}

int dis(int x, int y) {
	assert(x<y);
	return (y - x) & 1;
}

int n;

int main() {

	n = ri();
	int l = 0, r = n-1, lc, rc;
	lc = rc = ask(0);
	while (l != r) {
		int mid = (l + r) / 2 + 1;
		int mc = ask(mid);
		if ((lc ^ dis(l, mid)) == mc) {
			l = mid;
			lc = mc;
		}
		else if ((rc ^ dis(mid, r+1)) == mc) {
			r = mid - 1;
			rc = mc;
		}
		else assert(false);
	}
	assert(false);

	return 0;
}


Measured memory_bytes: 852
#include<stdio.h>

int main()
{
	int r[200000],n,i;
	int minv,maxv;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&r[i]);
	}
	minv=r[0];
	maxv=r[1]-r[0];
	for(i=1;i<n;i++)
	{
		maxv=maxv>r[i]-minv?maxv:r[i]-minv;
		minv=minv<r[i]?minv:r[i];
	}
	printf("%d\n",maxv);
	return 0;
} 


Measured memory_bytes: 2508
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int cnt1=0,cnt2=0;
    rep(i,m){
        int a; cin>>a;
        if(a<x)cnt1++;
        else cnt2++;
    }
    cout<<min(cnt1,cnt2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<cstring>
#include<climits>
#include<algorithm>
#define ll long long int
using namespace std;
int main(){
	string s;
	cin>>s;
	bool flag=false;
	for(int i=0;i<s.size();i++){
		if(s[i]=='7'){
			flag=true;
			break;
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
//const int N=;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int a,b;
int main(){
	a=read();b=read();
	if(a%2==0||b%2==0)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	
	int N, D;
	
	cin >> N >> D;
	
	int i = 0, M = 0;
	
	for (; i < N;) {
		long long X, Y;
		cin >> X >> Y;
		if (sqrt(X*X + Y*Y) <= D){
			M++;
		}
		i++;
	}
	
	cout << M;
	
	return 0;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	ll N, B, R;
	cin >> N >> B >> R;
	ll ans = N / (B+R) * B;
	ans += min(B, N % (B+R));	
	cout << ans << endl;
}


Measured memory_bytes: 256
# B - Five Dishes

n = []
for _ in range(5):
    n.append(int(input()))

time = 0
mini = 10
for x in n:
    rest = x%10
    if rest != 0:
        mini = min(rest, mini)
    while x%10 != 0:
        x += 1
    time += x
print(time-10+mini)

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

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

int dp[21][50000 +1];
int c[21];

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

    int n, m;
    cin >> n >> m;
    REP(i,1,m+1) cin >> c[i];
    sort(c+1, c+m+1);

    REP(i,1,n+1) {
        dp[1][i] = i;
        REP(j,2,m+1) {
            dp[j][i] = dp[j-1][i];
            if (i >= c[j]) {
                dp[j][i] = min(dp[j-1][i], dp[j][i-c[j]] +1);
            }
        }
    }

    // rep(i,n+1) {
    //     rep(j,m+1) cout << dp[j][i] << " ";
    //     cout << endl;
    // }

    cout << dp[m][n] << endl;
    return 0;
}



Measured memory_bytes: 7084
#include<stdio.h>
#include<math.h>
int main(void){
    int n=0,sum=0,tmp=0;
    scanf("%d",&n);
    n = n + 2;
    int a[n];
    a[0] = 0;
    a[n-1] = 0;
    for(int i=1; i<n-1; i++){
        scanf("%d",&a[i]);
    }

    for(int i=1; i<n; i++){
        if(a[i-1] - a[i] < 0){
            sum = sum - (a[i-1] - a[i]);
        }else{
            sum = sum + (a[i-1] - a[i]);
        }
    }

    for(int i=1; i<n-1; i++){
        tmp = fabs(a[i-1] - a[i]) + fabs(a[i] - a[i+1]) - fabs(a[i-1] - a[i+1]);
        printf("%d\n",sum - tmp);
    }

    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n;
    cin>>n;
    ll a,x,ax[15][15];
    rep(i,n)rep(j,n) ax[i][j]=-1;
    rep(i,n){
        cin>>a;
        rep(j,a){
            cin>>x; x--;
            cin>>ax[i][x];
        }
    }
    ll mx=0;
    rep(i,1<<n){
        bool flag=1;
        rep(j,n){
            if(i>>j&1){
                rep(k,n){
                    if(ax[j][k]==-1) continue;
                    if(ax[j][k]!=(i>>k&1)) flag=0;
                }
            }
        }
        if(flag) mx=max(mx,(ll)__builtin_popcount(i));
    }
    cout<<mx<<endl;
    return 0;
}

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

int main()
{
	int N, Y, x, y, z;
	cin >> N >> Y;
	
	for(x=0; x<=Y/10000; x++)
	   for(y=0; y<=Y/5000; y++)
	   {
	       z = N - x - y;
           if(z>=0 && x*10000+y*5000+z*1000==Y)
           {
               cout << x << " " << y << " " << z;
               return 0;
           }
	   }
	
	cout << "-1 -1 -1";
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N, W = map(int,input().split())
    w = [0]*N
    v = [0]*N
    for i in range(N):
        w[i], v[i] = map(int, input().split())
    dp = [0]*(W+1)
    for i in range(N):
        for j in range(W, w[i]-1, -1):
            dp[j] = max(dp[j], dp[j-w[i]]+v[i])
    print(max(dp))

if __name__ == '__main__':
    main()

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main(){
    const ll INF = 1e18;
    int a, b, q; cin >> a >> b >> q;
    vll s(a+2), t(b+2);
    s[0] = t[0] = -INF;
    s[a+1] = t[b+1] = INF;
    rep(i, a) cin >> s[i+1];
    rep(i, b) cin >> t[i+1];
    while(q--){
        ll x; cin >> x;
        auto tr = lower_bound(all(t), x);
        auto sr = lower_bound(all(s), x);
        ll TR = *tr - x;
        ll SR = *sr - x;
        ll TL = x - *(--tr);
        ll SL = x - *(--sr);
        // cout << SL << " " << TL << " : " << SR << " " << TR << endl;
        ll ans = min({max(TR, SR), max(TL, SL), TR + 2*SL, 2*TR + SL, TL + 2*SR, 2*TL + SR});
        cout << ans << endl;
    }
    return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 4748
module SS = Set.Make(String)

let () =
  let n = read_int () in
  let doit (op, x) s =
    if op = "insert" then SS.add x s
    else if op = "find" then (print_endline (if SS.mem x s then "yes" else "no"); s)
    else exit 1
  in
  let rec read i s =
    if i >= n then ()
    else begin
      match Str.split (Str.regexp_string " ") (read_line ()) with
      | [] | [_] -> exit 1
      | op :: x :: _ -> read (i + 1) (doit (op, x) s)
    end
  in
  read 0 (SS.empty)

Measured memory_bytes: 36028
function Main(input){
	input = ~~input;
  input -= input%3;
  input /= 3;
  return input;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
8
`);

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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int n,m,i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

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

int n,m,a[200005],b[200005];

int main()
{
    sf(n);
    for(int i=0;i<n;i++)
    {
        sf(a[i]);sf(b[i]);
    }
    m = 0;
    for(int i=0;i<n;i++)
    {
        if(i+2<n && a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2])
        {
            m=1;
        }
    }
    if(m==1)
    {
        pf("Yes\n");
    }
    else pf("No\n");
}


Measured memory_bytes: 3692
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define REPI(i,a,b) for (ll i=(a);i<(b);i++)
#define REP(i,n) REPI(i,0,n)

typedef long long int ll;

int SURP = 1000000007;

int main(){
	ll Q,H,S,D;
	ll N;

	cin >> Q >> H >> S >> D;
	cin >> N;

	ll min1 = 0;
	ll min2 = 0;

	min1 = min(min(Q*4,H*2),S);
	min2 = min(min1*2,D);

	ll out;
	if(N%2 == 1) out = (N/2) * min2 + min1;
	else out = N/2 * min2;

	cout << out << endl;

	return 0;
}


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

//1番目の勇者は1番目の街のモンスターを全力でmin(A1,B1)体倒し、
//残った力で2番目の街のモンスターを全力でmin(A2,B1−min(A1,B1))体倒す
int main() {
  int N;
  cin >> N;
  ll A[N], B[N];
  for (int i = 0; i <= N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
  }
  ll s = 0;//合計で倒せるモンスターの最大値
  for (int i = 0; i < N; i++) {
    s += min(A[i], B[i]);
    B[i] -= min(A[i], B[i]);
    A[i] -= min(A[i], B[i]);
    s += min(A[i + 1], B[i]);
    A[i+1] -= min(A[i + 1], B[i]);
  }
  cout << s << "\n";
  return 0;
}
//解説pdfによると最大流問題に帰着できるらしい...

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define printline cerr<<__LINE__<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))


/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */

struct UnionFind{
  vector<long long> data;
  UnionFind(long long N) : data(vector<long long>(N,-1)){}
  long long root(long long x){
    if(data[x] < 0)return x;
    else return data[x] = root(data[x]);
  }
  bool same(long long x,long long y){
    return root(x) == root(y);
  }
  void unite(long long x,long long y){
    if(!same(x,y)){
      x = root(x);
      y = root(y);
      if(data[x] < data[y]){
        data[x] += data[y];
        data[y] = x;
      }
      else{
        data[y] += data[x];
        data[x] = y;
      }
    }
    return;
  }
  long long getsize(long long x){
    return -data[root(x)];
  }
};

/* main */

signed main(){
	ll N,M;
	cin >> N >> M;
	vector<vl> v(N);
	FOR(i,0,N){
		ll K;
		cin >> K;
		ll p;
		FOR(j,0,K){
			cin >> p;
			p--;
			v[i].pb(p);
		}
	}
	UnionFind UF(M);
	FOR(i,0,N){
		FOR(j,0,v[i].size()-1)UF.unite(v[i][j],v[i][j+1]);
	}
	bool ans = true;
	FOR(i,0,N-1){
		if(UF.root(v[i][0]) != UF.root(v[i+1][0]))ans = false;
	}
	YES(ans);
}

Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstring>
const int maxn = 2e5 + 10;
typedef std::pair<long long, int> PLI;

std::priority_queue<PLI> q;
int n, m, pre[maxn], nxt[maxn];
long long ans, s[maxn];
bool del[maxn];
int main() {
	std::ios::sync_with_stdio(false), std::cin.tie(0), std::cout.tie(0);
	std::cin >> n; m = n >> 1;
	for (int i = 1; i <= n; ++i) {
		std::cin >> s[i];
		q.push(std::make_pair(s[i], i));
		pre[i] = i - 1, nxt[i] = i + 1;
	}
	nxt[n + 1] = n + 1;
	for (int i = 0; i < m; ++i) {
		while (del[q.top().second]) q.pop();
		ans += q.top().first;
		if (i == m - 1) std::cout << ans << '\n';
		int p = q.top().second, l = pre[p], r = nxt[p];
		q.pop(), del[l] = del[r] = true;
		if (l > 0 && r <= n) {
			s[p] = s[l] + s[r] - s[p];
			q.push(std::make_pair(s[p], p));
			nxt[pre[p] = pre[l]] = pre[nxt[p] = nxt[r]] = p;
		} else if (l == 0) pre[nxt[r]] = 0;
		else nxt[pre[l]] = n + 1;
	}
	return 0;
}


Measured memory_bytes: 9860
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   double t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n;
    l(i,0,n)
    {
        cin>>a;
        d=d+(1.0/a);
    }
    cout<<1.0/d<<endl;
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

void No() {
	cout << "No\n";
	exit(0);
}

int main() {
	int N; cin >> N;
	vector<int> num(3);
	for (int i = 0; i < 3; ++i) { cin >> num[i]; }
	vector<string> s(N);
	for (int i = 0; i < N; ++i) { cin >> s[i]; }

	auto wl = [&](int x, int y) {
		++num[x]; --num[y];
	};

	string ABC = "ABC";
	string ans = "";
	for (int i = 0; i < N; ++i) {
		for (int v : num) { if (v < 0) { No(); } }

		int c0 = s[i][0] - 'A', c1 = s[i][1] - 'A';
		if (num[c0] == 0 && num[c1] == 0) { No(); }

		if (num[c0] != num[c1] || i == N - 1) {
			if (num[c0] > num[c1]) {
				wl(c1, c0);
				ans += ABC[c1];
			} else {
				wl(c0, c1);
				ans += ABC[c0];
			}
			continue;
		}
		
		bool add0 = false;
		for (auto c : s[i + 1]) { add0 = add0 || (c == s[i][0]); }
		if (add0) {
			wl(c0, c1);
			ans += ABC[c0];
		} else {
			wl(c1, c0);
			ans += ABC[c1];
		}
	}

	cout << "Yes\n";
	for (auto c : ans) { cout << c << endl; }

	return 0;
}


Measured memory_bytes: 6764
# Binary Indexed Tree (Fenwick Tree)
class BIT():
    """一点加算、区間取得クエリをそれぞれO(logN)で答える
    add: i番目にvalを加える
    get_sum: 区間[l, r)の和を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目にvalを加える"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)


import copy

s = input()
n = len(s)
memo = {}
for i in range(n):
    if s[i] not in memo:
        memo[s[i]] = 1
    else:
        memo[s[i]] += 1

odd_cnt = 0
for i in memo:
    odd_cnt += memo[i] % 2
if odd_cnt > 1:
    print(-1)
    exit()

left = []
right = []

memo2 = copy.deepcopy(memo)
ans_cnt = 0
word = ""
for i in range(n):
    if memo2[s[i]]*2 > memo[s[i]] + 1:
        memo2[s[i]] -= 1
        ans_cnt += i - len(left)
        left.append(s[i])
    elif memo2[s[i]]*2 == memo[s[i]] + 1:
        word = s[i]
        memo2[s[i]] -= 1
        right.append(s[i])
    else:
        memo2[s[i]] -= 1
        right.append(s[i])
 
if word != "":
    for i in range(len(right)):
        if right[i] == word:
            ans_cnt += i
            del(right[i])
            break
right = right[::-1]

memo = {}
for i in range(len(right)):
    if right[i] not in memo:
        memo[right[i]] = [i]
    else:
        memo[right[i]].append(i)
for i in memo:
    memo[i] = memo[i][::-1]

for i in range(len(left)):
    tmp = left[i]
    left[i] = memo[tmp][-1]
    del(memo[tmp][-1])

memo = {}
for i in range(len(left)):
    memo[i] = left[i]

bit = BIT(len(left))
for i in range(len(left)):
    bit.add(memo[i], 1)
    ans_cnt += bit.get_sum(memo[i] + 1, len(left))
print(ans_cnt)

Measured memory_bytes: 74700
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define INF 10000000000
#define mod 1000000007
#define X 1000000
typedef long long int ll;
ll finv[X];
ll fac[X];
ll inv[X];
ll usort(const void *a, const void *b){return *(ll*)a-*(ll*)b;}
ll dsort(const void *a, const void *b){return *(ll*)b-*(ll*)a;}
ll ssort(const void *a, const void *b){return strcmp((char*)a,(char*)b);}
ll min(ll a,ll b){
  if(a>b)return b;
  return a;
}
ll max(ll a,ll b){
  if(a>b)return a;
  return b;
}
ll z(ll a){return max(a,-a);}
ll gcd(ll a,ll b){if(!b){return a;}else{return gcd(b,a%b);}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll kt(ll a){
  ll sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
ll ks(ll a){
  ll sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
ll nCr(int n,int k){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for (int i=2;i<X;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
int main(void){
  char s[2][4]={"Yes","No"};
  int k,x;
  scanf("%d %d",&k,&x);
  PRS(s[(k*500<x)]);
  return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
a.append(1000000)
dp = [0]*(n+1)
dp[0] = 1
j = 0
if a[j] == 1:
    j += 1
else:
    dp[1] = 1

for i in range(2,n+1):
    if i == a[j]:
        j += 1
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % 1000000007
#print(dp)
print(dp[n])

Measured memory_bytes: 13500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			int r = Integer.parseInt(br.readLine());
			int g = Integer.parseInt(br.readLine());

			System.out.println(2 * g - r);
		}
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
#include<string.h>

int main(){
  int totu;
  double xa,xb,xc,xd,ya,yb,yc,yd,a,c;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",
	      &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
    totu=0;
    //ax,cx test
    if(xa-xc==0.0){
      if((xb-xa)*(xd-xa)>0) totu=1;
    }else{
      a=(ya-yc)/(xa-xc);
      c=ya-xa*a;
      if((a*xb+c-yb)*(a*xd+c-yd)>0) totu=1;
    }
    //bx,dx test
    if(xb-xd==0.0){
      if((xa-xb)*(xc-xb)>0) totu=1;
    }else{
      a=(yb-yd)/(xb-xd);
      c=yb-xb*a;
      if((a*xa+c-ya)*(a*xc+c-yc)>0) totu=1;
    }
    printf("%s\n",totu?"NO":"YES");
  }
  return 0;
}

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

using namespace std;

int main() {

	string s;
	cin >> s;
	int ans1 = 0, ans2 = 0;
	for (int i = 0; i < s.size(); i ++) {
		if (i % 2) {
			ans1 += (s[i] == '0');
			ans2 += (s[i] == '1');
		}
		else {
			ans1 += (s[i] == '1');
			ans2 += (s[i] == '0');
		}
	}
	cout << min(ans1, ans2) << '\n';
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 9999999999999999;
using ll = long long;

vector <ll> numnum(ll n){
	vector<ll> ret;
	for(ll i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}



int main(){
  ll N,M;
  cin>>N>>M;
  ll ans = 1;
  ll p = (M/N)+1;
  vector <ll> aa = numnum(M);
  sort(aa.begin(),aa.end());
  for(ll i = 0;i<aa.size();i++){
    if(p>aa[i]){
      ans = aa[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int euler_phi(int n){
    if(n==0) return 0;
    int ret = n;
    for(int i=2; i*i<=n; ++i){
        if(n%i==0){
            ret -= ret/i;
            while(n%i==0) n/=i;
        }
    }
    if(n!=1) ret -= ret/n;
    return ret;
}

const int N = 1000010;
ll a[N];

int main(){
    a[1] = 2;
    for(int i=2; i<N; ++i) a[i] = a[i-1]+euler_phi(i);

    int t;
    scanf(" %d", &t);
    while(t--){
        int n;
        scanf(" %d", &n);
        printf("%lld\n", a[n]);
    }
    return 0;
}



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

int main() {
	string n;
	cin >> n;
	string ans;
	if (n[0] == n[2]) ans = "Yes";
	else ans = "No";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3612