akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline


class RollingHash:
    """文字列stringsの部分文字列のハッシュを構築する。O(N)"""
    def __init__(self, string):
        self.n = len(string)
        self.BASE = 1234
        self.MASK30 = (1 << 30) - 1
        self.MASK31 = (1 << 31) - 1
        self.MASK61 = (1 << 61) - 1
        self.MOD = self.MASK61
        self.hash = [0] * (self.n + 1)
        self.pow = [1] * (self.n + 1)

        for i, char in enumerate(string):
            self.hash[i + 1] = self.calc_mod(self.mul(self.hash[i], self.BASE)
                                             + ord(char))
            self.pow[i + 1] = self.calc_mod(self.mul(self.pow[i], self.BASE))

    def calc_mod(self, x):
        """x mod 2^61-1 を返す。"""
        xu = x >> 61
        xd = x & self.MASK61
        x = xu + xd
        if x >= self.MOD:
            x -= MASK61
        return x

    def mul(self, a, b):
        """a*b mod 2^61-1 を返す。"""
        au = a >> 31
        ad = a & self.MASK31
        bu = b >> 31
        bd = b & self.MASK31
        mid = ad * bu + au * bd
        midu = mid >> 30
        midd = mid & self.MASK30
        return self.calc_mod(au * bu * 2 + midu + (midd << 31) + ad * bd)

    def get_hash(self, l, r):
        """string[l:r]のハッシュ値を返す。O(1)"""
        res = self.calc_mod(self.hash[r]
                            - self.mul(self.hash[l], self.pow[r - l]))
        return res

    def merge(self, h1, h2, length2):
        """ハッシュ値h1と長さlength2のハッシュ値h2を結合する。O(1)"""
        return self.calc_mod(self.mul(h1, self.pow[length2]) + h2)

    def get_lcp(self, l1, r1, l2, r2):
        """string[l1:r2]とstring[l2:r2]の長共通接頭辞(Longest Common Prefix)の
        長さを求める。O(log|string|)
        """
        ng = min(r1 - l1, r2 - l2) + 1
        ok = 0
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if self.get_hash(l1, l1 + mid) == self.get_hash(l2, l2 + mid):
                ok = mid
            else:
                ng = mid
        return ok


n = int(input())
s = [input()[:-1] for i in range(n)]


s.sort(key=len)
str_set = set()
cnt = 0

for string in s:
    string = string[::-1]  # stringの後ろから見る
    n = len(string)
    rh = RollingHash(string)

    for r in range(1, n + 1):
        if rh.get_hash(0, r) in str_set:
            cnt += 1

    set_char = set()
    for r in range(1, n + 1)[::-1]:
        h_str = rh.get_hash(0, r - 1)
        h_r = rh.get_hash(r - 1, r)
        set_char.add(h_r)
        for h1 in set_char:
            if h1 == h_r:
                continue
            h = rh.merge(h_str, h1, 1)
            if h in str_set:
                cnt += 1
    str_set.add(rh.get_hash(0, n))

print(cnt)

Measured memory_bytes: 135928
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1]) {
		cout << "Bad";
	}
	else if (s[1] == s[2]) {
		cout << "Bad";
	}
	else if (s[2] == s[3]) {
		cout << "Bad";
	}
	else {
		cout << "Good";
	}



}

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

int main(){
  string s; cin >> s;
  ll N = s.size();
  ll K; cin >> K;
  ll ans = 0LL;
  
  if(N == 1){
    cout << K / 2 << endl;
    return 0;
  }
  
  char c = s[0];
  ll fcnt = 1;
  while((c == s[fcnt]) && (fcnt < N)){
    fcnt++;
  }
  
  if(fcnt == N){
    cout << (N * K) / 2 << endl;
    return 0;
  }
  
  c = s[N-1];
  ll scnt = N - 2;
  while(c == s[scnt]){
    scnt--;
  }
  
  if(s[0] == s[N-1]){
    ans += ((fcnt + (N - 1 - scnt)) / 2) * (K - 1);
    //cout << ans << ' ';
    ans += fcnt / 2 + (N - 1 - scnt) / 2;
  }else{
    ans += (fcnt / 2) * K;
    ans += ((N - 1 - scnt) / 2) * K;
  }
  
  c = s[fcnt];
  ll tmp = 1;
  fcnt++;
  for(; fcnt <= scnt; fcnt++){
    if(s[fcnt] == c){
      tmp++;
    }
    else{
      ans += (tmp/2) * K;
      tmp = 1;
    }
    c = s[fcnt];
  }
  
  ans += (tmp/2) * K;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,k,ans=0;
    cin>>n>>k;
    vector<int>v;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    for(int i=n-1,j=k-1;j>=0;j--,i--)
        ans+=v[i];
   cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

h,w=map(int,input().split())
data=[list(input()) for i in range(h)]
ans=[["#"]*(w+2) for i in range(h+2)]
for i in range(1,h+1):
    ans[i][1:w+1]=data[i-1]
for ai in ans:
    print(*ai,sep="")

Measured memory_bytes: 40560
n, m = (int(i) for i in input().split())
py = [[int(i) for i in input().split()] for j in range(m)]
pre = {}
for i in range(m):
    cur_p = py[i][0]
    cur_p_cities = pre.get(cur_p,[])
    cur_p_cities.append(i)
    pre[cur_p] = cur_p_cities

for i in pre.keys():
    pre[i].sort(key=lambda x:py[x][1])
    city_order = tuple(range(1,len(pre[i])+1))
    pre[i] = dict(zip(pre[i],city_order))

city_nums = []
for i in range(m):
    p = py[i][0]
    x = pre[py[i][0]][i]
    ans = "{:0>6d}".format(p)+"{:0>6d}".format(x)
    city_nums.append(ans)
    
for c_n in city_nums:
    print(c_n)

Measured memory_bytes: 69608
fn input() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_string()
}

