akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define endl "\n"
#define sz(u) (int)(u.size())
#define L(x)(2*x)
#define R(x)(2*x+1)
#define M(x,y)((x+y)/2)
typedef long long ll;
typedef unsigned long long ull;
const double PI=acos(-1);
using namespace std;
void solve(){
    int a,b,h,m;
    cin>>a>>b>>h>>m;
    double ang_h=0,ang_m=0;
    ang_h=30*h+double(m)/2;
    ang_m=6*m;
    cout<<setprecision(15)<<sqrt(a*a+b*b-2*a*b*cos(double(abs(ang_h-ang_m))*PI/180));
    }
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();

}



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


int main() {
	//cout << fixed << setprecision(10);
	long long int L[200000],R[200000],q,n,cou = 0, ax = 0, num[200000] = {};
	string str;
	cin >> n>>q>>str;
	for (int i = 0; i < n-1; i++) {
		if (str.substr(i, 2) == "AC") {
			num[i + 2] = num[i+1] + 1;
		}
		else {
			num[i + 2] = num[i+1];
		}
		
	}

	for (int i = 0; i < q; i++) {
		cin >> L[i] >> R[i];
	}


	for (int i = 0; i < q; i++) {
		if (L[i] != 1 && str.substr(L[i]-2, 2) == "AC") {
			cout << num[R[i]] - num[L[i] - 1]-1 << endl;
		}
		else {
			cout << num[R[i]] - num[L[i] - 1] << endl;
		}
	}
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef pair<ll, ll>P;
typedef tuple<ll, int, int>T;
#define PI 3.14159265358979


int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll>A(N);
  rep(i,N){cin>>A[i];}
  
  rep(i,K){
    vector<ll>B(N,0ll);
    rep(j,N){
      ll l=max(0ll,j-A[j]);
      ll r=min(N-1ll,j+A[j]);
      B[l]++;
      if(r+1<N)B[r+1]--;
    } 
    for(ll j=1;j<N;j++){B[j]+=B[j-1];}
    int flag=0;
    rep(j,N){
      A[j]=B[j];
      if(A[j]!=N){flag=1;}
    }
    if(flag==0){break;}
    
  }
  rep(i,N){cout<<A[i]<<' ';}
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m) { return (a % m + m) % m; }

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
int main() {
    string s, t;
    cin >> s >> t;
    if(s.size() < t.size()) {
        return 0;
    }
    int n = s.size();
    int m = t.size();
    ll hash = 0;
    ll master = 0;
    ll k = 1;
    ll base = 114514;
    ll inv = modinv(base, MOD);
    for(int i = 0; i < m; i++) {
        master = (master + (t[i] * k)) % MOD;
        hash = (hash + (s[i] * k)) % MOD;
        k = (k * base) % MOD;
    }
    if(hash == master) {
        cout << "0" << endl;
    }
    for(int i = 1; i + m - 1 < n; i++) {
        hash = (hash - (s[i - 1]) + MOD) % MOD;
        hash = (hash + s[i + m - 1] * k) % MOD;
        hash = (hash * inv) % MOD;
        if(hash == master) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
const double PI = acos(-1);
void fft(vector<complex<double>> &A, bool invert) {
    int N = A.size();
    if (N == 1) return;
    vector<complex<double>> A0(N / 2), A1(N / 2);
    for (int i = 0; 2 * i < N; i++) {
        A0[i] = A[2 * i];
        A1[i] = A[2 * i + 1];
    }
    fft(A0, invert);
    fft(A1, invert);
    double ang = 2 * PI / N * (invert == 0 ? -1 : +1);
    double coeff = (invert == 0 ? 1 : 0.5);
    for (int i = 0; 2 * i < N; i++) {
        complex<double> W {cos(ang * i), sin(ang * i)};
        A[i] = coeff * (A0[i] + W * A1[i]);
        A[i + N / 2] = coeff * (A0[i] - W * A1[i]);
    }
}
const int P = 200003;
const int G = 2; // primitive root of P
int main() {
    int N; cin >> N;
    vector<int> A(N); for (auto &a : A) cin >> a;
    vector<int> B(P, -1), Gn(P);
    Gn[0] = 1;
    B[Gn[0]] = 0;
    for (int i = 1; i < P - 1; i++) {
        Gn[i] = Gn[i - 1] * G % P;
        B[Gn[i]] = i;
    }
    vector<int> cnt(P);
    for (auto a : A) if (a != 0) {
        cnt[B[a]] += 1;
    }
    vector<complex<double>> C(524288), D(524288);
    for (int i = 0; i < P; i++) {
        C[i] = cnt[i];
    }
    fft(C, false);
    for (int i = 0; i < C.size(); i++) {
        D[i] = C[i] * C[i];
    }
    fft(D, true);
    for (int i = 0; i < P; i++) {
        D[i * 2] -= cnt[i];
    }
    Int ans = 0;
    for (int i = 0; i < 2 * P; i++) {
        ans += Gn[i % (P-1)] * (Int)(D[i].real() / 2 + 0.5);
    }
    cout << ans << endl;
    return 0;
}


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

const int MAXN = 110;
int n, m, ex, ey;
int dp[2][MAXN][MAXN][MAXN];
int C[MAXN][MAXN], R[MAXN][MAXN];
char s[MAXN][MAXN];

inline int QR(int p, int l, int r) {
	if(l >= r) return 0;
	return R[p][r]-R[p][l];
}

inline int QC(int p, int l, int r) {
	if(l >= r) return 0;
	return C[p][r]-C[p][l];
}

inline void chkmax(int &cur, int val) {
	if(cur < val) cur = val;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++) scanf("%s", s[i]+1);
	for(int i = 1; i <= n; i++) {
		C[i][0] = 0;
		for(int j = 1; j <= m; j++) {
			C[i][j] = C[i][j-1]+(s[i][j]=='o');
			if(s[i][j] == 'E') ex = i, ey = j;
		}
	}
	for(int i = 1; i <= m; i++) {
		R[i][0] = 0;
		for(int j = 1; j <= n; j++) 
			R[i][j] = R[i][j-1]+(s[j][i]=='o');
	}

	for(int l = 0; l < ex; l++) {
		for(int d = 0; d < ey; d++) 
			for(int r = 0; r <= n-ex; r++) 
				for(int u = 0; u <= m-ey; u++) {
					int val = dp[l&1][d][r][u];
					if(l != ex-1) {
						if(ex-l-1 <= r) chkmax(dp[l&1^1][d][r][u], val);
						else {
							int lef = max(ey-d, u+1), rig = min(ey+u, m-d);
							chkmax(dp[l&1^1][d][r][u], val+QC(ex-l-1, lef-1, rig));
						}
					}
					if(d != ey-1) {
						if(ey-d-1 <= u) chkmax(dp[l&1][d+1][r][u], val);
						else {
							int lef = max(ex-l, r+1), rig = min(ex+r, n-l);
							//if(d == 0 && r == 1 && u == 1) printf("!\n");
							chkmax(dp[l&1][d+1][r][u], val+QR(ey-d-1, lef-1, rig));
						}
					}
					if(r != n-ex) {
						if(ex+r+1 > n-l) chkmax(dp[l&1][d][r+1][u], val);
						else {
							int lef = max(ey-d, u+1), rig = min(ey+u, m-d);
							//if(d == 1 && r == 0 && u == 1) printf("!!\n");
							chkmax(dp[l&1][d][r+1][u], val+QC(ex+r+1, lef-1, rig));
						}
					}
					if(u != m-ey) {
						if(ey+u+1 > m-d) chkmax(dp[l&1][d][r][u+1], val);
						else {
							int lef = max(ex-l, r+1), rig = min(ex+r, n-l);
							//if(d == 1 && r == 1 && u == 0) printf("!!!\n");
							chkmax(dp[l&1][d][r][u+1], val+QR(ey+u+1, lef-1, rig));
						}
					}
				}
		if(l == ex-1) break;
		for(int d = 0; d < ey; d++) 
			for(int r = 0; r <= n-ex; r++) 
				for(int u = 0; u <= m-ey; u++) 
					dp[l&1][d][r][u] = 0;
	}
	printf("%d\n", dp[(ex-1)&1][ey-1][n-ex][m-ey]);
	return 0;
}


Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,p[51],q=0,a1=0,a2=0;
	cin>>n;
	bool b=true;
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	} 
	for(int j=0;j<n;j++)
	{
		if(p[j]!=j+1)
		{
			q++;
			if(q==1)
			{
				a1=j;
			}
			else
			{
				if(q==2)
				{
					a2=j;
				}
				else
				{
					b=false;
					break;
				}
			}
		} 
	}
	if(b)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;	
}

