akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}


fn main() {
    let n: u32 = read();
    let mut money: f64 = 0.0;

    for _i in 0..n {
        let line: String = read();
        let line_vec: Vec<&str> = line.split_whitespace().collect();
        if line_vec[1] == "JPY" {
            money += line_vec[0].parse().unwrap_or(0.0);
        }else{
            money += line_vec[0].parse().unwrap_or(0.0) * 380000.0;
        }
    }

    println!("{}", money);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007; // 10^9+7
const ll INF = 10000000000;

ll book[15][15];

int main(void){
    int n,m,x;
    cin >> n >> m >> x;

    rep(i,n){
        rep(j,m+1){
            cin >> book[i][j];
        }
    }

    ll money = INF;

    for(int bit = 0; bit < (1<<n); bit++){
        vector<ll> skill(m+1,0);
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                skill[0] += book[i][0];
                rep1(j,m) skill[j] += book[i][j];
            }
        }
        bool flag = true;
        rep1(k,m){
            if(skill[k] < x){
                flag = false;
                break;
            }
        }
        if(flag) money = min(money,skill[0]);
    }

    if(money == INF) cout << -1 << endl;
    else cout << money << endl;

    return 0;
}

Measured memory_bytes: 3600
def myAnswer(D:int, N:int) -> int:
   if(D == 0):
      return 101 if(N == 100) else N
   elif(D == 1):
      return 10100 if(N == 100) else N*100
   else:
      return 1010000 if(N == 100) else N*10000
         



def modelAnswer():
   tmp=1
def main():
   D,N =map(int,input().split())
   print(myAnswer(D,N))
if __name__ == '__main__':
   main()


Measured memory_bytes: 3060
class Node
	attr_accessor :key, :right, :left, :parent
	def initialize(key, right, left, parent)
		@key = key; @right = right; @left = left; @parent = parent
	end
end

$none = Node.new(0, nil, nil, nil)
$root = $none

def treeMinimum(x)
	while x.left != $none
		x = x.left
	end
	return x
end

def find(u, k)
	while u != $none && k != u.key
		if k < u.key
			u = u.left
		else
			u = u.right
		end
	end
	return u
end

def treeSuccessor(x)
	return treeMinimum(x.right) if x.right != $none
	y = x.parent
	while y != $none && x == y.right
		x = y
		y = y.parent
	end
	return y
end

def treeDelete(z)
	if z.left == $none || z.right == $none
		y = z
	else
		y = treeSuccessor(z)
	end

	if y.left != $none
		x = y.left
	else
		x = y.right
	end

	x.parent = y.parent if x != $none

	if y.parent == $none
		$root = x
	else
		if y == y.parent.left
			y.parent.left = x
		else
			y.parent.right = x
		end
	end

	z.key = y.key if y != z
end

def insert(k)
	y = $none	
	x = $root
	z = Node.new(k, $none, $none, $none)

	#cnt = 0
	while x != $none
		#puts cnt
		#cnt += 1

		y = x
		if z.key < x.key
			x = x.left
		else
			x = x.right
		end
	end

	z.parent = y
	if y == $none
		$root = z
	else
		if z.key < y.key
			y.left = z
		else
			y.right = z
		end
	end
end

def inorder(u)
	return if u == $none
	inorder(u.left)
	printf(" %d", u.key)
	inorder(u.right)
end

def preorder(u)
	return if u == $none
	printf(" %d", u.key)
	preorder(u.left)
	preorder(u.right)
end

n = gets.to_i
0...n.times do |i|
	line = gets.split
	com = line[0]
	if com == "insert"
		insert(line[1].to_i)
	elsif com == "print"
		inorder($root)
		puts
		preorder($root)
		puts
	elsif com == "find"
		t = find($root, line[1].to_i)
		if t != $none
			puts "yes"
		else
			puts "no"
		end
	elsif com == "delete"
		treeDelete(find($root, line[1].to_i))
	end
end

Measured memory_bytes: 66236
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    C = [0] * (N + 1)
    D = [0] * (N + 1)

    for i in range(N):
        C[A[i]] += 1
        D[B[i]] += 1

    for i in range(1, N + 1):
        if C[i] + D[i] > N:
            print('No')
            return

    print('Yes')

    C = list(accumulate(C))
    D = list(accumulate(D))

    B.reverse()

    i = 0
    while i < N and A[i] != B[i]:
        i += 1

    if i == N:
        print(*B)
        return

    n = A[i]
    leftA = C[n - 1]
    rightA = C[n]
    leftB = N - D[n]
    rightB = N - D[n - 1]

    i1 = min(leftA, leftB)
    i2 = max(leftA, leftB)
    i3 = min(rightA, rightB)
    i4 = max(rightA, rightB)

    c = 0
    for i in range(i1):
        if c == i3 - i2:
            break
        B[i], B[i2 + c] = B[i2 + c], B[i]
        c += 1

    for i in range(i4, N):
        if c == i3 - i2:
            break
        B[i], B[i2 + c] = B[i2 + c], B[i]
        c += 1

    print(*B)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 133488
