akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <array>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
  int n;
  cin >> n;
  double ans = 0;
  for(int i=0;i<n;i++){
    double inp; string tanni;
    cin >> inp >> tanni;
    if(tanni == "JPY"){
      ans += inp;
    } else {
      ans += inp * 380000;
    }
  }
  printf("%.16f\n", ans);
}



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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL x, y, z, n, a[100000][3], ans[100000];
typedef pair<LL, int> PP;
PQ<PP> pq[3][3];

PP get(int f, int t) {
	PP p = pq[f][t].top();
	while(ans[p.SE] != f) { pq[f][t].pop(); p = pq[f][t].top(); }
	return p;
}

void add(int i, int v) {
	ans[i] = v;
	inc(j, 3) {
		if(j == v) { continue; }
		pq[v][j].emplace(a[i][j] - a[i][v], i);
	}
}

bool RT(int r) { // r: 1 or 2
	PP e[3];
	inc(j, 3) { e[j] = get(j, (j + r) % 3); }
	
	if(e[0].FI + e[1].FI + e[2].FI <= 0) { return false; }
	inc(j, 3) { add(e[j].SE, (j + r) % 3); }
	return true;
}

bool SW(int f, int t) {
	PP ft = get(f, t);
	PP tf = get(t, f);
	
	if(ft.FI + tf.FI <= 0) { return false; }
	add(ft.SE, t);
	add(tf.SE, f);
	return true;
}

LL calc() {
	LL sum = 0;
	inc(i, n) {
		sum += a[i][ans[i]];
	}
	return sum;
}

int main() {
	cin >> x >> y >> z;
	n = x + y + z;
	inc(i, n) {
	inc(j, 3) {
		cin >> a[i][j];
	}
	}
	
	inc(i, n) {
		int v;
		if(inID(i, 0,     x)) { v = 0; }
		if(inID(i, x, x + y)) { v = 1; }
		if(inID(i, x + y, n)) { v = 2; }
		add(i, v);
	}
	
	// 適当
	inc(x, 8) {
		inc(j, 3) { while(SW(j, (j + 1) % 3)) { } }
		dec(j, 3) { while(SW(j, (j + 1) % 3)) { } }
		while(RT(1)) { }
		while(RT(2)) { }
		while(RT(1)) { }
	}
	
	cout << calc() << endl;
	
	return 0;
}


Measured memory_bytes: 9836
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
    int a;
    int b;
    scanf("%d %d", &a, &b);
    
    if (a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
}