Measured memory_bytes: 256
from collections import Counter

ans = int(input())
V = [int(i) for i in input().split()]

v1 = []
v2 = []

for i, v in enumerate(V):
    if i % 2 == 0:
       v1.append(v)
    else:
        v2.append(v)

v1c = Counter(v1).most_common()
v2c = Counter(v2).most_common()

k1, v1 = v1c[0][0], v1c[0][1]
k2, v2 = v2c[0][0], v2c[0][1]

if k1 == k2:
    ans -= v1
    m = 0
    if len(v1c) >= 2:
        m = max(m, v1c[1][1])
    if len(v2c) >= 2:
        m = max(m, v2c[1][1])
    ans -= m
else:
    ans -= v1 + v2

print(ans)

Measured memory_bytes: 21084
N,M,C = map(int, input().split())
B = list(map(int, input().split()))
cnt = 0

for _ in range(N):
    A = list(map(int, input().split()))
    s = C
    for j in range(M):
        s += A[j] * B[j]
    if s > 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 9180
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define ll long long
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if((a[0]==a[1]&&a[1]!=a[2])||(a[1]==a[2]&&a[0]!=a[1]))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
inf = 1000000
n = int(input())
M = [[inf for i in range(n)] for j in range(n)]
vwMtrx = []
for i in range(n):
    data = list(map(int,input().split()))
    u = data[0]
    k = data[1]
    col = []
    for j in range(0,2*k,2):
        v, w = data[j+2], data[j+3]
        M[u][v] = w
        col.append([v,w])
    vwMtrx.append(col)

def dijkstra(s):
    color = ["white" for i in range(n)]
    d = [inf for i in range(n)]
    p = [-1 for i in range(n)]
    d[s] = 0
    Q = [[s,0]]
    while Q != []:
        u = min(Q, key=lambda x:x[1])
        Q = [List for List in Q if List != u]
        u = u[0]
        color[u] = "black"

        vwList = vwMtrx[u]
        
        for vw in vwList:
            v,w = vw[0],vw[1]
            if color[v] != "black" and M[u][v] != inf:
                if d[u] + M[u][v] < d[v]:
                    d[v] = d[u] + M[u][v]
                    p[v] = u
                    color[v] = "gray"
                    Q.append([v, d[v]])

    return d