N, M = map(int, input().split())
p_S = [input().split() for _ in range(M)]

ans = [[0]*3 for _ in range(N)]
for ps in p_S:
  if ps[1] == "AC":
    ans[int(ps[0]) - 1][1] += 1
  elif ps[1] == "WA" and ans[int(ps[0]) - 1][1] == 0 :
    ans[int(ps[0]) - 1][2] += 1
ac = 0
pe = 0
#print(ans)

for a in ans:
  if a[1] >= 1:
    ac += 1
    pe += a[2]
print(ac, pe)

Measured memory_bytes: 42384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
  ll N,K;
  cin>>N>>K;
  
  if(K%2==0)
    cout<<(N/K)*(N/K)*(N/K)+((N+K/2)/K)*((N+K/2)/K)*((N+K/2)/K)<<endl;
  else
    cout<<(N/K)*(N/K)*(N/K)<<endl;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    int fst=0, lst=0;
    ffor(i,0,n)
    {
        string s;
        cin>>s;
        stack<int> st;
        for(auto ch:s)
        {
            if(ch=='(') st.push(1);
            else
            {
                if((!st.empty())&&st.top()==1) st.pop();
                else st.push(-1);
            }
        }
        int len=sz(st);
        int c=0;
        while((!st.empty())&&st.top()==1)
        {
            st.pop();
            c++;
        }
     //   cout<<c<<" "<<len-c<<endl;
        if(c==len) fst+=c;
        else if(c==0) lst+=len;
        else v.pb({c,len-c});
    }
    sort(all(v), [](auto a,auto b){
        return a.ff-a.ss>b.ff-b.ss;
    });

    int cnt=fst;
    if((fst==0||lst==0)&&sz(v))
    {
        cout<<"No";
        return 0;
    }
    for(auto i:v) 
    {
        if(cnt-i.ss<0)
        {
            cout<<"No";
            return 0;
        }
        cnt+=i.ff-i.ss;
        if(cnt<0)
        {
            cout<<"No";
            return 0;
        }
    }
    if(cnt==lst) cout<<"Yes";
    else cout<<"No";

    
    return 0;
}



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