Measured memory_bytes: 3148
/*
    Code written by Talant I.D.
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);

inline bool isvowel(char ch){
    ch = tolower(ch);
    return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}

inline bool isprime(int n){
    if(n < 2 || (n%2 == 0 && n != 2)) return false;
    for(int i = 3; i*i <= n; i += 2)
        if(n%i == 0) return false;
    return true;
}

const int N = 1e5+7;
vector <vector <int> > graph(N);
int dist[N], n, used[N];

void dfs(int v){
    used[v] = 1;
    for(int i = 0; i < graph[v].size(); i++){
        int to = graph[v][i];
        if(!used[to]){
            dfs(to);
        }
        dist[v] = max(dist[v], dist[to]+1);
    }
}

int main(){
    do_not_disturb

    int m, i;
    cin >> n >> m;
    for(i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        graph[x].pb(y);
    }

    for(i = 1; i <= n; i++){
        if(!used[i]){
            dfs(i);
        }
    }

    int mx = 0;
    for(i = 1; i <= n; i++){
        mx = max(mx, dist[i]);
    }
    cout << mx;

    return 0;
}


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

int main()
{
	string s;
	cin >> s;

	if (s == "RRR") {
		cout << 3 << endl;
	}
	else if (s == "RRS" || s == "SRR") {
		cout << 2 << endl;
	}
	else if(s == "SSS"){
		cout << 0 << endl;
	}
	else {
		cout << 1 << endl;
	}

	return 0;
}

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

int main(void)
{
	ios_base::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<int> cnt[n];
	for(int i = 0; i < m; i++) {
                int x, y;
                cin >> x;
                for(int j = 0; j < x; j++) {
                        cin >> y;
                        cnt[y - 1].push_back(i);
                }
	}
	vector<int> p(m);
	for(int i = 0; i < m; i++)
                cin >> p[i];
        int ans = 0;
        for(int i = 0; i < (1 << n); i++) {
                vector<int> z(m, 0);
                for(int j = 0; j < n; j++) {
                        if(i & (1 << j)) {
                                for(int k = 0; k < cnt[j].size(); k++)
                                        z[cnt[j][k]]++;
                        }
                }
                int flag = 1;
                for(int j = 0; j < m; j++)
                        flag = flag & (p[j] == (z[j] % 2));
                ans = ans + flag;
        }
        cout << ans;
	return 0;
}


Measured memory_bytes: 256
package main
import (
	"bufio"
	"fmt"
	"io"
	"os"
	"runtime/debug"
	"strconv"
)
var in = NewScanner(os.Stdin, 0)
func init(){
	debug.SetGCPercent(-1)
}
func main(){
	n, a := in.Double(), in.Double()
	fmt.Printf("%.10f\n", n/a)
}
const M7 = 1000000007
type Scanner struct{
	*bufio.Scanner
}
func NewScanner(r io.Reader, x int) *Scanner{
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if x <= 0{
		x = 1048576
	}
	s.Buffer([]byte{}, x)
	return &Scanner{s}
}
func (s *Scanner) Double() float64{
	s.Scan()
	i, e := strconv.ParseFloat(s.Text(), 64)
	if e != nil{
		panic(e)
	}
	return i
}
func isSpace(b byte) bool{
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(d []byte, e bool) (int, []byte, error){
	s := 0
	for s < len(d) && isSpace(d[s]){
		s++
	}
	for i := s; i < len(d); i++{
		if isSpace(d[i]){
			return i + 1, d[s:i], nil
		}
	}
	if e && len(d) > s{
		return len(d), d[s:], nil
	}
	return s, nil, nil
}
type ByteSlice []byte
type IntSlice []int


Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007

ll N;
vector<ll> a(200010,0);
vector<ll> b(200010,0);


int main() {
    cin >> N;
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    ll ans=0;
    rep(i,30){
        ll num = 0;
        ll T = pow(2,i+1);
        ll S = pow(2,i);
        vector<ll>bb(200010,0);
        rep(p,N) bb[p] = b[p]%T;
        sort(bb.begin(),bb.begin()+N);
        rep(j,N){
            ll inter[4];
            rep(k,4){
                ll temp = lower_bound(bb.begin(),bb.begin()+N,S*(k+1)-(a[j]%T)) - bb.begin();
                inter[k] = temp;
            }
            num += (inter[1]-inter[0])+(inter[3]-inter[2]);
        }
        if (num % 2) ans+=pow(2,i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll l, r, d;
    cin >> l >> r >> d;
    ll cnt = 0;
    for(ll i=l; i<=r; i++){
        if(i%d == 0) cnt++;
    }
    cout << cnt << endl;
}

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

using namespace std;

#define lolo long long

int a, b, h;

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

    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	try {
    		final int N = sc.nextInt();
    		String s = sc.next();

    		int count = 1;
    		for (int i=1; i<N; i++) {
    			if (s.charAt(i) != s.charAt(i-1)) {
    				count++;
    			}
    		}

    		System.out.println(count);

    	} finally {
    		sc.close();
    	}
    }
}



Measured memory_bytes: 24972
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String str=sc.next();
    sc.close();
    int start=0,end=0;
    for(int i=0;i<str.length();i++){
      if(str.charAt(i)=='A'){
        start=i;
        break;
      }
    }
    for(int i=0;i<str.length();i++){
      if(str.charAt(i)=='Z'){
        end=i;
      }
    }
    System.out.println(end-start+1);
  }
}

Measured memory_bytes: 29968
#include<cstdio>

int main(){
	int f[1000001] = {};
	int n;

	for(int i = 2; i < 500001; i++){
		f[i * 2] = 1;
	}

	for(int i = 3; i <= 1000; i += 2){
		for(int j = 2; j * i <= 1000000; j++){
			f[i * j] = 1;
		}		
	}

	int sum;

	while(scanf("%d", &n) + 1){
		int sum = n - 1;
		for(int i = 2; i <= n; i++){
			sum -= f[i];
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define all(x) x.begin(), x.end()
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

int main() {
    Int n, k;
    cin >> n >> k;
    Int res = 0;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    for (Int i = 0; i < n - 1; i++) {
        a[i + 1] += a[i];
    }
    for (Int i = 0; i < n; i++) {
        a[i] %= k;
        //cout << a[i] <<" ";
    }
    //cout << endl;
    map<Int, Int> mp;
    for (Int i = 0; i < min(n, k - 1); i++) {
        mp[a[i]]++;
    }
    mp[0]++;
    for (auto i : mp) {
        res += i.se * (i.se - 1) / 2;
    }
    mp[0]--;
    //dump(res);
    for (Int i = k - 1; i < n; i++) {
        if (k <= i) {
            mp[a[i - k]]--;
        }
        //cout << mp[a[i]] << " ";
        res += mp[a[i]];
      //  dump(res);
        mp[a[i]]++;
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
typedef long long LL;
int main()
{
	int L, R, d;
	cin >> L >> R >> d;
	int cnt = 0;
	for (;L <= R;L++)
	{
		if (L % d == 0)
			cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3188
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => {
  var arry = input.split('\n');
  var result = ''
  for (var i = 0; i < arry.length; i++) {
    var arr = arry[i].split(' ')
    var x = Number(arr[0]-0);
    var y = Number(arr[2]-0);

    var op = arr[1]


    if (op == '+') {
      result+= x + y;
    } else if (op == '-') {
      result+= x - y;
    } else if (op == '*') {
      result+= x * y;
    } else if (op == '/') {
      result+= Math.floor(x / y);
    }
    result+='\n'
  }
  console.log(result.trim());
})



Measured memory_bytes: 15516
#include <bits/stdc++.h>
#define INF 1e9+5
using namespace std;

int main(){
    int N,K,MIN;

    cin>>N>>K;    

    vector<int>h(N);
    vector<int>dp(N);


    for(int& x:h){
        cin>>x;
    }
 
    dp[0]=0;
    for(int i=1;i<N;i++){
        MIN=INF;
        for(int j=1;j<=min(i,K);j++){
            MIN=min(MIN,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i]=MIN;
    }

   cout<<dp[N-1]<<endl;

   return 0;
}

Measured memory_bytes: 1024
x = int(input())
a = []

for i in range(500):
    num = i ** 5
    a.append(num)

for i in range(500):
    for j in range(i, 500):
        if a[i] - a[j] == x:
            ans = str(i) + ' ' + str(j)
            break
        elif a[i] + a[j] == x:
            ans = str(i) + ' -' + str(j)
            break
        elif a[j] - a[i] == x:
            ans = '-' + str(i) + ' -' + str(j)
            break

print(ans)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define ll long long
const int N=100005;
using namespace std;
ll n,f[N][5],l,r,mid,a[N],b[N],c[N];
int main()
{
    cin>>n; 
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    for(int i=1;i<=n;i++) cin>>c[i];
    sort(a+1,a+1+n);
	sort(b+1,b+1+n);
	sort(c+1,c+1+n);
    for(int i=1;i<=n;i++) f[i][1]=i;
    for(int i=1;i<=n;i++)
    {
        l=1,r=n;
        while(l<=r)
        {
            mid=(l+r)/2;
            if(b[i]<=a[mid]) r=mid-1;
            else l=mid+1;
        }
        f[i][2]=f[i-1][2]+f[r][1];
    }
    for(int j=1;j<=n;j++)
    {
        l=1,r=n;
        while(l<=r)
        {
            mid=(l+r)/2;
            if(c[j]<=b[mid]) r=mid-1;
            else l=mid+1;
        }
        f[j][3]=f[j-1][3]+f[r][2];
    }
    cout<<f[n][3];
    return 0;
}

Measured memory_bytes: 6528
import sys
import math
n=int(input())
ans=100000000
N=int(math.sqrt(n))
for a in range(1,N+1):
    b=n//a
    if n==a*b:
        aa=str(a)
        bb=str(b)
        tmp=max(len(aa),len(bb))
        ans=min(ans,tmp)
print(ans)


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


int main(){
  int n;
  cin >> n;
  int ans = 1e9;
  stack<int> vec6, vec9;
  for(int i = 0; i <= n; i++){
    for(int i = 0; i < 9; i++){
      vec6.push(pow(6, i)); vec9.push(pow(9, i));
    }
    int tmp = i;
    int cnt = 0;
    while(tmp){
      int x = vec6.top();
      vec6.pop();
      cnt += tmp / x;
      tmp = tmp % x;
    }
    tmp = n - i;
    while(tmp){
      int x = vec9.top();
      vec9.pop();
      cnt += tmp / x;
      tmp = tmp % x;
    }
    ans = min(ans, cnt);
  }
  cout << ans <<endl;
}
    


Measured memory_bytes: 4148
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,k;
    cin>>n>>k;
    int x=1;
    while(n--)
    {
        if(x<=k)
        {
            x*=2;
        }
        else
        {
            x+=k;
        }
    }
    cout<<x;
    return 0;
}

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

int digit(int n){
  int sum = 0;
  while(n>0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  int curMin = 1e8;
  for(int i = 1; i < n; i++){
    curMin = min(curMin, digit(i)+digit(n-i));
  }
  cout << curMin << endl;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  if((S.at(6) == '1' || S.at(6) == '2'|| S.at(6) == '3'|| S.at(6) == '4') &&(S.at(5) != '1')){
    cout << "Heisei" << endl;
  }
  else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <iterator>
#include <algorithm>
#include <cfenv>
#include <random>
#include <numeric>
#include <cmath>
#include <iosfwd>
#include <iostream>
#include <ios>
#include <streambuf>
#include <istream>
#include <ostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include<string>
#include <bitset>

#define SIZE 1001
typedef long long ll;
using namespace std;

int main(){

    int D,T,S;

    cin >> D >> T >> S;

    if(D <= T*S){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> res = {to[0][0], 0};
  vector<bool> used(n);
  used[0] = used[to[0][0]] = true;
  rep(_, 2) {
    while (true) {
      int now = res.back();
      bool flag = true;
      for (auto next : to[now]) {
        if (!used[next]) {
          res.push_back(next);
          used[next] = true;
          flag = false;
          break;
        }
      }
      if (flag)
        break;
    }
    reverse(res.begin(), res.end());
  }
  cout << res.size() << endl;
  rep(i, res.size()) {
    if (i)
      cout << ' ';
    cout << res[i]+1;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int check(int x,int y, vvi ch) {
  int flg = 1;
  REP(i,8) {
    if(ch[x][i]==1) {
      flg=0;
      break;
    }
    if(ch[i][y]==1)  {
      flg=0;
      break;
    }
    if(x+i<8&&y+i<8) {
      if(ch[x+i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y+i<8) {
      if(ch[x-i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x+i<8&&y-i>=0) {
      if(ch[x+i][y-i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y-i>=0) {
      if(ch[x-i][y-i]==1)  {
      flg=0;
      break;
    }
    }
  }
  return flg;
}

int solution(double t,double p) {
  double f=1.0-(1/1.5)*log(2)*p*pow(2,-t/1.5);
  if(f>=0) return 1;
  else if(f<0) return 0; 
}

int main() {
  char s[101];
  cin >> s;
  int n=strlen(s);
  ll k;
  cin >> k;
  char ans;
  REP(i,n) {
    int x=s[i]-'0';
    ll temp = pow(x,5000000000000000);
    k-=temp;
    if(k<=0) {
      ans=s[i];
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner scan=new Scanner(System.in);
		String str=scan.next();
		int b=scan.nextInt();
		for(int j=0;j<b;j++) {
			String CH=scan.next();
			if(CH.equals("replace")) {
				int a=scan.nextInt();
				int c=scan.nextInt();
				String s=scan.next();
				str=str.substring(0,a)+s+str.substring(c+1,str.length());
			}
			if(CH.equals("reverse")) {
				int a=scan.nextInt();
				int c=scan.nextInt();
				String S=str.substring(a,c+1);
				StringBuffer sb=new StringBuffer(S);
				sb=sb.reverse();
				S=sb.toString();
				str=str.substring(0,a)+S+str.substring(c+1,str.length());
			}
			if(CH.equals("print")) {
				int a=scan.nextInt();
				int c=scan.nextInt();
				System.out.println(str.substring(a,c+1));
			}
		}
	}
}


Measured memory_bytes: 29836
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define dme cout<<-1<<endl;return 0
//ios::sync_with_stdio(false);
//<< setprecision(5)
const int mod=1e9+7;
const int big=1e8+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
int main(void){
	llint a,c;cin>>a>>c;
	cout<<c+c-a<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 1
mod = 10**9 + 7
h = [0 for _ in range(n)]
last = 0
for i in range(n):
    if t[i] != last:
        h[i] = t[i]
        last = t[i]
last = 0
for i in range(n):
    j = n-i-1
    if a[j] != last:
        if (h[j] > 0 and h[j] != a[j]) or a[j] > t[j]:
            ans = 0
            break
        h[j] = a[j]
        last = a[j]
for i in range(n):
    if h[i] == 0:
        ans = ans * min(t[i], a[i]) % mod
print(ans)

Measured memory_bytes: 19136
#include<iostream>
#include<algorithm>
using namespace std;
int a[100000];
int partition(int n,int key) {
	int i = 0;
	for (int j = 0; j < n - 1; j++) {
		if (a[j] <= key) {
			swap(a[i], a[j]);
			i++;
		}
	}
	swap(a[i], a[n - 1]);
	return i;
}
int main(void) {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int k=partition(n, a[n - 1]);
	for (int i = 0; i < n; i++) {
		if (i) cout << " ";
		if (i == k)cout << "[" << a[i] << "]";
		else
		{
			cout << a[i];
		}
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int ans = 0;
  while (N > 0){
    N /= K;
    ans ++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#define MN 10000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
long long s1,s2,need;
int n,a[MN+5],b[MN+5];
int main()
{
    n=read();
    for(int i=1;i<=n;++i) a[i]=read(),s1+=a[i];
    for(int i=1;i<=n;++i) b[i]=read(),s2+=b[i];
    for(int i=1;i<=n;++i) if(a[i]<b[i]) need+=(b[i]-a[i]+1)>>1;
    if(need>s2-s1) return 0*puts("No");
    else puts("Yes");
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w;
    cin >> h >> w;
    if (h==1 or w==1) {
        cout << 1 << endl;
        return 0;
    }
    if (h%2==0){
        cout << w*h/2 << endl;
        return 0;
    }
    cout << w*(h-1)/2 + (w - (w/2)) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <deque>
#include <bits/stdc++.h>
//#include "testlib.h"
using namespace std;
#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)

bool debug=true;

/*    *************************************
	  * Written in New Computer           *
	  * The following code belongs to     *
	  * XiaoGeNintendo of HellHoleStudios *
	  *************************************
*/
template<typename T1,typename T2>ostream& operator<<(ostream& os,pair<T1,T2> ptt){
	os<<ptt.first<<","<<ptt.second;
	return os;
}
template<typename T>ostream& operator<<(ostream& os,vector<T> vt){
	os<<"{";
	for(int i=0;i<vt.size();i++){
		os<<vt[i]<<" ";
	}
	os<<"}";
	return os;
}