fn main() {
    let line = &input();
    let mut seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    sort(&mut seg);
}

fn sort(line: &mut Vec<i32>) {
    line.sort_by(|a, b| a.cmp(b));
    println!("{}", line.iter().map(|x| x.to_string()).collect::<Vec<String>>().join(" "));
    // println!(
    //     "{}",
    //     line.iter()
    //         .map(|&x| x.to_string() + &' '.to_string())
    //         .collect::<String>()
    //         .trim()
    //         .to_string()
    // );
}


Measured memory_bytes: 5036
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M, C;
    cin >> N;
    cin >> M;
    cin >> C;

    vector<int> B(M);
    for (int i = 0; i < M; ++i)
    {
        cin >> B[i];
    }

    int nCorrect = 0;
    for (int i = 0; i < N; ++i)
    {
        int sum = 0;
        for (int j = 0; j < M; ++j)
        {
            int a;
            cin >> a;
            sum += a * B[j];
        }
        if (sum > -C) {
            nCorrect += 1;
        }
    }

    cout << nCorrect;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while ( cin >> N, N ) {
		vector<P> v;
		REP(i, N) {
			int h, r; cin >> h >> r;
			v.pb( P(h, r) );
		}
		int M; cin >> M;
		REP(i, M) {
			int h, r; cin >> h >> r;
			v.pb( P(h, r) );
		}
		sort( ALL(v) );
		N += M;
		vector< vector<int> > dp(N+1, vector<int>(N+1, -1)); dp[0][0] = 0;
		REP(i, N) {
			REP(j, N+1) {
				if (dp[i][j] < 0) continue;
				dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
				if (j == 0 || (v[j-1].first < v[i].first && v[j-1].second < v[i].second)) {
					dp[i+1][i+1] = max(dp[i+1][i+1], dp[i][j]+1);
				}
			}
		}
		int ans = -1;
		REP(i, N+1) ans = max(ans, dp[N][i]);
		cout << ans << endl;
	}
}

Measured memory_bytes: 3148
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <math.h>
#include <map>
#include <set>
#define sc scanf
#define pr printf
using namespace std;
typedef long long ll;
const int N = 100000+100;
bool ans[N];
char str[N];
bool hander_ans(int n);
bool is_right(int check_index , int rh , int lh);
int main()
{
    int i,j,n;
    while(~sc("%d",&n))
    {
        sc(" %s",str);

        ans[0] = 0 , ans[1] = 0;
        if(hander_ans(n)) continue;

        ans[0] = 0 , ans[1] = 1;
        if(hander_ans(n)) continue;

        ans[0] = 1 , ans[1] = 0;
        if(hander_ans(n)) continue;

        ans[0] = 1 , ans[1] = 1;
        if(hander_ans(n)) continue;

        pr("-1\n");
    }
    return 0;
}
bool is_right(int check_index , int rh , int lh)
{
    if(ans[check_index] == 0)
    {
        if(str[check_index] == 'o' && ans[rh] == ans[lh]) return 1;
        if(str[check_index] == 'x' && ans[rh] != ans[lh]) return 1;
    }
    else
    {
        if(str[check_index] == 'o' && ans[rh] != ans[lh]) return 1;
        if(str[check_index] == 'x' && ans[rh] == ans[lh]) return 1;
    }
    return 0;
}
bool hander_ans(int n)
{
    int i,j;
    for(i=2; i<n; i++)
    {
        if(ans[i-1] == 0)
        {
            if(str[i-1] == 'o')
                ans[i] = ans[i-2];
            else
                ans[i] = !ans[i-2];
        }
        else
        {
            if(str[i-1] == 'o')
                ans[i] = !ans[i-2];
            else
                ans[i] = ans[i-2];
        }
    }
    int flag = 0;
    if(is_right(n-1,0,n-2)) flag++;
    if(is_right(0,1,n-1)) flag++;
    if(flag == 2)
    {
        for(i=0; i<n; i++)
          if(ans[i]) pr("W");
          else pr("S");
         pr("\n");
         return 1;
    }
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long a =sc.nextLong();
		long b =sc.nextLong();
		long c =sc.nextLong();
		long d=sc.nextLong();
		long ans=0;
		long gcd=gcd(c,d);
		ans+=b-(b/c+b/d-b/(gcd*(c/gcd)*(d/gcd)));
		ans-=a-1-((a-1)/c+(a-1)/d-(a-1)/(gcd*(c/gcd)*(d/gcd)));
		System.out.println(ans);
	}
	private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}



Measured memory_bytes: 22868
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <numeric>
#include <set>
#include <unordered_set>
#include <queue>
#include <boost/math/constants/constants.hpp>
#include <boost/math/common_factor_rt.hpp>
 
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define FOR(i, n, m) for(int i=n; i<m; ++i)
 