const int maxn = 2e5 + 10;
int d[maxn];
void solve(long long K, long long N, std::vector<long long> A){
    A[0] = A[N] - K;

    for (int i = 1; i <= N; i++) {
        d[i-1] = A[i] - A[i-1];
    }
    sort(d, d + N);
    // for (int i = 0; i < N; i++) cout << d[i] << " "; cout << endl;
    cout << K - d[N-1]  << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N + 10);
    for(int i = 1 ; i <= N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(K, N, std::move(A));
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
#define fs first
#define se second

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;
typedef pair<ld, ld> pdd;

bool dp[101][10001];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    dp[0][0] = 1;
    int n, x;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        for (int j = 0; j <= 10000; ++j) {
            if (dp[i - 1][j]) {
                dp[i][j] = 1;
                if (j + x <= 10000) dp[i][j + x] = 1;
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= 10000; ++i) {
        if (i % 10 && dp[n][i]) {
            ans = i;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
  int R;
  cin>>R;
  if(R<1200){
    cout << "ABC"<<endl;
  }
  else if(R<2800){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }

  return 0;
}

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

int main() {
 int n;
 cin >> n;
 for (int x = n; x > 0; x--) { 
  for (int i = 1; i <= x; i++) {
    int m = i;
    for (int j = 1; j <= x; j++) {
      m *= i;
      if(x==m) {
        cout << x << endl;
        return 0;
      }
    }
  }
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
    int N, K;
    cin >> N >> K;
    vector <int> h(N);
    REP(i,N) cin >> h[i];
    int ans = 0;
    REP(i,N){
        if (h[i] >= K) ans += 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 640
//#include<bits/stdc++.h>
#include<string>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define ll long long
//#define ll unsigned long long
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-6
#define pi acos(-1)
#define mysetit set<ll>::iterator
#define mymsetit multiset<ll>::iterator
#define mymapit map<ll,ll>::iterator
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define mp make_pair
#define pb push_back
#define si size()
#define E exp(1.0)
#define fixed cout.setf(ios::fixed)
#define fixeds(x) setprecision(x)
using namespace std;
inline ll read(){ll s=0,w=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();return s*w;}
void put1(){puts("YES");}void put2(){puts("NO");}void put3(){puts("-1"); }
ll qpf(ll a,ll b,ll p){ll ret=0;while(b){if(b&1)ret=(ret+a)%p;a=(a+a)%p;b>>=1;}return ret%p;}
ll qp(ll a,ll n,ll p){ll ret=1;while(n){if(n&1)ret=qpf(ret,a,p);a=qpf(a,a,p);n>>=1;}return ret%p;}

using namespace std;
const int manx=1e6+5;

ll a[manx];
int main(){
    ll n=read(),k=read();
    for(int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+1+n);
    ll L=-1e18,R=1e18;
    while(L+1!=R){          //这里是二分答案 枚举的就是答案
        ll M=(L+R)/2,cnt=0;
        for(int i=1;i<=n;i++){
            ll l=i,r=n+1;
            if(a[i]<0){
                while(l+1!=r){  //这里是二分下标
                    ll m=(l+r)/2;
                    if(a[i]*a[m]<=M) r=m;
                    else l=m;
                }
                cnt+=n+1-r;
            }
            else{
                while(l+1!=r){
                    ll m=(l+r)/2;
                    if(a[i]*a[m]<=M) l=m;
                    else r=m;
                }
                cnt+=l-i;
            }
        }
        if(cnt<k) L=M;
        else R=M;
    }
    printf("%lld",R);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    int l = s.length();
    if (s[l-1] == 's')
        cout << s << "es" << endl;
    else 
        cout << s << "s" << endl;
    return 0;
}

//小数点精度
//cout << fixed << std::setprecision(15) << y << endl;

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int N=1e6+10;
int main()
{
	int n,m,ans=1;
	cin>>n>>m;
	int x=n;
	while(x<m)
	{
		x=x+(n-1);
		ans++;
	}
	if(m==1)
	ans=0;
	cout<<ans<<'\n';
	return 0;
}


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

#define    ll    long long int

const int N = 100005;
ll n, m;
ll ara[N];

ll gcd(ll a, ll b)
{
    ll tmp;
    while (b != 0) {
        tmp = a % b;
        a = b;
        b = tmp;
    }
    return a;
}

int main( )
{
    ll x = 1, i, j, k, l, g, fl = 1, ans;
    cin >> n >> m;
    for (i = 1; i <= n; i++) {
        cin >> j;
        j /= 2;
        ara[i] = j;
        g = gcd(j, x);
        x /= g;
        if (x * j > m) {
            fl = 0;
        }
        else {
            x = x * j;
        }
    }
    if (fl == 0) {
        cout << "0\n";
        return 0;
    }
    for (i = 1; i <= n; i++) {
        j = x / ara[i];
        if (j % 2 == 0) {
            fl = 0;
        }
    }
    j = m / x;
    ans = j / 2;
    if (j % 2 == 1) {
        ans++;
    }
    if (fl == 0) {
        ans = 0;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int z = 0; z < t; z++) {
            int n = sc.nextInt();
            PriorityQueue<long[]> lq = new PriorityQueue<>((x, y) -> Long.compare(x[0], y[0]));
            PriorityQueue<long[]> rq = new PriorityQueue<>((x, y) -> Long.compare(y[0], x[0]));
            long ans = 0L;
            for (int i = 0; i < n; i++) {
                long k = sc.nextLong();
                long l = sc.nextLong();
                long r = sc.nextLong();
                if(l < r){
                    rq.add(new long[]{k, r-l});
                    ans += l;
                }else{
                    lq.add(new long[]{k, l-r});
                    ans += r;
                }
            }
            PriorityQueue<Long> tmplq = new PriorityQueue<>();
            while(!lq.isEmpty()){
                long[] a = lq.poll();
                if(tmplq.size() < a[0]){
                    ans += a[1];
                    tmplq.add(a[1]);
                }else{
                    long tmpa = tmplq.peek();
                    if(tmpa < a[1]){
                        tmplq.poll();
                        tmplq.add(a[1]);
                        ans += a[1] - tmpa;
                    }
                }
            }
            PriorityQueue<Long> tmprq = new PriorityQueue<>();
            while(!rq.isEmpty()){
                long[] a = rq.poll();
                if(tmprq.size() < n-a[0]){
                    ans += a[1];
                    tmprq.add(a[1]);
                }else{
                    Long tmpa = tmprq.peek();
                    if(tmpa != null && tmpa < a[1]){
                        tmprq.poll();
                        tmprq.add(a[1]);
                        ans += a[1] - tmpa;
                    }
                }
            }
            sb.append(ans +"\n");
        }
        System.out.println(sb.toString());
        sc.close();

    }

}


Measured memory_bytes: 68620
n, t = map(int, input().split())
min_cost = float('inf')
for _i in range(n):
  cost, time = map(int, input().split())
  if time <= t and cost <= min_cost:
    min_cost = cost

if min_cost == float('inf'):
  print('TLE')
else:
  print(min_cost)

Measured memory_bytes: 9172
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        int s = 0;

        if(op.equals("+")){
            s = a + b;
        }else{
            s = a - b;
        }
        System.out.println(s);

    } 
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

int ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  ans = 0;

  for (int i = 1; i <= n; ++i) {
    string tmp = to_string(i);

    ans += (tmp.size() % 2 == 1) ? 1 : 0;
  }

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

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
typedef  long long ll;
ll a[maxn],sum[maxn];
const int mod = 1e9 + 7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin >> n;
    for(int i = 1;i <= n;i++) {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        sum[i] %= mod;
    }
    ll ans = 0;
    for(int i = 2;i <= n;i++){
        ans = (ans + a[i] * sum[i-1]) % mod;
    }
    cout << ans % mod<< endl;
    return 0;
}

Measured memory_bytes: 6740
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> C(N, 0);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    C[a]++;
    C[b]++;
  }
  for(int i=0; i<N; i++)
    cout << C[i] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
int main(){
  char a;
  cin >> a;
  if(isupper(a)) cout << "A" << endl;
  else cout << "a" << endl;
}

Measured memory_bytes: 3592
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

MAX = 1000000
primes = list()
for i in range(MAX):
    primes.append(True)
primes[0] = False
primes[1] = False

for i in range(2, MAX):
    j = i + i
    while j < MAX:
        primes[j] = False
        j = j + i

N = list(get_input())
for l in range(len(N)):
    n = int(N[l])
    ans = 0
    for i in range(n+1):
        if primes[i]:
            ans = ans + 1
    print(ans)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
    int i,j,k,l,r,x,y; string s;
    bool exit = false;
    ll K,N;
    vector <ll> A;
    cin>>N>>K;
    ll posI=-1;
    FOR(i,N){
        ll input;
        cin>>input;
        //A.push_back(input);
        if(input == 1){
            posI=i;
        }
    }
    cout << (N-1+K-2) / (K-1) <<endl;

    /*cin>>N;
    vector<ll> V;
    FOR(x,N+1) {
            FOR(y,N+1) {
                    ll ret=1;
                    FOR(i,x) ret*=2;
                    FOR(i,y) ret*=5;
                    V.push_back(ret);
            }
    }
    sort(ALL(V));
    FORR(v,V) cout<<v<<endl;*/
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}



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

using namespace std;

// long long helper(const vector<long long>& weight,const vector<long long>& value,const int& total_weight,int start,int cur_weight){
//     if(start==weight.size() or cur_weight>total_weight) return 0;
//     long long include = 0;
//     if(cur_weight+weight[start]<=total_weight) 
//         include = max(include,value[start]+helper(weight,value,total_weight,start+1,cur_weight+weight[start]));
//     include = max(include,helper(weight,value,total_weight,start+1,cur_weight));
//     return include;
// }


int main(){
    int n,w;
    cin>>n>>w;
    vector<long long> value(n);
    vector<long long> weight(n);
    for(int i=0;i<n;i++){
        cin>>weight[i];
        cin>>value[i];
    }
    vector<vector<long long>> dp(n+1,vector<long long>(w+1));
    for(int start=n-1;start>=0;start--){
        for(int cur_weight=w-1;cur_weight>=0;cur_weight--){
            if(cur_weight+weight[start]<=w) dp[start][cur_weight] = max(dp[start][cur_weight],value[start]+dp[start+1][cur_weight+weight[start]]);
            dp[start][cur_weight] = max(dp[start][cur_weight],dp[start+1][cur_weight]);
        }
    }
    cout<<dp[0][0];

}



Measured memory_bytes: 83172
#include <iostream>

using namespace std;
using ll = long long;

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  ll n; cin >> n;
  ll s[n]; REP(i,n) cin >> s[i];
  ll q; cin >> q;
  ll t[q]; REP(i,q) cin >> t[i];
  
  ll res = 0;
  for(ll y : t){
    for(ll x : s){
      if(x == y){
        ++res;
        break;
      }
    }
  }
  
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = Integer.parseInt(Integer.toString(a) + b);
    int i = 1;
    while (i * i <= c) i++;
    i--;
    if (i * i == c) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 23508
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
main(){
  int N;
  while(1){
    scanf("%d",&N);
    if(N==0) break;
    int o = 32;
    int a[25]={};
    for(int i=0;i<N;i++){
      scanf("%d",&a[i]);
    }
    int i=0;
    while(o>0){
      o-=((o-1)%5);
      if(o<=0) o=0;
      printf("%d\n",o);
      if(o==0) break;
      o-=a[i];
      if(o<=0) o=0;
      printf("%d\n",o);
      i=(i+1)%N;
    }
  }
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main () {
   ll n,m;
   cin>>n>>m;
   ll a[n],i;
   for(i=1;i<=n;i++){
       a[i]=m+i-1;
   }
   sort(a+1,a+n+1);
   ll s=0;
   ll mm=20000,p;
   for(i=1;i<=n;i++){
       if(abs(a[i])<mm){
           p=i;
           mm=abs(a[i]);
       }
       
   }
  
   for(i=1;i<=n;i++){
       if(i==p){
           continue;
       }
       else
       s=s+a[i];
       
   }
   
   cout<<s;
   return 0;
}


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

typedef pair<int,int> P;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x"="<<x<<endl

vector<int> construct_sa(const string& S){
  vector<int> SA, ranks, tmp;
  int N = S.length();

  SA.resize(N + 1);
  ranks.resize(N + 1);
  tmp.resize(N + 1);

  for(int i = 0; i <= N; i++){
    SA[i] = i;
    ranks[i] = (i < N ? S[i] : -1);
  }

  for(int k = 1; k <= N; k *= 2){
    auto f = [&](const int& a,const int& b){
      if(ranks[a] != ranks[b]) return ranks[a] < ranks[b];
      else{
        int ra = (a + k <= N ? ranks[a + k] : -1);
        int rb = (b + k <= N ? ranks[b + k] : -1);
        return ra < rb;
      }
    };

    sort(SA.begin(), SA.end(), f);

    tmp[SA[0]] = 0;
    for(int i = 1; i <= N; i++){
      tmp[SA[i]] = tmp[SA[i-1]] + (f(SA[i-1], SA[i]) ? 1 : 0);
    }
    for(int i = 0; i <= N; i++){
      ranks[i] = tmp[i];
    }
  }
  return SA;
}

//int main(int argc, char **argv){
int main(){
  /*if(argc < 3){
    cerr << "Few arguments." << endl;
    return 0;
  }*/


  string S;
  cin>>S;
  int N=S.size();
  vector<int> SA=construct_sa(S);

  int Q;
  cin>>Q;
  while(Q--){
    string T;
    cin>>T;
    int L=T.size();
    int l=0,r=N+1;
    rep(i,L){
      int nl,nr;

      {
        int lb=l-1,ub=r;
        while(ub-lb>1){
          int mid=(lb+ub)/2;
          if(SA[mid]+i<N&&S[SA[mid]+i]>=T[i]) ub=mid;
          else lb=mid;
        }
        nl=ub;
      }
      {
        int lb=l-1,ub=r;
        while(ub-lb>1){
          int mid=(lb+ub)/2;
          if(SA[mid]+i<N&&S[SA[mid]+i]>T[i]) ub=mid;
          else lb=mid;
        }
        nr=ub;
      }

      l=nl; r=nr;
    }

    if(l!=r)printf("1\n");
    else printf("0\n");
  }

  return 0;
}



Measured memory_bytes: 15776
#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;

const int MXN = 1e5 + 5;
int n, k;
int m[MXN][3];
int dp[MXN][4];

int x[3] = {0, 1, 2};

int Dp(int d, int lst) {
    if(d == n) return 0;
    if(dp[d][lst] != -1) return dp[d][lst];
    int ans = 0;
    for(int i = 0; i < 3; i++) {
        if(lst != x[i]) {
            ans = max(ans, Dp(d + 1, i) + m[d][i]);
        }
    }
    return dp[d][lst] = ans;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> m[i][0] >> m[i][1] >> m[i][2];
    }
    memset(dp, -1, sizeof dp);
    cout << Dp(0, 3) << endl;
    return 0;
}

Measured memory_bytes: 14152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void run(istream& in,ostream& out){
    int n;
    in>>n;
    vector<ll>V;
    for(int i=0;i<=n;i++){
        int x;in>>x;
        V.emplace_back(x);
    }
    sort(V.begin(),V.end());
    V.erase(unique(V.begin(),V.end()),end(V));
    ll small = 0;
    for(int i=1;i<=n;i++){
        small = __gcd(small , V[i]-V[i-1]);
    }
    out<<small<<endl;
}

int main()
{
    run(cin,cout);
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sR = new string(sS.Reverse().ToArray());                 // 文字列反転
            int iCnt = 0;
            for (int i = 0; i < (sS.Length) / 2; i++)
            {
                if (sS[i] != sR[i]) { iCnt += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iCnt.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13396
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        
        if(A<C & C<B){
                    System.out.println("Yes");
        }
        else if(B<C & C<A){
                    System.out.println("Yes");
        }
        else {
                    System.out.println("No");
        }      
    }
}


Measured memory_bytes: 22740
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>
typedef long long ll;
using namespace std;
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i]--;
    }
    vector<ll> sum(n + 1, 0);
    for(int i = 0; i < n; ++i) {
        sum[i + 1] = (sum[i] + a[i]) % k;
    }
    ll answer = 0;
    unordered_map<ll, ll> count;
    for(int i = 0; i <= n; ++i) {
        if(i >= k) { count[sum[i - k]]--; }
        answer += count[sum[i]];
        count[sum[i]]++;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 11592
package main

import (
	"fmt"
	"math"
)

const Mod = 1000000007

func main() {
	var N, M int

	fmt.Scan(&N, &M)

	p := Prime(M)
	n := make([]int, len(p))

	for i, v := range p {
		for M%v == 0 {
			n[i]++
			M /= v
		}
	}

	if M != 1 {
		p = append(p, M)
		n = append(n, 1)
	}

	var ret int64 = 1
	for _, v := range n {
		if v > 0 {
			ret = ret * C(int64(v+N-1), int64(v)) % Mod
		}
	}

	fmt.Println(ret)
}

func Prime(M int) []int {
	max := int(math.Pow(float64(M), 0.5)) + 1
	tmp := make([]bool, max+1)

	for i := 2; i < max+1; i++ {
		tmp[i] = true
	}

	ret := []int{}
	for i := 2; i < max; i++ {
		if tmp[i] {
			for j := i * i; j < max+1; j += i {
				tmp[j] = false
			}
		}
	}

	for i, v := range tmp {
		if v {
			ret = append(ret, i)
		}
	}

	return ret
}

func C(a, b int64) int64 {
	var ret int64 = 1
	var i int64
	for i = 1; i <= b; i++ {
		ret = (ret * (a - int64(i) + 1)) % Mod
		ret = (ret * Inv(i)) % Mod
	}

	return ret
}

func Inv(b int64) int64 {
	base := Mod - 2
	ret := int64(1)
	for base > 0 {
		if base&1 == 1 {
			ret = ret * b % Mod
		}
		b = (b * b) % Mod
		base >>= 1
	}
	return ret
}


Measured memory_bytes: 768
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll k,t;
  cin>>k>>t;
  vector<ll> v(t);
  rep(i,t) cin>>v[i];
  sort(ALL(v));
  ll ans=v[t-1];
  cout<<max((ll)0,ans-1-(k-ans))<<endl;
  
}