ll a,b,c;
int main(int argc,char* argv[]){
	cin>>a>>b>>c;
	if(c-a-b<0){
		cout<<"No";
		return 0;
	}
	if(4*a*b<(c-a-b)*(c-a-b)){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}



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

#define MAX 100

void push(int);
int pop(void);
void isEmpty(void);
void isFull(void);

int top=0,S[1000];

/*void isEmpty(){
  return top=0;
  }*/

/*void isFull(){
  return top >= MAX-1;
  }*/
void push(int x){
  top++;
  S[top]= x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b,i;
  char  s[100];
  while(scanf("%s",s) != EOF){
  
    if(s[0] == '+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0] == '-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0] == '*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(s));
    }
  }
  i = pop();
  printf("%d\n",i);

  return 0;
}

Measured memory_bytes: 548
MODE = "stdio"
require 'matrix'
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = "\
  3 4
  1 2 0 1
  0 3 0 1
  4 1 1 0
  1
  2
  3
  0
  ".split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
m,n =  line[0].split(" ").map(&:to_i)

mat = Array.new
vec = Array.new

(1..m).each do |mm|
  mat<<line[mm].split(" ").map(&:to_i)
end

(1+m..m+n).each do |nn|
  vec<<line[nn].to_i
end

A = Matrix[*mat]
B = Vector[*vec]

