akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

#ifdef _DEBUG
template <class Head>
void dump(const char* str, Head &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + 1, t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	int gx, gy; // goal
	cin >> gx >> gy;

	int axis = 0, cnt = 0; // axis = 0 -> x, = 1 -> y;

	vector<vector<int>> pos(2, vector<int>(2 * 8000 + 1));
	pos[0][8000] = 1, pos[1][8000] = 1;

	// 番兵
	s += 'T';
	bool firstT = true;
	for (int i = 0; i < s.size(); i++) {

		if(s[i] == 'T'){

			if (firstT) {
				assert(axis == 0);
				pos[axis][8000] = 0;
				pos[axis][8000 + cnt] = 1;
				firstT = false;
			}
			else {
				for (int j = 0; j <= 2 * 8000; j++) {
					if (pos[axis][j] > 0) {
						
						int id = 2 * i;

						if (pos[axis][j] < id) {
							pos[axis][j] = 0;
							pos[axis][j - cnt] = id;
							if (pos[axis][j + cnt] == 0) pos[axis][j + cnt] = id;
							else pos[axis][j + cnt] = id + 1;
						}
						if (pos[axis][j] > id) {
							pos[axis][j] = id;
							pos[axis][j - cnt] = id;
							if (pos[axis][j + cnt] == 0) pos[axis][j + cnt] = id;
							else pos[axis][j + cnt] = id + 1;
						}

					}
				}
			}

			cnt = 0;
			axis ^= 1;

		}
		else cnt++;

	}
	
	if (pos[0][gx + 8000] && pos[1][gy + 8000]) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}


Measured memory_bytes: 572
import java.util.*;