dList = dijkstra(0)
for i, d in enumerate(dList):
    print(i,d)



Measured memory_bytes: 6240
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long int a, b;
	cin >> a >> b;
	long long int ans = min(a, b / 2);
	a -= ans;
	b -= 2 * ans;
	if (b >= 4) {
		ans += b / 4;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [N, M, X, Y] = string_to_int(inputs[0])
    x = string_to_int(inputs[1])
    y = string_to_int(inputs[2])
    max_x = max(x)
    min_y = min(y)

    candidates = [x for x in range(max_x+1, min_y+1)]
    for c in candidates:
        if c > X and c <= Y:
            return "No War"
    return "War"


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(3))
    print(ret)


Measured memory_bytes: 3316
// import chie template :) {{{
import std.stdio,
       std.algorithm,
       std.array,
       std.string,
       std.math,
       std.conv,
       std.range,
       std.container,
       std.bigint,
       std.ascii;
// }}}
// tbh.scanner {{{
class Scanner {
  import std.stdio;
  import std.conv : to;
  import std.array : split;
  import std.string : chomp;

  private File file;
  private dchar[][] str;
  private uint idx;

  this(File file = stdin) {
    this.file = file;
    this.idx = 0;
  }

  private dchar[] next() {
    if (idx < str.length) {
      return str[idx++];
    }

    dchar[] s;
    while (s.length == 0) {
      s = file.readln.chomp.to!(dchar[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)() {
    return next.to!(T);
  }

  T[] nextArray(T)(uint len) {
    T[] ret = new T[len];

    foreach (ref c; ret) {
      c = next!(T);
    }

    return ret;
  }
}
// }}}


void main() {
  auto cin = new Scanner;
  int n = cin.next!int;
  int Y = cin.next!int;

  foreach (i; 0 .. n + 1) {
    foreach (j; 0 .. n + 1) {
      int k = n - i - j;
      if (n >= i + j && i * 10000 + j * 5000 + k * 1000 == Y) {
        writefln("%s %s %s", i, j, k);
        return;
      }
    }
  }
  writefln("-1 -1 -1");
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      String s = sc.next();
      if(a>=3200)System.out.println(s);
      else{
      System.out.println("red");
      }
    }
}


Measured memory_bytes: 21716
N, M, X = map(int, input().split())
BOOKS = [tuple(map(int, input().split())) for _ in range(N)]

INF = 10 ** 8
ans = INF
for selection in range(1 << N):
    price = 0
    values = [0] * M
    for i in range(N):
        if selection & (1 << i):
            x = BOOKS[i]
            price += x[0]
            for j in range(M):
                values[j] += x[j+1]
    if all(v >= X for v in values):
        ans = min(ans, price)

if ans == INF:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int x;cin>>x;
    cout<<((x<1200)?"ABC":"ARC")<<endl;
}

Measured memory_bytes: 3608
try: #ここから下でエラーを拾う
    while True:#無限ループ
        num = float(input()) #標準入力
        if num <= 48:print("light fly") #48以下なら"light fly"を出力する
        elif num <= 51:print("fly") #51以下なら"fly"を出力する
        elif num <= 54:print("bantam") #54以下なら"bantam"を出力する
        elif num <= 57:print("feather") #57以下なら"feather"を出力する
        elif num <= 60:print("light") #60以下なら"light"を出力する
        elif num <= 64:print("light welter")#64以下なら"light welter"を出力する
        elif num <= 69:print("welter") #69以下なら"welter"を出力する
        elif num <= 75:print("light middle") #75以下なら"light middle"を出力する
        elif num <= 81:print("middle") #81以下なら"middle"を出力する
        elif num <= 91:print("light heavy") #91以下なら"light heavy"を出力する  
        else:print("heavy") #それ以上なら"heavy"を出力する
except EOFError: #EOFErrorを拾う
    pass #処理なし


Measured memory_bytes: 5572
#include<stdio.h>

int main(void){
        int n;
        scanf("%d", &n);
        int a[n+1], ans[n+1];
        ans[0] = 0;
        for(int i=1; i<=n; i++) scanf("%d", &a[i]);

        for(int i=n; i>0; i--){
                int cnt = 0;
                for(int j=i+i; j<=n; j+=i){
                        cnt += ans[j];
                }
                ans[0] += ans[i] = (cnt%2!=a[i]);
        }

        printf("%d\n", ans[0]);
        for(int i=1; i<=n; i++){
                if(ans[i]) printf("%d ", i);
        }
        puts("");
        return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n) cin >> a[i];
  
  ll money = 1000, stock = 0, max_money = 1000;
  
  rep(i,n-1) {
    if (a[i] < a[i+1]) {
      stock += money / a[i];
      money %= a[i];
    }
    if (a[i] > a[i+1]) {
      money += a[i] * stock;
      stock = 0;
    }
    if (i==n-2) {
      money += stock * a[i+1];
      stock = 0;
    }
    max_money = max(money, max_money);
  }
  
  cout << max_money << endl;
}

Measured memory_bytes: 3624
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