Measured memory_bytes: 256
import re

def solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))

    t = [0] * (N+1)
    for i in range(N):
        t[i+1] = t[i] + (1 if acgt_string[i:i+2] == "AC" else 0)

    for start, end in sub_str_ith:
        print(t[end-1] - t[start-1])

def my_solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))
    # print(sub_str_ith)

    # 全ての'A'の位置を取得
    a_iths = [m.span() for m in re.finditer('AC', acgt_string)]
    # print(a_iths)

    for start, end in sub_str_ith:
        # print(start, end)
        num = 0
        for ac_start, ac_end in a_iths:
            if ac_start >= start-1 and ac_end <= end:
                num += 1
        print(num)


solve1()
# my_solve1()

Measured memory_bytes: 21532
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

nums = list(map(int, list(input())))

cand = [(nums[0], [str(nums[0])])]

for num in nums[1:]:
    new_cand = []
    for s, signs in cand:
        new_cand.append((s + num, signs + ['+', str(num)]))
        new_cand.append((s - num, signs + ['-', str(num)]))
    cand = new_cand

for num, signs in cand:
    if num == 7:
        print(''.join(signs) + '=7')
        break


Measured memory_bytes: 7584
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char a[N];
inline int read(){
    register int x=0,f=1;
    register char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
        x=x*10+(ch^48),ch=getchar();
    return x;
}
int main(){
    scanf("%s",a);
    for(int i=1;i<4;i++){
        if(a[i]==a[i-1]){
            puts("Bad");
            return 0;
        }
    }
    puts("Good");
    return 0;
}

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