public class Main{
   public static void main(String[] args){
     Scanner sc=new Scanner(System.in);
     final int A=sc.nextInt();
     final int B=sc.nextInt();
     int[] x={A+B,A-B,A*B};
     Arrays.sort(x);
     System.out.println(x[2]);
   }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define INF (int)1e9+1
#define INFLL (int)1e18+1
#define sz(bb) (int)bb.size()
#define all(qq) qq.begin(), qq.end() 
#define Max(a, b, c) max(a, max(b, c))
#define Min(a, b, c) min(a, min(b, c))
const double PI=acos(-1);
// #define int unsigned long long int//used when x<2^64-1 && x>0
#define int long long//used when x<2^63-1
//bool cmp if returns true it keeps 1st as first else swaps
typedef long long  ll;

const int N=100001;
void solve()
{
    int n;
    cin>>n;
    int arr[N];
    memset(arr, 0, sizeof(arr));
    int sum=0;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        sum+=x;
        arr[x]++;
    }
    int q;
    cin>>q;
    while(q--)
    {
        int a, b;
        cin>>a>>b;
        sum-=a*arr[a];
        sum+=b*arr[a];
        arr[b]+=arr[a];
        arr[a]=0;
        cout<<sum<<"\n";
    }
}
int32_t main()
{
    IOS;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
    long long N;
    cin >> N;
    vector<long long> a(3 * N);
    for (int i = 0; i < 3 * N; i++) {
        cin >> a[i];
    }

    vector<long long> left_sum(3 * N, 0), right_sum(3 * N, 0);
    long long curr_sum = 0;
    priority_queue<long long, vector<long long>, greater<long long>> left_pq;
    priority_queue<long long> right_pq;

    //左側を求める
    for (int i = 0; i < N; i++) {
        left_pq.push(a[i]);
        curr_sum += a[i];
    }
    left_sum[N - 1] = curr_sum;

    for (int i = N; i < 2 * N; i++) {
        left_pq.push(a[i]);
        auto t = left_pq.top();
        left_pq.pop();
        curr_sum += (a[i] - t);
        left_sum[i] = curr_sum;
    }

    //右側を求める
    curr_sum = 0;
    for (int i = 3 * N - 1; i >= 2 * N; i--) {
        right_pq.push(a[i]);
        curr_sum += a[i];
    }
    right_sum[2 * N] = curr_sum;
    for (int i = 2 * N - 1; i > N - 1; i--) {
        right_pq.push(a[i]);
        auto t = right_pq.top();
        right_pq.pop();
        curr_sum += (a[i] - t);
        right_sum[i] = curr_sum;
    }

    long long ans = LONG_MIN;
    for (int i = N; i <= 2 * N; i++) {
        ans = max(ans, left_sum[i - 1] - right_sum[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9588
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
//use proconio::fastout;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}

fn main() {
  input! {
     N:usize,Q:usize,
     c:[Usize1;N],
     lr:[(Usize1,Usize1);Q]
  }
  let inf = std::usize::MAX;
  let c: Vec<usize> = c;
  let lr: Vec<(usize, usize)> = lr;
  let mut ans = vec![0; Q];
  let mut last = vec![inf; N];
  let mut next = vec![vec![]; N];
  for i in 0..N {
    let v = last[c[i]];
    if v != inf {
      next[v as usize].push(i);
    }
    last[c[i]] = i;
  }
  let mut qs = vec![Vec::with_capacity(N); N];
  for qi in 0..Q {
    debug!(lr);
    //(qi, &(l, r)) in lr.iter().enumerate() {
    let (l, r) = lr[qi];
    qs[l].push((r, qi));
  }
  //println!("p{:?}", next);
  let mut bit = BIT::new(N);
  for x in (0..N).rev() {
    for &y in next[x].iter() {
      bit.add(y, 1usize);
    }
    //println!("prev={:?}", next);
    for &(r, qi) in qs[x].iter() {
      //println!("sum={}", bit.sum(r));
      ans[qi] = (r - x + 1) - bit.sum(r);
    }
  }

  for a in ans {
    println!("{}", a);
  }
}

struct BIT<T> {
  n: usize,
  d: Vec<T>,
}
use num_traits::*;
impl<T: NumAssign + ToPrimitive + FromPrimitive + Copy> BIT<T> {
  fn new(n: usize) -> BIT<T> {
    BIT {
      n: n,
      d: vec![T::from_i64(0).unwrap(); n + 1],
    }
  }
  fn add(&mut self, index: usize, x: T) -> () {
    let mut i = (index + 1) as i64;
    while i <= self.n as i64 {
      self.d[i as usize] += x;
      i += i & -i;
    }
  }
  fn sum(&self, index: usize) -> T {
    let mut x = self.d[0];
    let mut i = (index + 1) as i64;
    while i > 0 {
      x += self.d[i as usize];
      i -= i & -i;
    }
    x
  }
  fn range(&self, l: usize, r: usize) -> T {
    // l 以上 r 未満の範囲のsum
    match (l, r) {
      (0, _) => self.sum(r - 1),
      _ => self.sum(r - 1) - self.sum(l - 1),
    }
  }
}

Measured memory_bytes: 87000
import sys
from collections import deque
dq = deque()

#def insert_elem(ad_elem,curosor):

#def move(move_distance,cursor):

  #  return cursor

#def erase(cursor):


query_num = int(input())
cursor = 0
for i in range(query_num):
    query = sys.stdin.readline()
    if query[0] == '0':
        n = int(query[2:].strip())
        dq.appendleft(n)
    elif query[0] == '1':
        n = int(query[2:].strip())
        dq.rotate(-n)
        cursor += n
    else:
        dq.popleft()

dq.rotate(cursor)
for i in range(len(dq)):
    print(dq[i])


Measured memory_bytes: 21668
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl

string S;





int main()
{

	cin >> S;
	if(S.length() >= 4 &&S[0]=='Y'&&S[1]=='A'&&S[2]=='K'&&S[3]=='I')
		cout << "Yes";
	else
		cout << "No";





}


Measured memory_bytes: 256
class RollingHash():
    def __init__(self, string):
        self.n = len(string)
        self.BASE = 1234
        self.MOD = (1 << 61) - 1
        self.hash = [0] * (self.n + 1)
        self.pow = [1] * (self.n + 1)
        
        for i, char in enumerate(string):
            self.hash[i+1] = (self.hash[i] + ord(char)) * self.BASE % self.MOD
            self.pow[i+1] = (self.pow[i] * self.BASE) % self.MOD
            
    def get_hash(self, l, r):
        res = (self.hash[r] - self.hash[l] * self.pow[r-l]) % self.MOD
        return res

n = int(input())
s = input()

rh = RollingHash(s)

ans = 0
def solve(mid):
    length = mid
    set_ = set()
    for l in range(n):
        # [l, l + length), [l + length, l + 2*length)
        if l + 2*length > n:
            break
        set_.add(rh.get_hash(l, l + length))
        tmp = rh.get_hash(l + length, l + 2*length)
        if tmp in set_:
            ans = length
            return True
    return False
  
ok = 0
ng = n//2 + 1
while abs(ng - ok) > 1:
    mid = (ok + ng) // 2
    if solve(mid):
        ok = mid
    else:
        ng = mid
print(ok)
    

Measured memory_bytes: 46556
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        int modVal = n % 1000;
        if (modVal == 0) {
            System.out.println(0);
        } else {
            System.out.println(1000 - modVal);
        }
    }
}


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

int main(){
    double r;
    double pi = 3.141592653589;
    cin >> r;
    // r = 3;
    double area = r*r*pi;
    double circumference = 2*r*pi;
    cout << std::setprecision(16) << std:: fixed <<  area << " " << circumference;
    
    // cout << d << " " << r << " " << std::setprecision(13) << std::fixed << f << endl;

    return 0;
}


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

int recS(int x, int y){
    return x*y;
}

int main (){
    int a,b,c,d;
    cin >> a >> b >> c >>d;
    if(recS(a, b)>=recS(c,d)){
        cout << recS(a, b) << endl;
    }else if(recS(c,d) > recS(a,b)){
        cout << recS(c,d) << endl;
    }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let s = read::<String>();
  let n = s.chars().count();
  let mut r = 0;

  while r < n -1 && s.chars().nth(r) != s.chars().nth(r+1) {
    r +=1;
  }
  if r == n-1 {
    println!("Good");
  } else {
    println!("Bad");
  }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {
	
	int n;
	cin >> n;
	vi a(n + 1), b(n);
	rep(i, n + 1)cin >> a[i];
	rep(i, n)cin >> b[i];

	ll ans = 0;

	rep(i, n) {

		ans += min(a[i], b[i]);
		b[i] -= min(a[i], b[i]);

		ans += min(a[i + 1], b[i]);
		a[i + 1] -= min(a[i + 1], b[i]);

	}

	cout << ans << endl;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;

int main(){
    bool kotae=true;
    int a[6];
    rep(i,5){
        cin>>a[i];
    }
    int k;
    cin>>k;
    rep(i,5){
        for(int j=i+1;j<5;j++){
            if(a[j]-a[i]>k)kotae=false;
        }
    }
    string ans=(kotae)?"Yay!":":(";
    cout<<ans<<endl;
    return 0;
}

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

void R(int &x) {
	int f = 1; x = 0; char s = getchar();
	while(s > '9' || s < '0') {
		if(s == '-') f = -1;
		s = getchar();
	}
	while(s >= '0' && s <= '9') {
		x = (x << 3) + (x << 1) + (s ^ 48);
		s = getchar();
	}
	x *= f;
}

int n , m;

int main() {
	
	R(n) , R(m);
	
	int ans = 0; 
	
	for(int i = 1;i <= n; i++) {
		for(int j = 12; j <= m; j++) {
			int p1 = j % 10 , p2 = j / 10 % 10;
			if(p1 >= 2 && p2 >= 2 && p1 * p2 == i) {
				ans++;
			}
		}
	}
	
	printf("%d" , ans);
	
	return 0;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>

#pragma region _define

#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n,option) f(i,0,n)cout<<v[i]<<option;
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b)*b);
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		//ret %= 1000000007;
	}
	return ret;
}

#pragma endregion

/************************************************************************/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
 
	int n;
	cin >> n;
	vi a(n);
	map<LL, LL>m;
	f(i, 0, n) {
		cin >> a[i];
		m[a[i]]++;
	}
	sort(all(a), greater<LL>());
	LL A = 0, B = 0;
	f(i, 0, n) {
		if (B != 0) {
			break;
		}
		if (m[a[i]] >= 2) {
			if (A == 0) {
				A = a[i];
			}
			else {
				B = a[i];
			}
			m[a[i]] -= 2;
			i--;
		}
	}
	cout << A * B;
	return 0;
}