puts (A*B).to_a

Measured memory_bytes: 9440
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<ll, II> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 400010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    int a, b, c;
  cin >> a >> b;
	if (a % 2 && b % 2) cout << "Yes";
  else cout << "No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll N,T;
    cin>>N>>T;
    vector<ll> t(N);
    for(ll i=0;i<N;i++){
        cin>>t[i];
    }
    ll ans=0;
    for(ll i=1;i<N;i++){
        ans+=min(t[i]-t[i-1],T);
    }
    cout<<ans+T<<endl;
    return 0;
}

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

int main() {;
  for (int i = 1; i < 10001; i++) {
    int data;
    cin >> data;
    if (data == 0) {
      break;
    }
    else {
      cout << "Case " << i << ": " << data << endl;
    }
  }
}



Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    int h1,m1,h2,m2,k;
    IN h1>>m1>>h2>>m2>>k;
    int mm1=(60*h1)+m1;
    int mm2=(60*h2)+m2;
    int period=mm2-mm1;
    if(mm1>mm2)
    {
        period=1440+period;
    }
    OUT period-k<<endl
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

void b_sunuke_easy(void) {
	int w, h, n;
	int x[110], y[110], a[110];
	int area[110][110] = { 0 };
	cin >> w >> h >> n;
	for (int i = 0; i < n; i++)cin >> x[i] >> y[i] >> a[i];

	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= h; j++) {
			for (int k = 0; k <= w; k++) {
				if (a[i] == 1) {
					if (k < x[i]) area[j][k] = 1;
				}
				else if (a[i] == 2) {
					if (k >= x[i]) area[j][k] = 1;
				}
				else if (a[i] == 3) {
					if (j < y[i]) area[j][k] = 1;
				}
				else {
					if (j >= y[i]) area[j][k] = 1;
				}
			}
		}
      	}
	int cnt = 0;
	for (int j = 0; j < h; j++) {
		for (int i = 0; i < w; i++) {
			if (area[j][i] == 0) cnt++;
			//cout << area[j][i];
		}
		//cout << endl;
	}
	cout << cnt << endl;
}