int main() {
  ll K;
  string S;
  cin >> K >> S;
  ll l = S.length();
  
  if(l <= K){
    cout << S << endl;
  }else{
    rep(i, K){
      cout << S[i];
    }
    cout << "..." << endl;
  }
  
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<int> item;
  int a;
  for(int i=0; i<n; i++){
    cin >> a;
    item.push(a);
  }
  for(int i=0; i<m; i++){
    int ticket;
    ticket = item.top()/2;
    item.pop();
    item.push(ticket);
  }
  long long int ans;
  for(int i=0; i<n; i++){
    ans += item.top();
    item.pop();
  }
  cout << ans << endl;
}

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

long long int dp[1001][10000] = {};

int main() {

    long long int n, m;
    cin >> n >> m;

    for ( long long int i = 0; i <= m; i++ ) {
        for ( long long int j = 0; j < ( 1 << n ); j++ ) {
            dp[i][j] = 1145141919LL;
        }
    }

    dp[0][0] = 0;
    for ( long long int i = 0; i < m; i++ ) {
        long long int a, b;
        cin >> a >> b;
        long long int c = 0;
        for ( long long int j = 0; j < b; j++ ) {
            long long int in;
            cin >> in;
            in--;
            c |= ( 1 << in );
        }
        for ( long long int j = 0; j < ( 1 << n ); j++ ) {
            dp[i+1][j] = min( dp[i+1][j], dp[i][j] );
            dp[i+1][j|c] = min( dp[i+1][j|c], dp[i][j] + a );
        }
    }
/*
    for ( long long int i = 0; i <= m; i++ ) {
        for ( long long int j = 0; j < ( 1 << n ); j++ ) {
            cout << " " << dp[i][j];
        }
        cout << endl;
    }
*/
    long long int ans = dp[m][(1<<n)-1];
    if ( ans >= 1145141919LL ) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;

}


Measured memory_bytes: 77184
import sys
S = input()