s_=''
S_=[]

if len(set(S))==1:
    ans = len(S)-1
    
else:
    for s in S:
        if s != s_:
            S_.append(s)
            s_=s

        else:
            S_[-1]+=s

    change_str_dict={'R':'L','L':'R'}
    change_str=change_str_dict[S_[1][0]]

    for m in range(1,min(2*M,len(S_)),2):
        S_[m]=change_str*len(S_[m])

    S_=''.join(S_)
    # print(S_)

    s_=S_[0]
    ans=0
    for s in S_[1:]:
        if s == s_:
            ans+=1
        else:
            s_=s

print(ans)

Measured memory_bytes: 83660
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
#include <queue>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

struct E {
  int fr, to;
  ll cost;
  E(int fr, int to, ll cost) : fr(fr), to(to), cost(cost) {}
};
typedef vector<E> V;
//typedef vector<V> G;

void add_edge(vector<V> &vg, int fr, int to, ll cost) {
  vg[fr].push_back( E(fr, to, cost) );
  vg[to].push_back( E(to, fr, cost) );
}

ll shortest_path(vector<V> &vg, int src, int dst) {
  int N = vg.size();
  vector<char> vis(N, 0);
  priority_queue<pair<ll, int> > q;
  q.push(make_pair(-0LL, src));

  while (!q.empty()) {
    ll curr_cost = -q.top().first;
    int idx = q.top().second;
    q.pop();
    if (vis[idx]) continue;
    vis[idx] = 1;

    if (idx == dst) {
      return curr_cost;
    }

    for (auto& it : vg[idx]) {
      if (vis[it.to]) continue;
      q.push(make_pair(-(curr_cost + it.cost), it.to));
    }
  }

  return -1LL; // impossible
}