int main()
{
	b_sunuke_easy();
    return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//C++17以上
template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

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

    ll ans = 0;
    for(int i=0;i<n;i++){
        int tmp = a[i] - b[i];
        //i
        if(tmp >= 0){
            ans += b[i];
            b[i] = 0;
        }else{
            ans += a[i];
            b[i] = b[i] - a[i];
        }
        //i+1
        tmp = a[i+1] - b[i];
        if(tmp >= 0){
            ans += b[i];
            a[i+1] = tmp;
            b[i] = 0;
        }else{
            ans += a[i+1];
            a[i+1] = 0;
            b[i] = b[i] - a[i+1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

bool CheckKaibun(string s) {
    int num = s.length();
    // cout << "CHECK : " << s << endl;

    //奇数の場合は真ん中を消す
    if (num % 2 == 1) {
        s.erase(s.begin() + num / 2);
        num = s.length();
    }

    string sf;
    string sb;

    for (int i=0; i<num; ++i) {
        if (i < num / 2) sf.push_back(s[i]);
        else sb.push_back(s[i]); 
    }

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

    // cout << sf << " : " << sb << endl;

    return sf == sb;
}

int main() {
    string S;
    cin >> S;

    bool result1 = CheckKaibun(S);

    int N = S.length();

    std::string S2 = S.substr(0, (N - 1)/2);
    bool result2 = CheckKaibun(S2);

    std::string S3 = S.substr((N + 3)/2 - 1, N);
    bool result3 = CheckKaibun(S3);

    cout << ((result1 && result2 && result3) ? "Yes" : "No");
    
    return 0;
}

Measured memory_bytes: 256
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

N, W = gets_i_list
wv_list = []
N.times do
  wv_list.push gets_i_list
end

wv_list.sort!{|x,y| x[0]<=>y[0]}
dp = Array.new(W + 1, 0)

wv_list.each do |w, v|
  W.downto(w) do |i|
    dp[i] = dp[i - w] + v if dp[i] < dp[i - w] + v
  end
end

puts dp.max

Measured memory_bytes: 2812
#include <stdio.h>
#include <stdbool.h>
int memo[805][805]={0};
int next[805][805]={0};
int num[805]={0};
int num2[805]={0};
int dummy[805]={0};
bool ch[805]={0};
int n,max=0;

typedef struct{
  int now;
  int dis;
}queue;

void solve(int t);
void reset();
 queue qu[805];
 int t,co=1,nnum=0;
// queue now;

int main(void){
  int ans=0,i,j;
  while(1){
    scanf("%d\n",&n);
    if(n==0)break;
    max=0;
    ans=0;
    for(i=2;i<=n;i++){
      scanf("%d",&dummy[i]);
      next[i][num[i]]=dummy[i];
      next[dummy[i]][num[dummy[i]]]=i;
      num[i]++;
      num[dummy[i]]++;
    }
    for(i=2;i<=n;i++){
      scanf("%d",&memo[i][dummy[i]]);
      memo[dummy[i]][i]=memo[i][dummy[i]];
      if(num[i]==1||num[dummy[i]]==1)ans+=memo[i][dummy[i]];
      else ans+=memo[i][dummy[i]]*3;
    }
    /*for(i=1;i<n;i++)for(j=i+1;j<=n;j++){
	if(num[i]==1||num[j]==1)ans+=memo[i][j];
	else ans+=memo[i][j]*3;
	}*/
    for(i=1;i<=n;i++){
      if(num[i]==1)ch[i]=1;
      else ch[i]=0;
    }
    for(i=1;i<=n;i++){

      if(num[i]==1)continue;
      //solve(i);
      //reset();





      co=1;
  nnum=0;
  qu[0].dis=0;
  qu[0].now=i;
  ch[i]=1;
  while(co>nnum){
    //now.dis=qu[nnum].dis;
    //now.now=qu[nnum].now;
    if(max<qu[nnum].dis){
      // printf("%d %d\n",now.dis,now.now);
      max=qu[nnum].dis;
    }
    /*for(t=1;t<=n;t++){
      if(ch[t]==1||memo[t][qu[nnum].now]==0)continue;
      qu[co].dis=qu[nnum].dis+memo[t][qu[nnum].now];
      qu[co].now=t;
      ch[t]=1;
      co++;
      }*/
    for(t=0;t<num[qu[nnum].now];t++){
      if(ch[next[qu[nnum].now][t]]==1)continue;
      qu[co].dis=qu[nnum].dis+memo[next[qu[nnum].now][t]][qu[nnum].now];
      qu[co].now=next[qu[nnum].now][t];
      ch[next[qu[nnum].now][t]]=1;
      co++;
    }
    //for(i=1;i<=n;i++)printf("%d ",ch[i]);
    //printf("\n");
    nnum++;
    }


            for(j=1;j<=n;j++){
	if(num[j]==1)ch[j]=1;
	else ch[j]=0;
      }

      
    }
    printf("%d\n",ans-max);
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)memo[i][j]=0;
    for(i=1;i<=n;i++){
      num[i]=0;
      num2[i]=0;
      dummy[i]=0;
    }
  }
  return 0;
}

void solve(int t){
  queue qu[805];
  int i,j,co=1,nnum=0;;
  queue now;
  qu[0].dis=0;
  qu[0].now=t;
  ch[t]=1;
  while(co>nnum){
    now.dis=qu[nnum].dis;
    now.now=qu[nnum].now;
    if(max<now.dis){
      // printf("%d %d\n",now.dis,now.now);
      max=now.dis;
    }
    for(i=1;i<=n;i++){
      if(ch[i]==1||memo[i][now.now]==0)continue;
      qu[co].dis=now.dis+memo[i][now.now];
      qu[co].now=i;
      ch[i]=1;
      co++;
    }
    //for(i=1;i<=n;i++)printf("%d ",ch[i]);
    //printf("\n");
    nnum++;
  }
  //printf("\n");
}
void reset(){
  int i;
  for(i=1;i<=n;i++){
    if(num[i]==1)ch[i]=1;
    else ch[i]=0;
  }
}



Measured memory_bytes: 6848
#include <cstdio>
#include <iostream>
#include <cmath>
#include <limits>
using namespace std;

int main(){
	string enki;
	cin >> enki;
	if(enki == "A"){
		cout << "T" << endl;
	}
	else if(enki == "T"){
		cout << "A" << endl;
	}
	else if(enki == "C"){
		cout << "G" << endl;
	}
	else{
		cout << "C" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int asc(const void *a, const void *b)
{
    return *(int *)a - *(int *)b;
}
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int d[200005];
    for (i = 0; i < n; i++)
        scanf("%d", &d[i]);
    int m;
    scanf("%d", &m);
    int t[200005];
    for (i = 0; i < m; i++)
        scanf("%d", &t[i]);
    if (n < m)
    {
        printf("NO\n");
        return 0;
    }
    qsort(d, n, sizeof(int), asc);
    qsort(t, m, sizeof(int), asc);
    int j = 0;
    for (i = 0; i < m; i++)
    {
        while (d[j] != t[i])
        {
            j++;
            if (j == n)
            {
                printf("NO\n");
                return 0;
            }
        }
        d[j] = -1;
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 2556
from array import array
import bisect
import collections
import heapq
import itertools
import operator
import sys


class BIT:
    def __init__(self, n):
        self.n = n
        self.arr = array("l", [0] * (n + 1))

    def __str__(self):
        return str(self.arr.tolist())

    def add(self, i, x):
        while i <= self.n:
            self.arr[i] += x
            i += i & -i

    def sum(self, i, j=None):
        if j is None:
            s = 0
            while i > 0:
                s += self.arr[i]
                i -= i & -i
            return s

        if i > j:
            raise ValueError

        return self.sum(j) - self.sum(i - 1)


def main():
    n, q = map(int, sys.stdin.readline().split())
    bit = BIT(n)

    for _ in range(q):
        query, x, y = map(int, sys.stdin.readline().split())
        if query == 0:
            bit.add(x, y)
        elif query == 1:
            print(bit.sum(x, y))
        else:
            raise ValueError


if __name__ == "__main__":
    main()



Measured memory_bytes: 7432
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll a, b;

void solve()
{
    cin >> a >> b;
    nout((a*b)/__gcd(a,b));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;
  cin>>a>>b;
  if(a>=1){
    cout << "Positive";
  }
  else if(b<=-1&&(b-a)%2==1){
    cout << "Positive";
  }
  else if(b<=-1&&(b-a)%2==0){
    cout << "Negative";
  }
  else{
    cout << "Zero";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace io{
	const int l=1<<20;
	char buf[l],*s,*t;
	inline char gc(){
		if(s==t){
			t=(s=buf)+fread(buf,1,l,stdin);
			return s==t?EOF:*s++;
		}
		return *s++;
	}
	char c;
	template<class IT>inline void gi(IT &x){
		x=0;c=gc();while(c<'0'||c>'9')c=gc();
		while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=gc();}
	}
};
using io::gi;
template<class IT>inline void _int(      IT &a,      IT &b  ){if(a>b)swap(a,b);}
template<class IT>inline void cmin(      IT &a,const IT &b=0){if(a>b)a=b;}
template<class IT>inline void cmax(      IT &a,const IT &b=0){if(a<b)a=b;}
template<class IT>inline IT   _min(const IT &a,const IT &b=0){return a>b? b:a;}
template<class IT>inline IT   _max(const IT &a,const IT &b=0){return a<b? b:a;}
template<class IT>inline IT   _abs(const IT &a              ){return a<0?-a:a;}

const int N=200005;

struct qwq{
	int a,b;
	inline qwq(){}
	inline qwq(int a,int b):a(a),b(b){}
	inline bool operator<(const qwq &x)const{return a<x.a;}
};

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<10&&b<10)printf("%d",a*b);
	else printf("-1");
	return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.math;
import std.array;

void main(){
    int N = readln().chomp().to!int();
    int[] nums;
    int[] primes;
    for(int i = 0; i < N; i++){ nums ~= readln().chomp().to!int(); }
    foreach(int n; nums){
        bool isPrime = true;
        for(int i = 2; i <= sqrt(n.to!float()); i++){
            if(n % i == 0){
                isPrime = false;
                break;
            }
        }
        if(isPrime){ primes ~= n; }
    }
    primes.length.writeln();
}

Measured memory_bytes: 1136
#include <stdio.h>

int main(void) {
    int r, g;
    scanf("%d%d", &r, &g);
    // (r + x) / 2 = g
    // (r + x) = 2 * g
    // x = 2 * g - r
    printf("%d\n", 2 * g - r);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int modpow(int x,int n){
	int res=1;
	while(n>0){
		if(n&1) res=(res*x)%MOD;
		 x=(x*x)%MOD;
		 n>>=1;
	 }
	 return res;
}
int ncr(int n,int r){
	int res=1,fact=1;
	FOR(i,1,r) fact=(fact*i)%MOD;
	rep(i,r) res=(res*(n-i))%MOD;
	res=(res*modpow(fact,MOD-2))%MOD;
	return res;
}

signed main(){
	int x,y;
	cin>>x>>y;

	if((x+y)%3!=0){
		cout<<0<<endl;
		return 0;
	}
	if(max(x,y)>2*min(x,y)){
		cout<<0<<endl;
		return 0;
	}

	int tot=(x+y)/3;
	int a=y-tot;
	// int b=x-tot;
	cout<<ncr(tot,a)<<endl;

	
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int M,D;
    cin >> M >> D;
    int ans=0;
    rep2(i,1,M+1){
        rep2(j,1,D+1){
            int a=j/10,b=j%10;
            if (a<2||b<2) continue;
            if (a*b==i) ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> a(n);
    for(ll i=0;i<n;++i)
    {
        cin>>a[i].first;
        cin>>a[i].second;
    }
    sort(a.begin(),a.end());
    ll m1=m;
    ll sum=0;
    for(ll i=0;i<n;++i)
    {
        sum+=((a[i].first)*min(a[i].second,m1));
        m1-=a[i].second;
        if(m1<0)
            break;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
import math
N = int(input())

now = 0
p = [0, 0]

for line in (map(int, input().split()) for _ in range(N)):
  t, x, y = line
  d = abs(p[0] - x) + abs(p[1] - y)
  now += d
  if now < t:
    now += math.ceil((t - now)/2)*2
  if now != t:
    print("No")
    break
  p = x, y
else:
  print("Yes")


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

typedef vector<int> vi;

int main() {
    int n;
    cin >> n;
    vi arr(n);
    for(int i=0; i<n; i++) cin >> arr[i];

    int cont = 0;
    string state = "__";
    
    if(n < 3) {
        cout << "1\n";
        return 0;
    }

    /*if(arr[0] <= arr[1]) state = "CRE";
    if(arr[0] > arr[1]) state = "DCR";*/

    for(int i=0; i<n-1; i++) {

        if(state == "__") {            
            if(arr[i] == arr[i+1]) continue;
            else if(arr[i] < arr[i+1])state = "CRE";
            else if(arr[i] > arr[i+1]) state = "DCR";
            continue;
        }

        if(arr[i] < arr[i+1] && state != "CRE") {
            cont++;

            state = "__";
            continue;
        }

        if(arr[i] > arr[i+1] && state != "DCR") {
            cont++;

            state = "__";
            continue;
        }

    }
    cout << cont + 1 << '\n';
    return 0;
}



Measured memory_bytes: 640