for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == 'R' or S[i] == 'U' or S[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()
    else:
        if S[i] == 'L' or S[i] == 'U' or S[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()

print('Yes')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;

using namespace std;

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

  unordered_map<string, int> M;
  unordered_set<string> S;
  vector<string> vec;
  int max = 0;

  rep(i, n) {
    string s;
    cin >> s;
    M[s]++;
    if (M[s] > max) {
      max = M[s];
      vec.clear();
      vec.push_back(s);
      S.clear();
      S.insert(s);
    }
    if (M[s] == max) {
      if (S.count(s) == 0) {
        vec.push_back(s);
      }
    }
  }

  sort(vec.begin(), vec.end());
  for(string v: vec) {
    cout << v << endl;
  }
  
}


Measured memory_bytes: 27192
#include<stdio.h>
int main()
{
  unsigned long long int b=0;
  int a,c;
  scanf("%d",&a);
  for(c=1;c<=a;c++)
    if(c%3!=0&&c%5!=0) b=b+c;
  printf("%lld\n",b);
    return 0;
}

Measured memory_bytes: 1728
n,m = map(int,input().split())
gates = [list(map(int,input().split())) for _ in range(m)]
l = []
r = []
for gate in gates:
    l.append(gate[0])
    r.append(gate[1])
ans = min(r)+1 - max(l)
print(ans if ans > 0 else 0)

Measured memory_bytes: 29088
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()

//typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18; // segment tree size
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f; // memset(dp, 0x3f, sizeof(dp)), 2*INF < INT_MAX
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10; // double EPS

int main() {
	int A, B, C;
	scanf("%d %d %d", &A, &B, &C);

	if (A + B >= C) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip> 

using namespace std;

int main(){
    int N;
    double ans = 0;
    cin >> N;
    for(int i = 0 ; i < N; i++){
        double x;
        string u;
        cin >> x;
        cin >> u;
        if(u[0] == 'J') ans += x;
        else ans += 380000*x;
    }
    cout << fixed<< std::setprecision(5) << ans << endl;
}

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

using namespace std;

int main() {
    string s,t;
    cin>>s>>t;
    int answer = 0;
    for(int i=0 ; i<s.length() ; ++i) {
        if(s[i] != t[i]) answer++;
    }
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 3840
import java.util.Scanner;

public class Main {
	public void run() {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();

		int count = 0;
		for(int i = 0; i <= a; i++) {
			if(x < 500 * i) {
				continue;
			}
			for(int j = 0; j <= b; j++) {
				int remain = x - (500 * i + 100 * j);
				if(remain < 0) {
					continue;
				}
				if(remain / 50 <= c) {
					count++;
				}
			}
		}

		System.out.println(count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
 
#include <cstdio>
#include <cstdlib>
#include <cmath>
 
#include <iostream>
 
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
const ll mod = 1000000007;
 
class mint{
public:
  ll x;
  mint(ll x=0) : x(x%mod){}
  mint& operator+=(const mint rhs){
    x += rhs.x;
    while(x >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint rhs){
    x -= rhs.x;
    while(x < 0) x += mod;
    return *this;
  }
  mint & operator*=(const mint rhs){
    (x *= rhs.x) %= mod;
    return *this;
  }
  mint operator+(const mint rhs) const {
    mint res(*this);
    return res += rhs;
  }
  mint operator-(const mint rhs) const {
    mint res(*this);
    return res -= rhs;
  }
  mint operator*(const mint rhs) const {
    mint res(*this);
    return res *= rhs;
  }
  bool operator>(const ll rhs) const {
    return x > rhs;
  }
  bool operator<(const ll rhs) const {
    return x < rhs;
  }
  bool operator>=(const ll rhs) const {
    return x >= rhs;
  }
  bool operator<=(const ll rhs) const {
    return x <= rhs;
  }
  bool operator==(const ll rhs) const {
    return x == rhs;
  }
  bool operator!=(const ll rhs) const {
    return x != rhs;
  }
  friend ostream& operator<<(ostream& os,const mint rhs){
    os << rhs.x;
    return os;
  }
};
 
#define rep(index,num) for(int index=0;index<num;++index)
 
int main(){
  ll N,K;
  std::cin >> N >> K;
  ll A[N];
  rep(i,N) std::cin >> A[i];
 
  bool visited[N];
  for(int i=0;i<N;i++) visited[i] = false;
  ll now = 1;
  std::vector<ll> root;
  while(!visited[now-1]){
    root.push_back(now);
    visited[now-1] = true;
    now = A[now-1];
  }
  //for(int i=0;i<root.size();i++) std::cout << root[i] << " -> "; std::cout << std::endl;
  std::vector<ll> head,tail;
  ll i = 0;
  while(now != root[i]){
    head.push_back(root[i]);
    i++;
  }
  for(;i<root.size();i++){
    tail.push_back(root[i]);
  }
  if(K<head.size()){
    std::cout << head[K] << std::endl;
    return 0;
  }else{
    K -= head.size();
    std::cout << tail[K%tail.size()] << std::endl;
    return 0;
  }
}


Measured memory_bytes: 9532
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>



int main() {
  long i, j, k, num = 0, ans0 = 0, ans1 = 0, N, K, A[1000] = { 0 };
  scanf("%ld %ld", &N, &K);
  ans0 = N % K;
  ans1 = K - ans0;
  if (ans0 < ans1) printf("%ld", ans0);
  else             printf("%ld", ans1);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

bool is_prime(int x) {
    if(x < 2){
        return false;
    }
    else{
        for(int i = 2; i * i <= x; i++){
            if (x % i == 0) {
            return false;
            }
        }
        return true;
    }
}

int main(){
    int x;
    cin >> x;

    int prime = x;
    for(int i = 0; i < 100003; i++){
        if(!is_prime(prime)){
            prime++;
        }
    }
    cout << prime << endl;
}

Measured memory_bytes: 256
#include<cstdio>
double ans,k;
int n;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%lf",&k);
		ans+=1.00/k;
	}
	printf("%.10lf",1.00/ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s, t;
  cin >> s >> t;
  string ans;
  if(s.size() > t.size())
    ans = "GREATER";
  else if(s.size() < t.size())
    ans = "LESS";
  else {
    if(s > t)
      ans = "GREATER";
    else if(s < t)
      ans = "LESS";
    else
      ans = "EQUAL";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include <time.h>
using namespace std;
#include <math.h>
#define ll long long 
// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define max1 1000007
long long int mod =1e9+7;


int main(){	
//ios_base::sync_with_stdio(false);
	int x[5];
	for (int i = 0; i < 5; ++i)
	{
		cin>>x[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if(x[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}




		
}

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


int main(){
  string s;
  cin >> s;
  map<char, int> mp;
  for(auto e : s) mp[e]++;
  bool f = true;
  for(auto e : mp){
    if(e.second != 1) f = false;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define dbug(x) cout<<#x<<"="<<x<<endl
#define m0(x) memset(x,0,sizeof(x))
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef long long ll;
typedef pair<ll, ll> pl;

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

int main(){

  int N;
  cin >> N;

  vector<int> d(N);

  cin>>d;

  SORT(d);

  int mn,mx;
  int sum;

  mn=d[(N/2)-1];
  mx=d[(N/2)];

  cout << mx-mn <<endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;

int main()
{
  int H, W, D; scanf("%d %d %d", &H, &W, &D);
  int N = H * W;
  vector<pair<int, int>> pos(N + 5);
  for (int r = 1; r <= H; ++r) {
    for (int c = 1; c <= W; ++c) {
      int num; scanf("%d", &num);
      pos[num] = make_pair(r, c);
    }
  }
  vector<int> runsum(H * W + 5, -1);
  for (int start = 1; start <= D; ++start) {
    if (runsum[start] != -1) { continue; }
    runsum[start] = 0;
    for (int cur = start; cur + D <= N; cur += D) {
      int next = cur + D;
      runsum[next] = runsum[cur] + abs(pos[cur].first - pos[next].first) +
        abs(pos[cur].second - pos[next].second);
    }
  }

  int Q; scanf("%d", &Q);
  while (Q-- > 0) {
    int L, R; scanf("%d %d", &L, &R);
    int ans = runsum[R] - runsum[L];
    printf("%d\n", ans);
  }
  return 0;
}


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

int main(){
int n,c=0;
cin >> n;
int a[n];
for(int i=1;i<=n;i++)
  cin >> a[i]; 

for(int i=1;i<=n;i++)
  if(a[i]!=i && c==0)
  {	c=1;
    int t= a[i];
    a[i] = a[t];
	a[t] = t;
    
  }

for(int i=1;i<=n;i++)
  if(a[i]!=i){cout << "NO"; return 0;}
    
cout << "YES";
return 0;
}


Measured memory_bytes: 256
//By: Luogu@rui_er(122461)
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;

string s, t;
int ans = inf;

int main() {
	cin>>s>>t;
	int l1 = s.length(), l2 = t.length();
	for(int i=0;i<l1-l2+1;i++) {
		int _ = 0;
		for(int j=0;j<l2;j++) {
			if(s[i+j] != t[j]) {
				++_;
				if(_ >= ans) break;
			}
		}
		ans = min(ans, _);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3768
import math
 
A, B, H, M = map(int, input().split())
#時針の角度(H / 12 + M / 60 / 12)　- 分針の角度(M / 60)
angle = abs((H / 12 + M / 60 / 12) - (M / 60)) * 2 * math.pi
ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(angle))
print(ans)

Measured memory_bytes: 9560
#include<iostream>
using namespace std;
#include <vector>
#define re(i,n) for(int i = 0; i < n; i++)

int main() {
	int n;
	int p = 1;
	cin >> n;
	
	if (n < 10) cout << n << endl;
	else if (n < 100) cout << 9 << endl;
	else if (n < 1000) cout << 9 + (n - 99) << endl;
	else if (n < 10000) cout << 909 << endl;
	else if (n < 100000) cout << 909 + n - 9999 << endl;
	else cout << 90909 << endl;
	
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;


int main(void){
    int n;
    cin >> n;
    
    vector<int> a(n+1);
    vector<int>  ans(n+1);
    for (int i = 1; i < n+1; i++)
    {
        cin >> a.at(i);
        ans.at(a.at(i))=i;
    }
    
    for (int  i = 1; i < n+1; i++)
    {
        cout << ans.at(i)<<" ";
    }
    cout  << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int K;
  cin >> K;
  vector<set<ll> > vse(12);
  rep(j, 9) vse[1].insert(j+1);
  REP(i, 2, 11) {
    for(ll v: vse[i-1]) {
      int tmp = v % 10;
      if(tmp != 0) vse[i].insert(v*10+tmp-1);
      vse[i].insert(v*10+tmp);
      if(tmp != 9) vse[i].insert(v*10+tmp+1);
    }
  }
  int tmp = 1;
  while(K > 0) {
    if(K > vse[tmp].size()) {
      K -= vse[tmp].size();
      tmp++;
    } else {
      auto itr = vse[tmp].begin();
      rep(i, K-1) itr++;
      cout << *itr << endl;
      break;
    }
  }
  return 0;
}


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

using namespace std;

int main(){

    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<iostream>
#include<string>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int h, w;
    cin >> h >> w;
    string s[h];
    rep(i, h) cin >> s[i];
    int a[h][w];
    int r[h][w], l[h][w], u[h][w], d[h][w];
    rep(i, h)rep(j, w){
        if (j == 0) {
            if (s[i][j] == '.') l[i][j] = 1;
            else l[i][j] = 0;
        }else{
            if (s[i][j] == '.') l[i][j] = l[i][j-1] + 1;
            else l[i][j] = 0;
        }
    }
    rep(i, h)rep(j, w){
        if (j == 0) {
            if (s[i][w-j-1] == '.') r[i][w-j-1] = 1;
            else r[i][w-j-1] = 0;
        }else{
            if (s[i][w-j-1] == '.') r[i][w-j-1] = r[i][w-j] + 1;
            else r[i][w-j-1] = 0;
        }
    }
    rep(j, w)rep(i, h){
        if (i == 0) {
            if (s[i][j] == '.') u[i][j] = 1;
            else u[i][j] = 0;
        }else{
            if (s[i][j] == '.') u[i][j] = u[i-1][j] + 1;
            else u[i][j] = 0;
        }
    } 
    rep(j, w)rep(i, h){
        if (i == 0) {
            if (s[h-i-1][j] == '.') d[h-i-1][j] = 1;
            else d[h-i-1][j] = 0;
        }else{
            if (s[h-i-1][j] == '.') d[h-i-1][j] = d[h-i][j] + 1;
            else d[h-i-1][j] = 0;
        }
    }  
    // rep(i, h){
    //     rep(j, w) cout << d[i][j] << " " ;
    //     cout << endl;
    // }
    int ans = 0;
    rep(i, h)rep(j, w){
        int light = r[i][j] + l[i][j] + u[i][j] + d[i][j] - 3;
        if (light > ans) {
            ans = light;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 66816
import numpy as np

N = int(input())
X = [int(i) for i in input().split()]

xmin = min(X)
xmax = max(X)

vmin = 1e6
for i in range(xmin, xmax+1):
    v = sum((np.array(X) - i) ** 2)
    if v < vmin:
        vmin = v

print(vmin)


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

int sum(char *buf){
	char *p = buf;
	int sum = 0;
	while(*p != 0){
		if('0' <= *p && *p <= '9'){
			sum += *p - '0';
		}
		p++;
	}
	return sum;
}

int main(int argc, char *argv[]){
	char buf[1000+2];
	while(1){
		cin.getline(buf,sizeof(buf));
		if (buf[0] == '0')break;
		cout << sum(buf) << endl;
	}
}

Measured memory_bytes: 3068
import sys
sys.setrecursionlimit(10 ** 6)


N = int(input())
ans = []
a = ord('a')


def f(c, A):
    global N, a
    if 0 not in A:
        ans.append(''.join(A))
        return
    B = list(A)
    idx = B.index(0)
    B[idx] = c
    if 0 not in B:
        ans.append(''.join(B))
        return

    for i in range(2 ** (B.count(0)) - 1, -1, -1):
        k = i
        C = B[:]
        idx = C.index(0)
        while k > 0:
            if k & 1 == 1:
                C[idx] = c
            if 0 in C[idx + 1:]:
                idx = C.index(0, idx + 1)
            k >>= 1
        f(chr(ord(c) + 1), tuple(C))



A = [0] * N
f('a', tuple(A))
ans = list(ans)
ans.sort()
print(*ans, sep='\n')


Measured memory_bytes: 93276
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b; cin >> a>> b;
    cout << (a+b)/2 << endl;
}





Measured memory_bytes: 3080
N = gets.to_i 
S = gets.chomp

=begin
文字列を一文字ずつnextメソッドで入力された整数 N 分アルファベットを進めて
代入していく。
=end

str = ""

S.length.times do |i|
    c = S[i]
    num = 0

    while num < N
        c.next!
        if c=="AA"
            c="A"
        end
        num+=1
    end

    str+=c

end

puts(str)


Measured memory_bytes: 13820
#include <bits/stdc++.h>
#include <functional>
#include <iostream>
#define  pb push_back
#define  xx first
#define  yy second
#define PI acos(-1)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define NL printf("\n")
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


int dp[102][1002];
int inf  = 100000009;
int N,M;
int a[101][101];
int solve(int n, int m){

        if(n>=N || m>=M){
            return inf;
        }

        if(dp[n][m]!=-1) return dp[n][m];

        dp[n][m]=min(solve(n-1,m) , solve(n,m-1))+a[n][m];
        return dp[n][m];
}
int sum[101][101];

int main()
{
      //fast;
     int t=1;
    // cin >> t;

    while(t--)
    {
      int n,m;

         double N;
        cin >> N;
          double r = (double)(N/3.0);
          double  ans = r*r*r;
          printf("%.10lf\n",ans);
     }

          return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int h,w; cin >> h >> w;
    vector<vector<char>> s(h+2,vector<char> (w+2));
    rep(i,h+2){
        rep(j,w+1){
            if(i == 0 || j == 0 || i == h+1 || j == w+1) s[i][j] == '.';
            else cin >> s[i][j];
        }
    }

    bool ans = true;
    int dx[4] = {0, 1, 0, -1};
    int dy[4] = {1, 0, -1, 0};
    rep1(i,h+1){
        rep1(j,w+1){
            if(s[i][j] == '#'){
                bool can = false;
                rep(k,4){
                    if(s[i+dy[k]][j+dx[k]] == '#') can = true;
                }
                if(!(can)) ans = false;
            }
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
using ll = long long;
int main()
{
    int n,m;
    cin >> n >> m;
    int a[n];
    int sum = 0;
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    sort(a,a + n,greater<int>());
    if(a[m - 1]  / (double)sum >= 1.0 / (4.0 * m))
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    ll h,n;
    cin >> h >> n;
    vector<pair<ll,ll>> magic(n);
    ll a,b;
    rep(i,n){
        cin >> a >> b;
        magic[i] = make_pair(a,b);
    }
    vector<ll> dp(h+1);
    dp[0]=0;
    for(ll i=1; i<=h; i++){
        dp[i]=magic[0].second + dp[max(0LL,i-magic[0].first)];
        for(auto m: magic){
            dp[i]=min(dp[i], m.second + dp[max(0LL,i-m.first)]);
        }
    }
    cout << dp[h] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int n, m, q;
int a[55], b[55], c[55], d[55];
int A[10] = {};
int dfs(int *A, int j)
{
    if (j == n)
    {
        int ans = 0;
        for (int i = 0; i < q; i++)
        {
            if (A[b[i]] - A[a[i]] == c[i])
            {
                ans += d[i];
            }
        }
        return ans;
    }
    int max = 0;
    for (int i = A[j - 1]; i <= m; i++)
    {
        A[j] = i;
        int t = dfs(A, j + 1);
        max = (max > t) ? max : t;
    }
    return max;
}
int main()
{
    scanf("%d %d %d", &n, &m, &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d %d %d", &a[i], &b[i], &c[i], &d[i]);
        a[i]--;
        b[i]--;
    }
    A[0] = 1;
    printf("%d", dfs(A, 1));
    return 0;
}

Measured memory_bytes: 1736
X = int(input())
if X >= 400 and X<600:
    print(8)
elif X >= 600 and X<800:
    print(7)
elif X >= 800 and X<1000:
    print(6)
elif X >= 1000 and X<1200:
    print(5)
elif X >= 1200 and X<1400:
    print(4)
elif X >= 1400 and X<1600:
    print(3)
elif X >= 1600 and X<1800:
    print(2)
elif X >= 1800 and X<2000:
    print(1)

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


vector<string> deduplicate(vector<string> a) {
    sort(a.begin(),a.end());
    auto itr=unique(a.begin(),a.end());
    a.resize(itr-a.begin());
    return a;
}


int main() {
    string s;
    cin >> s;
    int n=s.size();
    int k;
    cin >> k;
    vector<string> t;
    rep(i,n) {
        string tmp;
        rep(j,min(n-i,k)) {
            tmp.push_back(s[i+j]);
            t.push_back(tmp);
        }
    }
    sort(t.begin(),t.end());
    vector<string> dt=deduplicate(t);
    cout << dt[k-1] << endl;
}

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

int main()
{
	int arrayLength, buffer;
	scanf("%d", &arrayLength);
	int *intArray = (int *)calloc(arrayLength, sizeof(int));

	for (int i = 0; i < arrayLength; i++)
	{		
		scanf("%d", &buffer);
		intArray[i] = buffer;
	}

	for (int i = 0; i < arrayLength; i++)
	{
		if (intArray[i] % 2 == 0)
		{
			if (intArray[i] % 5 == 0)
			{
				continue;
			}
			else if (intArray[i] % 3 == 0)
			{
				continue;
			}
			else
			{
				printf("DENIED \n");
				return 0;
			}	
		}
	}
	printf("APPROVED \n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <utility>
using namespace std;
int main()
{
    int x, y, z;

    cin >> x >> y >> z;

    if (x > y)
    {
        swap(x, y);
    }
    if (y > z)
    {
        swap(y, z);
    }
    if (x > y)
    {
        swap(x, y);
    }

    cout << x << " " << y << " " << z << endl;
}


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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

#define F first
#define S second

LL binpow (LL x, LL p , LL m) {
	x %= m;
	LL res = 1;
	while (p) {
		if (p&1) {
			res = res * x % m;
		}
		x = x* x % m;
		p >>= 1;
	}
	return res;
}

int main() {
	fastio();
	
	LL n;
	cin >> n;

	vector<pair<LL, LL>> vp(n);

	LL min1 = INF, max1 = -INF, min2 = INF, max2 = -INF;
	map<LL, LL> mp1, mp2;
	for (auto &e : vp) {
		cin >> e.F >> e.S;
		min1 = min(min1, e.F + e.S);
		max1 = max(max1, e.F + e.S);
		min2 = min(min2, e.F - e.S);
		max2 = max(max2, e.F - e.S);
	}

	cout << max(max2-min2, max1-min1) << "\n";

	

}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k ; 
  cin >> n >> k ;
  vector<intll> d(n) ; 
  rep(i,n) cin >> d.at(i) ;

  for(int i=k; i<n ; i++){
    if(d.at(i-k) < d.at(i) ){
      cout << "Yes" << endl ; 
    }
    else {
      cout << "No" << endl ;
    }
    
  }
 
}


Measured memory_bytes: 4784
N=int(input())
A=list(map(int,input().split()))
B=[[0]*2 for i in range(N)]
for i in range(N):
    B[i][0]=i+1
    B[i][1]=A[i]

C=sorted(B,key=lambda x:x[1])

for i in range(N):print(str(C[i][0])+' ',end="")


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

#define int long long 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define INF 1e9+1



//time complexity will be O(N^2*V) space complexity will be O(N^2*V)

class item{
    public:
    int val;
    int wt;
};

int N,W;
item arr[105];

int solve(){
    //dp[n][w]  max_val that we can obtain by having n number of items and max_capacity of knapsack is w

    //first look at the base cases
    int dp[N+1][W+1];

    for(int w=0;w<=W;w++) {
        //if the max_capacity of knapsack is less than the wt of the first item then the only option left is to exclude that item
        if(arr[1].wt>w) dp[1][w]=0;
        //otherwise just take that item and our max_val that we can obtain is equal to the val of the first item
        else dp[1][w]=arr[1].val;
    }
    for(int i=2;i<=N;i++){
        for(int w=0;w<=W;w++){
            dp[i][w]=dp[i-1][w];
            if(arr[i].wt>w) continue;
            dp[i][w]=max(dp[i][w],arr[i].val+dp[i-1][w-arr[i].wt]);
        }

    }
    return dp[N][W];
}

int32_t main(){
    cin>>N>>W;
    for(int i=1;i<=N;i++) cin>>arr[i].wt>>arr[i].val;
    cout<<solve()<<endl;
}

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

int main(){
    ll n,ans=0,ans2=0,mins = INT_MAX,temp=0;
    cin >> n;
    ll arr[n+5];
    for(int i=0; i<n; i++){
        cin >> arr[i];
        temp = arr[i];
        if(temp<0)temp*=-1;
        mins = min(temp,mins);
        ans2+=temp;
        //cout << ans2 << endl;
    }
    for(int i=0; i<n-1; i++){
        if(arr[i]<0){
           arr[i]*=-1,arr[i+1]*=-1;
        }
    }
    for(int i=0; i<n; i++){
        //cout << arr[i] << endl;
        ans +=arr[i];
    }
    ans2 = ans2-(mins*2);
    if(ans > ans2) {
        cout << ans << endl;
    } else cout << ans2 << endl;
}


Measured memory_bytes: 1024
n = int(input())
t = []
ans = 1
for i in range(n):
    t.append(int(input()))
def gcd(a,b):
    while b>0:
        a,b = b, a%b
    return a
def lcm(a,b):
    return a*b//gcd(a,b)

for i in range(n):
    ans = lcm(ans,t[i])

print(ans)

Measured memory_bytes: 3064
def main():
    """
    2 <= N <= 10^5
    1 <= M <= 10^5
    1 <= ai < bi <= N
    (ai, bi) != (aj, bj)
    """
    N, M = map(int, input().split())
    A, B = zip(*[
        map(int, input().split())
        for _ in range(M)
    ])
    # ans = WA(N, M, A, B)
    ans = editorial(N, M, A, B)
    # ans = TLE(N, M, A, B)

    print(ans)


def editorial(N, M, A, B):
    ans1 = AC_b_sort(N, M, A, B)
    ans2 = AC_a_sort(N, M, A, B)
    assert ans1 == ans2
    return ans1


def AC_b_sort(N, M, A, B):
    ab = sorted(zip(A, B), key=lambda x: (x[1], x[0]))
    ans = 0
    bef_b = 0
    for a, b in ab:
        # print(" " * (a-1), a, "-" * (b - a - 1), b, sep="")
        if bef_b <= a:
            ans += 1
            bef_b = b

    return ans


def AC_a_sort(N, M, A, B):
    ab = sorted(zip(A, B), key=lambda x: (x[0], -x[1]))
    ans = 0
    bef_b = float("inf")
    for a, b in ab:
        # print(" " * (a-1), a, "-" * (b - a - 1), b, sep="")
        if bef_b <= a:
            ans += 1
            bef_b = b
        else:
            bef_b = min(bef_b, b)

    return ans + 1


def TLE(N, M, A, B):
    """
    """
    ans = N - 1
    for a in A:
        for b in B:
            pass

    return ans


def WA(N, M, A, B):
    """
    ai, bi の分断:

    入力例1
        1, 4 の分断
            橋1-3 のどれかを除去
        2, 5 の分断
            橋2-4 のどれかを除去
        共通部: 2-3
        要望ごとの共通部を探す必要がある
            M^2: TLE

    A_min: 西
    A_max: 東
    B_min: 西
    B_max: 東

    入力例2
    9 5
    1------8
     2----7
      3-5
       4-6
          7-9

    a_min,b_max の順に並べる
    要望の東側が以前の西側未満ならOK
    要望の西側が以前の東側を超えないならOK ?
    """
    ab = sorted(zip(A, B), key=lambda x: (x[0], -x[1]))
    ans = 0
    bef_a, bef_b = -1, float("inf")
    for i, (a, b) in enumerate(ab):
        print(" " * (a-1), a, "-" * (b - a - 1), b, sep="")
        if bef_a <= a < b <= bef_b:
            pass
        elif bef_b <= a:
            ans += 1
        elif bef_a < a < bef_b < b:
            pass

        bef_a, bef_b = a, b

    return ans + 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 57472
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) throws IOException {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        int numberDigitTotal = 0;

        for(int i = 0; i < s.length(); i++)
        {
            numberDigitTotal += Integer.parseInt(s.substring(i,i + 1));
        }

        if(numberDigitTotal % 9 != 0)
        {
            System.out.println("No");
        }
        else
        {
           System.out.println("Yes");
        }
    }
}




Measured memory_bytes: 50740
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())
#define VI(a,n) vi a(n); rep(i,n)cin>>a[i]
#define sq(n) (n)*(n)

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w,k;
    cin>>h>>w>>k;
    vvi dp(h+1,vi(w));
    dp[0][0]=1;
    rep(i,h){
        rep(j,w){
            rep(k,1<<(w-1)){
                bool f=true;
                rep(l,w-2){
                    if((k&(1<<l))&&(k&(1<<(l+1))))f=false;
                }
                if(!f)continue;
                if(j>0&&(k&(1<<(j-1)))){
                    dp[i+1][j-1]+=dp[i][j];
                    dp[i+1][j-1]%=mod;
                }
                else if(j<w-1&&(k&(1<<j))){
                    dp[i+1][j+1]+=dp[i][j];
                    dp[i+1][j+1]%=mod;
                }
                else{
                    dp[i+1][j]+=dp[i][j];
                    dp[i+1][j]%=mod;
                }
            }
        }
    }
    cout<<dp[h][k-1]<<endl;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)

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

    int tmp_max = max( a * 10 + b + c, a + b * 10 + c); 
    cout << max(tmp_max, c * 10 + a + b) << endl;

    return 0;
}


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

typedef pair<int,int> P;

int main(){
    int a,b;
    cin >> a >> b;
    int chii = min(a,b);
    int dai = max(a,b);
    for (int i = 0; i < dai; i++){
        cout << chii;
    }
    cout << "\n";
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
x=[]
for i in range(m):
    b,c=map(int,input().split())
    x.append([b,c])
y=sorted(x,key=lambda x:(x[1],x[0]),reverse=True)

d=[]
cnt=0
for i in range(m):
    cnt+=y[i][0]
    d.extend([y[i][1]]*y[i][0])
    if cnt>n:
        break

for i in range(n):
    if len(d)<=i:
        break
    if d[i]>a[i]:
        a[i]=d[i]
    else:
        break
print(sum(a))

Measured memory_bytes: 33860
#include <iostream>
#include <climits>
using namespace std;
int main() {
    int e;
    while (cin >> e, e) {
        int mx = INT_MAX;
        for (long long z=0; z*z*z<=e; ++z) {
            for (long long y=0; y*y+z*z*z<=e; ++y) {
                long long x = e - z*z*z - y*y;
                if (x + y + z < mx) {
                    mx = x + y + z;
                }
            }
        }
        cout << mx << endl;
    }
    return 0;
}

Measured memory_bytes: 1160