Measured memory_bytes: 7296
/**
 * Sort I - Bubble Sort
 */

#include <iostream>

using namespace std;

int main() {
    int N, A[100], count = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = N - 1; i >= 1; i--) {
        for (int j = 0; j < i; j++) {
            if (A[j] > A[j + 1]) {
                A[j] += A[j + 1];
                A[j + 1] = A[j] - A[j + 1];
                A[j] = A[j] - A[j + 1];
                count++;
            }
        }
    }
    for (int i = 0; i < N; i++) {
        if (i < N - 1) {
            cout << A[i] << " ";
        } else {
            cout << A[i] << endl;
        }
    }
    cout << count << endl;
}


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


int main(){
  vector<long long> ans(1000,0);

  ans[0]=0;
  ans[1]=1;

  for(int i= 2;i<1000;i++){
    ans[i] = ans[i-1] + ans[i-2];
  }
  int n;
  cin >> n;

  cout << ans[n+1] << endl;
}


Measured memory_bytes: 3112
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

#define ll long long
#define el '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repi(i, a, b) for (int i = a; i >= b; i--)
#define VI vector<int>
#define VII vector<pair<int, int>>
#define PII pair<int, int>
#define MP make_pair
// #define log(fmt, ...) printf(fmt, ##__VA_ARGS__)
#define log(fmt, ...)
// #define check(...) assert(##__VA_ARGS__)
#define check(...)

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

    int l;
    cin >> l;
    double sz = l / 3.0;
    printf("%.6f", sz * sz * sz);
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
  int N;
  int K;
  int i;
  int ans = 1;

  scanf("%d %d",&N, &K);
  int array[N];
  for(i=0; i<N ;i++)
    {
      scanf("%d",&array[i]);
    }
  N -= K;
  if(N >= 0 && N%(K-1) != 0)
    {
      ans += N/(K-1) + 1;
    }
  else if(N >= 0 && N%(K-1) == 0)
    {
      ans += N/(K-1);
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
typedef long long ll;
const int MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    string s1,s2;
    cin >> s1 >> s2;
    ll res = 0;
    int state = -1;
    rep(i,s1.length()){
        if(i == 0){
            if(s1[i] == s2[i]){
                res += 3;
                res %= MOD;
                state = 0;
            }else{
                res += 6;
                res %= MOD;
                state = 1;
            }
        }else{
            if(s1[i] == s2[i]){
                if(state == 0){
                    res *= 2;
                    res %= MOD;
                    state = 0;
                }else{
                    res *= 1;
                    res %= MOD;
                    state = 0;
                }
            }else{
                if(state == 0){
                    res *= 2;
                    res %= MOD;
                    state = 1;
                }else if(state == 1 && s1[i] != s1[i-1]){
                    res *= 3;
                    res %= MOD;
                }
            }
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
'use strict'

function main(s) {

  s = s.split('\n')[0].split(' ').map(n => Number(n));

  const w = s[0];
  const a = s[1];
  const b = s[2];

  let ans = 0;

  if ((b + w) < a) ans = a - (b + w);
  if (b > (a + w)) ans = b - (a + w);

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};



int main(void) {
  int n;
  cin >> n;
  bool ok = false;
  rep(i,9)rep(j,9){
    if((i+1)*(j+1) == n) ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
         
         
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

int binary_search(int first, int a, int b, vi &l) {
    int ng = first - 1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = N;         // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        bool isOK = false;
        int c = l[mid];
        if (c < a + b) {
            isOK = true;
        }
        if (isOK)
            ok = mid;
        else
            ng = mid;
    }
    dump(ok, a, b, l[ok]);
    return ok;
}

signed main() {
    cin >> N;
    vi l(N);
    cin >> l;
    sort(ALL(l));
    REP(i, N)
    FOR(j, i + 1, N) {
        int tmp = upper_bound(l.begin() + j + 1, l.end(), l[i] + l[j] - 1) - l.begin() - j - 1;
        dump(i, j, tmp + j + 1);
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3504
w = input()
alphabet_list = [chr(i) for i in range(97,97+26)]

for i in range(len(alphabet_list)):
    count = 0
    for j in w:
        if alphabet_list[i] == j:
            count += 1
    if count % 2 != 0:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

public class MainClass
{
	public static void Main(string[] args)
	{
		string input = Console.ReadLine();
		int max = 0;
		int cur = 0;
		for(int i = 0; i < input.Length; i++)
		{
			if(IsChara(input[i])) cur++;
			else 
			{
				max = Math.Max(max, cur);
				cur = 0;
			}
		}
				max = Math.Max(max, cur);
		Console.WriteLine(max);

	}
	
	private static bool IsChara(char c)
	{
		return c == 'A' || c=='T'||c=='G'||c=='C';
	}
}

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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int a, b, c;
	int x;
	cin >> a >> b >> c;
	cin >> x;

	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (i*500 + j*100+ 50*k == x) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define PI 3.141592653589793

int main(void){
    int a,b,c;
    double s,l,h;
    
    scanf("%d%d%d",&a,&b,&c);
    
    s = sin(c * PI / 180.0)*a*b/2;
    l = a + b + sqrt(a*a + b*b - 2*a*b * cos(c * PI / 180.0));
    h = s/a*2;
    
    printf("%lf %lf %lf\n" ,s,l,h);
    
    return 0;
}

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

int main(){
  long double a,b,c;
  cin>>a>>b>>c;
  //cout<<pow(pow(x2-x1,2)+pow(y2-y1,2),0.5)<<endl;
  cout<<std::fixed<<std::setprecision(10)<<0.5*a*b*sin(c*(M_PI/180))<<endl<<a+b+pow(a*a+b*b-2*a*b*cos(c*(M_PI/180)),0.5)<<endl<<a*b*sin(c*(M_PI/180))/a<<endl;
  //cout<<hypot(x2-x1,y2-y1)<<endl;
}




Measured memory_bytes: 3484
#include<bits/stdc++.h>
using namespace std;
#define LINE 8
#define st 1
#define YOKO 17
int main(){
    int N;
    cin>>N;
    long long x[N];
    long long sum=0;
    for(int i=0;i<N;i++){
        cin>>x[i];
        sum+=x[i];
    }
    long long SUM=0;
    int P;
    cin>>P;
    for(int i=0;i<P;i++){
        int p,k;
        cin>>p>>k;
        SUM=sum-x[p-1]+k;
        cout<<SUM<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define two(a) (1<<(a))
#define LINF (1ll<<61)
#define EPS (1e-14)
#define Lshift(a,b) ((a)<<(b))
#define Rshift(a,b) ((a)>>(b))
#define rep(a,b) for(a=0 ; a<b ; a++)
#define xrep(a,b,c) for(a=b ; a<c ; a++)
#define INF (1<<29)
#define sz(a) int(a.size())
#define mset(x) memset(x, 0, sizeof(x))
#define swap(a,b) ( (a^=b) , (b^=a) , (a^=b) )
#define GET(x) (mark[x>>5]>>(x&31)&1)
#define SET(x) (mark[x>>5]|=1<<(x&31))
#define maxL (10000000>>5)+1
#define mod 1000000007
#define vi vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define si set<int>
#define pb push_back
typedef long long ll;
using namespace std;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string a, b;
    cin >> a >> b;
    int i;
    rep(i, sz(a)) if (a[i] != b[i]) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int a, b, c;
  cin >> a >> b >> c;
  cout << c << " " << a << " " << b;
  return 0;
}

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

int judge_point(int A[], int a[], int b[], int c[], int d[], int N, int M, int Q)
{
    int p = 0;
    for (size_t i = 0; i < Q; i++)
    {
        if (A[b[i] - 1] - A[a[i] - 1] == c[i])
        {
            p += d[i];
        }
    }
    return p;
}

int max(int a, int b)
{
    return a > b ? a : b;
}

int main(int argc, char const *argv[])
{
    int N, M, Q;
    int a[50], b[50], c[50], d[50];

    scanf("%d %d %d", &N, &M, &Q);
    for (size_t i = 0; i < Q; i++)
    {
        scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
    }

    int A_len = N;
    int A_num_max = M;
    int A[10];
    unsigned point = 0;

    for (size_t i0 = 1; i0 <= A_num_max; i0++)
        for (size_t i1 = i0; i1 <= A_num_max; i1++)
            for (size_t i2 = i1; i2 <= A_num_max; i2++)
                for (size_t i3 = i2; i3 <= A_num_max; i3++)
                    for (size_t i4 = i3; i4 <= A_num_max; i4++)
                        for (size_t i5 = i4; i5 <= A_num_max; i5++)
                            for (size_t i6 = i5; i6 <= A_num_max; i6++)
                                for (size_t i7 = i6; i7 <= A_num_max; i7++)
                                    for (size_t i8 = i7; i8 <= A_num_max; i8++)
                                        for (size_t i9 = i8; i9 <= A_num_max; i9++)
                                        {
                                            A[0] = i0;
                                            A[1] = i1;
                                            A[2] = i2;
                                            A[3] = i3;
                                            A[4] = i4;
                                            A[5] = i5;
                                            A[6] = i6;
                                            A[7] = i7;
                                            A[8] = i8;
                                            A[9] = i9;
                                            point = max(point, judge_point(A, a, b, c, d, N, M, Q));
                                        }

    printf("%u\n", point);
    
    return 0;
}


Measured memory_bytes: 1700
#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <cassert>

double distance(const std::vector<int>& v0, const std::vector<int>& v1)
{
    assert(v0.size() == v1.size());
    double L2 = std::inner_product(v0.begin(), v0.end(), v1.begin(), 0,
            std::plus<>(), [](int x0, int x1)->int{ return std::pow(x1-x0, 2); });
    return std::sqrt(L2);
}

int main()
{
    int N;
    int D;
    std::cin >> N >> D;
    std::vector<std::vector<int>> X(N);
    for (auto& x : X)
    {
        x.resize(D);
    }

    for (int n = 0; n < N; ++n)
    {
        for (int d = 0; d < D; ++d)
        {
            std::cin >> X[n][d];
        }
        std::cin.ignore(1, '\n');
    }

    int count = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            const double d = distance(X[i], X[j]);
            if (d == std::ceil(d))
            {
                ++count;
            }
        }
    }
    std::cout << count << std::endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
INF = float('inf')
n = int(input())
g = {i: [] for i in range(n + 1)}
for i in range(n):
    g[i].append(i + 1)
    num = 6
    while num <= n:
        g[i].append(i + num)
        num *= 6
    num = 9
    while num <= n:
        g[i].append(i + num)
        num *= 9
queue = deque([0])
dist = [INF] * (n + 1)
dist[0] = 0
while queue:
    c = queue.pop()
    for node in g[c]:
        if node <= n and dist[node] == INF:
            queue.appendleft(node)
            dist[node] = dist[c] + 1
print(dist[n])

Measured memory_bytes: 72676
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>

using namespace std;
typedef long long ll;
#define i_7 1000000007
#define i_5 1000000005

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
#define inf 100000000/*10^8*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)

////////////////////////////////////////

int main(){
    int a,b;cin>>a>>b;
    if(a+b==15)cout<<"+"<<endl;
    else if(a*b==15)cout<<"*"<<endl;
    else cout<<"x"<<endl;
    
    return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


int main() {
    int a, b;
    cin >> a >> b;

    int width = 95; //100 * 100;
    int cells = width * (width / 5);

    vector<bool> whites(cells, true);
    vector<bool> blacks(cells, false);

    for (int i = 1; i < a; i++) {
        blacks[i * 2] = true;
    }
    for (int i = 1; i < b; i++) {
        whites[i * 2] = false;
    }

    reverse(blacks.begin(), blacks.end());

    cout << ((width / 5) * 2 * 2) << ' ' << width + 2 << endl;

    for (int i = 0; i < cells; i++) {
        if (i % width == 0) {
            for (int j = 0; j < width + 2; j++) {
                cout << '.';
            }
            cout << endl;
            cout << '.';
        }
        if (whites[i] == true) {
            cout << '.';
        } else {
            cout << '#';
        }
        if (i % width == width - 1) {
            cout << '.' << endl;

        }
    }

    for (int i = 0; i < cells; i++) {
        if (i % width == 0) {
            cout << '#';
        }
        if (blacks[i] == true) {
            cout << '.';
        } else {
            cout << '#';
        }
        if (i % width == width - 1) {
            cout << '#' << endl;
            for (int j = 0; j < width + 2; j++) {
                cout << '#';
            }
            cout << endl;
        }
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int input[3];
	for (int i = 0; i < 3; i++) cin >> input[i];

	int result = 0;
	sort(input, input + 3);
	while (true) {
		if (input[0] + 1 < input[1]) {
			input[0] += 2;
		}
		else if (input[0] < input[1]) {
			input[0]++;
			input[2]++;
		}
		else if (input[0] < input[2]) {
			input[0]++;
			input[1]++;
		}
		else {
			break;
		}
		result++;

	}
	cout << result << endl;
	
    return 0;
}


Measured memory_bytes: 256
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1000007;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;

int main()
{
	//freopen("in.txt", "r", stdin);
	ll k;
	while (cin >> k)
	{
		ll tmp = 0;
		ll ans = 0;
		map<ll, ll> mp;
		int cot = 100000000;
		while (cot--)
		{
			ans = ans * 10ll + 7;
			tmp++;
			ans %= k;
			if (ans == 0)return cout << tmp << endl, 0;
		}
		cout << -1 << endl;
		
	}
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    int n;
    cin >> n;
    int ans[n+2] = {0};
    for (int i=2; i<=n; i++) {
        int boss;
        cin >> boss;
        ans[boss]++;
    }
    for (int i=1; i<=n; i++)
        cout << ans[i] << endl;
    //cout << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 4388
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int a[60];
    rep(i, N) cin >> a[i];
    int num = a[0];
    int idx = 0;
    rep(i, N) {
        if(abs(num) < abs(a[i])) {
            num = a[i];
            idx = i;
        }
    }
    
    cout << N * 2 - 1 << endl;
    rep(i, N) cout << idx + 1 << " " << i + 1 << endl;
    if(num < 0) {
        RREP(i, N, 2) cout << i << " " << i - 1 << endl;
    } else {
        REP(i, 1, N - 1)cout << i << " " << i + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N = int(input())
V = input().split()
C = input().split()
value = int(0)
i = int(0)
for i in range(N):
    if int(V[i]) > int(C[i]):
        add = int(V[i]) - int(C[i])
        value = value + add
    i = i + 1
print(value)

Measured memory_bytes: 3064
#include<cstdio>
using namespace std;

int main(){
    double r,S,l;
    scanf("%lf", &r);
    
    S = r * r * 3.141592653589;
    l = 2 * r * 3.141592653589;
    
    printf("%f %f\n", S, l);
    return 0;
}


Measured memory_bytes: 2704
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

ll dp[3001][3001];

int main(){
  ll n,s;
  cin >> n >> s;
  ll a[n];
  rep(i,n)cin >> a[i];
  memset(dp, 0, sizeof(dp));   // 一旦すべて 0 に
  dp[0][0] = 1;                // dp[0][0] だけ 1 に
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= s; ++j) {
      (dp[i+1][j] += 2*dp[i][j]) %= mod;
      if (j >= a[i]) (dp[i+1][j] += dp[i][j-a[i]]) %= mod;
    }
  }
  cout << dp[n][s] << endl;
return 0;}

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

int main() {
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;

    int ans = 1000000;
    for (int i = 1; i <= N; i++) {
        int ax = A / i;
        int ay = A % i;
        int bx = B / i;
        int by = B % i;
        int cx = C / i;
        int cy = C % i;
        int dx = D / i;
        int dy = D % i;

        int dis1 = abs(ax - bx) + abs(ay - by);
        int dis2 = abs(cx - dx) + abs(cy - dy);

        ans = min(ans, dis1 + dis2);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3092
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <functional>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

int a[100500];
int b[100500];
priority_queue<pii> good, bad;

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    int n;
    cin >> n;
    forn(i, n) {
        cin >> a[i];
    }
    forn(i, n)
        cin >> b[i];
    forn(i, n) {
        if (a[i] > b[i])
            good.push({ a[i] - b[i], i });
        else if (a[i] < b[i])
            bad.push({ b[i] - a[i], i });
    }
    int ans = 0;
    while (bad.size()) {
        if (good.empty()) {
            cout << -1;
            return 0;
        }
        pii cur = good.top();
        good.pop();
        ++ans;
        while (bad.size() && cur.first) {
            pii q = bad.top();
            bad.pop();
            int i = q.second;
            int d = min(q.first, cur.first);
            a[i] += d;
            cur.first -= d;
            if (a[i] >= b[i])
            {
                ++ans;
                continue;
            }
            q.first = b[i] - a[i];
            bad.push(q);
        }
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 2168
//
//Hiia
#include <stdio.h>
#include <stdlib.h>//rannsuu, zettaichi(absolute)
#include <time.h>
//srand((unsigned int) time(0));
#include <math.h>//koudona keisann
#include <string.h>//hairetsu
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
//#define N 998244353

int gcd(int m,int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
int lcm(int m,int n){if((0==m)||(0==n))return 0;return(m*n/gcd(m, n));}
int fact(int x){if(x==1) return(x);else return(x*fact(x-1));}//Kaijou x!
int ruijou(int base,int exponent){int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

long long int llgcd(long long int m,long long int n){if((0==m)||(0==n))return 0;while(m!=n)if(m>n)m=m-n;else n=n-m;return m;}
long long int lllcm(long long int m,long long int n){if((0==m)||(0==n))return 0;return(m*n/llgcd(m, n));}
long long int llfact(long long int x){if(x==1) return(x);else return(x*llfact(x-1));}//Kaijou
int llruijou(long long int base,long long int exponent){long long int i,answer=1;i=exponent;while(i!=0){answer=answer*base;--i;}return answer;}//ruijou base^exponent

int main()
{
  char s[200010],t[200010];
  scanf("%s %s", s,t);
  int num,c=0;
  num=strlen(s);
  for(int i = 0; i < num; i++) {
    if(s[i]==t[i]){
      c++;
    }
  }
  printf("%d\n", num-c);

  return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[123456];
int N,W,price[123],wt[123];
int32_t main()
{
   cin >> N>>W;
   for(int i=0;i<N;i++)
   {
       cin>> wt[i] >> price[i];
   }
   
   for(int i=0;i<N;i++)
   {
      for(int j=W-wt[i];j>=0;j--)
      {
         dp[j+wt[i]] = max(dp[j+wt[i]],dp[j]+price[i]);
      }
   }
   
   cout<<dp[W]<<"\n";

}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            ABC119_B();
        }

        static void ABC119_B()
        {
            var N = int.Parse(Console.ReadLine());
            var sum = 0D;
            for (var n = 0; n < N; n++)
            {
                var xu = Console.ReadLine().Split(' ').ToArray();
                var x = xu[0];
                var u = xu[1];
                sum += u == "BTC" ? 380000.0 * double.Parse(x) : double.Parse(x);
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    string s;
    cin >> s;
    int ar[s.length()];
    s.push_back('R');
    memset(ar, 0, sizeof(ar));
    int rl = -1, lr = -1;
    for (int ctr1 = 0; ctr1 + 1 < s.length(); ++ctr1) {
        if (s[ctr1] == 'R' && s[ctr1 + 1] == 'L')
            rl = ctr1;
        if (s[ctr1] == 'L' && s[ctr1 + 1] == 'R') {
            ar[rl] = (ctr1 - lr) / 2;
            ar[rl + 1] = (ctr1 - lr) / 2;
            if ((ctr1 - lr) % 2) {
                if ((ctr1 - lr) % 2 == (rl - lr) % 2)
                    ++ar[rl];
                else ++ar[rl + 1];
            }
            lr = ctr1;
        }
    }
    for (auto r : ar)
        cout << r << " ";

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    ll n,sum=0,A[200001],B[200001];
    cin>>n;
    rep(i,n) cin>>A[i],sum+=A[i];
    if(sum%(n*(n+1)/2)){
        cout<<"NO";
        return 0;
    }
    ll d=sum/(n*(n+1)/2);
    rep(i,n-1) B[i]=A[i+1]-A[i];
    ll ans=0;
    rep(i,n-1){
        if(d<B[i]){
            cout<<"NO";
            return 0;
        }
        if((d-B[i])%n){
            cout<<"NO";
            return 0;
        }
        ans+=(d-B[i])/n;
    }
    if(ans>d){
        cout<<"NO";
        return 0;
    }
    cout<<"YES";
}

Measured memory_bytes: 3072
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	static class Node {
		int id;
		int parentId;
		int depth;
		int[] children;
		public Node(int id, int parentId) {
			this.id = id;
			this.parentId = parentId;
			this.children = null;
			this.depth = 0;
		}
		public void setChildlen(int[] childlen) {
			this.children = childlen;
		}
		public void setParentId(int parentId) {
			this.parentId = parentId;
		}
		public void setDepth(int depth) {
			this.depth = depth;
		}
		private String getType() {
			if (depth == 0) {
				return "root";
			}
			if (children == null || children.length == 0) {
				return "leaf";
			}
			return "internal node";
		}		
		public String toString() {
			StringBuilder sb = new StringBuilder();
			sb.append("node " + id + ": ");
			sb.append("parent = " + parentId + ", ");
			sb.append("depth = " + depth + ", ");
			sb.append(getType() + ", ");
			sb.append(Arrays.toString(children));
			return sb.toString();
		}
	}
		
	public static void main(String[] args) throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		Node[] nodes = new Node[n];

		for (int i = 0; i < n; i++) {
			
			StringTokenizer st = new StringTokenizer(reader.readLine());
			
			int id = Integer.parseInt(st.nextToken());
			if (nodes[id] == null) {
				nodes[id] = new Node(id, -1);
			} else {
				if (nodes[id].parentId != -1) {
					nodes[id].setDepth(nodes[nodes[id].parentId].depth + 1);
				}
			}
			
			int m = Integer.parseInt(st.nextToken());
			int[] children = new int[m];
			for (int j = 0; j < m; j++) {
				int childId = Integer.parseInt(st.nextToken());
				children[j] = childId;
				if (nodes[childId] == null) {
					nodes[childId] = new Node(childId, id);
				} else {
					nodes[childId].setParentId(id);
				}
				nodes[childId].setDepth(nodes[id].depth + 1);
			}
			nodes[id].setChildlen(children);
		}
		
		for (Node node : nodes) {
			System.out.println(node);
		}
	}
}



Measured memory_bytes: 122376
import java.util.Scanner;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        long ans = calc(n);
        System.out.println(ans);
    }

    private static long calc(int n) {
        long[] memo = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            int j = 1;
            while (i * j <= n) {
                memo[i * j]++;
                j++;
            }
        }
        long sum = 0;
        for (int i = 1; i < memo.length; i++) {
            sum += i * memo[i];
        }
        return sum;
    }

}

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

int graph[60][60];
bool rireki[15];
int n,m;
int kekka = 0;
int dfs(int cur){
  int ok = 0;
  rireki[cur] = true;
  for(int i = 1;i <= n;i++){
    if(rireki[i] == true){
      ok++;
    }
  }
  if(ok == n){
    kekka++;
  }
  
  for(int i = 1;i <= n;i++){
    if(graph[cur][i] == 1 && rireki[i] == false){
      dfs(i);
      rireki[i] = false;
    }
  }
  return kekka;
}


int main(){
  cin >> n >> m;
  int a[60];
  int b[60];
  for(int i = 1;i <= m;i++){
    cin >> a[i] >> b[i];
    graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
  }
          
  cout << dfs(1) << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    ll n;
    cin >> n;
    cout << n * (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void swap(int a[],int p,int c,int n){
int i;
int b[50]={0};
for(i=0;i<p-1;i++)
b[i]=a[n-1-i];
for(i=0;i<c;i++)
a[n-1-i]=a[n-p-i];
for(i=0;i<p-1;i++)
a[n-c-1-i]=b[i];
}

int main(void){
int r,n,i,p,c,o;

while(1){
int a[50]={0};
scanf("%d%d",&n,&r);
if(n==0&&r==0)
break;
for(i=0;i<n;i++)
a[i]=i+1;
for(i=0;i<r;i++){
scanf("%d%d",&p,&c);
swap(a,p,c,n);
}
printf("%d\n",a[n-1]);
}
return 0;
}

Measured memory_bytes: 600