n = int(input())
arr = L()
answer = 0
for i in range(1, n):
    if arr[i] < arr[i-1]:
        answer += arr[i-1]-arr[i]
        arr[i] = arr[i-1]
out(answer)


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define _P(...) (void)fprintf(stderr, __VA_ARGS__)

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	int n;
	cin >> n;
	
	vector<ll> a(2000);
	a[0]=2; a[1]=1; a[2] = 3; a[3] = 4;
	if(n <=3) {cout << a[n] <<"\n"; return 0;}
	rep2(i, 2, n+5){
		a[i] = a[i-2] + a[i-1];
	}
	cout << a[n] <<"\n";
	return 0;
}

Measured memory_bytes: 384
n , k = map(int,input().split())
ab = []
for i in range(n):
    ab.append(list(map(int,input().split())))

ab.sort(key=lambda x:x[0])
i = 0
count = 0
while count < k:
    p = ab[i][0]
    count += ab[i][1]
    i += 1
print(p)

Measured memory_bytes: 64600
#include<stdio.h>

int nextInt();

int f(int N){return N&1?N*3+1:N>>1;}

int A, i;
char is[100000000];

int main(){
	A=nextInt();
	while(!is[A]){
		is[A]=1;
		A=f(A);
		i++;
	}
	printf("%d\n", i+1);
	return 0;
}

int nextInt(){
	int f=0; char c=getchar();
	while((c<'0')||('9'<c)){c=getchar();}
	while((c>='0')&&(c<='9')){f=f*10+(c-'0'); c=getchar();}
	return f;
}


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

int main() {
    int ans = 0;
    int N;
    cin >> N;
    vector<char> c(N);
    for (int i = 0; i < N; i++) {
        cin >> c[i];
    }

    vector<char> d = c;

    sort(d.begin(),d.end());
    for (int i = 0; i < N; i++)  {
        ans += c[i]!=d[i];
    }
    cout << ans/2 << endl;
    return 0;
}


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

int read()
{
	int ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10+ch-'0';
	if(flag)ans=-ans;
	return ans;
}

long long rell()
{
	long long ans=0;
	char ch=getchar();
	for(;(ch<'0' || ch>'9') && ch!='-';ch=getchar());
	bool flag=0;
	if(ch=='-')flag=1,ch=getchar();
	for(;ch>='0' && ch<='9';ch=getchar())ans=ans*10ll+(long long)(ch-'0');
	if(flag)ans=-ans;
	return ans;
}

void writ(int n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}

void wrll(long long n)
{
	char ch[25];
	int m=0;
	if(n<0)putchar('-'),n=-n;
	if(n==0)
	{
		putchar('0');
		return;
	}
	for(;n;n/=10ll)ch[m++]=n%10ll+'0';
	for(;m;)putchar(ch[--m]);
}
const int N=16;
int g[N][N],sum[1<<N],dp[N][1<<N];

int main()
{
	int n=read(),m=read(),gsum=0;
	memset(g,0,sizeof(g));
	for(int i=0;i<m;i++)
	{
		int u=read()-1,v=read()-1;
		g[u][v]=g[v][u]=read();
		gsum+=g[u][v];
	}
	sum[0]=0;
	for(int i=1;i<(1<<n);i++)
	{
		int j=0;
		for(;!(i&(1<<j));j++);
		sum[i]=sum[i-(1<<j)];
		for(int k=j+1;k<n;k++)if(i&(1<<k))
		{
			sum[i]+=g[j][k];
		}
		//printf("i=%d sum[i]=%d\n",i,sum[i]);
	}
	memset(dp,192,sizeof(dp));
	//printf("%d %d\n",dp[0][0],dp[0][0]*2);
	dp[0][1]=0;
	for(int i=1;i<(1<<n);i++)
	{
		for(int j=0;j<n;j++)if(i&(1<<j))
		{
			int I=i-(1<<j);
			for(int k=I;k;k=(k-1)&I)
			{
				//printf("k=%d ",k);
				dp[j][i]=max(dp[j][i],dp[j][i-k]+sum[k+(1<<j)]);
			}
			for(int k=0;k<n;k++)if(I&(1<<k) && g[j][k])
			{
				//printf("kk=%d ",k);
				dp[j][i]=max(dp[j][i],dp[k][I]+g[j][k]);
			}
			//printf("i=%d j=%d dp[j][i]=%d\n",i,j,dp[j][i]);
		}
	}
	writ(gsum-dp[n-1][(1<<n)-1]);
	puts("");
	return 0;
}


Measured memory_bytes: 4608
x,y = map(int,input().split())
ans = abs(abs(x)-abs(y))
if x > 0 and y > 0:
    if x > y:
        ans += 2
elif x > 0 and y < 0:
    ans += 1
elif x < 0 and y > 0:
    ans += 1
elif x < 0 and y < 0:
    if x > y:
        ans += 2
else:
    if x > y:
        ans += 1
print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] I = new int [101];
		for(int i =0;i<N;i++){
			int n = s.nextInt();
			I[n] += 1;
		}
		for(int j=100;j>0;j--){
			if(I[j]>=j){
				System.out.println(j);
				break;
			}else{
				I[j-1] += I[j];
			}
		}
		
	}
}