int main() {
  int N, M;
  while (scanf("%d%d", &N, &M) != EOF) {
    vector<int> p(M), q(M), c(M);
    vector<map<int, int>> colors(N);

    for (int i : range(M)) {
      scanf("%d%d%d", &p[i], &q[i], &c[i]);
      p[i]--;
      q[i]--;
      colors[p[i]][c[i]] = -1;
      colors[q[i]][c[i]] = -1;
    }

    int cnt = N;
    for (int i : range(N)) {
      for (auto& pp : colors[i]) {
        pp.second = cnt++;
      }
    }

    // create graph
    vector<V> vg(cnt);
    for (int i : range(N)) {
      for (auto& pp : colors[i]) add_edge(vg, i, pp.second, 1);
    }
    for (int i : range(M)) {
      add_edge(vg, colors[p[i]][c[i]], colors[q[i]][c[i]], 0);
    }

    ll res = shortest_path(vg, 0, N - 1);
    if (res < 0) {
      puts("-1");
    } else {
      printf("%lld\n", res / 2);
    }
  }
}


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

using namespace std;

int main() {
	
	string s;
	cin>>s;
	int ans = 0;
	for (int i = 0, j = (int)s.size() - 1;i < j;++i, --j) {
		if (s[i] != s[j]) {
			ans += 1;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 1000000007

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}


const ll sz = 3000000;

ll fact[sz + 10];

ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}


ll nCr(ll n, ll r)
{
    if(r > n) return 0;

    if(n < mod)
    {
        ll z = ((power(fact[r], mod - 2, mod)) * (power(fact[n - r], mod - 2, mod))) % mod;
        return (fact[n] * z) % mod;
    }

    /// Lucas Theorem
    vector < ll > N, K;

    while(n) N.push_back(n % mod), n /= mod;

    while(r) K.push_back(r % mod), r /= mod;

    ll ret = 1;

    for(ll i = 0; i < K.size(); i++)
    {
        ret = (ret * nCr(N[i],K[i])) % mod;
    }

    return ret;
}

void precalc()
{
    fact[0] = 1;

    for(ll i = 1; i <= sz; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
    }
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    string s;

    precalc();
    while(cin >> n >> s)
    {
		ll tot = s.size() + n;

		ans = power(26,tot,mod);

		for(i = 0; i < s.size(); i++)
		{
			ans = (ans - (nCr(tot,i) * power(25,tot - i, mod))) % mod;

			ans = (ans + mod) % mod;
		}

		cout << ans << '\n';


    }

}




Measured memory_bytes: 28656
import scala.io.StdIn

object Main {
  def main(args: Array[String]): Unit = {
    val inputs = Iterator.continually(StdIn.readLine()).takeWhile(_ != null)
    for{
      in <- inputs
      val Array(a, b) = in.split(" ").map(_.toInt)
    }(a, b) match {
      case (0,  0) =>
      case (a,  b) if a <= b => println(s"$a $b")
      case (a,  b) if a > b => println(s"$b $a")
    }
  }
}

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

int main(){
  long long  x; cin>>x;
  int a=0;
  int b=0;
  for (int i=-200; i<200; i++){
    for (int j=-200; j<200; j++){
      if (pow(i,5)-pow(j,5)==x){
        a=i;
        b=j;
      }
    }
  }
  cout<<a<<" "<<b<<endl;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
#include <vector>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTG(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL((a))), (a).end());} while(0)
#define ENDL cout << endl;
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VI = vector<int>;
using VVI = vector<VI>;
using Vll = vector<ll>;
using VVll = vector<Vll>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const ll MOD = 1e9 + 7;



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, Q;
  cin >> N >> M >> Q;
  VVI table(N+1, VI(N+1, 0));
  REP(i, M)
  {
    int L, R;
    cin >> L >> R;
    L--; R--;
    table.at(0).at(R)++;
    table.at(0).at(N)--;
    table.at(L+1).at(R)--;
    table.at(L+1).at(N)++;
  }
  REP(i, N) REP(j, N-1) table.at(i).at(j+1) += table.at(i).at(j);
  REP(i, N) REP(j, N-1) table.at(j+1).at(i) += table.at(j).at(i);
  REP(i, Q)
  {
    int p, q;
    cin >> p >> q;
    p--; q--;
    cout << table.at(p).at(q) << endl;
  }

  return 0;
}

Measured memory_bytes: 1920
k = int(input())
A = list(map(int,input().split()))[::-1]

dp = [[0,0] for _ in range(k+1)]
dp[0] = [2,2]

for i in range(k):
    dp[i+1][0] = ((dp[i][0]-1)//A[i] + 1)*A[i]
    dp[i+1][1] = (dp[i][1]//A[i])*A[i] + A[i] -1
    if dp[i+1][0] > dp[i+1][1]:
        print(-1)
        exit(0)
print(' '.join(str(i) for i in dp[k]))


Measured memory_bytes: 72684
#include <bits/stdc++.h>
using namespace std;
int main () {
	std::vector<int> v(3);
	int d;
	cin >> v[0] >> v[1] >> v[2] >> d;
	if((abs(v[0]-v[1]) <= d && abs(v[1]-v[2]) <= d) || abs(v[2]-v[0]) <= d){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int main(){
	int n,m,ans=0;
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char O[50],E[50];
  scanf("%s",&O);
  scanf("%s",&E);
  for(int i = 0;i < strlen(O);i++){
    printf("%c",O[i]);
    if(i != strlen(E)){
      printf("%c",E[i]);
    }
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 1000

int N,num_query;
queue<int> Q[NUM];

int main(){

	scanf("%d %d",&N,&num_query);

	int command,A,B;

	for(int loop = 0; loop < num_query; loop++){

		scanf("%d",&command);

		switch(command){
		case 0:

			scanf("%d %d",&A,&B);
			Q[A].push(B);
			break;

		case 1:

			scanf("%d",&A);
			if(!Q[A].empty()){
				printf("%d\n",Q[A].front());
			}
			break;

		case 2:

			scanf("%d",&A);
			if(!Q[A].empty()){
				Q[A].pop();
			}
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 4356
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        m: usize,
        a: [chars; n],
        b: [chars; n],
    }
    let mut ans = 0;
    for i in 0..n {
        for j in 0..m {
            if a[i][j] != b[i][j] {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}



Measured memory_bytes: 45944
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		x--;
		p[x] = i;
	}
	vector<int> a(n), b(n);
	a[0] = 1; b[0] = (int) 1e9;
	for (int i = 0; i < n - 1; i++) {
		int x = p[i + 1] - p[i];
		if (x > 0) {
			b[i + 1] = b[i] - x;
			a[i + 1] = a[i] + x * 2;
		} else {
			a[i + 1] = a[i] - x;
			b[i + 1] = b[i] + 2 * x;
		}
	}
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << a[i];
	}
	cout << '\n';
	for (int i = 0; i < n; i++) {
		if (i > 0) cout << " ";
		cout << b[i];
	}
	cout << '\n';
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cctype>
#include <algorithm>
#define gc() getchar()
#define MAXIN 300000
//#define gc() (SS==TT&&(TT=(SS=IN)+fread(IN,1,MAXIN,stdin),SS==TT)?EOF:*SS++)
typedef long long LL;
const int N=1e6+5;

int a[N];
char IN[MAXIN],*SS=IN,*TT=IN;

inline int read()
{
	int now=0;register char c=gc();
	for(;!isdigit(c);c=gc());
	for(;isdigit(c);now=now*10+c-'0',c=gc());
	return now;
}
bool Check1(const int n)
{
	int A=0,B=0;
	for(int i=2,a1=a[1]; i<=n; ++i)
		if(a[i]==a1) ++A;
		else if(a[i]==a1-1) ++B;
		else return 0;
	return B<n-1&&(A+1>>1)+B>=a[1]&&B<a[1];
}
bool Check2(const int n)
{
	int A=0,B=0;
	for(int i=2,a1=a[1]; i<=n; ++i)
		if(a[i]==a1) ++A;
		else if(a[i]==a1+1) ++B;
		else return 0;
//	printf("2: A:%d B:%d\n",A,B);
	return B!=1&&A+(B>>1)>=a[1]&&A+(B!=0)<=a[1];
}

int main()
{
//	freopen("hat.in","r",stdin);
//	freopen("hat.out","w",stdout);

	for(int T=1; T--; )
	{
		int n=read();
		for(int i=1; i<=n; ++i) a[i]=read();
//		printf("1:%d 2:%d\n",Check1(n),Check2(n));
		puts(Check1(n)||Check2(n)?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;
int main()
{
	int n, tgt = 0, res = 0, a[100];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		tgt += a[i];
	}
	if (tgt >= 0) tgt += n / 2; else tgt -= n / 2;
	tgt /= n;
	for (int i = 0; i < n; ++i) res += (tgt - a[i])*(tgt - a[i]);
	cout << res << endl;
}


Measured memory_bytes: 256