Measured memory_bytes: 26212
#include<stdio.h>
#include<algorithm>
int i,j;
int gou[6000000];
using namespace std;
int main(void){
	int n,m;
	int data[1001];
	scanf("%d %d",&n,&m);
	while(n!=0 && m!=0){
		for(i=0;i<n;i++){
			scanf("%d",&data[i]);
		}
		data[n]=0;
		sort(data,data+n+1);
		/*for(i=0;i<=n;i++){
			printf("%d \n",data[i]);
		}*/
		int cnt=0;
		for(i=0;i<=n;i++){
			for(j=i;j<=n;j++){
				gou[cnt]=data[i]+data[j];
				cnt++;
			}
		}
		sort(gou,gou+cnt);
		/*for(i=0;i<cnt;i++){
			printf("%d ",gou[i]);
		}
		printf("\n");*/
		//
		int max=0;
		for(i=0;i<cnt;i++){
			int syou=0,dai=cnt,sach;
			sach=m-gou[i];
			while(dai>=syou){
				int b;
				b=(dai+syou)/2;
				if(sach==gou[b]){
					max=m;
					break;
				}
				else if(sach>gou[b]){
					syou=b+1;
				}
				else if(sach<gou[b]){
					dai=b-1;
				}
			}
			if(max<gou[dai]+gou[i] && m>=gou[dai]+gou[i]){
				max=gou[dai]+gou[i];
			}
		}
		printf("%d\n",max);
		scanf("%d %d",&n,&m);
	}
	return 0;
}

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

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

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

    int N;
    cin >> N;
    vector<int> L(N), R(N);
    rep(i, N) {
        cin >> L[i] >> R[i];
        L[i] *= 2;
        R[i] *= -2;
    }
    sort(ALL(L), greater<int>());
    sort(ALL(R), greater<int>());
    vector<ll> sumL(N + 1), sumR(N + 1);
    rep(i, N) {
        sumL[i + 1] = sumL[i] + L[i];
        sumR[i + 1] = sumR[i] + R[i];
    }
    ll ans = 0;
    FOR(i, 1, N + 1) {
        chmax(ans, sumL[i] + sumR[i]);
        chmax(ans, sumL[i] + sumR[i - 1]);
        chmax(ans, sumL[i - 1] + sumR[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
cin.tie(NULL);
	ll n,m,id=0,i,j;
	cin>>n>>m;
	pair<ll,ll> p[m];
	ll a[n];
	for(i=0;i<n;i++)
	cin>>a[i];
	for(i=0;i<m;i++)
	cin>>p[i].second>>p[i].first;
	sort(p,p+m);
	sort(a,a+n);
	for(i=m-1;i>=0;i--)
	{
		
		for(j=0;j<p[i].second;j++)
		{
			if(id>=n)
			break;
			if(a[id]<p[i].first)
			{
				a[id]=p[i].first;
				id++;
			}
			else
			break;
		}
		if(id>=n)
		break;
	}
	ll sum=0;
	for(i=0;i<n;i++)
	sum+=a[i];
	cout<<sum;
}


Measured memory_bytes: 3840
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_set>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::unordered_set<char> fixedChars;
    for (std::size_t i = 0; i < s.size(); ++i) {
        char c1 = s[i];
        char c2 = t[i];

        if (s[i] != t[i]) {
            if (fixedChars.count(c2) != 0 || fixedChars.count(c1) != 0) {
                std::cout << "No" << std::endl;
                return 0;
            }

            std::replace(s.begin(), s.end(), c1, '_');
            std::replace(s.begin(), s.end(), c2, c1);
            std::replace(s.begin(), s.end(), '_', c2);

            fixedChars.insert(c2);
        } else {
            fixedChars.insert(c1);
        }
    }

    std::cout << "Yes" << std::endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p.at(i);
    int ans = 0;
    int current_min = p.at(0); //1e09
    for (int i = 0; i < n; i++) {
        current_min = min(current_min, p.at(i));
        if (current_min == p.at(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0
 
for i in range(A+1):
    if 500*i > X:
        break
    for j in range(B+1):
        if 500*i + 100*j > X:
            break
        for k in range(C+1):
            if 500*i+100*j+50*k == X:
                count += 1
            elif 500*i+100*j+50*k > X:
                break
            
print(count)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Numerics;

class Class3
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());


        bool zoromeFlg = false;
        int zoromeCnt = 0;
        for(int i = 1; i <= N; i++)
        {
            string[] values = Console.ReadLine().Split(" ");

            if (values[0].Equals(values[1]))
            {
                zoromeCnt++;
            } else
            {
                zoromeCnt = 0;
            }

            if (zoromeCnt == 3)
            {
                zoromeFlg = true;
            }
            

        }

        if (zoromeFlg)
        {
            Console.WriteLine("Yes");
        } else
        {
            Console.WriteLine("No");
        }




    }
}

Measured memory_bytes: 27528
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

struct edge {
    int time, x, y;
};

int main(){
    int N,Y; cin >> N >> Y;
    for (int i = 0; i <= 20000; i++){
        for (int j = 0; j <= 5000; j++){
            int k = N-i-j;
            if (k < 0){
                continue;
            }
            if (10000*k + 5000*j + 1000*i == Y){
                cout << k << " " << j << " " << i << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

vector<tuple<int, int, int> > v;

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

    ll X, K;
    std::cin >> X >> K;

    for(int i=0;i<K;++i){
        int r;
        std::cin >> r;

        v.emplace_back(r, 2, -1);
    }

    int Q;
    std::cin >> Q;

    for(int i=0;i<Q;++i){
        int t, a;
        std::cin >> t >> a;

        v.emplace_back(t, 1, a);
    }

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

    // 今 max{lb, min{ub, x + s}}
    ll lb = 0, ub = X, s = 0;
    int lastTime = 0, sgn = -1;
    for(const auto& p : v){
        int t, qt, a;
        tie(t, qt, a) = p;

        int passedTime = t - lastTime;
        if(qt == 1){
            ll x = max(lb, min<ll>(ub, a + s));
            x = max(0ll, min<ll>(X, x + sgn * passedTime));
            std::cout << x << std::endl;
        }else{
            lb = max(0ll, min<ll>(X, lb + sgn * passedTime));
            ub = max(0ll, min<ll>(X, ub + sgn * passedTime));
            s += sgn * passedTime;

            sgn *= -1;
            lastTime = t;
        }
    }
}


Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
#define int1 long long
int main() {
    int1 n, w;
    cin >> n >> w;
    int1 arr[n][2];
    int1 i, j;
    for (i = 0; i < n; i++) {
        cin >> arr[i][0] >> arr[i][1];
    }
    int1 dp[n][w + 2];
    for (i = 0; i < n; i++) {
        for (j = 0; j <= w; j++) {

            dp[i][j]=0;
        }
    }
    for (i = 0; i < n; i++) {
        dp[i][0] = 0;
    }
    for (i = 0; i <= w; i++) {
        dp[0][w] = 0;
    }
    dp[0][arr[0][0]] = arr[0][1];
    for (i = 1; i < n; i++) {
        for (j = 0; j <= w; j++) {
            int1 a1 = 0;
            int1 a2 = dp[i - 1][j];
            if (j - arr[i][0] >= 0) {
              //  cout<<arr[i][0]<<" ";
                a1 = arr[i][1] + dp[i - 1][j - arr[i][0]];
            }
            dp[i][j] = max(a1, a2);
        }
        //cout<<endl;
    }

    int1 m = 0;
    for (i = 0; i <= w; i++) {
        if (m < dp[n - 1][i]) {
            m = dp[n - 1][i];
        }
    }
    cout << m;
    return 0;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    ft
    int i,n,m,l,r;
    cin>>n>>m;
    l=n*2;
    r=n*4;
    if(m%2==0 && m>=l && m<=r)
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <string.h>
 
int main(void){
  char s[1001], order[8], ch[1001];
  int i, j, n, a, b;
 
  scanf("%s\n%d", s, &n);
 
  for(i=0;i<n;i++){
    scanf("%s %d %d", order, &a, &b);
     
    if(!strcmp(order, "reverse")){
      for(j=a;j<=b;j++)
        ch[b-j] = s[j];
      for(j=a;j<=b;j++)
        s[j] = ch[j-a];
    }
 
    if(!strcmp(order, "replace")){
      scanf("%s", ch);
      for(j=0;ch[j]!='\0';j++)
        s[a+j] = ch[j];
    }
 
    if(!strcmp(order, "print")){
      for(j=a;j<=b;j++)
        printf("%c", s[j]);
      printf("\n");
    }
  }
 
  return 0;
}


Measured memory_bytes: 2132
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, x;
int y;

signed main() {
	cin >> n >> x;
	y = gcd(n, x);
	cout << (n - y) * 3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll MAX=100004;
const ll MOD=998244353;
struct mgraph{
    ll r1,r2,v;
};
vector<ll> r;
ll t,a,X,K,Q;
mgraph c[MAX];
main(){
    scanf("%lld%lld",&X,&K);
    r.push_back(0);
    for(int i=1;i<=K;i++) {
        ll tmp;
        scanf("%lld",&tmp);
        r.push_back(tmp);
    }
    c[0]={0,X,0};
    for(int i=1;i<=K;i++){
        ll td=r[i]-r[i-1];
        if(i%2){
            c[i].v=max(c[i-1].v-td,0ll);
            c[i].r1=min(c[i-1].r2,max(td-c[i-1].v,0ll)+c[i-1].r1);
            c[i].r2=c[i-1].r2;
        }
        else{
            c[i].v=min(c[i-1].v+td,X);
            c[i].r1=c[i-1].r1;
            c[i].r2=max(c[i-1].r1,-max(td-(X-(c[i-1].v+c[i-1].r2-c[i-1].r1)),0ll)+c[i-1].r2);
        }
    }
    scanf("%lld",&Q);
    for(int j=0;j<Q;j++){
        mgraph tmp;
        vector<ll>::iterator low;
        scanf("%lld%lld",&t,&a);
        low=upper_bound(r.begin(),r.end(),t);
        ll td=t-*(low-1),i=low-r.begin();
        //printf("%lld %lld %lld\n",c[i-1].v,c[i-1].r1,c[i-1].r2);
        if(i%2){
            tmp.v=max(c[i-1].v-td,0ll);
            tmp.r1=min(c[i-1].r2,max(td-c[i-1].v,0ll)+c[i-1].r1);
            tmp.r2=c[i-1].r2;
        }
        else{
            tmp.v=min(c[i-1].v+td,X);
            tmp.r1=c[i-1].r1;
            tmp.r2=max(c[i-1].r1,-max(td-(X-(c[i-1].v+c[i-1].r2-c[i-1].r1)),0ll)+c[i-1].r2);
        }
        //printf("%lld %lld %lld\n",tmp.v,tmp.r1,tmp.r2);
        if(a<tmp.r1) printf("%lld\n",tmp.v);
        else if(a>tmp.r2) printf("%lld\n",tmp.v+tmp.r2-tmp.r1);
        else printf("%lld\n",tmp.v+a-tmp.r1);
    }
}


Measured memory_bytes: 4468
#include <iostream>

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a > b && a > c){
        cout << "A\n";
    }else if(b > c){
        cout << "B\n";
    }else{
        cout << "C\n";
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

int main(){
  string a,b;
  cin >> n;
  cin >> s >> t;
  m = 2 * n;
  rep(i,0,n){
    a = b = "";
    rep(j,n-i -1,n)a += s[j];
    lep(j,0,i)b += t[j];
    //cout << a << " " << b << endl;
    if(a == b)m = 2 * n - (i + 1);
  }
  print(m);
  return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    
    int m,f,r;
    while (cin >> m >> f >> r){
        if(m == -1 && f == -1 && r == -1) break;
        else if(m == -1 || f == -1 || m+f < 30) cout << "F" << endl;
        else if(m+f >= 80) cout << "A" << endl;
        else if(m+f >= 65) cout << "B" << endl;
        else if(m+f < 50 && r < 50) cout << "D" << endl;
        else cout << "C" << endl;
    }
}



Measured memory_bytes: 3116
function Main(input) {
    var n = input.split(" ")[0];
    var a = input.split(" ")[1];
    var b = input.split(" ")[2];
    var answer = 0;

    for(var i = 1; i <= n; i++ ) {
        var v = Math.floor(i/10000);
        var w = Math.floor(i % 10000 / 1000);
        var x = Math.floor(i % 1000 / 100);
        var y = Math.floor(i % 100 / 10);
        var z = i % 10;
        // if (v >= 10) {
        //     v = 0;
        // }
        // if (w >= 10) {
        //     w = 0;
        // }
        // if (x >= 10) {
        //     x = 0;
        // }
        // if (y >= 10) {
        //     y = 0;
        // }
        // if (z >= 10) {
        //     z = 0;
        // }


        if (v + w + x + y + z >= a && v + w + x + y + z <= b) {
            answer = answer + 10000*v + 1000*w + 100*x + 10*y + z;
        }
    }

    console.log(answer)
  
    }
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  

Measured memory_bytes: 7628
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string op;
    cin >> op;
    int g = 0, p = 0, ans = 0;
    for(int i = 0; i < op.size(); i++)
    {
        if(g <= p)
        {
            g++;
            if(op[i] == 'g')
            {
                ;
            }
            else
            {
                ans--;
            }
            
        }
        else
        {
            if(op[i] == 'g')
            {
                p++;
                ans++;
            }
            if(op[i] == 'p')
            {
                p++;
            }
        }
        
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 512
n,k,q=map(int,input().split())
l=list(map(int,input().split()))
ans=10**10
for i in range(n):
    x=l[i]
    tmp=[]
    z=[]
    for j in range(n):
        if l[j]>=x:
            tmp.append(l[j])
        if l[j]<x or j==n-1:
            tmp.sort()
            if len(tmp)-k+1>0:
                z+=tmp[:len(tmp)-k+1]
            tmp=[]
    z.sort()
    if len(z)>=q:
        ans=min(ans,z[q-1]-x)
print(ans)

Measured memory_bytes: 9436
#include <stdio.h>
int main(){
 
  int a,b,i,d;
 
  while(1){
  scanf("%d %d",&a,&b);
if(a==0 && b==0)break;
 
  for(i=0;i<a;i++){

    for(d=0;d<b;d++)
{
    printf("#");
  } 
  printf("\n");
 
  
  }
  printf("\n");
  }
  
 
  return 0;
  }



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

int main(){
    char moji[101];
    int cnt=0;
    int i=0;
    int length;

    while((moji[i] = getchar()) != EOF){
        i++;
    }

    length = i-1;

    for(int j=0; j<length/2; j++){
        if(moji[j] != moji[length-1-j]){
            cnt += 1;
        }
    }

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

    return 0;
}

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

using namespace std;

double a[101];

int main()
{
    int n, m;
    double sum = 0;
    cin >> n >> m;
    for(int i = 1; i <= n; i ++) {
        cin >> a[i];
        sum += a[i];
    }
    sum /= 4.0*m;
    sort(a + 1 , a + n + 1);
    for(int i = n; i >= n - m + 1; i --) {
        if(a[i] < sum) {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
import bisect
n = int(input())
ls = list(map(int,input().split()))
ls = sorted(ls)
ans = 0
for i in range(n):
    for j in range(i+1,n):
        k = bisect.bisect_left(ls,ls[i]+ls[j])
        ans += k-j-1
print(ans)

Measured memory_bytes: 9296
#include<iostream>
#include<cmath>
#include<vector>
#include<cstring>
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int q[101];
    int ans = 0;
    for(int i = 0; i < 100; i++) {
        q[i] = a*(i+1) % b;
        if(q[i] == c) ans++;
    }

    if(ans > 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> a(n);
    int32 sum = 0;
    REP(i,n){
        cin >> a[i];
        sum += a[i];
    }
    int32 dif = INF;
    int32 res = -1;
    REP(i,n){
        if(abs(a[i] * n - sum) < dif){
            dif = abs(a[i] * n - sum);
            res = i;
        }
    }
    cout << res << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
    string s;

    cin >>  s;
    
    for(int i=0; i < s.length(); i++) {
        if(i%2==0) {
            if(s[i] == 'L') {
                cout << "No";
                return 0;
            }
        }
        else {
            if(s[i] == 'R') {
                cout << "No";
                return 0;
            }
        }
    }

    cout << "Yes";
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int a,b,s,m,p,max;
  scanf("%d %d",&a,&b);
  
  s=a+b;
  m=a-b;
  p=a*b;
  max=s;
  
  if(m>s){
    max=m;
  }if(p>max){
    max=p;
  }
  
  printf("%d\n",max);
  
  return 0;
}

Measured memory_bytes: 128
//ABC128A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int a, p;
	cin >> a >> p;
	cout << (a*3+p)/2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int L[100000],R[100000],L1[100000],R1[100000],X[100000],Y[100000],F[100000];

int part(int p, int r) {
  int i=p-1,j,temp;
  for (j=p;j<r;j++) {
    if (L1[j] <= L1[r]) {
      i++;
      temp=L1[i];
      L1[i]=L1[j];
      L1[j]=temp;
      temp=X[i];
      X[i]=X[j];
      X[j]=temp;
    }
  }
  temp=L1[i+1];
  L1[i+1]=L1[r];
  L1[r]=temp;
  temp=X[i+1];
  X[i+1]=X[r];
  X[r]=temp;
  return i+1;
}

void qsort(int p,int r){
  if (p < r) {
    int q=part(p,r);
    qsort(p,q-1);
    qsort(q+1,r);
  }
}

int part2(int p, int r) {
  int i=p-1,j,temp;
  for (j=p;j<r;j++) {
    if (R1[j] <= R1[r]) {
      i++;
      temp=R1[i];
      R1[i]=R1[j];
      R1[j]=temp;
      temp=Y[i];
      Y[i]=Y[j];
      Y[j]=temp;
    }
  }
  temp=R1[i+1];
  R1[i+1]=R1[r];
  R1[r]=temp;
  temp=Y[i+1];
  Y[i+1]=Y[r];
  Y[r]=temp;
  return i+1;
}

void qsort2(int p,int r){
  if (p < r) {
    int q=part2(p,r);
    qsort2(p,q-1);
    qsort2(q+1,r);
  }
}

int main(){
  int i,N,l,r,x;
  long long K,K2;
  cin >> N;
  for (i=0;i<N;++i) {
    cin >> L[i] >> R[i];
    L1[i]=L[i];
    R1[i]=R[i];
    X[i]=i;
    Y[i]=i;
    F[i]=0;
  }
  qsort(0,N-1);
  qsort2(0,N-1);
  l=N-1;
  r=0;
  K=0;
  x=0;
  for (i=0;i<N;++i) {
    while (F[Y[r]]==1) {
      r++;
    }
    if (R1[r] < x) {
      K+=abs(x-R1[r]);
      x=R1[r];
    } else {
      break;
    }
    F[Y[r]]=1;
    r++;
    ++i;
    if (i==N) {
      break;
    }
    while (F[X[l]]==1) {
      l--;
    }
    if (L1[l] > x) {
      K+=abs(x-L1[l]);
      x=L1[l];
    } else {
      break;
    }
    F[X[l]]=1;
    l--;
  }
  K+=abs(x);

  l=N-1;
  r=0;
  K2=0;
  x=0;
  for (i=0;i<N;++i) {
    while (F[X[l]]==2) {
      l--;
    }
    if (L1[l] > x) {
      K2+=abs(x-L1[l]);
      x=L1[l];
    } else {
      break;
    }
    F[X[l]]=2;
    l--;
    ++i;
    if (i==N) {
      break;
    }
    while (F[Y[r]]==2) {
      r++;
    }
    if (R1[r] < x) {
      K2+=abs(x-R1[r]);
      x=R1[r];
    } else {
      break;
    }
    F[Y[r]]=2;
    r++;
  }
  K2+=abs(x);
  if (K>K2) {
    cout << K << endl;
  } else {
    cout << K2 << endl;
  }
  return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<fstream>
#include <cmath>
#include <algorithm>
#include <stack>
#include <vector>
#include <random>
#include <set>
using namespace std;
typedef long long ll;


int main(){
	ll n,s,m=998244353,ans=0;
	cin >> n >> s;
	vector<ll> a(n),dp(3001,0),t(3001,0);
	for(auto &&x:a)cin >> x;
	for(auto &&x:a){
		fill(t.begin(), t.end(),0LL);
		for(int i=0;i<3001;i++){
			( t[i] += dp[i] ) %= m;
			if(i+x<=3000)( t[i+x] += dp[i] ) %= m;
		}
		t[0]++;
		t[x]++;
		dp = t;
		( ans += dp[s] ) %= m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<vector>
#include<cmath>
using namespace std;
const int M =1e6+5;
char s[M];
int main() {
    scanf("%s",s);
    int n=strlen(s);
    int pre=-1;
    int ans=0;
    for(int j=0;j<n;j++){
        if(s[j]=='A'&&pre==-1) pre=j;
        if(s[j]=='Z'){
            if(~pre) ans=j-pre+1;
        }
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384